Esempio n. 1
0
function run()
{
    $TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $unix = new unix();
    $tmpfile = $unix->FILE_TEMP();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$pid} already executed since {$timepid}Mn\n";
        }
        if (!$GLOBALS["FORCE"]) {
            if ($timepid < 14) {
                return;
            }
            $kill = $unix->find_program("kill");
            unix_system_kill_force($pid);
        }
    }
    @file_put_contents($pidfile, getmypid());
    if (!$GLOBALS["FORCE"]) {
        if (!$GLOBALS["VERBOSE"]) {
            $time = $unix->file_time_min($TimeFile);
            if ($time < 14) {
                echo "Current {$time}Mn, require at least 14mn\n";
                return;
            }
        }
    }
    $binary = "/usr/share/artica-postfix/bin/pflogsumm.pl";
    @chmod("{$binary}", 0755);
    system("{$binary} -d today /var/log/mail.log >{$tmpfile}");
    ParseReport($tmpfile);
    @unlink($tmpfile);
    stats_total();
}
function pflogsumm($filename)
{
    $unix = new unix();
    $tmpfile = $unix->FILE_TEMP();
    $binary = "/usr/share/artica-postfix/bin/pflogsumm.pl";
    @chmod("{$binary}", 0755);
    echo "{$binary} {$filename} >{$tmpfile}\n";
    system("{$binary} {$filename} >{$tmpfile}");
    if (ParseReport($tmpfile)) {
        @unlink($tmpfile);
        return true;
    }
}