function MiltergreyList_days() { $unix = new unix(); ///etc/artica-postfix/pids/exec.postfix.miltergrey.stats.php.MiltergreyList_days.time $timeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); @mkdir("/home/artica/postfix/milter-greylist/logger", 0755, true); @chmod("/home/artica/postfix/milter-greylist", 0755, true); @chown("/home/artica/postfix/milter-greylist", "postfix"); @chgrp("/home/artica/postfix/milter-greylist", "postfix"); @chmod("/home/artica/postfix/milter-greylist/logger", 0755, true); @chown("/home/artica/postfix/milter-greylist/logger", "postfix"); @chgrp("/home/artica/postfix/milter-greylist/logger", "postfix"); if ($unix->process_exists($pid, basename(__FILE__))) { $pidTime = $unix->PROCCESS_TIME_MIN($pid); system_admin_events("Already process PID: {$pid} running since {$pidTime} minutes", __FUNCTION__, __FILE__, __LINE__, "postfix-stats"); return; } if (!$GLOBALS["VERBOSE"]) { if (!$GLOBALS["FORCE"]) { if ($unix->file_time_min($timeFile) < 60) { die; } } } @unlink($timeFile); @file_put_contents($timeFile, time()); @file_put_contents($pidfile, getmypid()); if (!$GLOBALS["FORCE"]) { if (system_is_overloaded(basename(__FILE__))) { system_admin_events("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__, "postfix-stats"); return; } } $q = new mysql_postfix_builder(); if ($GLOBALS["VERBOSE"]) { echo "Scanning tables...\n"; } $tables = $q->LIST_MILTERGREYLIST_HOUR_TABLES(); $currentHour = date("Y-m-d H"); $tt = 0; if (is_array($tables)) { while (list($tablesource, $time) = each($tables)) { $tt++; if (date("Y", $time) == "1970") { $q->QUERY_SQL("DROP TABLE {$tablesource}"); continue; } if (date("Y-m-d H", $time) == $currentHour) { if ($GLOBALS["VERBOSE"]) { echo "Skipping {$currentHour}\n"; } continue; } if ($GLOBALS["VERBOSE"]) { echo "Processing {$tablesource}: " . date("Y-m-d H", $time) . "[" . __LINE__ . "]\n"; } if (MiltergreyList_scan($tablesource, $time)) { if ($GLOBALS["VERBOSE"]) { echo "DUMP_TABLE {$tablesource}: " . date("Y-m-d H", $time) . "\n"; } if ($q->DUMP_TABLE($tablesource)) { $q->QUERY_SQL("DROP TABLE {$tablesource}"); } } else { if ($GLOBALS["VERBOSE"]) { echo "{$tablesource} failed...\n"; } } if (system_is_overloaded(basename(__FILE__))) { system_admin_events("Overloaded system, aborting task after {$tt} processed tables ", __FUNCTION__, __FILE__, __LINE__, "postfix-stats"); return; } } } if (!$GLOBALS["FORCE"]) { if (system_is_overloaded(basename(__FILE__))) { system_admin_events("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__, "postfix-stats"); return; } } $yesterday = $q->HIER(); $tables = $q->LIST_MILTERGREYLIST_DAY_TABLES(); if (is_array($tables)) { while (list($tablesource, $time) = each($tables)) { if (date("Y-m-d", $time) == date("Y-m-d")) { if ($GLOBALS["VERBOSE"]) { echo "Skipping {$currentHour}\n"; } continue; } if (date("Y-m-d", $time) == $yesterday) { if ($GLOBALS["VERBOSE"]) { echo "Skipping {$currentHour}\n"; } continue; } if ($GLOBALS["VERBOSE"]) { echo "Processing {$tablesource}: " . date("Y-m-d", $time) . "[" . __LINE__ . "]\n"; } if (MiltergreyList_month($tablesource, $time)) { if ($GLOBALS["VERBOSE"]) { echo "DUMP_TABLE {$tablesource}: " . date("Y-m-d H", $time) . "\n"; } if ($q->DUMP_TABLE($tablesource)) { $q->QUERY_SQL("DROP TABLE {$tablesource}"); } } else { if ($GLOBALS["VERBOSE"]) { echo "{$tablesource}: {failed}\n"; } } } } }