diff --git a/install/froxlor.sql b/install/froxlor.sql index 2ba6617d..09269f03 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -919,3 +919,30 @@ CREATE TABLE IF NOT EXISTS `aps_temp_settings` ( `Value` varchar(250) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM; + +# -------------------------------------------------------- + +# +# Tabellenstruktur fuer Tabelle `cronjobs_run` +# + +CREATE TABLE IF NOT EXISTS `cronjobs_run` ( + `id` bigint(20) NOT NULL auto_increment, + `cronfile` varchar(250) NOT NULL, + `lastrun` int(15) NOT NULL DEFAULT '0', + `interval` INTERVAL DEFAULT '5M', + PRIMARY KEY (`id`) +) ENGINE=MyISAM; + +# +# Dumping data for table `panel_phpconfigs` +# + +INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (1, 'cron_tasks.php', '5M'); +INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (2, 'cron_legacy.php', '5M'); +INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (3, 'cron_apsinstaller.php', '5M'); +INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (4, 'cron_autoresponder.php', '5M'); +INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (5, 'cron_apsupdater.php', '1H'); +INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (6, 'cron_traffic.php', '1D'); +INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (7, 'cron_used_tickets_reset.php', '1M'); +INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (8, 'cron_ticketarchive.php', '1M'); 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 2cdf4549..2a5c9de9 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -84,18 +84,47 @@ if($settings['panel']['frontend'] == 'froxlor' && $settings['panel']['version'] == '0.9-r2') { $updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 0.9-r2 to 0.9-r3"); - + $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'debug_cron', '0');"); $db->query("ALTER TABLE `" . TABLE_MAIL_AUTORESPONDER . "` ADD `date_from` int(15) NOT NULL default '-1' AFTER `enabled`"); $db->query("ALTER TABLE `" . TABLE_MAIL_AUTORESPONDER . "` ADD `date_until` int(15) NOT NULL default '-1' AFTER `date_from`"); - + // set new version $query = 'UPDATE `%s` SET `value` = \'0.9-r3\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\''; $query = sprintf($query, TABLE_PANEL_SETTINGS); $db->query($query); - $settings['panel']['version'] = '0.9-r3'; + $settings['panel']['version'] = '0.9-r3'; } +if($settings['panel']['frontend'] == 'froxlor' +&& $settings['panel']['version'] == '0.9-r3') +{ + $updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 0.9-r3 to 0.9-r4"); + + $db->query("CREATE TABLE IF NOT EXISTS `cronjobs_run` ( + `id` bigint(20) NOT NULL auto_increment, + `cronfile` varchar(250) NOT NULL, + `lastrun` int(15) NOT NULL DEFAULT '0', + `interval` INTERVAL DEFAULT '5M', + PRIMARY KEY (`id`) + ) ENGINE=MyISAM;"); + + $db->query("INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (1, 'cron_tasks.php', '5M');"); + $db->query("INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (2, 'cron_legacy.php', '5M');"); + $db->query("INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (3, 'cron_apsinstaller.php', '5M');"); + $db->query("INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (4, 'cron_autoresponder.php', '5M');"); + $db->query("INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (5, 'cron_apsupdater.php', '1H');"); + $db->query("INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (6, 'cron_traffic.php', '1D');"); + $db->query("INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (7, 'cron_used_tickets_reset.php', '1M');"); + $db->query("INSERT INTO `cronjobs_run` (`id`, `cronfile`, `interval`) VALUES (8, 'cron_ticketarchive.php', '1M');"); + + // set new version + + $query = 'UPDATE `%s` SET `value` = \'0.9-r4\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\''; + $query = sprintf($query, TABLE_PANEL_SETTINGS); + $db->query($query); + $settings['panel']['version'] = '0.9-r4'; +} ?> diff --git a/lib/functions/filedir/function.getNextCronjobs.php b/lib/functions/filedir/function.getNextCronjobs.php new file mode 100644 index 00000000..afa27b27 --- /dev/null +++ b/lib/functions/filedir/function.getNextCronjobs.php @@ -0,0 +1,28 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Functions + * @version $Id: $ + */ + +/* + * Function getNextCronjobs + * + * checks which cronjobs have to be executed + * + * @return array array of cron-files which are to be executed + */ +function getNextCronjobs() +{ + // SELECT `interval`, `lastrun` FROM `".PANEL_TABLE_CRONRUNS."` +} diff --git a/lib/functions/froxlor/function.includeCronjobs.php b/lib/functions/froxlor/function.includeCronjobs.php index 83e9d180..f42fb60d 100644 --- a/lib/functions/froxlor/function.includeCronjobs.php +++ b/lib/functions/froxlor/function.includeCronjobs.php @@ -15,30 +15,12 @@ * @version $Id: $ */ -function includeCronjobs($path, $debugHandler) +function includeCronjobs($debugHandler) { - $cronbasedir = makeCorrectDir($path); - $crondir = new DirectoryIterator($cronbasedir); - - foreach($crondir as $file) + $cronjobs = getNextCronjobs(); + + if($cronjobs !== false) { - if($file->isDot()) continue; - - if($file->isFile()) - { - if(fileowner(__FILE__) == $file->getOwner() - && filegroup(__FILE__) == $file->getGroup() - && $file->isReadable()) - { - fwrite($debugHandler, 'Including ...' . $file->getPathname() . "\n"); - include_once($file->getPathname()); - } - else - { - fwrite($debugHandler, 'WARNING! uid and/or gid of "' . __FILE__ . '" and "' . $file->getPathname() . '" don\'t match! Execution aborted!' . "\n"); - fclose($debugHandler); - die('WARNING! uid and/or gid of "' . __FILE__ . '" and "' . $file->getPathname() . '" don\'t match! Execution aborted!'); - } - } + // [...] } } diff --git a/lib/tables.inc.php b/lib/tables.inc.php index 62c3207c..8fa66eb6 100644 --- a/lib/tables.inc.php +++ b/lib/tables.inc.php @@ -67,7 +67,7 @@ define('PACKAGE_ENABLED', 2); // VERSION INFO -$version = '0.9-r3'; +$version = '0.9-r4'; $dbversion = '2'; ?> diff --git a/scripts/froxlor_master_cronjob.php b/scripts/froxlor_master_cronjob.php index ba6f8f2d..33d4d9f7 100644 --- a/scripts/froxlor_master_cronjob.php +++ b/scripts/froxlor_master_cronjob.php @@ -17,41 +17,9 @@ include_once(dirname(__FILE__) . '/../lib/cron_init.php'); -/* - * include jobs that run always (5 minutes if cron is setup that way) - */ -includeCronjobs($pathtophpfiles . '/scripts/jobs/always/', $debugHandler); - -/* - * include hourly jobs - */ -$today = time(); -if(date('i', $today) == '00') -{ - includeCronjobs($pathtophpfiles . '/scripts/jobs/hourly/', $debugHandler); -} - -/* - * include daily jobs (once a day) - */ -$today = time(); -if(date('Hi', $today) == '0000') -{ - includeCronjobs($pathtophpfiles . '/scripts/jobs/daily/', $debugHandler); -} - -/* - * include daily jobs (once a day) - */ -$today = time(); -if(date('dHi', $today) == '010000') -{ - includeCronjobs($pathtophpfiles . '/scripts/jobs/monthly/', $debugHandler); -} - +includeCronjobs($debugHandler); fwrite($debugHandler, 'Cronfiles have been included' . "\n"); - /* * we have to check the system's last guid with every cron run * in case the admin installed new software which added a new user