Synched up xCAT code to the latest. Added native SCSI/FCP support onto trunk. Replaced tabs with 4 spaces.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@14006 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
phamt 2012-10-15 01:50:28 +00:00
parent de82de8d87
commit 2f2a72e90c
9 changed files with 721 additions and 715 deletions

View File

@ -365,7 +365,6 @@ legend {
/*--- jQuery datatable ---*/
.dataTables_wrapper {
overflow: auto;
width: auto;
margin: 10px auto;
-moz-border-radius: 3px;

View File

@ -307,11 +307,11 @@ DataTable.prototype.add = function(rowCont) {
* @param barId Status bar ID
*/
function createStatusBar(barId) {
var statusBar = $('<div class="ui-corner-all" id="' + barId + '"></div>').css({
// Do not change the background color or color! This is handled by the theme
// the user selects.
var statusBar = $('<div class="ui-state-highlight ui-corner-all" id="' + barId + '"></div>').css({
'margin-bottom': '5px',
'min-height': '30px',
'background-color':'#7BBEDE',
'color': '#FFFFFF',
'max-height': '150px',
'overflow': 'auto'
});
@ -354,10 +354,10 @@ function createStatusBar(barId) {
* @return Info bar
*/
function createInfoBar(msg) {
var infoBar = $('<div class="ui-corner-all"></div>').css({
'margin': '5px 0px',
'background-color':'#7BBEDE',
'color': '#FFFFFF'
// Do not change the background color or color! This is handled by the theme
// the user selects.
var infoBar = $('<div class="ui-state-highlight ui-corner-all"></div>').css({
'margin': '5px 0px'
});
var icon = $('<span class="ui-icon ui-icon-info"></span>').css({
'display': 'inline-block',
@ -1055,4 +1055,4 @@ function getNodesChecked(datatableId) {
}
return tgts;
}
}

View File

@ -12,126 +12,131 @@ require_once "$TOPDIR/lib/jsonwrapper.php";
* @param $cmd The xCAT command
* @param $tgt The target node or group
* @param $args The xCAT command arguments, separated by semicolons
* @param $opts The xCAT command options, separated by semicolons
* @param $opts The xCAT command options, separated by semicolons
* @return The xCAT response. Replies are in the form of JSON
*/
if (isset($_GET["cmd"])) {
// HTTP GET requests
$cmd = $_GET["cmd"];
$tgt = $_GET["tgt"];
$args = $_GET["args"];
// HTTP GET requests
$cmd = $_GET["cmd"];
$tgt = $_GET["tgt"];
$args = $_GET["args"];
// File contents in case of file write
if (isset($_GET["cont"])) {
$cont = $_GET["cont"];
}
// File contents in case of file write
if (isset($_GET["cont"])) {
$cont = $_GET["cont"];
}
// Special messages put here
// This gets sent back to the AJAX request as is.
$msg = $_GET["msg"];
// Special messages put here
// This gets sent back to the AJAX request as is.
$msg = $_GET["msg"];
// If no $tgt is given, set $tgt to NULL
if (!$tgt) {
$tgt = NULL;
}
// If no $tgt is given, set $tgt to NULL
if (!$tgt) {
$tgt = NULL;
}
// If no $msg is given, set $msg to NULL
if (!$msg) {
$msg = NULL;
}
// If no $msg is given, set $msg to NULL
if (!$msg) {
$msg = NULL;
}
// If no $args are given, set $args_array to NULL
$args_array = array();
if ($args) {
// If $args contains multiple arguments, split it into an array
if (strpos($args,";")) {
// Split the arguments into an array
$args_array = array();
$args_array = explode(";", $args);
} else {
$args_array = array($args);
}
}
// If no $args are given, set $args_array to NULL
$args_array = array();
if ($args) {
// If $args contains multiple arguments, split it into an array
if (strpos($args,";")) {
// Split the arguments into an array
$args_array = array();
$args_array = explode(";", $args);
} else {
$args_array = array($args);
}
}
// If no $opts are given, set $opts_array to NULL
$opts_array = array();
if (isset($_GET["opts"])) {
$opts = $_GET["opts"];
// If no $opts are given, set $opts_array to NULL
$opts_array = array();
if (isset($_GET["opts"])) {
$opts = $_GET["opts"];
// If $args contains multiple arguments, split it into an array
if (strpos($opts,";")) {
// Split the arguments into an array
$opts_array = array();
$opts_array = explode(";", $opts);
} else {
$opts_array = array($opts);
}
}
// If $args contains multiple arguments, split it into an array
if (strpos($opts,";")) {
// Split the arguments into an array
$opts_array = array();
$opts_array = explode(";", $opts);
} else {
$opts_array = array($opts);
}
}
// Time needed to update /etc/hosts
if (strncasecmp($cmd, "makehosts", 9) == 0) {
sleep(5);
}
// Submit request and get response
$xml = docmd($cmd, $tgt, $args_array, $opts_array);
// If the output is flushed, do not return output in JSON
if (in_array("flush", $opts_array)) {
return;
}
// Submit request and get response
$xml = docmd($cmd, $tgt, $args_array, $opts_array);
// If the output is flushed, do not return output in JSON
if (in_array("flush", $opts_array)) {
return;
}
$rsp = array();
$rsp = array();
// webrun pping and gangliastatus output needs special handling
if(strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) {
$rsp = extractWebrun($xml);
}
// nodels output needs special handling
else if(strncasecmp($cmd, "nodels", 6) == 0) {
// Handle the output the same way as webrun
$rsp = extractNodels($xml);
}
// extnoderange output needs special handling
// This command gets the nodes and groups
else if(strncasecmp($cmd, "extnoderange", 12) == 0) {
$rsp = extractExtnoderange($xml);
}
// Write contents to file
else if(strncasecmp($cmd, "write", 4) == 0) {
// Directory should be /var/opt/xcat/profiles
// You can write anything to that directory
$file = "$tgt";
$handle = fopen($file, 'w') or die("Cannot open $file");
fwrite($handle, $cont);
fclose($handle);
// webrun pping and gangliastatus output needs special handling
if (strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) {
$rsp = extractWebrun($xml);
}
// nodels output needs special handling
else if (strncasecmp($cmd, "nodels", 6) == 0) {
// Handle the output the same way as webrun
$rsp = extractNodels($xml);
}
// extnoderange output needs special handling
// This command gets the nodes and groups
else if (strncasecmp($cmd, "extnoderange", 12) == 0) {
$rsp = extractExtnoderange($xml);
}
// Write contents to file
else if (strncasecmp($cmd, "write", 4) == 0) {
// Directory should be /var/opt/xcat/profiles
// You can write anything to that directory
$file = "$tgt";
$handle = fopen($file, 'w') or die("Cannot open $file");
fwrite($handle, $cont);
fclose($handle);
$rsp = "Directory entry written to $file";
}
// Handle the typical output
else {
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
if($data->name) {
$node = $data->name;
$rsp = "Directory entry written to $file";
}
// Handle the typical output
else {
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
if($data->name) {
$node = $data->name;
if ($data->data->contents) {
$cont = $data->data->contents;
} else {
$cont = $data->data;
}
if ($data->data->contents) {
$cont = $data->data->contents;
} else {
$cont = $data->data;
}
if ($data->data->desc) {
$cont = $data->data->desc . ": " . $cont;
}
if ($data->data->desc) {
$cont = $data->data->desc . ": " . $cont;
}
$cont = str_replace(":|:", "\n", $cont);
array_push($rsp, "$node: $cont");
} else if (strlen("$data") > 2) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
}
}
$cont = str_replace(":|:", "\n", $cont);
array_push($rsp, "$node: $cont");
} else if (strlen("$data") > 2) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
}
}
// Reply in the form of JSON
$rtn = array("rsp" => $rsp, "msg" => $msg);
echo json_encode($rtn);
// Reply in the form of JSON
$rtn = array("rsp" => $rsp, "msg" => $msg);
echo json_encode($rtn);
}
/**
@ -141,26 +146,26 @@ if (isset($_GET["cmd"])) {
* @return An array containing the output
*/
function extractWebrun($xml) {
$rsp = array();
$i = 0;
$rsp = array();
$i = 0;
// Extract data returned
foreach($xml->children() as $nodes){
foreach($nodes->children() as $node){
// Get the node name
$name = $node->name;
// Extract data returned
foreach($xml->children() as $nodes){
foreach($nodes->children() as $node){
// Get the node name
$name = $node->name;
// Get the content
$status = $node->data;
$status = str_replace(":|:", "\n", $status);
// Get the content
$status = $node->data;
$status = str_replace(":|:", "\n", $status);
// Add to return array
$rsp[$i] = array("$name", "$status");
$i++;
}
}
// Add to return array
$rsp[$i] = array("$name", "$status");
$i++;
}
}
return $rsp;
return $rsp;
}
/**
@ -170,26 +175,26 @@ function extractWebrun($xml) {
* @return An array containing the output
*/
function extractNodels($xml) {
$rsp = array();
$i = 0;
$rsp = array();
$i = 0;
// Extract data returned
foreach($xml->children() as $nodes){
foreach($nodes->children() as $node){
// Get the node name
$name = $node->name;
// Get the content
$status = $node->data->contents;
$status = str_replace(":|:", "\n", $status);
// Extract data returned
foreach($xml->children() as $nodes){
foreach($nodes->children() as $node){
// Get the node name
$name = $node->name;
// Get the content
$status = $node->data->contents;
$status = str_replace(":|:", "\n", $status);
$description = $node->data->desc;
// Add to return array
$rsp[$i] = array("$name", "$status", "$description");
$i++;
}
}
$description = $node->data->desc;
// Add to return array
$rsp[$i] = array("$name", "$status", "$description");
$i++;
}
}
return $rsp;
return $rsp;
}
/**
@ -199,13 +204,13 @@ function extractNodels($xml) {
* @return The nodes and groups
*/
function extractExtnoderange($xml) {
$rsp = array();
$rsp = array();
// Extract data returned
foreach ($xml->xcatresponse->intersectinggroups as $group) {
array_push($rsp, "$group");
}
// Extract data returned
foreach ($xml->xcatresponse->intersectinggroups as $group) {
array_push($rsp, "$group");
}
return $rsp;
return $rsp;
}
?>

View File

@ -5,7 +5,7 @@
// Retain session variables across page requests
session_start();
session_write_close(); // Do not block other HTTP requests
session_write_close(); // Do not block other HTTP requests
// The settings below display error on the screen, instead of giving blank pages.
error_reporting(E_ALL);
@ -22,33 +22,33 @@ ini_set('display_errors', true);
* See perl-xCAT/xCAT/Client.pm for the format
*/
function docmd($cmd, $nr, $args_array, $opts_array){
// If we are not logged in,
// do not try to communicate with xcatd
if (!is_logged()) {
echo "<p>You are not logged in! Failed to run command.</p>";
return simplexml_load_string('<xcat></xcat>', 'SimpleXMLElement', LIBXML_NOCDATA);
}
// If we are not logged in,
// do not try to communicate with xcatd
if (!is_logged()) {
echo "<p>You are not logged in! Failed to run command.</p>";
return simplexml_load_string('<xcat></xcat>', 'SimpleXMLElement', LIBXML_NOCDATA);
}
// Create xCAT request
// Add command, node range, and arguments to request
$request = simplexml_load_string('<xcatrequest></xcatrequest>');
$request->addChild('command', $cmd);
if (!empty($nr)) {
$request->addChild('noderange', $nr);
}
if (!empty($args_array)) {
foreach ($args_array as $a) {
$request->addChild('arg',$a);
}
}
// Create xCAT request
// Add command, node range, and arguments to request
$request = simplexml_load_string('<xcatrequest></xcatrequest>');
$request->addChild('command', $cmd);
if (!empty($nr)) {
$request->addChild('noderange', $nr);
}
if (!empty($args_array)) {
foreach ($args_array as $a) {
$request->addChild('arg',$a);
}
}
// Add user and password to request
$usernode=$request->addChild('becomeuser');
$usernode->addChild('username',$_SESSION["username"]);
$usernode->addChild('password',getpassword());
// Add user and password to request
$usernode=$request->addChild('becomeuser');
$usernode->addChild('username',$_SESSION["username"]);
$usernode->addChild('password',getpassword());
$xml = submit_request($request, 0, $opts_array);
return $xml;
$xml = submit_request($request, 0, $opts_array);
return $xml;
}
/**
@ -59,155 +59,157 @@ function docmd($cmd, $nr, $args_array, $opts_array){
* @return A tree of SimpleXML objects
*/
function submit_request($req, $skipVerify, $opts_array){
$xcathost = "localhost";
$port = "3001";
$rsp = FALSE;
$response = '';
$cleanexit = 0;
$flushtail = '';
$xcathost = "localhost";
$port = "3001";
$rsp = FALSE;
$response = '';
$cleanexit = 0;
$flushtail = '';
// Determine whether to flush output or not
$flush = false;
if ($opts_array && in_array("flush", $opts_array)) {
$flush = true;
}
// Determine whether to flush output or not
$flush = false;
if ($opts_array && in_array("flush", $opts_array)) {
$flush = true;
}
// Determine how to handle the flush output
// You can specify a function name, in place of TBD, to handle the flush output
$flush_format = "";
if ($opts_array && in_array("flush-format=TBD", $opts_array)) {
$flush_format = "TBD";
}
// Determine how to handle the flush output
// You can specify a function name, in place of TBD, to handle the flush output
$flush_format = "";
if ($opts_array && in_array("flush-format=TBD", $opts_array)) {
$flush_format = "TBD";
}
// Open syslog, include the process ID and also send the log to standard error,
// and use a user defined logging mechanism
openlog("xCAT-UI", LOG_PID | LOG_PERROR, LOG_LOCAL0);
// Open syslog, include the process ID and also send the log to standard error,
// and use a user defined logging mechanism
openlog("xCAT-UI", LOG_PID | LOG_PERROR, LOG_LOCAL0);
// Open a socket to xcatd
syslog(LOG_INFO, "Opening socket to xcatd...");
if ($fp = stream_socket_client('ssl://'.$xcathost.':'.$port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT)){
$reqXML = $req->asXML();
$nr = $req->noderange;
$cmd = $req->command;
// Open a socket to xcatd
syslog(LOG_INFO, "Opening socket to xcatd...");
if ($fp = stream_socket_client('ssl://'.$xcathost.':'.$port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT)){
$reqXML = $req->asXML();
$nr = $req->noderange;
$cmd = $req->command;
syslog(LOG_INFO, "Sending request: $cmd $nr");
stream_set_blocking($fp, 0); // Set as non-blocking
fwrite($fp,$req->asXML()); // Send XML to xcatd
set_time_limit(900); // Set 15 minutes timeout (for long running requests)
// The default is 30 seconds which is too short for some requests
syslog(LOG_INFO, "Sending request: $cmd $nr");
stream_set_blocking($fp, 0); // Set as non-blocking
fwrite($fp,$req->asXML()); // Send XML to xcatd
set_time_limit(900); // Set 15 minutes timeout (for long running requests)
// The default is 30 seconds which is too short for some requests
// Turn on output buffering
ob_start();
if ($flush){
echo str_pad('',1024)."\n";
}
while (!feof($fp)) {
// Read until there is no more
// Remove newlines and add it to the response
$str = fread($fp, 8192);
if ($str) {
$response .= preg_replace('/>\n\s*</', '><', $str);
// Turn on output buffering
ob_start();
if ($flush){
echo str_pad('',1024)."\n";
}
while (!feof($fp)) {
// Read until there is no more
// Remove newlines and add it to the response
$str = fread($fp, 8192);
if ($str) {
$response .= preg_replace('/>\n\s*</', '><', $str);
// Flush output to browser
if ($flush) {
// Flush output to browser
if ($flush) {
$str = $flushtail . $str;
if (preg_match('/[^>]+$/', $str, $matches)){
$flushtail = $matches[0];
$str = preg_replace('/[^>]+$/', '', $str);
}
else{
} else {
$flushtail = '';
}
$str = preg_replace('/<errorcode>.*<\/errorcode>/', '', $str);
// Strip HTML tags from output
if ($tmp = trim(strip_tags($str))) {
// Format the output based on what was given for $flush_format
if ($flush_format == "TDB") {
format_TBD($tmp);
} else {
$tmp = preg_replace('/\n\s*/', "\n", $tmp);
// Print out output by default
echo '<pre style="font-size: 10px;">' . $tmp . '</pre>';
ob_flush();
flush();
}
}
}
}
// Strip HTML tags from output
if ($tmp = trim(strip_tags($str))) {
// Format the output based on what was given for $flush_format
if ($flush_format == "TDB") {
format_TBD($tmp);
} else {
$tmp = preg_replace('/\n\s*/', "\n", $tmp);
// Print out output by default
echo '<pre style="font-size: 10px;">' . $tmp . '</pre>';
ob_flush();
flush();
}
}
}
}
// Look for serverdone response
$fullpattern = '/<xcatresponse>\s*<serverdone>\s*<\/serverdone>\s*<\/xcatresponse>/';
$mixedpattern = '/<serverdone>\s*<\/serverdone>.*<\/xcatresponse>/';
$recentpattern = '/<\/xcatresponse>/';
if (preg_match($recentpattern,$str) && preg_match($mixedpattern,$response)) {
// Transaction is done, package up XML and return it
// Remove the serverdone response and put an xcat tag around the rest
$count = 0;
$response = preg_replace($fullpattern,'', $response, -1, $count); // 1st try to remove the long pattern
if (!$count) {
$response = preg_replace($mixedpattern,'', $response) . '</xcatresponse>/';
}
$response = "<xcat>$response</xcat>";
$response = preg_replace('/>\n\s*</', '><', $response);
$response = preg_replace('/\n/', ':|:', $response);
$rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA);
$cleanexit = 1;
break;
}
} // End of while(!feof($fp))
// Look for serverdone response
$fullpattern = '/<xcatresponse>\s*<serverdone>\s*<\/serverdone>\s*<\/xcatresponse>/';
$mixedpattern = '/<serverdone>\s*<\/serverdone>.*<\/xcatresponse>/';
$recentpattern = '/<\/xcatresponse>/';
if (preg_match($recentpattern,$str) && preg_match($mixedpattern,$response)) {
// Transaction is done, package up XML and return it
// Remove the serverdone response and put an xcat tag around the rest
$count = 0;
$response = preg_replace($fullpattern,'', $response, -1, $count); // 1st try to remove the long pattern
if (!$count) {
$response = preg_replace($mixedpattern,'', $response) . '</xcatresponse>/';
}
$response = "<xcat>$response</xcat>";
$response = preg_replace('/>\n\s*</', '><', $response);
$response = preg_replace('/\n/', ':|:', $response);
$rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA);
$cleanexit = 1;
break;
}
} // End of while(!feof($fp))
syslog(LOG_INFO, "($cmd $nr) Sending response");
fclose($fp);
} else {
echo "<p>xCAT submit request socket error: $errno - $errstr</p>";
}
syslog(LOG_INFO, "($cmd $nr) Sending response");
fclose($fp);
} else {
echo "<p>xCAT submit request socket error: $errno - $errstr</p>";
}
// Flush (send) the output buffer and turn off output buffering
ob_end_flush();
// Flush (send) the output buffer and turn off output buffering
ob_end_flush();
// Close syslog
closelog();
// Close syslog
closelog();
if(! $cleanexit) {
if (preg_match('/^\s*<xcatresponse>.*<\/xcatresponse>\s*$/',$response)) {
// Probably an error message
$response = "<xcat>$response</xcat>";
$rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA);
} else if(!$skipVerify) {
echo "<p>(Error) xCAT response ended prematurely: ", htmlentities($response), "</p>";
$rsp = FALSE;
}
}
return $rsp;
if (!$cleanexit) {
if (preg_match('/^\s*<xcatresponse>.*<\/xcatresponse>\s*$/',$response)) {
// Probably an error message
$response = "<xcat>$response</xcat>";
$rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA);
} else if (!$skipVerify) {
echo "<p>(Error) xCAT response ended prematurely: ", htmlentities($response), "</p>";
$rsp = FALSE;
}
}
return $rsp;
}
/**
* Enable password storage to split between cookie and session variable
*/
function xorcrypt($data, $key) {
$datalen = strlen($data);
$keylen = strlen($key);
for ($i=0;$i<$datalen;$i++) {
$data[$i] = chr(ord($data[$i])^ord($key[$i]));
}
$datalen = strlen($data);
$keylen = strlen($key);
for ($i=0;$i<$datalen;$i++) {
$data[$i] = chr(ord($data[$i])^ord($key[$i]));
}
return $data;
return $data;
}
/**
* Get password
*/
function getpassword() {
if (isset($GLOBALS['xcatauthsecret'])) {
$cryptext = $GLOBALS['xcatauthsecret'];
} else if (isset($_COOKIE["xcatauthsecret"])) {
$cryptext = $_COOKIE["xcatauthsecret"];
} else {
return false;
}
if (isset($GLOBALS['xcatauthsecret'])) {
$cryptext = $GLOBALS['xcatauthsecret'];
} else if (isset($_COOKIE["xcatauthsecret"])) {
$cryptext = $_COOKIE["xcatauthsecret"];
} else {
return false;
}
return xorcrypt($_SESSION["secretkey"], base64_decode($cryptext));
return xorcrypt($_SESSION["secretkey"], base64_decode($cryptext));
}
/**
@ -218,15 +220,15 @@ function getpassword() {
* @param $password Password
*/
function setpassword($password) {
$randlen = strlen($password);
$key = getrandchars($randlen);
$cryptext = xorcrypt($password,$key);
$randlen = strlen($password);
$key = getrandchars($randlen);
$cryptext = xorcrypt($password,$key);
// Non-ascii characters, encode it in base64
$cryptext = base64_encode($cryptext);
setcookie("xcatauthsecret",$cryptext,0,'/');
$GLOBALS["xcatauthsecret"] = $cryptext;
$_SESSION["secretkey"] = $key;
// Non-ascii characters, encode it in base64
$cryptext = base64_encode($cryptext);
setcookie("xcatauthsecret",$cryptext,0,'/');
$GLOBALS["xcatauthsecret"] = $cryptext;
$_SESSION["secretkey"] = $key;
}
/**
@ -236,16 +238,16 @@ function setpassword($password) {
* @return RAND characters
*/
function getrandchars($length) {
$charset = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*';
$charsize = strlen($charset);
srand();
$chars = '';
for ($i=0;$i<$length;$i++) {
$num=rand()%$charsize;
$chars=$chars.substr($charset,$num,1);
}
$charset = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*';
$charsize = strlen($charset);
srand();
$chars = '';
for ($i=0;$i<$length;$i++) {
$num=rand()%$charsize;
$chars=$chars.substr($charset,$num,1);
}
return $chars;
return $chars;
}
/**
@ -254,11 +256,11 @@ function getrandchars($length) {
* @return True if user has a session, false otherwise
*/
function is_logged() {
if (isset($_SESSION["username"]) and !is_bool(getpassword())) {
return true;
} else {
return false;
}
if (isset($_SESSION["username"]) and !is_bool(getpassword())) {
return true;
} else {
return false;
}
}
/**
@ -267,27 +269,27 @@ function is_logged() {
* @return True if the user is currently logged in successfully, false otherwise
*/
function isAuthenticated() {
if (is_logged()) {
if ($_SESSION["xcatpassvalid"] != 1) {
$testcred = docmd("authcheck", "", NULL, NULL);
if (isset($testcred->{'xcatresponse'}->{'data'})) {
$result = "".$testcred->{'xcatresponse'}->{'data'};
if (is_numeric(strpos("Authenticated",$result))) {
// Logged in successfully
$_SESSION["xcatpassvalid"] = 1;
} else {
// Not logged in
$_SESSION["xcatpassvalid"] = 0;
}
}
}
}
if (is_logged()) {
if ($_SESSION["xcatpassvalid"] != 1) {
$testcred = docmd("authcheck", "", NULL, NULL);
if (isset($testcred->{'xcatresponse'}->{'data'})) {
$result = "".$testcred->{'xcatresponse'}->{'data'};
if (is_numeric(strpos("Authenticated",$result))) {
// Logged in successfully
$_SESSION["xcatpassvalid"] = 1;
} else {
// Not logged in
$_SESSION["xcatpassvalid"] = 0;
}
}
}
}
if (isset($_SESSION["xcatpassvalid"]) and $_SESSION["xcatpassvalid"]==1) {
return true;
} else {
return false;
}
if (isset($_SESSION["xcatpassvalid"]) and $_SESSION["xcatpassvalid"]==1) {
return true;
} else {
return false;
}
}
/**
@ -296,70 +298,70 @@ function isAuthenticated() {
* @return True if the user has root access, false otherwise
*/
function isRootAcess() {
if (is_logged() && $_SESSION["xcatpassvalid"]) {
$testacc = docmd('tabdump', '', array('policy', '-w', "name==" . $_SESSION["username"]), array());
if (isset($testacc->{'xcatresponse'}->{'data'}->{1})) {
$result = $testacc->{'xcatresponse'}->{'data'}->{1};
$result = str_replace('"', '', $result);
$args = array();
$args = explode(",", $result);
if (is_logged() && $_SESSION["xcatpassvalid"]) {
$testacc = docmd('tabdump', '', array('policy', '-w', "name==" . $_SESSION["username"]), array());
if (isset($testacc->{'xcatresponse'}->{'data'}->{1})) {
$result = $testacc->{'xcatresponse'}->{'data'}->{1};
$result = str_replace('"', '', $result);
$args = array();
$args = explode(",", $result);
// Get the comments which contains the privilege
$comments = $args[8];
$args = explode(";", $comments);
// Default privilege is guest
$privilege = 'guest';
$_SESSION["xcatpassvalid"] = 0;
foreach ($args as $arg) {
// Get user privilege
if ($arg && is_numeric(strpos($arg, "privilege"))) {
if (is_numeric(strpos($arg, "root"))) {
// Set privilege to root
$privilege = 'root';
$_SESSION["xcatpassvalid"] = 1;
}
// Get the comments which contains the privilege
$comments = $args[8];
$args = explode(";", $comments);
// Default privilege is guest
$privilege = 'guest';
$_SESSION["xcatpassvalid"] = 0;
foreach ($args as $arg) {
// Get user privilege
if ($arg && is_numeric(strpos($arg, "privilege"))) {
if (is_numeric(strpos($arg, "root"))) {
// Set privilege to root
$privilege = 'root';
$_SESSION["xcatpassvalid"] = 1;
}
break;
}
}
}
}
break;
}
}
}
}
if (strcmp($_SESSION["username"], 'root') == 0) {
$_SESSION["xcatpassvalid"] = 1;
}
if (strcmp($_SESSION["username"], 'root') == 0) {
$_SESSION["xcatpassvalid"] = 1;
}
if (isset($_SESSION["xcatpassvalid"]) and $_SESSION["xcatpassvalid"]==1) {
return true;
} else {
return false;
}
if (isset($_SESSION["xcatpassvalid"]) and $_SESSION["xcatpassvalid"]==1) {
return true;
} else {
return false;
}
}
/**
* Log out of current user session
*/
function logout() {
// Clear the secret cookie from browser
if (isset($_COOKIE["xcatauthsecret"])) {
setcookie("xcatauthsecret",'',time()-86400*7,'/');
}
// Clear the secret cookie from browser
if (isset($_COOKIE["xcatauthsecret"])) {
setcookie("xcatauthsecret",'',time()-86400*7,'/');
}
// Expire session cookie
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(),"",time()-86400*7,"/");
}
// Expire session cookie
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(),"",time()-86400*7,"/");
}
// Clear server store of data
$_SESSION=array();
// Clear server store of data
$_SESSION=array();
}
/**
* Format a given string and echo it back to the browser
*/
function format_TBD($str) {
// Format a given string however you want it
echo $tmp . '<br/>';
flush();
// Format a given string however you want it
echo $tmp . '<br/>';
flush();
}
?>

