Simple php script to run a shell command on a server when a button is pressed and return the result.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$output = array(); | |
$retvar = ""; | |
if ($_GET['run']) | |
{ | |
// 2>&1 redirects STDERR to STDOUT | |
exec("/bin/date 2>&1", $output, $retvar); | |
} | |
?> | |
<html> | |
<head> | |
<title>Date</title> | |
<style> | |
button{ | |
height:100px; | |
width:200px; | |
margin: -50px -100px; | |
position:relative; | |
top:15%; | |
left:50%; | |
} | |
</style> | |
</head> | |
<body> | |
<?php | |
if ($_GET['run'] && $retvar == 0) | |
{ | |
?> | |
<hr /> | |
<pre> | |
<?php | |
foreach ($output as $text) | |
{ | |
echo "$text\n"; | |
} | |
?> | |
<hr /> | |
</pre> | |
<?php | |
} else { | |
?> | |
<button onclick="window.location.href='?run=true'">Show Date</button> | |
<?php | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment