<?php
session_start();
$error = "";
if ( array_key_exists("log", $_REQUEST) && $_REQUEST["log"] == 1 )
{
$_SESSION = array();
if ( isset($_COOKIE[session_name()]) )
setcookie(session_name(), '', time()-42000, '/');
session_destroy();
header('Location: console.php');
}
function formatSize($size,$suff){
switch (true){
case ($size > 1099511627776):
$size /= 1099511627776;
$suffix = 'TB';
break;
case ($size > 1073741824):
$size /= 1073741824;
$suffix = 'GB';
break;
case ($size > 1048576):
$size /= 1048576;
$suffix = 'MB';
break;
case ($size > 1024):
$size /= 1024;
$suffix = 'KB';
break;
default:
$suffix = 'B';
}
return $suff ? round($size, 2).$suffix : round($size, 2);
}
$space = formatSize(diskfreespace("C:"),false) . "/" . formatSize(disk_total_space("C:"),true) . " free";
?>
<html>
<head>
<title>Server Console</title>
<script language="JavaScript" type="text/javascript">
function togglevis(obj_tog)
{
if ( obj_tog.style.display == "none" )
obj_tog.style.display = "block";
else
obj_tog.style.display = "none";
}
function php_eval(str_code,obj_result)
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4 || xmlHttp.readyState==3)
{
obj_result.innerHTML=xmlHttp.responseText;
}
}
str_fcode = "code=" + encodeURIComponent(str_code);
xmlHttp.open("POST","console_processor.php",true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", str_fcode.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(str_fcode);
}
function validateupload()
{
if ( document.upload.fileloc.value == "" )
{
alert("Please select a file")
}
else
{
document.upload.submit()
}
}
</script>
</head>
<body>
<!--Upload box-->
<div id="uploadbox" style="display:none; position:absolute; left:25px; top:33px; background:white; border-style: solid; border-width:1px; border-color: black; padding: 5px">
Upload:<br />
<form action="console.php?upl=1" method="POST" name="upload" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<input type="file" name="fileloc"> <input type="button" value="Upload!" onClick="validateupload()">
</form>
</div>
<table border=0 width=100% cellpadding=0 cellspacing=0>
<tr>
<td align=left width=50%><a href="javascript:togglevis(document.getElementById('uploadbox'))"><?php echo $space; ?></a></td>
<td align=right width=50%><a href="console.php?log=1">Logout</a></td>
</tr>
<tr>
<td align=center colspan=2 width=100%><strong style="font-size:24pt">Server Console</strong></td>
</tr>
</table>
<br />
<div align="center">
<?php
if ( array_key_exists("pw", $_REQUEST) )
{
//Login
if ( md5($_REQUEST["pw"]) == "<INSERT AN MD5'd PASSWORD HERE>" )
$_SESSION["pw"] = "<INSERT AN MD5'd PASSWORD HERE>";
else
$error = "Incorrect Password<br />";
}
if ( !isset($_SESSION["pw"]) )
{
echo $error;
?>
<form method="post" action="console.php">
<input type="password" name="pw">
<input type="submit" value="Login">
</form>
<?
}
else
{
if ( $_SESSION["pw"] != "<INSERT AN MD5'd PASSWORD HERE>" )
die("Invalid Session");
if ( array_key_exists("upl", $_REQUEST) && $_REQUEST["upl"] == 1 )
{
$uploads_dir = 'files';
$uplsuc = false;
if ($_FILES["fileloc"]["error"] == UPLOAD_ERR_OK && $_FILES["fileloc"]["size"] < 10000000)
{
$tmp_name = $_FILES["fileloc"]["tmp_name"];
$name = $_FILES["fileloc"]["name"];
$uplsuc = move_uploaded_file($tmp_name, "$uploads_dir\\$name") ? true : false;
}
if ( !$uplsuc )
echo "Upload failed<br />";
}
?>
<a href="javascript:togglevis(document.getElementById('codebox'))">Show/Hide Code</a>
<table border=0 width=100% height=500>
<tr align=center>
<td align=left valign=top>
<div id="codebox" style="display: block">
<form onSubmit="php_eval(this.code.value,document.getElementById('result')); return false" action="console.php#" method="post">
<strong>PHP:</strong>
<br />
<textarea name="code" cols=50 rows=20></textarea>
<input type="hidden" name="codetype" value="php">
<br />
<input type="Submit" value="Go!">
</form>
</div>
</td>
<td valign=top width=100%>
<div id="result"></div>
</td>
</tr>
</table>
<?php
}
?>
</div>
</body>
</html>