ظ†ط¸ط§ظ… ظ‚ظˆط§ظ„ط¨ ط¬ط¯ظٹط¯ ظ…ظ† ط¨ط±ظ…ط¬طھظٹ



رمز PHP:
<code style="white-space:nowrap"> <code> <?php
class template{

var
$vars;
var
$fid;
var
$temp_dir;
var
$cache_dir;
//Function to load a template file.


//Function to parse the Template Tags

function parse(){
//Foreach Statement
$this->files&#91;$this->fid&#93; = preg_replace("'<LOOP NAME=\"(.+)\">'i","<? foreach(\$this->vars&#91;\\1&#93; as \$key=>\$var){ ?>",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93; = preg_replace("'</LOOP>'i","<? } ?>",$this->files&#91;$this->fid&#93;
//Include Statement
$this->files&#91;$this->fid&#93; = preg_replace("'<INCLUDE FILENAME=\"(.+)\">'i","<? include(\"\\1\"); ?>",$this->files&#91;$this->fid&#93;
//Foreach Variables
$this->files&#91;$this->fid&#93; = preg_replace("'{{(.+)}}'","<?= \$var&#91;\\1&#93;?>",$this->files&#91;$this->fid&#93;
//Variables
$this->files&#91;$this->fid&#93; = preg_replace("'{(.+)}'","<?= \$this->vars&#91;\\1&#93;?>",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93; = preg_replace("'<else>'","<? else{ ?>",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;= preg_replace('/\<if condtion\=\"(.*)\\ (.*)\\ (.*)\">/','<?if($GLOBALS&#91;$1&#93;$2$3){?>',$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;= preg_replace('/\<\/if\>/','<?}?>',$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93; = preg_replace('/(<ELSE>|<ELSE \/>)/i','<? }else{ ?>',$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("neq","!=",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("eq","==",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("neq","!=",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("gt",">",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("lt","<",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("and","&&",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("orrrr","||",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("not","!",$this->files&#91;$this->fid&#93;
$this->files&#91;$this->fid&#93;=str_replace("mod","%",$this->files&#91;$this->fid&#93;
return
$this->files&#91;$this->fid&#93;;
}
FUNCTION
check_output($file)
{



if(
file_exists($file))
{
$check = @fopen("$file",r);
$r = @fread($check,filesize("$file"));
@
fclose($check);

}
return
$r;

}
//Function to OUTPUT
function print_temp($filename) {
$this->fid = "$this->cache_dir/$filename.php";
$this->parse();
$this->files&#91;$this->fid&#93; = file_get_contents("$this->temp_dir/$filename");
$this->vars = &$GLOBALS;
$this->parse();
if (!
is_writeable($this->cache_dir ) ) {
$m = @chmod($this->cache_dir, 0777);
$m = @chmod('class.php', 0777);
if(
$m){echo"تم";}
$html=$this->parse();
$check= $this->check_output($this->fid);
if(
$this->fid != $this->files&#91;$this->fid&#93{
if(
$check != $html)
{

$fp = fopen($this->fid,"w");
fwrite($fp,$this->files&#91;$this->fid&#93;
fclose($fp);

}
}
}else{
$html=$this->parse();
$check= $this->check_output($this->fid);
if(
$this->fid != $this->files&#91;$this->fid&#93{
if(
$check != $html)
{

$fp = fopen($this->fid,"w");
fwrite($fp,$this->files&#91;$this->fid&#93;
fclose($fp);

}
}
} include(
$this->fid);
}

}
?>
</code> </code>