View File

@ -11,29 +11,29 @@ header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (isset($_REQUEST["password"])) {
// Clear data from session
$_SESSION = array();
// Clear data from session
$_SESSION = array();
// Zap existing session entirely
session_regenerate_id(true);
setpassword($_REQUEST["password"]);
// Zap existing session entirely
session_regenerate_id(true);
setpassword($_REQUEST["password"]);
// Invalid password
$_SESSION["xcatpassvalid"] = -1;
// Invalid password
$_SESSION["xcatpassvalid"] = -1;
}
if (isset($_REQUEST["username"])) {
$_SESSION["username"] = $_REQUEST["username"];
$_SESSION["username"] = $_REQUEST["username"];
// Invalid user name
$_SESSION["xcatpassvalid"]=-1;
// Invalid user name
$_SESSION["xcatpassvalid"]=-1;
}
$jdata = array();
if (isAuthenticated() && isRootAcess()) {
$jdata["authenticated"]="yes";
$jdata["authenticated"]="yes";
} else {
$jdata["authenticated"]="no";
$jdata["authenticated"]="no";
}
echo json_encode($jdata);

View File

@ -7,90 +7,90 @@ $output = '';
$temp = '';
$pythonProcess = '';
if (!isAuthenticated()) {
echo ("Please login before continuing!");
echo ("Please login before continuing!");
}
$query = 's=' . $_POST['s'] . '&w=' . $_POST['w'] . '&h=' . $_POST['h'];
if (isset($_POST['q'])) {
$query .= '&q=1';
$query .= '&q=1';
} else {
$query .= '&q=0';
$query .= '&q=0';
}
if (isset($_POST['f'])) {
$pythonProcess = exec('ps -aef | grep -v grep | grep ajaxterm.py');
if ('' == $pythonProcess) {
exec('nohup ' . dirname(__FILE__) . '/ajaxterm/ajaxterm.py >/dev/null 2>&1 &');
}
sleep(1);
$pythonProcess = exec('ps -aef | grep -v grep | grep ajaxterm.py');
if ('' == $pythonProcess) {
exec('nohup ' . dirname(__FILE__) . '/ajaxterm/ajaxterm.py >/dev/null 2>&1 &');
}
sleep(1);
$temp = $query . '&k=' . urlencode($_SESSION["username"] . "\r");
$output = rconsSynchronise($temp);
if (0 < substr_count($output, 'error')) {
echo json_encode(array('err'=>$output));
exit;
}
sleep(1);
$temp = $query . '&k=' . urlencode($_SESSION["username"] . "\r");
$output = rconsSynchronise($temp);
if (0 < substr_count($output, 'error')) {
echo json_encode(array('err'=>$output));
exit;
}
sleep(1);
$temp = $query . '&k=' . urlencode(getpassword() . "\r");
$output = rconsSynchronise($temp);
if (0 < substr_count($output, 'error')) {
echo json_encode(array('err'=>$output));
exit;
}
sleep(1);
$temp = $query . '&k=' . urlencode(getpassword() . "\r");
$output = rconsSynchronise($temp);
if (0 < substr_count($output, 'error')) {
echo json_encode(array('err'=>$output));
exit;
}
sleep(1);
$temp = $query . '&c=1&k=' . urlencode('rcons ' . $_POST['s'] . "\r");
$temp = $query . '&c=1&k=' . urlencode('rcons ' . $_POST['s'] . "\r");
} else {
$temp = $query . '&c=1&k=' . urlencode($_POST['k']);
$temp = $query . '&c=1&k=' . urlencode($_POST['k']);
}
$output = rconsSynchronise($temp);
if (0 < substr_count($output, 'error')) {
echo (array('err'=>$output));
echo (array('err'=>$output));
} else {
$xml = simplexml_load_string($output);
if ('pre' == $xml->getName()) {
$output = $xml->asXML();
$output = preg_replace('/'. chr(160) . '/', '&nbsp;', $output);
$xml = simplexml_load_string($output);
if ('pre' == $xml->getName()) {
$output = $xml->asXML();
$output = preg_replace('/'. chr(160) . '/', '&nbsp;', $output);
echo json_encode(array('term'=>$output));
} else {
echo json_encode(array('nc'=>'nc'));
}
echo json_encode(array('term'=>$output));
} else {
echo json_encode(array('nc'=>'nc'));
}
}
function rconsSynchronise($parameter) {
$flag = false;
$return = "";
$out = "";
$fp = fsockopen("127.0.0.1", 8022, $errno, $errstr, 30);
if (!$fp) {
return "<error>$errstr($errno)</error>";
}
$flag = false;
$return = "";
$out = "";
$fp = fsockopen("127.0.0.1", 8022, $errno, $errstr, 30);
if (!$fp) {
return "<error>$errstr($errno)</error>";
}
$out = "GET /u?$parameter HTTP/1.1\r\nHost: 127.0.0.1:8022\r\nConnection: Close\r\n\r\n";
$out = "GET /u?$parameter HTTP/1.1\r\nHost: 127.0.0.1:8022\r\nConnection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$line = fgets($fp,1024);
if (0 == strlen($line)) {
continue;
}
fwrite($fp, $out);
while (!feof($fp)) {
$line = fgets($fp,1024);
if (0 == strlen($line)) {
continue;
}
if ('<' == substr($line, 0, 1)) {
$flag = true;
$return .= $line;
break;
}
}
if ('<' == substr($line, 0, 1)) {
$flag = true;
$return .= $line;
break;
}
}
if ($flag) {
while (!feof($fp)) {
$return .= fgets($fp, 1024);
}
}
if ($flag) {
while (!feof($fp)) {
$return .= fgets($fp, 1024);
}
}
return ($return);
return ($return);
}
?>

