die("Cannot be used in web server mode\n\n");
}
$unix = new unix();
if ($unix->process_number_me($argv) > 0) {
    die("Already executed\n\n");
}
if ($argv[1] == "--test-nas") {
    tests_nas(true);
    die;
}
if ($argv[1] == "--quotas") {
    CleanQuotas(true);
    die;
}
if ($argv[1] == "--remove-all") {
    removeall(true);
    die;
}
if ($argv[1] == "--numeric-members") {
    remove_numeric_members(true);
    die;
}
if ($argv[1] == "--backup") {
    backup_all(true);
    die;
}
purge();
function CleanQuotas()
{
    $sock = new sockets();
    $unix = new unix();
function squid_admin_notifs_check($nopid = false)
{
    $f = array();
    $unix = new unix();
    $sock = new sockets();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $BaseWorkDir = "{$GLOBALS["ARTICALOGDIR"]}/squid_admin_notifs";
    if (!is_dir($BaseWorkDir)) {
        return;
    }
    if (!($handle = opendir($BaseWorkDir))) {
        return;
    }
    $UfdbguardSMTPNotifs = unserialize(base64_decode($sock->GET_INFO("UfdbguardSMTPNotifs")));
    if (!isset($UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"])) {
        $UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"] = 0;
    }
    if (!is_numeric($UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"])) {
        $UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"] = 0;
    }
    if ($UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"] == 0) {
        removeall();
        return;
    }
    if (!isset($UfdbguardSMTPNotifs["smtp_dest"])) {
        return;
    }
    if (!isset($UfdbguardSMTPNotifs["smtp_sender"])) {
        $UfdbguardSMTPNotifs["smtp_sender"] = null;
    }
    while (false !== ($filename = readdir($handle))) {
        if ($filename == ".") {
            continue;
        }
        if ($filename == "..") {
            continue;
        }
        $targetFile = "{$BaseWorkDir}/{$filename}";
        if ($unix->file_time_min($targetFile) > 240) {
            @unlink($targetFile);
            continue;
        }
        $array = unserialize(@file_get_contents($targetFile));
        if (!is_array($array)) {
            @unlink($targetFile);
            continue;
        }
        if (!is_numeric($array["TASKID"])) {
            $array["TASKID"] = 0;
        }
        $content = $array["text"];
        $content_array = explode("\n", $content);
        if (count($content_array) > 0) {
            for ($i = 0; $i < count($content_array); $i++) {
                if (trim($content_array[$i]) == null) {
                    continue;
                }
                if ($GLOBALS["VERBOSE"]) {
                    echo "Strip `{$content_array[$i]}` line " . __LINE__ . "\n";
                }
                $subject = substr($content_array[$i], 0, 75) . "...";
                break;
            }
            $content = @implode("\r\n", $content_array);
        } else {
            if ($GLOBALS["VERBOSE"]) {
                echo "Strip `{$content}`\n";
            }
            $subject = substr($content, 0, 75) . "...";
        }
        unset($array["text"]);
        $content = $content . "\r\n------------------------------------------\r\n";
        while (list($key, $value) = each($array)) {
            $content = $content . "{$key}.....: {$value}\r\n";
        }
        $subject = "[" . $unix->hostname_g() . "]: {$subject}";
        if (!SendMessage($subject, $content, $UfdbguardSMTPNotifs)) {
            continue;
        }
        @unlink($targetFile);
    }
}
<?php

if ($argv[1] == "--remove-nics") {
    removeall();
    exit;
}
$iptables_save = "/sbin/iptables-save";
$iptables_restore = "/sbin/iptables-restore";
shell_exec("{$iptables_save} > /etc/artica-postfix/iptables-bridges.conf");
$data = file_get_contents("/etc/artica-postfix/iptables-bridges.conf");
$datas = explode("\n", $data);
$pattern = "#.+?ArticaNetworkBridges#";
$conf = array();
$d = 0;
while (list($num, $ligne) = each($datas)) {
    if ($ligne == null) {
        continue;
    }
    if (preg_match($pattern, $ligne)) {
        $d++;
        continue;
    }
    $conf[] = $ligne;
}
file_put_contents("/etc/artica-postfix/iptables-bridges.new.conf", @implode("\n", $conf));
shell_exec("{$iptables_restore} < /etc/artica-postfix/iptables-bridges.new.conf");
@unlink("/etc/artica-postfix/iptables-bridges.new.conf");
@unlink("/etc/artica-postfix/iptables-bridges.conf");
@unlink("/etc/artica-postfix/IPTABLES_BRIDGE");
function removeall()
{