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('in' => array(), out' => array(
50 '€', '?', '‚', 'ƒ',
51 '„', '…', '†', '‡',
52 'ˆ', '‰', 'Š', '‹',
53 'Œ', '?', 'Ž', '?',
54 '?', '‘', '’', '“',
55 '”', '•', '–', '—',
56 '˜', '™', 'š', '›',
57 'œ', '?', 'ž', 'Ÿ'
61 public $xmlrpcerr = array(
64 'incorrect_params'=>3,
65 'introspect_unknown'=>4,
70 'invalid_request'=>15,
73 'multicall_error'=>18,
74 'multicall_notstruct'=>9,
75 'multicall_nomethod'=>10,
76 'multicall_notstring'=>11,
77 'multicall_recursion'=>12,
78 'multicall_noparams'=>13,
79 'multicall_notarray'=>14,
81 'cannot_decompress'=>103,
82 'decompress_fail'=>104,
84 'server_cannot_decompress'=>106,
85 'server_decompress_fail'=>107
88 public $xmlrpcstr = array(
89 'unknown_method'=>'Unknown method',
90 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload',
91 'incorrect_params'=>'Incorrect parameters passed to method',
92 'introspect_unknown'=>"Can't introspect: method unknown",
93 'http_error'=>"Didn't receive 200 OK from remote server.",
94 'no_data'=>'No data received from server.',
95 'no_ssl'=>'No SSL support compiled in.',
96 'curl_fail'=>'CURL error',
97 'invalid_request'=>'Invalid request payload',
98 'no_curl'=>'No CURL support compiled in.',
99 'server_error'=>'Internal server error',
100 'multicall_error'=>'Received from server invalid multicall response',
101 'multicall_notstruct'=>'system.multicall expected struct',
102 'multicall_nomethod'=>'missing methodName',
103 'multicall_notstring'=>'methodName is not a string',
104 'multicall_recursion'=>'recursive system.multicall forbidden',
105 'multicall_noparams'=>'missing params',
106 'multicall_notarray'=>'params is not an array',
108 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress',
109 'decompress_fail'=>'Received from server invalid compressed HTTP',
110 'dechunk_fail'=>'Received from server invalid chunked HTTP',
111 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress',
112 'server_decompress_fail'=>'Received from client invalid compressed HTTP request'
115 // The charset encoding used by the server for received messages and
116 // by the client for received responses when received charset cannot be determined
117 // or is not supported
118 public $xmlrpc_defencoding = "UTF-8";
120 // The encoding used internally by PHP.
121 // String values received as xml will be converted to this, and php strings will be converted to xml
122 // as if having been coded with this
123 public $xmlrpc_internalencoding = "ISO-8859-1"; // TODO: maybe this would be better as UTF-8, or atleast configurable?
125 public $xmlrpcName = "XML-RPC for PHP";
126 public $xmlrpcVersion = "4.0.0.beta";
128 // let user errors start at 800
129 public $xmlrpcerruser = 800;
130 // let XML parse errors start at 100
131 public $xmlrpcerrxml = 100;
133 // set to TRUE to enable correct decoding of <NIL/> and <EX:NIL/> values
134 public $xmlrpc_null_extension = false;
136 // set to TRUE to enable encoding of php NULL values to <EX:NIL/> instead of <NIL/>
137 public $xmlrpc_null_apache_encoding = false;
139 public $xmlrpc_null_apache_encoding_ns = "http://ws.apache.org/xmlrpc/namespaces/extensions";
141 // used to store state during parsing
142 // quick explanation of components:
143 // ac - used to accumulate values
144 // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1)
145 // isf_reason - used for storing xmlrpcresp fault string
146 // lv - used to indicate "looking for a value": implements
147 // the logic to allow values with no types to be strings
148 // params - used to store parameters in method calls
149 // method - used to store method name
150 // stack - array with genealogy of xml elements names:
151 // used to validate nesting of xmlrpc elements
154 protected static $instance = null;
156 private function __construct() {
157 $this->xmlrpcTypes = array(
158 $this->xmlrpcI4 => 1,
159 $this->xmlrpcInt => 1,
160 $this->xmlrpcBoolean => 1,
161 $this->xmlrpcDouble => 1,
162 $this->xmlrpcString => 1,
163 $this->xmlrpcDateTime => 1,
164 $this->xmlrpcBase64 => 1,
165 $this->xmlrpcArray => 2,
166 $this->xmlrpcStruct => 3,
167 $this->xmlrpcNull => 1
170 for($i = 0; $i < 32; $i++) {
171 $this->xml_iso88591_Entities["in"][] = chr($i);
172 $this->xml_iso88591_Entities["out"][] = "&#{$i};";
175 for($i = 160; $i < 256; $i++) {
176 $this->xml_iso88591_Entities["in"][] = chr($i);
177 $this->xml_iso88591_Entities["out"][] = "&#{$i};";
180 /*for ($i = 128; $i < 160; $i++)
182 $this->xml_cp1252_Entities['in'][] = chr($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(self::$instance === null) {
191 self::$instance = new self();
194 return self::$instance;