Ejemplo n.º 1
0
function HyperCacheRetranslation_set($uri, $MD5File, $FileType, $TargetFile)
{
    $familysite = tool_get_familysite($uri);
    $unix = new unix();
    $extention = $unix->file_extension(basename($TargetFile));
    $dbfile = "/usr/share/squid3/HyperCache-{$familysite}-Retranslation.db";
    if (!is_file($dbfile)) {
        try {
            events("Creating {$dbfile} database", 0, 2, __LINE__);
            $db_desttmp = @dba_open($dbfile, "c", "db4");
        } catch (Exception $e) {
            $error = $e->getMessage();
            events("FATAL ERROR {$error} on {$dbfile}", 0, 0, __LINE__);
        }
        @dba_close($db_desttmp);
    }
    if (!is_file($dbfile)) {
        events("FATAL ERROR {$error} on {$dbfile}", 0, 0, __LINE__);
        return;
    }
    $db_con = dba_open($dbfile, "c", "db4");
    $md5 = md5($uri);
    $array["MD5FILE"] = $MD5File;
    $array["MD5TYPE"] = $FileType;
    $array["EXT"] = $extention;
    $array["TARGET"] = $TargetFile;
    if (!@dba_replace($md5, serialize($array), $db_con)) {
        events("{$dbfile} unable to save {$md5} information...", 0, 0, __LINE__);
        @dba_close($db_con);
        return;
    }
    return true;
}
Ejemplo n.º 2
0
function HyperCacheRetranslation_set($uri, $MD5File, $FileType, $TargetFile)
{
    $familysite = tool_get_familysite($uri);
    $unix = new unix();
    $extention = $unix->file_extension(basename($TargetFile));
    $dbfile = "/usr/share/squid3/HyperCache-{$familysite}-Retranslation.db";
    berekley_db_create($dbfile);
    if (!is_file($dbfile)) {
        events("FATAL ERROR on {$dbfile}", 0, 0, __LINE__);
        return;
    }
    $db_con = dba_open($dbfile, "c", "db4");
    $md5 = md5($uri);
    $array["MD5FILE"] = $MD5File;
    $array["MD5TYPE"] = $FileType;
    $array["EXT"] = $extention;
    $array["TARGET"] = $TargetFile;
    if (!@dba_replace($md5, serialize($array), $db_con)) {
        events("{$dbfile} unable to save {$md5} information...", 0, 0, __LINE__);
        @dba_close($db_con);
        return false;
    }
    @dba_close($db_con);
    return true;
}
Ejemplo n.º 3
0
function HyperCacheRules_set($URI, $ID)
{
    $uri_md5 = md5($URI);
    $familysite = tool_get_familysite($URI);
    $HyperCacheBuffer = $GLOBALS["HyperCacheBuffer"];
    if (!isset($GLOBALS["HYPER_CACHE_BUFFER_COUNT"])) {
        $GLOBALS["HYPER_CACHE_BUFFER_COUNT"] = 0;
    }
    $dbfile = "/usr/share/squid3/HyperCacheQueue-{$familysite}-{$ID}.db";
    $GLOBALS["HYPER_CACHE_BUFFER"][$dbfile][] = $URI;
    $GLOBALS["HYPER_CACHE_BUFFER_COUNT"]++;
    if ($GLOBALS["HyperCacheDebug"]) {
        events("HyperCacheRules_set: add to buffer {$GLOBALS["HYPER_CACHE_BUFFER_COUNT"]}/{$HyperCacheBuffer} [" . __LINE__ . "]");
    }
    if ($GLOBALS["HYPER_CACHE_BUFFER_COUNT"] < $HyperCacheBuffer) {
        return;
    }
    HyperCacheCleanBuffer();
}
Ejemplo n.º 4
0
function HyperCacheRules_set($URI,$ID){
	$uri_md5=md5($URI);
	$familysite=tool_get_familysite($URI);
	$HyperCacheBuffer=$GLOBALS["HyperCacheBuffer"];
	if(!isset($GLOBALS["HYPER_CACHE_BUFFER_COUNT"])){$GLOBALS["HYPER_CACHE_BUFFER_COUNT"]=0;}
	
	$dbfile="/usr/share/squid3/HyperCacheQueue-$familysite-$ID.db";
	$GLOBALS["HYPER_CACHE_BUFFER"][$dbfile][]=$URI;
	$GLOBALS["HYPER_CACHE_BUFFER_COUNT"]++;
	
	if($GLOBALS["HYPER_CACHE_BUFFER_COUNT"]<$HyperCacheBuffer){return true;}
	
	events("HyperCacheRules_set:: Clean buffer with {$GLOBALS["HYPER_CACHE_BUFFER_COUNT"]} elements...");
		
	while (list ($dbfile, $array) = each ($GLOBALS["HYPER_CACHE_BUFFER"]) ){
		if(!tool_create_berekley($dbfile)){return;}
		$db_con = @dba_open($dbfile, "c","db4");
		if(!$db_con){events("HyperCacheRules_set:: FATAL!!!::{$dbfile}, unable to open");return false; }
		while (list ($index, $url) = each ($array) ){
			events("HyperCacheRules_set:: Clean buffer $dbfile -> $url");
			if(!@dba_replace($url,"NONE",$db_con)){events("HyperCacheRules_set:: FAILED SAVING *** $URI ***"); @dba_close($db_con); return false; }
		}
		$GLOBALS["HYPER_CACHE_BUFFER"][$dbfile]=array();
		@dba_close($db_con);
	}
	$GLOBALS["HYPER_CACHE_BUFFER_COUNT"]=0;
	$GLOBALS["HYPER_CACHE_BUFFER"]=array();
	return true;

	
}