View File

@ -15,102 +15,102 @@ require_once "$TOPDIR/lib/jsonwrapper.php";
* @return The xCAT response. Replies are in the form of JSON
*/
if (isset($_GET["cmd"])) {
// HTTP GET requests
$cmd = $_GET["cmd"];
$tgt = $_GET["tgt"];
$args = $_GET["args"];
// HTTP GET requests
$cmd = $_GET["cmd"];
$tgt = $_GET["tgt"];
$args = $_GET["args"];
// Special messages put here
// This gets sent back to the AJAX request as is.
$msg = $_GET["msg"];
// Special messages put here
// This gets sent back to the AJAX request as is.
$msg = $_GET["msg"];
// If no $tgt is given, set $tgt to NULL
if (!$tgt) {
$tgt = NULL;
}
// If no $tgt is given, set $tgt to NULL
if (!$tgt) {
$tgt = NULL;
}
// If no $msg is given, set $msg to NULL
if (!$msg) {
$msg = NULL;
}
// If no $msg is given, set $msg to NULL
if (!$msg) {
$msg = NULL;
}
// If no $args are given, set $args_array to NULL
$args_array = array();
if ($args) {
// If $args contains multiple arguments, split it into an array
if (strpos($args,";")) {
// Split the arguments into an array
$args_array = array();
$args_array = explode(";", $args);
} else {
$args_array = array($args);
}
}
// If no $args are given, set $args_array to NULL
$args_array = array();
if ($args) {
// If $args contains multiple arguments, split it into an array
if (strpos($args,";")) {
// Split the arguments into an array
$args_array = array();
$args_array = explode(";", $args);
} else {
$args_array = array($args);
}
}
// If no $opts are given, set $opts_array to NULL
$opts_array = array();
if (isset($_GET["opts"])) {
$opts = $_GET["opts"];
// If no $opts are given, set $opts_array to NULL
$opts_array = array();
if (isset($_GET["opts"])) {
$opts = $_GET["opts"];
// If $args contains multiple arguments, split it into an array
if (strpos($opts,";")) {
// Split the arguments into an array
$opts_array = array();
$opts_array = explode(";", $opts);
} else {
$opts_array = array($opts);
}
}
// If $args contains multiple arguments, split it into an array
if (strpos($opts,";")) {
// Split the arguments into an array
$opts_array = array();
$opts_array = explode(";", $opts);
} else {
$opts_array = array($opts);
}
}
// Submit request and get response
$xml = docmd($cmd, $tgt, $args_array, $opts_array);
// If the output is flushed, do not return output in JSON
if (in_array("flush", $opts_array)) {
return;
}
// Submit request and get response
$xml = docmd($cmd, $tgt, $args_array, $opts_array);
// If the output is flushed, do not return output in JSON
if (in_array("flush", $opts_array)) {
return;
}
$rsp = array();
$rsp = array();
// webrun pping and gangliastatus output needs special handling
if(strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) {
$rsp = extractWebrun($xml);
}
// nodels output needs special handling
else if(strncasecmp($cmd, "nodels", 6) == 0) {
// Handle the output the same way as webrun
$rsp = extractNodels($xml);
}
// extnoderange output needs special handling
// This command gets the nodes and groups
else if(strncasecmp($cmd, "extnoderange", 12) == 0) {
$rsp = extractExtnoderange($xml);
}
// Handle the typical output
else {
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
if($data->name) {
$node = $data->name;
// webrun pping and gangliastatus output needs special handling
if(strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) {
$rsp = extractWebrun($xml);
}
// nodels output needs special handling
else if(strncasecmp($cmd, "nodels", 6) == 0) {
// Handle the output the same way as webrun
$rsp = extractNodels($xml);
}
// extnoderange output needs special handling
// This command gets the nodes and groups
else if(strncasecmp($cmd, "extnoderange", 12) == 0) {
$rsp = extractExtnoderange($xml);
}
// Handle the typical output
else {
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
if($data->name) {
$node = $data->name;
if($data->data->contents){
$cont = $data->data->contents;
} else {
$cont = $data->data;
}
if($data->data->contents){
$cont = $data->data->contents;
} else {
$cont = $data->data;
}
$cont = str_replace(":|:", "\n", $cont);
array_push($rsp, "$node: $cont");
} else if (strlen("$data") > 2) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
}
}
$cont = str_replace(":|:", "\n", $cont);
array_push($rsp, "$node: $cont");
} else if (strlen("$data") > 2) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
}
}
// Reply in the form of JSON
$rtn = array("rsp" => $rsp, "msg" => $msg);
echo json_encode($rtn);
// Reply in the form of JSON
$rtn = array("rsp" => $rsp, "msg" => $msg);
echo json_encode($rtn);
}
/**
@ -120,26 +120,26 @@ if (isset($_GET["cmd"])) {
* @return An array containing the output
*/
function extractWebrun($xml) {
$rsp = array();
$i = 0;
$rsp = array();
$i = 0;
// Extract data returned
foreach($xml->children() as $nodes){
foreach($nodes->children() as $node){
// Get the node name
$name = $node->name;
// Extract data returned
foreach($xml->children() as $nodes){
foreach($nodes->children() as $node){
// Get the node name
$name = $node->name;
// Get the content
$status = $node->data;
$status = str_replace(":|:", "\n", $status);
// Get the content
$status = $node->data;
$status = str_replace(":|:", "\n", $status);
// Add to return array
$rsp[$i] = array("$name", "$status");
$i++;
}
}
// Add to return array
$rsp[$i] = array("$name", "$status");
$i++;
}
}
return $rsp;
return $rsp;
}
/**
@ -149,26 +149,26 @@ function extractWebrun($xml) {
* @return An array containing the output
*/
function extractNodels($xml) {
$rsp = array();
$i = 0;
$rsp = array();
$i = 0;
// Extract data returned
foreach($xml->children() as $nodes){
foreach($nodes->children() as $node){
// Get the node name
$name = $node->name;
// Get the content
$status = $node->data->contents;
$status = str_replace(":|:", "\n", $status);
// Extract data returned
foreach($xml->children() as $nodes){
foreach($nodes->children() as $node){
// Get the node name
$name = $node->name;
// Get the content
$status = $node->data->contents;
$status = str_replace(":|:", "\n", $status);
$description = $node->data->desc;
// Add to return array
$rsp[$i] = array("$name", "$status", "$description");
$i++;
}
}
$description = $node->data->desc;
// Add to return array
$rsp[$i] = array("$name", "$status", "$description");
$i++;
}
}
return $rsp;
return $rsp;
}
/**
@ -178,13 +178,13 @@ function extractNodels($xml) {
* @return The nodes and groups
*/
function extractExtnoderange($xml) {
$rsp = array();
$rsp = array();
// Extract data returned
foreach ($xml->xcatresponse->intersectinggroups as $group) {
array_push($rsp, "$group");
}
// Extract data returned
foreach ($xml->xcatresponse->intersectinggroups as $group) {
array_push($rsp, "$group");
}
return $rsp;
return $rsp;
}
?>

