replace the \n in data by :|:

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6950 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
xq2005 2010-08-03 09:06:09 +00:00
parent 078b1fad3a
commit 99aac6db31
2 changed files with 11 additions and 2 deletions

View File

@ -67,7 +67,12 @@ if (isset($_GET["cmd"])) {
foreach ($child->children() as $data) {
if($data->name) {
$node = $data->name;
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) {

View File

@ -67,8 +67,8 @@ function submit_request($req, $skipVerify){
fwrite($fp,$req->asXML()); // Send XML to xcatd
while(!feof($fp)){ // Read until there is no more
// Remove newlines and add it to the response
$response .= preg_replace('/\n/', ':|:', fread($fp, 8192));
$response .= fread($fp, 8192);
$response = preg_replace('/>\n\s*</', '><', $response);
// Look for serverdone response
$fullpattern = '/<xcatresponse>\s*<serverdone>\s*<\/serverdone>\s*<\/xcatresponse>/';
$mixedpattern = '/<serverdone>\s*<\/serverdone>.*<\/xcatresponse>/';
@ -80,6 +80,10 @@ function submit_request($req, $skipVerify){
$response = preg_replace($fullpattern,'', $response, -1, $count); // 1st try to remove the long pattern
if (!$count) { $response = preg_replace($mixedpattern,'', $response) . '</xcatresponse>/'; } // if its not there, then remove the short pattern
$response = "<xcat>$response</xcat>";
//delete the \n between '>' and '<'
$response = preg_replace('/>\n\s*</', '><', $response);
//replace the '\n' by ':|:' in the data area.
$response = preg_replace('/\n/', ':|:', $response);
$rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA);
$cleanexit = 1;
break;