Beispiel #1
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;
}
Beispiel #2
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 #3
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 #4
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);
}