View File

@ -12,9 +12,9 @@ require_once "$TOPDIR/lib/jsonwrapper.php";
* @return The xCAT response. Replies are in the form of JSON
*/
if (isset($_POST["table"])) {
// HTTP POST requests
$tab = $_POST["table"];
$cont = $_POST["cont"];
// HTTP POST requests
$tab = $_POST["table"];
$cont = $_POST["cont"];
}
// Create xCAT request
@ -31,46 +31,46 @@ $usernode->addChild('password', getpassword());
// Go through each table row
$first = 0;
foreach($cont as $line){
if($first == 0){
// The 1st line is the table header
// It does not need special processing
// Create string containing all array elements
$str = implode(",", $line);
$request->addChild('data', $str);
if($first == 0){
// The 1st line is the table header
// It does not need special processing
// Create string containing all array elements
$str = implode(",", $line);
$request->addChild('data', $str);
$first = 1;
continue;
}
$first = 1;
continue;
}
// Go through each column
foreach ($line as &$col){
// If the column does begins and end with a quote
// Change quotes to &quot;
if(!empty($col) && !preg_match('/^".*"$/', $col)) {
$col = '&quot;' . $col . '&quot;';
}
}
// Go through each column
foreach ($line as &$col){
// If the column does begins and end with a quote
// Change quotes to &quot;
if(!empty($col) && !preg_match('/^".*"$/', $col)) {
$col = '&quot;' . $col . '&quot;';
}
}
// Sort line
ksort($line, SORT_NUMERIC);
$keys = array_keys($line);
$max = count($line) - 1;
if ($keys[$max] != $max){
for ($i = 0; $i <= $keys[$max]; $i++) {
if (!isset($line[$i])) {
$line[$i]='';
}
}
ksort($line, SORT_NUMERIC);
}
// Sort line
ksort($line, SORT_NUMERIC);
$keys = array_keys($line);
$max = count($line) - 1;
if ($keys[$max] != $max){
for ($i = 0; $i <= $keys[$max]; $i++) {
if (!isset($line[$i])) {
$line[$i]='';
}
}
ksort($line, SORT_NUMERIC);
}
// Create string containing all array elements
$str = implode(",", $line);
// Replace " with &quot;
$str = str_replace('"', '&quot;', $str);
// Replace ' with &apos;
$str = str_replace("'", '&apos;', $str);
$request->addChild('data', $str);
// Create string containing all array elements
$str = implode(",", $line);
// Replace " with &quot;
$str = str_replace('"', '&quot;', $str);
// Replace ' with &apos;
$str = str_replace("'", '&apos;', $str);
$request->addChild('data', $str);
}
// Run command

