children() as $child) { foreach ($child->children() as $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); // CLI command: mkvm gpok3 /tmp/gpok3.txt // Create user entry array_unshift($arr, $userEntry); $xml = docmd($cmd, $tgt, $arr); foreach ($xml->children() as $child) { foreach ($child->children() as $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"; // Write to file $handle = fopen($script, 'w') or die("Cannot open $script"); fwrite($handle, $att); fclose($handle); // 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); foreach ($xml->children() as $child) { foreach ($child->children() as $data) { array_push($rsp, "$data"); } } // Remove this file unlink($script); } // Reply in the form of JSON $rtn = array("rsp" => $rsp, "msg" => $msg); echo json_encode($rtn); } ?>