| 253 | | |
| | 257 | |
| | 258 | function respondResultPage($error) { |
| | 259 | if ($error === true) |
| | 260 | $error = 0; |
| | 261 | else if ($error === false) |
| | 262 | $error = 1; |
| | 263 | header('Content-Type: text/xml; charset=utf-8'); |
| | 264 | print ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<response>\n<error>$error</error>\n</response>"); |
| | 265 | exit; |
| | 266 | } |
| | 267 | |
| | 268 | function printRespond($result, $useCDATA=true) { |
| | 269 | header('Content-Type: text/xml; charset=utf-8'); |
| | 270 | $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; |
| | 271 | $xml .= "<response>\n"; |
| | 272 | $xml .= misc::printRespondValue($result, $useCDATA); |
| | 273 | $xml .= "</response>\n"; |
| | 274 | die($xml); |
| | 275 | } |
| | 276 | /* private */ |
| | 277 | function printRespondValue($array, $useCDATA=true) { |
| | 278 | $xml = ''; |
| | 279 | if(is_array($array)) { |
| | 280 | foreach($array as $key => $value) { |
| | 281 | if(is_null($value)) |
| | 282 | continue; |
| | 283 | else if(is_array($value)) { |
| | 284 | if(is_numeric($key)) |
| | 285 | $xml .= misc::printRespondValue($value, $useCDATA)."\n"; |
| | 286 | else |
| | 287 | $xml .= "<$key>".misc::printRespondValue($value, $useCDATA)."</$key>\n"; |
| | 288 | } |
| | 289 | else { |
| | 290 | if($useCDATA) |
| | 291 | $xml .= "<$key><![CDATA[".misc::escapeCData($value)."]]></$key>\n"; |
| | 292 | else |
| | 293 | $xml .= "<$key>".htmlspecialchars($value)."</$key>\n"; |
| | 294 | } |
| | 295 | } |
| | 296 | } |
| | 297 | return $xml; |
| | 298 | } |