To return to the scripts listing, click here
<?
$base_dir = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], "/") + 1);
$code_name = $_GET['code'];
$preview_name = $_GET['preview'];
if(!empty($code_name) && !preg_match("#[/|\\\]#", $code_name)) {
?><html>
<head>
<title><?=$code_name?> - New Server</title>
</head>
<body>
To return to the scripts listing, click <a href="?">here</a><br />
<? if($code_name != "index") { ?>
To see a preview of this script, click <a href="?preview=<?=$code_name?>">here</a><br />
<? } ?>
<br /><hr /><br />
<? highlight_file($base_dir . $code_name . ".php") ?>
<br /><br /><hr /><br />
<? if($code_name != "index") { ?>
To see a preview of this script, click <a href="?preview=<?=$code_name?>">here</a><br />
<? } ?>
To return to the scripts listing, click <a href="?">here</a>
</body>
</html><?
} elseif(!empty($preview_name) && !preg_match("#[/|\\\]#", $preview_name) && $preview_name != "index") {
?><html>
<head>
<title><?=$preview_name?></title>
</head>
<body>
To return to the scripts listing, click <a href="?">here</a><br />
To view the source of this script, click <a href="?code=<?=$preview_name?>">here</a><br />
<br /><hr />
<? include($base_dir . $preview_name . ".php") ?>
<br /><hr /><br />
To view the source of this script, click <a href="?code=<?=$preview_name?>">here</a><br />
To return to the scripts listing, click <a href="?">here</a>
</body>
</html><?
} else {
?><html>
<head>
<title>PHP Scripts Listing</title>
</head>
<body>
<h1>My PHP Script Examples</h1>
<ul>
<?
$files = glob($base_dir . "*.php");
foreach($files as $file) {
$file = str_replace(array($base_dir, ".php"), "", $file);
?><li>
<?=$file?>
(<a href="?code=<?=$file?>">source</a>
<? if($file != "index") { ?>
|| <a href="?preview=<?=$file?>">preview</a>
<? } ?>
)
</li><?
}
?>
</ul>
</body>
</html>
<? } ?>
To return to the scripts listing, click here