5 public $xmlrpcI4 = "i4";
6 public $xmlrpcInt = "int";
7 public $xmlrpcBoolean = "boolean";
8 public $xmlrpcDouble = "double";
9 public $xmlrpcString = "string";
10 public $xmlrpcDateTime = "dateTime.iso8601";
11 public $xmlrpcBase64 = "base64";
12 public $xmlrpcArray = "array";
13 public $xmlrpcStruct = "struct";
14 public $xmlrpcValue = "undefined";
15 public $xmlrpcNull = "null";
19 public $xmlrpc_valid_parents = array(
20 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
21 'BOOLEAN' => array('VALUE'),
22 'I4' => array('VALUE'),
23 'INT' => array('VALUE'),
24 'STRING' => array('VALUE'),
25 'DOUBLE' => array('VALUE'),
26 'DATETIME.ISO8601' => array('VALUE'),
27 'BASE64' => array('VALUE'),
28 'MEMBER' => array('STRUCT'),
29 'NAME' => array('MEMBER'),
30 'DATA' => array('ARRAY'),
31 'ARRAY' => array('VALUE'),
32 'STRUCT' => array('VALUE'),
33 'PARAM' => array('PARAMS'),
34 'METHODNAME' => array('METHODCALL'),
35 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
36 'FAULT' => array('METHODRESPONSE'),
37 'NIL' => array('VALUE'), // only used when extension activated
38 'EX:NIL' => array('VALUE') // only used when extension activated
41 // tables used for transcoding different charsets into us-ascii xml
42 public $xml_iso88591_Entities = array("in" => array(), "out" => array());
44 /// @todo add to iso table the characters from cp_1252 range, i.e. 128 to 159?
45 /// These will NOT be present in true ISO-8859-1, but will save the unwary
46 /// windows user from sending junk (though no luck when reciving them...)
48 $GLOBALS['xml_cp1252_Entities']=array();
49 for ($i = 128; $i < 160; $i++)
51 $GLOBALS['xml_cp1252_Entities']['in'][] = chr($i);
53 $GLOBALS['xml_cp1252_Entities']['out'] = array(
54 '€', '?', '‚', 'ƒ',
55 '„', '…', '†', '‡',
56 'ˆ', '‰', 'Š', '‹',
57 'Œ', '?', 'Ž', '?',
58 '?', '‘', '’', '“',
59 '”', '•', '–', '—',
60 '˜', '™', 'š', '›',
61 'œ', '?', 'ž', 'Ÿ'
65 public $xmlrpcerr = array(
68 'incorrect_params'=>3,
69 'introspect_unknown'=>4,
74 'invalid_request'=>15,
77 'multicall_error'=>18,
78 'multicall_notstruct'=>9,
79 'multicall_nomethod'=>10,
80 'multicall_notstring'=>11,
81 'multicall_recursion'=>12,
82 'multicall_noparams'=>13,
83 'multicall_notarray'=>14,
85 'cannot_decompress'=>103,
86 'decompress_fail'=>104,
88 'server_cannot_decompress'=>106,
89 'server_decompress_fail'=>107
92 public $xmlrpcstr = array(
93 'unknown_method'=>'Unknown method',
94 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload',
95 'incorrect_params'=>'Incorrect parameters passed to method',
96 'introspect_unknown'=>"Can't introspect: method unknown",
97 'http_error'=>"Didn't receive 200 OK from remote server.",
98 'no_data'=>'No data received from server.',
99 'no_ssl'=>'No SSL support compiled in.',
100 'curl_fail'=>'CURL error',
101 'invalid_request'=>'Invalid request payload',
102 'no_curl'=>'No CURL support compiled in.',
103 'server_error'=>'Internal server error',
104 'multicall_error'=>'Received from server invalid multicall response',
105 'multicall_notstruct'=>'system.multicall expected struct',
106 'multicall_nomethod'=>'missing methodName',
107 'multicall_notstring'=>'methodName is not a string',
108 'multicall_recursion'=>'recursive system.multicall forbidden',
109 'multicall_noparams'=>'missing params',
110 'multicall_notarray'=>'params is not an array',
112 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress',
113 'decompress_fail'=>'Received from server invalid compressed HTTP',
114 'dechunk_fail'=>'Received from server invalid chunked HTTP',
115 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress',
116 'server_decompress_fail'=>'Received from client invalid compressed HTTP request'
119 // The charset encoding used by the server for received messages and
120 // by the client for received responses when received charset cannot be determined
121 // or is not supported
122 public $xmlrpc_defencoding = "UTF-8";
124 // The encoding used internally by PHP.
125 // String values received as xml will be converted to this, and php strings will be converted to xml
126 // as if having been coded with this
127 public $xmlrpc_internalencoding = "ISO-8859-1"; // TODO: maybe this would be better as UTF-8, or atleast configurable?
129 public $xmlrpcName = "XML-RPC for PHP";
130 public $xmlrpcVersion = "3.0.0.beta";
132 // let user errors start at 800
133 public $xmlrpcerruser = 800;
134 // let XML parse errors start at 100
135 public $xmlrpcerrxml = 100;
137 // set to TRUE to enable correct decoding of <NIL/> and <EX:NIL/> values
138 public $xmlrpc_null_extension = false;
140 // set to TRUE to enable encoding of php NULL values to <EX:NIL/> instead of <NIL/>
141 public $xmlrpc_null_apache_encoding = false;
143 public $xmlrpc_null_apache_encoding_ns = "http://ws.apache.org/xmlrpc/namespaces/extensions";
145 // used to store state during parsing
146 // quick explanation of components:
147 // ac - used to accumulate values
148 // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1)
149 // isf_reason - used for storing xmlrpcresp fault string
150 // lv - used to indicate "looking for a value": implements
151 // the logic to allow values with no types to be strings
152 // params - used to store parameters in method calls
153 // method - used to store method name
154 // stack - array with genealogy of xml elements names:
155 // used to validate nesting of xmlrpc elements
158 private static $instance = null;
160 private function __construct() {
161 $this->xmlrpcTypes = array(
162 $this->xmlrpcI4 => 1,
163 $this->xmlrpcInt => 1,
164 $this->xmlrpcBoolean => 1,
165 $this->xmlrpcDouble => 1,
166 $this->xmlrpcString => 1,
167 $this->xmlrpcDateTime => 1,
168 $this->xmlrpcBase64 => 1,
169 $this->xmlrpcArray => 2,
170 $this->xmlrpcStruct => 3,
171 $this->xmlrpcNull => 1
174 for($i = 0; $i < 32; $i++) {
175 $this->xml_iso88591_Entities["in"][] = chr($i);
176 $this->xml_iso88591_Entities["out"][] = "&#{$i};";
179 for($i = 160; $i < 256; $i++) {
180 $this->xml_iso88591_Entities["in"][] = chr($i);
181 $this->xml_iso88591_Entities["out"][] = "&#{$i};";
186 * This class is singleton for performance reasons: this way the ASCII array needs to be done only once.
188 public static function instance() {
189 if(Phpxmlrpc::$instance === null) {
190 Phpxmlrpc::$instance = new Phpxmlrpc();
193 return Phpxmlrpc::$instance;