From 0cd452de282b5bf605293f28fd751cfa27f756e3 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Mon, 1 Mar 2010 17:43:47 +0000 Subject: [PATCH] fixing function checkLastGuid() --- .../updates/froxlor/0.9/update_0.9.inc.php | 2 +- .../system/function.checklastguid.php | 23 +++++++++++++------ scripts/froxlor_master_cronjob.php | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index 2392de0c..48f300af 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -299,7 +299,7 @@ if(isFroxlorVersion('0.9.1')) && (int)$result['latestguid'] > 0 && $result['latestguid'] != $settings['system']['lastguid'] ) { - checkLastGuid($result['latestguid']); + checkLastGuid(); lastStepStatus(1, 'fixed'); } else { lastStepStatus(0); diff --git a/lib/functions/system/function.checklastguid.php b/lib/functions/system/function.checklastguid.php index 34f4c0e1..6ec43986 100644 --- a/lib/functions/system/function.checklastguid.php +++ b/lib/functions/system/function.checklastguid.php @@ -29,9 +29,9 @@ * * @return null */ -function checkLastGuid($froxlor_guid = 0) +function checkLastGuid() { - global $log, $cronlog; + global $log, $cronlog, $db, $settings; $mylog = null; if (isset($cronlog) && $cronlog instanceof FroxlorLogger) { @@ -43,6 +43,10 @@ function checkLastGuid($froxlor_guid = 0) $group_lines = array(); $group_guids = array(); $update_to_guid = 0; + + $froxlor_guid = 0; + $result = $db->query_first("SELECT MAX(`guid`) as `fguid` FROM `".TABLE_PANEL_CUSTOMERS."`"); + $froxlor_guid = $result['fguid']; $g_file = '/etc/group'; @@ -73,17 +77,22 @@ function checkLastGuid($froxlor_guid = 0) $guid = isset($group[2]) ? (int)$group[2] : 0; - if($guid > $froxlor_guid) + if($guid > $update_to_guid) { $update_to_guid = $guid; } } - if($update_to_guid > $froxlor_guid) + if($update_to_guid < $froxlor_guid) { - $mylog->logAction(CRON_ACTION, LOG_NOTICE, 'Updating froxlor last guid to '.$update_to_guid); - saveSetting('system', 'lastguid', $update_to_guid); - $settings['system']['lastguid'] = $update_to_guid; + $update_to_guid = $froxlor_guid; + + if ($update_to_guid != $settings['system']['lastguid']) + { + $mylog->logAction(CRON_ACTION, LOG_NOTICE, 'Updating froxlor last guid to '.$update_to_guid); + saveSetting('system', 'lastguid', $update_to_guid); + $settings['system']['lastguid'] = $update_to_guid; + } } } else diff --git a/scripts/froxlor_master_cronjob.php b/scripts/froxlor_master_cronjob.php index 41a8b8b8..c09ea87c 100644 --- a/scripts/froxlor_master_cronjob.php +++ b/scripts/froxlor_master_cronjob.php @@ -32,7 +32,7 @@ fwrite($debugHandler, 'Cronfiles have been included' . "\n"); * so users in the database don't conflict with system users */ $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Checking system\'s last guid'); -checkLastGuid($settings['system']['lastguid']); +checkLastGuid(); /* * shutdown cron