2010-07-20 05:28:07 +00:00
|
|
|
<?php
|
|
|
|
/* Required libraries */
|
|
|
|
$TOPDIR = '..';
|
|
|
|
require_once "$TOPDIR/lib/functions.php";
|
|
|
|
require_once "$TOPDIR/lib/jsonwrapper.php";
|
|
|
|
|
|
|
|
/**
|
2011-09-12 14:24:09 +00:00
|
|
|
* This will handle system commands, e.g. rpm -qa xCAT
|
2010-07-20 05:28:07 +00:00
|
|
|
*
|
2012-05-04 14:45:17 +00:00
|
|
|
* @param $cmd The system command
|
|
|
|
* @return The system response. Replies are in the form of JSON
|
2010-07-20 05:28:07 +00:00
|
|
|
*/
|
2011-09-12 14:24:09 +00:00
|
|
|
if (!isAuthenticated()) {
|
2012-05-04 14:45:17 +00:00
|
|
|
echo ("<b>Please login before continuing!</b>");
|
|
|
|
exit;
|
2010-09-13 08:36:05 +00:00
|
|
|
}
|
2010-07-20 05:28:07 +00:00
|
|
|
|
|
|
|
if (isset($_GET["cmd"])) {
|
2012-05-04 14:45:17 +00:00
|
|
|
// HTTP GET requests
|
|
|
|
$cmd = $_GET["cmd"];
|
|
|
|
$msg = NULL;
|
|
|
|
$ret = "";
|
2011-04-15 20:46:23 +00:00
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
if (isset($_GET["msg"])) {
|
|
|
|
$msg = $_GET["msg"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($cmd == "ostype") {
|
|
|
|
$ret = strtolower(PHP_OS);
|
|
|
|
} else {
|
|
|
|
$ret = shell_exec($cmd);
|
|
|
|
}
|
2010-07-20 05:28:07 +00:00
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
echo json_encode(array("rsp"=>$ret, "msg" => $msg));
|
2010-07-20 05:28:07 +00:00
|
|
|
}
|
|
|
|
?>
|