<?php
//////////////////////////////////////////////////////////////
///  phpEval() by James Heinrich <info@silisoftware.com>    //
//        available at http://www.silisoftware.com         ///
//////////////////////////////////////////////////////////////
//                                                          //
//         This code is released under the GNU GPL:         //
//           http://www.gnu.org/copyleft/gpl.html           //
//                                                          //
//      +---------------------------------------------+     //
//      | If you do use this code somewhere, send me  |     //
//      | an email and tell me how/where you used it. |     //
//      +---------------------------------------------+     //
//                                                          //
//////////////////////////////////////////////////////////////
///                                                         //
define('PHP_EVAL_VERSION''1.1.3');                        //
// v1.1.3 - June 26, 2005                                   //
//   * replaced stripslashes with SafeStripSlashes          //
//                                                          //
// v1.1.2 - November 28, 2002                               //
//   * removed &gt; and &lt; translation (highlight_string  //
//     does this automatically)                             //
//                                                          //
// v1.1.1 - September 19, 2002                              //
//   * syntax highlighting added                            //
//                                                          //
// v1.1.0 - September 17, 2002                              //
//   * now works with register_globals = off                //
//   * now requires PHP v4.1.0 or higher ($_SERVER, $_POST) //
//                                                          //
// v1.0.0 - May 10, 2002                                    //
//   * initial public release                               //
//                                                         ///
//////////////////////////////////////////////////////////////

function SafeStripSlashes($string) {
    if (
get_magic_quotes_gpc()) {
        
$string stripslashes($string);
    }
    return 
$string;
}

echo 
'<html><head><title>phpEval() v'.PHP_EVAL_VERSION.' (www.silisoftware.com)</title></head><body>';

if (@
$_POST['StatementToEvaluate']) {

    
$starttime time();
    eval(
SafeStripSlashes(@$_POST['StatementToEvaluate']));

    echo 
'<table border="1" width="500" cellspacing="0" cellpadding="10"><tr><td><b><pre>';
    if (
phpversion() >= '4.2.0') {
        
$highlighted_code highlight_string('<?php'."\n".@$_POST['StatementToEvaluate']."\n".'?>'true);
    } else {
        
ob_start();
        
highlight_string('<?php'."\n".@$_POST['StatementToEvaluate']."\n".'?>');
        
$highlighted_code ob_get_contents();
        
ob_end_clean();
    }
    
$highlighted_code str_replace('<font color="#0000BB">&lt;?php<br /></font>'''str_replace('<font color="#0000BB">?&gt;</font>'''$highlighted_code));
    echo 
$highlighted_code;
    echo 
'</pre></b></td></tr></table>';
    echo 
'Evaluated in '.number_format(time() - $starttime).' seconds';

} else {

    echo 
'Type in a PHP statement that you want evaluated.<br>';
    echo 
'Something like <pre>echo date(\'F j, Y g:ia\');</pre><br>';

}
echo 
'<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo 
'<textarea name="StatementToEvaluate" cols="100" rows="25" wrap="off">'.htmlspecialchars(@$_POST['StatementToEvaluate']).'</textarea>';
echo 
'<br><input type="submit" value="Run"></form>';
echo 
'</body></html>';

?>