Beispiel #1
0
function FIX_1_CATEGORY_CHECKED()
{
    @mkdir("/var/lib/squidguard/checked", 0755, true);
    if (!is_file("/var/lib/squidguard/checked/domains")) {
        @unlink("/var/lib/squidguard/checked/domains.ufdb");
        for ($i = 0; $i <= 10; $i++) {
            $f[] = md5(time() . "{$i}.com") . ".com";
            $t[] = md5(time() . "{$i}.com") . ".com/index.html";
        }
        @file_put_contents("/var/lib/squidguard/checked/domains", @implode("\n", $f));
    }
    if (!is_file("/var/lib/squidguard/checked/urls")) {
        @file_put_contents("/var/lib/squidguard/checked/urls", @implode("\n", $t));
    }
    if (!is_file("/var/lib/squidguard/checked/expressions")) {
        @file_put_contents("/var/lib/squidguard/checked/expressions", "\n");
    }
    if (!is_file("/var/lib/squidguard/checked/domains.ufdb")) {
        $ufd = new compile_ufdbguard();
        $ufd->compile_category("checked");
    }
}
Beispiel #2
0
function ChecksConfig()
{
    $sock = new sockets();
    $unix = new unix();
    $Urgency = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidUrgency"));
    if ($Urgency == 1) {
        return true;
    }
    $ufdbguardConfig = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    $ufdbClass = new compile_ufdbguard();
    $datas = $ufdbClass->SetDefaultsConfig($ufdbguardConfig);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}: tcpsockets={$datas["tcpsockets"]}\n";
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} tcpsockets =1\n";
    }
    if ($ufdbguardConfig["listen_addr"] == "all") {
        $ufdbguardConfig["listen_addr"] = "127.0.0.1";
    }
    $uri = "{$ufdbguardConfig["listen_addr"]}:{$ufdbguardConfig["listen_port"]}";
    build_progress("{APP_UFDBGUARD} {$uri}", 10);
    $port = $ufdbguardConfig["listen_port"];
    $listen_addr = $ufdbguardConfig["listen_addr"];
    $SQUID_ALL_PORTS = $unix->SQUID_ALL_PORTS();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Squid listens " . count($SQUID_ALL_PORTS) . "\n";
    }
    if (isset($SQUID_ALL_PORTS[$port])) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Squid Port conflict !!!\n";
        }
        $ufdbguardConfig["listen_port"] = 3977;
        @file_put_contents("/etc/artica-postfix/settings/Daemons/ufdbguardConfig", base64_decode(serialize($ufdbguardConfig)));
        system("{$php5} /usr/share/artica-postfix/exec.squidguard.php --conf --force");
    }
    $f = explode("\n", @file_get_contents("/etc/squid3/squid.conf"));
    while (list($index, $ligne) = each($f)) {
        $ligne = trim($ligne);
        if (preg_match("#^url_rewrite_program.*?ufdbgclient#", $ligne, $re)) {
            return true;
        }
    }
    build_progress("{APP_UFDBGUARD} {$uri}", 20);
    return false;
}
function CoherenceRepertoiresUfdb()
{
    if (!ifMustBeExecuted()) {
        WriteMyLogs("No make sense to execute this script...", __FUNCTION__, __FILE__, __LINE__);
        if ($GLOBALS["VERBOSE"]) {
            echo "No make sense to execute this script...\n";
        }
        die;
    }
    $unix = new unix();
    $q = new mysql_squid_builder();
    $BASE_URI = "ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidguard_contrib";
    $ufdbGenTable = $unix->find_program("ufdbGenTable");
    if (!is_file($ufdbGenTable)) {
        return;
    }
    $ufdb = new compile_ufdbguard();
    $rm = $unix->find_program("rm");
    $dirs = $unix->dirdir("/var/lib/ftpunivtlse1fr");
    $Conversion = $q->TLSE_CONVERTION();
    while (list($directory, $line) = each($dirs)) {
        $database = basename($directory);
        if (isset($Conversion[$database])) {
            if (!is_file("{$directory}/domains")) {
                echo "{$directory} has no domains\n";
                shell_exec("{$rm} -rf {$directory}");
                continue;
            }
            if (is_file("{$directory}/domains.ufdb")) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$directory}/domains.ufdb OK\n";
                }
                continue;
            }
            $ufdb->UfdbGenTable("{$directory}", basename($directory));
        }
    }
}
Beispiel #4
0
function url_rewrite_bypass_save()
{
    if (!class_exists("compile_ufdbguard")) {
        include_once "ressources/class.compile.ufdbguard.inc";
    }
    $squid = new squidbee();
    $squid->url_rewrite_bypass = $_POST["url_rewrite_bypass"];
    $squid->SaveToLdap();
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $datas = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    $ufdbclass = new compile_ufdbguard();
    $datas = $ufdbclass->SetDefaultsConfig($datas);
    $sock->SET_INFO("UfdbReloadBySchedule", $_POST["UfdbReloadBySchedule"]);
    $datas["url-lookup-result-during-database-reload"] = $_POST["reload"];
    $datas["url-lookup-result-when-fatal-error"] = $_POST["error"];
    $sock->SaveConfigFile(base64_encode(serialize($datas)), "ufdbguardConfig");
}
Beispiel #5
0
function main()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
    $sock = new sockets();
    $t = time();
    $SquidGuardIPWeb = $sock->GET_INFO("SquidGuardIPWeb");
    $SquidGuardApachePort = intval($sock->GET_INFO("SquidGuardApachePort"));
    if ($SquidGuardApachePort == 0) {
        $SquidGuardApachePort = 9020;
    }
    $UseRemoteUfdbguardService = intval($sock->GET_INFO("UseRemoteUfdbguardService"));
    $UfdbGuardThreads = $sock->GET_INFO("UfdbGuardThreads");
    $ufdbclass = new compile_ufdbguard();
    $UFDB = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    $UFDB = $ufdbclass->SetDefaultsConfig($UFDB);
    $datas = $UFDB;
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    $EnableGoogleSafeSearch = $sock->GET_INFO("EnableGoogleSafeSearch");
    $EnableGoogleSafeBrowsing = intval($sock->GET_INFO("EnableGoogleSafeBrowsing"));
    $EnableGoogleSafeBrowsing_popupon = $tpl->javascript_parse_text("{EnableGoogleSafeBrowsing_popupon}");
    $EnableGoogleSafeBrowsing_popupoff = $tpl->javascript_parse_text("{EnableGoogleSafeBrowsing_popupoff}");
    $DisableGoogleSSL = intval($sock->GET_INFO("DisableGoogleSSL"));
    $PhishTankApiKey = $sock->GET_INFO("PhishTankApiKey");
    $EnableSquidPhishTank = intval($sock->GET_INFO("EnableSquidPhishTank"));
    if (!is_numeric($EnableGoogleSafeSearch)) {
        $EnableGoogleSafeSearch = 1;
    }
    $SquidUrgency = intval($sock->GET_INFO("SquidUrgency"));
    $ufdbguardConfig = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    if (!is_numeric($ufdbguardConfig["DebugAll"])) {
        $ufdbguardConfig["DebugAll"] = 0;
    }
    if ($ufdbguardConfig["DebugAll"] == 1) {
        echo FATAL_ERROR_SHOW_128("<strong>{webfiltering_in_debug_mode}</strong><p>&nbsp;</p>{webfiltering_in_debug_mode_text}\n\t\t\t\t<div style='margin:20px;text-align:right'>" . button("{disable}", "Loadjs('ufdbguard.debug.php')", 20) . "</div>\n\t\t\t\t\n\t\t\t\t");
    }
    if ($SquidUrgency == 1) {
        echo FATAL_ERROR_SHOW_128("<strong>{proxy_in_emergency_mode}</strong><p>&nbsp;</p>{proxy_in_emergency_mode_explain}\n\t\t<div style='margin:20px;text-align:right'>" . button("{urgency_mode}", "Loadjs('squid.urgency.php?justbutton=yes')", 20) . "</div>\n\t\t");
    }
    $GoogleSafeBrowsingApiKey = $sock->GET_INFO("GoogleSafeBrowsingApiKey");
    $UfdbUseArticaClient = $sock->GET_INFO("UfdbUseArticaClient");
    if (!is_numeric($UfdbUseArticaClient)) {
        $UfdbUseArticaClient = 1;
    }
    $GoogleSafeBrowsingApiKey_color = "#04A910";
    $GoogleSafeBrowsingApiKey_link = $tpl->_ENGINE_parse_body("{defined}");
    $PhishTankApiKey_color = "#04A910";
    $PhishTankApiKey_link = $tpl->_ENGINE_parse_body("{defined}");
    if (strlen($PhishTankApiKey) < 10) {
        $PhishTankApiKey_color = "#A90404";
        $PhishTankApiKey_link = $tpl->_ENGINE_parse_body("{not_set}");
    }
    if (strlen($GoogleSafeBrowsingApiKey) < 10) {
        $GoogleSafeBrowsingApiKey_color = "#A90404";
        $GoogleSafeBrowsingApiKey_link = $tpl->_ENGINE_parse_body("{not_set}");
    }
    $EnableGoogleSafeBrowsing_field = Paragraphe_switch_img("{EnableGoogleSafeBrowsing}", "{EnableGoogleSafeBrowsing_explain}\n\t\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t\t\t<a href=\"javascript:Loadjs('{$page}?GoogleSafeBrowsingApiKey-js=yes')\"\n\t\t\t\t\tstyle='font-size:22px;color:{$GoogleSafeBrowsingApiKey_color};text-decoration:underline'>{API_KEY}:{$GoogleSafeBrowsingApiKey_link}</a>\n\t\t\t\n\t\t\t\t\t</div>\n\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t\t\t<a href=\"https://developers.google.com/safe-browsing/key_signup\"\n\t\t\t\t\tstyle='font-size:18px;text-decoration:underline' target=_new>Google:&nbsp;{free_register}</a>\n\t\t\t\t\t</div>\n\t\t\t\t", "EnableGoogleSafeBrowsing-{$t}", $EnableGoogleSafeBrowsing, null, 750);
    $EnablePhishtank = Paragraphe_switch_img("{PhishTank_enable}", "{PhishTank_about}\n\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t<a href=\"javascript:Loadjs('{$page}?PhishTankApiKey-js=yes')\"\n\t\t\tstyle='font-size:22px;color:{$PhishTankApiKey_color};text-decoration:underline'>{API_KEY}:{$PhishTankApiKey_link}</a>\n\t\t\t\t\n\t\t\t</div>\n\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t<a href=\"https://www.phishtank.com/api_register.php\"\n\t\t\tstyle='font-size:18px;text-decoration:underline' target=_new>PhishTank:&nbsp;{free_register}</a>\n\t\t\t</div>\n\t\t\t", "EnableSquidPhishTank-{$t}", $EnableSquidPhishTank, null, 750);
    $EnableGoogleSafeBrowsing_button = button("{apply}", "EnableGoogleSafeBrowsing{$t}()", 26);
    $EnablePhishtank_button = button("{apply}", "EnablePhishtank{$t}()", 26);
    if ($UfdbUseArticaClient == 0) {
        $EnableGoogleSafeBrowsing_field = Paragraphe_switch_disable("{EnableGoogleSafeBrowsing}", "{EnableGoogleSafeBrowsing_explain}", "EnableGoogleSafeBrowsing-{$t}", $EnableGoogleSafeBrowsing, null, 750);
        $EnablePhishtank = Paragraphe_switch_disable("{PhishTank_enable}", "{PhishTank_about}", "EnableSquidPhishTank-{$t}", $EnableSquidPhishTank, null, 750);
        $EnableGoogleSafeBrowsing_button = null;
        $EnablePhishtank_button = null;
    }
    if ($UFDB["UseRemoteUfdbguardService"] == 1) {
        $sock->SET_INFO("UseRemoteUfdbguardService", 1);
        $UseRemoteUfdbguardService = 1;
    }
    if ($DisableGoogleSSL == 1) {
        $DisableGoogleSSL_text = "{enabled}";
    } else {
        $DisableGoogleSSL_text = "{disabled}";
    }
    echo $tpl->_ENGINE_parse_body("<div style='margin-bottom:20px;margin-top:20px;width:98%' class=form>\n\t\t\t{$EnablePhishtank}\n\t\t\t<div style='text-align:right'>{$EnablePhishtank_button}</div>\n\t\t\t</div>");
    if ($UseRemoteUfdbguardService == 0) {
        echo $tpl->_ENGINE_parse_body("<div style='margin-bottom:20px;margin-top:20px;width:98%' class=form>" . Paragraphe_switch_img("{EnableGoogleSafeSearch}", "{safesearch_explain}\n\t\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t\t\t<a href=\"javascript:Loadjs('squid.google.ssl.php')\" \n\t\t\t\t\tstyle='font-size:22px;text-decoration:underline'>{disable_google_ssl} ({$DisableGoogleSSL_text})</a></div>\n\t\t\t\t\n\t\t\t\t", "EnableGoogleSafeSearch-{$t}", $EnableGoogleSafeSearch, null, 750) . "\n\t\t\t\t\t\n\t\t<div style='text-align:right'>" . button("{apply}", "EnableGoogleSafeSearch{$t}()", 26) . "</div>\t\t\t\n\t\t</div>");
    }
    echo $tpl->_ENGINE_parse_body("<div style='margin-bottom:20px;margin-top:20px;width:98%' class=form>\n\t\t{$EnableGoogleSafeBrowsing_field}\n\t\t<div style='text-align:right'>{$EnableGoogleSafeBrowsing_button}</div>\n\t\t</div>");
    if ($SquidGuardIPWeb == null) {
        $SquidGuardIPWeb = "http://" . $_SERVER['SERVER_ADDR'] . ':' . $SquidGuardApachePort . "/exec.squidguard.php";
        $fulluri = "http://" . $_SERVER['SERVER_ADDR'] . ':' . $SquidGuardApachePort . "/exec.squidguard.php";
        $sock->SET_INFO("SquidGuardIPWeb", $fulluri);
    } else {
        $fulluri = $SquidGuardIPWeb;
    }
    if (!$users->CORP_LICENSE) {
        $MyVersion = "{license_error}";
    } else {
        $q = new mysql_squid_builder();
        $MyVersion = trim($sock->getFrameWork("ufdbguard.php?articawebfilter-database-version=yes"));
        $MyVersion = $q->time_to_date($MyVersion, true);
    }
    if ($UseRemoteUfdbguardService == 0) {
        $wizard = "\n\t\t<tr><td colspan=3>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td colspan=3 align='center'>" . button("{wizard_rule}", "Loadjs('dansguardian2.wizard.rule.php')", 26) . "\n\t\t\t\t\t<div style='font-size:14px;margin-top:15px'>{wizard_rule_ufdb_explain}</div>\n\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\n\t\t</tr>";
        $build_rules = "<tr><td colspan=3>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td colspan=3 align='center'>" . button("{compile_rules}", "Loadjs('dansguardian2.compile.php');", 26) . "\n\t\t\t\t\t<div style='font-size:14px;margin-top:15px'>{wizard_rule_ufdb_compile_explain}</div>\n\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\n\t\t</tr>";
    }
    $t = time();
    $html = "\n\t<div style='width:98%' class=form>\n\t\t<div style='font-size:28px;font-weight:bold'>\n\t\t<table style='width:100%;margin-top:30px'>\n\t\t<tr>\n\t\t\t<td style='vertical-align:middle;font-size:18px' class=legend>{listen_address}:</td>\n\t\t\t<td style='vertical-align:middle;font-size:18px'>{$datas["listen_addr"]}:{$datas["listen_port"]}</td>\n\t\t\t<td>&nbsp;</td>\n\t\t</tr>\t\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\t\n\t\t<tr>\n\t\t\t<td style='vertical-align:middle;font-size:18px' class=legend>{webpage_deny_url}:</td>\n\t\t\t<td style='vertical-align:middle;font-size:18px'>{$fulluri}</td>\n\t\t\t<td>" . button("{options}", "Loadjs('ufdbguard.urichange.php')", 16) . "</td>\n\t\t</tr>\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td style='vertical-align:middle;font-size:18px' class=legend>{artica_databases}:</td>\n\t\t\t<td style='vertical-align:middle;font-size:18px'>{$MyVersion}</td>\n\t\t\t<td>" . button("{options}", "LoadAjax('BodyContent','artica.update.php?webfiltering-tabs=yes&from-ufdbguard=yes')", 16) . "</td>\n\t\t</tr>\n\n\t\t{$wizard}\n\t\t{$build_rules}\n\t\t\n\t\t\n\t\t</table>\n\n\t\t\n\t\t<script>\n\t\t\n\tvar xEnableGoogleSafeSearch{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tLoadjs('dansguardian2.compile.php');\n\t\t\n\t}\t\t\n\t\t\n\tfunction EnableGoogleSafeSearch{$t}(){\n\t\tif(!document.getElementById('EnableGoogleSafeSearch-{$t}')){ alert('Error in field, please refresh...'); return; }\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('EnableGoogleSafeSearch', document.getElementById('EnableGoogleSafeSearch-{$t}').value);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xEnableGoogleSafeSearch{$t});  \n\t}\n\t\n\tvar xEnableGoogleSafeBrowsing{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tLoadAjaxRound('main-ufdb-frontend','ufdbguard.status.php');\n\t\tLoadjs('squid.compile.progress.php');\n\t\t\n\t}\t\n\t\n\tfunction EnableGoogleSafeBrowsing{$t}(){\n\t\tif(!document.getElementById('EnableGoogleSafeBrowsing-{$t}')){alert('Error in field, please refresh...'); return; }\n\t\tvar XHR = new XHRConnection();\n\t\tvar EnableGoogleSafeBrowsing=document.getElementById('EnableGoogleSafeBrowsing-{$t}').value;\n\t\tif(EnableGoogleSafeBrowsing==1){ if(!confirm('{$EnableGoogleSafeBrowsing_popupon}')){return;} }\n\t\tif(EnableGoogleSafeBrowsing==0){if(!confirm('{$EnableGoogleSafeBrowsing_popupoff}')){return;} }\n\t\tXHR.appendData('EnableGoogleSafeBrowsing', EnableGoogleSafeBrowsing);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xEnableGoogleSafeBrowsing{$t}); \t\n\t\n\t}\n\t\n\tfunction  EnablePhishtank{$t}(){\n\t\tif(!document.getElementById('EnableSquidPhishTank-{$t}')){alert('Error in field, please refresh...'); return; }\n\t\tvar XHR = new XHRConnection();\n\t\tvar EnableSquidPhishTank=document.getElementById('EnableSquidPhishTank-{$t}').value;\n\t\tXHR.appendData('EnableSquidPhishTank', EnableSquidPhishTank);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xEnableGoogleSafeBrowsing{$t}); \n\t}\n\t\n</script>\n\t\t\n\t\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Beispiel #6
0
function CheckDirectories($verifdbs = false)
{
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $sysctl = $unix->find_program("sysctl");
    $echo = $unix->find_program("echo");
    $nohup = $unix->find_program("nohup");
    $kill = $unix->find_program("kill");
    $cp = $unix->find_program("cp");
    $PossibleDirs[] = "/var/lib/ufdbartica";
    @mkdir("/home/ufdbcat", 0755, true);
    @mkdir("/home/ufdbcat/security", 0755, true);
    $compile_ufdbguard = new compile_ufdbguard();
    $compile_ufdbguard->BuildCertificates();
    $cp = $unix->find_program("cp");
    while (list($index, $Directory) = each($PossibleDirs)) {
        if (is_link($Directory)) {
            $Directory = readlink($Directory);
        }
        $dirs = $unix->dirdir($Directory);
        $max = count($dirs);
        $c = 0;
        while (list($index, $Directory2) = each($dirs)) {
            if (is_link($Directory2)) {
                $Directory2 = readlink($Directory2);
            }
            if (!is_file("{$Directory2}/domains.ufdb")) {
                continue;
            }
            $destdir = "/home/ufdbcat/" . basename($Directory2);
            $c++;
            $prc = $c / $max * 100;
            $prc = round($prc);
            if ($prc > 9) {
                if ($prc < 95) {
                    build_progress("{category}:" . basename($Directory2), $prc);
                }
            }
            if ($verifdbs) {
                $FILETIME1 = md5_file("{$Directory2}/domains.ufdb");
                $FILETIME2 = null;
                if (is_file("{$destdir}/domains.ufdb")) {
                    $FILETIME2 = md5_file("{$destdir}/domains.ufdb");
                }
                @mkdir($destdir, 0755, true);
                if ($FILETIME2 == $FILETIME1) {
                    if ($GLOBALS["OUTPUT"]) {
                        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} OK `" . basename($Directory2) . " not changed..\n";
                    }
                    continue;
                }
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Duplicate `" . basename($Directory2) . "` {$FILETIME2}<>{$FILETIME1}\n";
                }
                shell_exec("{$cp} -rf {$Directory2}/* {$destdir}/");
                @chmod($destdir, 0755);
            }
        }
    }
}
Beispiel #7
0
function UFDBGUARD_COMPILE_ALL_CATEGORIES()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $oldpid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        return;
    }
    @file_put_contents($pidfile, getmypid());
    ufdbguard_admin_events("start all categories compilation", __FUNCTION__, __FILE__, __LINE__, "compile");
    $q = new mysql_squid_builder();
    $t = time();
    $cats = $q->LIST_TABLES_CATEGORIES();
    $ufdb = new compile_ufdbguard();
    while (list($table, $line) = each($cats)) {
        if (preg_match("#category_(.+)#", $table, $re)) {
            $ufdb->compile_category($re[1]);
        }
    }
    $ttook = $unix->distanceOfTimeInWords($t, time(), true);
    ufdbguard_admin_events("Compilation all categories done ({$ttook})", __FUNCTION__, __FILE__, __LINE__, "global-compile");
    ufdbguard_admin_events("Service will be reloaded", __FUNCTION__, __FILE__, __LINE__, "config");
    shell_exec("/etc/init.d/ufdb reload");
}
Beispiel #8
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);
}