diff options
author | Dries Buytaert <dries@buytaert.net> | 2000-12-16 08:39:01 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2000-12-16 08:39:01 +0000 |
commit | c1a88d5d6733f1cd17fe677456cb445edd6a7afd (patch) | |
tree | 16d244b1d1ca04ec010198f5ba268bed7ca717b6 /includes/cron.inc | |
parent | 8a77861958367a0364675f93c8d49b953e4d8566 (diff) | |
download | brdo-c1a88d5d6733f1cd17fe677456cb445edd6a7afd.tar.gz brdo-c1a88d5d6733f1cd17fe677456cb445edd6a7afd.tar.bz2 |
Again, a large batch of updates - I'm twisting things around here:
1. improved .htaccess to be more "secure": to keep prying
eyes out
2. rewrote the administration section from scratch using a
modular approach
3. improved the information gathered by error.php - we can
now (hopefully) track what bots are crawling us.
4. fixed a bug in submit.php, fixed a bug in theme zaphod,
fixed a bug in theme marvin.
5. rewrote cron from scratch - it now interfaces with
modules as it should have been from the beginning.
Very cool if you ask me - it can use UNIX/Linux
crontabs.
6. updated widget.inc to be module aware - needs more
work though - maybe this afternoon?
7. updated most modules: small bugfixes, improvements, and
even the documentation
8. removed diary.php and made it a module - you can now
run a drop.org site without a diary system if someone
would prefer so
9. updated all themes to use the new modules where
appropriate
10. added a robots.txt because the error message in the
watchdog become annoying.
11. added the new configuration system (mutliple vhosts
on the same source tree) - use hostname.conf instead
of config.inc
12. removed calendar.inc and made it a module
13. added format_interval() to functions.inc (UnConeD)
14. whatever I forgot ...
Diffstat (limited to 'includes/cron.inc')
-rw-r--r-- | includes/cron.inc | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/includes/cron.inc b/includes/cron.inc index 59ff0a07c..4cfb74fb8 100644 --- a/includes/cron.inc +++ b/includes/cron.inc @@ -1,24 +1,41 @@ <? -function cron_add($name, $help, $code, $scheduled, $message = "") { - if (empty($name) || empty($code) || empty($scheduled)) { +include "includes/theme.inc"; + +function cron_set($module, $scheduled, $message = "") { + if (empty($module) || empty($scheduled)) { $message = "failed: information missing"; } + else if (db_fetch_object(db_query("SELECT * FROM cron WHERE module = '$module'"))) { + db_query("UPDATE cron SET scheduled = $scheduled WHERE module = '$module'"); + } else { - $result = db_query("INSERT INTO cron (name, help, code, scheduled) VALUES ('". check_input($name) ."', '". check_input($help) ."', '". check_code($code) ."', '". check_input($scheduled) ."')"); + db_query("INSERT INTO cron (module, scheduled, timestamp) VALUES ('". check_input($module) ."', '". check_input($scheduled) ."', '42')"); } } -function cron_delete($id) { - $result = db_query("DELETE FROM cron WHERE id = $id"); +function cron_get($module) { + return db_fetch_object(db_query("SELECT * FROM cron WHERE module = '$module'"), 0); +} + +function cron_delete($module) { + $result = db_query("DELETE FROM cron WHERE module = '$module'"); } -function cron_execute($cron) { - eval($cron->code); +function cron_run($cron) { + $time = time(); - db_query("UPDATE cron SET timestamp = '". time() ."' WHERE id = $cron->id"); + $result = db_query("SELECT * FROM cron WHERE $time - timestamp > scheduled"); + + while ($task = db_fetch_object($result)) { + include "modules/". $task->module .".module"; + if ($function = $module["cron"]) { + watchdog("message", "cron: executed '". $task->module ."_cron()'"); + $function(); + } + } - watchdog("message", "cron: executed '$cron->name'"); + db_query("UPDATE cron SET timestamp = $time WHERE $time - timestamp > scheduled"); } ?> |