2010-07-20 05:28:07 +00:00
|
|
|
<?php
|
|
|
|
/* Required libraries */
|
|
|
|
$TOPDIR = '..';
|
|
|
|
require_once "$TOPDIR/lib/functions.php";
|
|
|
|
require_once "$TOPDIR/lib/jsonwrapper.php";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Issue a xCAT command, e.g. rpm -qa xCAT
|
2010-10-08 03:03:42 +00:00
|
|
|
* This will handle system commands.
|
2010-07-20 05:28:07 +00:00
|
|
|
*
|
|
|
|
* @param $cmd The system command
|
|
|
|
* @return The system response. Replies are in the form of JSON
|
|
|
|
*/
|
2010-09-13 08:36:05 +00:00
|
|
|
if (!isAuthenticated()){
|
|
|
|
echo ("<b>Please log in from the main page first!</b>");
|
|
|
|
exit;
|
|
|
|
}
|
2010-07-20 05:28:07 +00:00
|
|
|
|
|
|
|
if (isset($_GET["cmd"])) {
|
2010-11-17 18:53:40 +00:00
|
|
|
// HTTP GET requests
|
|
|
|
$cmd = $_GET["cmd"];
|
2011-04-07 07:57:24 +00:00
|
|
|
$msg = NULL;
|
|
|
|
|
|
|
|
if (isset($_GET["msg"])){
|
|
|
|
$msg = $_GET["msg"];
|
|
|
|
}
|
2010-11-17 18:53:40 +00:00
|
|
|
$ret = "";
|
2010-07-20 05:28:07 +00:00
|
|
|
|
2010-11-17 18:53:40 +00:00
|
|
|
if ("ostype" == $cmd) {
|
|
|
|
$ret = strtolower(PHP_OS);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$ret = shell_exec($cmd);
|
|
|
|
}
|
2010-07-20 05:28:07 +00:00
|
|
|
|
2011-04-07 07:57:24 +00:00
|
|
|
echo json_encode(array("rsp"=>$ret, "msg" => $msg));
|
2010-07-20 05:28:07 +00:00
|
|
|
}
|
|
|
|
?>
|