@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
35 | 35 | // OF THE POSSIBILITY OF SUCH DAMAGE. |
36 | 36 | |
37 | - if(!function_exists('xml_parser_create')) |
|
37 | + if (!function_exists('xml_parser_create')) |
|
38 | 38 | { |
39 | 39 | // For PHP 4 onward, XML functionality is always compiled-in on windows: |
40 | 40 | // no more need to dl-open it. It might have been compiled out on *nix... |
41 | - if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN')) |
|
41 | + if (strtoupper(substr(PHP_OS, 0, 3) != 'WIN')) |
|
42 | 42 | { |
43 | 43 | dl('xml.so'); |
44 | 44 | } |
@@ -47,18 +47,18 @@ discard block |
||
47 | 47 | // G. Giunta 2005/01/29: declare global these variables, |
48 | 48 | // so that xmlrpc.inc will work even if included from within a function |
49 | 49 | // Milosch: 2005/08/07 - explicitly request these via $GLOBALS where used. |
50 | - $GLOBALS['xmlrpcI4']='i4'; |
|
51 | - $GLOBALS['xmlrpcInt']='int'; |
|
52 | - $GLOBALS['xmlrpcBoolean']='boolean'; |
|
53 | - $GLOBALS['xmlrpcDouble']='double'; |
|
54 | - $GLOBALS['xmlrpcString']='string'; |
|
55 | - $GLOBALS['xmlrpcDateTime']='dateTime.iso8601'; |
|
56 | - $GLOBALS['xmlrpcBase64']='base64'; |
|
57 | - $GLOBALS['xmlrpcArray']='array'; |
|
58 | - $GLOBALS['xmlrpcStruct']='struct'; |
|
59 | - $GLOBALS['xmlrpcValue']='undefined'; |
|
60 | - |
|
61 | - $GLOBALS['xmlrpcTypes']=array( |
|
50 | + $GLOBALS['xmlrpcI4'] = 'i4'; |
|
51 | + $GLOBALS['xmlrpcInt'] = 'int'; |
|
52 | + $GLOBALS['xmlrpcBoolean'] = 'boolean'; |
|
53 | + $GLOBALS['xmlrpcDouble'] = 'double'; |
|
54 | + $GLOBALS['xmlrpcString'] = 'string'; |
|
55 | + $GLOBALS['xmlrpcDateTime'] = 'dateTime.iso8601'; |
|
56 | + $GLOBALS['xmlrpcBase64'] = 'base64'; |
|
57 | + $GLOBALS['xmlrpcArray'] = 'array'; |
|
58 | + $GLOBALS['xmlrpcStruct'] = 'struct'; |
|
59 | + $GLOBALS['xmlrpcValue'] = 'undefined'; |
|
60 | + |
|
61 | + $GLOBALS['xmlrpcTypes'] = array( |
|
62 | 62 | $GLOBALS['xmlrpcI4'] => 1, |
63 | 63 | $GLOBALS['xmlrpcInt'] => 1, |
64 | 64 | $GLOBALS['xmlrpcBoolean'] => 1, |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | ); |
94 | 94 | |
95 | 95 | // define extra types for supporting NULL (useful for json or <NIL/>) |
96 | - $GLOBALS['xmlrpcNull']='null'; |
|
97 | - $GLOBALS['xmlrpcTypes']['null']=1; |
|
96 | + $GLOBALS['xmlrpcNull'] = 'null'; |
|
97 | + $GLOBALS['xmlrpcTypes']['null'] = 1; |
|
98 | 98 | |
99 | 99 | // Not in use anymore since 2.0. Shall we remove it? |
100 | 100 | /// @deprecated |
101 | - $GLOBALS['xmlEntities']=array( |
|
101 | + $GLOBALS['xmlEntities'] = array( |
|
102 | 102 | 'amp' => '&', |
103 | 103 | 'quot' => '"', |
104 | 104 | 'lt' => '<', |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | |
109 | 109 | // tables used for transcoding different charsets into us-ascii xml |
110 | 110 | |
111 | - $GLOBALS['xml_iso88591_Entities']=array(); |
|
111 | + $GLOBALS['xml_iso88591_Entities'] = array(); |
|
112 | 112 | $GLOBALS['xml_iso88591_Entities']['in'] = array(); |
113 | 113 | $GLOBALS['xml_iso88591_Entities']['out'] = array(); |
114 | - for ($i = 0; $i < 32; $i++) |
|
114 | + for ($i = 0; $i<32; $i++) |
|
115 | 115 | { |
116 | 116 | $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); |
117 | 117 | $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; |
118 | 118 | } |
119 | - for ($i = 160; $i < 256; $i++) |
|
119 | + for ($i = 160; $i<256; $i++) |
|
120 | 120 | { |
121 | 121 | $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); |
122 | 122 | $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | // The charset encoding used by the server for received messages and |
201 | 201 | // by the client for received responses when received charset cannot be determined |
202 | 202 | // or is not supported |
203 | - $GLOBALS['xmlrpc_defencoding']='UTF-8'; |
|
203 | + $GLOBALS['xmlrpc_defencoding'] = 'UTF-8'; |
|
204 | 204 | |
205 | 205 | // The encoding used internally by PHP. |
206 | 206 | // String values received as xml will be converted to this, and php strings will be converted to xml |
207 | 207 | // as if having been coded with this |
208 | - $GLOBALS['xmlrpc_internalencoding']='ISO-8859-1'; |
|
208 | + $GLOBALS['xmlrpc_internalencoding'] = 'ISO-8859-1'; |
|
209 | 209 | |
210 | - $GLOBALS['xmlrpcName']='XML-RPC for PHP'; |
|
211 | - $GLOBALS['xmlrpcVersion']='3.0.1'; |
|
210 | + $GLOBALS['xmlrpcName'] = 'XML-RPC for PHP'; |
|
211 | + $GLOBALS['xmlrpcVersion'] = '3.0.1'; |
|
212 | 212 | |
213 | 213 | // let user errors start at 800 |
214 | - $GLOBALS['xmlrpcerruser']=800; |
|
214 | + $GLOBALS['xmlrpcerruser'] = 800; |
|
215 | 215 | // let XML parse errors start at 100 |
216 | - $GLOBALS['xmlrpcerrxml']=100; |
|
216 | + $GLOBALS['xmlrpcerrxml'] = 100; |
|
217 | 217 | |
218 | 218 | // formulate backslashes for escaping regexp |
219 | 219 | // Not in use anymore since 2.0. Shall we remove it? |
220 | 220 | /// @deprecated |
221 | - $GLOBALS['xmlrpc_backslash']=chr(92).chr(92); |
|
221 | + $GLOBALS['xmlrpc_backslash'] = chr(92).chr(92); |
|
222 | 222 | |
223 | 223 | // set to TRUE to enable correct decoding of <NIL/> and <EX:NIL/> values |
224 | - $GLOBALS['xmlrpc_null_extension']=false; |
|
224 | + $GLOBALS['xmlrpc_null_extension'] = false; |
|
225 | 225 | |
226 | 226 | // set to TRUE to enable encoding of php NULL values to <EX:NIL/> instead of <NIL/> |
227 | - $GLOBALS['xmlrpc_null_apache_encoding']=false; |
|
228 | - $GLOBALS['xmlrpc_null_apache_encoding_ns']='http://ws.apache.org/xmlrpc/namespaces/extensions'; |
|
227 | + $GLOBALS['xmlrpc_null_apache_encoding'] = false; |
|
228 | + $GLOBALS['xmlrpc_null_apache_encoding_ns'] = 'http://ws.apache.org/xmlrpc/namespaces/extensions'; |
|
229 | 229 | |
230 | 230 | // used to store state during parsing |
231 | 231 | // quick explanation of components: |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | // method - used to store method name |
239 | 239 | // stack - array with genealogy of xml elements names: |
240 | 240 | // used to validate nesting of xmlrpc elements |
241 | - $GLOBALS['_xh']=null; |
|
241 | + $GLOBALS['_xh'] = null; |
|
242 | 242 | |
243 | 243 | /** |
244 | 244 | * Convert a string to the correct XML representation in a target charset |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @todo do a bit of basic benchmarking (strtr vs. str_replace) |
255 | 255 | * @todo make usage of iconv() or recode_string() or mb_string() where available |
256 | 256 | */ |
257 | - function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='') |
|
257 | + function xmlrpc_encode_entitites($data, $src_encoding = '', $dest_encoding = '') |
|
258 | 258 | { |
259 | 259 | if ($src_encoding == '') |
260 | 260 | { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $src_encoding = $GLOBALS['xmlrpc_internalencoding']; |
263 | 263 | } |
264 | 264 | |
265 | - switch(strtoupper($src_encoding.'_'.$dest_encoding)) |
|
265 | + switch (strtoupper($src_encoding.'_'.$dest_encoding)) |
|
266 | 266 | { |
267 | 267 | case 'ISO-8859-1_': |
268 | 268 | case 'ISO-8859-1_US-ASCII': |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | $escaped_data = ''; |
290 | 290 | // be kind to users creating string xmlrpcvals out of different php types |
291 | 291 | $data = (string) $data; |
292 | - $ns = strlen ($data); |
|
293 | - for ($nn = 0; $nn < $ns; $nn++) |
|
292 | + $ns = strlen($data); |
|
293 | + for ($nn = 0; $nn<$ns; $nn++) |
|
294 | 294 | { |
295 | 295 | $ch = $data[$nn]; |
296 | 296 | $ii = ord($ch); |
297 | 297 | //1 7 0bbbbbbb (127) |
298 | - if ($ii < 128) |
|
298 | + if ($ii<128) |
|
299 | 299 | { |
300 | 300 | /// @todo shall we replace this with a (supposedly) faster str_replace? |
301 | - switch($ii){ |
|
301 | + switch ($ii) { |
|
302 | 302 | case 34: |
303 | 303 | $escaped_data .= '"'; |
304 | 304 | break; |
@@ -319,31 +319,31 @@ discard block |
||
319 | 319 | } // switch |
320 | 320 | } |
321 | 321 | //2 11 110bbbbb 10bbbbbb (2047) |
322 | - else if ($ii>>5 == 6) |
|
322 | + else if ($ii >> 5 == 6) |
|
323 | 323 | { |
324 | 324 | $b1 = ($ii & 31); |
325 | 325 | $ii = ord($data[$nn+1]); |
326 | 326 | $b2 = ($ii & 63); |
327 | - $ii = ($b1 * 64) + $b2; |
|
328 | - $ent = sprintf ('&#%d;', $ii); |
|
327 | + $ii = ($b1 * 64)+$b2; |
|
328 | + $ent = sprintf('&#%d;', $ii); |
|
329 | 329 | $escaped_data .= $ent; |
330 | 330 | $nn += 1; |
331 | 331 | } |
332 | 332 | //3 16 1110bbbb 10bbbbbb 10bbbbbb |
333 | - else if ($ii>>4 == 14) |
|
333 | + else if ($ii >> 4 == 14) |
|
334 | 334 | { |
335 | 335 | $b1 = ($ii & 15); |
336 | 336 | $ii = ord($data[$nn+1]); |
337 | 337 | $b2 = ($ii & 63); |
338 | 338 | $ii = ord($data[$nn+2]); |
339 | 339 | $b3 = ($ii & 63); |
340 | - $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
|
341 | - $ent = sprintf ('&#%d;', $ii); |
|
340 | + $ii = ((($b1 * 64)+$b2) * 64)+$b3; |
|
341 | + $ent = sprintf('&#%d;', $ii); |
|
342 | 342 | $escaped_data .= $ent; |
343 | 343 | $nn += 2; |
344 | 344 | } |
345 | 345 | //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
346 | - else if ($ii>>3 == 30) |
|
346 | + else if ($ii >> 3 == 30) |
|
347 | 347 | { |
348 | 348 | $b1 = ($ii & 7); |
349 | 349 | $ii = ord($data[$nn+1]); |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | $b3 = ($ii & 63); |
353 | 353 | $ii = ord($data[$nn+3]); |
354 | 354 | $b4 = ($ii & 63); |
355 | - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
|
356 | - $ent = sprintf ('&#%d;', $ii); |
|
355 | + $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4; |
|
356 | + $ent = sprintf('&#%d;', $ii); |
|
357 | 357 | $escaped_data .= $ent; |
358 | 358 | $nn += 3; |
359 | 359 | } |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | /// xml parser handler function for opening element tags |
389 | - function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false) |
|
389 | + function xmlrpc_se($parser, $name, $attrs, $accept_single_vals = false) |
|
390 | 390 | { |
391 | 391 | // if invalid xmlrpc already detected, skip all processing |
392 | - if ($GLOBALS['_xh']['isf'] < 2) |
|
392 | + if ($GLOBALS['_xh']['isf']<2) |
|
393 | 393 | { |
394 | 394 | // check for correct element nesting |
395 | 395 | // top level element can only be of 2 types |
@@ -422,15 +422,15 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - switch($name) |
|
425 | + switch ($name) |
|
426 | 426 | { |
427 | 427 | // optimize for speed switch cases: most common cases first |
428 | 428 | case 'VALUE': |
429 | 429 | /// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element |
430 | - $GLOBALS['_xh']['vt']='value'; // indicator: no value found yet |
|
431 | - $GLOBALS['_xh']['ac']=''; |
|
432 | - $GLOBALS['_xh']['lv']=1; |
|
433 | - $GLOBALS['_xh']['php_class']=null; |
|
430 | + $GLOBALS['_xh']['vt'] = 'value'; // indicator: no value found yet |
|
431 | + $GLOBALS['_xh']['ac'] = ''; |
|
432 | + $GLOBALS['_xh']['lv'] = 1; |
|
433 | + $GLOBALS['_xh']['php_class'] = null; |
|
434 | 434 | break; |
435 | 435 | case 'I4': |
436 | 436 | case 'INT': |
@@ -439,18 +439,18 @@ discard block |
||
439 | 439 | case 'DOUBLE': |
440 | 440 | case 'DATETIME.ISO8601': |
441 | 441 | case 'BASE64': |
442 | - if ($GLOBALS['_xh']['vt']!='value') |
|
442 | + if ($GLOBALS['_xh']['vt'] != 'value') |
|
443 | 443 | { |
444 | 444 | //two data elements inside a value: an error occurred! |
445 | 445 | $GLOBALS['_xh']['isf'] = 2; |
446 | 446 | $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; |
447 | 447 | return; |
448 | 448 | } |
449 | - $GLOBALS['_xh']['ac']=''; // reset the accumulator |
|
449 | + $GLOBALS['_xh']['ac'] = ''; // reset the accumulator |
|
450 | 450 | break; |
451 | 451 | case 'STRUCT': |
452 | 452 | case 'ARRAY': |
453 | - if ($GLOBALS['_xh']['vt']!='value') |
|
453 | + if ($GLOBALS['_xh']['vt'] != 'value') |
|
454 | 454 | { |
455 | 455 | //two data elements inside a value: an error occurred! |
456 | 456 | $GLOBALS['_xh']['isf'] = 2; |
@@ -468,10 +468,10 @@ discard block |
||
468 | 468 | $cur_val['php_class'] = $attrs['PHP_CLASS']; |
469 | 469 | } |
470 | 470 | $GLOBALS['_xh']['valuestack'][] = $cur_val; |
471 | - $GLOBALS['_xh']['vt']='data'; // be prepared for a data element next |
|
471 | + $GLOBALS['_xh']['vt'] = 'data'; // be prepared for a data element next |
|
472 | 472 | break; |
473 | 473 | case 'DATA': |
474 | - if ($GLOBALS['_xh']['vt']!='data') |
|
474 | + if ($GLOBALS['_xh']['vt'] != 'data') |
|
475 | 475 | { |
476 | 476 | //two data elements inside a value: an error occurred! |
477 | 477 | $GLOBALS['_xh']['isf'] = 2; |
@@ -486,31 +486,31 @@ discard block |
||
486 | 486 | case 'METHODNAME': |
487 | 487 | case 'NAME': |
488 | 488 | /// @todo we could check for 2 NAME elements inside a MEMBER element |
489 | - $GLOBALS['_xh']['ac']=''; |
|
489 | + $GLOBALS['_xh']['ac'] = ''; |
|
490 | 490 | break; |
491 | 491 | case 'FAULT': |
492 | - $GLOBALS['_xh']['isf']=1; |
|
492 | + $GLOBALS['_xh']['isf'] = 1; |
|
493 | 493 | break; |
494 | 494 | case 'MEMBER': |
495 | - $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name']=''; // set member name to null, in case we do not find in the xml later on |
|
495 | + $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = ''; // set member name to null, in case we do not find in the xml later on |
|
496 | 496 | //$GLOBALS['_xh']['ac']=''; |
497 | 497 | // Drop trough intentionally |
498 | 498 | case 'PARAM': |
499 | 499 | // clear value type, so we can check later if no value has been passed for this param/member |
500 | - $GLOBALS['_xh']['vt']=null; |
|
500 | + $GLOBALS['_xh']['vt'] = null; |
|
501 | 501 | break; |
502 | 502 | case 'NIL': |
503 | 503 | case 'EX:NIL': |
504 | 504 | if ($GLOBALS['xmlrpc_null_extension']) |
505 | 505 | { |
506 | - if ($GLOBALS['_xh']['vt']!='value') |
|
506 | + if ($GLOBALS['_xh']['vt'] != 'value') |
|
507 | 507 | { |
508 | 508 | //two data elements inside a value: an error occurred! |
509 | 509 | $GLOBALS['_xh']['isf'] = 2; |
510 | 510 | $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; |
511 | 511 | return; |
512 | 512 | } |
513 | - $GLOBALS['_xh']['ac']=''; // reset the accumulator |
|
513 | + $GLOBALS['_xh']['ac'] = ''; // reset the accumulator |
|
514 | 514 | break; |
515 | 515 | } |
516 | 516 | // we do not support the <NIL/> extension, so |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | $GLOBALS['_xh']['stack'][] = $name; |
527 | 527 | |
528 | 528 | /// @todo optimization creep: move this inside the big switch() above |
529 | - if($name!='VALUE') |
|
529 | + if ($name != 'VALUE') |
|
530 | 530 | { |
531 | - $GLOBALS['_xh']['lv']=0; |
|
531 | + $GLOBALS['_xh']['lv'] = 0; |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | /// xml parser handler function for close element tags |
543 | 543 | function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true) |
544 | 544 | { |
545 | - if ($GLOBALS['_xh']['isf'] < 2) |
|
545 | + if ($GLOBALS['_xh']['isf']<2) |
|
546 | 546 | { |
547 | 547 | // push this element name from stack |
548 | 548 | // NB: if XML validates, correct opening/closing is guaranteed and |
@@ -550,14 +550,14 @@ discard block |
||
550 | 550 | // we also checked for proper nesting at start of elements... |
551 | 551 | $curr_elem = array_pop($GLOBALS['_xh']['stack']); |
552 | 552 | |
553 | - switch($name) |
|
553 | + switch ($name) |
|
554 | 554 | { |
555 | 555 | case 'VALUE': |
556 | 556 | // This if() detects if no scalar was inside <VALUE></VALUE> |
557 | - if ($GLOBALS['_xh']['vt']=='value') |
|
557 | + if ($GLOBALS['_xh']['vt'] == 'value') |
|
558 | 558 | { |
559 | - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; |
|
560 | - $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString']; |
|
559 | + $GLOBALS['_xh']['value'] = $GLOBALS['_xh']['ac']; |
|
560 | + $GLOBALS['_xh']['vt'] = $GLOBALS['xmlrpcString']; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | if ($rebuild_xmlrpcvals) |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | // check if we are inside an array or struct: |
572 | 572 | // if value just built is inside an array, let's move it into array on the stack |
573 | 573 | $vscount = count($GLOBALS['_xh']['valuestack']); |
574 | - if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') |
|
574 | + if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type'] == 'ARRAY') |
|
575 | 575 | { |
576 | 576 | $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp; |
577 | 577 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | // check if we are inside an array or struct: |
593 | 593 | // if value just built is inside an array, let's move it into array on the stack |
594 | 594 | $vscount = count($GLOBALS['_xh']['valuestack']); |
595 | - if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') |
|
595 | + if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type'] == 'ARRAY') |
|
596 | 596 | { |
597 | 597 | $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value']; |
598 | 598 | } |
@@ -605,28 +605,28 @@ discard block |
||
605 | 605 | case 'DOUBLE': |
606 | 606 | case 'DATETIME.ISO8601': |
607 | 607 | case 'BASE64': |
608 | - $GLOBALS['_xh']['vt']=strtolower($name); |
|
608 | + $GLOBALS['_xh']['vt'] = strtolower($name); |
|
609 | 609 | /// @todo: optimization creep - remove the if/elseif cycle below |
610 | 610 | /// since the case() in which we are already did that |
611 | - if ($name=='STRING') |
|
611 | + if ($name == 'STRING') |
|
612 | 612 | { |
613 | - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; |
|
613 | + $GLOBALS['_xh']['value'] = $GLOBALS['_xh']['ac']; |
|
614 | 614 | } |
615 | - elseif ($name=='DATETIME.ISO8601') |
|
615 | + elseif ($name == 'DATETIME.ISO8601') |
|
616 | 616 | { |
617 | 617 | if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac'])) |
618 | 618 | { |
619 | 619 | error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']); |
620 | 620 | } |
621 | - $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime']; |
|
622 | - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; |
|
621 | + $GLOBALS['_xh']['vt'] = $GLOBALS['xmlrpcDateTime']; |
|
622 | + $GLOBALS['_xh']['value'] = $GLOBALS['_xh']['ac']; |
|
623 | 623 | } |
624 | - elseif ($name=='BASE64') |
|
624 | + elseif ($name == 'BASE64') |
|
625 | 625 | { |
626 | 626 | /// @todo check for failure of base64 decoding / catch warnings |
627 | - $GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']); |
|
627 | + $GLOBALS['_xh']['value'] = base64_decode($GLOBALS['_xh']['ac']); |
|
628 | 628 | } |
629 | - elseif ($name=='BOOLEAN') |
|
629 | + elseif ($name == 'BOOLEAN') |
|
630 | 630 | { |
631 | 631 | // special case here: we translate boolean 1 or 0 into PHP |
632 | 632 | // constants true or false. |
@@ -634,19 +634,19 @@ discard block |
||
634 | 634 | // spec never mentions them (see eg. Blogger api docs) |
635 | 635 | // NB: this simple checks helps a lot sanitizing input, ie no |
636 | 636 | // security problems around here |
637 | - if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0) |
|
637 | + if ($GLOBALS['_xh']['ac'] == '1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0) |
|
638 | 638 | { |
639 | - $GLOBALS['_xh']['value']=true; |
|
639 | + $GLOBALS['_xh']['value'] = true; |
|
640 | 640 | } |
641 | 641 | else |
642 | 642 | { |
643 | 643 | // log if receiveing something strange, even though we set the value to false anyway |
644 | - if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0) |
|
644 | + if ($GLOBALS['_xh']['ac'] != '0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0) |
|
645 | 645 | error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']); |
646 | - $GLOBALS['_xh']['value']=false; |
|
646 | + $GLOBALS['_xh']['value'] = false; |
|
647 | 647 | } |
648 | 648 | } |
649 | - elseif ($name=='DOUBLE') |
|
649 | + elseif ($name == 'DOUBLE') |
|
650 | 650 | { |
651 | 651 | // we have a DOUBLE |
652 | 652 | // we must check that only 0123456789-.<space> are characters here |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | { |
656 | 656 | /// @todo: find a better way of throwing an error than this! |
657 | 657 | error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']); |
658 | - $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; |
|
658 | + $GLOBALS['_xh']['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
|
659 | 659 | } |
660 | 660 | else |
661 | 661 | { |
662 | 662 | // it's ok, add it on |
663 | - $GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac']; |
|
663 | + $GLOBALS['_xh']['value'] = (double) $GLOBALS['_xh']['ac']; |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | else |
@@ -671,16 +671,16 @@ discard block |
||
671 | 671 | { |
672 | 672 | /// @todo find a better way of throwing an error than this! |
673 | 673 | error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']); |
674 | - $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; |
|
674 | + $GLOBALS['_xh']['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
|
675 | 675 | } |
676 | 676 | else |
677 | 677 | { |
678 | 678 | // it's ok, add it on |
679 | - $GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac']; |
|
679 | + $GLOBALS['_xh']['value'] = (int) $GLOBALS['_xh']['ac']; |
|
680 | 680 | } |
681 | 681 | } |
682 | 682 | //$GLOBALS['_xh']['ac']=''; // is this necessary? |
683 | - $GLOBALS['_xh']['lv']=3; // indicate we've found a value |
|
683 | + $GLOBALS['_xh']['lv'] = 3; // indicate we've found a value |
|
684 | 684 | break; |
685 | 685 | case 'NAME': |
686 | 686 | $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = $GLOBALS['_xh']['ac']; |
@@ -698,14 +698,14 @@ discard block |
||
698 | 698 | break; |
699 | 699 | case 'DATA': |
700 | 700 | //$GLOBALS['_xh']['ac']=''; // is this necessary? |
701 | - $GLOBALS['_xh']['vt']=null; // reset this to check for 2 data elements in a row - even if they're empty |
|
701 | + $GLOBALS['_xh']['vt'] = null; // reset this to check for 2 data elements in a row - even if they're empty |
|
702 | 702 | break; |
703 | 703 | case 'STRUCT': |
704 | 704 | case 'ARRAY': |
705 | 705 | // fetch out of stack array of values, and promote it to current value |
706 | 706 | $curr_val = array_pop($GLOBALS['_xh']['valuestack']); |
707 | 707 | $GLOBALS['_xh']['value'] = $curr_val['values']; |
708 | - $GLOBALS['_xh']['vt']=strtolower($name); |
|
708 | + $GLOBALS['_xh']['vt'] = strtolower($name); |
|
709 | 709 | if (isset($curr_val['php_class'])) |
710 | 710 | { |
711 | 711 | $GLOBALS['_xh']['php_class'] = $curr_val['php_class']; |
@@ -716,22 +716,22 @@ discard block |
||
716 | 716 | // unless no VALUE was found |
717 | 717 | if ($GLOBALS['_xh']['vt']) |
718 | 718 | { |
719 | - $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value']; |
|
720 | - $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt']; |
|
719 | + $GLOBALS['_xh']['params'][] = $GLOBALS['_xh']['value']; |
|
720 | + $GLOBALS['_xh']['pt'][] = $GLOBALS['_xh']['vt']; |
|
721 | 721 | } |
722 | 722 | else |
723 | 723 | error_log('XML-RPC: missing VALUE inside PARAM in received xml'); |
724 | 724 | break; |
725 | 725 | case 'METHODNAME': |
726 | - $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']); |
|
726 | + $GLOBALS['_xh']['method'] = preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']); |
|
727 | 727 | break; |
728 | 728 | case 'NIL': |
729 | 729 | case 'EX:NIL': |
730 | 730 | if ($GLOBALS['xmlrpc_null_extension']) |
731 | 731 | { |
732 | - $GLOBALS['_xh']['vt']='null'; |
|
733 | - $GLOBALS['_xh']['value']=null; |
|
734 | - $GLOBALS['_xh']['lv']=3; |
|
732 | + $GLOBALS['_xh']['vt'] = 'null'; |
|
733 | + $GLOBALS['_xh']['value'] = null; |
|
734 | + $GLOBALS['_xh']['lv'] = 3; |
|
735 | 735 | break; |
736 | 736 | } |
737 | 737 | // drop through intentionally if nil extension not enabled |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | function xmlrpc_cd($parser, $data) |
759 | 759 | { |
760 | 760 | // skip processing if xml fault already detected |
761 | - if ($GLOBALS['_xh']['isf'] < 2) |
|
761 | + if ($GLOBALS['_xh']['isf']<2) |
|
762 | 762 | { |
763 | 763 | // "lookforvalue==3" means that we've found an entire value |
764 | 764 | // and should discard any further character data |
765 | - if($GLOBALS['_xh']['lv']!=3) |
|
765 | + if ($GLOBALS['_xh']['lv'] != 3) |
|
766 | 766 | { |
767 | 767 | // G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2 |
768 | 768 | //if($GLOBALS['_xh']['lv']==1) |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | //{ |
777 | 777 | // $GLOBALS['_xh']['ac'] = ''; |
778 | 778 | //} |
779 | - $GLOBALS['_xh']['ac'].=$data; |
|
779 | + $GLOBALS['_xh']['ac'] .= $data; |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | } |
@@ -786,16 +786,16 @@ discard block |
||
786 | 786 | function xmlrpc_dh($parser, $data) |
787 | 787 | { |
788 | 788 | // skip processing if xml fault already detected |
789 | - if ($GLOBALS['_xh']['isf'] < 2) |
|
789 | + if ($GLOBALS['_xh']['isf']<2) |
|
790 | 790 | { |
791 | - if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') |
|
791 | + if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') |
|
792 | 792 | { |
793 | 793 | // G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2 |
794 | 794 | //if($GLOBALS['_xh']['lv']==1) |
795 | 795 | //{ |
796 | 796 | // $GLOBALS['_xh']['lv']=2; |
797 | 797 | //} |
798 | - $GLOBALS['_xh']['ac'].=$data; |
|
798 | + $GLOBALS['_xh']['ac'] .= $data; |
|
799 | 799 | } |
800 | 800 | } |
801 | 801 | return true; |
@@ -805,30 +805,30 @@ discard block |
||
805 | 805 | { |
806 | 806 | var $path; |
807 | 807 | var $server; |
808 | - var $port=0; |
|
809 | - var $method='http'; |
|
808 | + var $port = 0; |
|
809 | + var $method = 'http'; |
|
810 | 810 | var $errno; |
811 | 811 | var $errstr; |
812 | - var $debug=0; |
|
813 | - var $username=''; |
|
814 | - var $password=''; |
|
815 | - var $authtype=1; |
|
816 | - var $cert=''; |
|
817 | - var $certpass=''; |
|
818 | - var $cacert=''; |
|
819 | - var $cacertdir=''; |
|
820 | - var $key=''; |
|
821 | - var $keypass=''; |
|
822 | - var $verifypeer=true; |
|
823 | - var $verifyhost=1; |
|
824 | - var $no_multicall=false; |
|
825 | - var $proxy=''; |
|
826 | - var $proxyport=0; |
|
827 | - var $proxy_user=''; |
|
828 | - var $proxy_pass=''; |
|
829 | - var $proxy_authtype=1; |
|
830 | - var $cookies=array(); |
|
831 | - var $extracurlopts=array(); |
|
812 | + var $debug = 0; |
|
813 | + var $username = ''; |
|
814 | + var $password = ''; |
|
815 | + var $authtype = 1; |
|
816 | + var $cert = ''; |
|
817 | + var $certpass = ''; |
|
818 | + var $cacert = ''; |
|
819 | + var $cacertdir = ''; |
|
820 | + var $key = ''; |
|
821 | + var $keypass = ''; |
|
822 | + var $verifypeer = true; |
|
823 | + var $verifyhost = 1; |
|
824 | + var $no_multicall = false; |
|
825 | + var $proxy = ''; |
|
826 | + var $proxyport = 0; |
|
827 | + var $proxy_user = ''; |
|
828 | + var $proxy_pass = ''; |
|
829 | + var $proxy_authtype = 1; |
|
830 | + var $cookies = array(); |
|
831 | + var $extracurlopts = array(); |
|
832 | 832 | |
833 | 833 | /** |
834 | 834 | * List of http compression methods accepted by the client for responses. |
@@ -872,59 +872,59 @@ discard block |
||
872 | 872 | * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used |
873 | 873 | * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed |
874 | 874 | */ |
875 | - function __construct($path, $server='', $port='', $method='') |
|
875 | + function __construct($path, $server = '', $port = '', $method = '') |
|
876 | 876 | { |
877 | 877 | // allow user to specify all params in $path |
878 | - if($server == '' and $port == '' and $method == '') |
|
878 | + if ($server == '' and $port == '' and $method == '') |
|
879 | 879 | { |
880 | 880 | $parts = parse_url($path); |
881 | 881 | $server = $parts['host']; |
882 | 882 | $path = isset($parts['path']) ? $parts['path'] : ''; |
883 | - if(isset($parts['query'])) |
|
883 | + if (isset($parts['query'])) |
|
884 | 884 | { |
885 | 885 | $path .= '?'.$parts['query']; |
886 | 886 | } |
887 | - if(isset($parts['fragment'])) |
|
887 | + if (isset($parts['fragment'])) |
|
888 | 888 | { |
889 | 889 | $path .= '#'.$parts['fragment']; |
890 | 890 | } |
891 | - if(isset($parts['port'])) |
|
891 | + if (isset($parts['port'])) |
|
892 | 892 | { |
893 | 893 | $port = $parts['port']; |
894 | 894 | } |
895 | - if(isset($parts['scheme'])) |
|
895 | + if (isset($parts['scheme'])) |
|
896 | 896 | { |
897 | 897 | $method = $parts['scheme']; |
898 | 898 | } |
899 | - if(isset($parts['user'])) |
|
899 | + if (isset($parts['user'])) |
|
900 | 900 | { |
901 | 901 | $this->username = $parts['user']; |
902 | 902 | } |
903 | - if(isset($parts['pass'])) |
|
903 | + if (isset($parts['pass'])) |
|
904 | 904 | { |
905 | 905 | $this->password = $parts['pass']; |
906 | 906 | } |
907 | 907 | } |
908 | - if($path == '' || $path[0] != '/') |
|
908 | + if ($path == '' || $path[0] != '/') |
|
909 | 909 | { |
910 | - $this->path='/'.$path; |
|
910 | + $this->path = '/'.$path; |
|
911 | 911 | } |
912 | 912 | else |
913 | 913 | { |
914 | - $this->path=$path; |
|
914 | + $this->path = $path; |
|
915 | 915 | } |
916 | - $this->server=$server; |
|
917 | - if($port != '') |
|
916 | + $this->server = $server; |
|
917 | + if ($port != '') |
|
918 | 918 | { |
919 | - $this->port=$port; |
|
919 | + $this->port = $port; |
|
920 | 920 | } |
921 | - if($method != '') |
|
921 | + if ($method != '') |
|
922 | 922 | { |
923 | - $this->method=$method; |
|
923 | + $this->method = $method; |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | // if ZLIB is enabled, let the client by default accept compressed responses |
927 | - if(function_exists('gzinflate') || ( |
|
927 | + if (function_exists('gzinflate') || ( |
|
928 | 928 | function_exists('curl_init') && (($info = curl_version()) && |
929 | 929 | ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) |
930 | 930 | )) |
@@ -939,13 +939,13 @@ discard block |
||
939 | 939 | $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); |
940 | 940 | |
941 | 941 | // initialize user_agent string |
942 | - $this->user_agent = $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion']; |
|
942 | + $this->user_agent = $GLOBALS['xmlrpcName'].' '.$GLOBALS['xmlrpcVersion']; |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | /** |
946 | 946 | * @deprecated |
947 | 947 | */ |
948 | - function xmlrpc_client($path, $server='', $port='', $method='') |
|
948 | + function xmlrpc_client($path, $server = '', $port = '', $method = '') |
|
949 | 949 | { |
950 | 950 | self::__construct($path, $server, $port, $method); |
951 | 951 | } |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | */ |
958 | 958 | function setDebug($in) |
959 | 959 | { |
960 | - $this->debug=$in; |
|
960 | + $this->debug = $in; |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | /** |
@@ -967,11 +967,11 @@ discard block |
||
967 | 967 | * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth) |
968 | 968 | * @access public |
969 | 969 | */ |
970 | - function setCredentials($u, $p, $t=1) |
|
970 | + function setCredentials($u, $p, $t = 1) |
|
971 | 971 | { |
972 | - $this->username=$u; |
|
973 | - $this->password=$p; |
|
974 | - $this->authtype=$t; |
|
972 | + $this->username = $u; |
|
973 | + $this->password = $p; |
|
974 | + $this->authtype = $t; |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | /** |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false |
994 | 994 | * @access public |
995 | 995 | */ |
996 | - function setCaCertificate($cacert, $is_dir=false) |
|
996 | + function setCaCertificate($cacert, $is_dir = false) |
|
997 | 997 | { |
998 | 998 | if ($is_dir) |
999 | 999 | { |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | if ($compmethod == 'any') |
1071 | 1071 | $this->accepted_compression = array('gzip', 'deflate'); |
1072 | 1072 | else |
1073 | - if ($compmethod == false ) |
|
1073 | + if ($compmethod == false) |
|
1074 | 1074 | $this->accepted_compression = array(); |
1075 | 1075 | else |
1076 | 1076 | $this->accepted_compression = array($compmethod); |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | * |
1102 | 1102 | * @todo check correctness of urlencoding cookie value (copied from php way of doing it...) |
1103 | 1103 | */ |
1104 | - function setCookie($name, $value='', $path='', $domain='', $port=null) |
|
1104 | + function setCookie($name, $value = '', $path = '', $domain = '', $port = null) |
|
1105 | 1105 | { |
1106 | 1106 | $this->cookies[$name]['value'] = urlencode($value); |
1107 | 1107 | if ($path || $domain || $port) |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | * It allows eg. to bind client to a specific IP interface / address |
1123 | 1123 | * @param array $options |
1124 | 1124 | */ |
1125 | - function SetCurlOptions( $options ) |
|
1125 | + function SetCurlOptions($options) |
|
1126 | 1126 | { |
1127 | 1127 | $this->extracurlopts = $options; |
1128 | 1128 | } |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | * Set user-agent string that will be used by this client instance |
1132 | 1132 | * in http headers sent to the server |
1133 | 1133 | */ |
1134 | - function SetUserAgent( $agentstring ) |
|
1134 | + function SetUserAgent($agentstring) |
|
1135 | 1135 | { |
1136 | 1136 | $this->user_agent = $agentstring; |
1137 | 1137 | } |
@@ -1144,22 +1144,22 @@ discard block |
||
1144 | 1144 | * @return xmlrpcresp |
1145 | 1145 | * @access public |
1146 | 1146 | */ |
1147 | - function& send($msg, $timeout=0, $method='') |
|
1147 | + function& send($msg, $timeout = 0, $method = '') |
|
1148 | 1148 | { |
1149 | 1149 | // if user deos not specify http protocol, use native method of this client |
1150 | 1150 | // (i.e. method set during call to constructor) |
1151 | - if($method == '') |
|
1151 | + if ($method == '') |
|
1152 | 1152 | { |
1153 | 1153 | $method = $this->method; |
1154 | 1154 | } |
1155 | 1155 | |
1156 | - if(is_array($msg)) |
|
1156 | + if (is_array($msg)) |
|
1157 | 1157 | { |
1158 | 1158 | // $msg is an array of xmlrpcmsg's |
1159 | 1159 | $r = $this->multicall($msg, $timeout, $method); |
1160 | 1160 | return $r; |
1161 | 1161 | } |
1162 | - elseif(is_string($msg)) |
|
1162 | + elseif (is_string($msg)) |
|
1163 | 1163 | { |
1164 | 1164 | $n = new xmlrpcmsg(''); |
1165 | 1165 | $n->payload = $msg; |
@@ -1167,11 +1167,11 @@ discard block |
||
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | // where msg is an xmlrpcmsg |
1170 | - $msg->debug=$this->debug; |
|
1170 | + $msg->debug = $this->debug; |
|
1171 | 1171 | |
1172 | - if($method == 'https') |
|
1172 | + if ($method == 'https') |
|
1173 | 1173 | { |
1174 | - $r =& $this->sendPayloadHTTPS( |
|
1174 | + $r = & $this->sendPayloadHTTPS( |
|
1175 | 1175 | $msg, |
1176 | 1176 | $this->server, |
1177 | 1177 | $this->port, |
@@ -1193,9 +1193,9 @@ discard block |
||
1193 | 1193 | $this->keypass |
1194 | 1194 | ); |
1195 | 1195 | } |
1196 | - elseif($method == 'http11') |
|
1196 | + elseif ($method == 'http11') |
|
1197 | 1197 | { |
1198 | - $r =& $this->sendPayloadCURL( |
|
1198 | + $r = & $this->sendPayloadCURL( |
|
1199 | 1199 | $msg, |
1200 | 1200 | $this->server, |
1201 | 1201 | $this->port, |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | } |
1219 | 1219 | else |
1220 | 1220 | { |
1221 | - $r =& $this->sendPayloadHTTP10( |
|
1221 | + $r = & $this->sendPayloadHTTP10( |
|
1222 | 1222 | $msg, |
1223 | 1223 | $this->server, |
1224 | 1224 | $this->port, |
@@ -1240,29 +1240,29 @@ discard block |
||
1240 | 1240 | /** |
1241 | 1241 | * @access private |
1242 | 1242 | */ |
1243 | - function &sendPayloadHTTP10($msg, $server, $port, $timeout=0, |
|
1244 | - $username='', $password='', $authtype=1, $proxyhost='', |
|
1245 | - $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1) |
|
1243 | + function &sendPayloadHTTP10($msg, $server, $port, $timeout = 0, |
|
1244 | + $username = '', $password = '', $authtype = 1, $proxyhost = '', |
|
1245 | + $proxyport = 0, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1) |
|
1246 | 1246 | { |
1247 | - if($port==0) |
|
1247 | + if ($port == 0) |
|
1248 | 1248 | { |
1249 | - $port=80; |
|
1249 | + $port = 80; |
|
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | // Only create the payload if it was not created previously |
1253 | - if(empty($msg->payload)) |
|
1253 | + if (empty($msg->payload)) |
|
1254 | 1254 | { |
1255 | 1255 | $msg->createPayload($this->request_charset_encoding); |
1256 | 1256 | } |
1257 | 1257 | |
1258 | 1258 | $payload = $msg->payload; |
1259 | 1259 | // Deflate request body and set appropriate request headers |
1260 | - if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) |
|
1260 | + if (function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) |
|
1261 | 1261 | { |
1262 | - if($this->request_compression == 'gzip') |
|
1262 | + if ($this->request_compression == 'gzip') |
|
1263 | 1263 | { |
1264 | 1264 | $a = @gzencode($payload); |
1265 | - if($a) |
|
1265 | + if ($a) |
|
1266 | 1266 | { |
1267 | 1267 | $payload = $a; |
1268 | 1268 | $encoding_hdr = "Content-Encoding: gzip\r\n"; |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | else |
1272 | 1272 | { |
1273 | 1273 | $a = @gzcompress($payload); |
1274 | - if($a) |
|
1274 | + if ($a) |
|
1275 | 1275 | { |
1276 | 1276 | $payload = $a; |
1277 | 1277 | $encoding_hdr = "Content-Encoding: deflate\r\n"; |
@@ -1284,10 +1284,10 @@ discard block |
||
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | // thanks to Grant Rauscher <[email protected]> for this |
1287 | - $credentials=''; |
|
1288 | - if($username!='') |
|
1287 | + $credentials = ''; |
|
1288 | + if ($username != '') |
|
1289 | 1289 | { |
1290 | - $credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; |
|
1290 | + $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n"; |
|
1291 | 1291 | if ($authtype != 1) |
1292 | 1292 | { |
1293 | 1293 | error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0'); |
@@ -1295,28 +1295,28 @@ discard block |
||
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | $accepted_encoding = ''; |
1298 | - if(is_array($this->accepted_compression) && count($this->accepted_compression)) |
|
1298 | + if (is_array($this->accepted_compression) && count($this->accepted_compression)) |
|
1299 | 1299 | { |
1300 | - $accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; |
|
1300 | + $accepted_encoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n"; |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | $proxy_credentials = ''; |
1304 | - if($proxyhost) |
|
1304 | + if ($proxyhost) |
|
1305 | 1305 | { |
1306 | - if($proxyport == 0) |
|
1306 | + if ($proxyport == 0) |
|
1307 | 1307 | { |
1308 | 1308 | $proxyport = 8080; |
1309 | 1309 | } |
1310 | 1310 | $connectserver = $proxyhost; |
1311 | 1311 | $connectport = $proxyport; |
1312 | 1312 | $uri = 'http://'.$server.':'.$port.$this->path; |
1313 | - if($proxyusername != '') |
|
1313 | + if ($proxyusername != '') |
|
1314 | 1314 | { |
1315 | 1315 | if ($proxyauthtype != 1) |
1316 | 1316 | { |
1317 | 1317 | error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
1318 | 1318 | } |
1319 | - $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n"; |
|
1319 | + $proxy_credentials = 'Proxy-Authorization: Basic '.base64_encode($proxyusername.':'.$proxypassword)."\r\n"; |
|
1320 | 1320 | } |
1321 | 1321 | } |
1322 | 1322 | else |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | |
1329 | 1329 | // Cookie generation, as per rfc2965 (version 1 cookies) or |
1330 | 1330 | // netscape's rules (version 0 cookies) |
1331 | - $cookieheader=''; |
|
1331 | + $cookieheader = ''; |
|
1332 | 1332 | if (count($this->cookies)) |
1333 | 1333 | { |
1334 | 1334 | $version = ''; |
@@ -1336,73 +1336,73 @@ discard block |
||
1336 | 1336 | { |
1337 | 1337 | if ($cookie['version']) |
1338 | 1338 | { |
1339 | - $version = ' $Version="' . $cookie['version'] . '";'; |
|
1340 | - $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";'; |
|
1339 | + $version = ' $Version="'.$cookie['version'].'";'; |
|
1340 | + $cookieheader .= ' '.$name.'="'.$cookie['value'].'";'; |
|
1341 | 1341 | if ($cookie['path']) |
1342 | - $cookieheader .= ' $Path="' . $cookie['path'] . '";'; |
|
1342 | + $cookieheader .= ' $Path="'.$cookie['path'].'";'; |
|
1343 | 1343 | if ($cookie['domain']) |
1344 | - $cookieheader .= ' $Domain="' . $cookie['domain'] . '";'; |
|
1344 | + $cookieheader .= ' $Domain="'.$cookie['domain'].'";'; |
|
1345 | 1345 | if ($cookie['port']) |
1346 | - $cookieheader .= ' $Port="' . $cookie['port'] . '";'; |
|
1346 | + $cookieheader .= ' $Port="'.$cookie['port'].'";'; |
|
1347 | 1347 | } |
1348 | 1348 | else |
1349 | 1349 | { |
1350 | - $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";"; |
|
1350 | + $cookieheader .= ' '.$name.'='.$cookie['value'].";"; |
|
1351 | 1351 | } |
1352 | 1352 | } |
1353 | - $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n"; |
|
1353 | + $cookieheader = 'Cookie:'.$version.substr($cookieheader, 0, -1)."\r\n"; |
|
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | // omit port if 80 |
1357 | - $port = ($port == 80) ? '' : (':' . $port); |
|
1358 | - |
|
1359 | - $op= 'POST ' . $uri. " HTTP/1.0\r\n" . |
|
1360 | - 'User-Agent: ' . $this->user_agent . "\r\n" . |
|
1361 | - 'Host: '. $server . $port . "\r\n" . |
|
1362 | - $credentials . |
|
1363 | - $proxy_credentials . |
|
1364 | - $accepted_encoding . |
|
1365 | - $encoding_hdr . |
|
1366 | - 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . |
|
1367 | - $cookieheader . |
|
1368 | - 'Content-Type: ' . $msg->content_type . "\r\nContent-Length: " . |
|
1369 | - strlen($payload) . "\r\n\r\n" . |
|
1357 | + $port = ($port == 80) ? '' : (':'.$port); |
|
1358 | + |
|
1359 | + $op = 'POST '.$uri." HTTP/1.0\r\n". |
|
1360 | + 'User-Agent: '.$this->user_agent."\r\n". |
|
1361 | + 'Host: '.$server.$port."\r\n". |
|
1362 | + $credentials. |
|
1363 | + $proxy_credentials. |
|
1364 | + $accepted_encoding. |
|
1365 | + $encoding_hdr. |
|
1366 | + 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)."\r\n". |
|
1367 | + $cookieheader. |
|
1368 | + 'Content-Type: '.$msg->content_type."\r\nContent-Length: ". |
|
1369 | + strlen($payload)."\r\n\r\n". |
|
1370 | 1370 | $payload; |
1371 | 1371 | |
1372 | - if($this->debug > 1) |
|
1372 | + if ($this->debug>1) |
|
1373 | 1373 | { |
1374 | - print "<PRE>\n---SENDING---\n" . htmlentities($op) . "\n---END---\n</PRE>"; |
|
1374 | + print "<PRE>\n---SENDING---\n".htmlentities($op)."\n---END---\n</PRE>"; |
|
1375 | 1375 | // let the client see this now in case http times out... |
1376 | 1376 | flush(); |
1377 | 1377 | } |
1378 | 1378 | |
1379 | - if($timeout>0) |
|
1379 | + if ($timeout>0) |
|
1380 | 1380 | { |
1381 | - $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout); |
|
1381 | + $fp = @fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout); |
|
1382 | 1382 | } |
1383 | 1383 | else |
1384 | 1384 | { |
1385 | - $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr); |
|
1385 | + $fp = @fsockopen($connectserver, $connectport, $this->errno, $this->errstr); |
|
1386 | 1386 | } |
1387 | - if($fp) |
|
1387 | + if ($fp) |
|
1388 | 1388 | { |
1389 | - if($timeout>0 && function_exists('stream_set_timeout')) |
|
1389 | + if ($timeout>0 && function_exists('stream_set_timeout')) |
|
1390 | 1390 | { |
1391 | 1391 | stream_set_timeout($fp, $timeout); |
1392 | 1392 | } |
1393 | 1393 | } |
1394 | 1394 | else |
1395 | 1395 | { |
1396 | - $this->errstr='Connect error: '.$this->errstr; |
|
1397 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')'); |
|
1396 | + $this->errstr = 'Connect error: '.$this->errstr; |
|
1397 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr.' ('.$this->errno.')'); |
|
1398 | 1398 | return $r; |
1399 | 1399 | } |
1400 | 1400 | |
1401 | - if(!fputs($fp, $op, strlen($op))) |
|
1401 | + if (!fputs($fp, $op, strlen($op))) |
|
1402 | 1402 | { |
1403 | 1403 | fclose($fp); |
1404 | - $this->errstr='Write error'; |
|
1405 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr); |
|
1404 | + $this->errstr = 'Write error'; |
|
1405 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr); |
|
1406 | 1406 | return $r; |
1407 | 1407 | } |
1408 | 1408 | else |
@@ -1412,15 +1412,15 @@ discard block |
||
1412 | 1412 | } |
1413 | 1413 | // G. Giunta 2005/10/24: close socket before parsing. |
1414 | 1414 | // should yield slightly better execution times, and make easier recursive calls (e.g. to follow http redirects) |
1415 | - $ipd=''; |
|
1415 | + $ipd = ''; |
|
1416 | 1416 | do |
1417 | 1417 | { |
1418 | 1418 | // shall we check for $data === FALSE? |
1419 | 1419 | // as per the manual, it signals an error |
1420 | - $ipd.=fread($fp, 32768); |
|
1421 | - } while(!feof($fp)); |
|
1420 | + $ipd .= fread($fp, 32768); |
|
1421 | + } while (!feof($fp)); |
|
1422 | 1422 | fclose($fp); |
1423 | - $r =& $msg->parseResponse($ipd, false, $this->return_type); |
|
1423 | + $r = & $msg->parseResponse($ipd, false, $this->return_type); |
|
1424 | 1424 | return $r; |
1425 | 1425 | |
1426 | 1426 | } |
@@ -1428,12 +1428,12 @@ discard block |
||
1428 | 1428 | /** |
1429 | 1429 | * @access private |
1430 | 1430 | */ |
1431 | - function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='', |
|
1432 | - $password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='', |
|
1433 | - $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, |
|
1434 | - $keepalive=false, $key='', $keypass='') |
|
1431 | + function &sendPayloadHTTPS($msg, $server, $port, $timeout = 0, $username = '', |
|
1432 | + $password = '', $authtype = 1, $cert = '', $certpass = '', $cacert = '', $cacertdir = '', |
|
1433 | + $proxyhost = '', $proxyport = 0, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1, |
|
1434 | + $keepalive = false, $key = '', $keypass = '') |
|
1435 | 1435 | { |
1436 | - $r =& $this->sendPayloadCURL($msg, $server, $port, $timeout, $username, |
|
1436 | + $r = & $this->sendPayloadCURL($msg, $server, $port, $timeout, $username, |
|
1437 | 1437 | $password, $authtype, $cert, $certpass, $cacert, $cacertdir, $proxyhost, $proxyport, |
1438 | 1438 | $proxyusername, $proxypassword, $proxyauthtype, 'https', $keepalive, $key, $keypass); |
1439 | 1439 | return $r; |
@@ -1445,31 +1445,31 @@ discard block |
||
1445 | 1445 | * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers! |
1446 | 1446 | * @access private |
1447 | 1447 | */ |
1448 | - function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='', |
|
1449 | - $password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='', |
|
1450 | - $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https', |
|
1451 | - $keepalive=false, $key='', $keypass='') |
|
1448 | + function &sendPayloadCURL($msg, $server, $port, $timeout = 0, $username = '', |
|
1449 | + $password = '', $authtype = 1, $cert = '', $certpass = '', $cacert = '', $cacertdir = '', |
|
1450 | + $proxyhost = '', $proxyport = 0, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1, $method = 'https', |
|
1451 | + $keepalive = false, $key = '', $keypass = '') |
|
1452 | 1452 | { |
1453 | - if(!function_exists('curl_init')) |
|
1453 | + if (!function_exists('curl_init')) |
|
1454 | 1454 | { |
1455 | - $this->errstr='CURL unavailable on this install'; |
|
1456 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']); |
|
1455 | + $this->errstr = 'CURL unavailable on this install'; |
|
1456 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']); |
|
1457 | 1457 | return $r; |
1458 | 1458 | } |
1459 | - if($method == 'https') |
|
1459 | + if ($method == 'https') |
|
1460 | 1460 | { |
1461 | - if(($info = curl_version()) && |
|
1461 | + if (($info = curl_version()) && |
|
1462 | 1462 | ((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version'])))) |
1463 | 1463 | { |
1464 | - $this->errstr='SSL unavailable on this install'; |
|
1465 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']); |
|
1464 | + $this->errstr = 'SSL unavailable on this install'; |
|
1465 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']); |
|
1466 | 1466 | return $r; |
1467 | 1467 | } |
1468 | 1468 | } |
1469 | 1469 | |
1470 | - if($port == 0) |
|
1470 | + if ($port == 0) |
|
1471 | 1471 | { |
1472 | - if($method == 'http') |
|
1472 | + if ($method == 'http') |
|
1473 | 1473 | { |
1474 | 1474 | $port = 80; |
1475 | 1475 | } |
@@ -1480,19 +1480,19 @@ discard block |
||
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | // Only create the payload if it was not created previously |
1483 | - if(empty($msg->payload)) |
|
1483 | + if (empty($msg->payload)) |
|
1484 | 1484 | { |
1485 | 1485 | $msg->createPayload($this->request_charset_encoding); |
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | // Deflate request body and set appropriate request headers |
1489 | 1489 | $payload = $msg->payload; |
1490 | - if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) |
|
1490 | + if (function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) |
|
1491 | 1491 | { |
1492 | - if($this->request_compression == 'gzip') |
|
1492 | + if ($this->request_compression == 'gzip') |
|
1493 | 1493 | { |
1494 | 1494 | $a = @gzencode($payload); |
1495 | - if($a) |
|
1495 | + if ($a) |
|
1496 | 1496 | { |
1497 | 1497 | $payload = $a; |
1498 | 1498 | $encoding_hdr = 'Content-Encoding: gzip'; |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | else |
1502 | 1502 | { |
1503 | 1503 | $a = @gzcompress($payload); |
1504 | - if($a) |
|
1504 | + if ($a) |
|
1505 | 1505 | { |
1506 | 1506 | $payload = $a; |
1507 | 1507 | $encoding_hdr = 'Content-Encoding: deflate'; |
@@ -1513,17 +1513,17 @@ discard block |
||
1513 | 1513 | $encoding_hdr = ''; |
1514 | 1514 | } |
1515 | 1515 | |
1516 | - if($this->debug > 1) |
|
1516 | + if ($this->debug>1) |
|
1517 | 1517 | { |
1518 | - print "<PRE>\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n</PRE>"; |
|
1518 | + print "<PRE>\n---SENDING---\n".htmlentities($payload)."\n---END---\n</PRE>"; |
|
1519 | 1519 | // let the client see this now in case http times out... |
1520 | 1520 | flush(); |
1521 | 1521 | } |
1522 | 1522 | |
1523 | - if(!$keepalive || !$this->xmlrpc_curl_handle) |
|
1523 | + if (!$keepalive || !$this->xmlrpc_curl_handle) |
|
1524 | 1524 | { |
1525 | - $curl = curl_init($method . '://' . $server . ':' . $port . $this->path); |
|
1526 | - if($keepalive) |
|
1525 | + $curl = curl_init($method.'://'.$server.':'.$port.$this->path); |
|
1526 | + if ($keepalive) |
|
1527 | 1527 | { |
1528 | 1528 | $this->xmlrpc_curl_handle = $curl; |
1529 | 1529 | } |
@@ -1536,7 +1536,7 @@ discard block |
||
1536 | 1536 | // results into variable |
1537 | 1537 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
1538 | 1538 | |
1539 | - if($this->debug) |
|
1539 | + if ($this->debug) |
|
1540 | 1540 | { |
1541 | 1541 | curl_setopt($curl, CURLOPT_VERBOSE, 1); |
1542 | 1542 | } |
@@ -1552,7 +1552,7 @@ discard block |
||
1552 | 1552 | // NB: if we set an empty string, CURL will add http header indicating |
1553 | 1553 | // ALL methods it is supporting. This is possibly a better option than |
1554 | 1554 | // letting the user tell what curl can / cannot do... |
1555 | - if(is_array($this->accepted_compression) && count($this->accepted_compression)) |
|
1555 | + if (is_array($this->accepted_compression) && count($this->accepted_compression)) |
|
1556 | 1556 | { |
1557 | 1557 | //curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression)); |
1558 | 1558 | // empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?) |
@@ -1564,26 +1564,26 @@ discard block |
||
1564 | 1564 | curl_setopt($curl, CURLOPT_ENCODING, ''); |
1565 | 1565 | } |
1566 | 1566 | // extra headers |
1567 | - $headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); |
|
1567 | + $headers = array('Content-Type: '.$msg->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)); |
|
1568 | 1568 | // if no keepalive is wanted, let the server know it in advance |
1569 | - if(!$keepalive) |
|
1569 | + if (!$keepalive) |
|
1570 | 1570 | { |
1571 | 1571 | $headers[] = 'Connection: close'; |
1572 | 1572 | } |
1573 | 1573 | // request compression header |
1574 | - if($encoding_hdr) |
|
1574 | + if ($encoding_hdr) |
|
1575 | 1575 | { |
1576 | 1576 | $headers[] = $encoding_hdr; |
1577 | 1577 | } |
1578 | 1578 | |
1579 | 1579 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
1580 | 1580 | // timeout is borked |
1581 | - if($timeout) |
|
1581 | + if ($timeout) |
|
1582 | 1582 | { |
1583 | - curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); |
|
1583 | + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1); |
|
1584 | 1584 | } |
1585 | 1585 | |
1586 | - if($username && $password) |
|
1586 | + if ($username && $password) |
|
1587 | 1587 | { |
1588 | 1588 | curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); |
1589 | 1589 | if (defined('CURLOPT_HTTPAUTH')) |
@@ -1596,43 +1596,43 @@ discard block |
||
1596 | 1596 | } |
1597 | 1597 | } |
1598 | 1598 | |
1599 | - if($method == 'https') |
|
1599 | + if ($method == 'https') |
|
1600 | 1600 | { |
1601 | 1601 | // set cert file |
1602 | - if($cert) |
|
1602 | + if ($cert) |
|
1603 | 1603 | { |
1604 | 1604 | curl_setopt($curl, CURLOPT_SSLCERT, $cert); |
1605 | 1605 | } |
1606 | 1606 | // set cert password |
1607 | - if($certpass) |
|
1607 | + if ($certpass) |
|
1608 | 1608 | { |
1609 | 1609 | curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certpass); |
1610 | 1610 | } |
1611 | 1611 | // whether to verify remote host's cert |
1612 | 1612 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer); |
1613 | 1613 | // set ca certificates file/dir |
1614 | - if($cacert) |
|
1614 | + if ($cacert) |
|
1615 | 1615 | { |
1616 | 1616 | curl_setopt($curl, CURLOPT_CAINFO, $cacert); |
1617 | 1617 | } |
1618 | - if($cacertdir) |
|
1618 | + if ($cacertdir) |
|
1619 | 1619 | { |
1620 | 1620 | curl_setopt($curl, CURLOPT_CAPATH, $cacertdir); |
1621 | 1621 | } |
1622 | 1622 | // set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?) |
1623 | - if($key) |
|
1623 | + if ($key) |
|
1624 | 1624 | { |
1625 | 1625 | curl_setopt($curl, CURLOPT_SSLKEY, $key); |
1626 | 1626 | } |
1627 | 1627 | // set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?) |
1628 | - if($keypass) |
|
1628 | + if ($keypass) |
|
1629 | 1629 | { |
1630 | 1630 | curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keypass); |
1631 | 1631 | } |
1632 | 1632 | |
1633 | 1633 | // Upgrade transparently to more stringent check for versions of php which do not support otherwise. |
1634 | 1634 | // Doing it in constructor would be cleaner; doing it here saves us a couple of function calls |
1635 | - if($this->verifyhost == 1 && $info = curl_version() && version_compare($info['version'], '7.28.1') >= 0) |
|
1635 | + if ($this->verifyhost == 1 && $info = curl_version() && version_compare($info['version'], '7.28.1')>=0) |
|
1636 | 1636 | { |
1637 | 1637 | $this->verifyhost = 2; |
1638 | 1638 | } |
@@ -1641,15 +1641,15 @@ discard block |
||
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | // proxy info |
1644 | - if($proxyhost) |
|
1644 | + if ($proxyhost) |
|
1645 | 1645 | { |
1646 | - if($proxyport == 0) |
|
1646 | + if ($proxyport == 0) |
|
1647 | 1647 | { |
1648 | 1648 | $proxyport = 8080; // NB: even for HTTPS, local connection is on port 8080 |
1649 | 1649 | } |
1650 | 1650 | curl_setopt($curl, CURLOPT_PROXY, $proxyhost.':'.$proxyport); |
1651 | 1651 | //curl_setopt($curl, CURLOPT_PROXYPORT,$proxyport); |
1652 | - if($proxyusername) |
|
1652 | + if ($proxyusername) |
|
1653 | 1653 | { |
1654 | 1654 | curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyusername.':'.$proxypassword); |
1655 | 1655 | if (defined('CURLOPT_PROXYAUTH')) |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | $cookieheader = ''; |
1672 | 1672 | foreach ($this->cookies as $name => $cookie) |
1673 | 1673 | { |
1674 | - $cookieheader .= $name . '=' . $cookie['value'] . '; '; |
|
1674 | + $cookieheader .= $name.'='.$cookie['value'].'; '; |
|
1675 | 1675 | } |
1676 | 1676 | curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2)); |
1677 | 1677 | } |
@@ -1683,40 +1683,40 @@ discard block |
||
1683 | 1683 | |
1684 | 1684 | $result = curl_exec($curl); |
1685 | 1685 | |
1686 | - if ($this->debug > 1) |
|
1686 | + if ($this->debug>1) |
|
1687 | 1687 | { |
1688 | 1688 | print "<PRE>\n---CURL INFO---\n"; |
1689 | - foreach(curl_getinfo($curl) as $name => $val) |
|
1689 | + foreach (curl_getinfo($curl) as $name => $val) |
|
1690 | 1690 | { |
1691 | 1691 | if (is_array($val)) |
1692 | 1692 | { |
1693 | 1693 | $val = implode("\n", $val); |
1694 | 1694 | } |
1695 | - print $name . ': ' . htmlentities($val) . "\n"; |
|
1695 | + print $name.': '.htmlentities($val)."\n"; |
|
1696 | 1696 | } |
1697 | 1697 | |
1698 | 1698 | print "---END---\n</PRE>"; |
1699 | 1699 | } |
1700 | 1700 | |
1701 | - if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'? |
|
1701 | + if (!$result) /// @todo we should use a better check here - what if we get back '' or '0'? |
|
1702 | 1702 | { |
1703 | - $this->errstr='no response'; |
|
1704 | - $resp=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl)); |
|
1703 | + $this->errstr = 'no response'; |
|
1704 | + $resp = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail'].': '.curl_error($curl)); |
|
1705 | 1705 | curl_close($curl); |
1706 | - if($keepalive) |
|
1706 | + if ($keepalive) |
|
1707 | 1707 | { |
1708 | 1708 | $this->xmlrpc_curl_handle = null; |
1709 | 1709 | } |
1710 | 1710 | } |
1711 | 1711 | else |
1712 | 1712 | { |
1713 | - if(!$keepalive) |
|
1713 | + if (!$keepalive) |
|
1714 | 1714 | { |
1715 | 1715 | curl_close($curl); |
1716 | 1716 | } |
1717 | - $resp =& $msg->parseResponse($result, true, $this->return_type); |
|
1717 | + $resp = & $msg->parseResponse($result, true, $this->return_type); |
|
1718 | 1718 | // if we got back a 302, we can not reuse the curl handle for later calls |
1719 | - if($resp->faultCode() == $GLOBALS['xmlrpcerr']['http_error'] && $keepalive) |
|
1719 | + if ($resp->faultCode() == $GLOBALS['xmlrpcerr']['http_error'] && $keepalive) |
|
1720 | 1720 | { |
1721 | 1721 | curl_close($curl); |
1722 | 1722 | $this->xmlrpc_curl_handle = null; |
@@ -1747,16 +1747,16 @@ discard block |
||
1747 | 1747 | * @return array |
1748 | 1748 | * @access public |
1749 | 1749 | */ |
1750 | - function multicall($msgs, $timeout=0, $method='', $fallback=true) |
|
1750 | + function multicall($msgs, $timeout = 0, $method = '', $fallback = true) |
|
1751 | 1751 | { |
1752 | 1752 | if ($method == '') |
1753 | 1753 | { |
1754 | 1754 | $method = $this->method; |
1755 | 1755 | } |
1756 | - if(!$this->no_multicall) |
|
1756 | + if (!$this->no_multicall) |
|
1757 | 1757 | { |
1758 | 1758 | $results = $this->_try_multicall($msgs, $timeout, $method); |
1759 | - if(is_array($results)) |
|
1759 | + if (is_array($results)) |
|
1760 | 1760 | { |
1761 | 1761 | // System.multicall succeeded |
1762 | 1762 | return $results; |
@@ -1795,9 +1795,9 @@ discard block |
||
1795 | 1795 | { |
1796 | 1796 | // system.multicall is (probably) unsupported by server: |
1797 | 1797 | // emulate multicall via multiple requests |
1798 | - foreach($msgs as $msg) |
|
1798 | + foreach ($msgs as $msg) |
|
1799 | 1799 | { |
1800 | - $results[] =& $this->send($msg, $timeout, $method); |
|
1800 | + $results[] = & $this->send($msg, $timeout, $method); |
|
1801 | 1801 | } |
1802 | 1802 | } |
1803 | 1803 | else |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | // user does NOT want to fallback on many single calls: |
1806 | 1806 | // since we should always return an array of responses, |
1807 | 1807 | // return an array with the same error repeated n times |
1808 | - foreach($msgs as $msg) |
|
1808 | + foreach ($msgs as $msg) |
|
1809 | 1809 | { |
1810 | 1810 | $results[] = $result; |
1811 | 1811 | } |
@@ -1823,12 +1823,12 @@ discard block |
||
1823 | 1823 | { |
1824 | 1824 | // Construct multicall message |
1825 | 1825 | $calls = array(); |
1826 | - foreach($msgs as $msg) |
|
1826 | + foreach ($msgs as $msg) |
|
1827 | 1827 | { |
1828 | - $call['methodName'] = new xmlrpcval($msg->method(),'string'); |
|
1828 | + $call['methodName'] = new xmlrpcval($msg->method(), 'string'); |
|
1829 | 1829 | $numParams = $msg->getNumParams(); |
1830 | 1830 | $params = array(); |
1831 | - for($i = 0; $i < $numParams; $i++) |
|
1831 | + for ($i = 0; $i<$numParams; $i++) |
|
1832 | 1832 | { |
1833 | 1833 | $params[$i] = $msg->getParam($i); |
1834 | 1834 | } |
@@ -1839,9 +1839,9 @@ discard block |
||
1839 | 1839 | $multicall->addParam(new xmlrpcval($calls, 'array')); |
1840 | 1840 | |
1841 | 1841 | // Attempt RPC call |
1842 | - $result =& $this->send($multicall, $timeout, $method); |
|
1842 | + $result = & $this->send($multicall, $timeout, $method); |
|
1843 | 1843 | |
1844 | - if($result->faultCode() != 0) |
|
1844 | + if ($result->faultCode() != 0) |
|
1845 | 1845 | { |
1846 | 1846 | // call to system.multicall failed |
1847 | 1847 | return $result; |
@@ -1858,29 +1858,29 @@ discard block |
||
1858 | 1858 | { |
1859 | 1859 | ///@todo test this code branch... |
1860 | 1860 | $rets = $result->value(); |
1861 | - if(!is_array($rets)) |
|
1861 | + if (!is_array($rets)) |
|
1862 | 1862 | { |
1863 | - return false; // bad return type from system.multicall |
|
1863 | + return false; // bad return type from system.multicall |
|
1864 | 1864 | } |
1865 | 1865 | $numRets = count($rets); |
1866 | - if($numRets != count($msgs)) |
|
1866 | + if ($numRets != count($msgs)) |
|
1867 | 1867 | { |
1868 | - return false; // wrong number of return values. |
|
1868 | + return false; // wrong number of return values. |
|
1869 | 1869 | } |
1870 | 1870 | |
1871 | 1871 | $response = array(); |
1872 | - for($i = 0; $i < $numRets; $i++) |
|
1872 | + for ($i = 0; $i<$numRets; $i++) |
|
1873 | 1873 | { |
1874 | 1874 | $val = $rets[$i]; |
1875 | 1875 | if (!is_array($val)) { |
1876 | 1876 | return false; |
1877 | 1877 | } |
1878 | - switch(count($val)) |
|
1878 | + switch (count($val)) |
|
1879 | 1879 | { |
1880 | 1880 | case 1: |
1881 | - if(!isset($val[0])) |
|
1881 | + if (!isset($val[0])) |
|
1882 | 1882 | { |
1883 | - return false; // Bad value |
|
1883 | + return false; // Bad value |
|
1884 | 1884 | } |
1885 | 1885 | // Normal return value |
1886 | 1886 | $response[$i] = new xmlrpcresp($val[0], 0, '', 'phpvals'); |
@@ -1888,12 +1888,12 @@ discard block |
||
1888 | 1888 | case 2: |
1889 | 1889 | /// @todo remove usage of @: it is apparently quite slow |
1890 | 1890 | $code = @$val['faultCode']; |
1891 | - if(!is_int($code)) |
|
1891 | + if (!is_int($code)) |
|
1892 | 1892 | { |
1893 | 1893 | return false; |
1894 | 1894 | } |
1895 | 1895 | $str = @$val['faultString']; |
1896 | - if(!is_string($str)) |
|
1896 | + if (!is_string($str)) |
|
1897 | 1897 | { |
1898 | 1898 | return false; |
1899 | 1899 | } |
@@ -1908,38 +1908,38 @@ discard block |
||
1908 | 1908 | else // return type == 'xmlrpcvals' |
1909 | 1909 | { |
1910 | 1910 | $rets = $result->value(); |
1911 | - if($rets->kindOf() != 'array') |
|
1911 | + if ($rets->kindOf() != 'array') |
|
1912 | 1912 | { |
1913 | - return false; // bad return type from system.multicall |
|
1913 | + return false; // bad return type from system.multicall |
|
1914 | 1914 | } |
1915 | 1915 | $numRets = $rets->arraysize(); |
1916 | - if($numRets != count($msgs)) |
|
1916 | + if ($numRets != count($msgs)) |
|
1917 | 1917 | { |
1918 | - return false; // wrong number of return values. |
|
1918 | + return false; // wrong number of return values. |
|
1919 | 1919 | } |
1920 | 1920 | |
1921 | 1921 | $response = array(); |
1922 | - for($i = 0; $i < $numRets; $i++) |
|
1922 | + for ($i = 0; $i<$numRets; $i++) |
|
1923 | 1923 | { |
1924 | 1924 | $val = $rets->arraymem($i); |
1925 | - switch($val->kindOf()) |
|
1925 | + switch ($val->kindOf()) |
|
1926 | 1926 | { |
1927 | 1927 | case 'array': |
1928 | - if($val->arraysize() != 1) |
|
1928 | + if ($val->arraysize() != 1) |
|
1929 | 1929 | { |
1930 | - return false; // Bad value |
|
1930 | + return false; // Bad value |
|
1931 | 1931 | } |
1932 | 1932 | // Normal return value |
1933 | 1933 | $response[$i] = new xmlrpcresp($val->arraymem(0)); |
1934 | 1934 | break; |
1935 | 1935 | case 'struct': |
1936 | 1936 | $code = $val->structmem('faultCode'); |
1937 | - if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') |
|
1937 | + if ($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') |
|
1938 | 1938 | { |
1939 | 1939 | return false; |
1940 | 1940 | } |
1941 | 1941 | $str = $val->structmem('faultString'); |
1942 | - if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') |
|
1942 | + if ($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') |
|
1943 | 1943 | { |
1944 | 1944 | return false; |
1945 | 1945 | } |
@@ -1976,9 +1976,9 @@ discard block |
||
1976 | 1976 | * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain |
1977 | 1977 | * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called... |
1978 | 1978 | */ |
1979 | - function __construct($val, $fcode = 0, $fstr = '', $valtyp='') |
|
1979 | + function __construct($val, $fcode = 0, $fstr = '', $valtyp = '') |
|
1980 | 1980 | { |
1981 | - if($fcode != 0) |
|
1981 | + if ($fcode != 0) |
|
1982 | 1982 | { |
1983 | 1983 | // error response |
1984 | 1984 | $this->errno = $fcode; |
@@ -2017,7 +2017,7 @@ discard block |
||
2017 | 2017 | /** |
2018 | 2018 | * @deprecated |
2019 | 2019 | */ |
2020 | - function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='') |
|
2020 | + function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp = '') |
|
2021 | 2021 | { |
2022 | 2022 | self::__construct($val, $fcode, $fstr, $valtyp); |
2023 | 2023 | } |
@@ -2074,10 +2074,10 @@ discard block |
||
2074 | 2074 | * @return string the xml representation of the response |
2075 | 2075 | * @access public |
2076 | 2076 | */ |
2077 | - function serialize($charset_encoding='') |
|
2077 | + function serialize($charset_encoding = '') |
|
2078 | 2078 | { |
2079 | 2079 | if ($charset_encoding != '') |
2080 | - $this->content_type = 'text/xml; charset=' . $charset_encoding; |
|
2080 | + $this->content_type = 'text/xml; charset='.$charset_encoding; |
|
2081 | 2081 | else |
2082 | 2082 | $this->content_type = 'text/xml'; |
2083 | 2083 | if ($GLOBALS['xmlrpc_null_apache_encoding']) |
@@ -2088,24 +2088,24 @@ discard block |
||
2088 | 2088 | { |
2089 | 2089 | $result = "<methodResponse>\n"; |
2090 | 2090 | } |
2091 | - if($this->errno) |
|
2091 | + if ($this->errno) |
|
2092 | 2092 | { |
2093 | 2093 | // G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients |
2094 | 2094 | // by xml-encoding non ascii chars |
2095 | - $result .= "<fault>\n" . |
|
2096 | -"<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno . |
|
2097 | -"</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" . |
|
2098 | -xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" . |
|
2095 | + $result .= "<fault>\n". |
|
2096 | +"<value>\n<struct><member><name>faultCode</name>\n<value><int>".$this->errno. |
|
2097 | +"</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>". |
|
2098 | +xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</string></value>\n</member>\n". |
|
2099 | 2099 | "</struct>\n</value>\n</fault>"; |
2100 | 2100 | } |
2101 | 2101 | else |
2102 | 2102 | { |
2103 | - if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval')) |
|
2103 | + if (!is_object($this->val) || !is_a($this->val, 'xmlrpcval')) |
|
2104 | 2104 | { |
2105 | 2105 | if (is_string($this->val) && $this->valtyp == 'xml') |
2106 | 2106 | { |
2107 | - $result .= "<params>\n<param>\n" . |
|
2108 | - $this->val . |
|
2107 | + $result .= "<params>\n<param>\n". |
|
2108 | + $this->val. |
|
2109 | 2109 | "</param>\n</params>"; |
2110 | 2110 | } |
2111 | 2111 | else |
@@ -2116,8 +2116,8 @@ discard block |
||
2116 | 2116 | } |
2117 | 2117 | else |
2118 | 2118 | { |
2119 | - $result .= "<params>\n<param>\n" . |
|
2120 | - $this->val->serialize($charset_encoding) . |
|
2119 | + $result .= "<params>\n<param>\n". |
|
2120 | + $this->val->serialize($charset_encoding). |
|
2121 | 2121 | "</param>\n</params>"; |
2122 | 2122 | } |
2123 | 2123 | } |
@@ -2131,20 +2131,20 @@ discard block |
||
2131 | 2131 | { |
2132 | 2132 | var $payload; |
2133 | 2133 | var $methodname; |
2134 | - var $params=array(); |
|
2135 | - var $debug=0; |
|
2134 | + var $params = array(); |
|
2135 | + var $debug = 0; |
|
2136 | 2136 | var $content_type = 'text/xml'; |
2137 | 2137 | |
2138 | 2138 | /** |
2139 | 2139 | * @param string $meth the name of the method to invoke |
2140 | 2140 | * @param array $pars array of parameters to be passed to the method (xmlrpcval objects) |
2141 | 2141 | */ |
2142 | - function __construct($meth, $pars=0) |
|
2142 | + function __construct($meth, $pars = 0) |
|
2143 | 2143 | { |
2144 | - $this->methodname=$meth; |
|
2145 | - if(is_array($pars) && count($pars)>0) |
|
2144 | + $this->methodname = $meth; |
|
2145 | + if (is_array($pars) && count($pars)>0) |
|
2146 | 2146 | { |
2147 | - for($i=0; $i<count($pars); $i++) |
|
2147 | + for ($i = 0; $i<count($pars); $i++) |
|
2148 | 2148 | { |
2149 | 2149 | $this->addParam($pars[$i]); |
2150 | 2150 | } |
@@ -2154,7 +2154,7 @@ discard block |
||
2154 | 2154 | /** |
2155 | 2155 | * @deprecated |
2156 | 2156 | */ |
2157 | - function xmlrpcmsg($meth, $pars=0) |
|
2157 | + function xmlrpcmsg($meth, $pars = 0) |
|
2158 | 2158 | { |
2159 | 2159 | self::__construct($meth, $pars); |
2160 | 2160 | } |
@@ -2162,15 +2162,15 @@ discard block |
||
2162 | 2162 | /** |
2163 | 2163 | * @access private |
2164 | 2164 | */ |
2165 | - function xml_header($charset_encoding='') |
|
2165 | + function xml_header($charset_encoding = '') |
|
2166 | 2166 | { |
2167 | 2167 | if ($charset_encoding != '') |
2168 | 2168 | { |
2169 | - return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?" . ">\n<methodCall>\n"; |
|
2169 | + return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?".">\n<methodCall>\n"; |
|
2170 | 2170 | } |
2171 | 2171 | else |
2172 | 2172 | { |
2173 | - return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; |
|
2173 | + return "<?xml version=\"1.0\"?".">\n<methodCall>\n"; |
|
2174 | 2174 | } |
2175 | 2175 | } |
2176 | 2176 | |
@@ -2193,23 +2193,23 @@ discard block |
||
2193 | 2193 | /** |
2194 | 2194 | * @access private |
2195 | 2195 | */ |
2196 | - function createPayload($charset_encoding='') |
|
2196 | + function createPayload($charset_encoding = '') |
|
2197 | 2197 | { |
2198 | 2198 | if ($charset_encoding != '') |
2199 | - $this->content_type = 'text/xml; charset=' . $charset_encoding; |
|
2199 | + $this->content_type = 'text/xml; charset='.$charset_encoding; |
|
2200 | 2200 | else |
2201 | 2201 | $this->content_type = 'text/xml'; |
2202 | - $this->payload=$this->xml_header($charset_encoding); |
|
2203 | - $this->payload.='<methodName>' . xmlrpc_encode_entitites($this->methodname, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</methodName>\n"; |
|
2204 | - $this->payload.="<params>\n"; |
|
2205 | - for($i=0; $i<count($this->params); $i++) |
|
2202 | + $this->payload = $this->xml_header($charset_encoding); |
|
2203 | + $this->payload .= '<methodName>'.xmlrpc_encode_entitites($this->methodname, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</methodName>\n"; |
|
2204 | + $this->payload .= "<params>\n"; |
|
2205 | + for ($i = 0; $i<count($this->params); $i++) |
|
2206 | 2206 | { |
2207 | - $p=$this->params[$i]; |
|
2208 | - $this->payload.="<param>\n" . $p->serialize($charset_encoding) . |
|
2207 | + $p = $this->params[$i]; |
|
2208 | + $this->payload .= "<param>\n".$p->serialize($charset_encoding). |
|
2209 | 2209 | "</param>\n"; |
2210 | 2210 | } |
2211 | - $this->payload.="</params>\n"; |
|
2212 | - $this->payload.=$this->xml_footer(); |
|
2211 | + $this->payload .= "</params>\n"; |
|
2212 | + $this->payload .= $this->xml_footer(); |
|
2213 | 2213 | } |
2214 | 2214 | |
2215 | 2215 | /** |
@@ -2218,11 +2218,11 @@ discard block |
||
2218 | 2218 | * @return string the method that will be invoked |
2219 | 2219 | * @access public |
2220 | 2220 | */ |
2221 | - function method($meth='') |
|
2221 | + function method($meth = '') |
|
2222 | 2222 | { |
2223 | - if($meth!='') |
|
2223 | + if ($meth != '') |
|
2224 | 2224 | { |
2225 | - $this->methodname=$meth; |
|
2225 | + $this->methodname = $meth; |
|
2226 | 2226 | } |
2227 | 2227 | return $this->methodname; |
2228 | 2228 | } |
@@ -2233,7 +2233,7 @@ discard block |
||
2233 | 2233 | * @return string the xml representation of the message, xml prologue included |
2234 | 2234 | * @access public |
2235 | 2235 | */ |
2236 | - function serialize($charset_encoding='') |
|
2236 | + function serialize($charset_encoding = '') |
|
2237 | 2237 | { |
2238 | 2238 | $this->createPayload($charset_encoding); |
2239 | 2239 | return $this->payload; |
@@ -2248,9 +2248,9 @@ discard block |
||
2248 | 2248 | function addParam($par) |
2249 | 2249 | { |
2250 | 2250 | // add check: do not add to self params which are not xmlrpcvals |
2251 | - if(is_object($par) && is_a($par, 'xmlrpcval')) |
|
2251 | + if (is_object($par) && is_a($par, 'xmlrpcval')) |
|
2252 | 2252 | { |
2253 | - $this->params[]=$par; |
|
2253 | + $this->params[] = $par; |
|
2254 | 2254 | return true; |
2255 | 2255 | } |
2256 | 2256 | else |
@@ -2289,13 +2289,13 @@ discard block |
||
2289 | 2289 | */ |
2290 | 2290 | function &parseResponseFile($fp) |
2291 | 2291 | { |
2292 | - $ipd=''; |
|
2293 | - while($data=fread($fp, 32768)) |
|
2292 | + $ipd = ''; |
|
2293 | + while ($data = fread($fp, 32768)) |
|
2294 | 2294 | { |
2295 | - $ipd.=$data; |
|
2295 | + $ipd .= $data; |
|
2296 | 2296 | } |
2297 | 2297 | //fclose($fp); |
2298 | - $r =& $this->parseResponse($ipd); |
|
2298 | + $r = & $this->parseResponse($ipd); |
|
2299 | 2299 | return $r; |
2300 | 2300 | } |
2301 | 2301 | |
@@ -2303,22 +2303,22 @@ discard block |
||
2303 | 2303 | * Parses HTTP headers and separates them from data. |
2304 | 2304 | * @access private |
2305 | 2305 | */ |
2306 | - function &parseResponseHeaders(&$data, $headers_processed=false) |
|
2306 | + function &parseResponseHeaders(&$data, $headers_processed = false) |
|
2307 | 2307 | { |
2308 | 2308 | // Support "web-proxy-tunelling" connections for https through proxies |
2309 | - if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data)) |
|
2309 | + if (preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data)) |
|
2310 | 2310 | { |
2311 | 2311 | // Look for CR/LF or simple LF as line separator, |
2312 | 2312 | // (even though it is not valid http) |
2313 | - $pos = strpos($data,"\r\n\r\n"); |
|
2314 | - if($pos || is_int($pos)) |
|
2313 | + $pos = strpos($data, "\r\n\r\n"); |
|
2314 | + if ($pos || is_int($pos)) |
|
2315 | 2315 | { |
2316 | 2316 | $bd = $pos+4; |
2317 | 2317 | } |
2318 | 2318 | else |
2319 | 2319 | { |
2320 | - $pos = strpos($data,"\n\n"); |
|
2321 | - if($pos || is_int($pos)) |
|
2320 | + $pos = strpos($data, "\n\n"); |
|
2321 | + if ($pos || is_int($pos)) |
|
2322 | 2322 | { |
2323 | 2323 | $bd = $pos+2; |
2324 | 2324 | } |
@@ -2337,28 +2337,28 @@ discard block |
||
2337 | 2337 | else |
2338 | 2338 | { |
2339 | 2339 | error_log('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed'); |
2340 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)'); |
|
2340 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)'); |
|
2341 | 2341 | return $r; |
2342 | 2342 | } |
2343 | 2343 | } |
2344 | 2344 | |
2345 | 2345 | // Strip HTTP 1.1 100 Continue header if present |
2346 | - while(preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data)) |
|
2346 | + while (preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data)) |
|
2347 | 2347 | { |
2348 | 2348 | $pos = strpos($data, 'HTTP', 12); |
2349 | 2349 | // server sent a Continue header without any (valid) content following... |
2350 | 2350 | // give the client a chance to know it |
2351 | - if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5 |
|
2351 | + if (!$pos && !is_int($pos)) // works fine in php 3, 4 and 5 |
|
2352 | 2352 | { |
2353 | 2353 | break; |
2354 | 2354 | } |
2355 | 2355 | $data = substr($data, $pos); |
2356 | 2356 | } |
2357 | - if(!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) |
|
2357 | + if (!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) |
|
2358 | 2358 | { |
2359 | - $errstr= substr($data, 0, strpos($data, "\n")-1); |
|
2360 | - error_log('XML-RPC: '.__METHOD__.': HTTP error, got response: ' .$errstr); |
|
2361 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (' . $errstr . ')'); |
|
2359 | + $errstr = substr($data, 0, strpos($data, "\n")-1); |
|
2360 | + error_log('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr); |
|
2361 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error'].' ('.$errstr.')'); |
|
2362 | 2362 | return $r; |
2363 | 2363 | } |
2364 | 2364 | |
@@ -2367,15 +2367,15 @@ discard block |
||
2367 | 2367 | |
2368 | 2368 | // be tolerant to usage of \n instead of \r\n to separate headers and data |
2369 | 2369 | // (even though it is not valid http) |
2370 | - $pos = strpos($data,"\r\n\r\n"); |
|
2371 | - if($pos || is_int($pos)) |
|
2370 | + $pos = strpos($data, "\r\n\r\n"); |
|
2371 | + if ($pos || is_int($pos)) |
|
2372 | 2372 | { |
2373 | 2373 | $bd = $pos+4; |
2374 | 2374 | } |
2375 | 2375 | else |
2376 | 2376 | { |
2377 | - $pos = strpos($data,"\n\n"); |
|
2378 | - if($pos || is_int($pos)) |
|
2377 | + $pos = strpos($data, "\n\n"); |
|
2378 | + if ($pos || is_int($pos)) |
|
2379 | 2379 | { |
2380 | 2380 | $bd = $pos+2; |
2381 | 2381 | } |
@@ -2388,11 +2388,11 @@ discard block |
||
2388 | 2388 | } |
2389 | 2389 | // be tolerant to line endings, and extra empty lines |
2390 | 2390 | $ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos))); |
2391 | - while(list(,$line) = @each($ar)) |
|
2391 | + while (list(,$line) = @each($ar)) |
|
2392 | 2392 | { |
2393 | 2393 | // take care of multi-line headers and cookies |
2394 | - $arr = explode(':',$line,2); |
|
2395 | - if(count($arr) > 1) |
|
2394 | + $arr = explode(':', $line, 2); |
|
2395 | + if (count($arr)>1) |
|
2396 | 2396 | { |
2397 | 2397 | $header_name = strtolower(trim($arr[0])); |
2398 | 2398 | /// @todo some other headers (the ones that allow a CSV list of values) |
@@ -2416,7 +2416,7 @@ discard block |
||
2416 | 2416 | // glue together all received cookies, using a comma to separate them |
2417 | 2417 | // (same as php does with getallheaders()) |
2418 | 2418 | if (isset($GLOBALS['_xh']['headers'][$header_name])) |
2419 | - $GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie); |
|
2419 | + $GLOBALS['_xh']['headers'][$header_name] .= ', '.trim($cookie); |
|
2420 | 2420 | else |
2421 | 2421 | $GLOBALS['_xh']['headers'][$header_name] = trim($cookie); |
2422 | 2422 | // parse cookie attributes, in case user wants to correctly honour them |
@@ -2450,23 +2450,23 @@ discard block |
||
2450 | 2450 | $GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]); |
2451 | 2451 | } |
2452 | 2452 | } |
2453 | - elseif(isset($header_name)) |
|
2453 | + elseif (isset($header_name)) |
|
2454 | 2454 | { |
2455 | 2455 | /// @todo version1 cookies might span multiple lines, thus breaking the parsing above |
2456 | - $GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line); |
|
2456 | + $GLOBALS['_xh']['headers'][$header_name] .= ' '.trim($line); |
|
2457 | 2457 | } |
2458 | 2458 | } |
2459 | 2459 | |
2460 | 2460 | $data = substr($data, $bd); |
2461 | 2461 | |
2462 | - if($this->debug && count($GLOBALS['_xh']['headers'])) |
|
2462 | + if ($this->debug && count($GLOBALS['_xh']['headers'])) |
|
2463 | 2463 | { |
2464 | 2464 | print '<PRE>'; |
2465 | - foreach($GLOBALS['_xh']['headers'] as $header => $value) |
|
2465 | + foreach ($GLOBALS['_xh']['headers'] as $header => $value) |
|
2466 | 2466 | { |
2467 | 2467 | print htmlentities("HEADER: $header: $value\n"); |
2468 | 2468 | } |
2469 | - foreach($GLOBALS['_xh']['cookies'] as $header => $value) |
|
2469 | + foreach ($GLOBALS['_xh']['cookies'] as $header => $value) |
|
2470 | 2470 | { |
2471 | 2471 | print htmlentities("COOKIE: $header={$value['value']}\n"); |
2472 | 2472 | } |
@@ -2475,12 +2475,12 @@ discard block |
||
2475 | 2475 | |
2476 | 2476 | // if CURL was used for the call, http headers have been processed, |
2477 | 2477 | // and dechunking + reinflating have been carried out |
2478 | - if(!$headers_processed) |
|
2478 | + if (!$headers_processed) |
|
2479 | 2479 | { |
2480 | 2480 | // Decode chunked encoding sent by http 1.1 servers |
2481 | - if(isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked') |
|
2481 | + if (isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked') |
|
2482 | 2482 | { |
2483 | - if(!$data = decode_chunked($data)) |
|
2483 | + if (!$data = decode_chunked($data)) |
|
2484 | 2484 | { |
2485 | 2485 | error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server'); |
2486 | 2486 | $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['dechunk_fail'], $GLOBALS['xmlrpcstr']['dechunk_fail']); |
@@ -2490,25 +2490,25 @@ discard block |
||
2490 | 2490 | |
2491 | 2491 | // Decode gzip-compressed stuff |
2492 | 2492 | // code shamelessly inspired from nusoap library by Dietrich Ayala |
2493 | - if(isset($GLOBALS['_xh']['headers']['content-encoding'])) |
|
2493 | + if (isset($GLOBALS['_xh']['headers']['content-encoding'])) |
|
2494 | 2494 | { |
2495 | 2495 | $GLOBALS['_xh']['headers']['content-encoding'] = str_replace('x-', '', $GLOBALS['_xh']['headers']['content-encoding']); |
2496 | - if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip') |
|
2496 | + if ($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip') |
|
2497 | 2497 | { |
2498 | 2498 | // if decoding works, use it. else assume data wasn't gzencoded |
2499 | - if(function_exists('gzinflate')) |
|
2499 | + if (function_exists('gzinflate')) |
|
2500 | 2500 | { |
2501 | - if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) |
|
2501 | + if ($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) |
|
2502 | 2502 | { |
2503 | 2503 | $data = $degzdata; |
2504 | - if($this->debug) |
|
2505 | - print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; |
|
2504 | + if ($this->debug) |
|
2505 | + print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n".htmlentities($data)."\n---END---</PRE>"; |
|
2506 | 2506 | } |
2507 | - elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) |
|
2507 | + elseif ($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) |
|
2508 | 2508 | { |
2509 | 2509 | $data = $degzdata; |
2510 | - if($this->debug) |
|
2511 | - print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; |
|
2510 | + if ($this->debug) |
|
2511 | + print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n".htmlentities($data)."\n---END---</PRE>"; |
|
2512 | 2512 | } |
2513 | 2513 | else |
2514 | 2514 | { |
@@ -2529,7 +2529,7 @@ discard block |
||
2529 | 2529 | |
2530 | 2530 | // real stupid hack to avoid PHP complaining about returning NULL by ref |
2531 | 2531 | $r = null; |
2532 | - $r =& $r; |
|
2532 | + $r = & $r; |
|
2533 | 2533 | return $r; |
2534 | 2534 | } |
2535 | 2535 | |
@@ -2541,28 +2541,28 @@ discard block |
||
2541 | 2541 | * @return xmlrpcresp |
2542 | 2542 | * @access public |
2543 | 2543 | */ |
2544 | - function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals') |
|
2544 | + function &parseResponse($data = '', $headers_processed = false, $return_type = 'xmlrpcvals') |
|
2545 | 2545 | { |
2546 | - if($this->debug) |
|
2546 | + if ($this->debug) |
|
2547 | 2547 | { |
2548 | 2548 | //by maHo, replaced htmlspecialchars with htmlentities |
2549 | - print "<PRE>---GOT---\n" . htmlentities($data) . "\n---END---\n</PRE>"; |
|
2549 | + print "<PRE>---GOT---\n".htmlentities($data)."\n---END---\n</PRE>"; |
|
2550 | 2550 | } |
2551 | 2551 | |
2552 | - if($data == '') |
|
2552 | + if ($data == '') |
|
2553 | 2553 | { |
2554 | 2554 | error_log('XML-RPC: '.__METHOD__.': no response received from server.'); |
2555 | 2555 | $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_data'], $GLOBALS['xmlrpcstr']['no_data']); |
2556 | 2556 | return $r; |
2557 | 2557 | } |
2558 | 2558 | |
2559 | - $GLOBALS['_xh']=array(); |
|
2559 | + $GLOBALS['_xh'] = array(); |
|
2560 | 2560 | |
2561 | 2561 | $raw_data = $data; |
2562 | 2562 | // parse the HTTP headers of the response, if present, and separate them from data |
2563 | - if(substr($data, 0, 4) == 'HTTP') |
|
2563 | + if (substr($data, 0, 4) == 'HTTP') |
|
2564 | 2564 | { |
2565 | - $r =& $this->parseResponseHeaders($data, $headers_processed); |
|
2565 | + $r = & $this->parseResponseHeaders($data, $headers_processed); |
|
2566 | 2566 | if ($r) |
2567 | 2567 | { |
2568 | 2568 | // failed processing of HTTP response headers |
@@ -2577,7 +2577,7 @@ discard block |
||
2577 | 2577 | $GLOBALS['_xh']['cookies'] = array(); |
2578 | 2578 | } |
2579 | 2579 | |
2580 | - if($this->debug) |
|
2580 | + if ($this->debug) |
|
2581 | 2581 | { |
2582 | 2582 | $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
2583 | 2583 | if ($start) |
@@ -2597,7 +2597,7 @@ discard block |
||
2597 | 2597 | // be tolerant of junk after methodResponse (e.g. javascript ads automatically inserted by free hosts) |
2598 | 2598 | // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib |
2599 | 2599 | $pos = strrpos($data, '</methodResponse>'); |
2600 | - if($pos !== false) |
|
2600 | + if ($pos !== false) |
|
2601 | 2601 | { |
2602 | 2602 | $data = substr($data, 0, $pos+17); |
2603 | 2603 | } |
@@ -2615,13 +2615,13 @@ discard block |
||
2615 | 2615 | // try to 'guestimate' the character encoding of the received response |
2616 | 2616 | $resp_encoding = guess_encoding(@$GLOBALS['_xh']['headers']['content-type'], $data); |
2617 | 2617 | |
2618 | - $GLOBALS['_xh']['ac']=''; |
|
2618 | + $GLOBALS['_xh']['ac'] = ''; |
|
2619 | 2619 | //$GLOBALS['_xh']['qt']=''; //unused... |
2620 | 2620 | $GLOBALS['_xh']['stack'] = array(); |
2621 | 2621 | $GLOBALS['_xh']['valuestack'] = array(); |
2622 | - $GLOBALS['_xh']['isf']=0; // 0 = OK, 1 for xmlrpc fault responses, 2 = invalid xmlrpc |
|
2623 | - $GLOBALS['_xh']['isf_reason']=''; |
|
2624 | - $GLOBALS['_xh']['rt']=''; // 'methodcall or 'methodresponse' |
|
2622 | + $GLOBALS['_xh']['isf'] = 0; // 0 = OK, 1 for xmlrpc fault responses, 2 = invalid xmlrpc |
|
2623 | + $GLOBALS['_xh']['isf_reason'] = ''; |
|
2624 | + $GLOBALS['_xh']['rt'] = ''; // 'methodcall or 'methodresponse' |
|
2625 | 2625 | |
2626 | 2626 | // Since parsing will fail if charset is not specified in the xml prologue, |
2627 | 2627 | // the encoding is not UTF8 and there are non-ascii chars in the text, we try to work round that... |
@@ -2635,7 +2635,7 @@ discard block |
||
2635 | 2635 | if (extension_loaded('mbstring')) { |
2636 | 2636 | $data = mb_convert_encoding($data, 'UTF-8', $resp_encoding); |
2637 | 2637 | } else { |
2638 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $resp_encoding); |
|
2638 | + error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$resp_encoding); |
|
2639 | 2639 | } |
2640 | 2640 | } |
2641 | 2641 | } |
@@ -2670,10 +2670,10 @@ discard block |
||
2670 | 2670 | xml_set_default_handler($parser, 'xmlrpc_dh'); |
2671 | 2671 | |
2672 | 2672 | // first error check: xml not well formed |
2673 | - if(!xml_parse($parser, $data, count($data))) |
|
2673 | + if (!xml_parse($parser, $data, count($data))) |
|
2674 | 2674 | { |
2675 | 2675 | // thanks to Peter Kocks <[email protected]> |
2676 | - if((xml_get_current_line_number($parser)) == 1) |
|
2676 | + if ((xml_get_current_line_number($parser)) == 1) |
|
2677 | 2677 | { |
2678 | 2678 | $errstr = 'XML error at line 1, check URL'; |
2679 | 2679 | } |
@@ -2684,9 +2684,9 @@ discard block |
||
2684 | 2684 | xml_get_current_line_number($parser), xml_get_current_column_number($parser)); |
2685 | 2685 | } |
2686 | 2686 | error_log($errstr); |
2687 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcstr']['invalid_return'].' ('.$errstr.')'); |
|
2687 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcstr']['invalid_return'].' ('.$errstr.')'); |
|
2688 | 2688 | xml_parser_free($parser); |
2689 | - if($this->debug) |
|
2689 | + if ($this->debug) |
|
2690 | 2690 | { |
2691 | 2691 | print $errstr; |
2692 | 2692 | } |
@@ -2697,7 +2697,7 @@ discard block |
||
2697 | 2697 | } |
2698 | 2698 | xml_parser_free($parser); |
2699 | 2699 | // second error check: xml well formed but not xml-rpc compliant |
2700 | - if ($GLOBALS['_xh']['isf'] > 1) |
|
2700 | + if ($GLOBALS['_xh']['isf']>1) |
|
2701 | 2701 | { |
2702 | 2702 | if ($this->debug) |
2703 | 2703 | { |
@@ -2705,7 +2705,7 @@ discard block |
||
2705 | 2705 | } |
2706 | 2706 | |
2707 | 2707 | $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], |
2708 | - $GLOBALS['xmlrpcstr']['invalid_return'] . ' ' . $GLOBALS['_xh']['isf_reason']); |
|
2708 | + $GLOBALS['xmlrpcstr']['invalid_return'].' '.$GLOBALS['_xh']['isf_reason']); |
|
2709 | 2709 | } |
2710 | 2710 | // third error check: parsing of the response has somehow gone boink. |
2711 | 2711 | // NB: shall we omit this check, since we trust the parsing code? |
@@ -2714,7 +2714,7 @@ discard block |
||
2714 | 2714 | // something odd has happened |
2715 | 2715 | // and it's time to generate a client side error |
2716 | 2716 | // indicating something odd went on |
2717 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], |
|
2717 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], |
|
2718 | 2718 | $GLOBALS['xmlrpcstr']['invalid_return']); |
2719 | 2719 | } |
2720 | 2720 | else |
@@ -2729,9 +2729,9 @@ discard block |
||
2729 | 2729 | } |
2730 | 2730 | |
2731 | 2731 | // note that using =& will raise an error if $GLOBALS['_xh']['st'] does not generate an object. |
2732 | - $v =& $GLOBALS['_xh']['value']; |
|
2732 | + $v = & $GLOBALS['_xh']['value']; |
|
2733 | 2733 | |
2734 | - if($GLOBALS['_xh']['isf']) |
|
2734 | + if ($GLOBALS['_xh']['isf']) |
|
2735 | 2735 | { |
2736 | 2736 | /// @todo we should test here if server sent an int and a string, |
2737 | 2737 | /// and/or coerce them into such... |
@@ -2748,7 +2748,7 @@ discard block |
||
2748 | 2748 | $errstr = $v['faultString']; |
2749 | 2749 | } |
2750 | 2750 | |
2751 | - if($errno == 0) |
|
2751 | + if ($errno == 0) |
|
2752 | 2752 | { |
2753 | 2753 | // FAULT returned, errno needs to reflect that |
2754 | 2754 | $errno = -1; |
@@ -2758,7 +2758,7 @@ discard block |
||
2758 | 2758 | } |
2759 | 2759 | else |
2760 | 2760 | { |
2761 | - $r=new xmlrpcresp($v, 0, '', $return_type); |
|
2761 | + $r = new xmlrpcresp($v, 0, '', $return_type); |
|
2762 | 2762 | } |
2763 | 2763 | } |
2764 | 2764 | |
@@ -2771,26 +2771,26 @@ discard block |
||
2771 | 2771 | |
2772 | 2772 | class xmlrpcval |
2773 | 2773 | { |
2774 | - var $me=array(); |
|
2775 | - var $mytype=0; |
|
2776 | - var $_php_class=null; |
|
2774 | + var $me = array(); |
|
2775 | + var $mytype = 0; |
|
2776 | + var $_php_class = null; |
|
2777 | 2777 | |
2778 | 2778 | /** |
2779 | 2779 | * @param mixed $val |
2780 | 2780 | * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed |
2781 | 2781 | */ |
2782 | - function __construct($val=-1, $type='') |
|
2782 | + function __construct($val = -1, $type = '') |
|
2783 | 2783 | { |
2784 | 2784 | /// @todo: optimization creep - do not call addXX, do it all inline. |
2785 | 2785 | /// downside: booleans will not be coerced anymore |
2786 | - if($val!==-1 || $type!='') |
|
2786 | + if ($val !== -1 || $type != '') |
|
2787 | 2787 | { |
2788 | 2788 | // optimization creep: inlined all work done by constructor |
2789 | - switch($type) |
|
2789 | + switch ($type) |
|
2790 | 2790 | { |
2791 | 2791 | case '': |
2792 | - $this->mytype=1; |
|
2793 | - $this->me['string']=$val; |
|
2792 | + $this->mytype = 1; |
|
2793 | + $this->me['string'] = $val; |
|
2794 | 2794 | break; |
2795 | 2795 | case 'i4': |
2796 | 2796 | case 'int': |
@@ -2800,16 +2800,16 @@ discard block |
||
2800 | 2800 | case 'dateTime.iso8601': |
2801 | 2801 | case 'base64': |
2802 | 2802 | case 'null': |
2803 | - $this->mytype=1; |
|
2804 | - $this->me[$type]=$val; |
|
2803 | + $this->mytype = 1; |
|
2804 | + $this->me[$type] = $val; |
|
2805 | 2805 | break; |
2806 | 2806 | case 'array': |
2807 | - $this->mytype=2; |
|
2808 | - $this->me['array']=$val; |
|
2807 | + $this->mytype = 2; |
|
2808 | + $this->me['array'] = $val; |
|
2809 | 2809 | break; |
2810 | 2810 | case 'struct': |
2811 | - $this->mytype=3; |
|
2812 | - $this->me['struct']=$val; |
|
2811 | + $this->mytype = 3; |
|
2812 | + $this->me['struct'] = $val; |
|
2813 | 2813 | break; |
2814 | 2814 | default: |
2815 | 2815 | error_log("XML-RPC: ".__METHOD__.": not a known type ($type)"); |
@@ -2836,7 +2836,7 @@ discard block |
||
2836 | 2836 | /** |
2837 | 2837 | * @deprecated |
2838 | 2838 | */ |
2839 | - function xmlrpcval($val=-1, $type='') |
|
2839 | + function xmlrpcval($val = -1, $type = '') |
|
2840 | 2840 | { |
2841 | 2841 | self::__construct($val, $type); |
2842 | 2842 | } |
@@ -2847,10 +2847,10 @@ discard block |
||
2847 | 2847 | * @param string $type |
2848 | 2848 | * @return int 1 or 0 on failure |
2849 | 2849 | */ |
2850 | - function addScalar($val, $type='string') |
|
2850 | + function addScalar($val, $type = 'string') |
|
2851 | 2851 | { |
2852 | - $typeof=@$GLOBALS['xmlrpcTypes'][$type]; |
|
2853 | - if($typeof!=1) |
|
2852 | + $typeof = @$GLOBALS['xmlrpcTypes'][$type]; |
|
2853 | + if ($typeof != 1) |
|
2854 | 2854 | { |
2855 | 2855 | error_log("XML-RPC: ".__METHOD__.": not a scalar type ($type)"); |
2856 | 2856 | return 0; |
@@ -2859,19 +2859,19 @@ discard block |
||
2859 | 2859 | // coerce booleans into correct values |
2860 | 2860 | // NB: we should either do it for datetimes, integers and doubles, too, |
2861 | 2861 | // or just plain remove this check, implemented on booleans only... |
2862 | - if($type==$GLOBALS['xmlrpcBoolean']) |
|
2862 | + if ($type == $GLOBALS['xmlrpcBoolean']) |
|
2863 | 2863 | { |
2864 | - if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false'))) |
|
2864 | + if (strcasecmp($val, 'true') == 0 || $val == 1 || ($val == true && strcasecmp($val, 'false'))) |
|
2865 | 2865 | { |
2866 | - $val=true; |
|
2866 | + $val = true; |
|
2867 | 2867 | } |
2868 | 2868 | else |
2869 | 2869 | { |
2870 | - $val=false; |
|
2870 | + $val = false; |
|
2871 | 2871 | } |
2872 | 2872 | } |
2873 | 2873 | |
2874 | - switch($this->mytype) |
|
2874 | + switch ($this->mytype) |
|
2875 | 2875 | { |
2876 | 2876 | case 1: |
2877 | 2877 | error_log('XML-RPC: '.__METHOD__.': scalar xmlrpcval can have only one value'); |
@@ -2885,12 +2885,12 @@ discard block |
||
2885 | 2885 | //$ar[]=new xmlrpcval($val, $type); |
2886 | 2886 | //$this->me['array']=$ar; |
2887 | 2887 | // Faster (?) avoid all the costly array-copy-by-val done here... |
2888 | - $this->me['array'][]=new xmlrpcval($val, $type); |
|
2888 | + $this->me['array'][] = new xmlrpcval($val, $type); |
|
2889 | 2889 | return 1; |
2890 | 2890 | default: |
2891 | 2891 | // a scalar, so set the value and remember we're scalar |
2892 | - $this->me[$type]=$val; |
|
2893 | - $this->mytype=$typeof; |
|
2892 | + $this->me[$type] = $val; |
|
2893 | + $this->mytype = $typeof; |
|
2894 | 2894 | return 1; |
2895 | 2895 | } |
2896 | 2896 | } |
@@ -2905,13 +2905,13 @@ discard block |
||
2905 | 2905 | */ |
2906 | 2906 | function addArray($vals) |
2907 | 2907 | { |
2908 | - if($this->mytype==0) |
|
2908 | + if ($this->mytype == 0) |
|
2909 | 2909 | { |
2910 | - $this->mytype=$GLOBALS['xmlrpcTypes']['array']; |
|
2911 | - $this->me['array']=$vals; |
|
2910 | + $this->mytype = $GLOBALS['xmlrpcTypes']['array']; |
|
2911 | + $this->me['array'] = $vals; |
|
2912 | 2912 | return 1; |
2913 | 2913 | } |
2914 | - elseif($this->mytype==2) |
|
2914 | + elseif ($this->mytype == 2) |
|
2915 | 2915 | { |
2916 | 2916 | // we're adding to an array here |
2917 | 2917 | $this->me['array'] = array_merge($this->me['array'], $vals); |
@@ -2919,7 +2919,7 @@ discard block |
||
2919 | 2919 | } |
2920 | 2920 | else |
2921 | 2921 | { |
2922 | - error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']'); |
|
2922 | + error_log('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
2923 | 2923 | return 0; |
2924 | 2924 | } |
2925 | 2925 | } |
@@ -2934,13 +2934,13 @@ discard block |
||
2934 | 2934 | */ |
2935 | 2935 | function addStruct($vals) |
2936 | 2936 | { |
2937 | - if($this->mytype==0) |
|
2937 | + if ($this->mytype == 0) |
|
2938 | 2938 | { |
2939 | - $this->mytype=$GLOBALS['xmlrpcTypes']['struct']; |
|
2940 | - $this->me['struct']=$vals; |
|
2939 | + $this->mytype = $GLOBALS['xmlrpcTypes']['struct']; |
|
2940 | + $this->me['struct'] = $vals; |
|
2941 | 2941 | return 1; |
2942 | 2942 | } |
2943 | - elseif($this->mytype==3) |
|
2943 | + elseif ($this->mytype == 3) |
|
2944 | 2944 | { |
2945 | 2945 | // we're adding to a struct here |
2946 | 2946 | $this->me['struct'] = array_merge($this->me['struct'], $vals); |
@@ -2948,7 +2948,7 @@ discard block |
||
2948 | 2948 | } |
2949 | 2949 | else |
2950 | 2950 | { |
2951 | - error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']'); |
|
2951 | + error_log('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
2952 | 2952 | return 0; |
2953 | 2953 | } |
2954 | 2954 | } |
@@ -2957,12 +2957,12 @@ discard block |
||
2957 | 2957 | // DEPRECATED! |
2958 | 2958 | function dump($ar) |
2959 | 2959 | { |
2960 | - foreach($ar as $key => $val) |
|
2960 | + foreach ($ar as $key => $val) |
|
2961 | 2961 | { |
2962 | 2962 | echo "$key => $val<br />"; |
2963 | - if($key == 'array') |
|
2963 | + if ($key == 'array') |
|
2964 | 2964 | { |
2965 | - while(list($key2, $val2) = each($val)) |
|
2965 | + while (list($key2, $val2) = each($val)) |
|
2966 | 2966 | { |
2967 | 2967 | echo "-- $key2 => $val2<br />"; |
2968 | 2968 | } |
@@ -2977,7 +2977,7 @@ discard block |
||
2977 | 2977 | */ |
2978 | 2978 | function kindOf() |
2979 | 2979 | { |
2980 | - switch($this->mytype) |
|
2980 | + switch ($this->mytype) |
|
2981 | 2981 | { |
2982 | 2982 | case 3: |
2983 | 2983 | return 'struct'; |
@@ -2996,28 +2996,28 @@ discard block |
||
2996 | 2996 | /** |
2997 | 2997 | * @access private |
2998 | 2998 | */ |
2999 | - function serializedata($typ, $val, $charset_encoding='') |
|
2999 | + function serializedata($typ, $val, $charset_encoding = '') |
|
3000 | 3000 | { |
3001 | - $rs=''; |
|
3002 | - switch(@$GLOBALS['xmlrpcTypes'][$typ]) |
|
3001 | + $rs = ''; |
|
3002 | + switch (@$GLOBALS['xmlrpcTypes'][$typ]) |
|
3003 | 3003 | { |
3004 | 3004 | case 1: |
3005 | - switch($typ) |
|
3005 | + switch ($typ) |
|
3006 | 3006 | { |
3007 | 3007 | case $GLOBALS['xmlrpcBase64']: |
3008 | - $rs.="<${typ}>" . base64_encode($val) . "</${typ}>"; |
|
3008 | + $rs .= "<${typ}>".base64_encode($val)."</${typ}>"; |
|
3009 | 3009 | break; |
3010 | 3010 | case $GLOBALS['xmlrpcBoolean']: |
3011 | - $rs.="<${typ}>" . ($val ? '1' : '0') . "</${typ}>"; |
|
3011 | + $rs .= "<${typ}>".($val ? '1' : '0')."</${typ}>"; |
|
3012 | 3012 | break; |
3013 | 3013 | case $GLOBALS['xmlrpcString']: |
3014 | 3014 | // G. Giunta 2005/2/13: do NOT use htmlentities, since |
3015 | 3015 | // it will produce named html entities, which are invalid xml |
3016 | - $rs.="<${typ}>" . xmlrpc_encode_entitites($val, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding). "</${typ}>"; |
|
3016 | + $rs .= "<${typ}>".xmlrpc_encode_entitites($val, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</${typ}>"; |
|
3017 | 3017 | break; |
3018 | 3018 | case $GLOBALS['xmlrpcInt']: |
3019 | 3019 | case $GLOBALS['xmlrpcI4']: |
3020 | - $rs.="<${typ}>".(int)$val."</${typ}>"; |
|
3020 | + $rs .= "<${typ}>".(int) $val."</${typ}>"; |
|
3021 | 3021 | break; |
3022 | 3022 | case $GLOBALS['xmlrpcDouble']: |
3023 | 3023 | // avoid using standard conversion of float to string because it is locale-dependent, |
@@ -3025,71 +3025,71 @@ discard block |
||
3025 | 3025 | // sprintf('%F') could be most likely ok but it fails eg. on 2e-14. |
3026 | 3026 | // The code below tries its best at keeping max precision while avoiding exp notation, |
3027 | 3027 | // but there is of course no limit in the number of decimal places to be used... |
3028 | - $rs.="<${typ}>".preg_replace('/\\.?0+$/','',number_format((double)$val, 128, '.', ''))."</${typ}>"; |
|
3028 | + $rs .= "<${typ}>".preg_replace('/\\.?0+$/', '', number_format((double) $val, 128, '.', ''))."</${typ}>"; |
|
3029 | 3029 | break; |
3030 | 3030 | case $GLOBALS['xmlrpcDateTime']: |
3031 | 3031 | if (is_string($val)) |
3032 | 3032 | { |
3033 | - $rs.="<${typ}>${val}</${typ}>"; |
|
3033 | + $rs .= "<${typ}>${val}</${typ}>"; |
|
3034 | 3034 | } |
3035 | - else if(is_a($val, 'DateTime')) |
|
3035 | + else if (is_a($val, 'DateTime')) |
|
3036 | 3036 | { |
3037 | - $rs.="<${typ}>".$val->format('Ymd\TH:i:s')."</${typ}>"; |
|
3037 | + $rs .= "<${typ}>".$val->format('Ymd\TH:i:s')."</${typ}>"; |
|
3038 | 3038 | } |
3039 | - else if(is_int($val)) |
|
3039 | + else if (is_int($val)) |
|
3040 | 3040 | { |
3041 | - $rs.="<${typ}>".strftime("%Y%m%dT%H:%M:%S", $val)."</${typ}>"; |
|
3041 | + $rs .= "<${typ}>".strftime("%Y%m%dT%H:%M:%S", $val)."</${typ}>"; |
|
3042 | 3042 | } |
3043 | 3043 | else |
3044 | 3044 | { |
3045 | 3045 | // not really a good idea here: but what shall we output anyway? left for backward compat... |
3046 | - $rs.="<${typ}>${val}</${typ}>"; |
|
3046 | + $rs .= "<${typ}>${val}</${typ}>"; |
|
3047 | 3047 | } |
3048 | 3048 | break; |
3049 | 3049 | case $GLOBALS['xmlrpcNull']: |
3050 | 3050 | if ($GLOBALS['xmlrpc_null_apache_encoding']) |
3051 | 3051 | { |
3052 | - $rs.="<ex:nil/>"; |
|
3052 | + $rs .= "<ex:nil/>"; |
|
3053 | 3053 | } |
3054 | 3054 | else |
3055 | 3055 | { |
3056 | - $rs.="<nil/>"; |
|
3056 | + $rs .= "<nil/>"; |
|
3057 | 3057 | } |
3058 | 3058 | break; |
3059 | 3059 | default: |
3060 | 3060 | // no standard type value should arrive here, but provide a possibility |
3061 | 3061 | // for xmlrpcvals of unknown type... |
3062 | - $rs.="<${typ}>${val}</${typ}>"; |
|
3062 | + $rs .= "<${typ}>${val}</${typ}>"; |
|
3063 | 3063 | } |
3064 | 3064 | break; |
3065 | 3065 | case 3: |
3066 | 3066 | // struct |
3067 | 3067 | if ($this->_php_class) |
3068 | 3068 | { |
3069 | - $rs.='<struct php_class="' . $this->_php_class . "\">\n"; |
|
3069 | + $rs .= '<struct php_class="'.$this->_php_class."\">\n"; |
|
3070 | 3070 | } |
3071 | 3071 | else |
3072 | 3072 | { |
3073 | - $rs.="<struct>\n"; |
|
3073 | + $rs .= "<struct>\n"; |
|
3074 | 3074 | } |
3075 | - foreach($val as $key2 => $val2) |
|
3075 | + foreach ($val as $key2 => $val2) |
|
3076 | 3076 | { |
3077 | - $rs.='<member><name>'.xmlrpc_encode_entitites($key2, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</name>\n"; |
|
3077 | + $rs .= '<member><name>'.xmlrpc_encode_entitites($key2, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</name>\n"; |
|
3078 | 3078 | //$rs.=$this->serializeval($val2); |
3079 | - $rs.=$val2->serialize($charset_encoding); |
|
3080 | - $rs.="</member>\n"; |
|
3079 | + $rs .= $val2->serialize($charset_encoding); |
|
3080 | + $rs .= "</member>\n"; |
|
3081 | 3081 | } |
3082 | - $rs.='</struct>'; |
|
3082 | + $rs .= '</struct>'; |
|
3083 | 3083 | break; |
3084 | 3084 | case 2: |
3085 | 3085 | // array |
3086 | - $rs.="<array>\n<data>\n"; |
|
3087 | - for($i=0; $i<count($val); $i++) |
|
3086 | + $rs .= "<array>\n<data>\n"; |
|
3087 | + for ($i = 0; $i<count($val); $i++) |
|
3088 | 3088 | { |
3089 | 3089 | //$rs.=$this->serializeval($val[$i]); |
3090 | - $rs.=$val[$i]->serialize($charset_encoding); |
|
3090 | + $rs .= $val[$i]->serialize($charset_encoding); |
|
3091 | 3091 | } |
3092 | - $rs.="</data>\n</array>"; |
|
3092 | + $rs .= "</data>\n</array>"; |
|
3093 | 3093 | break; |
3094 | 3094 | default: |
3095 | 3095 | break; |
@@ -3103,14 +3103,14 @@ discard block |
||
3103 | 3103 | * @return string |
3104 | 3104 | * @access public |
3105 | 3105 | */ |
3106 | - function serialize($charset_encoding='') |
|
3106 | + function serialize($charset_encoding = '') |
|
3107 | 3107 | { |
3108 | 3108 | // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... |
3109 | 3109 | //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) |
3110 | 3110 | //{ |
3111 | 3111 | reset($this->me); |
3112 | 3112 | list($typ, $val) = each($this->me); |
3113 | - return '<value>' . $this->serializedata($typ, $val, $charset_encoding) . "</value>\n"; |
|
3113 | + return '<value>'.$this->serializedata($typ, $val, $charset_encoding)."</value>\n"; |
|
3114 | 3114 | //} |
3115 | 3115 | } |
3116 | 3116 | |
@@ -3120,10 +3120,10 @@ discard block |
||
3120 | 3120 | // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... |
3121 | 3121 | //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) |
3122 | 3122 | //{ |
3123 | - $ar=$o->me; |
|
3123 | + $ar = $o->me; |
|
3124 | 3124 | reset($ar); |
3125 | 3125 | list($typ, $val) = each($ar); |
3126 | - return '<value>' . $this->serializedata($typ, $val) . "</value>\n"; |
|
3126 | + return '<value>'.$this->serializedata($typ, $val)."</value>\n"; |
|
3127 | 3127 | //} |
3128 | 3128 | } |
3129 | 3129 | |
@@ -3176,32 +3176,32 @@ discard block |
||
3176 | 3176 | { |
3177 | 3177 | // UNSTABLE |
3178 | 3178 | reset($this->me); |
3179 | - list($a,$b)=each($this->me); |
|
3179 | + list($a, $b) = each($this->me); |
|
3180 | 3180 | // contributed by I Sofer, 2001-03-24 |
3181 | 3181 | // add support for nested arrays to scalarval |
3182 | 3182 | // i've created a new method here, so as to |
3183 | 3183 | // preserve back compatibility |
3184 | 3184 | |
3185 | - if(is_array($b)) |
|
3185 | + if (is_array($b)) |
|
3186 | 3186 | { |
3187 | 3187 | @reset($b); |
3188 | - while(list($id,$cont) = @each($b)) |
|
3188 | + while (list($id, $cont) = @each($b)) |
|
3189 | 3189 | { |
3190 | 3190 | $b[$id] = $cont->scalarval(); |
3191 | 3191 | } |
3192 | 3192 | } |
3193 | 3193 | |
3194 | 3194 | // add support for structures directly encoding php objects |
3195 | - if(is_object($b)) |
|
3195 | + if (is_object($b)) |
|
3196 | 3196 | { |
3197 | 3197 | $t = get_object_vars($b); |
3198 | 3198 | @reset($t); |
3199 | - while(list($id,$cont) = @each($t)) |
|
3199 | + while (list($id, $cont) = @each($t)) |
|
3200 | 3200 | { |
3201 | 3201 | $t[$id] = $cont->scalarval(); |
3202 | 3202 | } |
3203 | 3203 | @reset($t); |
3204 | - while(list($id,$cont) = @each($t)) |
|
3204 | + while (list($id, $cont) = @each($t)) |
|
3205 | 3205 | { |
3206 | 3206 | @$b->$id = $cont; |
3207 | 3207 | } |
@@ -3218,7 +3218,7 @@ discard block |
||
3218 | 3218 | function scalarval() |
3219 | 3219 | { |
3220 | 3220 | reset($this->me); |
3221 | - list(,$b)=each($this->me); |
|
3221 | + list(,$b) = each($this->me); |
|
3222 | 3222 | return $b; |
3223 | 3223 | } |
3224 | 3224 | |
@@ -3231,10 +3231,10 @@ discard block |
||
3231 | 3231 | function scalartyp() |
3232 | 3232 | { |
3233 | 3233 | reset($this->me); |
3234 | - list($a,)=each($this->me); |
|
3235 | - if($a==$GLOBALS['xmlrpcI4']) |
|
3234 | + list($a,) = each($this->me); |
|
3235 | + if ($a == $GLOBALS['xmlrpcI4']) |
|
3236 | 3236 | { |
3237 | - $a=$GLOBALS['xmlrpcInt']; |
|
3237 | + $a = $GLOBALS['xmlrpcInt']; |
|
3238 | 3238 | } |
3239 | 3239 | return $a; |
3240 | 3240 | } |
@@ -3291,23 +3291,23 @@ discard block |
||
3291 | 3291 | * @param int $utc (0 or 1) |
3292 | 3292 | * @return string |
3293 | 3293 | */ |
3294 | - function iso8601_encode($timet, $utc=0) |
|
3294 | + function iso8601_encode($timet, $utc = 0) |
|
3295 | 3295 | { |
3296 | - if(!$utc) |
|
3296 | + if (!$utc) |
|
3297 | 3297 | { |
3298 | - $t=strftime("%Y%m%dT%H:%M:%S", $timet); |
|
3298 | + $t = strftime("%Y%m%dT%H:%M:%S", $timet); |
|
3299 | 3299 | } |
3300 | 3300 | else |
3301 | 3301 | { |
3302 | - if(function_exists('gmstrftime')) |
|
3302 | + if (function_exists('gmstrftime')) |
|
3303 | 3303 | { |
3304 | 3304 | // gmstrftime doesn't exist in some versions |
3305 | 3305 | // of PHP |
3306 | - $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet); |
|
3306 | + $t = gmstrftime("%Y%m%dT%H:%M:%S", $timet); |
|
3307 | 3307 | } |
3308 | 3308 | else |
3309 | 3309 | { |
3310 | - $t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z')); |
|
3310 | + $t = strftime("%Y%m%dT%H:%M:%S", $timet-date('Z')); |
|
3311 | 3311 | } |
3312 | 3312 | } |
3313 | 3313 | return $t; |
@@ -3319,18 +3319,18 @@ discard block |
||
3319 | 3319 | * @param int $utc either 0 or 1 |
3320 | 3320 | * @return int (datetime) |
3321 | 3321 | */ |
3322 | - function iso8601_decode($idate, $utc=0) |
|
3322 | + function iso8601_decode($idate, $utc = 0) |
|
3323 | 3323 | { |
3324 | - $t=0; |
|
3325 | - if(preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs)) |
|
3324 | + $t = 0; |
|
3325 | + if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs)) |
|
3326 | 3326 | { |
3327 | - if($utc) |
|
3327 | + if ($utc) |
|
3328 | 3328 | { |
3329 | - $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
3329 | + $t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
3330 | 3330 | } |
3331 | 3331 | else |
3332 | 3332 | { |
3333 | - $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
3333 | + $t = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
3334 | 3334 | } |
3335 | 3335 | } |
3336 | 3336 | return $t; |
@@ -3357,15 +3357,15 @@ discard block |
||
3357 | 3357 | * @param array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects; if 'dates_as_objects' is set xmlrpc datetimes are decoded as php DateTime objects (standard is |
3358 | 3358 | * @return mixed |
3359 | 3359 | */ |
3360 | - function php_xmlrpc_decode($xmlrpc_val, $options=array()) |
|
3360 | + function php_xmlrpc_decode($xmlrpc_val, $options = array()) |
|
3361 | 3361 | { |
3362 | - switch($xmlrpc_val->kindOf()) |
|
3362 | + switch ($xmlrpc_val->kindOf()) |
|
3363 | 3363 | { |
3364 | 3364 | case 'scalar': |
3365 | 3365 | if (in_array('extension_api', $options)) |
3366 | 3366 | { |
3367 | 3367 | reset($xmlrpc_val->me); |
3368 | - list($typ,$val) = each($xmlrpc_val->me); |
|
3368 | + list($typ, $val) = each($xmlrpc_val->me); |
|
3369 | 3369 | switch ($typ) |
3370 | 3370 | { |
3371 | 3371 | case 'dateTime.iso8601': |
@@ -3406,7 +3406,7 @@ discard block |
||
3406 | 3406 | case 'array': |
3407 | 3407 | $size = $xmlrpc_val->arraysize(); |
3408 | 3408 | $arr = array(); |
3409 | - for($i = 0; $i < $size; $i++) |
|
3409 | + for ($i = 0; $i<$size; $i++) |
|
3410 | 3410 | { |
3411 | 3411 | $arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options); |
3412 | 3412 | } |
@@ -3421,7 +3421,7 @@ discard block |
||
3421 | 3421 | && class_exists($xmlrpc_val->_php_class)) |
3422 | 3422 | { |
3423 | 3423 | $obj = @new $xmlrpc_val->_php_class; |
3424 | - while(list($key,$value)=$xmlrpc_val->structeach()) |
|
3424 | + while (list($key, $value) = $xmlrpc_val->structeach()) |
|
3425 | 3425 | { |
3426 | 3426 | $obj->$key = php_xmlrpc_decode($value, $options); |
3427 | 3427 | } |
@@ -3430,7 +3430,7 @@ discard block |
||
3430 | 3430 | else |
3431 | 3431 | { |
3432 | 3432 | $arr = array(); |
3433 | - while(list($key,$value)=$xmlrpc_val->structeach()) |
|
3433 | + while (list($key, $value) = $xmlrpc_val->structeach()) |
|
3434 | 3434 | { |
3435 | 3435 | $arr[$key] = php_xmlrpc_decode($value, $options); |
3436 | 3436 | } |
@@ -3439,7 +3439,7 @@ discard block |
||
3439 | 3439 | case 'msg': |
3440 | 3440 | $paramcount = $xmlrpc_val->getNumParams(); |
3441 | 3441 | $arr = array(); |
3442 | - for($i = 0; $i < $paramcount; $i++) |
|
3442 | + for ($i = 0; $i<$paramcount; $i++) |
|
3443 | 3443 | { |
3444 | 3444 | $arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i)); |
3445 | 3445 | } |
@@ -3450,13 +3450,13 @@ discard block |
||
3450 | 3450 | // This constant left here only for historical reasons... |
3451 | 3451 | // it was used to decide if we have to define xmlrpc_encode on our own, but |
3452 | 3452 | // we do not do it anymore |
3453 | - if(function_exists('xmlrpc_decode')) |
|
3453 | + if (function_exists('xmlrpc_decode')) |
|
3454 | 3454 | { |
3455 | - define('XMLRPC_EPI_ENABLED','1'); |
|
3455 | + define('XMLRPC_EPI_ENABLED', '1'); |
|
3456 | 3456 | } |
3457 | 3457 | else |
3458 | 3458 | { |
3459 | - define('XMLRPC_EPI_ENABLED','0'); |
|
3459 | + define('XMLRPC_EPI_ENABLED', '0'); |
|
3460 | 3460 | } |
3461 | 3461 | |
3462 | 3462 | /** |
@@ -3476,10 +3476,10 @@ discard block |
||
3476 | 3476 | * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api' |
3477 | 3477 | * @return xmlrpcval |
3478 | 3478 | */ |
3479 | - function php_xmlrpc_encode($php_val, $options=array()) |
|
3479 | + function php_xmlrpc_encode($php_val, $options = array()) |
|
3480 | 3480 | { |
3481 | 3481 | $type = gettype($php_val); |
3482 | - switch($type) |
|
3482 | + switch ($type) |
|
3483 | 3483 | { |
3484 | 3484 | case 'string': |
3485 | 3485 | if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) |
@@ -3508,16 +3508,16 @@ discard block |
||
3508 | 3508 | $j = 0; |
3509 | 3509 | $arr = array(); |
3510 | 3510 | $ko = false; |
3511 | - foreach($php_val as $key => $val) |
|
3511 | + foreach ($php_val as $key => $val) |
|
3512 | 3512 | { |
3513 | 3513 | $arr[$key] = php_xmlrpc_encode($val, $options); |
3514 | - if(!$ko && $key !== $j) |
|
3514 | + if (!$ko && $key !== $j) |
|
3515 | 3515 | { |
3516 | 3516 | $ko = true; |
3517 | 3517 | } |
3518 | 3518 | $j++; |
3519 | 3519 | } |
3520 | - if($ko) |
|
3520 | + if ($ko) |
|
3521 | 3521 | { |
3522 | 3522 | $xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']); |
3523 | 3523 | } |
@@ -3527,11 +3527,11 @@ discard block |
||
3527 | 3527 | } |
3528 | 3528 | break; |
3529 | 3529 | case 'object': |
3530 | - if(is_a($php_val, 'xmlrpcval')) |
|
3530 | + if (is_a($php_val, 'xmlrpcval')) |
|
3531 | 3531 | { |
3532 | 3532 | $xmlrpc_val = $php_val; |
3533 | 3533 | } |
3534 | - else if(is_a($php_val, 'DateTime')) |
|
3534 | + else if (is_a($php_val, 'DateTime')) |
|
3535 | 3535 | { |
3536 | 3536 | $xmlrpc_val = new xmlrpcval($php_val->format('Ymd\TH:i:s'), $GLOBALS['xmlrpcStruct']); |
3537 | 3537 | } |
@@ -3539,7 +3539,7 @@ discard block |
||
3539 | 3539 | { |
3540 | 3540 | $arr = array(); |
3541 | 3541 | reset($php_val); |
3542 | - while(list($k,$v) = each($php_val)) |
|
3542 | + while (list($k, $v) = each($php_val)) |
|
3543 | 3543 | { |
3544 | 3544 | $arr[$k] = php_xmlrpc_encode($v, $options); |
3545 | 3545 | } |
@@ -3569,7 +3569,7 @@ discard block |
||
3569 | 3569 | case 'resource': |
3570 | 3570 | if (in_array('extension_api', $options)) |
3571 | 3571 | { |
3572 | - $xmlrpc_val = new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']); |
|
3572 | + $xmlrpc_val = new xmlrpcval((int) $php_val, $GLOBALS['xmlrpcInt']); |
|
3573 | 3573 | } |
3574 | 3574 | else |
3575 | 3575 | { |
@@ -3593,7 +3593,7 @@ discard block |
||
3593 | 3593 | * @param array $options |
3594 | 3594 | * @return mixed false on error, or an instance of either xmlrpcval, xmlrpcmsg or xmlrpcresp |
3595 | 3595 | */ |
3596 | - function php_xmlrpc_decode_xml($xml_val, $options=array()) |
|
3596 | + function php_xmlrpc_decode_xml($xml_val, $options = array()) |
|
3597 | 3597 | { |
3598 | 3598 | $GLOBALS['_xh'] = array(); |
3599 | 3599 | $GLOBALS['_xh']['ac'] = ''; |
@@ -3621,7 +3621,7 @@ discard block |
||
3621 | 3621 | if (extension_loaded('mbstring')) { |
3622 | 3622 | $xml_val = mb_convert_encoding($xml_val, 'UTF-8', $val_encoding); |
3623 | 3623 | } else { |
3624 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $val_encoding); |
|
3624 | + error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$val_encoding); |
|
3625 | 3625 | } |
3626 | 3626 | } |
3627 | 3627 | } |
@@ -3641,7 +3641,7 @@ discard block |
||
3641 | 3641 | xml_set_element_handler($parser, 'xmlrpc_se_any', 'xmlrpc_ee'); |
3642 | 3642 | xml_set_character_data_handler($parser, 'xmlrpc_cd'); |
3643 | 3643 | xml_set_default_handler($parser, 'xmlrpc_dh'); |
3644 | - if(!xml_parse($parser, $xml_val, 1)) |
|
3644 | + if (!xml_parse($parser, $xml_val, 1)) |
|
3645 | 3645 | { |
3646 | 3646 | $errstr = sprintf('XML error: %s at line %d, column %d', |
3647 | 3647 | xml_error_string(xml_get_error_code($parser)), |
@@ -3651,7 +3651,7 @@ discard block |
||
3651 | 3651 | return false; |
3652 | 3652 | } |
3653 | 3653 | xml_parser_free($parser); |
3654 | - if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too??? |
|
3654 | + if ($GLOBALS['_xh']['isf']>1) // test that $GLOBALS['_xh']['value'] is an obj, too??? |
|
3655 | 3655 | { |
3656 | 3656 | error_log($GLOBALS['_xh']['isf_reason']); |
3657 | 3657 | return false; |
@@ -3659,7 +3659,7 @@ discard block |
||
3659 | 3659 | switch ($GLOBALS['_xh']['rt']) |
3660 | 3660 | { |
3661 | 3661 | case 'methodresponse': |
3662 | - $v =& $GLOBALS['_xh']['value']; |
|
3662 | + $v = & $GLOBALS['_xh']['value']; |
|
3663 | 3663 | if ($GLOBALS['_xh']['isf'] == 1) |
3664 | 3664 | { |
3665 | 3665 | $vc = $v->structmem('faultCode'); |
@@ -3673,7 +3673,7 @@ discard block |
||
3673 | 3673 | return $r; |
3674 | 3674 | case 'methodcall': |
3675 | 3675 | $m = new xmlrpcmsg($GLOBALS['_xh']['method']); |
3676 | - for($i=0; $i < count($GLOBALS['_xh']['params']); $i++) |
|
3676 | + for ($i = 0; $i<count($GLOBALS['_xh']['params']); $i++) |
|
3677 | 3677 | { |
3678 | 3678 | $m->addParam($GLOBALS['_xh']['params'][$i]); |
3679 | 3679 | } |
@@ -3701,18 +3701,18 @@ discard block |
||
3701 | 3701 | |
3702 | 3702 | // read chunk-size, chunk-extension (if any) and crlf |
3703 | 3703 | // get the position of the linebreak |
3704 | - $chunkend = strpos($buffer,"\r\n") + 2; |
|
3705 | - $temp = substr($buffer,0,$chunkend); |
|
3706 | - $chunk_size = hexdec( trim($temp) ); |
|
3704 | + $chunkend = strpos($buffer, "\r\n")+2; |
|
3705 | + $temp = substr($buffer, 0, $chunkend); |
|
3706 | + $chunk_size = hexdec(trim($temp)); |
|
3707 | 3707 | $chunkstart = $chunkend; |
3708 | - while($chunk_size > 0) |
|
3708 | + while ($chunk_size>0) |
|
3709 | 3709 | { |
3710 | - $chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size); |
|
3710 | + $chunkend = strpos($buffer, "\r\n", $chunkstart+$chunk_size); |
|
3711 | 3711 | |
3712 | 3712 | // just in case we got a broken connection |
3713 | - if($chunkend == false) |
|
3713 | + if ($chunkend == false) |
|
3714 | 3714 | { |
3715 | - $chunk = substr($buffer,$chunkstart); |
|
3715 | + $chunk = substr($buffer, $chunkstart); |
|
3716 | 3716 | // append chunk-data to entity-body |
3717 | 3717 | $new .= $chunk; |
3718 | 3718 | $length += strlen($chunk); |
@@ -3720,21 +3720,21 @@ discard block |
||
3720 | 3720 | } |
3721 | 3721 | |
3722 | 3722 | // read chunk-data and crlf |
3723 | - $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); |
|
3723 | + $chunk = substr($buffer, $chunkstart, $chunkend-$chunkstart); |
|
3724 | 3724 | // append chunk-data to entity-body |
3725 | 3725 | $new .= $chunk; |
3726 | 3726 | // length := length + chunk-size |
3727 | 3727 | $length += strlen($chunk); |
3728 | 3728 | // read chunk-size and crlf |
3729 | - $chunkstart = $chunkend + 2; |
|
3729 | + $chunkstart = $chunkend+2; |
|
3730 | 3730 | |
3731 | - $chunkend = strpos($buffer,"\r\n",$chunkstart)+2; |
|
3732 | - if($chunkend == false) |
|
3731 | + $chunkend = strpos($buffer, "\r\n", $chunkstart)+2; |
|
3732 | + if ($chunkend == false) |
|
3733 | 3733 | { |
3734 | 3734 | break; //just in case we got a broken connection |
3735 | 3735 | } |
3736 | - $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart); |
|
3737 | - $chunk_size = hexdec( trim($temp) ); |
|
3736 | + $temp = substr($buffer, $chunkstart, $chunkend-$chunkstart); |
|
3737 | + $chunk_size = hexdec(trim($temp)); |
|
3738 | 3738 | $chunkstart = $chunkend; |
3739 | 3739 | } |
3740 | 3740 | return $new; |
@@ -3754,7 +3754,7 @@ discard block |
||
3754 | 3754 | * |
3755 | 3755 | * @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!! |
3756 | 3756 | */ |
3757 | - function guess_encoding($httpheader='', $xmlchunk='', $encoding_prefs=null) |
|
3757 | + function guess_encoding($httpheader = '', $xmlchunk = '', $encoding_prefs = null) |
|
3758 | 3758 | { |
3759 | 3759 | // discussion: see http://www.yale.edu/pclt/encoding/ |
3760 | 3760 | // 1 - test if encoding is specified in HTTP HEADERS |
@@ -3772,7 +3772,7 @@ discard block |
||
3772 | 3772 | |
3773 | 3773 | /// @todo this test will pass if ANY header has charset specification, not only Content-Type. Fix it? |
3774 | 3774 | $matches = array(); |
3775 | - if(preg_match('/;\s*charset\s*=([^;]+)/i', $httpheader, $matches)) |
|
3775 | + if (preg_match('/;\s*charset\s*=([^;]+)/i', $httpheader, $matches)) |
|
3776 | 3776 | { |
3777 | 3777 | return strtoupper(trim($matches[1], " \t\"")); |
3778 | 3778 | } |
@@ -3784,15 +3784,15 @@ discard block |
||
3784 | 3784 | // in the xml declaration, and verify if they match. |
3785 | 3785 | /// @todo implement check as described above? |
3786 | 3786 | /// @todo implement check for first bytes of string even without a BOM? (It sure looks harder than for cases WITH a BOM) |
3787 | - if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk)) |
|
3787 | + if (preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk)) |
|
3788 | 3788 | { |
3789 | 3789 | return 'UCS-4'; |
3790 | 3790 | } |
3791 | - elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk)) |
|
3791 | + elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk)) |
|
3792 | 3792 | { |
3793 | 3793 | return 'UTF-16'; |
3794 | 3794 | } |
3795 | - elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk)) |
|
3795 | + elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk)) |
|
3796 | 3796 | { |
3797 | 3797 | return 'UTF-8'; |
3798 | 3798 | } |
@@ -3801,8 +3801,8 @@ discard block |
||
3801 | 3801 | // Details: |
3802 | 3802 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
3803 | 3803 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
3804 | - if (preg_match('/^<\?xml\s+version\s*=\s*'. "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
3805 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
3804 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
3805 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
3806 | 3806 | $xmlchunk, $matches)) |
3807 | 3807 | { |
3808 | 3808 | return strtoupper(substr($matches[2], 1, -1)); |
@@ -3810,9 +3810,9 @@ discard block |
||
3810 | 3810 | |
3811 | 3811 | // 4 - if mbstring is available, let it do the guesswork |
3812 | 3812 | // NB: we favour finding an encoding that is compatible with what we can process |
3813 | - if(extension_loaded('mbstring')) |
|
3813 | + if (extension_loaded('mbstring')) |
|
3814 | 3814 | { |
3815 | - if($encoding_prefs) |
|
3815 | + if ($encoding_prefs) |
|
3816 | 3816 | { |
3817 | 3817 | $enc = mb_detect_encoding($xmlchunk, $encoding_prefs); |
3818 | 3818 | } |
@@ -3822,7 +3822,7 @@ discard block |
||
3822 | 3822 | } |
3823 | 3823 | // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... |
3824 | 3824 | // IANA also likes better US-ASCII, so go with it |
3825 | - if($enc == 'ASCII') |
|
3825 | + if ($enc == 'ASCII') |
|
3826 | 3826 | { |
3827 | 3827 | $enc = 'US-'.$enc; |
3828 | 3828 | } |
@@ -3865,8 +3865,8 @@ discard block |
||
3865 | 3865 | // Details: |
3866 | 3866 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
3867 | 3867 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
3868 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
3869 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
3868 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
3869 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
3870 | 3870 | $xmlChunk, $matches)) |
3871 | 3871 | { |
3872 | 3872 | return true; |
@@ -3885,7 +3885,7 @@ discard block |
||
3885 | 3885 | function is_valid_charset($encoding, $validlist) |
3886 | 3886 | { |
3887 | 3887 | $charset_supersets = array( |
3888 | - 'US-ASCII' => array ('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', |
|
3888 | + 'US-ASCII' => array('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', |
|
3889 | 3889 | 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', |
3890 | 3890 | 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-12', |
3891 | 3891 | 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8', |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | /* Functions that implement system.XXX methods of xmlrpc servers */ |
60 | - $_xmlrpcs_getCapabilities_sig=array(array($GLOBALS['xmlrpcStruct'])); |
|
61 | - $_xmlrpcs_getCapabilities_doc='This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to'; |
|
62 | - $_xmlrpcs_getCapabilities_sdoc=array(array('list of capabilities, described as structs with a version number and url for the spec')); |
|
63 | - function _xmlrpcs_getCapabilities($server, $m=null) |
|
60 | + $_xmlrpcs_getCapabilities_sig = array(array($GLOBALS['xmlrpcStruct'])); |
|
61 | + $_xmlrpcs_getCapabilities_doc = 'This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to'; |
|
62 | + $_xmlrpcs_getCapabilities_sdoc = array(array('list of capabilities, described as structs with a version number and url for the spec')); |
|
63 | + function _xmlrpcs_getCapabilities($server, $m = null) |
|
64 | 64 | { |
65 | 65 | $outAr = $GLOBALS['xmlrpcs_capabilities']; |
66 | 66 | // NIL extension |
@@ -75,117 +75,117 @@ discard block |
||
75 | 75 | |
76 | 76 | // listMethods: signature was either a string, or nothing. |
77 | 77 | // The useless string variant has been removed |
78 | - $_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray'])); |
|
79 | - $_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch'; |
|
80 | - $_xmlrpcs_listMethods_sdoc=array(array('list of method names')); |
|
81 | - function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing |
|
78 | + $_xmlrpcs_listMethods_sig = array(array($GLOBALS['xmlrpcArray'])); |
|
79 | + $_xmlrpcs_listMethods_doc = 'This method lists all the methods that the XML-RPC server knows how to dispatch'; |
|
80 | + $_xmlrpcs_listMethods_sdoc = array(array('list of method names')); |
|
81 | + function _xmlrpcs_listMethods($server, $m = null) // if called in plain php values mode, second param is missing |
|
82 | 82 | { |
83 | 83 | |
84 | - $outAr=array(); |
|
85 | - foreach($server->dmap as $key => $val) |
|
84 | + $outAr = array(); |
|
85 | + foreach ($server->dmap as $key => $val) |
|
86 | 86 | { |
87 | - $outAr[]=new xmlrpcval($key, 'string'); |
|
87 | + $outAr[] = new xmlrpcval($key, 'string'); |
|
88 | 88 | } |
89 | - if($server->allow_system_funcs) |
|
89 | + if ($server->allow_system_funcs) |
|
90 | 90 | { |
91 | - foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val) |
|
91 | + foreach ($GLOBALS['_xmlrpcs_dmap'] as $key => $val) |
|
92 | 92 | { |
93 | - $outAr[]=new xmlrpcval($key, 'string'); |
|
93 | + $outAr[] = new xmlrpcval($key, 'string'); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | return new xmlrpcresp(new xmlrpcval($outAr, 'array')); |
97 | 97 | } |
98 | 98 | |
99 | - $_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString'])); |
|
100 | - $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; |
|
101 | - $_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); |
|
99 | + $_xmlrpcs_methodSignature_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString'])); |
|
100 | + $_xmlrpcs_methodSignature_doc = 'Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; |
|
101 | + $_xmlrpcs_methodSignature_sdoc = array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); |
|
102 | 102 | function _xmlrpcs_methodSignature($server, $m) |
103 | 103 | { |
104 | 104 | // let accept as parameter both an xmlrpcval or string |
105 | 105 | if (is_object($m)) |
106 | 106 | { |
107 | - $methName=$m->getParam(0); |
|
108 | - $methName=$methName->scalarval(); |
|
107 | + $methName = $m->getParam(0); |
|
108 | + $methName = $methName->scalarval(); |
|
109 | 109 | } |
110 | 110 | else |
111 | 111 | { |
112 | - $methName=$m; |
|
112 | + $methName = $m; |
|
113 | 113 | } |
114 | - if(strpos($methName, "system.") === 0) |
|
114 | + if (strpos($methName, "system.") === 0) |
|
115 | 115 | { |
116 | - $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; |
|
116 | + $dmap = $GLOBALS['_xmlrpcs_dmap']; $sysCall = 1; |
|
117 | 117 | } |
118 | 118 | else |
119 | 119 | { |
120 | - $dmap=$server->dmap; $sysCall=0; |
|
120 | + $dmap = $server->dmap; $sysCall = 0; |
|
121 | 121 | } |
122 | - if(isset($dmap[$methName])) |
|
122 | + if (isset($dmap[$methName])) |
|
123 | 123 | { |
124 | - if(isset($dmap[$methName]['signature'])) |
|
124 | + if (isset($dmap[$methName]['signature'])) |
|
125 | 125 | { |
126 | - $sigs=array(); |
|
127 | - foreach($dmap[$methName]['signature'] as $inSig) |
|
126 | + $sigs = array(); |
|
127 | + foreach ($dmap[$methName]['signature'] as $inSig) |
|
128 | 128 | { |
129 | - $cursig=array(); |
|
130 | - foreach($inSig as $sig) |
|
129 | + $cursig = array(); |
|
130 | + foreach ($inSig as $sig) |
|
131 | 131 | { |
132 | - $cursig[]=new xmlrpcval($sig, 'string'); |
|
132 | + $cursig[] = new xmlrpcval($sig, 'string'); |
|
133 | 133 | } |
134 | - $sigs[]=new xmlrpcval($cursig, 'array'); |
|
134 | + $sigs[] = new xmlrpcval($cursig, 'array'); |
|
135 | 135 | } |
136 | - $r=new xmlrpcresp(new xmlrpcval($sigs, 'array')); |
|
136 | + $r = new xmlrpcresp(new xmlrpcval($sigs, 'array')); |
|
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | 140 | // NB: according to the official docs, we should be returning a |
141 | 141 | // "none-array" here, which means not-an-array |
142 | - $r=new xmlrpcresp(new xmlrpcval('undef', 'string')); |
|
142 | + $r = new xmlrpcresp(new xmlrpcval('undef', 'string')); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | else |
146 | 146 | { |
147 | - $r=new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); |
|
147 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); |
|
148 | 148 | } |
149 | 149 | return $r; |
150 | 150 | } |
151 | 151 | |
152 | - $_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); |
|
153 | - $_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string'; |
|
154 | - $_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described')); |
|
152 | + $_xmlrpcs_methodHelp_sig = array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); |
|
153 | + $_xmlrpcs_methodHelp_doc = 'Returns help text if defined for the method passed, otherwise returns an empty string'; |
|
154 | + $_xmlrpcs_methodHelp_sdoc = array(array('method description', 'name of the method to be described')); |
|
155 | 155 | function _xmlrpcs_methodHelp($server, $m) |
156 | 156 | { |
157 | 157 | // let accept as parameter both an xmlrpcval or string |
158 | 158 | if (is_object($m)) |
159 | 159 | { |
160 | - $methName=$m->getParam(0); |
|
161 | - $methName=$methName->scalarval(); |
|
160 | + $methName = $m->getParam(0); |
|
161 | + $methName = $methName->scalarval(); |
|
162 | 162 | } |
163 | 163 | else |
164 | 164 | { |
165 | - $methName=$m; |
|
165 | + $methName = $m; |
|
166 | 166 | } |
167 | - if(strpos($methName, "system.") === 0) |
|
167 | + if (strpos($methName, "system.") === 0) |
|
168 | 168 | { |
169 | - $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; |
|
169 | + $dmap = $GLOBALS['_xmlrpcs_dmap']; $sysCall = 1; |
|
170 | 170 | } |
171 | 171 | else |
172 | 172 | { |
173 | - $dmap=$server->dmap; $sysCall=0; |
|
173 | + $dmap = $server->dmap; $sysCall = 0; |
|
174 | 174 | } |
175 | - if(isset($dmap[$methName])) |
|
175 | + if (isset($dmap[$methName])) |
|
176 | 176 | { |
177 | - if(isset($dmap[$methName]['docstring'])) |
|
177 | + if (isset($dmap[$methName]['docstring'])) |
|
178 | 178 | { |
179 | - $r=new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string'); |
|
179 | + $r = new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string'); |
|
180 | 180 | } |
181 | 181 | else |
182 | 182 | { |
183 | - $r=new xmlrpcresp(new xmlrpcval('', 'string')); |
|
183 | + $r = new xmlrpcresp(new xmlrpcval('', 'string')); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | else |
187 | 187 | { |
188 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); |
|
188 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); |
|
189 | 189 | } |
190 | 190 | return $r; |
191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"')); |
196 | 196 | function _xmlrpcs_multicall_error($err) |
197 | 197 | { |
198 | - if(is_string($err)) |
|
198 | + if (is_string($err)) |
|
199 | 199 | { |
200 | 200 | $str = $GLOBALS['xmlrpcstr']["multicall_${err}"]; |
201 | 201 | $code = $GLOBALS['xmlrpcerr']["multicall_${err}"]; |
@@ -213,52 +213,52 @@ discard block |
||
213 | 213 | |
214 | 214 | function _xmlrpcs_multicall_do_call($server, $call) |
215 | 215 | { |
216 | - if($call->kindOf() != 'struct') |
|
216 | + if ($call->kindOf() != 'struct') |
|
217 | 217 | { |
218 | 218 | return _xmlrpcs_multicall_error('notstruct'); |
219 | 219 | } |
220 | 220 | $methName = @$call->structmem('methodName'); |
221 | - if(!$methName) |
|
221 | + if (!$methName) |
|
222 | 222 | { |
223 | 223 | return _xmlrpcs_multicall_error('nomethod'); |
224 | 224 | } |
225 | - if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') |
|
225 | + if ($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') |
|
226 | 226 | { |
227 | 227 | return _xmlrpcs_multicall_error('notstring'); |
228 | 228 | } |
229 | - if($methName->scalarval() == 'system.multicall') |
|
229 | + if ($methName->scalarval() == 'system.multicall') |
|
230 | 230 | { |
231 | 231 | return _xmlrpcs_multicall_error('recursion'); |
232 | 232 | } |
233 | 233 | |
234 | 234 | $params = @$call->structmem('params'); |
235 | - if(!$params) |
|
235 | + if (!$params) |
|
236 | 236 | { |
237 | 237 | return _xmlrpcs_multicall_error('noparams'); |
238 | 238 | } |
239 | - if($params->kindOf() != 'array') |
|
239 | + if ($params->kindOf() != 'array') |
|
240 | 240 | { |
241 | 241 | return _xmlrpcs_multicall_error('notarray'); |
242 | 242 | } |
243 | 243 | $numParams = $params->arraysize(); |
244 | 244 | |
245 | 245 | $msg = new xmlrpcmsg($methName->scalarval()); |
246 | - for($i = 0; $i < $numParams; $i++) |
|
246 | + for ($i = 0; $i<$numParams; $i++) |
|
247 | 247 | { |
248 | - if(!$msg->addParam($params->arraymem($i))) |
|
248 | + if (!$msg->addParam($params->arraymem($i))) |
|
249 | 249 | { |
250 | 250 | $i++; |
251 | 251 | return _xmlrpcs_multicall_error(new xmlrpcresp(0, |
252 | 252 | $GLOBALS['xmlrpcerr']['incorrect_params'], |
253 | - $GLOBALS['xmlrpcstr']['incorrect_params'] . ": probable xml error in param " . $i)); |
|
253 | + $GLOBALS['xmlrpcstr']['incorrect_params'].": probable xml error in param ".$i)); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | 257 | $result = $server->execute($msg); |
258 | 258 | |
259 | - if($result->faultCode() != 0) |
|
259 | + if ($result->faultCode() != 0) |
|
260 | 260 | { |
261 | - return _xmlrpcs_multicall_error($result); // Method returned fault. |
|
261 | + return _xmlrpcs_multicall_error($result); // Method returned fault. |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | return new xmlrpcval(array($result->value()), 'array'); |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | |
267 | 267 | function _xmlrpcs_multicall_do_call_phpvals($server, $call) |
268 | 268 | { |
269 | - if(!is_array($call)) |
|
269 | + if (!is_array($call)) |
|
270 | 270 | { |
271 | 271 | return _xmlrpcs_multicall_error('notstruct'); |
272 | 272 | } |
273 | - if(!array_key_exists('methodName', $call)) |
|
273 | + if (!array_key_exists('methodName', $call)) |
|
274 | 274 | { |
275 | 275 | return _xmlrpcs_multicall_error('nomethod'); |
276 | 276 | } |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | { |
279 | 279 | return _xmlrpcs_multicall_error('notstring'); |
280 | 280 | } |
281 | - if($call['methodName'] == 'system.multicall') |
|
281 | + if ($call['methodName'] == 'system.multicall') |
|
282 | 282 | { |
283 | 283 | return _xmlrpcs_multicall_error('recursion'); |
284 | 284 | } |
285 | - if(!array_key_exists('params', $call)) |
|
285 | + if (!array_key_exists('params', $call)) |
|
286 | 286 | { |
287 | 287 | return _xmlrpcs_multicall_error('noparams'); |
288 | 288 | } |
289 | - if(!is_array($call['params'])) |
|
289 | + if (!is_array($call['params'])) |
|
290 | 290 | { |
291 | 291 | return _xmlrpcs_multicall_error('notarray'); |
292 | 292 | } |
@@ -295,14 +295,14 @@ discard block |
||
295 | 295 | // base64 or datetime values, but they will be listed as strings here... |
296 | 296 | $numParams = count($call['params']); |
297 | 297 | $pt = array(); |
298 | - foreach($call['params'] as $val) |
|
298 | + foreach ($call['params'] as $val) |
|
299 | 299 | $pt[] = php_2_xmlrpc_type(gettype($val)); |
300 | 300 | |
301 | 301 | $result = $server->execute($call['methodName'], $call['params'], $pt); |
302 | 302 | |
303 | - if($result->faultCode() != 0) |
|
303 | + if ($result->faultCode() != 0) |
|
304 | 304 | { |
305 | - return _xmlrpcs_multicall_error($result); // Method returned fault. |
|
305 | + return _xmlrpcs_multicall_error($result); // Method returned fault. |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | return new xmlrpcval(array($result->value()), 'array'); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | { |
317 | 317 | $calls = $m->getParam(0); |
318 | 318 | $numCalls = $calls->arraysize(); |
319 | - for($i = 0; $i < $numCalls; $i++) |
|
319 | + for ($i = 0; $i<$numCalls; $i++) |
|
320 | 320 | { |
321 | 321 | $call = $calls->arraymem($i); |
322 | 322 | $result[$i] = _xmlrpcs_multicall_do_call($server, $call); |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | } |
325 | 325 | else |
326 | 326 | { |
327 | - $numCalls=count($m); |
|
328 | - for($i = 0; $i < $numCalls; $i++) |
|
327 | + $numCalls = count($m); |
|
328 | + for ($i = 0; $i<$numCalls; $i++) |
|
329 | 329 | { |
330 | 330 | $result[$i] = _xmlrpcs_multicall_do_call_phpvals($server, $m[$i]); |
331 | 331 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | return new xmlrpcresp(new xmlrpcval($result, 'array')); |
335 | 335 | } |
336 | 336 | |
337 | - $GLOBALS['_xmlrpcs_dmap']=array( |
|
337 | + $GLOBALS['_xmlrpcs_dmap'] = array( |
|
338 | 338 | 'system.listMethods' => array( |
339 | 339 | 'function' => '_xmlrpcs_listMethods', |
340 | 340 | 'signature' => $_xmlrpcs_listMethods_sig, |
@@ -374,24 +374,24 @@ discard block |
||
374 | 374 | * NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors. |
375 | 375 | * |
376 | 376 | */ |
377 | - function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null) |
|
377 | + function _xmlrpcs_errorHandler($errcode, $errstring, $filename = null, $lineno = null, $context = null) |
|
378 | 378 | { |
379 | 379 | // obey the @ protocol |
380 | 380 | if (error_reporting() == 0) |
381 | 381 | return; |
382 | 382 | |
383 | 383 | //if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING) |
384 | - if($errcode != E_STRICT) |
|
384 | + if ($errcode != E_STRICT) |
|
385 | 385 | { |
386 | - $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n"; |
|
386 | + $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'].$errstring."\n"; |
|
387 | 387 | } |
388 | 388 | // Try to avoid as much as possible disruption to the previous error handling |
389 | 389 | // mechanism in place |
390 | - if($GLOBALS['_xmlrpcs_prev_ehandler'] == '') |
|
390 | + if ($GLOBALS['_xmlrpcs_prev_ehandler'] == '') |
|
391 | 391 | { |
392 | 392 | // The previous error handler was the default: all we should do is log error |
393 | 393 | // to the default error log (if level high enough) |
394 | - if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) |
|
394 | + if (ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) |
|
395 | 395 | { |
396 | 396 | error_log($errstring); |
397 | 397 | } |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | else |
400 | 400 | { |
401 | 401 | // Pass control on to previous error handler, trying to avoid loops... |
402 | - if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') |
|
402 | + if ($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') |
|
403 | 403 | { |
404 | 404 | // NB: this code will NOT work on php < 4.0.2: only 2 params were used for error handlers |
405 | - if(is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) |
|
405 | + if (is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) |
|
406 | 406 | { |
407 | 407 | // the following works both with static class methods and plain object methods as error handler |
408 | 408 | call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context)); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | - $GLOBALS['_xmlrpc_debuginfo']=''; |
|
418 | + $GLOBALS['_xmlrpc_debuginfo'] = ''; |
|
419 | 419 | |
420 | 420 | /** |
421 | 421 | * Add a string to the debug info that can be later seralized by the server |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | */ |
428 | 428 | function xmlrpc_debugmsg($m) |
429 | 429 | { |
430 | - $GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n"; |
|
430 | + $GLOBALS['_xmlrpc_debuginfo'] .= $m."\n"; |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | class xmlrpc_server |
@@ -436,20 +436,20 @@ discard block |
||
436 | 436 | * Array defining php functions exposed as xmlrpc methods by this server |
437 | 437 | * @access private |
438 | 438 | */ |
439 | - var $dmap=array(); |
|
439 | + var $dmap = array(); |
|
440 | 440 | /** |
441 | 441 | * Defines how functions in dmap will be invoked: either using an xmlrpc msg object |
442 | 442 | * or plain php values. |
443 | 443 | * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals' |
444 | 444 | */ |
445 | - var $functions_parameters_type='xmlrpcvals'; |
|
445 | + var $functions_parameters_type = 'xmlrpcvals'; |
|
446 | 446 | /** |
447 | 447 | * Option used for fine-tuning the encoding the php values returned from |
448 | 448 | * functions registered in the dispatch map when the functions_parameters_types |
449 | 449 | * member is set to 'phpvals' |
450 | 450 | * @see php_xmlrpc_encode for a list of values |
451 | 451 | */ |
452 | - var $phpvals_encoding_options = array( 'auto_dates' ); |
|
452 | + var $phpvals_encoding_options = array('auto_dates'); |
|
453 | 453 | /// controls whether the server is going to echo debugging messages back to the client as comments in response body. valid values: 0,1,2,3 |
454 | 454 | var $debug = 1; |
455 | 455 | /** |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | * @param array $dispmap the dispatch map with definition of exposed services |
498 | 498 | * @param boolean $servicenow set to false to prevent the server from running upon construction |
499 | 499 | */ |
500 | - function __construct($dispMap=null, $serviceNow=true) |
|
500 | + function __construct($dispMap = null, $serviceNow = true) |
|
501 | 501 | { |
502 | 502 | // if ZLIB is enabled, let the server by default accept compressed requests, |
503 | 503 | // and compress responses sent to clients that support them |
504 | - if(function_exists('gzinflate')) |
|
504 | + if (function_exists('gzinflate')) |
|
505 | 505 | { |
506 | 506 | $this->accepted_compression = array('gzip', 'deflate'); |
507 | 507 | $this->compress_response = true; |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | * instead, you can use the class add_to_map() function |
520 | 520 | * to add functions manually (borrowed from SOAPX4) |
521 | 521 | */ |
522 | - if($dispMap) |
|
522 | + if ($dispMap) |
|
523 | 523 | { |
524 | 524 | $this->dmap = $dispMap; |
525 | - if($serviceNow) |
|
525 | + if ($serviceNow) |
|
526 | 526 | { |
527 | 527 | $this->service(); |
528 | 528 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | /** |
533 | 533 | * @deprecated |
534 | 534 | */ |
535 | - function xmlrpc_client($dispMap=null, $serviceNow=true) |
|
535 | + function xmlrpc_client($dispMap = null, $serviceNow = true) |
|
536 | 536 | { |
537 | 537 | self::__construct($dispMap, $serviceNow); |
538 | 538 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | function setDebug($in) |
555 | 555 | { |
556 | - $this->debug=$in; |
|
556 | + $this->debug = $in; |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * @param string $charset_encoding the target charset encoding for the serialization |
562 | 562 | * @return string an XML comment (or two) |
563 | 563 | */ |
564 | - function serializeDebug($charset_encoding='') |
|
564 | + function serializeDebug($charset_encoding = '') |
|
565 | 565 | { |
566 | 566 | // Tough encoding problem: which internal charset should we assume for debug info? |
567 | 567 | // It might contain a copy of raw data received from client, ie with unknown encoding, |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | { |
574 | 574 | $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; |
575 | 575 | } |
576 | - if($GLOBALS['_xmlrpc_debuginfo']!='') |
|
576 | + if ($GLOBALS['_xmlrpc_debuginfo'] != '') |
|
577 | 577 | { |
578 | 578 | |
579 | - $out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n"; |
|
579 | + $out .= "<!-- DEBUG INFO:\n".xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."\n-->\n"; |
|
580 | 580 | // NB: a better solution MIGHT be to use CDATA, but we need to insert it |
581 | 581 | // into return payload AFTER the beginning tag |
582 | 582 | //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n"; |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @return xmlrpcresp the response object (usually not used by caller...) |
591 | 591 | * @access public |
592 | 592 | */ |
593 | - function service($data=null, $return_payload=false) |
|
593 | + function service($data = null, $return_payload = false) |
|
594 | 594 | { |
595 | 595 | if ($data === null) |
596 | 596 | { |
@@ -603,30 +603,30 @@ discard block |
||
603 | 603 | $this->debug_info = ''; |
604 | 604 | |
605 | 605 | // Echo back what we received, before parsing it |
606 | - if($this->debug > 1) |
|
606 | + if ($this->debug>1) |
|
607 | 607 | { |
608 | - $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); |
|
608 | + $this->debugmsg("+++GOT+++\n".$data."\n+++END+++"); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding); |
612 | 612 | if (!$r) |
613 | 613 | { |
614 | - $r=$this->parseRequest($data, $req_charset); |
|
614 | + $r = $this->parseRequest($data, $req_charset); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | // save full body of request into response, for more debugging usages |
618 | 618 | $r->raw_data = $raw_data; |
619 | 619 | |
620 | - if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) |
|
620 | + if ($this->debug>2 && $GLOBALS['_xmlrpcs_occurred_errors']) |
|
621 | 621 | { |
622 | - $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . |
|
623 | - $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++"); |
|
622 | + $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n". |
|
623 | + $GLOBALS['_xmlrpcs_occurred_errors']."+++END+++"); |
|
624 | 624 | } |
625 | 625 | |
626 | - $payload=$this->xml_header($resp_charset); |
|
627 | - if($this->debug > 0) |
|
626 | + $payload = $this->xml_header($resp_charset); |
|
627 | + if ($this->debug>0) |
|
628 | 628 | { |
629 | - $payload = $payload . $this->serializeDebug($resp_charset); |
|
629 | + $payload = $payload.$this->serializeDebug($resp_charset); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | // G. Giunta 2006-01-27: do not create response serialization if it has |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | { |
636 | 636 | $r->serialize($resp_charset); |
637 | 637 | } |
638 | - $payload = $payload . $r->payload; |
|
638 | + $payload = $payload.$r->payload; |
|
639 | 639 | |
640 | 640 | if ($return_payload) |
641 | 641 | { |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | // if we get a warning/error that has output some text before here, then we cannot |
646 | 646 | // add a new header. We cannot say we are sending xml, either... |
647 | - if(!headers_sent()) |
|
647 | + if (!headers_sent()) |
|
648 | 648 | { |
649 | 649 | header('Content-Type: '.$r->content_type); |
650 | 650 | // we do not know if client actually told us an accepted charset, but if he did |
@@ -655,10 +655,10 @@ discard block |
||
655 | 655 | // if we can do it, and we want to do it, and client asked us to, |
656 | 656 | // and php ini settings do not force it already |
657 | 657 | $php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'); |
658 | - if($this->compress_response && function_exists('gzencode') && $resp_encoding != '' |
|
658 | + if ($this->compress_response && function_exists('gzencode') && $resp_encoding != '' |
|
659 | 659 | && $php_no_self_compress) |
660 | 660 | { |
661 | - if(strpos($resp_encoding, 'gzip') !== false) |
|
661 | + if (strpos($resp_encoding, 'gzip') !== false) |
|
662 | 662 | { |
663 | 663 | $payload = gzencode($payload); |
664 | 664 | header("Content-Encoding: gzip"); |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | |
675 | 675 | // do not ouput content-length header if php is compressing output for us: |
676 | 676 | // it will mess up measurements |
677 | - if($php_no_self_compress) |
|
677 | + if ($php_no_self_compress) |
|
678 | 678 | { |
679 | - header('Content-Length: ' . (int)strlen($payload)); |
|
679 | + header('Content-Length: '.(int) strlen($payload)); |
|
680 | 680 | } |
681 | 681 | } |
682 | 682 | else |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * @param array $sigdoc the array of valid method signatures docs (one string per param, one for return type) |
700 | 700 | * @access public |
701 | 701 | */ |
702 | - function add_to_map($methodname,$function,$sig=null,$doc=false,$sigdoc=false) |
|
702 | + function add_to_map($methodname, $function, $sig = null, $doc = false, $sigdoc = false) |
|
703 | 703 | { |
704 | 704 | $this->dmap[$methodname] = array( |
705 | 705 | 'function' => $function, |
@@ -733,47 +733,47 @@ discard block |
||
733 | 733 | { |
734 | 734 | $numParams = count($in); |
735 | 735 | } |
736 | - foreach($sig as $cursig) |
|
736 | + foreach ($sig as $cursig) |
|
737 | 737 | { |
738 | - if(count($cursig)==$numParams+1) |
|
738 | + if (count($cursig) == $numParams+1) |
|
739 | 739 | { |
740 | - $itsOK=1; |
|
741 | - for($n=0; $n<$numParams; $n++) |
|
740 | + $itsOK = 1; |
|
741 | + for ($n = 0; $n<$numParams; $n++) |
|
742 | 742 | { |
743 | 743 | if (is_object($in)) |
744 | 744 | { |
745 | - $p=$in->getParam($n); |
|
746 | - if($p->kindOf() == 'scalar') |
|
745 | + $p = $in->getParam($n); |
|
746 | + if ($p->kindOf() == 'scalar') |
|
747 | 747 | { |
748 | - $pt=$p->scalartyp(); |
|
748 | + $pt = $p->scalartyp(); |
|
749 | 749 | } |
750 | 750 | else |
751 | 751 | { |
752 | - $pt=$p->kindOf(); |
|
752 | + $pt = $p->kindOf(); |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | else |
756 | 756 | { |
757 | - $pt= $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4... |
|
757 | + $pt = $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4... |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | // param index is $n+1, as first member of sig is return type |
761 | - if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) |
|
761 | + if ($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) |
|
762 | 762 | { |
763 | - $itsOK=0; |
|
764 | - $pno=$n+1; |
|
765 | - $wanted=$cursig[$n+1]; |
|
766 | - $got=$pt; |
|
763 | + $itsOK = 0; |
|
764 | + $pno = $n+1; |
|
765 | + $wanted = $cursig[$n+1]; |
|
766 | + $got = $pt; |
|
767 | 767 | break; |
768 | 768 | } |
769 | 769 | } |
770 | - if($itsOK) |
|
770 | + if ($itsOK) |
|
771 | 771 | { |
772 | - return array(1,''); |
|
772 | + return array(1, ''); |
|
773 | 773 | } |
774 | 774 | } |
775 | 775 | } |
776 | - if(isset($wanted)) |
|
776 | + if (isset($wanted)) |
|
777 | 777 | { |
778 | 778 | return array(0, "Wanted ${wanted}, got ${got} at param ${pno}"); |
779 | 779 | } |
@@ -797,12 +797,12 @@ discard block |
||
797 | 797 | error_log('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated'); |
798 | 798 | } |
799 | 799 | |
800 | - if($this->debug > 1) |
|
800 | + if ($this->debug>1) |
|
801 | 801 | { |
802 | - if(function_exists('getallheaders')) |
|
802 | + if (function_exists('getallheaders')) |
|
803 | 803 | { |
804 | 804 | $this->debugmsg(''); // empty line |
805 | - foreach(getallheaders() as $name => $val) |
|
805 | + foreach (getallheaders() as $name => $val) |
|
806 | 806 | { |
807 | 807 | $this->debugmsg("HEADER: $name: $val"); |
808 | 808 | } |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | |
811 | 811 | } |
812 | 812 | |
813 | - if(isset($_SERVER['HTTP_CONTENT_ENCODING'])) |
|
813 | + if (isset($_SERVER['HTTP_CONTENT_ENCODING'])) |
|
814 | 814 | { |
815 | 815 | $content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']); |
816 | 816 | } |
@@ -820,26 +820,26 @@ discard block |
||
820 | 820 | } |
821 | 821 | |
822 | 822 | // check if request body has been compressed and decompress it |
823 | - if($content_encoding != '' && strlen($data)) |
|
823 | + if ($content_encoding != '' && strlen($data)) |
|
824 | 824 | { |
825 | - if($content_encoding == 'deflate' || $content_encoding == 'gzip') |
|
825 | + if ($content_encoding == 'deflate' || $content_encoding == 'gzip') |
|
826 | 826 | { |
827 | 827 | // if decoding works, use it. else assume data wasn't gzencoded |
828 | - if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) |
|
828 | + if (function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) |
|
829 | 829 | { |
830 | - if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) |
|
830 | + if ($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) |
|
831 | 831 | { |
832 | 832 | $data = $degzdata; |
833 | - if($this->debug > 1) |
|
833 | + if ($this->debug>1) |
|
834 | 834 | { |
835 | - $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); |
|
835 | + $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
836 | 836 | } |
837 | 837 | } |
838 | - elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) |
|
838 | + elseif ($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) |
|
839 | 839 | { |
840 | 840 | $data = $degzdata; |
841 | - if($this->debug > 1) |
|
842 | - $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); |
|
841 | + if ($this->debug>1) |
|
842 | + $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
843 | 843 | } |
844 | 844 | else |
845 | 845 | { |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | * @return xmlrpcresp |
913 | 913 | * @access private |
914 | 914 | */ |
915 | - function parseRequest($data, $req_encoding='') |
|
915 | + function parseRequest($data, $req_encoding = '') |
|
916 | 916 | { |
917 | 917 | // 2005/05/07 commented and moved into caller function code |
918 | 918 | //if($data=='') |
@@ -924,16 +924,16 @@ discard block |
||
924 | 924 | // so we do not try to convert them into xml character entities |
925 | 925 | //$data = xmlrpc_html_entity_xlate($data); |
926 | 926 | |
927 | - $GLOBALS['_xh']=array(); |
|
928 | - $GLOBALS['_xh']['ac']=''; |
|
929 | - $GLOBALS['_xh']['stack']=array(); |
|
927 | + $GLOBALS['_xh'] = array(); |
|
928 | + $GLOBALS['_xh']['ac'] = ''; |
|
929 | + $GLOBALS['_xh']['stack'] = array(); |
|
930 | 930 | $GLOBALS['_xh']['valuestack'] = array(); |
931 | - $GLOBALS['_xh']['params']=array(); |
|
932 | - $GLOBALS['_xh']['pt']=array(); |
|
933 | - $GLOBALS['_xh']['isf']=0; |
|
934 | - $GLOBALS['_xh']['isf_reason']=''; |
|
935 | - $GLOBALS['_xh']['method']=false; // so we can check later if we got a methodname or not |
|
936 | - $GLOBALS['_xh']['rt']=''; |
|
931 | + $GLOBALS['_xh']['params'] = array(); |
|
932 | + $GLOBALS['_xh']['pt'] = array(); |
|
933 | + $GLOBALS['_xh']['isf'] = 0; |
|
934 | + $GLOBALS['_xh']['isf_reason'] = ''; |
|
935 | + $GLOBALS['_xh']['method'] = false; // so we can check later if we got a methodname or not |
|
936 | + $GLOBALS['_xh']['rt'] = ''; |
|
937 | 937 | |
938 | 938 | // decompose incoming XML into request structure |
939 | 939 | |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | if (extension_loaded('mbstring')) { |
952 | 952 | $data = mb_convert_encoding($data, 'UTF-8', $req_encoding); |
953 | 953 | } else { |
954 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $req_encoding); |
|
954 | + error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$req_encoding); |
|
955 | 955 | } |
956 | 956 | } |
957 | 957 | } |
@@ -980,10 +980,10 @@ discard block |
||
980 | 980 | xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); |
981 | 981 | xml_set_character_data_handler($parser, 'xmlrpc_cd'); |
982 | 982 | xml_set_default_handler($parser, 'xmlrpc_dh'); |
983 | - if(!xml_parse($parser, $data, 1)) |
|
983 | + if (!xml_parse($parser, $data, 1)) |
|
984 | 984 | { |
985 | 985 | // return XML error as a faultCode |
986 | - $r=new xmlrpcresp(0, |
|
986 | + $r = new xmlrpcresp(0, |
|
987 | 987 | $GLOBALS['xmlrpcerrxml']+xml_get_error_code($parser), |
988 | 988 | sprintf('XML error: %s at line %d, column %d', |
989 | 989 | xml_error_string(xml_get_error_code($parser)), |
@@ -993,9 +993,9 @@ discard block |
||
993 | 993 | elseif ($GLOBALS['_xh']['isf']) |
994 | 994 | { |
995 | 995 | xml_parser_free($parser); |
996 | - $r=new xmlrpcresp(0, |
|
996 | + $r = new xmlrpcresp(0, |
|
997 | 997 | $GLOBALS['xmlrpcerr']['invalid_request'], |
998 | - $GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']); |
|
998 | + $GLOBALS['xmlrpcstr']['invalid_request'].' '.$GLOBALS['_xh']['isf_reason']); |
|
999 | 999 | } |
1000 | 1000 | else |
1001 | 1001 | { |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | // registered as phpvals) that would mean a useless encode+decode pass |
1007 | 1007 | if ($this->functions_parameters_type != 'xmlrpcvals' || (isset($this->dmap[$GLOBALS['_xh']['method']]['parameters_type']) && ($this->dmap[$GLOBALS['_xh']['method']]['parameters_type'] == 'phpvals'))) |
1008 | 1008 | { |
1009 | - if($this->debug > 1) |
|
1009 | + if ($this->debug>1) |
|
1010 | 1010 | { |
1011 | 1011 | $this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++"); |
1012 | 1012 | } |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | else |
1016 | 1016 | { |
1017 | 1017 | // build an xmlrpcmsg object with data parsed from xml |
1018 | - $m=new xmlrpcmsg($GLOBALS['_xh']['method']); |
|
1018 | + $m = new xmlrpcmsg($GLOBALS['_xh']['method']); |
|
1019 | 1019 | // now add parameters in |
1020 | - for($i=0; $i<count($GLOBALS['_xh']['params']); $i++) |
|
1020 | + for ($i = 0; $i<count($GLOBALS['_xh']['params']); $i++) |
|
1021 | 1021 | { |
1022 | 1022 | $m->addParam($GLOBALS['_xh']['params'][$i]); |
1023 | 1023 | } |
1024 | 1024 | |
1025 | - if($this->debug > 1) |
|
1025 | + if ($this->debug>1) |
|
1026 | 1026 | { |
1027 | 1027 | $this->debugmsg("\n+++PARSED+++\n".var_export($m, true)."\n+++END+++"); |
1028 | 1028 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | * @return xmlrpcresp |
1041 | 1041 | * @access private |
1042 | 1042 | */ |
1043 | - function execute($m, $params=null, $paramtypes=null) |
|
1043 | + function execute($m, $params = null, $paramtypes = null) |
|
1044 | 1044 | { |
1045 | 1045 | if (is_object($m)) |
1046 | 1046 | { |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | $sysCall = $this->allow_system_funcs && (strpos($methName, "system.") === 0); |
1054 | 1054 | $dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap; |
1055 | 1055 | |
1056 | - if(!isset($dmap[$methName]['function'])) |
|
1056 | + if (!isset($dmap[$methName]['function'])) |
|
1057 | 1057 | { |
1058 | 1058 | // No such method |
1059 | 1059 | return new xmlrpcresp(0, |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | // Check signature |
1065 | - if(isset($dmap[$methName]['signature'])) |
|
1065 | + if (isset($dmap[$methName]['signature'])) |
|
1066 | 1066 | { |
1067 | 1067 | $sig = $dmap[$methName]['signature']; |
1068 | 1068 | if (is_object($m)) |
@@ -1073,37 +1073,37 @@ discard block |
||
1073 | 1073 | { |
1074 | 1074 | list($ok, $errstr) = $this->verifySignature($paramtypes, $sig); |
1075 | 1075 | } |
1076 | - if(!$ok) |
|
1076 | + if (!$ok) |
|
1077 | 1077 | { |
1078 | 1078 | // Didn't match. |
1079 | 1079 | return new xmlrpcresp( |
1080 | 1080 | 0, |
1081 | 1081 | $GLOBALS['xmlrpcerr']['incorrect_params'], |
1082 | - $GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}" |
|
1082 | + $GLOBALS['xmlrpcstr']['incorrect_params'].": ${errstr}" |
|
1083 | 1083 | ); |
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | $func = $dmap[$methName]['function']; |
1088 | 1088 | // let the 'class::function' syntax be accepted in dispatch maps |
1089 | - if(is_string($func) && strpos($func, '::')) |
|
1089 | + if (is_string($func) && strpos($func, '::')) |
|
1090 | 1090 | { |
1091 | 1091 | $func = explode('::', $func); |
1092 | 1092 | } |
1093 | 1093 | // verify that function to be invoked is in fact callable |
1094 | - if(!is_callable($func)) |
|
1094 | + if (!is_callable($func)) |
|
1095 | 1095 | { |
1096 | 1096 | error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler is not callable"); |
1097 | 1097 | return new xmlrpcresp( |
1098 | 1098 | 0, |
1099 | 1099 | $GLOBALS['xmlrpcerr']['server_error'], |
1100 | - $GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method" |
|
1100 | + $GLOBALS['xmlrpcstr']['server_error'].": no function matches method" |
|
1101 | 1101 | ); |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | // If debug level is 3, we should catch all errors generated during |
1105 | 1105 | // processing of user function, and log them as part of response |
1106 | - if($this->debug > 2) |
|
1106 | + if ($this->debug>2) |
|
1107 | 1107 | { |
1108 | 1108 | $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler'); |
1109 | 1109 | } |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | // Allow mixed-convention servers |
1113 | 1113 | if (is_object($m)) |
1114 | 1114 | { |
1115 | - if($sysCall) |
|
1115 | + if ($sysCall) |
|
1116 | 1116 | { |
1117 | 1117 | $r = call_user_func($func, $this, $m); |
1118 | 1118 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | $r = new xmlrpcresp( |
1133 | 1133 | 0, |
1134 | 1134 | $GLOBALS['xmlrpcerr']['server_error'], |
1135 | - $GLOBALS['xmlrpcstr']['server_error'] . ": function does not return xmlrpcresp object" |
|
1135 | + $GLOBALS['xmlrpcstr']['server_error'].": function does not return xmlrpcresp object" |
|
1136 | 1136 | ); |
1137 | 1137 | } |
1138 | 1138 | } |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | else |
1141 | 1141 | { |
1142 | 1142 | // call a 'plain php' function |
1143 | - if($sysCall) |
|
1143 | + if ($sysCall) |
|
1144 | 1144 | { |
1145 | 1145 | array_unshift($params, $this); |
1146 | 1146 | $r = call_user_func_array($func, $params); |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | // an eror response |
1156 | 1156 | if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) |
1157 | 1157 | { |
1158 | - $r = new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']); |
|
1158 | + $r = new xmlrpcresp(0, (integer) $r['faultCode'], (string) $r['faultString']); |
|
1159 | 1159 | } |
1160 | 1160 | else |
1161 | 1161 | { |
@@ -1178,11 +1178,11 @@ discard block |
||
1178 | 1178 | } |
1179 | 1179 | } |
1180 | 1180 | } |
1181 | - catch(Exception $e) |
|
1181 | + catch (Exception $e) |
|
1182 | 1182 | { |
1183 | 1183 | // (barring errors in the lib) an uncatched exception happened |
1184 | 1184 | // in the called function, we wrap it in a proper error-response |
1185 | - switch($this->exception_handling) |
|
1185 | + switch ($this->exception_handling) |
|
1186 | 1186 | { |
1187 | 1187 | case 2: |
1188 | 1188 | throw $e; |
@@ -1194,11 +1194,11 @@ discard block |
||
1194 | 1194 | $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error']); |
1195 | 1195 | } |
1196 | 1196 | } |
1197 | - if($this->debug > 2) |
|
1197 | + if ($this->debug>2) |
|
1198 | 1198 | { |
1199 | 1199 | // note: restore the error handler we found before calling the |
1200 | 1200 | // user func, even if it has been changed inside the func itself |
1201 | - if($GLOBALS['_xmlrpcs_prev_ehandler']) |
|
1201 | + if ($GLOBALS['_xmlrpcs_prev_ehandler']) |
|
1202 | 1202 | { |
1203 | 1203 | set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']); |
1204 | 1204 | } |
@@ -1223,15 +1223,15 @@ discard block |
||
1223 | 1223 | /** |
1224 | 1224 | * @access private |
1225 | 1225 | */ |
1226 | - function xml_header($charset_encoding='') |
|
1226 | + function xml_header($charset_encoding = '') |
|
1227 | 1227 | { |
1228 | 1228 | if ($charset_encoding != '') |
1229 | 1229 | { |
1230 | - return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?" . ">\n"; |
|
1230 | + return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?".">\n"; |
|
1231 | 1231 | } |
1232 | 1232 | else |
1233 | 1233 | { |
1234 | - return "<?xml version=\"1.0\"?" . ">\n"; |
|
1234 | + return "<?xml version=\"1.0\"?".">\n"; |
|
1235 | 1235 | } |
1236 | 1236 | } |
1237 | 1237 | |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | */ |
1242 | 1242 | function echoInput() |
1243 | 1243 | { |
1244 | - $r=new xmlrpcresp(new xmlrpcval( "'Aha said I: '" . $GLOBALS['HTTP_RAW_POST_DATA'], 'string')); |
|
1244 | + $r = new xmlrpcresp(new xmlrpcval("'Aha said I: '".$GLOBALS['HTTP_RAW_POST_DATA'], 'string')); |
|
1245 | 1245 | print $r->serialize(); |
1246 | 1246 | } |
1247 | 1247 | } |