View Single Post
Old 12-17-2007, 04:03 PM   #2 (permalink)
ReSpawN
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

I kinda refixed the script, using PHP 5.2.5.
Execute.php;
PHP Code:
<a href="<[siteurl]>"Hello </a>
<
phpcode>
if(
true)
{
    echo 
'First off, why would you use echo ()? It\'s a function more simply used as echo "this";, not like you had.<br>';
    echo 
'next off, tryping if (TRUE) { on one line, not on two, will shorten the length of your script thus the load time.';
}
</
phpcode
File.php;
PHP Code:
<?php
        
        
//runs the php within template files             
        
function Runphp($txt)
        {    
            
//split it away from the rest of the text
            
$php preg_split("/(<phpcode>.*<\\/phpcode>)/Us"$txt, -1PREG_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
                
}
            }
        }  

        
$file file_get_contents('execute.php');
        
        
Runphp($file);
        
?>
Exports:
PHP Code:
First offwhy would you use echo ()? It's a function more simply used as echo "this";, not like you had.
next off, tryping if (TRUE) { on one line, not on two, will shorten the length of your script thus the load time. 
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote