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");
$res = db_query("SELECT * FROM `linkchecker_tasks` WHERE taskid=0;");
$foo = db_fetch_array($res);
if (empty($foo)) {
$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) {
d_("Setting the process state to 1 (running)");
db_query("UPDATE `linkchecker_tasks` SET `status` = 1, `update` = NOW() WHERE taskid=0;");
$time = 0;
}
else {
$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;
}