12-17-2007, 01:30 AM
|
#1 (permalink)
|
|
The Addict
Join Date: Nov 2007
Posts: 264
Thanks: 2
|
Having an issue with eval'd code
Well this is the file thats being parsed
PHP Code:
<a href="<[siteurl]>"> Hello </a>
<phpcode>
if(true)
{
echo('ello there');
}
</phpcode>
and this is the file that runs the code within <phpcode>
PHP Code:
//runs the php within template files
public function Runphp($txt)
{
//split it away from the rest of the text
$php = preg_split("/(<phpcode>.*<\\/phpcode>)/Us", $txt, -1, PREG_SPLIT_DELIM_CAPTURE);
$stop = count($php);
//run the loop and execute the php
for($phpe = 0; $phpe < $stop; ++$phpe)
{
$phpexc = $php[$phpe];
if (preg_match("/^<phpcode>(.*)<\\/phpcode>/Us", $phpexc, $phpexec))
{
$phpex_p = $phpexec[1];
ob_start();
eval($phpex_p);
$c = ob_get_clean;
$c = str_replace('ob_get_clean','',$c);
$c = preg_replace('/(<phpcode>.*<\\/phpcode>)/Us',$c,$txt,$stop);
return $c; //return it
}
}
}
maybe I'm missing something plainly obvious but the hello link is supposed to be before the 'ello there' and it's being switched around, any help would be appreciated
(sorry if it's in the wrong section)
|
|
|
|