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