function lc_CheckRuntime in Link checker 5
2 calls to lc_CheckRuntime()
- lc_DoLinkChecks in ./
linkchecker.module - linkchecker_cron in ./
linkchecker.module - Implementation of hook_cron() Rebuild the table if necessary.
File
- ./
linkchecker.module, line 382 - This module periodically check html links referenced by drupal nodes Developed and maintained by Marek Tichy, marek@ecn.cz
Code
function lc_CheckRuntime($maxtime) {
d_("Checking time, max time is {$maxtime} seconds");
/* TASK ID 0 is used in a special way
taskid - 0
nodeid - timestamp of the last database rebuild
status - 1 - running, 0 - not running
update - timestamp of the last start
*/
$res = db_query("SELECT * FROM `linkchecker_tasks` WHERE taskid=0;");
$foo = db_fetch_array($res);
if (empty($foo)) {
// the 0 record is missing, add it
$sql = "INSERT INTO `linkchecker_tasks` VALUES (0," . lc_now_to_int() . ",0,NOW());";
db_query($sql);
d_("Cannot find time record, adding it: {$sql}.");
$foo["status"] = 0;
}
if ($foo["status"] == 0) {
// not running yet
d_("Setting the process state to 1 (running)");
db_query("UPDATE `linkchecker_tasks` SET `status` = 1, `update` = NOW() WHERE taskid=0;");
$time = 0;
}
else {
// has been running for a while, check time
$time = time() - strtotime($foo["update"]);
d_("Time record found, it says we have been running since {$foo['update']}, which is {$time} seconds ago.");
}
if ($time < $maxtime) {
//
$ret = true;
d_("Time left:" . ($maxtime - $time));
d_("Memory usage:" . number_format(memory_get_usage(), 0, '.', ',') . " bytes");
}
else {
d_("No time left, switching to state 0 (not running)");
db_query("UPDATE `linkchecker_tasks` SET `status` = 0, `update` = NOW() WHERE taskid=0;");
$ret = false;
}
return $ret;
}