Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/modules/Eval/eval.php
<?php
/*
*****************************************************************

 eval.php
 
*****************************************************************
LSP: Lunabyte Systems Portal
Open-Source Project Inspired by Zef Hemel (hide@address.com)
*****************************************************************
Software Version:                  LSP 2.0 "Enigma 2"
Software by:                         Lunabyte Systems (http://www.lunabyte.net)
Copyright 2002-2005 by:       Lunabyte Systems (http://www.lunabyte.net)
Support, News, Updates at:    http://www.lunabyte.net
*****************************************************************
This program is free software; you may redistribute it and/or modify it 
under the terms of the provided license as published by Lunabyte Systems.

This program is distributed in the hope that it is and will be useful,                  
but WITHOUT ANY WARRANTIES; without even any implied warranty of           
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        

See the "LSP_license.txt" file for details of the LSP license.
The latest version can always be found at http://www.lunabyte.net.
*****************************************************************
*/

Header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header ( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
Header ( "Cache-Control: no-store, no-cache, must-revalidate");
Header ( "Cache-Control: post-check=0, pre-check=0", false);
Header ( "Pragma: no-cache");

isallowedTo('admin_forum');

$context['page_title'] = 'Code Eval';

echo '
<html><head>
<title>Code Eval</title>
</head>
<body>
';

$code = isset($_POST['code']) ? stripslashes($_POST['code']) : '';

$ev[0] = getmicrotime();
eval($code);
$ev[1] = getmicrotime();

echo '
	<script language="JavaScript" type="text/javascript">
	function SelMybox(form, feild)
	{
		eval(\'document.\' + form + \'.\' + feild + \'.select();\');
	}

	function AllowTabCharacter()
	{
	if (event != null)
		if (event.srcElement)
			if (event.srcElement.value)
				if (event.keyCode == 9)
					if (document.selection != null)
					{
						document.selection.createRange().text = \'\\t\';
						event.returnValue = false;
					}
					else
					{
						event.srcElement.value += \'\\t\';
						return false;
					}
	}
	</script>

<hr noshade color="#FF8000" size="1" width="100%">
<form method="post" action="', $_SERVER['PHP_SELF'], '?module=Eval;file=eval" name="evalcode">
  <textarea rows="18" name="code" cols="85" onfocus="SelMybox(\'evalcode\', \'code\');"  onkeydown="AllowTabCharacter();">', $code, '</textarea><br />
  <input type="submit" value="Submit" name="B1">
</form>
<hr noshade color="#FF8000" size="1">
Eval exacution time: 
', $ev[1] - $ev[0], '<br />';

$linecode = explode("\n", $code);
$clines = count($linecode);

echo '
Lines of code: ', $clines, '<br /><br />
<hr noshade color="#FF8000" size="1" width="100%">
<div style="width: 100%; font-size: 8pt; font-family: Arial; white-space: nowrap; overflow: auto;">
<ol>
';

for ($i=0; $i<$clines; $i++)
{
	$linecode{$i} = stripslashes($linecode{$i});
	$linecode{$i} = str_replace(array('&gt;', '&lt;', '&#36;', '&quot;'), array('>', '<', '$', '"'), $linecode{$i});
	//$linecode{$i} = str_replace('<br />', "\n", $linecode{$i});
	$linecode{$i} = html_entity_decode($linecode{$i}, ENT_QUOTES);

$linecode{$i} = highlight_string('<?'.$linecode{$i}.'?>', true);

$linecode{$i} = str_replace('&lt;?', '', $linecode{$i});
$linecode{$i} = str_replace('?&gt;', '', $linecode{$i});

echo '
<li>', $linecode{$i}, '</li>
';
}
echo '</ol>
</div>
';

function getmicrotime()
{
     list($usec, $sec) = explode(" ", microtime());
     return ((float)$usec + (float)$sec);
}

function EvalErrorHandler($error_level, $errstr, $errfile, $errline)
{
	echo '(', $error_level % 255 == E_ERROR ? 'Error' : ($error_level % 255 == E_WARNING ? 'Warning' : 'Notice'), ') ', $errstr, '<br />';
}

echo '
</body></html>';

?>
Return current item: Enigma