fixing function checkLastGuid()

This commit is contained in:
Michael Kaufmann (d00p)
2010-03-01 17:43:47 +00:00
parent 91d461b122
commit 0cd452de28
3 changed files with 18 additions and 9 deletions

View File

@@ -299,7 +299,7 @@ if(isFroxlorVersion('0.9.1'))
&& (int)$result['latestguid'] > 0 && (int)$result['latestguid'] > 0
&& $result['latestguid'] != $settings['system']['lastguid'] && $result['latestguid'] != $settings['system']['lastguid']
) { ) {
checkLastGuid($result['latestguid']); checkLastGuid();
lastStepStatus(1, 'fixed'); lastStepStatus(1, 'fixed');
} else { } else {
lastStepStatus(0); lastStepStatus(0);

View File

@@ -29,9 +29,9 @@
* *
* @return null * @return null
*/ */
function checkLastGuid($froxlor_guid = 0) function checkLastGuid()
{ {
global $log, $cronlog; global $log, $cronlog, $db, $settings;
$mylog = null; $mylog = null;
if (isset($cronlog) && $cronlog instanceof FroxlorLogger) { if (isset($cronlog) && $cronlog instanceof FroxlorLogger) {
@@ -44,6 +44,10 @@ function checkLastGuid($froxlor_guid = 0)
$group_guids = array(); $group_guids = array();
$update_to_guid = 0; $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'; $g_file = '/etc/group';
if(file_exists($g_file)) if(file_exists($g_file))
@@ -73,19 +77,24 @@ function checkLastGuid($froxlor_guid = 0)
$guid = isset($group[2]) ? (int)$group[2] : 0; $guid = isset($group[2]) ? (int)$group[2] : 0;
if($guid > $froxlor_guid) if($guid > $update_to_guid)
{ {
$update_to_guid = $guid; $update_to_guid = $guid;
} }
} }
if($update_to_guid > $froxlor_guid) if($update_to_guid < $froxlor_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); $mylog->logAction(CRON_ACTION, LOG_NOTICE, 'Updating froxlor last guid to '.$update_to_guid);
saveSetting('system', 'lastguid', $update_to_guid); saveSetting('system', 'lastguid', $update_to_guid);
$settings['system']['lastguid'] = $update_to_guid; $settings['system']['lastguid'] = $update_to_guid;
} }
} }
}
else else
{ {
$mylog->logAction(CRON_ACTION, LOG_NOTICE, 'File /etc/group not readable; cannot check for latest guid'); $mylog->logAction(CRON_ACTION, LOG_NOTICE, 'File /etc/group not readable; cannot check for latest guid');

View File

@@ -32,7 +32,7 @@ fwrite($debugHandler, 'Cronfiles have been included' . "\n");
* so users in the database don't conflict with system users * so users in the database don't conflict with system users
*/ */
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Checking system\'s last guid'); $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Checking system\'s last guid');
checkLastGuid($settings['system']['lastguid']); checkLastGuid();
/* /*
* shutdown cron * shutdown cron