From b289a6746adb64228b34e9a82924325c17f91f83 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Thu, 25 Feb 2010 07:05:23 +0000 Subject: [PATCH] - improved last-guid sanity check on update to 0.9.1, fixes #34 - replacing deprecated functions in PHP-5.3 (no external libraries for now like phpmailer), refs #35 --- install/updates/froxlor/0.9/update_0.9.inc.php | 13 +++++++++++-- lib/classes/aps/class.ApsParser.php | 2 +- lib/functions/froxlor/function.updateFunctions.php | 8 ++++---- lib/functions/system/function.checklastguid.php | 3 ++- 4 files changed, 18 insertions(+), 8 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 7c78303b..2392de0c 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -292,9 +292,18 @@ if(isFroxlorVersion('0.9.1')) showUpdateStep("Updating from 0.9.1 to 0.9.2", false); showUpdateStep("Checking whether last-system-guid is sane"); - checkLastGuid($settings['system']['lastguid']); - lastStepStatus(0); + $result = $db->query_first("SELECT MAX(`guid`) as `latestguid` FROM `".TABLE_PANEL_CUSTOMERS."`"); + + if (isset($result['latestguid']) + && (int)$result['latestguid'] > 0 + && $result['latestguid'] != $settings['system']['lastguid'] + ) { + checkLastGuid($result['latestguid']); + lastStepStatus(1, 'fixed'); + } else { + lastStepStatus(0); + } updateToVersion('0.9.2'); } diff --git a/lib/classes/aps/class.ApsParser.php b/lib/classes/aps/class.ApsParser.php index dd74b6dc..41b85395 100644 --- a/lib/classes/aps/class.ApsParser.php +++ b/lib/classes/aps/class.ApsParser.php @@ -843,7 +843,7 @@ class ApsParser { //split all keywords - $Elements = split('[ ,;]', trim($_GET['keyword'])); + $Elements = preg_split('/[ ,;]/', trim($_GET['keyword'])); if(count($Elements) == 1 && strlen($Elements[0]) == 0) diff --git a/lib/functions/froxlor/function.updateFunctions.php b/lib/functions/froxlor/function.updateFunctions.php index 918468e5..472e97b7 100644 --- a/lib/functions/froxlor/function.updateFunctions.php +++ b/lib/functions/froxlor/function.updateFunctions.php @@ -138,22 +138,22 @@ function showUpdateStep($task = null, $needs_status = true) * * @return string formatted output and log-entry */ -function lastStepStatus($status = -1) +function lastStepStatus($status = -1, $message = '') { global $updatelog; switch($status) { case 0: - $status_sign = '[OK]'; + $status_sign = ($message != '') ? '['.$message.']' : '[OK]'; $status_color = '1dcd00'; break; case 1: - $status_sign = '[??]'; + $status_sign = ($message != '') ? '['.$message.']' : '[??]'; $status_color = 'db7100'; break; case 2: - $status_sign = '[!!]'; + $status_sign = ($message != '') ? '['.$message.']' : '[!!]'; $status_color = 'ff0000'; break; default: diff --git a/lib/functions/system/function.checklastguid.php b/lib/functions/system/function.checklastguid.php index 85817590..c3957182 100644 --- a/lib/functions/system/function.checklastguid.php +++ b/lib/functions/system/function.checklastguid.php @@ -64,7 +64,7 @@ function checkLastGuid($froxlor_guid = 0) continue; } - $guid = (int)$group[2]; + $guid = isset($group[2]) ? (int)$group[2] : 0; if($guid > $froxlor_guid) { @@ -76,6 +76,7 @@ function checkLastGuid($froxlor_guid = 0) { $cronlog->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