Example #1
0
function HyperCacheRules($PROTO, $ToUfdb, $URI, $IP, $userid, $DEBUGHOSTNAME)
{
    if ($GLOBALS["SquidEnforceRules"] == 0) {
        return;
    }
    if (preg_match("#([0-9\\.]+)\\/(.*)#", $IP, $re)) {
        $IP = $re[1];
        $USER = $re[2];
    }
    if ($IP == "127.0.0.1") {
        return;
    }
    if ($PROTO != "GET") {
        if ($GLOBALS["HyperCacheDebug"]) {
            events("HyperCacheRules:{$PROTO}/{$IP} <> GET ABORT");
        }
        return false;
    }
    if ($GLOBALS["SquidEnforceRules"] == 0) {
        if ($GLOBALS["HyperCacheDebug"]) {
            events("HyperCacheRules:{$IP} Not enabled <> GET ABORT");
        }
        return;
    }
    if (HyperCacheRulesBlacklist($DEBUGHOSTNAME)) {
        return;
    }
    $URI = HyperCacheCleanUri($URI);
    if ($GLOBALS["HyperCacheOK"][md5($URI)]) {
        Output_results($GLOBALS["HyperCacheOK"][md5($URI)], __FUNCTION__, __LINE__);
        if ($GLOBALS["HyperCacheDebug"]) {
            events("HyperCacheRules:`{$URI}` -> REDIRECT MEM");
        }
        return true;
    }
    include_once dirname(__FILE__) . "/ressources/class.HyperCache.inc";
    include_once dirname(__FILE__) . "/ressources/class.hyperCache-central.inc";
    $HyperCache = new HyperCache();
    if ($HyperCache->HyperCacheRulesMatchPattern($GLOBALS["HyperCacheListenAddr"], $URI)) {
        return false;
    }
    if (HyperCacheRuleMirror($URI)) {
        return true;
    }
    if (HyperCacheWhiteUri($URI)) {
        return false;
    }
    $ID = $HyperCache->HyperCacheRulesMatches($URI);
    if ($ID == 0) {
        if ($GLOBALS["HyperCacheDebug"]) {
            events("HyperCacheRules: ID == {$ID} FALSE [" . __LINE__ . "]");
        }
        return false;
    }
    if (HyperCacheRulesSave($URI, $ID)) {
        return true;
    }
    if ($GLOBALS["HyperCacheDebug"]) {
        events("HyperCacheRules:`{$URI}` no match");
    }
}
Example #2
0
function HyperCacheRules($PROTO,$ToUfdb,$URI,$IP,$userid,$DEBUGHOSTNAME){
	
	
	if(preg_match("#([0-9\.]+)\/(.*)#", $IP,$re)){
		$IP=$re[1];
		$USER=$re[2];
	}
	if($IP=="127.0.0.1"){return;}
	
	
	
	
	if($PROTO<>"GET"){
		if($GLOBALS["HyperCacheDebug"]){events("HyperCacheRules:$PROTO/$IP <> GET ABORT");}
		return false;
	}
	if($GLOBALS["SquidEnforceRules"]==0){
		if($GLOBALS["HyperCacheDebug"]){events("HyperCacheRules:$IP Not enabled <> GET ABORT");}
		return;
	}
	
	if(HyperCacheRulesBlacklist($DEBUGHOSTNAME)){return;}
	
	$URI=HyperCacheCleanUri($URI);
	
	if($GLOBALS["HyperCacheOK"][md5($URI)]){
		Output_results($GLOBALS["HyperCacheOK"][md5($URI)]);
		if($GLOBALS["HyperCacheDebug"]){events("HyperCacheRules:`$URI` -> REDIRECT MEM");}
		return true;
		
	}
	
	$HyperCache=new HyperCache();
	if($HyperCache->HyperCacheRulesMatchPattern($GLOBALS["HyperCacheListenAddr"], $URI)){return false;}
	
	if(HyperCacheRuleMirror($URI)){return true;}
	if(HyperCacheWhiteUri($URI)){return false;}
	
	
	$ID=$HyperCache->HyperCacheRulesMatches($URI);
	if($ID==0){return false;}
	
	if(HyperCacheRulesSave($URI,$ID)){return true;}
	
	if($GLOBALS["HyperCacheDebug"]){events("HyperCacheRules:`$URI` no match");}
}