예제 #1
0
function ufdbguard27()
{
    $unix = new unix();
    $sock = new sockets();
    $squid = new squidbee();
    $users = new usersMenus();
    $major = $unix->UFDBGUARDD_MAJOR();
    $minor = $unix->UFDBGUARDD_MINOR();
    $datas = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    $ufdbClass = new compile_ufdbguard();
    $datas = $ufdbClass->SetDefaultsConfig($datas);
    if (!isset($datas["url_rewrite_children_concurrency"])) {
        $datas["url_rewrite_children_concurrency"] = 2;
    }
    if (!isset($datas["url_rewrite_children_startup"])) {
        $datas["url_rewrite_children_startup"] = 5;
    }
    if (!isset($datas["url_rewrite_children_idle"])) {
        $datas["url_rewrite_children_idle"] = 5;
    }
    if (!is_numeric($datas["url_rewrite_children_concurrency"])) {
        $datas["url_rewrite_children_concurrency"] = 2;
    }
    if ($datas["url_rewrite_children_concurrency"] > 1) {
        $moinsC = "-C ";
    }
    if ($squid->EnableRemoteStatisticsAppliance == 1) {
        $RemoteStatisticsApplianceSettings = unserialize(base64_decode($sock->GET_INFO("RemoteStatisticsApplianceSettings")));
        if ($this->ASROOT) {
            echo "Starting......: " . date("H:i:s") . " [UFDB]: Using remote appliance {$RemoteStatisticsApplianceSettings["SERVER"]}:{$datas["listen_port"]} as Web filtering engine\n";
        }
        $datas["remote_server"] = $RemoteStatisticsApplianceSettings["SERVER"];
        $datas["UseRemoteUfdbguardService"] = 1;
        $datas["remote_port"] = $datas["listen_port"];
    }
    $binary = "/usr/share/artica-postfix/ufdbgclient.php";
    $log = "-l /var/log/squid";
    if (!is_numeric($datas["listen_port"])) {
        $datas["listen_port"] = "3977";
    }
    if (!is_numeric($datas["tcpsockets"])) {
        $datas["tcpsockets"] = 1;
    }
    if (!is_numeric($datas["remote_port"])) {
        $datas["remote_port"] = 3977;
    }
    if ($datas["remote_port"] == null) {
        $datas["UseRemoteUfdbguardService"] = 0;
    }
    if ($datas["listen_addr"] == null) {
        $datas["listen_addr"] = "127.0.0.1";
    }
    if ($datas["listen_addr"] == "all") {
        $datas["listen_addr"] = "127.0.0.1";
    }
    if ($datas["UseRemoteUfdbguardService"] == 1) {
        if (trim($datas["remote_server"] == null)) {
            $datas["remote_server"] = "127.0.0.1";
        }
        $address = "-S {$datas["remote_server"]} -p {$datas["remote_port"]} ";
        echo "Starting......: " . date("H:i:s") . " ufdbguardd: Use remote ufdbguard service: {$datas["remote_server"]}:{$datas["remote_port"]}\n";
        $GLOBALS[__FUNCTION__] = "{$binary} {$moinsC}{$address} {$log}";
        return "{$binary} {$moinsC}{$address} {$log}";
    }
    $effective_port = $squid->ufdbguard_value("port");
    echo "Starting......: " . date("H:i:s") . " ufdbguardd: Effective port:`{$effective_port}`\n";
    if (is_numeric($effective_port)) {
        $datas["tcpsockets"] = 1;
    }
    if ($major > 0) {
        if ($minor > 26) {
            if ($datas["tcpsockets"] == 1) {
                if (trim($datas["listen_addr"] == null)) {
                    $datas["listen_addr"] = "127.0.0.1";
                }
                echo "Starting......: " . date("H:i:s") . " ufdbguardd: Use remote ufdbguard service: {$datas["listen_addr"]}:{$datas["remote_port"]}\n";
                $address = "-S {$datas["listen_addr"]} -p {$datas["listen_port"]} ";
                $GLOBALS[__FUNCTION__] = "{$binary} {$moinsC}{$address} {$log}";
                $f[] = "url_rewrite_program {$binary} {$moinsC}{$address} {$log}";
                $f[] = $squid->url_rewrite_children();
                return @implode("\n", $f);
            }
        }
    }
    echo "Starting......: " . date("H:i:s") . " ufdbguardd: Use remote ufdbguard service: {$binary} {$moinsC}{$log}\n";
    $GLOBALS[__FUNCTION__] = "{$binary} {$moinsC}{$log}";
    $f[] = "url_rewrite_program /usr/share/artica-postfix/ufdbgclient.php";
    $f[] = $squid->url_rewrite_children();
    return @implode("\n", $f);
}