ähm nur
Code: Alles auswählen
$_cachedCode = $code;
Code: Alles auswählen
$_cachedCode = $code;
Code: Alles auswählen
$output = '<?php $_cachedCode = $code ?>'.$output;
Code: Alles auswählen
$output = '<'.'?php $_cachedCode = Array(); $_cachedCode["update"] = false; $_cachedCode["code"] = $code; ?'.'>'."\n".$output;
$output.= '<'.'?php if ($_cachedCode["update"] == true) conUpdateCacheCode('."$idcatart,$lang,$client,0,'',true".'); ?'.'>'."\n";
Code: Alles auswählen
//Standardfall
$part = ereg_replace('=([[:digit:]]+)[[:space:]](.*)cache!>',
'<!?php if ((time() > '.time().'+\\1) and (!$edit)):'."\n".
'ob_start();'."\n".
'\\2'."\n".
'$cached_code=ob_get_flush();'."\n".
'conUpdateCacheCode('."$idcatart,$lang,$client,$cacheid".',$cached_code);'."\n".
'else:?!>'."\n".
'<!--cached code id '."$cacheid -->\n".
'<?php'."\n".
'\\2'."\n".
'?>'."\n".
'<!--cached code id '."$cacheid -->\n".
'<!?endif;?!>',$part);
Code: Alles auswählen
$tag = "<!-- cached code id $cacheid -->"; // the cache block delimiter
//Standardfall
$part = ereg_replace('=([[:digit:]]+)[[:space:]](.*)cache!>',
'<!?php if ((time() > '.time().'+\\1) and (!$edit)):'."\n".
'ob_start();'."\n".
'\\2'."\n".
'$_cachedCode["update"] = true;'."\n".
'conUpdateCacheCode('."$idcatart,$lang,$client,$cacheid".',ob_get_flush());'."\n".
'else:?!>'."\n".
$tag."\n".
'<?php'."\n".
'\\2'."\n".
'?>'."\n".
$tag."\n".
'<!?endif;?!>',$part);
Code: Alles auswählen
function conUpdateCacheCode($idcatart,$lang,$client,$cacheid,$newCodeBlock, $update = false)
{
global $_cachedCode;
if (!$update) {
$tag = "<!-- cached code id $cacheid -->"; // the cache block delimiter
$codearr = explode($tag, $_cachedCode['code']); // explode the old code and ...
$_cachedCode['code'] = $codearr[0].$tag.$newCodeBlock.$tag.$codearr[2]; //...glue together the new one
$_cachedCode['code'] = preg_replace("/if \(\(time\(\) > \d*\+(\d*)\)/","if ((time() > ".time()."+$1)", $_cachedCode['code']); // fit it into the code for expiration checking
} else {
echo "<!-- CACHED PARTS UPDATED //-->";
global $cfg;
$db = new DB_Contenido();
$sql = "UPDATE ".$cfg["tab"]["code"]." SET `code`='".addslashes(addslashes($_cachedCode['code']))."' WHERE `idcatart` = ".$idcatart." AND `idlang` = ".$lang." AND `idclient` = ".$client.";";// do not forget to addslash twice.
$db->query($sql);
}
}
Code: Alles auswählen
preg_replace("/if \(\(time\(\) > \d*\+(\d*)\)/","if ((time() > ".time()."+$1)", $_cachedCode['code']); // fit it into the code for expiration checking
die änderung find, oder versteh ich nicht...preg für Zeitupdate gefixt.
check ich momentan auch nicht...Zwischen <!cache=x und dem nächsten <container /> muss ein HTML-Tag stehen, sonst geht der Container nicht.