diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-06-01 06:46:55 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-06-01 06:46:55 +0000 |
commit | e5033fe1cf07caeb61e72dfe1ae9a7b07f5406c0 (patch) | |
tree | 42a05e1a99c3dd54b80e57f77f9500a9a9b0015d /modules/cloud.module | |
parent | 882c3f6d2d6d82513b94cf6b719e01e803a33cf1 (diff) | |
download | brdo-e5033fe1cf07caeb61e72dfe1ae9a7b07f5406c0.tar.gz brdo-e5033fe1cf07caeb61e72dfe1ae9a7b07f5406c0.tar.bz2 |
- Fixed critical bug #1788: cloud module pings too much. Modified patch by
Kjartan.
This update requires some database changes so make sure to run update.php.
Diffstat (limited to 'modules/cloud.module')
-rw-r--r-- | modules/cloud.module | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/cloud.module b/modules/cloud.module index 45e5ae764..d85473e4e 100644 --- a/modules/cloud.module +++ b/modules/cloud.module @@ -23,7 +23,7 @@ function cloud_system($field){ } function cloud_cron() { - $result = db_query("SELECT * FROM site WHERE timestamp = 0 OR timestamp + refresh < ". time()); + $result = db_query("SELECT * FROM site WHERE checked = 0 OR checked + refresh < %d", time()); while ($site = db_fetch_array($result)) { cloud_update($site); @@ -78,7 +78,10 @@ function cloud_update($site) { } if (abs($site["size"] - strlen($data)) >= $site["threshold"]) { - db_query("UPDATE site SET size = '". strlen($data) ."', timestamp = '". time() ."' WHERE link = '%s'", $site["link"]); + db_query("UPDATE site SET size = %d, changed = %d, checked = %d WHERE link = '%s'", strlen($data), time(), time(), $site["link"]); + } + else { + db_query("UPDATE site SET checked = %d WHERE link = '%s'", time(), $site["link"]); } fclose($fp); @@ -130,22 +133,22 @@ function cloud_display() { $header = array(t("site"), t("last update"), array("data" => t("operations"), "colspan" => 2)); while ($site = db_fetch_object($result)) { - $rows[] = array("<a href=\"$site->link\">$site->name</a>", ($site->timestamp ? format_interval(time() - $site->timestamp) ." ago" : "never"), l(t("edit site"), "admin/syndication/cloud/edit/$site->sid"), l(t("update site"), "admin/syndication/cloud/update/$site->sid")); + $rows[] = array("<a href=\"$site->link\">$site->name</a>", ($site->changed ? format_interval(time() - $site->changed) ." ago" : "never"), l(t("edit site"), "admin/syndication/cloud/edit/$site->sid"), l(t("update site"), "admin/syndication/cloud/update/$site->sid")); } return table($header, $rows); } function cloud_list($limit = 10) { - $result = db_query_range("SELECT * FROM site WHERE timestamp > ". (time() - 604800) ." ORDER BY timestamp DESC", 0, $limit); + $result = db_query_range("SELECT * FROM site WHERE changed > ". (time() - 604800) ." ORDER BY changed DESC", 0, $limit); $hour = -1; $list = -1; $inlist = false; $output .= "<div class=\"item-list\">"; while ($site = db_fetch_object($result)) { - if ($hour != floor((time() - $site->timestamp) / 3600)) { - $hour = floor((time() - $site->timestamp) / 3600); + if ($hour != floor((time() - $site->changed) / 3600)) { + $hour = floor((time() - $site->changed) / 3600); if ($hour < 12) { if ($inlist) { $output .= "</ul>"; |