View File

@ -13,125 +13,125 @@ require_once "$TOPDIR/lib/jsonwrapper.php";
* @return The xCAT response. Replies are in the form of JSON
*/
if (isset($_GET["cmd"])) {
// HTTP GET requests
$cmd = $_GET["cmd"];
$tgt = $_GET["tgt"];
$args = $_GET["args"];
// HTTP GET requests
$cmd = $_GET["cmd"];
$tgt = $_GET["tgt"];
$args = $_GET["args"];
// Attachments are put here
$att = $_GET["att"];
// Attachments are put here
$att = $_GET["att"];
// Special messages put here
$msg = $_GET["msg"];
// Special messages put here
$msg = $_GET["msg"];
// If no $tgt is given, set $tgt to NULL
if (!$tgt) {
$tgt = NULL;
}
// If no $tgt is given, set $tgt to NULL
if (!$tgt) {
$tgt = NULL;
}
// If no $args is given, set $args to NULL
if (!$args) {
$args = NULL;
}
// If no $args is given, set $args to NULL
if (!$args) {
$args = NULL;
}
// If no $msg is given, set $msg to NULL
if (!$msg) {
$msg = NULL;
}
// If no $msg is given, set $msg to NULL
if (!$msg) {
$msg = NULL;
}
// If no $att is given, set $att to NULL
if (!$att) {
$att = NULL;
}
// If no $att is given, set $att to NULL
if (!$att) {
$att = NULL;
}
// If $args contains multiple arguments, split it into an array
if (strpos($args,";")) {
// Split the arguments into an array
$arr = array();
$arr = explode(";", $args);
} else {
$arr = array($args);
}
// If $args contains multiple arguments, split it into an array
if (strpos($args,";")) {
// Split the arguments into an array
$arr = array();
$arr = explode(";", $args);
} else {
$arr = array($args);
}
$rsp = array();
$rsp = array();
// Replace user entry
if (strncasecmp($cmd, "chvm", 4) == 0 && strncasecmp($arr[0], "--replacevs", 11) == 0) {
// Directory /var/tmp permissions = 777
// You can write anything to that directory
$userEntry = "/var/tmp/$tgt.txt";
$handle = fopen($userEntry, 'w') or die("Cannot open $userEntry");
fwrite($handle, $att);
fclose($handle);
// Replace user entry
if (strncasecmp($cmd, "chvm", 4) == 0 && strncasecmp($arr[0], "--replacevs", 11) == 0) {
// Directory /var/tmp permissions = 777
// You can write anything to that directory
$userEntry = "/var/tmp/$tgt.txt";
$handle = fopen($userEntry, 'w') or die("Cannot open $userEntry");
fwrite($handle, $att);
fclose($handle);
// CLI command: chvm gpok249 --replacevs /tmp/dirEntry.txt
// Replace user entry
array_push($arr, $userEntry);
$xml = docmd($cmd, $tgt, $arr, NULL);
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
}
// CLI command: chvm gpok249 --replacevs /tmp/dirEntry.txt
// Replace user entry
array_push($arr, $userEntry);
$xml = docmd($cmd, $tgt, $arr, NULL);
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
}
// Create virtual server
else if (strncasecmp($cmd, "mkvm", 4) == 0) {
// Directory /var/tmp permissions = 777
// You can write anything to that directory
$userEntry = "/var/tmp/$tgt.txt";
$handle = fopen($userEntry, 'w') or die("Cannot open $userEntry");
fwrite($handle, $att);
fclose($handle);
// Create virtual server
else if (strncasecmp($cmd, "mkvm", 4) == 0) {
// Directory /var/tmp permissions = 777
// You can write anything to that directory
$userEntry = "/var/tmp/$tgt.txt";
$handle = fopen($userEntry, 'w') or die("Cannot open $userEntry");
fwrite($handle, $att);
fclose($handle);
// CLI command: mkvm gpok3 /tmp/gpok3.txt
// Create user entry
array_unshift($arr, $userEntry);
$xml = docmd($cmd, $tgt, $arr, NULL);
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
}
// CLI command: mkvm gpok3 /tmp/gpok3.txt
// Create user entry
array_unshift($arr, $userEntry);
$xml = docmd($cmd, $tgt, $arr, NULL);
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
}
// Run shell script
// This is a typical command used by all platforms. It is put here because
// most of the code needed are already here
else if (strncasecmp($cmd, "xdsh", 4) == 0) {
// Directory /var/tmp permissions = 777
// You can write anything to that directory
$msgArgs = explode(";", $msg);
$inst = str_replace("out=scriptStatusBar", "", $msgArgs[0]);
$script = "/var/tmp/script$inst.sh";
// Run shell script
// This is a typical command used by all platforms. It is put here because
// most of the code needed are already here
else if (strncasecmp($cmd, "xdsh", 4) == 0) {
// Directory /var/tmp permissions = 777
// You can write anything to that directory
$msgArgs = explode(";", $msg);
$inst = str_replace("out=scriptStatusBar", "", $msgArgs[0]);
$script = "/var/tmp/script$inst.sh";
// Write to file
$handle = fopen($script, 'w') or die("Cannot open $script");
fwrite($handle, $att);
fclose($handle);
// Write to file
$handle = fopen($script, 'w') or die("Cannot open $script");
fwrite($handle, $att);
fclose($handle);
// Change it to executable
chmod($script, 0777);
// Change it to executable
chmod($script, 0777);
// CLI command: xdsh gpok3 -e /var/tmp/gpok3.sh
// Create user entry
array_push($arr, $script);
$xml = docmd($cmd, $tgt, $arr, NULL);
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
// CLI command: xdsh gpok3 -e /var/tmp/gpok3.sh
// Create user entry
array_push($arr, $script);
$xml = docmd($cmd, $tgt, $arr, NULL);
foreach ($xml->children() as $child) {
foreach ($child->children() as $data) {
$data = str_replace(":|:", "\n", $data);
array_push($rsp, "$data");
}
}
// Remove this file
unlink($script);
}
// Remove this file
unlink($script);
}
// Reply in the form of JSON
$rtn = array("rsp" => $rsp, "msg" => $msg);
echo json_encode($rtn);
// Reply in the form of JSON
$rtn = array("rsp" => $rsp, "msg" => $msg);
echo json_encode($rtn);
}
?>