From 77fd1f51a3c5f5a52f72ef8a299fe368228e2285 Mon Sep 17 00:00:00 2001 From: vdigital Date: Fri, 23 May 2008 21:05:41 +0000 Subject: git-svn-id: http://piwigo.org/svn/trunk@2357 68402e56-0260-453c-a942-63ccdbb3a9ee --- BSF/include/ws_protocols/xmlrpc_encoder.php | 115 ++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 BSF/include/ws_protocols/xmlrpc_encoder.php (limited to 'BSF/include/ws_protocols/xmlrpc_encoder.php') diff --git a/BSF/include/ws_protocols/xmlrpc_encoder.php b/BSF/include/ws_protocols/xmlrpc_encoder.php new file mode 100644 index 000000000..26f0f510e --- /dev/null +++ b/BSF/include/ws_protocols/xmlrpc_encoder.php @@ -0,0 +1,115 @@ +'.($data ? '1' : '0').''; + case 'integer': + return ''.$data.''; + case 'double': + return ''.$data.''; + case 'string': + return ''.htmlspecialchars($data).''; + case 'object': + case 'array': + $is_array = range(0, count($data) - 1) === array_keys($data); + if ($is_array) + { + $return = ''."\n"; + foreach ($data as $item) + { + $return .= ' '.xmlrpc_encode($item)."\n"; + } + $return .= ''; + } + else + { + $return = ''."\n"; + foreach ($data as $name => $value) + { + $name = htmlspecialchars($name); + $return .= " $name"; + $return .= xmlrpc_encode($value)."\n"; + } + $return .= ''; + } + return $return; + } +} + +class PwgXmlRpcEncoder extends PwgResponseEncoder +{ + function encodeResponse($response) + { + $respClass = strtolower( get_class($response) ); + if ($respClass=='pwgerror') + { + $code = $response->code(); + $msg = htmlspecialchars($response->message()); + $ret = << + + + + + faultCode + {$code} + + + faultString + {$msg} + + + + + +EOD; + return $ret; + } + + parent::flattenResponse($response); + $ret = xmlrpc_encode($response); + $ret = << + + + + $ret + + + + +EOD; + return $ret; + } + + function getContentType() + { + return 'text/xml'; + } +} + +?> -- cgit v1.2.3