From:             springchun at 21cn dot com
Operating system: linux
PHP version:      4.3.1
PHP Bug Type:     Unknown/Other Function
Bug description:  This is best php template 

Description:
------------
This is best php template than Smarty,FastTemplate and PHPLIB Template;
Is it add this function into php5.0.dll?
please seen 'http://www.cqlc.net/document.txt';
function cqlctpl($file)
            {
            $fp=fopen($file,"r");
           
$msg="echo\"".str_replace("\"","\\\"",fread($fp,filesize($file)))."\";";
            fclose($fp);
            $oldstr=array(0=>"/\{loop:([^\}]+)\}(.+)\{\/loop\}/si",
                          1=>"/\{logi:([^\}]+)\}(.+)\{\/logi\}/si",
                          2=>"/\{exec:([^\}]+)\}/si",
                          3=>"/(\{\*[^\*]+\*\})/si"
                         );
            $newstr=array(0=>"\";\\1{echo\"\\2\";}echo\"",
                          1=>"\";\\1{echo\"\\2\";}echo\"",
                          2=>"\";\\1;echo\"",
                          3=>""
                         );
            return preg_replace($oldstr,$newstr,$msg);
            }


Reproduce code:
---------------
<?
   function cqlctpl($file)
            {
            $fp=fopen($file,"r");
           
$msg="echo\"".str_replace("\"","\\\"",fread($fp,filesize($file)))."\";";
            fclose($fp);
            $oldstr=array(0=>"/\{loop:([^\}]+)\}(.+)\{\/loop\}/si",
                          1=>"/\{logi:([^\}]+)\}(.+)\{\/logi\}/si",
                          2=>"/\{exec:([^\}]+)\}/si",
                          3=>"/(\{\*[^\*]+\*\})/si"
                         );
            $newstr=array(0=>"\";\\1{echo\"\\2\";}echo\"",
                          1=>"\";\\1{echo\"\\2\";}echo\"",
                          2=>"\";\\1;echo\"",
                          3=>""
                         );
            return preg_replace($oldstr,$newstr,$msg);
            }

  function test(){echo"<p>this is 2.tml ,welcome you";}

  $title="this is a tml";

  $body="this out ";

  for($i=0;$i<10;$i++)$array[$i]="hello world $i";

  eval(cqlctpl("1.txt"));



Expected result:
----------------
this is a tml (1.tml) 
  this out is hello world 0 

  this out is hello world 1 

  this out is hello world 2 

  this out is hello world 3 

  this out is hello world 4 

  this out is hello world 5 

  this out is hello world 6 

  6 is biger than 5 

  this out is hello world 7 

  7 is biger than 5 

  this out is hello world 8 

  8 is biger than 5 

  this out is hello world 9 

  9 is biger than 5 

  time is 1059193623 

  this is other tml(2.tml)
  this is 2.tml ,welcome you 


Actual result:
--------------
this is a tml (1.tml) 
  this out is hello world 0 

  this out is hello world 1 

  this out is hello world 2 

  this out is hello world 3 

  this out is hello world 4 

  this out is hello world 5 

  this out is hello world 6 

  6 is biger than 5 

  this out is hello world 7 

  7 is biger than 5 

  this out is hello world 8 

  8 is biger than 5 

  this out is hello world 9 

  9 is biger than 5 

  time is 1059193623 

  this is other tml(2.tml)
  this is 2.tml ,welcome you 


-- 
Edit bug report at http://bugs.php.net/?id=24818&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=24818&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=24818&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=24818&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24818&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24818&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24818&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24818&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24818&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24818&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24818&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24818&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24818&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24818&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24818&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24818&r=gnused

Reply via email to