function ParseKav4ProxyLogs()
{
    $dir = "/var/log/artica-postfix/kaspersky/kav4proxy";
    if (!is_dir($dir)) {
        return null;
    }
    $unix = new unix();
    $files = $unix->DirFiles($dir);
    while (list($num, $file) = each($files)) {
        if (!preg_match("#([0-9\\-]+)_([0-9]+)-([0-9]+)-([0-9]+)#", $file, $re)) {
            continue;
        }
        $date = "{$re[1]} {$re[2]}:{$re[3]}:{$re[4]}";
        $NumberofKas3FilesUpdated = NumberofKavFilesUpdated("{$dir}/{$file}");
        if ($NumberofKas3FilesUpdated < 0) {
            $subject = "Kaspersky Antivirus Proxy: update failed";
            send_email_events($subject, @file_get_contents("{$dir}/{$file}"), "KASPERSKY_UPDATES", $date);
            @unlink("{$dir}/{$file}");
            continue;
        }
        if ($NumberofKas3FilesUpdated > 0) {
            $subject = "Kaspersky Antivirus Proxy: {$NumberofKas3FilesUpdated} new viruses in databases";
            send_email_events($subject, @file_get_contents("{$dir}/{$file}"), "KASPERSKY_UPDATES", $date);
        }
        @unlink("{$dir}/{$file}");
    }
}
function ParseKav4ProxyLogs()
{
    $users = new usersMenus();
    if (!$users->KAV4PROXY_INSTALLED) {
        die;
    }
    $unix = new unix();
    $pid = $unix->PIDOF("/opt/kaspersky/kav4proxy/bin/kav4proxy-keepup2date");
    if ($unix->process_exists($pid)) {
        return;
    }
    $dir = "/var/log/artica-postfix/kaspersky/kav4proxy";
    if (!is_dir($dir)) {
        return null;
    }
    $unix = new unix();
    $files = $unix->DirFiles($dir);
    $lic = false;
    while (list($num, $file) = each($files)) {
        if (!preg_match("#([0-9\\-]+)_([0-9]+)-([0-9]+)-([0-9]+)#", $file, $re)) {
            continue;
        }
        $date = "{$re[1]} {$re[2]}:{$re[3]}:{$re[4]}";
        $NumberofKas3FilesUpdated = NumberofKavFilesUpdated("{$dir}/{$file}");
        if ($NumberofKas3FilesUpdated < 0) {
            $subject = "Kaspersky Antivirus Proxy: update failed";
            send_email_events($subject, @file_get_contents("{$dir}/{$file}"), "KASPERSKY_UPDATES", $date);
            ParseKav4ProxyLogsMysql($date, $subject, "{$dir}/{$file}");
            $lic = true;
            continue;
        }
        if ($NumberofKas3FilesUpdated > 0) {
            $subject = "Kaspersky Antivirus Proxy: {$NumberofKas3FilesUpdated} new viruses in databases";
            ParseKav4ProxyLogsMysql($date, $subject, "{$dir}/{$file}");
            send_email_events($subject, @file_get_contents("{$dir}/{$file}"), "KASPERSKY_UPDATES", $date);
            $lic = true;
            continue;
        }
        if (AllAreUp2date("{$dir}/{$file}")) {
            ParseKav4ProxyLogsMysql($date, "All files are up-to-date", "{$dir}/{$file}");
            $lic = true;
            continue;
        }
        if (completed("{$dir}/{$file}")) {
            ParseKav4ProxyLogsMysql($date, "Update completed successfully", "{$dir}/{$file}");
            $lic = true;
            continue;
        }
        $size = @filesize("{$dir}/{$file}");
        ParseKav4ProxyLogsMysql($date, "Updates launched...({$size} bytes)", "{$dir}/{$file}");
    }
    if ($lic) {
        $php5 = $unix->LOCATE_PHP5_BIN();
        shell_exec("{$php5} /usr/share/artica-postfix/exec.kav4proxy.php --license");
    }
}