diff options
author | Dries Buytaert <dries@buytaert.net> | 2002-04-08 19:50:28 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2002-04-08 19:50:28 +0000 |
commit | 5d9a8e34a97aaa8b70ad05800a432e7a13bf6598 (patch) | |
tree | ef5d869b5833c26a15b2747769e663b0b2d8052f /modules/cloud.module | |
parent | 9e4e2dd57c2c8876fc74b659671466910d078407 (diff) | |
download | brdo-5d9a8e34a97aaa8b70ad05800a432e7a13bf6598.tar.gz brdo-5d9a8e34a97aaa8b70ad05800a432e7a13bf6598.tar.bz2 |
- Made the cloud module a lot more configurable: both the update interval
and the number of bytes required for an update, can be changed now.
Diffstat (limited to 'modules/cloud.module')
-rw-r--r-- | modules/cloud.module | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/modules/cloud.module b/modules/cloud.module index 2e2451311..16ea99b0a 100644 --- a/modules/cloud.module +++ b/modules/cloud.module @@ -18,12 +18,7 @@ function cloud_help($type = "administrator") { } function cloud_cron() { - if (time() % 25 == 0) { - $result = db_query("SELECT * FROM site"); - } - else { - $result = db_query("SELECT * FROM site WHERE timestamp > ". (time() - 604800)); - } + $result = db_query("SELECT * FROM site WHERE timestamp = 0 OR timestamp + refresh < ". time()); while ($site = db_fetch_array($result)) { cloud_update($site); @@ -69,7 +64,7 @@ function cloud_update($site) { $data .= fgets($fp, 128); } - if (abs($site["size"] - strlen($data)) > 50) { + if (abs($site["size"] - strlen($data)) > $site["threshold"]) { db_query("UPDATE site SET size = '". strlen($data) ."', timestamp = '". time() ."' WHERE link = '". check_input($site["link"]) ."'"); } @@ -82,10 +77,14 @@ function cloud_update($site) { function cloud_form($edit = array()) { + $period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200)); + $threshold = array (0 => "0 bytes", 10 => "10 bytes", 20 => "20 bytes", 40 => "40 bytes", 60 => "60 bytes", 80 => "80 bytes", 160 => "160 bytes", 320 => "320 bytes", 640 => "640 bytes"); $form .= form_textfield("Site name", "name", $edit["name"], 50, 128, "The name of the website you want to monitor for updates."); $form .= form_textfield("Site URL", "link", $edit["link"], 50, 255, "The URL of the website you want to monitor for updates."); $form .= form_textfield("URL to monitor", "feed", $edit["feed"], 50, 255, "The URL of the page you want to monitor for updates. Likely to be same as the site's URL but useful to monitor framed pages and more accurate when pointed to a XML/RSS/RDF feed."); + $form .= form_select("Update interval", "refresh", ($edit["refresh"] ? $edit["refresh"] : 3600), $period, "The refresh interval indicating how often you want to check this site for updates. Requires crontab."); + $form .= form_select("Change threshold", "threshold", ($edit["threshold"] ? $edit["threshold"] : 40), $threshold, "The number of bytes the site must have been modified before concidered changed."); $form .= form_submit("Submit"); @@ -103,13 +102,13 @@ function cloud_get_site($sid) { function cloud_save($edit) { if ($edit["sid"] && $edit["name"]) { - db_query("UPDATE site SET name = '". check_input($edit["name"]) ."', link = '". check_input($edit["link"]) ."', feed = '". check_input($edit["feed"]) ."' WHERE sid = '". check_input($edit["sid"]) ."'"); + db_query("UPDATE site SET name = '". check_input($edit["name"]) ."', link = '". check_input($edit["link"]) ."', feed = '". check_input($edit["feed"]) ."', refresh = '". check_input($edit["refresh"]) ."', threshold = '". check_input($edit["threshold"]) ."' WHERE sid = '". check_input($edit["sid"]) ."'"); } else if ($edit["sid"]) { db_query("DELETE FROM site WHERE sid = '". check_input($edit["sid"]) ."'"); } else { - db_query("INSERT INTO site (name, link, feed) VALUES ('". check_input($edit["name"]) ."', '". check_input($edit["link"]) ."', '". check_input($edit["feed"]) ."')"); + db_query("INSERT INTO site (name, link, feed, refresh, threshold) VALUES ('". check_input($edit["name"]) ."', '". check_input($edit["link"]) ."', '". check_input($edit["feed"]) ."', '". check_input($edit["refresh"]) ."', '". check_input($edit["threshold"]) ."')"); } } |