background image

     return true;
    }

    function template($file) {

     global $tpldir, $objdir;

     $objfile = $objdir.$file.'.tpl.php';

        if(!file_exists($objfile)) {
            $tplfile = $tpldir.$file.'.htm';

            parse_template($tplfile);
        }

        return $objfile;
    }

    function parse_template($tplfile) {

        global $tpldir, $objdir;

     $file = basename($tplfile, '.htm');
     $objfile = $objdir.$file.'.tpl.php';

        if(!$fp = @fopen($tplfile, 'r')) {

      exit("current template file '$tplfile' not found or have no access!");
     }

     $template = fread($fp, max(filesize($tplfile), 1));
     fclose($fp);

        $template = preg_replace("/[nrt]*{subtemplates+([a-z0-9_:]+)}[nrt]*/is", 

"<?php include template('1'); ?>", $template);

     $template = preg_replace("/([nr]+)t+/s", "1", $template);
     $template = preg_replace("/<!--{(.+?)}-->/s", "{1}", $template);

        $template = preg_replace("/{($[a-za-z0-9_[]'"$.x7f-xff]+)}/s", "<?php echo 
1; ?>", $template);

        $template = preg_replace("/[nrt]*{evals+(.+?)}[nrt]*/is", "<?php 1; ?>", 

$template);
        $template = preg_replace("/[nrt]*{echos+(.+?)}[nrt]*/is", "<?php echo 1; ?

>", $template);
     $template = preg_replace("/([nrt]*){elseifs+(.+?)}([nrt]*)/is", "1<?php } 

elseif(2) { ?>3", $template);
     $template = preg_replace("/([nrt]*){else}([nrt]*)/is", "1<?php } else { ?>2", 

$template);

     for($i = 0; $i < 5; $i++) {
            $template = preg_replace("/[nrt]*{loops+(s+)s+(s+)}[nr]*(.+?)

[nr]*{/loop}[nrt]*/is", "<?php if(is_array(1)) { foreach(1 as 2) { ?>3<?php } } ?
>", $template);

            $template = preg_replace("/[nrt]*{loops+(s+)s+(s+)s+(s+)}[nrt]*(.+?)
[nrt]*{/loop}[nrt]*/is", "<?php if(is_array(1)) { foreach(1 as 2 => 3) { ?>4<?

php } } ?>", $template);
      $template = preg_replace("/([nrt]*){ifs+(.+?)}([nr]*)(.+?)([nr]*){/if}

([nrt]*)/is", "1<?php if(2) { ?>345<?php } ?>6", $template);
     }

        $template = preg_replace("/{([a-za-z_x7f-xff][a-za-z0-9_x7f-xff]*)}/s", 

"<?php echo 1; ?>", $template);
     $template = preg_replace("/ ?>[nr]*<?php /s", " ", $template);