function postqueue() { $unix = new unix(); if (!$GLOBALS["FORCE"]) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $oldpid = @file_get_contents($pidfile); if ($unix->process_exists($oldpid)) { echo __FUNCTION__ . " already executed pid {$oldpid}\n"; return; } @file_put_contents($pidfile, getmypid()); } $f = array(); foreach (glob("/var/log/artica-postfix/postqueue/*.array") as $filename) { $f[] = $filename; } if (count($f) > 0) { $q = new mysql(); $q->QUERY_SQL("truncate table postqueue", "artica_events"); while (list($index, $filename) = each($f)) { if (postqueue_parse($filename)) { events("postqueue():: Success parsing " . basename($filename)); @unlink($filename); } } } shell_exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.watchdog.postfix.queue.php >/dev/null 2>&1 &"); }
function postqueue() { $unix = new unix(); if (!$GLOBALS["FORCE"]) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid)) { echo __FUNCTION__ . " already executed pid {$pid}\n"; return; } @file_put_contents($pidfile, getmypid()); } if (system_is_overloaded()) { return; } $DirPath = "{$GLOBALS["ARTICALOGDIR"]}/postqueue"; if (!($handle = opendir($DirPath))) { if ($GLOBALS["VERBOSE"]) { echo "{$DirPath} ERROR\n"; } return; } $c = 0; while (false !== ($file = readdir($handle))) { if ($file == ".") { continue; } if ($file == "..") { continue; } if (is_dir("{$DirPath}/{$file}")) { if ($GLOBALS["VERBOSE"]) { echo "{$DirPath}/{$file} -> DIR\n"; } continue; } $filename = "{$DirPath}/{$file}"; $time = $unix->file_time_min($filename); if ($time > 180) { @unlink($filename); continue; } $c++; } if ($c == 0) { return; } $q = new mysql(); $q->QUERY_SQL("truncate table postqueue", "artica_events"); if (!($handle = opendir($DirPath))) { if ($GLOBALS["VERBOSE"]) { echo "{$DirPath} ERROR\n"; } return; } $c = 0; while (false !== ($file = readdir($handle))) { if ($file == ".") { continue; } if ($file == "..") { continue; } if (is_dir("{$DirPath}/{$file}")) { if ($GLOBALS["VERBOSE"]) { echo "{$DirPath}/{$file} -> DIR\n"; } continue; } $filename = "{$DirPath}/{$file}"; if (postqueue_parse($filename)) { events("postqueue():: Success parsing " . basename($filename)); @unlink($filename); } } shell_exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.watchdog.postfix.queue.php >/dev/null 2>&1 &"); }