@@ -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. |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | /** |
| 870 | 870 | * @deprecated |
| 871 | 871 | */ |
| 872 | - function xmlrpc_client($path, $server='', $port='', $method='') |
|
| 872 | + function xmlrpc_client($path, $server = '', $port = '', $method = '') |
|
| 873 | 873 | {
|
| 874 | 874 | self::__construct($path, $server, $port, $method); |
| 875 | 875 | } |
@@ -880,59 +880,59 @@ discard block |
||
| 880 | 880 | * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used |
| 881 | 881 | * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed |
| 882 | 882 | */ |
| 883 | - function __construct($path, $server='', $port='', $method='') |
|
| 883 | + function __construct($path, $server = '', $port = '', $method = '') |
|
| 884 | 884 | {
|
| 885 | 885 | // allow user to specify all params in $path |
| 886 | - if($server == '' and $port == '' and $method == '') |
|
| 886 | + if ($server == '' and $port == '' and $method == '') |
|
| 887 | 887 | {
|
| 888 | 888 | $parts = parse_url($path); |
| 889 | 889 | $server = $parts['host']; |
| 890 | 890 | $path = isset($parts['path']) ? $parts['path'] : ''; |
| 891 | - if(isset($parts['query'])) |
|
| 891 | + if (isset($parts['query'])) |
|
| 892 | 892 | {
|
| 893 | 893 | $path .= '?'.$parts['query']; |
| 894 | 894 | } |
| 895 | - if(isset($parts['fragment'])) |
|
| 895 | + if (isset($parts['fragment'])) |
|
| 896 | 896 | {
|
| 897 | 897 | $path .= '#'.$parts['fragment']; |
| 898 | 898 | } |
| 899 | - if(isset($parts['port'])) |
|
| 899 | + if (isset($parts['port'])) |
|
| 900 | 900 | {
|
| 901 | 901 | $port = $parts['port']; |
| 902 | 902 | } |
| 903 | - if(isset($parts['scheme'])) |
|
| 903 | + if (isset($parts['scheme'])) |
|
| 904 | 904 | {
|
| 905 | 905 | $method = $parts['scheme']; |
| 906 | 906 | } |
| 907 | - if(isset($parts['user'])) |
|
| 907 | + if (isset($parts['user'])) |
|
| 908 | 908 | {
|
| 909 | 909 | $this->username = $parts['user']; |
| 910 | 910 | } |
| 911 | - if(isset($parts['pass'])) |
|
| 911 | + if (isset($parts['pass'])) |
|
| 912 | 912 | {
|
| 913 | 913 | $this->password = $parts['pass']; |
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | - if($path == '' || $path[0] != '/') |
|
| 916 | + if ($path == '' || $path[0] != '/') |
|
| 917 | 917 | {
|
| 918 | - $this->path='/'.$path; |
|
| 918 | + $this->path = '/'.$path; |
|
| 919 | 919 | } |
| 920 | 920 | else |
| 921 | 921 | {
|
| 922 | - $this->path=$path; |
|
| 922 | + $this->path = $path; |
|
| 923 | 923 | } |
| 924 | - $this->server=$server; |
|
| 925 | - if($port != '') |
|
| 924 | + $this->server = $server; |
|
| 925 | + if ($port != '') |
|
| 926 | 926 | {
|
| 927 | - $this->port=$port; |
|
| 927 | + $this->port = $port; |
|
| 928 | 928 | } |
| 929 | - if($method != '') |
|
| 929 | + if ($method != '') |
|
| 930 | 930 | {
|
| 931 | - $this->method=$method; |
|
| 931 | + $this->method = $method; |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | // if ZLIB is enabled, let the client by default accept compressed responses |
| 935 | - if(function_exists('gzinflate') || (
|
|
| 935 | + if (function_exists('gzinflate') || (
|
|
| 936 | 936 | function_exists('curl_init') && (($info = curl_version()) &&
|
| 937 | 937 | ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) |
| 938 | 938 | )) |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
|
| 948 | 948 | |
| 949 | 949 | // initialize user_agent string |
| 950 | - $this->user_agent = $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion']; |
|
| 950 | + $this->user_agent = $GLOBALS['xmlrpcName'].' '.$GLOBALS['xmlrpcVersion']; |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | /** |
@@ -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 | } |
@@ -1969,7 +1969,7 @@ discard block |
||
| 1969 | 1969 | /** |
| 1970 | 1970 | * @deprecated |
| 1971 | 1971 | */ |
| 1972 | - function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='') |
|
| 1972 | + function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp = '') |
|
| 1973 | 1973 | {
|
| 1974 | 1974 | self::__construct($val, $fcode, $fstr, $valtyp); |
| 1975 | 1975 | } |
@@ -1984,9 +1984,9 @@ discard block |
||
| 1984 | 1984 | * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain |
| 1985 | 1985 | * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called... |
| 1986 | 1986 | */ |
| 1987 | - function __construct($val, $fcode = 0, $fstr = '', $valtyp='') |
|
| 1987 | + function __construct($val, $fcode = 0, $fstr = '', $valtyp = '') |
|
| 1988 | 1988 | {
|
| 1989 | - if($fcode != 0) |
|
| 1989 | + if ($fcode != 0) |
|
| 1990 | 1990 | {
|
| 1991 | 1991 | // error response |
| 1992 | 1992 | $this->errno = $fcode; |
@@ -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,14 +2131,14 @@ 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 | * @deprecated |
| 2140 | 2140 | */ |
| 2141 | - function xmlrpcmsg($meth, $pars=0) |
|
| 2141 | + function xmlrpcmsg($meth, $pars = 0) |
|
| 2142 | 2142 | {
|
| 2143 | 2143 | self::__construct($meth, $pars); |
| 2144 | 2144 | } |
@@ -2147,12 +2147,12 @@ discard block |
||
| 2147 | 2147 | * @param string $meth the name of the method to invoke |
| 2148 | 2148 | * @param array $pars array of parameters to be passed to the method (xmlrpcval objects) |
| 2149 | 2149 | */ |
| 2150 | - function __construct($meth, $pars=0) |
|
| 2150 | + function __construct($meth, $pars = 0) |
|
| 2151 | 2151 | {
|
| 2152 | - $this->methodname=$meth; |
|
| 2153 | - if(is_array($pars) && count($pars)>0) |
|
| 2152 | + $this->methodname = $meth; |
|
| 2153 | + if (is_array($pars) && count($pars)>0) |
|
| 2154 | 2154 | {
|
| 2155 | - for($i=0; $i<count($pars); $i++) |
|
| 2155 | + for ($i = 0; $i<count($pars); $i++) |
|
| 2156 | 2156 | {
|
| 2157 | 2157 | $this->addParam($pars[$i]); |
| 2158 | 2158 | } |
@@ -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,14 +2771,14 @@ 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 | * @deprecated |
| 2780 | 2780 | */ |
| 2781 | - function xmlrpcval($val=-1, $type='') |
|
| 2781 | + function xmlrpcval($val = -1, $type = '') |
|
| 2782 | 2782 | {
|
| 2783 | 2783 | self::__construct($val, $type); |
| 2784 | 2784 | } |
@@ -2787,18 +2787,18 @@ discard block |
||
| 2787 | 2787 | * @param mixed $val |
| 2788 | 2788 | * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed |
| 2789 | 2789 | */ |
| 2790 | - function __construct($val=-1, $type='') |
|
| 2790 | + function __construct($val = -1, $type = '') |
|
| 2791 | 2791 | {
|
| 2792 | 2792 | /// @todo: optimization creep - do not call addXX, do it all inline. |
| 2793 | 2793 | /// downside: booleans will not be coerced anymore |
| 2794 | - if($val!==-1 || $type!='') |
|
| 2794 | + if ($val !== -1 || $type != '') |
|
| 2795 | 2795 | {
|
| 2796 | 2796 | // optimization creep: inlined all work done by constructor |
| 2797 | - switch($type) |
|
| 2797 | + switch ($type) |
|
| 2798 | 2798 | {
|
| 2799 | 2799 | case '': |
| 2800 | - $this->mytype=1; |
|
| 2801 | - $this->me['string']=$val; |
|
| 2800 | + $this->mytype = 1; |
|
| 2801 | + $this->me['string'] = $val; |
|
| 2802 | 2802 | break; |
| 2803 | 2803 | case 'i4': |
| 2804 | 2804 | case 'int': |
@@ -2808,16 +2808,16 @@ discard block |
||
| 2808 | 2808 | case 'dateTime.iso8601': |
| 2809 | 2809 | case 'base64': |
| 2810 | 2810 | case 'null': |
| 2811 | - $this->mytype=1; |
|
| 2812 | - $this->me[$type]=$val; |
|
| 2811 | + $this->mytype = 1; |
|
| 2812 | + $this->me[$type] = $val; |
|
| 2813 | 2813 | break; |
| 2814 | 2814 | case 'array': |
| 2815 | - $this->mytype=2; |
|
| 2816 | - $this->me['array']=$val; |
|
| 2815 | + $this->mytype = 2; |
|
| 2816 | + $this->me['array'] = $val; |
|
| 2817 | 2817 | break; |
| 2818 | 2818 | case 'struct': |
| 2819 | - $this->mytype=3; |
|
| 2820 | - $this->me['struct']=$val; |
|
| 2819 | + $this->mytype = 3; |
|
| 2820 | + $this->me['struct'] = $val; |
|
| 2821 | 2821 | break; |
| 2822 | 2822 | default: |
| 2823 | 2823 | error_log("XML-RPC: ".__METHOD__.": not a known type ($type)");
|
@@ -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', |