コード例 #1
0
function HyperCacheScanDBFile($dbfile, $ID)
{
    $TT = time();
    $filesize = FormatBytes(@filesize($dbfile) / 1024);
    if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
        echo "HyperCacheScanDBFile ---> {$dbfile} [" . __LINE__ . "]\n";
    }
    $db_con = dba_open($dbfile, "r", "db4");
    if (!$db_con) {
        events("{failed}: DB open" . basename($dbfile), $ID, 0, __LINE__);
        return false;
    }
    $HyperCacheRules = HyperCacheRulesLoad();
    if (!isset($HyperCacheRules[$ID])) {
        if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
            events("No rule for ID {$ID}!", 0, 2, __LINE__);
        }
        return;
    }
    $FileTypesArray = unserialize($HyperCacheRules[$ID]["FileTypes"]);
    if (count($FileTypesArray) == 0) {
        events("No Files type defined, aborting", $ID, 0, __LINE__);
        return;
    }
    $urikey = dba_firstkey($db_con);
    $ARRAY_SAVE = array();
    $c = 0;
    $HyPerCacheClass = new HyperCache();
    while ($urikey != false) {
        $FileType = dba_fetch($urikey, $db_con);
        if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
            echo "HyperCacheScanDBFile::[{$FileType}]: {$urikey}\n";
        }
        if ($FileType == "NONE") {
            $FileType = HyperCacheGetMimeType($urikey, $ID);
            if ($FileType == null) {
                $urikey = dba_nextkey($db_con);
                continue;
            }
            $ARRAY_SAVE[$urikey] = $FileType;
        }
        if (!isset($FileTypesArray[$FileType])) {
            if (!$HyPerCacheClass->ChecksOtherRules($urikey, $FileType, $ID)) {
                if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
                    events("{$urikey} {$FileType} No match...", $ID, 3, __LINE__);
                }
                $urikey = dba_nextkey($db_con);
                continue;
            }
        }
        $TargetFile = HyperCacheScanBuildLocalPath($urikey, $ID);
        $FullTargetFile = $GLOBALS["HyperCacheStoragePath"] . "/" . $TargetFile;
        if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
            events("HyperCacheScanDBFile::Local file: {$FullTargetFile}", $ID, 3, __LINE__);
        }
        if (is_file($FullTargetFile)) {
            $urikey = dba_nextkey($db_con);
            continue;
        }
        events("Downloading {$urikey} [{$FileType}]", $ID, 2, __LINE__);
        HyperCacheScanDownload($urikey, $TargetFile, $ID, $FileType);
        $urikey = dba_nextkey($db_con);
    }
    @dba_close($db_con);
    HyperCacheScanDBFile_setbulk($dbfile, $ARRAY_SAVE);
}
コード例 #2
0
ファイル: exec.squidcache.php プロジェクト: BillTheBest/1.6.x
function HyperCacheScanDBFile($dbfile, $ID)
{
    $TT = time();
    $unix = new unix();
    $Cache = unserialize(@file_get_contents("/usr/share/squid3/lastScan.array"));
    if (isset($Cache[$ID][$dbfile])) {
        $filemm = filemtime($dbfile);
        if ($filemm == $Cache[$ID][$dbfile]) {
            if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
                echo "HyperCacheScanDBFile {$filemm} == {$Cache[$ID][$dbfile]} [" . __LINE__ . "]\n";
            }
            return;
        }
    }
    $filesize = FormatBytes(@filesize($dbfile) / 1024);
    if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
        echo "HyperCacheScanDBFile ---> {$dbfile} [" . __LINE__ . "]\n";
    }
    $db_con = dba_open($dbfile, "r", "db4");
    if (!$db_con) {
        events("{failed}: DB open" . basename($dbfile), $ID, 0, __LINE__);
        return false;
    }
    $HyperCacheRules = HyperCacheRulesLoad();
    if (!isset($HyperCacheRules[$ID])) {
        if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
            events("No rule for ID {$ID}!", 0, 2, __LINE__);
        }
        return;
    }
    $FileTypesArray = unserialize($HyperCacheRules[$ID]["FileTypes"]);
    if (count($FileTypesArray) == 0) {
        events("No Files type defined, aborting", $ID, 0, __LINE__);
        return;
    }
    $urikey = dba_firstkey($db_con);
    $ARRAY_SAVE = array();
    $c = 0;
    while ($urikey != false) {
        $FileType = dba_fetch($urikey, $db_con);
        $GLOBALS["MAINDB"][$urikey] = $FileType;
        $urikey = dba_nextkey($db_con);
    }
    @dba_close($db_con);
    $GLOBAL["BLACKLISTED"] = array();
    if (!class_exists("HyperCache")) {
        include_once dirname(__FILE__) . "/ressources/class.HyperCache.inc";
    }
    $HyPerCacheClass = new HyperCache();
    if (!function_exists("HyperCacheRulesBlacklist")) {
        include_once dirname(__FILE__) . "/ressources/class.hyperCache-central.inc";
    }
    while (list($urikey, $FileType) = each($GLOBALS["MAINDB"])) {
        if (HyperCacheRulesBlacklist($urikey)) {
            if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
                echo "HyperCacheScanDBFile:: {$urikey} Blacklisted";
            }
            $GLOBAL["BLACKLISTED"][$urikey] = true;
            continue;
        }
        $SCANNED_URL = ifTracker($urikey);
        $H = parse_url($SCANNED_URL);
        $path = $H["path"];
        $filename = basename($path);
        $extention = $unix->file_extension($filename);
        $GetMimeFromExtension = GetMimeFromExtension($extention);
        if ($GetMimeFromExtension != null) {
            if ($FileType != $GetMimeFromExtension) {
                $FileType = $GetMimeFromExtension;
                $ARRAY_SAVE[$urikey] = $FileType;
            }
        } else {
            if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
                echo "HyperCacheScanDBFile:: {$SCANNED_URL} {$filename}/{$FileType} - {$extention} no MIME ??\n";
            }
        }
        if ($FileType == "NONE") {
            $FileType = HyperCacheGetMimeType($urikey, $ID);
            if ($FileType == null) {
                $GLOBAL["BLACKLISTED"][$urikey] = true;
                continue;
            }
            $ARRAY_SAVE[$urikey] = $FileType;
        }
        if (!isset($FileTypesArray[$FileType])) {
            if (!$HyPerCacheClass->ChecksOtherRules($urikey, $FileType, $ID)) {
                $GLOBAL["BLACKLISTED"][$urikey] = true;
                if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
                    events("{$urikey} {$FileType} No match...", $ID, 3, __LINE__);
                }
                continue;
            }
        }
        $TargetFile = HyperCacheScanBuildLocalPath($urikey, $ID);
        $FullTargetFile = $GLOBALS["HyperCacheStoragePath"] . "/" . $TargetFile;
        if (is_file($FullTargetFile)) {
            continue;
        }
        events("Downloading {$urikey} [{$FileType}]", $ID, 2, __LINE__);
        HyperCacheScanDownload($urikey, $TargetFile, $ID, $FileType);
    }
    if (count($GLOBAL["BLACKLISTED"]) > 0) {
        HyperCacheScanDBFile_removebulk($dbfile, $GLOBAL["BLACKLISTED"]);
    }
    HyperCacheScanDBFile_setbulk($dbfile, $ARRAY_SAVE);
    $filemm = filemtime($dbfile);
    $Cache[$ID][$dbfile] = $filemm;
    @file_put_contents("/usr/share/squid3/lastScan.array", serialize($Cache));
}
コード例 #3
0
ファイル: ufdbgclient.php プロジェクト: articatech/artica
function ufdbconfig()
{
    $quota = new ufdbgquota();
    if (!is_file("/etc/artica-postfix/settings/Daemons/WebFilteringRansomware")) {
        $GLOBALS["WebFilteringRansomware"] = 1;
        @file_put_contents("/etc/artica-postfix/settings/Daemons/WebFilteringRansomware", 1);
    }
    $GLOBALS["EnableITChart"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableITChart"));
    $GLOBALS["HTTrackInSquid"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HTTrackInSquid"));
    $GLOBALS["GoogleSafeBrowsingApiKey"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/GoogleSafeBrowsingApiKey"));
    $GLOBALS["EnableGoogleSafeBrowsing"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableGoogleSafeBrowsing"));
    $GLOBALS["GoogleSafeBrowsingCacheTime"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/GoogleSafeBrowsingCacheTime"));
    $GLOBALS["HyperCacheStoragePath"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheStoragePath"));
    $GLOBALS["HyperCacheMemEntries"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheMemEntries"));
    $GLOBALS["HyperCacheBuffer"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheBuffer"));
    $GLOBALS["SquidUrgency"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidUrgency"));
    $GLOBALS["UpdateUtilityForceProxy"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/UpdateUtilityForceProxy"));
    $GLOBALS["HyperCacheHTTPListenPort"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheHTTPListenPort"));
    if ($GLOBALS["HyperCacheHTTPListenPort"] == 0) {
        $GLOBALS["HyperCacheHTTPListenPort"] = 8700;
    }
    $GLOBALS["HyperCacheListenAddr"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheListenAddr"));
    $GLOBALS["EnableHTTPSURBL"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableHTTPSURBL"));
    $GLOBALS["PHISHTANK"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableSquidPhishTank"));
    $GLOBALS["WindowsUpdateCaching"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateCaching"));
    $GLOBALS["WindowsUpdateCachingDir"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateCachingDir");
    if ($GLOBALS["WindowsUpdateCachingDir"] == null) {
        $GLOBALS["WindowsUpdateCachingDir"] = "/home/squid/WindowsUpdate";
    }
    $GLOBALS["SquidGuardRedirectSSLBehavior"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardRedirectSSLBehavior"));
    $GLOBALS["SquidGuardRedirectBehavior"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardRedirectBehavior"));
    $GLOBALS["SquidGuardRedirectHTTPCode"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardRedirectHTTPCode"));
    if ($GLOBALS["SquidGuardRedirectBehavior"] == null) {
        $GLOBALS["SquidGuardRedirectBehavior="] = "url";
    }
    if ($GLOBALS["SquidGuardRedirectSSLBehavior"] == null) {
        $GLOBALS["SquidGuardRedirectSSLBehavior="] = "url";
    }
    if (!is_numeric($GLOBALS["SquidGuardRedirectHTTPCode"])) {
        $GLOBALS["SquidGuardRedirectHTTPCode"] = 302;
    }
    $GLOBALS["SquidGuardWebUseExternalUri"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebUseExternalUri"));
    $GLOBALS["SquidGuardWebExternalUri"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebExternalUri"));
    $GLOBALS["SquidGuardWebExternalUriSSL"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebExternalUriSSL"));
    $GLOBALS["SquidGuardWebSSLCompatibility"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebSSLCompatibility"));
    $GLOBALS["SquidGuardServerName"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardServerName");
    $GLOBALS["SquidGuardApachePort"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardApachePort"));
    $GLOBALS["SquidGuardApacheSSLPort"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardApacheSSLPort"));
    if ($GLOBALS["SquidGuardApachePort"] == 0) {
        $GLOBALS["SquidGuardApachePort"] = 9025;
    }
    if ($GLOBALS["SquidGuardApacheSSLPort"] == 0) {
        $GLOBALS["SquidGuardApacheSSLPort"] = 9020;
    }
    if ($GLOBALS["SquidGuardServerName"] == null) {
        $GLOBALS["SquidGuardServerName"] = php_uname("n");
    }
    if ($GLOBALS["HyperCacheStoragePath"] == null) {
        $GLOBALS["HyperCacheStoragePath"] = "/home/artica/proxy-cache";
    }
    if ($GLOBALS["GoogleSafeBrowsingCacheTime"] == 0) {
        $GLOBALS["GoogleSafeBrowsingCacheTime"] = 10080;
    }
    $GLOBALS["GoogleSafeBrowsingDNS"] = trim(strtolower(@file_get_contents("/etc/artica-postfix/settings/Daemons/GoogleSafeBrowsingDNS")));
    $GLOBALS["GoogleSafeBrowsingInterface"] = trim(strtolower(@file_get_contents("/etc/artica-postfix/settings/Daemons/GoogleSafeBrowsingInterface")));
    if ($GLOBALS["HyperCacheMemEntries"] == 0) {
        $GLOBALS["HyperCacheMemEntries"] = 500000;
    }
    if ($GLOBALS["HyperCacheBuffer"] == 0) {
        $GLOBALS["HyperCacheBuffer"] = 50;
    }
    if ($GLOBALS["GoogleSafeBrowsingDNS"] == null) {
        $GLOBALS["GoogleSafeBrowsingDNS"] = "8.8.8.8,4.4.4.4";
    }
    if ($GLOBALS["GoogleSafeBrowsingDNS"] == "*") {
        $GLOBALS["GoogleSafeBrowsingDNS"] = null;
    }
    if ($GLOBALS["GoogleSafeBrowsingDNS"] == "default") {
        $GLOBALS["GoogleSafeBrowsingDNS"] = null;
    }
    if ($GLOBALS["GOOGLE_SAFE"]) {
        events("ufdbconfig:: /etc/artica-postfix/settings/Daemons/EnableGoogleSafeBrowsing = {$GLOBALS["EnableGoogleSafeBrowsing"]}");
    }
    $GLOBALS["PROXY"] = array();
    $ini = new Bs_IniHandler();
    $datas = @file_get_contents("/etc/artica-postfix/settings/Daemons/ArticaProxySettings");
    if (trim($datas) != null) {
        $ini->loadString($datas);
    }
    if (isset($ini->_params["PROXY"])) {
        $GLOBALS["PROXY"] = $ini->_params["PROXY"];
    }
    $GLOBALS["SquidEnforceRules"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidEnforceRules"));
    $EnableUfdbGuard = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableUfdbGuard"));
    $UseRemoteUfdbguardService = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/UseRemoteUfdbguardService"));
    $EnableRemoteStatisticsAppliance = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableRemoteStatisticsAppliance"));
    $datas = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/ufdbguardConfig")));
    $RemoteStatisticsApplianceSettings = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/RemoteStatisticsApplianceSettings")));
    $SquidGuardIPWeb = unserialize(@file_get_contents("/var/log/squid/SquidGuardIPWeb"));
    if (is_array($SquidGuardIPWeb)) {
        $GLOBALS["SquidGuardIPWeb"] = $SquidGuardIPWeb["SquidGuardIPWeb"];
    }
    $SquidGuardWebUseExternalUri = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebUseExternalUri"));
    if ($SquidGuardWebUseExternalUri == 1) {
        $GLOBALS["SquidGuardIPWeb"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebExternalUri");
        $GLOBALS["SquidGuardIPWeb_SSL"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebExternalUriSSL");
    }
    if ($GLOBALS["SquidEnforceRules"] == 1) {
        HyperCacheRulesLoad();
    }
    if (!isset($datas["url_rewrite_children_concurrency"])) {
        $datas["url_rewrite_children_concurrency"] = 2;
    }
    $GLOBALS["url_rewrite_concurrency"] = $datas["url_rewrite_children_concurrency"];
    $GLOBALS["UfdbgclientSockTimeOut"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/UfdbgclientSockTimeOut"));
    if ($GLOBALS["UfdbgclientSockTimeOut"] == 0) {
        $GLOBALS["UfdbgclientSockTimeOut"] = 2;
    }
    $GLOBALS["UfdbgclientMaxSockTimeOut"] = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/UfdbgclientMaxSockTimeOut"));
    if ($GLOBALS["UfdbgclientMaxSockTimeOut"] == 0) {
        $GLOBALS["UfdbgclientMaxSockTimeOut"] = 5;
    }
    if (!isset($datas["remote_port"])) {
        $datas["remote_port"] = 3977;
    }
    if (!isset($datas["remote_server"])) {
        $datas["remote_server"] = "127.0.0.1";
    }
    if (!is_numeric($datas["remote_port"])) {
        $datas["remote_port"] = 3977;
    }
    if (trim($datas["remote_server"] == null)) {
        $datas["remote_server"] = "127.0.0.1";
    }
    if (!isset($datas["remote_server"])) {
        $datas["remote_server"] = null;
    }
    if (!isset($datas["remote_port"])) {
        $datas["remote_port"] = 3977;
    }
    if ($datas["remote_server"] == "all") {
        $datas["remote_server"] = "127.0.0.1";
    }
    if ($datas["remote_server"] == null) {
        $datas["remote_server"] = "127.0.0.1";
    }
    if (!is_numeric($datas["remote_port"])) {
        $datas["remote_port"] = 3977;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        $GLOBALS["EnableUfdbGuard"] = 1;
        $datas["remote_server"] = $RemoteStatisticsApplianceSettings["SERVER"];
        $UseRemoteUfdbguardService = 1;
        $GLOBALS["EnableUfdbGuard"] = 1;
        $datas["remote_port"] = $datas["listen_port"];
        events("Using remote appliance {$RemoteStatisticsApplianceSettings["SERVER"]}:{$datas["listen_port"]} as Web filtering engine");
        $GLOBALS["UFDB_SERVER"] = $RemoteStatisticsApplianceSettings["SERVER"];
        $GLOBALS["UFDB_PORT"] = $datas["listen_port"];
        return;
    }
    if ($UseRemoteUfdbguardService == 1) {
        $GLOBALS["EnableUfdbGuard"] = 1;
        $GLOBALS["UFDB_SERVER"] = $datas["remote_server"];
        $GLOBALS["UFDB_PORT"] = $datas["remote_port"];
        if (!is_numeric($GLOBALS["UFDB_PORT"])) {
            $GLOBALS["UFDB_PORT"] = 3977;
        }
        if (trim($GLOBALS["UFDB_SERVER"] == null)) {
            $GLOBALS["UFDB_SERVER"] = "127.0.0.1";
        }
        if (!isset($GLOBALS["UFDB_SERVER"])) {
            $GLOBALS["UFDB_SERVER"] = null;
        }
        if (!isset($GLOBALS["UFDB_PORT"])) {
            $GLOBALS["UFDB_PORT"] = 3977;
        }
        if ($GLOBALS["UFDB_SERVER"] == "all") {
            $GLOBALS["UFDB_SERVER"] = "127.0.0.1";
        }
        if ($GLOBALS["UFDB_SERVER"] == null) {
            $GLOBALS["UFDB_SERVER"] = "127.0.0.1";
        }
        if (!is_numeric($GLOBALS["UFDB_PORT"])) {
            $GLOBALS["UFDB_PORT"] = 3977;
        }
        events("Using remote service {$datas["remote_server"]}:{$datas["remote_port"]} as Web filtering engine");
        return;
    }
    if ($EnableUfdbGuard == 0) {
        events("Web filtering engine is disabled");
        $GLOBALS["EnableUfdbGuard"] = 0;
        return;
    }
    $effective_port = ufdbguard_value("port");
    $interface = ufdbguard_value("interface");
    $GLOBALS["UFDB_SERVER"] = $interface;
    $GLOBALS["UFDB_PORT"] = $effective_port;
    $GLOBALS["EnableUfdbGuard"] = 1;
    if (!is_numeric($GLOBALS["UFDB_PORT"])) {
        $GLOBALS["UFDB_PORT"] = 3977;
    }
    if (trim($GLOBALS["UFDB_SERVER"] == null)) {
        $GLOBALS["UFDB_SERVER"] = "127.0.0.1";
    }
    if (!isset($GLOBALS["UFDB_SERVER"])) {
        $GLOBALS["UFDB_SERVER"] = null;
    }
    if (!isset($GLOBALS["UFDB_PORT"])) {
        $GLOBALS["UFDB_PORT"] = 3977;
    }
    if ($GLOBALS["UFDB_SERVER"] == "all") {
        $GLOBALS["UFDB_SERVER"] = "127.0.0.1";
    }
    if ($GLOBALS["UFDB_SERVER"] == null) {
        $GLOBALS["UFDB_SERVER"] = "127.0.0.1";
    }
    if (!is_numeric($GLOBALS["UFDB_PORT"])) {
        $GLOBALS["UFDB_PORT"] = 3977;
    }
    events("Using local service {$interface}:{$effective_port} as Web filtering engine");
    events("Redirect engine:{$GLOBALS["SquidGuardRedirectBehavior"]} CODE {$GLOBALS["SquidGuardRedirectHTTPCode"]}");
}
コード例 #4
0
ファイル: ufdbgclient.php プロジェクト: brucewu16899/1.6.x
function ufdbconfig(){
	
	
	$GLOBALS["GoogleSafeBrowsingApiKey"]=trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/GoogleSafeBrowsingApiKey"));
	$GLOBALS["EnableGoogleSafeBrowsing"]=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableGoogleSafeBrowsing"));
	$GLOBALS["GoogleSafeBrowsingCacheTime"]=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/GoogleSafeBrowsingCacheTime"));
	
	$GLOBALS["HyperCacheStoragePath"]=trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheStoragePath"));
	$GLOBALS["HyperCacheMemEntries"]=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheMemEntries"));
	$GLOBALS["HyperCacheBuffer"]=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheBuffer"));
	
	
	$GLOBALS["HyperCacheHTTPListenPort"]=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheHTTPListenPort"));
	if($GLOBALS["HyperCacheHTTPListenPort"]==0){$GLOBALS["HyperCacheHTTPListenPort"]=8700;}
	
	$GLOBALS["HyperCacheListenAddr"]=trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/HyperCacheListenAddr"));
	
	
	
	
	if($GLOBALS["HyperCacheStoragePath"]==null){$GLOBALS["HyperCacheStoragePath"]="/home/artica/proxy-cache";}
	if($GLOBALS["GoogleSafeBrowsingCacheTime"]==0){$GLOBALS["GoogleSafeBrowsingCacheTime"]=10080;}
	$GLOBALS["GoogleSafeBrowsingDNS"]=trim(strtolower(@file_get_contents("/etc/artica-postfix/settings/Daemons/GoogleSafeBrowsingDNS")));
	$GLOBALS["GoogleSafeBrowsingInterface"]=trim(strtolower(@file_get_contents("/etc/artica-postfix/settings/Daemons/GoogleSafeBrowsingInterface")));
	
	
	if($GLOBALS["HyperCacheMemEntries"]==0){$GLOBALS["HyperCacheMemEntries"]=500000;}
	if($GLOBALS["HyperCacheBuffer"]==0){$GLOBALS["HyperCacheBuffer"]=50;}
	
	
	if($GLOBALS["GoogleSafeBrowsingDNS"]==null){$GLOBALS["GoogleSafeBrowsingDNS"]="8.8.8.8,4.4.4.4";}
	if($GLOBALS["GoogleSafeBrowsingDNS"]=="*"){$GLOBALS["GoogleSafeBrowsingDNS"]=null;}
	if($GLOBALS["GoogleSafeBrowsingDNS"]=="default"){$GLOBALS["GoogleSafeBrowsingDNS"]=null;}
	
	
	if($GLOBALS["GOOGLE_SAFE"]){
		events("ufdbconfig:: /etc/artica-postfix/settings/Daemons/EnableGoogleSafeBrowsing = {$GLOBALS["EnableGoogleSafeBrowsing"]}");
	}
	
	$GLOBALS["PROXY"]=array();
	$ini=new Bs_IniHandler();
	
	$datas=@file_get_contents("/etc/artica-postfix/settings/Daemons/ArticaProxySettings");
	if(trim($datas)<>null){$ini->loadString($datas);}
	if(isset($ini->_params["PROXY"])){$GLOBALS["PROXY"]=$ini->_params["PROXY"];}
	
	$GLOBALS["SquidEnforceRules"]=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidEnforceRules"));
	$GLOBALS["EnableStreamCache"]=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableStreamCache"));
	$EnableUfdbGuard=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableUfdbGuard"));
	$UseRemoteUfdbguardService=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/UseRemoteUfdbguardService"));
	$EnableRemoteStatisticsAppliance=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableRemoteStatisticsAppliance"));
	$datas=unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/ufdbguardConfig")));
	$RemoteStatisticsApplianceSettings=unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/RemoteStatisticsApplianceSettings")));
	$SquidGuardIPWeb=unserialize(@file_get_contents("/var/log/squid/SquidGuardIPWeb"));
	if(is_array($SquidGuardIPWeb)){$GLOBALS["SquidGuardIPWeb"]=$SquidGuardIPWeb["SquidGuardIPWeb"];}
	$SquidGuardWebUseExternalUri=intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebUseExternalUri"));
	if($SquidGuardWebUseExternalUri==1){
		$GLOBALS["SquidGuardIPWeb"]=@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebExternalUri");
		$GLOBALS["SquidGuardIPWeb_SSL"]=@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidGuardWebExternalUriSSL");
	}
	
	if($GLOBALS["SquidEnforceRules"]==1){
		HyperCacheRulesLoad();
	}
	
	

	if(!is_numeric($datas["remote_port"])){$datas["remote_port"]=3977;}
	if(trim($datas["remote_server"]==null)){$datas["remote_server"]="127.0.0.1";}
	if(!isset($datas["remote_server"])){$datas["remote_server"]=null;}
	if(!isset($datas["remote_port"])){$datas["remote_port"]=3977;}
	if($datas["remote_server"]=="all"){$datas["remote_server"]="127.0.0.1";}
	if($datas["remote_server"]==null){$datas["remote_server"]="127.0.0.1";}
	if(!is_numeric($datas["remote_port"])){$datas["remote_port"]=3977;}

	
	if($EnableRemoteStatisticsAppliance==1){
		$GLOBALS["EnableUfdbGuard"]=1;
		$datas["remote_server"]=$RemoteStatisticsApplianceSettings["SERVER"];
		$UseRemoteUfdbguardService=1;
		$GLOBALS["EnableUfdbGuard"]=1;
		$datas["remote_port"]=$datas["listen_port"];
		events("Using remote appliance {$RemoteStatisticsApplianceSettings["SERVER"]}:{$datas["listen_port"]} as Web filtering engine");
		$GLOBALS["UFDB_SERVER"]=$RemoteStatisticsApplianceSettings["SERVER"];
		$GLOBALS["UFDB_PORT"]=$datas["listen_port"];
		return;
	}

	
	if($UseRemoteUfdbguardService==1){
		$GLOBALS["EnableUfdbGuard"]=1;
		$GLOBALS["UFDB_SERVER"]=$datas["remote_server"];
		$GLOBALS["UFDB_PORT"]=$datas["remote_port"];
		if(!is_numeric($GLOBALS["UFDB_PORT"])){$GLOBALS["UFDB_PORT"]=3977;}
		if(trim($GLOBALS["UFDB_SERVER"]==null)){$GLOBALS["UFDB_SERVER"]="127.0.0.1";}
		if(!isset($GLOBALS["UFDB_SERVER"])){$GLOBALS["UFDB_SERVER"]=null;}
		if(!isset($GLOBALS["UFDB_PORT"])){$GLOBALS["UFDB_PORT"]=3977;}
		if($GLOBALS["UFDB_SERVER"]=="all"){$GLOBALS["UFDB_SERVER"]="127.0.0.1";}
		if($GLOBALS["UFDB_SERVER"]==null){$GLOBALS["UFDB_SERVER"]="127.0.0.1";}
		if(!is_numeric($GLOBALS["UFDB_PORT"])){$GLOBALS["UFDB_PORT"]=3977;}
		events("Using remote service {$datas["remote_server"]}:{$datas["remote_port"]} as Web filtering engine");
		
		return;
	}
	if($EnableUfdbGuard==0){
		events("Web filtering engine is disabled");
		$GLOBALS["EnableUfdbGuard"]=0;
		return;
	}
	$effective_port=ufdbguard_value("port");
	$interface=ufdbguard_value("interface");
	
	$GLOBALS["UFDB_SERVER"]=$interface;
	$GLOBALS["UFDB_PORT"]=$effective_port;
	$GLOBALS["EnableUfdbGuard"]=1;
	if(!is_numeric($GLOBALS["UFDB_PORT"])){$GLOBALS["UFDB_PORT"]=3977;}
	if(trim($GLOBALS["UFDB_SERVER"]==null)){$GLOBALS["UFDB_SERVER"]="127.0.0.1";}
	if(!isset($GLOBALS["UFDB_SERVER"])){$GLOBALS["UFDB_SERVER"]=null;}
	if(!isset($GLOBALS["UFDB_PORT"])){$GLOBALS["UFDB_PORT"]=3977;}
	if($GLOBALS["UFDB_SERVER"]=="all"){$GLOBALS["UFDB_SERVER"]="127.0.0.1";}
	if($GLOBALS["UFDB_SERVER"]==null){$GLOBALS["UFDB_SERVER"]="127.0.0.1";}
	if(!is_numeric($GLOBALS["UFDB_PORT"])){$GLOBALS["UFDB_PORT"]=3977;}
	events("Using local service {$interface}:{$effective_port} as Web filtering engine");
}