From d236a5cedafc1091a7d7be0392e0c7917d331288 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Mon, 22 Feb 2010 12:24:45 +0000 Subject: [PATCH] - setting version to 0.9.2 - checking for sane last-system-guid on update - added a bit of cronlogging to ApsUpdater (only in paranoid mode) --- install/froxlor.sql | 2 +- .../updates/froxlor/0.9/update_0.9.inc.php | 11 +++++++++++ lib/classes/aps/class.ApsUpdater.php | 19 +++++++++++++++---- lib/tables.inc.php | 2 +- scripts/jobs/cron_apsupdater.php | 2 +- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/install/froxlor.sql b/install/froxlor.sql index 7cdf08e3..efe4bf87 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -451,7 +451,7 @@ INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) V INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (18, 'system', 'vmail_homedir', '/var/customers/mail/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (19, 'system', 'bindconf_directory', '/etc/bind/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (20, 'system', 'bindreload_command', '/etc/init.d/bind9 reload'); -INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '0.9.1'); +INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '0.9.2'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (23, 'system', 'hostname', 'SERVERNAME'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (24, 'login', 'maxloginattempts', '3'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (25, 'login', 'deactivatetime', '900'); 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 c169345f..17dae86f 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -287,4 +287,15 @@ if(isFroxlorVersion('0.9')) updateToVersion('0.9.1'); } +if(isFroxlorVersion('0.9.1')) +{ + showUpdateStep("Updating from 0.9.1 to 0.9.2", false); + + showUpdateStep("Checking wether last-system-guid is sane"); + checkLastGuid($settings['system']['lastguid']); + + lastStepStatus(0); + updateToVersion('0.9.2'); +} + ?> diff --git a/lib/classes/aps/class.ApsUpdater.php b/lib/classes/aps/class.ApsUpdater.php index e23a96f3..ac4f6598 100644 --- a/lib/classes/aps/class.ApsUpdater.php +++ b/lib/classes/aps/class.ApsUpdater.php @@ -31,6 +31,12 @@ class ApsUpdater extends ApsParser private $RequestDomain = ''; private $RootUrl = ''; private $RootDir = ''; + + /** + * FroxlorLogger + * @var FroxlorLogger + */ + private $_cronlog = null; /** * constructor of class. setup some basic variables needed by class @@ -38,12 +44,13 @@ class ApsUpdater extends ApsParser * @param db instance of the database class from syscp */ - public function __construct($db) + public function __construct($db, $cronlog) { $this->db = $db; $this->RequestDomain = 'apscatalog.com'; $this->RootUrl = '/1/'; $this->RootDir = dirname(dirname(dirname(dirname(__FILE__)))) . '/'; + $this->_cronlog = $cronlog; } /** @@ -52,12 +59,14 @@ class ApsUpdater extends ApsParser public function UpdateHandler() { + $this->_cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Changing directory to '" . $this->RootDir . "'"); chdir($this->RootDir); //return if allow_url_fopen is disabled if(!ini_get('allow_url_fopen')) { + $this->_cronlog->logAction(CRON_ACTION, LOG_ERROR, "The APS updater cronjob requires that allow_url_fopen is enabled for the PHP CLI binary!"); echo "The APS updater cronjob requires that allow_url_fopen is enabled for the PHP CLI binary!\n"; return; } @@ -68,6 +77,7 @@ class ApsUpdater extends ApsParser if($this->db->num_rows($Result) == 0) { + $this->_cronlog->logAction(CRON_ACTION, LOG_NOTICE, "No tasks for ApsUpdater"); return; } @@ -77,20 +87,21 @@ class ApsUpdater extends ApsParser $this->db->query('DELETE FROM `' . TABLE_APS_TASKS . '` WHERE `Task` = ' . $Task['Task']); //fetch all vendors - + $this->_cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Fetching all Vendors from '" . $this->RootUrl . "'"); $Vendors = self::FetchSubUrls($this->RootUrl); if($Vendors !== false) { foreach($Vendors as $Vendor) { //fetch all applications from vendors - + $this->_cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Fetching all from Vendor '" . $Vendor. "'"); $Applications = self::FetchSubUrls($this->RootUrl . $Vendor); if($Applications !== false) { foreach($Applications as $Application) { //get newest version of package which is already installed + $this->_cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Checking application '" . substr($Application, 0, -1) . "'"); $CurrentVersion = ''; $Result = $this->db->query('SELECT * FROM `' . TABLE_APS_PACKAGES . '` WHERE `Name` = "' . $this->db->escape(substr($Application, 0, -1)) . '"'); @@ -193,7 +204,7 @@ class ApsUpdater extends ApsParser $Url = str_replace(' ', '%20', $Url); //get content from website url - + $this->_cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Downloading '" . 'http://' . $this->RequestDomain . $Url . '.aps' . $Downloads[0] . "'"); $Content = @file_get_contents('http://' . $this->RequestDomain . $Url . '.aps' . $Downloads[0]); if($Content != false) diff --git a/lib/tables.inc.php b/lib/tables.inc.php index cf2142e0..33f9cb96 100644 --- a/lib/tables.inc.php +++ b/lib/tables.inc.php @@ -68,7 +68,7 @@ define('PACKAGE_ENABLED', 2); // VERSION INFO -$version = '0.9.1'; +$version = '0.9.2'; $dbversion = '2'; ?> diff --git a/scripts/jobs/cron_apsupdater.php b/scripts/jobs/cron_apsupdater.php index 130844be..2a4ec14f 100644 --- a/scripts/jobs/cron_apsupdater.php +++ b/scripts/jobs/cron_apsupdater.php @@ -17,7 +17,7 @@ * @version $Id$ */ -$Aps = new ApsUpdater($db); +$Aps = new ApsUpdater($db, $cronlog); $Aps->UpdateHandler(); ?>