Completed
Push — master ( 1b9763...313734 )
by Stefan
03:05
created
Components/Klarna/Klarna.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3429,8 +3429,7 @@  discard block
 block discarded – undo
3429 3429
             //Attempt to load previously stored pclasses, so they aren't
3430 3430
             // accidentially removed.
3431 3431
             $pclasses->load($this->pcURI);
3432
-        }
3433
-        catch(Exception $e) {
3432
+        } catch(Exception $e) {
3434 3433
             self::printDebug('load pclasses', $e->getMessage());
3435 3434
         }
3436 3435
 
@@ -3779,12 +3778,10 @@  discard block
 block discarded – undo
3779 3778
             }
3780 3779
 
3781 3780
             return php_xmlrpc_decode($xmlrpcresp->value());
3782
-        }
3783
-        catch(KlarnaException $e) {
3781
+        } catch(KlarnaException $e) {
3784 3782
             //Otherwise it is caught below, and rethrown.
3785 3783
             throw $e;
3786
-        }
3787
-        catch(Exception $e) {
3784
+        } catch(Exception $e) {
3788 3785
             throw new KlarnaException($e->getMessage(), $e->getCode());
3789 3786
         }
3790 3787
     }
Please login to merge, or discard this patch.
Models/lightConnector.php 1 patch
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,7 +5,8 @@  discard block
 block discarded – undo
5 5
  *
6 6
  * @author andre
7 7
  */
8
-class lightConnector {
8
+class lightConnector
9
+{
9 10
 
10 11
     /**
11 12
      * Connecting method
@@ -45,7 +46,8 @@  discard block
 block discarded – undo
45 46
      * @param type $config
46 47
      * @param type $method
47 48
      */
48
-    public function __construct($config, $method = null) {
49
+    public function __construct($config, $method = null)
50
+    {
49 51
         parent::__construct();
50 52
         $this->method = $method;
51 53
         $this->config = $config;
@@ -57,7 +59,8 @@  discard block
 block discarded – undo
57 59
      * @param string $method
58 60
      * @return void
59 61
      */
60
-    public function setMethod($method) {
62
+    public function setMethod($method)
63
+    {
61 64
         $this->method = $method;
62 65
     }
63 66
 
@@ -67,7 +70,8 @@  discard block
 block discarded – undo
67 70
      * @param string $klarnaOrderId
68 71
      * @return void
69 72
      */
70
-    public function setKlarnaOrderId($klarnaOrderId) {
73
+    public function setKlarnaOrderId($klarnaOrderId)
74
+    {
71 75
         $this->klarnaOrderId = $klarnaOrderId;
72 76
     }
73 77
 
@@ -76,7 +80,8 @@  discard block
 block discarded – undo
76 80
      * 
77 81
      * @param string $transactionId
78 82
      */
79
-    public function setTransactionId($transactionId) {
83
+    public function setTransactionId($transactionId)
84
+    {
80 85
         $this->transactionId = $transactionId;
81 86
     }
82 87
 
@@ -87,7 +92,8 @@  discard block
 block discarded – undo
87 92
      * @param array $shippingAddress
88 93
      * @return void
89 94
      */
90
-    public function updateCustomerAddress($billingAddress, $shippingAddress = false) {
95
+    public function updateCustomerAddress($billingAddress, $shippingAddress = false)
96
+    {
91 97
         $aAddressParts = array('');
92 98
     }
93 99
     
@@ -96,7 +102,8 @@  discard block
 block discarded – undo
96 102
      * 
97 103
      * @param array $data
98 104
      */
99
-    protected function setCall($data) {
105
+    protected function setCall($data)
106
+    {
100 107
         $testdrive = $this->config->get('testDrive');
101 108
         $url = ($testdrive) ? $this->apiUrl['test'] : $this->apiUrl['live'];
102 109
         
Please login to merge, or discard this patch.
Components/Klarna/transport/xmlrpc-3.0.0.beta/lib/xmlrpc.inc 1 patch
Braces   +447 added lines, -875 removed lines patch added patch discarded remove patch
@@ -35,12 +35,10 @@  discard block
 block discarded – undo
35 35
 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
36 36
 // OF THE POSSIBILITY OF SUCH DAMAGE.
37 37
 
38
-	if(!function_exists('xml_parser_create'))
39
-	{
38
+	if(!function_exists('xml_parser_create')) {
40 39
 		// For PHP 4 onward, XML functionality is always compiled-in on windows:
41 40
 		// no more need to dl-open it. It might have been compiled out on *nix...
42
-		if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN'))
43
-		{
41
+		if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN')) {
44 42
 			dl('xml.so');
45 43
 		}
46 44
 	}
@@ -112,13 +110,11 @@  discard block
 block discarded – undo
112 110
 	$GLOBALS['xml_iso88591_Entities']=array();
113 111
 	$GLOBALS['xml_iso88591_Entities']['in'] = array();
114 112
 	$GLOBALS['xml_iso88591_Entities']['out'] = array();
115
-	for ($i = 0; $i < 32; $i++)
116
-	{
113
+	for ($i = 0; $i < 32; $i++) {
117 114
 		$GLOBALS['xml_iso88591_Entities']['in'][] = chr($i);
118 115
 		$GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';';
119 116
 	}
120
-	for ($i = 160; $i < 256; $i++)
121
-	{
117
+	for ($i = 160; $i < 256; $i++) {
122 118
 		$GLOBALS['xml_iso88591_Entities']['in'][] = chr($i);
123 119
 		$GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';';
124 120
 	}
@@ -256,14 +252,12 @@  discard block
 block discarded – undo
256 252
 	*/
257 253
 	function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='')
258 254
 	{
259
-		if ($src_encoding == '')
260
-		{
255
+		if ($src_encoding == '') {
261 256
 			// lame, but we know no better...
262 257
 			$src_encoding = $GLOBALS['xmlrpc_internalencoding'];
263 258
 		}
264 259
 
265
-		switch(strtoupper($src_encoding.'_'.$dest_encoding))
266
-		{
260
+		switch(strtoupper($src_encoding.'_'.$dest_encoding)) {
267 261
 			case 'ISO-8859-1_':
268 262
 			case 'ISO-8859-1_US-ASCII':
269 263
 				$escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
@@ -290,15 +284,13 @@  discard block
 block discarded – undo
290 284
 	// be kind to users creating string xmlrpcvals out of different php types
291 285
 	$data = (string) $data;
292 286
 	$ns = strlen ($data);
293
-	for ($nn = 0; $nn < $ns; $nn++)
294
-	{
287
+	for ($nn = 0; $nn < $ns; $nn++) {
295 288
 		$ch = $data[$nn];
296 289
 		$ii = ord($ch);
297 290
 		//1 7 0bbbbbbb (127)
298
-		if ($ii < 128)
299
-		{
291
+		if ($ii < 128) {
300 292
 			/// @todo shall we replace this with a (supposedly) faster str_replace?
301
-			switch($ii){
293
+			switch($ii) {
302 294
 				case 34:
303 295
 					$escaped_data .= '&quot;';
304 296
 					break;
@@ -319,8 +311,7 @@  discard block
 block discarded – undo
319 311
 			} // switch
320 312
 		}
321 313
 		//2 11 110bbbbb 10bbbbbb (2047)
322
-		else if ($ii>>5 == 6)
323
-		{
314
+		else if ($ii>>5 == 6) {
324 315
 			$b1 = ($ii & 31);
325 316
 			$ii = ord($data[$nn+1]);
326 317
 			$b2 = ($ii & 63);
@@ -330,8 +321,7 @@  discard block
 block discarded – undo
330 321
 			$nn += 1;
331 322
 		}
332 323
 		//3 16 1110bbbb 10bbbbbb 10bbbbbb
333
-		else if ($ii>>4 == 14)
334
-		{
324
+		else if ($ii>>4 == 14) {
335 325
 			$b1 = ($ii & 15);
336 326
 			$ii = ord($data[$nn+1]);
337 327
 			$b2 = ($ii & 63);
@@ -343,8 +333,7 @@  discard block
 block discarded – undo
343 333
 			$nn += 2;
344 334
 		}
345 335
 		//4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
346
-		else if ($ii>>3 == 30)
347
-		{
336
+		else if ($ii>>3 == 30) {
348 337
 			$b1 = ($ii & 7);
349 338
 			$ii = ord($data[$nn+1]);
350 339
 			$b2 = ($ii & 63);
@@ -389,41 +378,32 @@  discard block
 block discarded – undo
389 378
 	function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false)
390 379
 	{
391 380
 		// if invalid xmlrpc already detected, skip all processing
392
-		if ($GLOBALS['_xh']['isf'] < 2)
393
-		{
381
+		if ($GLOBALS['_xh']['isf'] < 2) {
394 382
 			// check for correct element nesting
395 383
 			// top level element can only be of 2 types
396 384
 			/// @todo optimization creep: save this check into a bool variable, instead of using count() every time:
397 385
 			///       there is only a single top level element in xml anyway
398
-			if (count($GLOBALS['_xh']['stack']) == 0)
399
-			{
386
+			if (count($GLOBALS['_xh']['stack']) == 0) {
400 387
 				if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && (
401
-					$name != 'VALUE' && !$accept_single_vals))
402
-				{
388
+					$name != 'VALUE' && !$accept_single_vals)) {
403 389
 					$GLOBALS['_xh']['isf'] = 2;
404 390
 					$GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element';
405 391
 					return;
406
-				}
407
-				else
408
-				{
392
+				} else {
409 393
 					$GLOBALS['_xh']['rt'] = strtolower($name);
410 394
 					$GLOBALS['_xh']['rt'] = strtolower($name);
411 395
 				}
412
-			}
413
-			else
414
-			{
396
+			} else {
415 397
 				// not top level element: see if parent is OK
416 398
 				$parent = end($GLOBALS['_xh']['stack']);
417
-				if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name]))
418
-				{
399
+				if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name])) {
419 400
 					$GLOBALS['_xh']['isf'] = 2;
420 401
 					$GLOBALS['_xh']['isf_reason'] = "xmlrpc element $name cannot be child of $parent";
421 402
 					return;
422 403
 				}
423 404
 			}
424 405
 
425
-			switch($name)
426
-			{
406
+			switch($name) {
427 407
 				// optimize for speed switch cases: most common cases first
428 408
 				case 'VALUE':
429 409
 					/// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element
@@ -439,8 +419,7 @@  discard block
 block discarded – undo
439 419
 				case 'DOUBLE':
440 420
 				case 'DATETIME.ISO8601':
441 421
 				case 'BASE64':
442
-					if ($GLOBALS['_xh']['vt']!='value')
443
-					{
422
+					if ($GLOBALS['_xh']['vt']!='value') {
444 423
 						//two data elements inside a value: an error occurred!
445 424
 						$GLOBALS['_xh']['isf'] = 2;
446 425
 						$GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
@@ -450,8 +429,7 @@  discard block
 block discarded – undo
450 429
 					break;
451 430
 				case 'STRUCT':
452 431
 				case 'ARRAY':
453
-					if ($GLOBALS['_xh']['vt']!='value')
454
-					{
432
+					if ($GLOBALS['_xh']['vt']!='value') {
455 433
 						//two data elements inside a value: an error occurred!
456 434
 						$GLOBALS['_xh']['isf'] = 2;
457 435
 						$GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
@@ -463,16 +441,14 @@  discard block
 block discarded – undo
463 441
 					$cur_val['type'] = $name;
464 442
 					// check for out-of-band information to rebuild php objs
465 443
 					// and in case it is found, save it
466
-					if (@isset($attrs['PHP_CLASS']))
467
-					{
444
+					if (@isset($attrs['PHP_CLASS'])) {
468 445
 						$cur_val['php_class'] = $attrs['PHP_CLASS'];
469 446
 					}
470 447
 					$GLOBALS['_xh']['valuestack'][] = $cur_val;
471 448
 					$GLOBALS['_xh']['vt']='data'; // be prepared for a data element next
472 449
 					break;
473 450
 				case 'DATA':
474
-					if ($GLOBALS['_xh']['vt']!='data')
475
-					{
451
+					if ($GLOBALS['_xh']['vt']!='data') {
476 452
 						//two data elements inside a value: an error occurred!
477 453
 						$GLOBALS['_xh']['isf'] = 2;
478 454
 						$GLOBALS['_xh']['isf_reason'] = "found two data elements inside an array element";
@@ -501,10 +477,8 @@  discard block
 block discarded – undo
501 477
 					break;
502 478
 				case 'NIL':
503 479
 				case 'EX:NIL':
504
-					if ($GLOBALS['xmlrpc_null_extension'])
505
-					{
506
-						if ($GLOBALS['_xh']['vt']!='value')
507
-						{
480
+					if ($GLOBALS['xmlrpc_null_extension']) {
481
+						if ($GLOBALS['_xh']['vt']!='value') {
508 482
 							//two data elements inside a value: an error occurred!
509 483
 							$GLOBALS['_xh']['isf'] = 2;
510 484
 							$GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
@@ -526,8 +500,7 @@  discard block
 block discarded – undo
526 500
 			$GLOBALS['_xh']['stack'][] = $name;
527 501
 
528 502
 			/// @todo optimization creep: move this inside the big switch() above
529
-			if($name!='VALUE')
530
-			{
503
+			if($name!='VALUE') {
531 504
 				$GLOBALS['_xh']['lv']=0;
532 505
 			}
533 506
 		}
@@ -542,58 +515,48 @@  discard block
 block discarded – undo
542 515
 	/// xml parser handler function for close element tags
543 516
 	function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true)
544 517
 	{
545
-		if ($GLOBALS['_xh']['isf'] < 2)
546
-		{
518
+		if ($GLOBALS['_xh']['isf'] < 2) {
547 519
 			// push this element name from stack
548 520
 			// NB: if XML validates, correct opening/closing is guaranteed and
549 521
 			// we do not have to check for $name == $curr_elem.
550 522
 			// we also checked for proper nesting at start of elements...
551 523
 			$curr_elem = array_pop($GLOBALS['_xh']['stack']);
552 524
 
553
-			switch($name)
554
-			{
525
+			switch($name) {
555 526
 				case 'VALUE':
556 527
 					// This if() detects if no scalar was inside <VALUE></VALUE>
557
-					if ($GLOBALS['_xh']['vt']=='value')
558
-					{
528
+					if ($GLOBALS['_xh']['vt']=='value') {
559 529
 						$GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
560 530
 						$GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString'];
561 531
 					}
562 532
 
563
-					if ($rebuild_xmlrpcvals)
564
-					{
533
+					if ($rebuild_xmlrpcvals) {
565 534
 						// build the xmlrpc val out of the data received, and substitute it
566 535
 						$temp = new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']);
567 536
 						// in case we got info about underlying php class, save it
568 537
 						// in the object we're rebuilding
569
-						if (isset($GLOBALS['_xh']['php_class']))
570
-							$temp->_php_class = $GLOBALS['_xh']['php_class'];
538
+						if (isset($GLOBALS['_xh']['php_class'])) {
539
+													$temp->_php_class = $GLOBALS['_xh']['php_class'];
540
+						}
571 541
 						// check if we are inside an array or struct:
572 542
 						// if value just built is inside an array, let's move it into array on the stack
573 543
 						$vscount = count($GLOBALS['_xh']['valuestack']);
574
-						if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
575
-						{
544
+						if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') {
576 545
 							$GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp;
577
-						}
578
-						else
579
-						{
546
+						} else {
580 547
 							$GLOBALS['_xh']['value'] = $temp;
581 548
 						}
582
-					}
583
-					else
584
-					{
549
+					} else {
585 550
 						/// @todo this needs to treat correctly php-serialized objects,
586 551
 						/// since std deserializing is done by php_xmlrpc_decode,
587 552
 						/// which we will not be calling...
588
-						if (isset($GLOBALS['_xh']['php_class']))
589
-						{
553
+						if (isset($GLOBALS['_xh']['php_class'])) {
590 554
 						}
591 555
 
592 556
 						// check if we are inside an array or struct:
593 557
 						// if value just built is inside an array, let's move it into array on the stack
594 558
 						$vscount = count($GLOBALS['_xh']['valuestack']);
595
-						if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
596
-						{
559
+						if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') {
597 560
 							$GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value'];
598 561
 						}
599 562
 					}
@@ -608,73 +571,53 @@  discard block
 block discarded – undo
608 571
 					$GLOBALS['_xh']['vt']=strtolower($name);
609 572
 					/// @todo: optimization creep - remove the if/elseif cycle below
610 573
 					/// since the case() in which we are already did that
611
-					if ($name=='STRING')
612
-					{
574
+					if ($name=='STRING') {
613 575
 						$GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
614
-					}
615
-					elseif ($name=='DATETIME.ISO8601')
616
-					{
617
-						if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac']))
618
-						{
576
+					} elseif ($name=='DATETIME.ISO8601') {
577
+						if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac'])) {
619 578
 							error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']);
620 579
 						}
621 580
 						$GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime'];
622 581
 						$GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
623
-					}
624
-					elseif ($name=='BASE64')
625
-					{
582
+					} elseif ($name=='BASE64') {
626 583
 						/// @todo check for failure of base64 decoding / catch warnings
627 584
 						$GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']);
628
-					}
629
-					elseif ($name=='BOOLEAN')
630
-					{
585
+					} elseif ($name=='BOOLEAN') {
631 586
 						// special case here: we translate boolean 1 or 0 into PHP
632 587
 						// constants true or false.
633 588
 						// Strings 'true' and 'false' are accepted, even though the
634 589
 						// spec never mentions them (see eg. Blogger api docs)
635 590
 						// NB: this simple checks helps a lot sanitizing input, ie no
636 591
 						// security problems around here
637
-						if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0)
638
-						{
592
+						if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0) {
639 593
 							$GLOBALS['_xh']['value']=true;
640
-						}
641
-						else
642
-						{
594
+						} else {
643 595
 							// 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)
645
-								error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']);
596
+							if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0) {
597
+															error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']);
598
+							}
646 599
 							$GLOBALS['_xh']['value']=false;
647 600
 						}
648
-					}
649
-					elseif ($name=='DOUBLE')
650
-					{
601
+					} elseif ($name=='DOUBLE') {
651 602
 						// we have a DOUBLE
652 603
 						// we must check that only 0123456789-.<space> are characters here
653 604
 						// NOTE: regexp could be much stricter than this...
654
-						if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac']))
655
-						{
605
+						if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac'])) {
656 606
 							/// @todo: find a better way of throwing an error than this!
657 607
 							error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']);
658 608
 							$GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
659
-						}
660
-						else
661
-						{
609
+						} else {
662 610
 							// it's ok, add it on
663 611
 							$GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac'];
664 612
 						}
665
-					}
666
-					else
667
-					{
613
+					} else {
668 614
 						// we have an I4/INT
669 615
 						// we must check that only 0123456789-<space> are characters here
670
-						if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac']))
671
-						{
616
+						if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac'])) {
672 617
 							/// @todo find a better way of throwing an error than this!
673 618
 							error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']);
674 619
 							$GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
675
-						}
676
-						else
677
-						{
620
+						} else {
678 621
 							// it's ok, add it on
679 622
 							$GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac'];
680 623
 						}
@@ -689,12 +632,12 @@  discard block
 block discarded – undo
689 632
 					//$GLOBALS['_xh']['ac']=''; // is this necessary?
690 633
 					// add to array in the stack the last element built,
691 634
 					// unless no VALUE was found
692
-					if ($GLOBALS['_xh']['vt'])
693
-					{
635
+					if ($GLOBALS['_xh']['vt']) {
694 636
 						$vscount = count($GLOBALS['_xh']['valuestack']);
695 637
 						$GLOBALS['_xh']['valuestack'][$vscount-1]['values'][$GLOBALS['_xh']['valuestack'][$vscount-1]['name']] = $GLOBALS['_xh']['value'];
696
-					} else
697
-						error_log('XML-RPC: missing VALUE inside STRUCT in received xml');
638
+					} else {
639
+											error_log('XML-RPC: missing VALUE inside STRUCT in received xml');
640
+					}
698 641
 					break;
699 642
 				case 'DATA':
700 643
 					//$GLOBALS['_xh']['ac']=''; // is this necessary?
@@ -706,29 +649,26 @@  discard block
 block discarded – undo
706 649
 					$curr_val = array_pop($GLOBALS['_xh']['valuestack']);
707 650
 					$GLOBALS['_xh']['value'] = $curr_val['values'];
708 651
 					$GLOBALS['_xh']['vt']=strtolower($name);
709
-					if (isset($curr_val['php_class']))
710
-					{
652
+					if (isset($curr_val['php_class'])) {
711 653
 						$GLOBALS['_xh']['php_class'] = $curr_val['php_class'];
712 654
 					}
713 655
 					break;
714 656
 				case 'PARAM':
715 657
 					// add to array of params the current value,
716 658
 					// unless no VALUE was found
717
-					if ($GLOBALS['_xh']['vt'])
718
-					{
659
+					if ($GLOBALS['_xh']['vt']) {
719 660
 						$GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value'];
720 661
 						$GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt'];
662
+					} else {
663
+											error_log('XML-RPC: missing VALUE inside PARAM in received xml');
721 664
 					}
722
-					else
723
-						error_log('XML-RPC: missing VALUE inside PARAM in received xml');
724 665
 					break;
725 666
 				case 'METHODNAME':
726 667
 					$GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']);
727 668
 					break;
728 669
 				case 'NIL':
729 670
 				case 'EX:NIL':
730
-					if ($GLOBALS['xmlrpc_null_extension'])
731
-					{
671
+					if ($GLOBALS['xmlrpc_null_extension']) {
732 672
 						$GLOBALS['_xh']['vt']='null';
733 673
 						$GLOBALS['_xh']['value']=null;
734 674
 						$GLOBALS['_xh']['lv']=3;
@@ -758,12 +698,10 @@  discard block
 block discarded – undo
758 698
 	function xmlrpc_cd($parser, $data)
759 699
 	{
760 700
 		// skip processing if xml fault already detected
761
-		if ($GLOBALS['_xh']['isf'] < 2)
762
-		{
701
+		if ($GLOBALS['_xh']['isf'] < 2) {
763 702
 			// "lookforvalue==3" means that we've found an entire value
764 703
 			// and should discard any further character data
765
-			if($GLOBALS['_xh']['lv']!=3)
766
-			{
704
+			if($GLOBALS['_xh']['lv']!=3) {
767 705
 				// G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2
768 706
 				//if($GLOBALS['_xh']['lv']==1)
769 707
 				//{
@@ -786,10 +724,8 @@  discard block
 block discarded – undo
786 724
 	function xmlrpc_dh($parser, $data)
787 725
 	{
788 726
 		// skip processing if xml fault already detected
789
-		if ($GLOBALS['_xh']['isf'] < 2)
790
-		{
791
-			if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';')
792
-			{
727
+		if ($GLOBALS['_xh']['isf'] < 2) {
728
+			if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') {
793 729
 				// G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2
794 730
 				//if($GLOBALS['_xh']['lv']==1)
795 731
 				//{
@@ -875,51 +811,39 @@  discard block
 block discarded – undo
875 811
 		function xmlrpc_client($path, $server='', $port='', $method='')
876 812
 		{
877 813
 			// allow user to specify all params in $path
878
-			if($server == '' and $port == '' and $method == '')
879
-			{
814
+			if($server == '' and $port == '' and $method == '') {
880 815
 				$parts = parse_url($path);
881 816
 				$server = $parts['host'];
882 817
 				$path = isset($parts['path']) ? $parts['path'] : '';
883
-				if(isset($parts['query']))
884
-				{
818
+				if(isset($parts['query'])) {
885 819
 					$path .= '?'.$parts['query'];
886 820
 				}
887
-				if(isset($parts['fragment']))
888
-				{
821
+				if(isset($parts['fragment'])) {
889 822
 					$path .= '#'.$parts['fragment'];
890 823
 				}
891
-				if(isset($parts['port']))
892
-				{
824
+				if(isset($parts['port'])) {
893 825
 					$port = $parts['port'];
894 826
 				}
895
-				if(isset($parts['scheme']))
896
-				{
827
+				if(isset($parts['scheme'])) {
897 828
 					$method = $parts['scheme'];
898 829
 				}
899
-				if(isset($parts['user']))
900
-				{
830
+				if(isset($parts['user'])) {
901 831
 					$this->username = $parts['user'];
902 832
 				}
903
-				if(isset($parts['pass']))
904
-				{
833
+				if(isset($parts['pass'])) {
905 834
 					$this->password = $parts['pass'];
906 835
 				}
907 836
 			}
908
-			if($path == '' || $path[0] != '/')
909
-			{
837
+			if($path == '' || $path[0] != '/') {
910 838
 				$this->path='/'.$path;
911
-			}
912
-			else
913
-			{
839
+			} else {
914 840
 				$this->path=$path;
915 841
 			}
916 842
 			$this->server=$server;
917
-			if($port != '')
918
-			{
843
+			if($port != '') {
919 844
 				$this->port=$port;
920 845
 			}
921
-			if($method != '')
922
-			{
846
+			if($method != '') {
923 847
 				$this->method=$method;
924 848
 			}
925 849
 
@@ -927,8 +851,7 @@  discard block
 block discarded – undo
927 851
 			if(function_exists('gzinflate') || (
928 852
 				function_exists('curl_init') && (($info = curl_version()) &&
929 853
 				((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
930
-			))
931
-			{
854
+			)) {
932 855
 				$this->accepted_compression = array('gzip', 'deflate');
933 856
 			}
934 857
 
@@ -987,12 +910,9 @@  discard block
 block discarded – undo
987 910
 		*/
988 911
 		function setCaCertificate($cacert, $is_dir=false)
989 912
 		{
990
-			if ($is_dir)
991
-			{
913
+			if ($is_dir) {
992 914
 				$this->cacertdir = $cacert;
993
-			}
994
-			else
995
-			{
915
+			} else {
996 916
 				$this->cacert = $cacert;
997 917
 			}
998 918
 		}
@@ -1059,10 +979,11 @@  discard block
 block discarded – undo
1059 979
 		*/
1060 980
 		function setAcceptedCompression($compmethod)
1061 981
 		{
1062
-			if ($compmethod == 'any')
1063
-				$this->accepted_compression = array('gzip', 'deflate');
1064
-			else
1065
-				$this->accepted_compression = array($compmethod);
982
+			if ($compmethod == 'any') {
983
+							$this->accepted_compression = array('gzip', 'deflate');
984
+			} else {
985
+							$this->accepted_compression = array($compmethod);
986
+			}
1066 987
 		}
1067 988
 
1068 989
 		/**
@@ -1093,15 +1014,12 @@  discard block
 block discarded – undo
1093 1014
 		function setCookie($name, $value='', $path='', $domain='', $port=null)
1094 1015
 		{
1095 1016
 			$this->cookies[$name]['value'] = urlencode($value);
1096
-			if ($path || $domain || $port)
1097
-			{
1017
+			if ($path || $domain || $port) {
1098 1018
 				$this->cookies[$name]['path'] = $path;
1099 1019
 				$this->cookies[$name]['domain'] = $domain;
1100 1020
 				$this->cookies[$name]['port'] = $port;
1101 1021
 				$this->cookies[$name]['version'] = 1;
1102
-			}
1103
-			else
1104
-			{
1022
+			} else {
1105 1023
 				$this->cookies[$name]['version'] = 0;
1106 1024
 			}
1107 1025
 		}
@@ -1137,19 +1055,15 @@  discard block
 block discarded – undo
1137 1055
 		{
1138 1056
 			// if user deos not specify http protocol, use native method of this client
1139 1057
 			// (i.e. method set during call to constructor)
1140
-			if($method == '')
1141
-			{
1058
+			if($method == '') {
1142 1059
 				$method = $this->method;
1143 1060
 			}
1144 1061
 
1145
-			if(is_array($msg))
1146
-			{
1062
+			if(is_array($msg)) {
1147 1063
 				// $msg is an array of xmlrpcmsg's
1148 1064
 				$r = $this->multicall($msg, $timeout, $method);
1149 1065
 				return $r;
1150
-			}
1151
-			elseif(is_string($msg))
1152
-			{
1066
+			} elseif(is_string($msg)) {
1153 1067
 				$n = new xmlrpcmsg('');
1154 1068
 				$n->payload = $msg;
1155 1069
 				$msg = $n;
@@ -1158,8 +1072,7 @@  discard block
 block discarded – undo
1158 1072
 			// where msg is an xmlrpcmsg
1159 1073
 			$msg->debug=$this->debug;
1160 1074
 
1161
-			if($method == 'https')
1162
-			{
1075
+			if($method == 'https') {
1163 1076
 				$r =& $this->sendPayloadHTTPS(
1164 1077
 					$msg,
1165 1078
 					$this->server,
@@ -1181,9 +1094,7 @@  discard block
 block discarded – undo
1181 1094
 					$this->key,
1182 1095
 					$this->keypass
1183 1096
 				);
1184
-			}
1185
-			elseif($method == 'http11')
1186
-			{
1097
+			} elseif($method == 'http11') {
1187 1098
 				$r =& $this->sendPayloadCURL(
1188 1099
 					$msg,
1189 1100
 					$this->server,
@@ -1204,9 +1115,7 @@  discard block
 block discarded – undo
1204 1115
 					'http',
1205 1116
 					$this->keepalive
1206 1117
 				);
1207
-			}
1208
-			else
1209
-			{
1118
+			} else {
1210 1119
 				$r =& $this->sendPayloadHTTP10(
1211 1120
 					$msg,
1212 1121
 					$this->server,
@@ -1233,83 +1142,64 @@  discard block
 block discarded – undo
1233 1142
 			$username='', $password='', $authtype=1, $proxyhost='',
1234 1143
 			$proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1)
1235 1144
 		{
1236
-			if($port==0)
1237
-			{
1145
+			if($port==0) {
1238 1146
 				$port=80;
1239 1147
 			}
1240 1148
 
1241 1149
 			// Only create the payload if it was not created previously
1242
-			if(empty($msg->payload))
1243
-			{
1150
+			if(empty($msg->payload)) {
1244 1151
 				$msg->createPayload($this->request_charset_encoding);
1245 1152
 			}
1246 1153
 
1247 1154
 			$payload = $msg->payload;
1248 1155
 			// Deflate request body and set appropriate request headers
1249
-			if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate'))
1250
-			{
1251
-				if($this->request_compression == 'gzip')
1252
-				{
1156
+			if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) {
1157
+				if($this->request_compression == 'gzip') {
1253 1158
 					$a = @gzencode($payload);
1254
-					if($a)
1255
-					{
1159
+					if($a) {
1256 1160
 						$payload = $a;
1257 1161
 						$encoding_hdr = "Content-Encoding: gzip\r\n";
1258 1162
 					}
1259
-				}
1260
-				else
1261
-				{
1163
+				} else {
1262 1164
 					$a = @gzcompress($payload);
1263
-					if($a)
1264
-					{
1165
+					if($a) {
1265 1166
 						$payload = $a;
1266 1167
 						$encoding_hdr = "Content-Encoding: deflate\r\n";
1267 1168
 					}
1268 1169
 				}
1269
-			}
1270
-			else
1271
-			{
1170
+			} else {
1272 1171
 				$encoding_hdr = '';
1273 1172
 			}
1274 1173
 
1275 1174
 			// thanks to Grant Rauscher <[email protected]> for this
1276 1175
 			$credentials='';
1277
-			if($username!='')
1278
-			{
1176
+			if($username!='') {
1279 1177
 				$credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
1280
-				if ($authtype != 1)
1281
-				{
1178
+				if ($authtype != 1) {
1282 1179
 					error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0');
1283 1180
 				}
1284 1181
 			}
1285 1182
 
1286 1183
 			$accepted_encoding = '';
1287
-			if(is_array($this->accepted_compression) && count($this->accepted_compression))
1288
-			{
1184
+			if(is_array($this->accepted_compression) && count($this->accepted_compression)) {
1289 1185
 				$accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n";
1290 1186
 			}
1291 1187
 
1292 1188
 			$proxy_credentials = '';
1293
-			if($proxyhost)
1294
-			{
1295
-				if($proxyport == 0)
1296
-				{
1189
+			if($proxyhost) {
1190
+				if($proxyport == 0) {
1297 1191
 					$proxyport = 8080;
1298 1192
 				}
1299 1193
 				$connectserver = $proxyhost;
1300 1194
 				$connectport = $proxyport;
1301 1195
 				$uri = 'http://'.$server.':'.$port.$this->path;
1302
-				if($proxyusername != '')
1303
-				{
1304
-					if ($proxyauthtype != 1)
1305
-					{
1196
+				if($proxyusername != '') {
1197
+					if ($proxyauthtype != 1) {
1306 1198
 						error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0');
1307 1199
 					}
1308 1200
 					$proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n";
1309 1201
 				}
1310
-			}
1311
-			else
1312
-			{
1202
+			} else {
1313 1203
 				$connectserver = $server;
1314 1204
 				$connectport = $port;
1315 1205
 				$uri = $this->path;
@@ -1318,24 +1208,22 @@  discard block
 block discarded – undo
1318 1208
 			// Cookie generation, as per rfc2965 (version 1 cookies) or
1319 1209
 			// netscape's rules (version 0 cookies)
1320 1210
 			$cookieheader='';
1321
-			if (count($this->cookies))
1322
-			{
1211
+			if (count($this->cookies)) {
1323 1212
 				$version = '';
1324
-				foreach ($this->cookies as $name => $cookie)
1325
-				{
1326
-					if ($cookie['version'])
1327
-					{
1213
+				foreach ($this->cookies as $name => $cookie) {
1214
+					if ($cookie['version']) {
1328 1215
 						$version = ' $Version="' . $cookie['version'] . '";';
1329 1216
 						$cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";';
1330
-						if ($cookie['path'])
1331
-							$cookieheader .= ' $Path="' . $cookie['path'] . '";';
1332
-						if ($cookie['domain'])
1333
-							$cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
1334
-						if ($cookie['port'])
1335
-							$cookieheader .= ' $Port="' . $cookie['port'] . '";';
1336
-					}
1337
-					else
1338
-					{
1217
+						if ($cookie['path']) {
1218
+													$cookieheader .= ' $Path="' . $cookie['path'] . '";';
1219
+						}
1220
+						if ($cookie['domain']) {
1221
+													$cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
1222
+						}
1223
+						if ($cookie['port']) {
1224
+													$cookieheader .= ' $Port="' . $cookie['port'] . '";';
1225
+						}
1226
+					} else {
1339 1227
 						$cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";";
1340 1228
 					}
1341 1229
 				}
@@ -1355,52 +1243,40 @@  discard block
 block discarded – undo
1355 1243
 				strlen($payload) . "\r\n\r\n" .
1356 1244
 				$payload;
1357 1245
 
1358
-			if($this->debug > 1)
1359
-			{
1246
+			if($this->debug > 1) {
1360 1247
 				print "<PRE>\n---SENDING---\n" . htmlentities($op) . "\n---END---\n</PRE>";
1361 1248
 				// let the client see this now in case http times out...
1362 1249
 				flush();
1363 1250
 			}
1364 1251
 
1365
-			if($timeout>0)
1366
-			{
1252
+			if($timeout>0) {
1367 1253
 				$fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout);
1368
-			}
1369
-			else
1370
-			{
1254
+			} else {
1371 1255
 				$fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr);
1372 1256
 			}
1373
-			if($fp)
1374
-			{
1375
-				if($timeout>0 && function_exists('stream_set_timeout'))
1376
-				{
1257
+			if($fp) {
1258
+				if($timeout>0 && function_exists('stream_set_timeout')) {
1377 1259
 					stream_set_timeout($fp, $timeout);
1378 1260
 				}
1379
-			}
1380
-			else
1381
-			{
1261
+			} else {
1382 1262
 				$this->errstr='Connect error: '.$this->errstr;
1383 1263
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')');
1384 1264
 				return $r;
1385 1265
 			}
1386 1266
 
1387
-			if(!fputs($fp, $op, strlen($op)))
1388
-			{
1267
+			if(!fputs($fp, $op, strlen($op))) {
1389 1268
 				fclose($fp);
1390 1269
 				$this->errstr='Write error';
1391 1270
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr);
1392 1271
 				return $r;
1393
-			}
1394
-			else
1395
-			{
1272
+			} else {
1396 1273
 				// reset errno and errstr on succesful socket connection
1397 1274
 				$this->errstr = '';
1398 1275
 			}
1399 1276
 			// G. Giunta 2005/10/24: close socket before parsing.
1400 1277
 			// should yeld slightly better execution times, and make easier recursive calls (e.g. to follow http redirects)
1401 1278
 			$ipd='';
1402
-			do
1403
-			{
1279
+			do {
1404 1280
 				// shall we check for $data === FALSE?
1405 1281
 				// as per the manual, it signals an error
1406 1282
 				$ipd.=fread($fp, 32768);
@@ -1436,94 +1312,72 @@  discard block
 block discarded – undo
1436 1312
 			$proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https',
1437 1313
 			$keepalive=false, $key='', $keypass='')
1438 1314
 		{
1439
-			if(!function_exists('curl_init'))
1440
-			{
1315
+			if(!function_exists('curl_init')) {
1441 1316
 				$this->errstr='CURL unavailable on this install';
1442 1317
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']);
1443 1318
 				return $r;
1444 1319
 			}
1445
-			if($method == 'https')
1446
-			{
1320
+			if($method == 'https') {
1447 1321
 				if(($info = curl_version()) &&
1448
-					((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version']))))
1449
-				{
1322
+					((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version'])))) {
1450 1323
 					$this->errstr='SSL unavailable on this install';
1451 1324
 					$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']);
1452 1325
 					return $r;
1453 1326
 				}
1454 1327
 			}
1455 1328
 
1456
-			if($port == 0)
1457
-			{
1458
-				if($method == 'http')
1459
-				{
1329
+			if($port == 0) {
1330
+				if($method == 'http') {
1460 1331
 					$port = 80;
1461
-				}
1462
-				else
1463
-				{
1332
+				} else {
1464 1333
 					$port = 443;
1465 1334
 				}
1466 1335
 			}
1467 1336
 
1468 1337
 			// Only create the payload if it was not created previously
1469
-			if(empty($msg->payload))
1470
-			{
1338
+			if(empty($msg->payload)) {
1471 1339
 				$msg->createPayload($this->request_charset_encoding);
1472 1340
 			}
1473 1341
 
1474 1342
 			// Deflate request body and set appropriate request headers
1475 1343
 			$payload = $msg->payload;
1476
-			if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate'))
1477
-			{
1478
-				if($this->request_compression == 'gzip')
1479
-				{
1344
+			if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) {
1345
+				if($this->request_compression == 'gzip') {
1480 1346
 					$a = @gzencode($payload);
1481
-					if($a)
1482
-					{
1347
+					if($a) {
1483 1348
 						$payload = $a;
1484 1349
 						$encoding_hdr = 'Content-Encoding: gzip';
1485 1350
 					}
1486
-				}
1487
-				else
1488
-				{
1351
+				} else {
1489 1352
 					$a = @gzcompress($payload);
1490
-					if($a)
1491
-					{
1353
+					if($a) {
1492 1354
 						$payload = $a;
1493 1355
 						$encoding_hdr = 'Content-Encoding: deflate';
1494 1356
 					}
1495 1357
 				}
1496
-			}
1497
-			else
1498
-			{
1358
+			} else {
1499 1359
 				$encoding_hdr = '';
1500 1360
 			}
1501 1361
 
1502
-			if($this->debug > 1)
1503
-			{
1362
+			if($this->debug > 1) {
1504 1363
 				print "<PRE>\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n</PRE>";
1505 1364
 				// let the client see this now in case http times out...
1506 1365
 				flush();
1507 1366
 			}
1508 1367
 
1509
-			if(!$keepalive || !$this->xmlrpc_curl_handle)
1510
-			{
1368
+			if(!$keepalive || !$this->xmlrpc_curl_handle) {
1511 1369
 				$curl = curl_init($method . '://' . $server . ':' . $port . $this->path);
1512
-				if($keepalive)
1513
-				{
1370
+				if($keepalive) {
1514 1371
 					$this->xmlrpc_curl_handle = $curl;
1515 1372
 				}
1516
-			}
1517
-			else
1518
-			{
1373
+			} else {
1519 1374
 				$curl = $this->xmlrpc_curl_handle;
1520 1375
 			}
1521 1376
 
1522 1377
 			// results into variable
1523 1378
 			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
1524 1379
 
1525
-			if($this->debug)
1526
-			{
1380
+			if($this->debug) {
1527 1381
 				curl_setopt($curl, CURLOPT_VERBOSE, 1);
1528 1382
 			}
1529 1383
 			curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
@@ -1539,81 +1393,65 @@  discard block
 block discarded – undo
1539 1393
 			// NB: if we set an empty string, CURL will add http header indicating
1540 1394
 			// ALL methods it is supporting. This is possibly a better option than
1541 1395
 			// letting the user tell what curl can / cannot do...
1542
-			if(is_array($this->accepted_compression) && count($this->accepted_compression))
1543
-			{
1396
+			if(is_array($this->accepted_compression) && count($this->accepted_compression)) {
1544 1397
 				//curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression));
1545 1398
 				// empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
1546
-				if (count($this->accepted_compression) == 1)
1547
-				{
1399
+				if (count($this->accepted_compression) == 1) {
1548 1400
 					curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]);
1401
+				} else {
1402
+									curl_setopt($curl, CURLOPT_ENCODING, '');
1549 1403
 				}
1550
-				else
1551
-					curl_setopt($curl, CURLOPT_ENCODING, '');
1552 1404
 			}
1553 1405
 			// extra headers
1554 1406
 			$headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
1555 1407
 			// if no keepalive is wanted, let the server know it in advance
1556
-			if(!$keepalive)
1557
-			{
1408
+			if(!$keepalive) {
1558 1409
 				$headers[] = 'Connection: close';
1559 1410
 			}
1560 1411
 			// request compression header
1561
-			if($encoding_hdr)
1562
-			{
1412
+			if($encoding_hdr) {
1563 1413
 				$headers[] = $encoding_hdr;
1564 1414
 			}
1565 1415
 
1566 1416
 			curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
1567 1417
 			// timeout is borked
1568
-			if($timeout)
1569
-			{
1418
+			if($timeout) {
1570 1419
 				curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1);
1571 1420
 			}
1572 1421
 
1573
-			if($username && $password)
1574
-			{
1422
+			if($username && $password) {
1575 1423
 				curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
1576
-				if (defined('CURLOPT_HTTPAUTH'))
1577
-				{
1424
+				if (defined('CURLOPT_HTTPAUTH')) {
1578 1425
 					curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype);
1579
-				}
1580
-				else if ($authtype != 1)
1581
-				{
1426
+				} else if ($authtype != 1) {
1582 1427
 					error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
1583 1428
 				}
1584 1429
 			}
1585 1430
 
1586
-			if($method == 'https')
1587
-			{
1431
+			if($method == 'https') {
1588 1432
 				// set cert file
1589
-				if($cert)
1590
-				{
1433
+				if($cert) {
1591 1434
 					curl_setopt($curl, CURLOPT_SSLCERT, $cert);
1592 1435
 				}
1593 1436
 				// set cert password
1594
-				if($certpass)
1595
-				{
1437
+				if($certpass) {
1596 1438
 					curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certpass);
1597 1439
 				}
1598 1440
 				// whether to verify remote host's cert
1599 1441
 				curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer);
1600 1442
 				// set ca certificates file/dir
1601
-				if($cacert)
1602
-				{
1443
+				if($cacert) {
1603 1444
 					curl_setopt($curl, CURLOPT_CAINFO, $cacert);
1604 1445
 				}
1605
-				if($cacertdir)
1606
-				{
1446
+				if($cacertdir) {
1607 1447
 					curl_setopt($curl, CURLOPT_CAPATH, $cacertdir);
1608 1448
 				}
1609 1449
 				// set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
1610
-				if($key)
1611
-				{
1450
+				if($key) {
1612 1451
 					curl_setopt($curl, CURLOPT_SSLKEY, $key);
1613 1452
 				}
1614 1453
 				// set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
1615
-				if($keypass)
1616
-				{
1454
+				if($keypass) {
1617 1455
 					curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keypass);
1618 1456
 				}
1619 1457
 				// whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used
@@ -1621,23 +1459,17 @@  discard block
 block discarded – undo
1621 1459
 			}
1622 1460
 
1623 1461
 			// proxy info
1624
-			if($proxyhost)
1625
-			{
1626
-				if($proxyport == 0)
1627
-				{
1462
+			if($proxyhost) {
1463
+				if($proxyport == 0) {
1628 1464
 					$proxyport = 8080; // NB: even for HTTPS, local connection is on port 8080
1629 1465
 				}
1630 1466
 				curl_setopt($curl, CURLOPT_PROXY, $proxyhost.':'.$proxyport);
1631 1467
 				//curl_setopt($curl, CURLOPT_PROXYPORT,$proxyport);
1632
-				if($proxyusername)
1633
-				{
1468
+				if($proxyusername) {
1634 1469
 					curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyusername.':'.$proxypassword);
1635
-					if (defined('CURLOPT_PROXYAUTH'))
1636
-					{
1470
+					if (defined('CURLOPT_PROXYAUTH')) {
1637 1471
 						curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype);
1638
-					}
1639
-					else if ($proxyauthtype != 1)
1640
-					{
1472
+					} else if ($proxyauthtype != 1) {
1641 1473
 						error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1642 1474
 					}
1643 1475
 				}
@@ -1646,45 +1478,40 @@  discard block
 block discarded – undo
1646 1478
 			// NB: should we build cookie http headers by hand rather than let CURL do it?
1647 1479
 			// the following code does not honour 'expires', 'path' and 'domain' cookie attributes
1648 1480
 			// set to client obj the the user...
1649
-			if (count($this->cookies))
1650
-			{
1481
+			if (count($this->cookies)) {
1651 1482
 				$cookieheader = '';
1652
-				foreach ($this->cookies as $name => $cookie)
1653
-				{
1483
+				foreach ($this->cookies as $name => $cookie) {
1654 1484
 					$cookieheader .= $name . '=' . $cookie['value'] . '; ';
1655 1485
 				}
1656 1486
 				curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2));
1657 1487
 			}
1658 1488
 
1659
-			foreach ($this->extracurlopts as $opt => $val)
1660
-			{
1489
+			foreach ($this->extracurlopts as $opt => $val) {
1661 1490
 				curl_setopt($curl, $opt, $val);
1662 1491
 			}
1663 1492
 
1664 1493
 			$result = curl_exec($curl);
1665 1494
 
1666
-			if ($this->debug > 1)
1667
-			{
1495
+			if ($this->debug > 1) {
1668 1496
 				print "<PRE>\n---CURL INFO---\n";
1669
-				foreach(curl_getinfo($curl) as $name => $val)
1670
-					 print $name . ': ' . htmlentities($val). "\n";
1497
+				foreach(curl_getinfo($curl) as $name => $val) {
1498
+									 print $name . ': ' . htmlentities($val). "\n";
1499
+				}
1671 1500
 				print "---END---\n</PRE>";
1672 1501
 			}
1673 1502
 
1674
-			if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'?
1503
+			if(!$result) {
1504
+			    /// @todo we should use a better check here - what if we get back '' or '0'?
1675 1505
 			{
1676 1506
 				$this->errstr='no response';
1507
+			}
1677 1508
 				$resp=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl));
1678 1509
 				curl_close($curl);
1679
-				if($keepalive)
1680
-				{
1510
+				if($keepalive) {
1681 1511
 					$this->xmlrpc_curl_handle = null;
1682 1512
 				}
1683
-			}
1684
-			else
1685
-			{
1686
-				if(!$keepalive)
1687
-				{
1513
+			} else {
1514
+				if(!$keepalive) {
1688 1515
 					curl_close($curl);
1689 1516
 				}
1690 1517
 				$resp =& $msg->parseResponse($result, true, $this->return_type);
@@ -1716,64 +1543,46 @@  discard block
 block discarded – undo
1716 1543
 		*/
1717 1544
 		function multicall($msgs, $timeout=0, $method='', $fallback=true)
1718 1545
 		{
1719
-			if ($method == '')
1720
-			{
1546
+			if ($method == '') {
1721 1547
 				$method = $this->method;
1722 1548
 			}
1723
-			if(!$this->no_multicall)
1724
-			{
1549
+			if(!$this->no_multicall) {
1725 1550
 				$results = $this->_try_multicall($msgs, $timeout, $method);
1726
-				if(is_array($results))
1727
-				{
1551
+				if(is_array($results)) {
1728 1552
 					// System.multicall succeeded
1729 1553
 					return $results;
1730
-				}
1731
-				else
1732
-				{
1554
+				} else {
1733 1555
 					// either system.multicall is unsupported by server,
1734 1556
 					// or call failed for some other reason.
1735
-					if ($fallback)
1736
-					{
1557
+					if ($fallback) {
1737 1558
 						// Don't try it next time...
1738 1559
 						$this->no_multicall = true;
1739
-					}
1740
-					else
1741
-					{
1742
-						if (is_a($results, 'xmlrpcresp'))
1743
-						{
1560
+					} else {
1561
+						if (is_a($results, 'xmlrpcresp')) {
1744 1562
 							$result = $results;
1745
-						}
1746
-						else
1747
-						{
1563
+						} else {
1748 1564
 							$result = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']);
1749 1565
 						}
1750 1566
 					}
1751 1567
 				}
1752
-			}
1753
-			else
1754
-			{
1568
+			} else {
1755 1569
 				// override fallback, in case careless user tries to do two
1756 1570
 				// opposite things at the same time
1757 1571
 				$fallback = true;
1758 1572
 			}
1759 1573
 
1760 1574
 			$results = array();
1761
-			if ($fallback)
1762
-			{
1575
+			if ($fallback) {
1763 1576
 				// system.multicall is (probably) unsupported by server:
1764 1577
 				// emulate multicall via multiple requests
1765
-				foreach($msgs as $msg)
1766
-				{
1578
+				foreach($msgs as $msg) {
1767 1579
 					$results[] =& $this->send($msg, $timeout, $method);
1768 1580
 				}
1769
-			}
1770
-			else
1771
-			{
1581
+			} else {
1772 1582
 				// user does NOT want to fallback on many single calls:
1773 1583
 				// since we should always return an array of responses,
1774 1584
 				// return an array with the same error repeated n times
1775
-				foreach($msgs as $msg)
1776
-				{
1585
+				foreach($msgs as $msg) {
1777 1586
 					$results[] = $result;
1778 1587
 				}
1779 1588
 			}
@@ -1790,13 +1599,11 @@  discard block
 block discarded – undo
1790 1599
 		{
1791 1600
 			// Construct multicall message
1792 1601
 			$calls = array();
1793
-			foreach($msgs as $msg)
1794
-			{
1602
+			foreach($msgs as $msg) {
1795 1603
 				$call['methodName'] = new xmlrpcval($msg->method(),'string');
1796 1604
 				$numParams = $msg->getNumParams();
1797 1605
 				$params = array();
1798
-				for($i = 0; $i < $numParams; $i++)
1799
-				{
1606
+				for($i = 0; $i < $numParams; $i++) {
1800 1607
 					$params[$i] = $msg->getParam($i);
1801 1608
 				}
1802 1609
 				$call['params'] = new xmlrpcval($params, 'array');
@@ -1808,8 +1615,7 @@  discard block
 block discarded – undo
1808 1615
 			// Attempt RPC call
1809 1616
 			$result =& $this->send($multicall, $timeout, $method);
1810 1617
 
1811
-			if($result->faultCode() != 0)
1812
-			{
1618
+			if($result->faultCode() != 0) {
1813 1619
 				// call to system.multicall failed
1814 1620
 				return $result;
1815 1621
 			}
@@ -1817,36 +1623,28 @@  discard block
 block discarded – undo
1817 1623
 			// Unpack responses.
1818 1624
 			$rets = $result->value();
1819 1625
 
1820
-			if ($this->return_type == 'xml')
1821
-			{
1626
+			if ($this->return_type == 'xml') {
1822 1627
 					return $rets;
1823
-			}
1824
-			else if ($this->return_type == 'phpvals')
1825
-			{
1628
+			} else if ($this->return_type == 'phpvals') {
1826 1629
 				///@todo test this code branch...
1827 1630
 				$rets = $result->value();
1828
-				if(!is_array($rets))
1829
-				{
1631
+				if(!is_array($rets)) {
1830 1632
 					return false;		// bad return type from system.multicall
1831 1633
 				}
1832 1634
 				$numRets = count($rets);
1833
-				if($numRets != count($msgs))
1834
-				{
1635
+				if($numRets != count($msgs)) {
1835 1636
 					return false;		// wrong number of return values.
1836 1637
 				}
1837 1638
 
1838 1639
 				$response = array();
1839
-				for($i = 0; $i < $numRets; $i++)
1840
-				{
1640
+				for($i = 0; $i < $numRets; $i++) {
1841 1641
 					$val = $rets[$i];
1842 1642
 					if (!is_array($val)) {
1843 1643
 						return false;
1844 1644
 					}
1845
-					switch(count($val))
1846
-					{
1645
+					switch(count($val)) {
1847 1646
 						case 1:
1848
-							if(!isset($val[0]))
1849
-							{
1647
+							if(!isset($val[0])) {
1850 1648
 								return false;		// Bad value
1851 1649
 							}
1852 1650
 							// Normal return value
@@ -1855,13 +1653,11 @@  discard block
 block discarded – undo
1855 1653
 						case 2:
1856 1654
 							///	@todo remove usage of @: it is apparently quite slow
1857 1655
 							$code = @$val['faultCode'];
1858
-							if(!is_int($code))
1859
-							{
1656
+							if(!is_int($code)) {
1860 1657
 								return false;
1861 1658
 							}
1862 1659
 							$str = @$val['faultString'];
1863
-							if(!is_string($str))
1864
-							{
1660
+							if(!is_string($str)) {
1865 1661
 								return false;
1866 1662
 							}
1867 1663
 							$response[$i] = new xmlrpcresp(0, $code, $str);
@@ -1871,29 +1667,23 @@  discard block
 block discarded – undo
1871 1667
 					}
1872 1668
 				}
1873 1669
 				return $response;
1874
-			}
1875
-			else // return type == 'xmlrpcvals'
1670
+			} else // return type == 'xmlrpcvals'
1876 1671
 			{
1877 1672
 				$rets = $result->value();
1878
-				if($rets->kindOf() != 'array')
1879
-				{
1673
+				if($rets->kindOf() != 'array') {
1880 1674
 					return false;		// bad return type from system.multicall
1881 1675
 				}
1882 1676
 				$numRets = $rets->arraysize();
1883
-				if($numRets != count($msgs))
1884
-				{
1677
+				if($numRets != count($msgs)) {
1885 1678
 					return false;		// wrong number of return values.
1886 1679
 				}
1887 1680
 
1888 1681
 				$response = array();
1889
-				for($i = 0; $i < $numRets; $i++)
1890
-				{
1682
+				for($i = 0; $i < $numRets; $i++) {
1891 1683
 					$val = $rets->arraymem($i);
1892
-					switch($val->kindOf())
1893
-					{
1684
+					switch($val->kindOf()) {
1894 1685
 						case 'array':
1895
-							if($val->arraysize() != 1)
1896
-							{
1686
+							if($val->arraysize() != 1) {
1897 1687
 								return false;		// Bad value
1898 1688
 							}
1899 1689
 							// Normal return value
@@ -1901,13 +1691,11 @@  discard block
 block discarded – undo
1901 1691
 							break;
1902 1692
 						case 'struct':
1903 1693
 							$code = $val->structmem('faultCode');
1904
-							if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int')
1905
-							{
1694
+							if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') {
1906 1695
 								return false;
1907 1696
 							}
1908 1697
 							$str = $val->structmem('faultString');
1909
-							if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string')
1910
-							{
1698
+							if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') {
1911 1699
 								return false;
1912 1700
 							}
1913 1701
 							$response[$i] = new xmlrpcresp(0, $code->scalarval(), $str->scalarval());
@@ -1945,36 +1733,25 @@  discard block
 block discarded – undo
1945 1733
 		*/
1946 1734
 		function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='')
1947 1735
 		{
1948
-			if($fcode != 0)
1949
-			{
1736
+			if($fcode != 0) {
1950 1737
 				// error response
1951 1738
 				$this->errno = $fcode;
1952 1739
 				$this->errstr = $fstr;
1953 1740
 				//$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later.
1954
-			}
1955
-			else
1956
-			{
1741
+			} else {
1957 1742
 				// successful response
1958 1743
 				$this->val = $val;
1959
-				if ($valtyp == '')
1960
-				{
1744
+				if ($valtyp == '') {
1961 1745
 					// user did not declare type of response value: try to guess it
1962
-					if (is_object($this->val) && is_a($this->val, 'xmlrpcval'))
1963
-					{
1746
+					if (is_object($this->val) && is_a($this->val, 'xmlrpcval')) {
1964 1747
 						$this->valtyp = 'xmlrpcvals';
1965
-					}
1966
-					else if (is_string($this->val))
1967
-					{
1748
+					} else if (is_string($this->val)) {
1968 1749
 						$this->valtyp = 'xml';
1969 1750
 
1970
-					}
1971
-					else
1972
-					{
1751
+					} else {
1973 1752
 						$this->valtyp = 'phpvals';
1974 1753
 					}
1975
-				}
1976
-				else
1977
-				{
1754
+				} else {
1978 1755
 					// user declares type of resp value: believe him
1979 1756
 					$this->valtyp = $valtyp;
1980 1757
 				}
@@ -2035,13 +1812,13 @@  discard block
 block discarded – undo
2035 1812
 		*/
2036 1813
 		function serialize($charset_encoding='')
2037 1814
 		{
2038
-			if ($charset_encoding != '')
2039
-				$this->content_type = 'text/xml; charset=' . $charset_encoding;
2040
-			else
2041
-				$this->content_type = 'text/xml';
1815
+			if ($charset_encoding != '') {
1816
+							$this->content_type = 'text/xml; charset=' . $charset_encoding;
1817
+			} else {
1818
+							$this->content_type = 'text/xml';
1819
+			}
2042 1820
 			$result = "<methodResponse>\n";
2043
-			if($this->errno)
2044
-			{
1821
+			if($this->errno) {
2045 1822
 				// G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients
2046 1823
 				// by xml-encoding non ascii chars
2047 1824
 				$result .= "<fault>\n" .
@@ -2049,25 +1826,17 @@  discard block
 block discarded – undo
2049 1826
 "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" .
2050 1827
 xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" .
2051 1828
 "</struct>\n</value>\n</fault>";
2052
-			}
2053
-			else
2054
-			{
2055
-				if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval'))
2056
-				{
2057
-					if (is_string($this->val) && $this->valtyp == 'xml')
2058
-					{
1829
+			} else {
1830
+				if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval')) {
1831
+					if (is_string($this->val) && $this->valtyp == 'xml') {
2059 1832
 						$result .= "<params>\n<param>\n" .
2060 1833
 							$this->val .
2061 1834
 							"</param>\n</params>";
2062
-					}
2063
-					else
2064
-					{
1835
+					} else {
2065 1836
 						/// @todo try to build something serializable?
2066 1837
 						die('cannot serialize xmlrpcresp objects whose content is native php values');
2067 1838
 					}
2068
-				}
2069
-				else
2070
-				{
1839
+				} else {
2071 1840
 					$result .= "<params>\n<param>\n" .
2072 1841
 						$this->val->serialize($charset_encoding) .
2073 1842
 						"</param>\n</params>";
@@ -2094,10 +1863,8 @@  discard block
 block discarded – undo
2094 1863
 		function xmlrpcmsg($meth, $pars=0)
2095 1864
 		{
2096 1865
 			$this->methodname=$meth;
2097
-			if(is_array($pars) && count($pars)>0)
2098
-			{
2099
-				for($i=0; $i<count($pars); $i++)
2100
-				{
1866
+			if(is_array($pars) && count($pars)>0) {
1867
+				for($i=0; $i<count($pars); $i++) {
2101 1868
 					$this->addParam($pars[$i]);
2102 1869
 				}
2103 1870
 			}
@@ -2108,12 +1875,9 @@  discard block
 block discarded – undo
2108 1875
 		*/
2109 1876
 		function xml_header($charset_encoding='')
2110 1877
 		{
2111
-			if ($charset_encoding != '')
2112
-			{
1878
+			if ($charset_encoding != '') {
2113 1879
 				return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?" . ">\n<methodCall>\n";
2114
-			}
2115
-			else
2116
-			{
1880
+			} else {
2117 1881
 				return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
2118 1882
 			}
2119 1883
 		}
@@ -2139,15 +1903,15 @@  discard block
 block discarded – undo
2139 1903
 		*/
2140 1904
 		function createPayload($charset_encoding='')
2141 1905
 		{
2142
-			if ($charset_encoding != '')
2143
-				$this->content_type = 'text/xml; charset=' . $charset_encoding;
2144
-			else
2145
-				$this->content_type = 'text/xml';
1906
+			if ($charset_encoding != '') {
1907
+							$this->content_type = 'text/xml; charset=' . $charset_encoding;
1908
+			} else {
1909
+							$this->content_type = 'text/xml';
1910
+			}
2146 1911
 			$this->payload=$this->xml_header($charset_encoding);
2147 1912
 			$this->payload.='<methodName>' . $this->methodname . "</methodName>\n";
2148 1913
 			$this->payload.="<params>\n";
2149
-			for($i=0; $i<count($this->params); $i++)
2150
-			{
1914
+			for($i=0; $i<count($this->params); $i++) {
2151 1915
 				$p=$this->params[$i];
2152 1916
 				$this->payload.="<param>\n" . $p->serialize($charset_encoding) .
2153 1917
 				"</param>\n";
@@ -2164,8 +1928,7 @@  discard block
 block discarded – undo
2164 1928
 		*/
2165 1929
 		function method($meth='')
2166 1930
 		{
2167
-			if($meth!='')
2168
-			{
1931
+			if($meth!='') {
2169 1932
 				$this->methodname=$meth;
2170 1933
 			}
2171 1934
 			return $this->methodname;
@@ -2191,13 +1954,10 @@  discard block
 block discarded – undo
2191 1954
 		function addParam($par)
2192 1955
 		{
2193 1956
 			// add check: do not add to self params which are not xmlrpcvals
2194
-			if(is_object($par) && is_a($par, 'xmlrpcval'))
2195
-			{
1957
+			if(is_object($par) && is_a($par, 'xmlrpcval')) {
2196 1958
 				$this->params[]=$par;
2197 1959
 				return true;
2198
-			}
2199
-			else
2200
-			{
1960
+			} else {
2201 1961
 				return false;
2202 1962
 			}
2203 1963
 		}
@@ -2208,14 +1968,18 @@  discard block
 block discarded – undo
2208 1968
 		* @return xmlrpcval the i-th parameter
2209 1969
 		* @access public
2210 1970
 		*/
2211
-		function getParam($i) { return $this->params[$i]; }
1971
+		function getParam($i)
1972
+		{
1973
+return $this->params[$i]; }
2212 1974
 
2213 1975
 		/**
2214 1976
 		* Returns the number of parameters in the messge.
2215 1977
 		* @return integer the number of parameters currently set
2216 1978
 		* @access public
2217 1979
 		*/
2218
-		function getNumParams() { return count($this->params); }
1980
+		function getNumParams()
1981
+		{
1982
+return count($this->params); }
2219 1983
 
2220 1984
 		/**
2221 1985
 		* Given an open file handle, read all data available and parse it as axmlrpc response.
@@ -2232,8 +1996,7 @@  discard block
 block discarded – undo
2232 1996
 		function &parseResponseFile($fp)
2233 1997
 		{
2234 1998
 			$ipd='';
2235
-			while($data=fread($fp, 32768))
2236
-			{
1999
+			while($data=fread($fp, 32768)) {
2237 2000
 				$ipd.=$data;
2238 2001
 			}
2239 2002
 			//fclose($fp);
@@ -2248,36 +2011,26 @@  discard block
 block discarded – undo
2248 2011
 		function &parseResponseHeaders(&$data, $headers_processed=false)
2249 2012
 		{
2250 2013
 				// Support "web-proxy-tunelling" connections for https through proxies
2251
-				if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data))
2252
-				{
2014
+				if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data)) {
2253 2015
 					// Look for CR/LF or simple LF as line separator,
2254 2016
 					// (even though it is not valid http)
2255 2017
 					$pos = strpos($data,"\r\n\r\n");
2256
-					if($pos || is_int($pos))
2257
-					{
2018
+					if($pos || is_int($pos)) {
2258 2019
 						$bd = $pos+4;
2259
-					}
2260
-					else
2261
-					{
2020
+					} else {
2262 2021
 						$pos = strpos($data,"\n\n");
2263
-						if($pos || is_int($pos))
2264
-						{
2022
+						if($pos || is_int($pos)) {
2265 2023
 							$bd = $pos+2;
2266
-						}
2267
-						else
2268
-						{
2024
+						} else {
2269 2025
 							// No separation between response headers and body: fault?
2270 2026
 							$bd = 0;
2271 2027
 						}
2272 2028
 					}
2273
-					if ($bd)
2274
-					{
2029
+					if ($bd) {
2275 2030
 						// this filters out all http headers from proxy.
2276 2031
 						// maybe we could take them into account, too?
2277 2032
 						$data = substr($data, $bd);
2278
-					}
2279
-					else
2280
-					{
2033
+					} else {
2281 2034
 						error_log('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed');
2282 2035
 						$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)');
2283 2036
 						return $r;
@@ -2285,19 +2038,19 @@  discard block
 block discarded – undo
2285 2038
 				}
2286 2039
 
2287 2040
 				// Strip HTTP 1.1 100 Continue header if present
2288
-				while(preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data))
2289
-				{
2041
+				while(preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data)) {
2290 2042
 					$pos = strpos($data, 'HTTP', 12);
2291 2043
 					// server sent a Continue header without any (valid) content following...
2292 2044
 					// give the client a chance to know it
2293
-					if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5
2045
+					if(!$pos && !is_int($pos)) {
2046
+					    // works fine in php 3, 4 and 5
2294 2047
 					{
2295 2048
 						break;
2296 2049
 					}
2050
+					}
2297 2051
 					$data = substr($data, $pos);
2298 2052
 				}
2299
-				if(!preg_match('/^HTTP\/[0-9.]+ 200 /', $data))
2300
-				{
2053
+				if(!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) {
2301 2054
 					$errstr= substr($data, 0, strpos($data, "\n")-1);
2302 2055
 					error_log('XML-RPC: '.__METHOD__.': HTTP error, got response: ' .$errstr);
2303 2056
 					$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (' . $errstr . ')');
@@ -2310,19 +2063,13 @@  discard block
 block discarded – undo
2310 2063
 				// be tolerant to usage of \n instead of \r\n to separate headers and data
2311 2064
 				// (even though it is not valid http)
2312 2065
 				$pos = strpos($data,"\r\n\r\n");
2313
-				if($pos || is_int($pos))
2314
-				{
2066
+				if($pos || is_int($pos)) {
2315 2067
 					$bd = $pos+4;
2316
-				}
2317
-				else
2318
-				{
2068
+				} else {
2319 2069
 					$pos = strpos($data,"\n\n");
2320
-					if($pos || is_int($pos))
2321
-					{
2070
+					if($pos || is_int($pos)) {
2322 2071
 						$bd = $pos+2;
2323
-					}
2324
-					else
2325
-					{
2072
+					} else {
2326 2073
 						// No separation between response headers and body: fault?
2327 2074
 						// we could take some action here instead of going on...
2328 2075
 						$bd = 0;
@@ -2330,70 +2077,55 @@  discard block
 block discarded – undo
2330 2077
 				}
2331 2078
 				// be tolerant to line endings, and extra empty lines
2332 2079
 				$ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));
2333
-				while(list(,$line) = @each($ar))
2334
-				{
2080
+				while(list(,$line) = @each($ar)) {
2335 2081
 					// take care of multi-line headers and cookies
2336 2082
 					$arr = explode(':',$line,2);
2337
-					if(count($arr) > 1)
2338
-					{
2083
+					if(count($arr) > 1) {
2339 2084
 						$header_name = strtolower(trim($arr[0]));
2340 2085
 						/// @todo some other headers (the ones that allow a CSV list of values)
2341 2086
 						/// do allow many values to be passed using multiple header lines.
2342 2087
 						/// We should add content to $GLOBALS['_xh']['headers'][$header_name]
2343 2088
 						/// instead of replacing it for those...
2344
-						if ($header_name == 'set-cookie' || $header_name == 'set-cookie2')
2345
-						{
2346
-							if ($header_name == 'set-cookie2')
2347
-							{
2089
+						if ($header_name == 'set-cookie' || $header_name == 'set-cookie2') {
2090
+							if ($header_name == 'set-cookie2') {
2348 2091
 								// version 2 cookies:
2349 2092
 								// there could be many cookies on one line, comma separated
2350 2093
 								$cookies = explode(',', $arr[1]);
2351
-							}
2352
-							else
2353
-							{
2094
+							} else {
2354 2095
 								$cookies = array($arr[1]);
2355 2096
 							}
2356
-							foreach ($cookies as $cookie)
2357
-							{
2097
+							foreach ($cookies as $cookie) {
2358 2098
 								// glue together all received cookies, using a comma to separate them
2359 2099
 								// (same as php does with getallheaders())
2360
-								if (isset($GLOBALS['_xh']['headers'][$header_name]))
2361
-									$GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie);
2362
-								else
2363
-									$GLOBALS['_xh']['headers'][$header_name] = trim($cookie);
2100
+								if (isset($GLOBALS['_xh']['headers'][$header_name])) {
2101
+																	$GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie);
2102
+								} else {
2103
+																	$GLOBALS['_xh']['headers'][$header_name] = trim($cookie);
2104
+								}
2364 2105
 								// parse cookie attributes, in case user wants to correctly honour them
2365 2106
 								// feature creep: only allow rfc-compliant cookie attributes?
2366 2107
 								// @todo support for server sending multiple time cookie with same name, but using different PATHs
2367 2108
 								$cookie = explode(';', $cookie);
2368
-								foreach ($cookie as $pos => $val)
2369
-								{
2109
+								foreach ($cookie as $pos => $val) {
2370 2110
 									$val = explode('=', $val, 2);
2371 2111
 									$tag = trim($val[0]);
2372 2112
 									$val = trim(@$val[1]);
2373 2113
 									/// @todo with version 1 cookies, we should strip leading and trailing " chars
2374
-									if ($pos == 0)
2375
-									{
2114
+									if ($pos == 0) {
2376 2115
 										$cookiename = $tag;
2377 2116
 										$GLOBALS['_xh']['cookies'][$tag] = array();
2378 2117
 										$GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val);
2379
-									}
2380
-									else
2381
-									{
2382
-										if ($tag != 'value')
2383
-										{
2118
+									} else {
2119
+										if ($tag != 'value') {
2384 2120
 										  $GLOBALS['_xh']['cookies'][$cookiename][$tag] = $val;
2385 2121
 										}
2386 2122
 									}
2387 2123
 								}
2388 2124
 							}
2389
-						}
2390
-						else
2391
-						{
2125
+						} else {
2392 2126
 							$GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]);
2393 2127
 						}
2394
-					}
2395
-					elseif(isset($header_name))
2396
-					{
2128
+					} elseif(isset($header_name)) {
2397 2129
 						///	@todo version1 cookies might span multiple lines, thus breaking the parsing above
2398 2130
 						$GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line);
2399 2131
 					}
@@ -2401,15 +2133,12 @@  discard block
 block discarded – undo
2401 2133
 
2402 2134
 				$data = substr($data, $bd);
2403 2135
 
2404
-				if($this->debug && count($GLOBALS['_xh']['headers']))
2405
-				{
2136
+				if($this->debug && count($GLOBALS['_xh']['headers'])) {
2406 2137
 					print '<PRE>';
2407
-					foreach($GLOBALS['_xh']['headers'] as $header => $value)
2408
-					{
2138
+					foreach($GLOBALS['_xh']['headers'] as $header => $value) {
2409 2139
 						print htmlentities("HEADER: $header: $value\n");
2410 2140
 					}
2411
-					foreach($GLOBALS['_xh']['cookies'] as $header => $value)
2412
-					{
2141
+					foreach($GLOBALS['_xh']['cookies'] as $header => $value) {
2413 2142
 						print htmlentities("COOKIE: $header={$value['value']}\n");
2414 2143
 					}
2415 2144
 					print "</PRE>\n";
@@ -2417,13 +2146,10 @@  discard block
 block discarded – undo
2417 2146
 
2418 2147
 				// if CURL was used for the call, http headers have been processed,
2419 2148
 				// and dechunking + reinflating have been carried out
2420
-				if(!$headers_processed)
2421
-				{
2149
+				if(!$headers_processed) {
2422 2150
 					// Decode chunked encoding sent by http 1.1 servers
2423
-					if(isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked')
2424
-					{
2425
-						if(!$data = decode_chunked($data))
2426
-						{
2151
+					if(isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked') {
2152
+						if(!$data = decode_chunked($data)) {
2427 2153
 							error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server');
2428 2154
 							$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['dechunk_fail'], $GLOBALS['xmlrpcstr']['dechunk_fail']);
2429 2155
 							return $r;
@@ -2432,35 +2158,27 @@  discard block
 block discarded – undo
2432 2158
 
2433 2159
 					// Decode gzip-compressed stuff
2434 2160
 					// code shamelessly inspired from nusoap library by Dietrich Ayala
2435
-					if(isset($GLOBALS['_xh']['headers']['content-encoding']))
2436
-					{
2161
+					if(isset($GLOBALS['_xh']['headers']['content-encoding'])) {
2437 2162
 						$GLOBALS['_xh']['headers']['content-encoding'] = str_replace('x-', '', $GLOBALS['_xh']['headers']['content-encoding']);
2438
-						if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip')
2439
-						{
2163
+						if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip') {
2440 2164
 							// if decoding works, use it. else assume data wasn't gzencoded
2441
-							if(function_exists('gzinflate'))
2442
-							{
2443
-								if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data))
2444
-								{
2165
+							if(function_exists('gzinflate')) {
2166
+								if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
2445 2167
 									$data = $degzdata;
2446
-									if($this->debug)
2447
-									print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2448
-								}
2449
-								elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
2450
-								{
2168
+									if($this->debug) {
2169
+																		print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2170
+									}
2171
+								} elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
2451 2172
 									$data = $degzdata;
2452
-									if($this->debug)
2453
-									print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2454
-								}
2455
-								else
2456
-								{
2173
+									if($this->debug) {
2174
+																		print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2175
+									}
2176
+								} else {
2457 2177
 									error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server');
2458 2178
 									$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']);
2459 2179
 									return $r;
2460 2180
 								}
2461
-							}
2462
-							else
2463
-							{
2181
+							} else {
2464 2182
 								error_log('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
2465 2183
 								$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']);
2466 2184
 								return $r;
@@ -2485,14 +2203,12 @@  discard block
 block discarded – undo
2485 2203
 		*/
2486 2204
 		function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals')
2487 2205
 		{
2488
-			if($this->debug)
2489
-			{
2206
+			if($this->debug) {
2490 2207
 				//by maHo, replaced htmlspecialchars with htmlentities
2491 2208
 				print "<PRE>---GOT---\n" . htmlentities($data) . "\n---END---\n</PRE>";
2492 2209
 			}
2493 2210
 
2494
-			if($data == '')
2495
-			{
2211
+			if($data == '') {
2496 2212
 				error_log('XML-RPC: '.__METHOD__.': no response received from server.');
2497 2213
 				$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_data'], $GLOBALS['xmlrpcstr']['no_data']);
2498 2214
 				return $r;
@@ -2502,28 +2218,22 @@  discard block
 block discarded – undo
2502 2218
 
2503 2219
 			$raw_data = $data;
2504 2220
 			// parse the HTTP headers of the response, if present, and separate them from data
2505
-			if(substr($data, 0, 4) == 'HTTP')
2506
-			{
2221
+			if(substr($data, 0, 4) == 'HTTP') {
2507 2222
 				$r =& $this->parseResponseHeaders($data, $headers_processed);
2508
-				if ($r)
2509
-				{
2223
+				if ($r) {
2510 2224
 					// failed processing of HTTP response headers
2511 2225
 					// save into response obj the full payload received, for debugging
2512 2226
 					$r->raw_data = $data;
2513 2227
 					return $r;
2514 2228
 				}
2515
-			}
2516
-			else
2517
-			{
2229
+			} else {
2518 2230
 				$GLOBALS['_xh']['headers'] = array();
2519 2231
 				$GLOBALS['_xh']['cookies'] = array();
2520 2232
 			}
2521 2233
 
2522
-			if($this->debug)
2523
-			{
2234
+			if($this->debug) {
2524 2235
 				$start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
2525
-				if ($start)
2526
-				{
2236
+				if ($start) {
2527 2237
 					$start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
2528 2238
 					$end = strpos($data, '-->', $start);
2529 2239
 					$comments = substr($data, $start, $end-$start);
@@ -2539,14 +2249,12 @@  discard block
 block discarded – undo
2539 2249
 			// be tolerant of junk after methodResponse (e.g. javascript ads automatically inserted by free hosts)
2540 2250
 			// idea from Luca Mariano <[email protected]> originally in PEARified version of the lib
2541 2251
 			$pos = strrpos($data, '</methodResponse>');
2542
-			if($pos !== false)
2543
-			{
2252
+			if($pos !== false) {
2544 2253
 				$data = substr($data, 0, $pos+17);
2545 2254
 			}
2546 2255
 
2547 2256
 			// if user wants back raw xml, give it to him
2548
-			if ($return_type == 'xml')
2549
-			{
2257
+			if ($return_type == 'xml') {
2550 2258
 				$r = new xmlrpcresp($data, 0, '', 'xml');
2551 2259
 				$r->hdrs = $GLOBALS['_xh']['headers'];
2552 2260
 				$r->_cookies = $GLOBALS['_xh']['cookies'];
@@ -2567,12 +2275,13 @@  discard block
 block discarded – undo
2567 2275
 
2568 2276
 			// if response charset encoding is not known / supported, try to use
2569 2277
 			// the default encoding and parse the xml anyway, but log a warning...
2570
-			if (!in_array($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
2571
-			// the following code might be better for mb_string enabled installs, but
2278
+			if (!in_array($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) {
2279
+						// the following code might be better for mb_string enabled installs, but
2572 2280
 			// makes the lib about 200% slower...
2573 2281
 			//if (!is_valid_charset($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
2574 2282
 			{
2575 2283
 				error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received response: '.$resp_encoding);
2284
+			}
2576 2285
 				$resp_encoding = $GLOBALS['xmlrpc_defencoding'];
2577 2286
 			}
2578 2287
 			$parser = xml_parser_create($resp_encoding);
@@ -2583,21 +2292,15 @@  discard block
 block discarded – undo
2583 2292
 			// we use the broadest one, ie. utf8
2584 2293
 			// This allows to send data which is native in various charset,
2585 2294
 			// by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding
2586
-			if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
2587
-			{
2295
+			if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) {
2588 2296
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
2589
-			}
2590
-			else
2591
-			{
2297
+			} else {
2592 2298
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
2593 2299
 			}
2594 2300
 
2595
-			if ($return_type == 'phpvals')
2596
-			{
2301
+			if ($return_type == 'phpvals') {
2597 2302
 				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
2598
-			}
2599
-			else
2600
-			{
2303
+			} else {
2601 2304
 				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
2602 2305
 			}
2603 2306
 
@@ -2605,15 +2308,11 @@  discard block
 block discarded – undo
2605 2308
 			xml_set_default_handler($parser, 'xmlrpc_dh');
2606 2309
 
2607 2310
 			// first error check: xml not well formed
2608
-			if(!xml_parse($parser, $data, count($data)))
2609
-			{
2311
+			if(!xml_parse($parser, $data, count($data))) {
2610 2312
 				// thanks to Peter Kocks <[email protected]>
2611
-				if((xml_get_current_line_number($parser)) == 1)
2612
-				{
2313
+				if((xml_get_current_line_number($parser)) == 1) {
2613 2314
 					$errstr = 'XML error at line 1, check URL';
2614
-				}
2615
-				else
2616
-				{
2315
+				} else {
2617 2316
 					$errstr = sprintf('XML error: %s at line %d, column %d',
2618 2317
 						xml_error_string(xml_get_error_code($parser)),
2619 2318
 						xml_get_current_line_number($parser), xml_get_current_column_number($parser));
@@ -2621,8 +2320,7 @@  discard block
 block discarded – undo
2621 2320
 				error_log($errstr);
2622 2321
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcstr']['invalid_return'].' ('.$errstr.')');
2623 2322
 				xml_parser_free($parser);
2624
-				if($this->debug)
2625
-				{
2323
+				if($this->debug) {
2626 2324
 					print $errstr;
2627 2325
 				}
2628 2326
 				$r->hdrs = $GLOBALS['_xh']['headers'];
@@ -2632,10 +2330,8 @@  discard block
 block discarded – undo
2632 2330
 			}
2633 2331
 			xml_parser_free($parser);
2634 2332
 			// second error check: xml well formed but not xml-rpc compliant
2635
-			if ($GLOBALS['_xh']['isf'] > 1)
2636
-			{
2637
-				if ($this->debug)
2638
-				{
2333
+			if ($GLOBALS['_xh']['isf'] > 1) {
2334
+				if ($this->debug) {
2639 2335
 					/// @todo echo something for user?
2640 2336
 				}
2641 2337
 
@@ -2644,18 +2340,14 @@  discard block
 block discarded – undo
2644 2340
 			}
2645 2341
 			// third error check: parsing of the response has somehow gone boink.
2646 2342
 			// NB: shall we omit this check, since we trust the parsing code?
2647
-			elseif ($return_type == 'xmlrpcvals' && !is_object($GLOBALS['_xh']['value']))
2648
-			{
2343
+			elseif ($return_type == 'xmlrpcvals' && !is_object($GLOBALS['_xh']['value'])) {
2649 2344
 				// something odd has happened
2650 2345
 				// and it's time to generate a client side error
2651 2346
 				// indicating something odd went on
2652 2347
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'],
2653 2348
 					$GLOBALS['xmlrpcstr']['invalid_return']);
2654
-			}
2655
-			else
2656
-			{
2657
-				if ($this->debug)
2658
-				{
2349
+			} else {
2350
+				if ($this->debug) {
2659 2351
 					print "<PRE>---PARSED---\n";
2660 2352
 					// somehow htmlentities chokes on var_export, and some full html string...
2661 2353
 					//print htmlentitites(var_export($GLOBALS['_xh']['value'], true));
@@ -2666,33 +2358,26 @@  discard block
 block discarded – undo
2666 2358
 				// note that using =& will raise an error if $GLOBALS['_xh']['st'] does not generate an object.
2667 2359
 				$v =& $GLOBALS['_xh']['value'];
2668 2360
 
2669
-				if($GLOBALS['_xh']['isf'])
2670
-				{
2361
+				if($GLOBALS['_xh']['isf']) {
2671 2362
 					/// @todo we should test here if server sent an int and a string,
2672 2363
 					/// and/or coerce them into such...
2673
-					if ($return_type == 'xmlrpcvals')
2674
-					{
2364
+					if ($return_type == 'xmlrpcvals') {
2675 2365
 						$errno_v = $v->structmem('faultCode');
2676 2366
 						$errstr_v = $v->structmem('faultString');
2677 2367
 						$errno = $errno_v->scalarval();
2678 2368
 						$errstr = $errstr_v->scalarval();
2679
-					}
2680
-					else
2681
-					{
2369
+					} else {
2682 2370
 						$errno = $v['faultCode'];
2683 2371
 						$errstr = $v['faultString'];
2684 2372
 					}
2685 2373
 
2686
-					if($errno == 0)
2687
-					{
2374
+					if($errno == 0) {
2688 2375
 						// FAULT returned, errno needs to reflect that
2689 2376
 						$errno = -1;
2690 2377
 					}
2691 2378
 
2692 2379
 					$r = new xmlrpcresp(0, $errno, $errstr);
2693
-				}
2694
-				else
2695
-				{
2380
+				} else {
2696 2381
 					$r=new xmlrpcresp($v, 0, '', $return_type);
2697 2382
 				}
2698 2383
 			}
@@ -2718,11 +2403,9 @@  discard block
 block discarded – undo
2718 2403
 		{
2719 2404
 			/// @todo: optimization creep - do not call addXX, do it all inline.
2720 2405
 			/// downside: booleans will not be coerced anymore
2721
-			if($val!==-1 || $type!='')
2722
-			{
2406
+			if($val!==-1 || $type!='') {
2723 2407
 				// optimization creep: inlined all work done by constructor
2724
-				switch($type)
2725
-				{
2408
+				switch($type) {
2726 2409
 					case '':
2727 2410
 						$this->mytype=1;
2728 2411
 						$this->me['string']=$val;
@@ -2777,8 +2460,7 @@  discard block
 block discarded – undo
2777 2460
 		function addScalar($val, $type='string')
2778 2461
 		{
2779 2462
 			$typeof=@$GLOBALS['xmlrpcTypes'][$type];
2780
-			if($typeof!=1)
2781
-			{
2463
+			if($typeof!=1) {
2782 2464
 				error_log("XML-RPC: ".__METHOD__.": not a scalar type ($type)");
2783 2465
 				return 0;
2784 2466
 			}
@@ -2786,20 +2468,15 @@  discard block
 block discarded – undo
2786 2468
 			// coerce booleans into correct values
2787 2469
 			// NB: we should either do it for datetimes, integers and doubles, too,
2788 2470
 			// or just plain remove this check, implemented on booleans only...
2789
-			if($type==$GLOBALS['xmlrpcBoolean'])
2790
-			{
2791
-				if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false')))
2792
-				{
2471
+			if($type==$GLOBALS['xmlrpcBoolean']) {
2472
+				if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false'))) {
2793 2473
 					$val=true;
2794
-				}
2795
-				else
2796
-				{
2474
+				} else {
2797 2475
 					$val=false;
2798 2476
 				}
2799 2477
 			}
2800 2478
 
2801
-			switch($this->mytype)
2802
-			{
2479
+			switch($this->mytype) {
2803 2480
 				case 1:
2804 2481
 					error_log('XML-RPC: '.__METHOD__.': scalar xmlrpcval can have only one value');
2805 2482
 					return 0;
@@ -2832,20 +2509,15 @@  discard block
 block discarded – undo
2832 2509
 		*/
2833 2510
 		function addArray($vals)
2834 2511
 		{
2835
-			if($this->mytype==0)
2836
-			{
2512
+			if($this->mytype==0) {
2837 2513
 				$this->mytype=$GLOBALS['xmlrpcTypes']['array'];
2838 2514
 				$this->me['array']=$vals;
2839 2515
 				return 1;
2840
-			}
2841
-			elseif($this->mytype==2)
2842
-			{
2516
+			} elseif($this->mytype==2) {
2843 2517
 				// we're adding to an array here
2844 2518
 				$this->me['array'] = array_merge($this->me['array'], $vals);
2845 2519
 				return 1;
2846
-			}
2847
-			else
2848
-			{
2520
+			} else {
2849 2521
 				error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
2850 2522
 				return 0;
2851 2523
 			}
@@ -2861,20 +2533,15 @@  discard block
 block discarded – undo
2861 2533
 		*/
2862 2534
 		function addStruct($vals)
2863 2535
 		{
2864
-			if($this->mytype==0)
2865
-			{
2536
+			if($this->mytype==0) {
2866 2537
 				$this->mytype=$GLOBALS['xmlrpcTypes']['struct'];
2867 2538
 				$this->me['struct']=$vals;
2868 2539
 				return 1;
2869
-			}
2870
-			elseif($this->mytype==3)
2871
-			{
2540
+			} elseif($this->mytype==3) {
2872 2541
 				// we're adding to a struct here
2873 2542
 				$this->me['struct'] = array_merge($this->me['struct'], $vals);
2874 2543
 				return 1;
2875
-			}
2876
-			else
2877
-			{
2544
+			} else {
2878 2545
 				error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
2879 2546
 				return 0;
2880 2547
 			}
@@ -2884,13 +2551,10 @@  discard block
 block discarded – undo
2884 2551
 		// DEPRECATED!
2885 2552
 		function dump($ar)
2886 2553
 		{
2887
-			foreach($ar as $key => $val)
2888
-			{
2554
+			foreach($ar as $key => $val) {
2889 2555
 				echo "$key => $val<br />";
2890
-				if($key == 'array')
2891
-				{
2892
-					while(list($key2, $val2) = each($val))
2893
-					{
2556
+				if($key == 'array') {
2557
+					while(list($key2, $val2) = each($val)) {
2894 2558
 						echo "-- $key2 => $val2<br />";
2895 2559
 					}
2896 2560
 				}
@@ -2904,8 +2568,7 @@  discard block
 block discarded – undo
2904 2568
 		*/
2905 2569
 		function kindOf()
2906 2570
 		{
2907
-			switch($this->mytype)
2908
-			{
2571
+			switch($this->mytype) {
2909 2572
 				case 3:
2910 2573
 					return 'struct';
2911 2574
 					break;
@@ -2926,11 +2589,9 @@  discard block
 block discarded – undo
2926 2589
 		function serializedata($typ, $val, $charset_encoding='')
2927 2590
 		{
2928 2591
 			$rs='';
2929
-			switch(@$GLOBALS['xmlrpcTypes'][$typ])
2930
-			{
2592
+			switch(@$GLOBALS['xmlrpcTypes'][$typ]) {
2931 2593
 				case 1:
2932
-					switch($typ)
2933
-					{
2594
+					switch($typ) {
2934 2595
 						case $GLOBALS['xmlrpcBase64']:
2935 2596
 							$rs.="<${typ}>" . base64_encode($val) . "</${typ}>";
2936 2597
 							break;
@@ -2955,31 +2616,24 @@  discard block
 block discarded – undo
2955 2616
 							$rs.="<${typ}>".preg_replace('/\\.?0+$/','',number_format((double)$val, 128, '.', ''))."</${typ}>";
2956 2617
 							break;
2957 2618
 						case $GLOBALS['xmlrpcDateTime']:
2958
-							if (is_string($val))
2959
-							{
2619
+							if (is_string($val)) {
2960 2620
 								$rs.="<${typ}>${val}</${typ}>";
2961 2621
 							}
2962
-							else if(is_a($val, 'DateTime'))
2963
-							{
2622
+							else if(is_a($val, 'DateTime')) {
2964 2623
 								$rs.="<${typ}>".$val->format('Ymd\TH:i:s')."</${typ}>";
2965 2624
 							}
2966
-							else if(is_int($val))
2967
-							{
2625
+							else if(is_int($val)) {
2968 2626
 								$rs.="<${typ}>".strftime("%Y%m%dT%H:%M:%S", $val)."</${typ}>";
2969 2627
 							}
2970
-							else
2971
-							{
2628
+							else {
2972 2629
 								// not really a good idea here: but what shall we output anyway? left for backward compat...
2973 2630
 								$rs.="<${typ}>${val}</${typ}>";
2974 2631
 							}
2975 2632
 							break;
2976 2633
 						case $GLOBALS['xmlrpcNull']:
2977
-							if ($GLOBALS['xmlrpc_null_apache_encoding'])
2978
-							{
2634
+							if ($GLOBALS['xmlrpc_null_apache_encoding']) {
2979 2635
 								$rs.="<ex:nil/>";
2980
-							}
2981
-							else
2982
-							{
2636
+							} else {
2983 2637
 								$rs.="<nil/>";
2984 2638
 							}
2985 2639
 							break;
@@ -2991,16 +2645,12 @@  discard block
 block discarded – undo
2991 2645
 					break;
2992 2646
 				case 3:
2993 2647
 					// struct
2994
-					if ($this->_php_class)
2995
-					{
2648
+					if ($this->_php_class) {
2996 2649
 						$rs.='<struct php_class="' . $this->_php_class . "\">\n";
2997
-					}
2998
-					else
2999
-					{
2650
+					} else {
3000 2651
 						$rs.="<struct>\n";
3001 2652
 					}
3002
-					foreach($val as $key2 => $val2)
3003
-					{
2653
+					foreach($val as $key2 => $val2) {
3004 2654
 						$rs.='<member><name>'.xmlrpc_encode_entitites($key2, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</name>\n";
3005 2655
 						//$rs.=$this->serializeval($val2);
3006 2656
 						$rs.=$val2->serialize($charset_encoding);
@@ -3011,8 +2661,7 @@  discard block
 block discarded – undo
3011 2661
 				case 2:
3012 2662
 					// array
3013 2663
 					$rs.="<array>\n<data>\n";
3014
-					for($i=0; $i<count($val); $i++)
3015
-					{
2664
+					for($i=0; $i<count($val); $i++) {
3016 2665
 						//$rs.=$this->serializeval($val[$i]);
3017 2666
 						$rs.=$val[$i]->serialize($charset_encoding);
3018 2667
 					}
@@ -3109,27 +2758,22 @@  discard block
 block discarded – undo
3109 2758
 			// i've created a new method here, so as to
3110 2759
 			// preserve back compatibility
3111 2760
 
3112
-			if(is_array($b))
3113
-			{
2761
+			if(is_array($b)) {
3114 2762
 				@reset($b);
3115
-				while(list($id,$cont) = @each($b))
3116
-				{
2763
+				while(list($id,$cont) = @each($b)) {
3117 2764
 					$b[$id] = $cont->scalarval();
3118 2765
 				}
3119 2766
 			}
3120 2767
 
3121 2768
 			// add support for structures directly encoding php objects
3122
-			if(is_object($b))
3123
-			{
2769
+			if(is_object($b)) {
3124 2770
 				$t = get_object_vars($b);
3125 2771
 				@reset($t);
3126
-				while(list($id,$cont) = @each($t))
3127
-				{
2772
+				while(list($id,$cont) = @each($t)) {
3128 2773
 					$t[$id] = $cont->scalarval();
3129 2774
 				}
3130 2775
 				@reset($t);
3131
-				while(list($id,$cont) = @each($t))
3132
-				{
2776
+				while(list($id,$cont) = @each($t)) {
3133 2777
 					@$b->$id = $cont;
3134 2778
 				}
3135 2779
 			}
@@ -3159,8 +2803,7 @@  discard block
 block discarded – undo
3159 2803
 		{
3160 2804
 			reset($this->me);
3161 2805
 			list($a,)=each($this->me);
3162
-			if($a==$GLOBALS['xmlrpcI4'])
3163
-			{
2806
+			if($a==$GLOBALS['xmlrpcI4']) {
3164 2807
 				$a=$GLOBALS['xmlrpcInt'];
3165 2808
 			}
3166 2809
 			return $a;
@@ -3220,20 +2863,14 @@  discard block
 block discarded – undo
3220 2863
 	*/
3221 2864
 	function iso8601_encode($timet, $utc=0)
3222 2865
 	{
3223
-		if(!$utc)
3224
-		{
2866
+		if(!$utc) {
3225 2867
 			$t=strftime("%Y%m%dT%H:%M:%S", $timet);
3226
-		}
3227
-		else
3228
-		{
3229
-			if(function_exists('gmstrftime'))
3230
-			{
2868
+		} else {
2869
+			if(function_exists('gmstrftime')) {
3231 2870
 				// gmstrftime doesn't exist in some versions
3232 2871
 				// of PHP
3233 2872
 				$t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
3234
-			}
3235
-			else
3236
-			{
2873
+			} else {
3237 2874
 				$t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z'));
3238 2875
 			}
3239 2876
 		}
@@ -3249,14 +2886,10 @@  discard block
 block discarded – undo
3249 2886
 	function iso8601_decode($idate, $utc=0)
3250 2887
 	{
3251 2888
 		$t=0;
3252
-		if(preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs))
3253
-		{
3254
-			if($utc)
3255
-			{
2889
+		if(preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs)) {
2890
+			if($utc) {
3256 2891
 				$t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3257
-			}
3258
-			else
3259
-			{
2892
+			} else {
3260 2893
 				$t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3261 2894
 			}
3262 2895
 		}
@@ -3286,15 +2919,12 @@  discard block
 block discarded – undo
3286 2919
 	*/
3287 2920
 	function php_xmlrpc_decode($xmlrpc_val, $options=array())
3288 2921
 	{
3289
-		switch($xmlrpc_val->kindOf())
3290
-		{
2922
+		switch($xmlrpc_val->kindOf()) {
3291 2923
 			case 'scalar':
3292
-				if (in_array('extension_api', $options))
3293
-				{
2924
+				if (in_array('extension_api', $options)) {
3294 2925
 					reset($xmlrpc_val->me);
3295 2926
 					list($typ,$val) = each($xmlrpc_val->me);
3296
-					switch ($typ)
3297
-					{
2927
+					switch ($typ) {
3298 2928
 						case 'dateTime.iso8601':
3299 2929
 							$xmlrpc_val->scalar = $val;
3300 2930
 							$xmlrpc_val->xmlrpc_type = 'datetime';
@@ -3308,24 +2938,19 @@  discard block
 block discarded – undo
3308 2938
 							return $xmlrpc_val->scalarval();
3309 2939
 					}
3310 2940
 				}
3311
-				if (in_array('dates_as_objects', $options) && $xmlrpc_val->scalartyp() == 'dateTime.iso8601')
3312
-				{
2941
+				if (in_array('dates_as_objects', $options) && $xmlrpc_val->scalartyp() == 'dateTime.iso8601') {
3313 2942
 					// we return a Datetime object instead of a string
3314 2943
 					// since now the constructor of xmlrpcval accepts safely strings, ints and datetimes,
3315 2944
 					// we cater to all 3 cases here
3316 2945
 					$out = $xmlrpc_val->scalarval();
3317
-					if (is_string($out))
3318
-					{
2946
+					if (is_string($out)) {
3319 2947
 						$out = strtotime($out);
3320 2948
 					}
3321
-					if (is_int($out))
3322
-					{
2949
+					if (is_int($out)) {
3323 2950
 						$result = new Datetime();
3324 2951
 						$result->setTimestamp($out);
3325 2952
 						return $result;
3326
-					}
3327
-					elseif (is_a($out, 'Datetime'))
3328
-					{
2953
+					} elseif (is_a($out, 'Datetime')) {
3329 2954
 						return $out;
3330 2955
 					}
3331 2956
 				}
@@ -3333,8 +2958,7 @@  discard block
 block discarded – undo
3333 2958
 			case 'array':
3334 2959
 				$size = $xmlrpc_val->arraysize();
3335 2960
 				$arr = array();
3336
-				for($i = 0; $i < $size; $i++)
3337
-				{
2961
+				for($i = 0; $i < $size; $i++) {
3338 2962
 					$arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options);
3339 2963
 				}
3340 2964
 				return $arr;
@@ -3345,20 +2969,15 @@  discard block
 block discarded – undo
3345 2969
 				// shall we check for proper subclass of xmlrpcval instead of
3346 2970
 				// presence of _php_class to detect what we can do?
3347 2971
 				if (in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != ''
3348
-					&& class_exists($xmlrpc_val->_php_class))
3349
-				{
2972
+					&& class_exists($xmlrpc_val->_php_class)) {
3350 2973
 					$obj = @new $xmlrpc_val->_php_class;
3351
-					while(list($key,$value)=$xmlrpc_val->structeach())
3352
-					{
2974
+					while(list($key,$value)=$xmlrpc_val->structeach()) {
3353 2975
 						$obj->$key = php_xmlrpc_decode($value, $options);
3354 2976
 					}
3355 2977
 					return $obj;
3356
-				}
3357
-				else
3358
-				{
2978
+				} else {
3359 2979
 					$arr = array();
3360
-					while(list($key,$value)=$xmlrpc_val->structeach())
3361
-					{
2980
+					while(list($key,$value)=$xmlrpc_val->structeach()) {
3362 2981
 						$arr[$key] = php_xmlrpc_decode($value, $options);
3363 2982
 					}
3364 2983
 					return $arr;
@@ -3366,8 +2985,7 @@  discard block
 block discarded – undo
3366 2985
 			case 'msg':
3367 2986
 				$paramcount = $xmlrpc_val->getNumParams();
3368 2987
 				$arr = array();
3369
-				for($i = 0; $i < $paramcount; $i++)
3370
-				{
2988
+				for($i = 0; $i < $paramcount; $i++) {
3371 2989
 					$arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i));
3372 2990
 				}
3373 2991
 				return $arr;
@@ -3377,12 +2995,9 @@  discard block
 block discarded – undo
3377 2995
 	// This constant left here only for historical reasons...
3378 2996
 	// it was used to decide if we have to define xmlrpc_encode on our own, but
3379 2997
 	// we do not do it anymore
3380
-	if(function_exists('xmlrpc_decode'))
3381
-	{
2998
+	if(function_exists('xmlrpc_decode')) {
3382 2999
 		define('XMLRPC_EPI_ENABLED','1');
3383
-	}
3384
-	else
3385
-	{
3000
+	} else {
3386 3001
 		define('XMLRPC_EPI_ENABLED','0');
3387 3002
 	}
3388 3003
 
@@ -3406,13 +3021,13 @@  discard block
 block discarded – undo
3406 3021
 	function php_xmlrpc_encode($php_val, $options=array())
3407 3022
 	{
3408 3023
 		$type = gettype($php_val);
3409
-		switch($type)
3410
-		{
3024
+		switch($type) {
3411 3025
 			case 'string':
3412
-				if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val))
3413
-					$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3414
-				else
3415
-					$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3026
+				if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) {
3027
+									$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3028
+				} else {
3029
+									$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3030
+				}
3416 3031
 				break;
3417 3032
 			case 'integer':
3418 3033
 				$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']);
@@ -3435,44 +3050,32 @@  discard block
 block discarded – undo
3435 3050
 				$j = 0;
3436 3051
 				$arr = array();
3437 3052
 				$ko = false;
3438
-				foreach($php_val as $key => $val)
3439
-				{
3053
+				foreach($php_val as $key => $val) {
3440 3054
 					$arr[$key] = php_xmlrpc_encode($val, $options);
3441
-					if(!$ko && $key !== $j)
3442
-					{
3055
+					if(!$ko && $key !== $j) {
3443 3056
 						$ko = true;
3444 3057
 					}
3445 3058
 					$j++;
3446 3059
 				}
3447
-				if($ko)
3448
-				{
3060
+				if($ko) {
3449 3061
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
3450
-				}
3451
-				else
3452
-				{
3062
+				} else {
3453 3063
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcArray']);
3454 3064
 				}
3455 3065
 				break;
3456 3066
 			case 'object':
3457
-				if(is_a($php_val, 'xmlrpcval'))
3458
-				{
3067
+				if(is_a($php_val, 'xmlrpcval')) {
3459 3068
 					$xmlrpc_val = $php_val;
3460
-				}
3461
-				else if(is_a($php_val, 'DateTime'))
3462
-				{
3069
+				} else if(is_a($php_val, 'DateTime')) {
3463 3070
 					$xmlrpc_val = new xmlrpcval($php_val->format('Ymd\TH:i:s'), $GLOBALS['xmlrpcStruct']);
3464
-				}
3465
-				else
3466
-				{
3071
+				} else {
3467 3072
 					$arr = array();
3468 3073
 					reset($php_val);
3469
-					while(list($k,$v) = each($php_val))
3470
-					{
3074
+					while(list($k,$v) = each($php_val)) {
3471 3075
 						$arr[$k] = php_xmlrpc_encode($v, $options);
3472 3076
 					}
3473 3077
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
3474
-					if (in_array('encode_php_objs', $options))
3475
-					{
3078
+					if (in_array('encode_php_objs', $options)) {
3476 3079
 						// let's save original class name into xmlrpcval:
3477 3080
 						// might be useful later on...
3478 3081
 						$xmlrpc_val->_php_class = get_class($php_val);
@@ -3480,26 +3083,18 @@  discard block
 block discarded – undo
3480 3083
 				}
3481 3084
 				break;
3482 3085
 			case 'NULL':
3483
-				if (in_array('extension_api', $options))
3484
-				{
3086
+				if (in_array('extension_api', $options)) {
3485 3087
 					$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcString']);
3486
-				}
3487
-				else if (in_array('null_extension', $options))
3488
-				{
3088
+				} else if (in_array('null_extension', $options)) {
3489 3089
 					$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcNull']);
3490
-				}
3491
-				else
3492
-				{
3090
+				} else {
3493 3091
 					$xmlrpc_val = new xmlrpcval();
3494 3092
 				}
3495 3093
 				break;
3496 3094
 			case 'resource':
3497
-				if (in_array('extension_api', $options))
3498
-				{
3095
+				if (in_array('extension_api', $options)) {
3499 3096
 					$xmlrpc_val = new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']);
3500
-				}
3501
-				else
3502
-				{
3097
+				} else {
3503 3098
 					$xmlrpc_val = new xmlrpcval();
3504 3099
 				}
3505 3100
 			// catch "user function", "unknown type"
@@ -3537,19 +3132,15 @@  discard block
 block discarded – undo
3537 3132
 		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
3538 3133
 		// What if internal encoding is not in one of the 3 allowed?
3539 3134
 		// we use the broadest one, ie. utf8!
3540
-		if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
3541
-		{
3135
+		if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) {
3542 3136
 			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
3543
-		}
3544
-		else
3545
-		{
3137
+		} else {
3546 3138
 			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
3547 3139
 		}
3548 3140
 		xml_set_element_handler($parser, 'xmlrpc_se_any', 'xmlrpc_ee');
3549 3141
 		xml_set_character_data_handler($parser, 'xmlrpc_cd');
3550 3142
 		xml_set_default_handler($parser, 'xmlrpc_dh');
3551
-		if(!xml_parse($parser, $xml_val, 1))
3552
-		{
3143
+		if(!xml_parse($parser, $xml_val, 1)) {
3553 3144
 			$errstr = sprintf('XML error: %s at line %d, column %d',
3554 3145
 						xml_error_string(xml_get_error_code($parser)),
3555 3146
 						xml_get_current_line_number($parser), xml_get_current_column_number($parser));
@@ -3558,30 +3149,27 @@  discard block
 block discarded – undo
3558 3149
 			return false;
3559 3150
 		}
3560 3151
 		xml_parser_free($parser);
3561
-		if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too???
3152
+		if ($GLOBALS['_xh']['isf'] > 1) {
3153
+		    // test that $GLOBALS['_xh']['value'] is an obj, too???
3562 3154
 		{
3563 3155
 			error_log($GLOBALS['_xh']['isf_reason']);
3156
+		}
3564 3157
 			return false;
3565 3158
 		}
3566
-		switch ($GLOBALS['_xh']['rt'])
3567
-		{
3159
+		switch ($GLOBALS['_xh']['rt']) {
3568 3160
 			case 'methodresponse':
3569 3161
 				$v =& $GLOBALS['_xh']['value'];
3570
-				if ($GLOBALS['_xh']['isf'] == 1)
3571
-				{
3162
+				if ($GLOBALS['_xh']['isf'] == 1) {
3572 3163
 					$vc = $v->structmem('faultCode');
3573 3164
 					$vs = $v->structmem('faultString');
3574 3165
 					$r = new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval());
3575
-				}
3576
-				else
3577
-				{
3166
+				} else {
3578 3167
 					$r = new xmlrpcresp($v);
3579 3168
 				}
3580 3169
 				return $r;
3581 3170
 			case 'methodcall':
3582 3171
 				$m = new xmlrpcmsg($GLOBALS['_xh']['method']);
3583
-				for($i=0; $i < count($GLOBALS['_xh']['params']); $i++)
3584
-				{
3172
+				for($i=0; $i < count($GLOBALS['_xh']['params']); $i++) {
3585 3173
 					$m->addParam($GLOBALS['_xh']['params'][$i]);
3586 3174
 				}
3587 3175
 				return $m;
@@ -3612,13 +3200,11 @@  discard block
 block discarded – undo
3612 3200
 		$temp = substr($buffer,0,$chunkend);
3613 3201
 		$chunk_size = hexdec( trim($temp) );
3614 3202
 		$chunkstart = $chunkend;
3615
-		while($chunk_size > 0)
3616
-		{
3203
+		while($chunk_size > 0) {
3617 3204
 			$chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size);
3618 3205
 
3619 3206
 			// just in case we got a broken connection
3620
-			if($chunkend == false)
3621
-			{
3207
+			if($chunkend == false) {
3622 3208
 				$chunk = substr($buffer,$chunkstart);
3623 3209
 				// append chunk-data to entity-body
3624 3210
 				$new .= $chunk;
@@ -3636,8 +3222,7 @@  discard block
 block discarded – undo
3636 3222
 			$chunkstart = $chunkend + 2;
3637 3223
 
3638 3224
 			$chunkend = strpos($buffer,"\r\n",$chunkstart)+2;
3639
-			if($chunkend == false)
3640
-			{
3225
+			if($chunkend == false) {
3641 3226
 				break; //just in case we got a broken connection
3642 3227
 			}
3643 3228
 			$temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
@@ -3678,8 +3263,7 @@  discard block
 block discarded – undo
3678 3263
 
3679 3264
 		/// @todo this test will pass if ANY header has charset specification, not only Content-Type. Fix it?
3680 3265
 		$matches = array();
3681
-		if(preg_match('/;\s*charset\s*=([^;]+)/i', $httpheader, $matches))
3682
-		{
3266
+		if(preg_match('/;\s*charset\s*=([^;]+)/i', $httpheader, $matches)) {
3683 3267
 			return strtoupper(trim($matches[1], " \t\""));
3684 3268
 		}
3685 3269
 
@@ -3690,16 +3274,11 @@  discard block
 block discarded – undo
3690 3274
 		//     in the xml declaration, and verify if they match.
3691 3275
 		/// @todo implement check as described above?
3692 3276
 		/// @todo implement check for first bytes of string even without a BOM? (It sure looks harder than for cases WITH a BOM)
3693
-		if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk))
3694
-		{
3277
+		if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk)) {
3695 3278
 			return 'UCS-4';
3696
-		}
3697
-		elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
3698
-		{
3279
+		} elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk)) {
3699 3280
 			return 'UTF-16';
3700
-		}
3701
-		elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
3702
-		{
3281
+		} elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk)) {
3703 3282
 			return 'UTF-8';
3704 3283
 		}
3705 3284
 
@@ -3709,33 +3288,25 @@  discard block
 block discarded – undo
3709 3288
 		// EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
3710 3289
 		if (preg_match('/^<\?xml\s+version\s*=\s*'. "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
3711 3290
 			'\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
3712
-			$xmlchunk, $matches))
3713
-		{
3291
+			$xmlchunk, $matches)) {
3714 3292
 			return strtoupper(substr($matches[2], 1, -1));
3715 3293
 		}
3716 3294
 
3717 3295
 		// 4 - if mbstring is available, let it do the guesswork
3718 3296
 		// NB: we favour finding an encoding that is compatible with what we can process
3719
-		if(extension_loaded('mbstring'))
3720
-		{
3721
-			if($encoding_prefs)
3722
-			{
3297
+		if(extension_loaded('mbstring')) {
3298
+			if($encoding_prefs) {
3723 3299
 				$enc = mb_detect_encoding($xmlchunk, $encoding_prefs);
3724
-			}
3725
-			else
3726
-			{
3300
+			} else {
3727 3301
 				$enc = mb_detect_encoding($xmlchunk);
3728 3302
 			}
3729 3303
 			// NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII...
3730 3304
 			// IANA also likes better US-ASCII, so go with it
3731
-			if($enc == 'ASCII')
3732
-			{
3305
+			if($enc == 'ASCII') {
3733 3306
 				$enc = 'US-'.$enc;
3734 3307
 			}
3735 3308
 			return $enc;
3736
-		}
3737
-		else
3738
-		{
3309
+		} else {
3739 3310
 			// no encoding specified: as per HTTP1.1 assume it is iso-8859-1?
3740 3311
 			// Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types
3741 3312
 			// this should be the standard. And we should be getting text/xml as request and response.
@@ -3759,16 +3330,17 @@  discard block
 block discarded – undo
3759 3330
 				'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8',
3760 3331
 				'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN')
3761 3332
 		);
3762
-		if (is_string($validlist))
3763
-			$validlist = explode(',', $validlist);
3764
-		if (@in_array(strtoupper($encoding), $validlist))
3765
-			return true;
3766
-		else
3767
-		{
3768
-			if (array_key_exists($encoding, $charset_supersets))
3769
-				foreach ($validlist as $allowed)
3333
+		if (is_string($validlist)) {
3334
+					$validlist = explode(',', $validlist);
3335
+		}
3336
+		if (@in_array(strtoupper($encoding), $validlist)) {
3337
+					return true;
3338
+		} else {
3339
+			if (array_key_exists($encoding, $charset_supersets)) {
3340
+							foreach ($validlist as $allowed)
3770 3341
 					if (in_array($allowed, $charset_supersets[$encoding]))
3771 3342
 						return true;
3343
+			}
3772 3344
 				return false;
3773 3345
 		}
3774 3346
 	}
Please login to merge, or discard this patch.
Components/Klarna/transport/xmlrpc-3.0.0.beta/lib/xmlrpc_wrappers.inc 1 patch
Braces   +131 added lines, -286 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@  discard block
 block discarded – undo
28 28
 	*/
29 29
 	function php_2_xmlrpc_type($phptype)
30 30
 	{
31
-		switch(strtolower($phptype))
32
-		{
31
+		switch(strtolower($phptype)) {
33 32
 			case 'string':
34 33
 				return $GLOBALS['xmlrpcString'];
35 34
 			case 'integer':
@@ -50,12 +49,9 @@  discard block
 block discarded – undo
50 49
 			case 'resource':
51 50
 				return '';
52 51
 			default:
53
-				if(class_exists($phptype))
54
-				{
52
+				if(class_exists($phptype)) {
55 53
 					return $GLOBALS['xmlrpcStruct'];
56
-				}
57
-				else
58
-				{
54
+				} else {
59 55
 					// unknown: might be any 'extended' xmlrpc type
60 56
 					return $GLOBALS['xmlrpcValue'];
61 57
 				}
@@ -69,8 +65,7 @@  discard block
 block discarded – undo
69 65
 	*/
70 66
 	function xmlrpc_2_php_type($xmlrpctype)
71 67
 	{
72
-		switch(strtolower($xmlrpctype))
73
-		{
68
+		switch(strtolower($xmlrpctype)) {
74 69
 			case 'base64':
75 70
 			case 'datetime.iso8601':
76 71
 			case 'string':
@@ -150,115 +145,87 @@  discard block
 block discarded – undo
150 145
 		$decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false;
151 146
 		$catch_warnings = isset($extra_options['suppress_warnings']) && $extra_options['suppress_warnings'] ? '@' : '';
152 147
 
153
-		if(version_compare(phpversion(), '5.0.3') == -1)
154
-		{
148
+		if(version_compare(phpversion(), '5.0.3') == -1) {
155 149
 			// up to php 5.0.3 some useful reflection methods were missing
156 150
 			error_log('XML-RPC: cannot not wrap php functions unless running php version bigger than 5.0.3');
157 151
 			return false;
158 152
 		}
159 153
 
160 154
         $exists = false;
161
-	    if (is_string($funcname) && strpos($funcname, '::') !== false)
162
-	    {
155
+	    if (is_string($funcname) && strpos($funcname, '::') !== false) {
163 156
 	        $funcname = explode('::', $funcname);
164 157
 	    }
165
-        if(is_array($funcname))
166
-        {
167
-            if(count($funcname) < 2 || (!is_string($funcname[0]) && !is_object($funcname[0])))
168
-            {
158
+        if(is_array($funcname)) {
159
+            if(count($funcname) < 2 || (!is_string($funcname[0]) && !is_object($funcname[0]))) {
169 160
     			error_log('XML-RPC: syntax for function to be wrapped is wrong');
170 161
     			return false;
171 162
             }
172
-            if(is_string($funcname[0]))
173
-            {
163
+            if(is_string($funcname[0])) {
174 164
                 $plainfuncname = implode('::', $funcname);
175
-            }
176
-            elseif(is_object($funcname[0]))
177
-            {
165
+            } elseif(is_object($funcname[0])) {
178 166
                 $plainfuncname = get_class($funcname[0]) . '->' . $funcname[1];
179 167
             }
180 168
             $exists = method_exists($funcname[0], $funcname[1]);
181
-            if (!$exists && version_compare(phpversion(), '5.1') < 0)
182
-            {
169
+            if (!$exists && version_compare(phpversion(), '5.1') < 0) {
183 170
                // workaround for php 5.0: static class methods are not seen by method_exists
184 171
                $exists = is_callable( $funcname );
185 172
             }
186
-        }
187
-        else
188
-        {
173
+        } else {
189 174
             $plainfuncname = $funcname;
190 175
             $exists = function_exists($funcname);
191 176
         }
192 177
 
193
-		if(!$exists)
194
-		{
178
+		if(!$exists) {
195 179
 			error_log('XML-RPC: function to be wrapped is not defined: '.$plainfuncname);
196 180
 			return false;
197
-		}
198
-		else
199
-		{
181
+		} else {
200 182
 			// determine name of new php function
201
-			if($newfuncname == '')
202
-			{
203
-				if(is_array($funcname))
204
-				{
205
-    				if(is_string($funcname[0]))
206
-        				$xmlrpcfuncname = "{$prefix}_".implode('_', $funcname);
207
-    				else
208
-    					$xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]) . '_' . $funcname[1];
209
-				}
210
-				else
211
-				{
183
+			if($newfuncname == '') {
184
+				if(is_array($funcname)) {
185
+    				if(is_string($funcname[0])) {
186
+    				        				$xmlrpcfuncname = "{$prefix}_".implode('_', $funcname);
187
+    				} else {
188
+    				    					$xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]) . '_' . $funcname[1];
189
+    				}
190
+				} else {
212 191
 					$xmlrpcfuncname = "{$prefix}_$funcname";
213 192
 				}
214
-			}
215
-			else
216
-			{
193
+			} else {
217 194
 				$xmlrpcfuncname = $newfuncname;
218 195
 			}
219
-			while($buildit && function_exists($xmlrpcfuncname))
220
-			{
196
+			while($buildit && function_exists($xmlrpcfuncname)) {
221 197
 				$xmlrpcfuncname .= 'x';
222 198
 			}
223 199
 
224 200
 			// start to introspect PHP code
225
-			if(is_array($funcname))
226
-			{
201
+			if(is_array($funcname)) {
227 202
     			$func = new ReflectionMethod($funcname[0], $funcname[1]);
228
-    			if($func->isPrivate())
229
-    			{
203
+    			if($func->isPrivate()) {
230 204
     				error_log('XML-RPC: method to be wrapped is private: '.$plainfuncname);
231 205
     				return false;
232 206
     			}
233
-    			if($func->isProtected())
234
-    			{
207
+    			if($func->isProtected()) {
235 208
     				error_log('XML-RPC: method to be wrapped is protected: '.$plainfuncname);
236 209
     				return false;
237 210
     			}
238
-     			if($func->isConstructor())
239
-    			{
211
+     			if($func->isConstructor()) {
240 212
     				error_log('XML-RPC: method to be wrapped is the constructor: '.$plainfuncname);
241 213
     				return false;
242 214
     			}
243 215
 			    // php 503 always says isdestructor = true...
244
-                if( version_compare(phpversion(), '5.0.3') != 0 && $func->isDestructor())
245
-    			{
216
+                if( version_compare(phpversion(), '5.0.3') != 0 && $func->isDestructor()) {
246 217
     				error_log('XML-RPC: method to be wrapped is the destructor: '.$plainfuncname);
247 218
     				return false;
248 219
     			}
249
-    			if($func->isAbstract())
250
-    			{
220
+    			if($func->isAbstract()) {
251 221
     				error_log('XML-RPC: method to be wrapped is abstract: '.$plainfuncname);
252 222
     				return false;
253 223
     			}
254 224
                 /// @todo add more checks for static vs. nonstatic?
255
-            }
256
-			else
257
-			{
225
+            } else {
258 226
     			$func = new ReflectionFunction($funcname);
259 227
             }
260
-			if($func->isInternal())
261
-			{
228
+			if($func->isInternal()) {
262 229
 				// Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs
263 230
 				// instead of getparameters to fully reflect internal php functions ?
264 231
 				error_log('XML-RPC: function to be wrapped is internal: '.$plainfuncname);
@@ -277,49 +244,35 @@  discard block
 block discarded – undo
277 244
 			$paramDocs = array();
278 245
 
279 246
 			$docs = $func->getDocComment();
280
-			if($docs != '')
281
-			{
247
+			if($docs != '') {
282 248
 				$docs = explode("\n", $docs);
283 249
 				$i = 0;
284
-				foreach($docs as $doc)
285
-				{
250
+				foreach($docs as $doc) {
286 251
 					$doc = trim($doc, " \r\t/*");
287
-					if(strlen($doc) && strpos($doc, '@') !== 0 && !$i)
288
-					{
289
-						if($desc)
290
-						{
252
+					if(strlen($doc) && strpos($doc, '@') !== 0 && !$i) {
253
+						if($desc) {
291 254
 							$desc .= "\n";
292 255
 						}
293 256
 						$desc .= $doc;
294
-					}
295
-					elseif(strpos($doc, '@param') === 0)
296
-					{
257
+					} elseif(strpos($doc, '@param') === 0) {
297 258
 						// syntax: @param type [$name] desc
298
-						if(preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches))
299
-						{
300
-							if(strpos($matches[1], '|'))
301
-							{
259
+						if(preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches)) {
260
+							if(strpos($matches[1], '|')) {
302 261
 								//$paramDocs[$i]['type'] = explode('|', $matches[1]);
303 262
 								$paramDocs[$i]['type'] = 'mixed';
304
-							}
305
-							else
306
-							{
263
+							} else {
307 264
 								$paramDocs[$i]['type'] = $matches[1];
308 265
 							}
309 266
 							$paramDocs[$i]['name'] = trim($matches[2]);
310 267
 							$paramDocs[$i]['doc'] = $matches[3];
311 268
 						}
312 269
 						$i++;
313
-					}
314
-					elseif(strpos($doc, '@return') === 0)
315
-					{
270
+					} elseif(strpos($doc, '@return') === 0) {
316 271
 						// syntax: @return type desc
317 272
 						//$returns = preg_split('/\s+/', $doc);
318
-						if(preg_match('/@return\s+(\S+)\s+(.+)/', $doc, $matches))
319
-						{
273
+						if(preg_match('/@return\s+(\S+)\s+(.+)/', $doc, $matches)) {
320 274
 							$returns = php_2_xmlrpc_type($matches[1]);
321
-							if(isset($matches[2]))
322
-							{
275
+							if(isset($matches[2])) {
323 276
 								$returnsDocs = $matches[2];
324 277
 							}
325 278
 						}
@@ -330,8 +283,7 @@  discard block
 block discarded – undo
330 283
 			// execute introspection of actual function prototype
331 284
 			$params = array();
332 285
 			$i = 0;
333
-			foreach($func->getParameters() as $paramobj)
334
-			{
286
+			foreach($func->getParameters() as $paramobj) {
335 287
 				$params[$i] = array();
336 288
 				$params[$i]['name'] = '$'.$paramobj->getName();
337 289
 				$params[$i]['isoptional'] = $paramobj->isOptional();
@@ -345,38 +297,30 @@  discard block
 block discarded – undo
345 297
 			$parsvariations = array();
346 298
 			$pars = array();
347 299
 			$pnum = count($params);
348
-			foreach($params as $param)
349
-			{
350
-				if (isset($paramDocs[$i]['name']) && $paramDocs[$i]['name'] && strtolower($paramDocs[$i]['name']) != strtolower($param['name']))
351
-				{
300
+			foreach($params as $param) {
301
+				if (isset($paramDocs[$i]['name']) && $paramDocs[$i]['name'] && strtolower($paramDocs[$i]['name']) != strtolower($param['name'])) {
352 302
 					// param name from phpdoc info does not match param definition!
353 303
 					$paramDocs[$i]['type'] = 'mixed';
354 304
 				}
355 305
 
356
-				if($param['isoptional'])
357
-				{
306
+				if($param['isoptional']) {
358 307
 					// this particular parameter is optional. save as valid previous list of parameters
359 308
 					$innercode .= "if (\$paramcount > $i) {\n";
360 309
 					$parsvariations[] = $pars;
361 310
 				}
362 311
 				$innercode .= "\$p$i = \$msg->getParam($i);\n";
363
-				if ($decode_php_objects)
364
-				{
312
+				if ($decode_php_objects) {
365 313
 					$innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i, array('decode_php_objs'));\n";
366
-				}
367
-				else
368
-				{
314
+				} else {
369 315
 					$innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i);\n";
370 316
 				}
371 317
 
372 318
 				$pars[] = "\$p$i";
373 319
 				$i++;
374
-				if($param['isoptional'])
375
-				{
320
+				if($param['isoptional']) {
376 321
 					$innercode .= "}\n";
377 322
 				}
378
-				if($i == $pnum)
379
-				{
323
+				if($i == $pnum) {
380 324
 					// last allowed parameters combination
381 325
 					$parsvariations[] = $pars;
382 326
 				}
@@ -384,56 +328,42 @@  discard block
 block discarded – undo
384 328
 
385 329
 			$sigs = array();
386 330
 			$psigs = array();
387
-			if(count($parsvariations) == 0)
388
-			{
331
+			if(count($parsvariations) == 0) {
389 332
 				// only known good synopsis = no parameters
390 333
 				$parsvariations[] = array();
391 334
 				$minpars = 0;
392
-			}
393
-			else
394
-			{
335
+			} else {
395 336
 				$minpars = count($parsvariations[0]);
396 337
 			}
397 338
 
398
-			if($minpars)
399
-			{
339
+			if($minpars) {
400 340
 				// add to code the check for min params number
401 341
 				// NB: this check needs to be done BEFORE decoding param values
402 342
 				$innercode = "\$paramcount = \$msg->getNumParams();\n" .
403 343
 				"if (\$paramcount < $minpars) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}');\n" . $innercode;
404
-			}
405
-			else
406
-			{
344
+			} else {
407 345
 				$innercode = "\$paramcount = \$msg->getNumParams();\n" . $innercode;
408 346
 			}
409 347
 
410 348
 			$innercode .= "\$np = false;\n";
411 349
 			// since there are no closures in php, if we are given an object instance,
412 350
             // we store a pointer to it in a global var...
413
-			if ( is_array($funcname) && is_object($funcname[0]) )
414
-			{
351
+			if ( is_array($funcname) && is_object($funcname[0]) ) {
415 352
 			    $GLOBALS['xmlrpcWPFObjHolder'][$xmlrpcfuncname] =& $funcname[0];
416 353
 			    $innercode .= "\$obj =& \$GLOBALS['xmlrpcWPFObjHolder']['$xmlrpcfuncname'];\n";
417 354
 			    $realfuncname = '$obj->'.$funcname[1];
418
-			}
419
-			else
420
-			{
355
+			} else {
421 356
     			$realfuncname = $plainfuncname;
422 357
             }
423
-			foreach($parsvariations as $pars)
424
-			{
358
+			foreach($parsvariations as $pars) {
425 359
 				$innercode .= "if (\$paramcount == " . count($pars) . ") \$retval = {$catch_warnings}$realfuncname(" . implode(',', $pars) . "); else\n";
426 360
 				// build a 'generic' signature (only use an appropriate return type)
427 361
 				$sig = array($returns);
428 362
 				$psig = array($returnsDocs);
429
-				for($i=0; $i < count($pars); $i++)
430
-				{
431
-					if (isset($paramDocs[$i]['type']))
432
-					{
363
+				for($i=0; $i < count($pars); $i++) {
364
+					if (isset($paramDocs[$i]['type'])) {
433 365
 						$sig[] = php_2_xmlrpc_type($paramDocs[$i]['type']);
434
-					}
435
-					else
436
-					{
366
+					} else {
437 367
 						$sig[] = $GLOBALS['xmlrpcValue'];
438 368
 					}
439 369
 					$psig[] = isset($paramDocs[$i]['doc']) ? $paramDocs[$i]['doc'] : '';
@@ -445,31 +375,27 @@  discard block
 block discarded – undo
445 375
 			$innercode .= "if (\$np) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}'); else {\n";
446 376
 			//$innercode .= "if (\$_xmlrpcs_error_occurred) return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']user, \$_xmlrpcs_error_occurred); else\n";
447 377
 			$innercode .= "if (is_a(\$retval, '{$prefix}resp')) return \$retval; else\n";
448
-			if($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64'])
449
-			{
378
+			if($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64']) {
450 379
 				$innercode .= "return new {$prefix}resp(new {$prefix}val(\$retval, '$returns'));";
451
-			}
452
-			else
453
-			{
454
-				if ($encode_php_objects)
455
-					$innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval, array('encode_php_objs')));\n";
456
-				else
457
-					$innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval));\n";
380
+			} else {
381
+				if ($encode_php_objects) {
382
+									$innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval, array('encode_php_objs')));\n";
383
+				} else {
384
+									$innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval));\n";
385
+				}
458 386
 			}
459 387
 			// shall we exclude functions returning by ref?
460 388
 			// if($func->returnsReference())
461 389
 			// 	return false;
462 390
 			$code = "function $xmlrpcfuncname(\$msg) {\n" . $innercode . "}\n}";
463 391
 			//print_r($code);
464
-			if ($buildit)
465
-			{
392
+			if ($buildit) {
466 393
 				$allOK = 0;
467 394
 				eval($code.'$allOK=1;');
468 395
 				// alternative
469 396
 				//$xmlrpcfuncname = create_function('$m', $innercode);
470 397
 
471
-				if(!$allOK)
472
-				{
398
+				if(!$allOK) {
473 399
 					error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap php function '.$plainfuncname);
474 400
 					return false;
475 401
 				}
@@ -501,8 +427,7 @@  discard block
 block discarded – undo
501 427
 		$methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : '';
502 428
 		$methodtype = isset($extra_options['method_type']) ? $extra_options['method_type'] : 'auto';
503 429
 
504
-        if(version_compare(phpversion(), '5.0.3') == -1)
505
-		{
430
+        if(version_compare(phpversion(), '5.0.3') == -1) {
506 431
 			// up to php 5.0.3 some useful reflection methods were missing
507 432
 			error_log('XML-RPC: cannot not wrap php functions unless running php version bigger than 5.0.3');
508 433
 			return false;
@@ -510,20 +435,15 @@  discard block
 block discarded – undo
510 435
 
511 436
         $result = array();
512 437
 		$mlist = get_class_methods($classname);
513
-		foreach($mlist as $mname)
514
-		{
515
-    		if ($methodfilter == '' || preg_match($methodfilter, $mname))
516
-			{
438
+		foreach($mlist as $mname) {
439
+    		if ($methodfilter == '' || preg_match($methodfilter, $mname)) {
517 440
     			// echo $mlist."\n";
518 441
     			$func = new ReflectionMethod($classname, $mname);
519
-    			if(!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract())
520
-    			{
442
+    			if(!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract()) {
521 443
         			if(($func->isStatic && ($methodtype == 'all' || $methodtype == 'static' || ($methodtype == 'auto' && is_string($classname)))) ||
522
-            			(!$func->isStatic && ($methodtype == 'all' || $methodtype == 'nonstatic' || ($methodtype == 'auto' && is_object($classname)))))
523
-            		{
444
+            			(!$func->isStatic && ($methodtype == 'all' || $methodtype == 'nonstatic' || ($methodtype == 'auto' && is_object($classname))))) {
524 445
                         $methodwrap = wrap_php_function(array($classname, $mname), '', $extra_options);
525
-                        if ( $methodwrap )
526
-                        {
446
+                        if ( $methodwrap ) {
527 447
                             $result[$methodwrap['function']] = $methodwrap['function'];
528 448
                         }
529 449
                     }
@@ -574,13 +494,10 @@  discard block
 block discarded – undo
574 494
 	{
575 495
 		// mind numbing: let caller use sane calling convention (as per javadoc, 3 params),
576 496
 		// OR the 2.0 calling convention (no options) - we really love backward compat, don't we?
577
-		if (!is_array($extra_options))
578
-		{
497
+		if (!is_array($extra_options)) {
579 498
 			$signum = $extra_options;
580 499
 			$extra_options = array();
581
-		}
582
-		else
583
-		{
500
+		} else {
584 501
 			$signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0;
585 502
 			$timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0;
586 503
 			$protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : '';
@@ -595,13 +512,10 @@  discard block
 block discarded – undo
595 512
 		$simple_client_copy = isset($extra_options['simple_client_copy']) ? (int)($extra_options['simple_client_copy']) : 0;
596 513
 		$buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true;
597 514
 		$prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc';
598
-		if (isset($extra_options['return_on_fault']))
599
-		{
515
+		if (isset($extra_options['return_on_fault'])) {
600 516
 			$decode_fault = true;
601 517
 			$fault_response = $extra_options['return_on_fault'];
602
-		}
603
-		else
604
-		{
518
+		} else {
605 519
 			$decode_fault = false;
606 520
 			$fault_response = '';
607 521
 		}
@@ -615,39 +529,28 @@  discard block
 block discarded – undo
615 529
 		$msg->addparam(new $valclass($methodname));
616 530
 		$client->setDebug($debug);
617 531
 		$response =& $client->send($msg, $timeout, $protocol);
618
-		if($response->faultCode())
619
-		{
532
+		if($response->faultCode()) {
620 533
 			error_log('XML-RPC: could not retrieve method signature from remote server for method '.$methodname);
621 534
 			return false;
622
-		}
623
-		else
624
-		{
535
+		} else {
625 536
 			$msig = $response->value();
626
-			if ($client->return_type != 'phpvals')
627
-			{
537
+			if ($client->return_type != 'phpvals') {
628 538
 				$msig = $decodefunc($msig);
629 539
 			}
630
-			if(!is_array($msig) || count($msig) <= $signum)
631
-			{
540
+			if(!is_array($msig) || count($msig) <= $signum) {
632 541
 				error_log('XML-RPC: could not retrieve method signature nr.'.$signum.' from remote server for method '.$methodname);
633 542
 				return false;
634
-			}
635
-			else
636
-			{
543
+			} else {
637 544
 				// pick a suitable name for the new function, avoiding collisions
638
-				if($newfuncname != '')
639
-				{
545
+				if($newfuncname != '') {
640 546
 					$xmlrpcfuncname = $newfuncname;
641
-				}
642
-				else
643
-				{
547
+				} else {
644 548
 					// take care to insure that methodname is translated to valid
645 549
 					// php function name
646 550
 					$xmlrpcfuncname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
647 551
 						array('_', ''), $methodname);
648 552
 				}
649
-				while($buildit && function_exists($xmlrpcfuncname))
650
-				{
553
+				while($buildit && function_exists($xmlrpcfuncname)) {
651 554
 					$xmlrpcfuncname .= 'x';
652 555
 				}
653 556
 
@@ -655,16 +558,13 @@  discard block
 block discarded – undo
655 558
 				$mdesc = '';
656 559
 				// if in 'offline' mode, get method description too.
657 560
 				// in online mode, favour speed of operation
658
-				if(!$buildit)
659
-				{
561
+				if(!$buildit) {
660 562
 					$msg = new $msgclass('system.methodHelp');
661 563
 					$msg->addparam(new $valclass($methodname));
662 564
 					$response =& $client->send($msg, $timeout, $protocol);
663
-					if (!$response->faultCode())
664
-					{
565
+					if (!$response->faultCode()) {
665 566
 						$mdesc = $response->value();
666
-						if ($client->return_type != 'phpvals')
667
-						{
567
+						if ($client->return_type != 'phpvals') {
668 568
 							$mdesc = $mdesc->scalarval();
669 569
 						}
670 570
 					}
@@ -676,24 +576,18 @@  discard block
 block discarded – undo
676 576
 					$fault_response);
677 577
 
678 578
 				//print_r($code);
679
-				if ($buildit)
680
-				{
579
+				if ($buildit) {
681 580
 					$allOK = 0;
682 581
 					eval($results['source'].'$allOK=1;');
683 582
 					// alternative
684 583
 					//$xmlrpcfuncname = create_function('$m', $innercode);
685
-					if($allOK)
686
-					{
584
+					if($allOK) {
687 585
 						return $xmlrpcfuncname;
688
-					}
689
-					else
690
-					{
586
+					} else {
691 587
 						error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap remote method '.$methodname);
692 588
 						return false;
693 589
 					}
694
-				}
695
-				else
696
-				{
590
+				} else {
697 591
 					$results['function'] = $xmlrpcfuncname;
698 592
 					return $results;
699 593
 				}
@@ -728,37 +622,26 @@  discard block
 block discarded – undo
728 622
 
729 623
 		$msg = new $msgclass('system.listMethods');
730 624
 		$response =& $client->send($msg, $timeout, $protocol);
731
-		if($response->faultCode())
732
-		{
625
+		if($response->faultCode()) {
733 626
 			error_log('XML-RPC: could not retrieve method list from remote server');
734 627
 			return false;
735
-		}
736
-		else
737
-		{
628
+		} else {
738 629
 			$mlist = $response->value();
739
-			if ($client->return_type != 'phpvals')
740
-			{
630
+			if ($client->return_type != 'phpvals') {
741 631
 				$mlist = $decodefunc($mlist);
742 632
 			}
743
-			if(!is_array($mlist) || !count($mlist))
744
-			{
633
+			if(!is_array($mlist) || !count($mlist)) {
745 634
 				error_log('XML-RPC: could not retrieve meaningful method list from remote server');
746 635
 				return false;
747
-			}
748
-			else
749
-			{
636
+			} else {
750 637
 				// pick a suitable name for the new function, avoiding collisions
751
-				if($newclassname != '')
752
-				{
638
+				if($newclassname != '') {
753 639
 					$xmlrpcclassname = $newclassname;
754
-				}
755
-				else
756
-				{
640
+				} else {
757 641
 					$xmlrpcclassname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
758 642
 						array('_', ''), $client->server).'_client';
759 643
 				}
760
-				while($buildit && class_exists($xmlrpcclassname))
761
-				{
644
+				while($buildit && class_exists($xmlrpcclassname)) {
762 645
 					$xmlrpcclassname .= 'x';
763 646
 				}
764 647
 
@@ -773,46 +656,34 @@  discard block
 block discarded – undo
773 656
 					'decode_php_objs' => $decode_php_objects
774 657
 					);
775 658
 				/// @todo build javadoc for class definition, too
776
-				foreach($mlist as $mname)
777
-				{
778
-					if ($methodfilter == '' || preg_match($methodfilter, $mname))
779
-					{
659
+				foreach($mlist as $mname) {
660
+					if ($methodfilter == '' || preg_match($methodfilter, $mname)) {
780 661
 						$opts['new_function_name'] = preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
781 662
 							array('_', ''), $mname);
782 663
 						$methodwrap = wrap_xmlrpc_method($client, $mname, $opts);
783
-						if ($methodwrap)
784
-						{
785
-							if (!$buildit)
786
-							{
664
+						if ($methodwrap) {
665
+							if (!$buildit) {
787 666
 								$source .= $methodwrap['docstring'];
788 667
 							}
789 668
 							$source .= $methodwrap['source']."\n";
790
-						}
791
-						else
792
-						{
669
+						} else {
793 670
 							error_log('XML-RPC: will not create class method to wrap remote method '.$mname);
794 671
 						}
795 672
 					}
796 673
 				}
797 674
 				$source .= "}\n";
798
-				if ($buildit)
799
-				{
675
+				if ($buildit) {
800 676
 					$allOK = 0;
801 677
 					eval($source.'$allOK=1;');
802 678
 					// alternative
803 679
 					//$xmlrpcfuncname = create_function('$m', $innercode);
804
-					if($allOK)
805
-					{
680
+					if($allOK) {
806 681
 						return $xmlrpcclassname;
807
-					}
808
-					else
809
-					{
682
+					} else {
810 683
 						error_log('XML-RPC: could not create class '.$xmlrpcclassname.' to wrap remote server '.$client->server);
811 684
 						return false;
812 685
 					}
813
-				}
814
-				else
815
-				{
686
+				} else {
816 687
 					return array('class' => $xmlrpcclassname, 'code' => $source, 'docstring' => '');
817 688
 				}
818 689
 			}
@@ -833,60 +704,46 @@  discard block
 block discarded – undo
833 704
 		$fault_response='')
834 705
 	{
835 706
 		$code = "function $xmlrpcfuncname (";
836
-		if ($client_copy_mode < 2)
837
-		{
707
+		if ($client_copy_mode < 2) {
838 708
 			// client copy mode 0 or 1 == partial / full client copy in emitted code
839 709
 			$innercode = build_client_wrapper_code($client, $client_copy_mode, $prefix);
840 710
 			$innercode .= "\$client->setDebug(\$debug);\n";
841 711
 			$this_ = '';
842
-		}
843
-		else
844
-		{
712
+		} else {
845 713
 			// client copy mode 2 == no client copy in emitted code
846 714
 			$innercode = '';
847 715
 			$this_ = 'this->';
848 716
 		}
849 717
 		$innercode .= "\$msg = new {$prefix}msg('$methodname');\n";
850 718
 
851
-		if ($mdesc != '')
852
-		{
719
+		if ($mdesc != '') {
853 720
 			// take care that PHP comment is not terminated unwillingly by method description
854 721
 			$mdesc = "/**\n* ".str_replace('*/', '* /', $mdesc)."\n";
855
-		}
856
-		else
857
-		{
722
+		} else {
858 723
 			$mdesc = "/**\nFunction $xmlrpcfuncname\n";
859 724
 		}
860 725
 
861 726
 		// param parsing
862 727
 		$plist = array();
863 728
 		$pcount = count($msig);
864
-		for($i = 1; $i < $pcount; $i++)
865
-		{
729
+		for($i = 1; $i < $pcount; $i++) {
866 730
 			$plist[] = "\$p$i";
867 731
 			$ptype = $msig[$i];
868 732
 			if($ptype == 'i4' || $ptype == 'int' || $ptype == 'boolean' || $ptype == 'double' ||
869
-				$ptype == 'string' || $ptype == 'dateTime.iso8601' || $ptype == 'base64' || $ptype == 'null')
870
-			{
733
+				$ptype == 'string' || $ptype == 'dateTime.iso8601' || $ptype == 'base64' || $ptype == 'null') {
871 734
 				// only build directly xmlrpcvals when type is known and scalar
872 735
 				$innercode .= "\$p$i = new {$prefix}val(\$p$i, '$ptype');\n";
873
-			}
874
-			else
875
-			{
876
-				if ($encode_php_objects)
877
-				{
736
+			} else {
737
+				if ($encode_php_objects) {
878 738
 					$innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i, array('encode_php_objs'));\n";
879
-				}
880
-				else
881
-				{
739
+				} else {
882 740
 					$innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i);\n";
883 741
 				}
884 742
 			}
885 743
 			$innercode .= "\$msg->addparam(\$p$i);\n";
886 744
 			$mdesc .= '* @param '.xmlrpc_2_php_type($ptype)." \$p$i\n";
887 745
 		}
888
-		if ($client_copy_mode < 2)
889
-		{
746
+		if ($client_copy_mode < 2) {
890 747
 			$plist[] = '$debug=0';
891 748
 			$mdesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
892 749
 		}
@@ -894,27 +751,18 @@  discard block
 block discarded – undo
894 751
 		$mdesc .= '* @return '.xmlrpc_2_php_type($msig[0])." (or an {$prefix}resp obj instance if call fails)\n*/\n";
895 752
 
896 753
 		$innercode .= "\$res =& \${$this_}client->send(\$msg, $timeout, '$protocol');\n";
897
-		if ($decode_fault)
898
-		{
899
-			if (is_string($fault_response) && ((strpos($fault_response, '%faultCode%') !== false) || (strpos($fault_response, '%faultString%') !== false)))
900
-			{
754
+		if ($decode_fault) {
755
+			if (is_string($fault_response) && ((strpos($fault_response, '%faultCode%') !== false) || (strpos($fault_response, '%faultString%') !== false))) {
901 756
 				$respcode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $fault_response)."')";
902
-			}
903
-			else
904
-			{
757
+			} else {
905 758
 				$respcode = var_export($fault_response, true);
906 759
 			}
907
-		}
908
-		else
909
-		{
760
+		} else {
910 761
 			$respcode = '$res';
911 762
 		}
912
-		if ($decode_php_objects)
913
-		{
763
+		if ($decode_php_objects) {
914 764
 			$innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value(), array('decode_php_objs'));";
915
-		}
916
-		else
917
-		{
765
+		} else {
918 766
 			$innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value());";
919 767
 		}
920 768
 
@@ -936,12 +784,9 @@  discard block
 block discarded – undo
936 784
 
937 785
 		// copy all client fields to the client that will be generated runtime
938 786
 		// (this provides for future expansion or subclassing of client obj)
939
-		if ($verbatim_client_copy)
940
-		{
941
-			foreach($client as $fld => $val)
942
-			{
943
-				if($fld != 'debug' && $fld != 'return_type')
944
-				{
787
+		if ($verbatim_client_copy) {
788
+			foreach($client as $fld => $val) {
789
+				if($fld != 'debug' && $fld != 'return_type') {
945 790
 					$val = var_export($val, true);
946 791
 					$code .= "\$client->$fld = $val;\n";
947 792
 				}
Please login to merge, or discard this patch.
Components/Klarna/transport/xmlrpc-3.0.0.beta/lib/xmlrpcs.inc 1 patch
Braces   +172 added lines, -353 removed lines patch added patch discarded remove patch
@@ -83,14 +83,11 @@  discard block
 block discarded – undo
83 83
 	{
84 84
 
85 85
 		$outAr=array();
86
-		foreach($server->dmap as $key => $val)
87
-		{
86
+		foreach($server->dmap as $key => $val) {
88 87
 			$outAr[]=new xmlrpcval($key, 'string');
89 88
 		}
90
-		if($server->allow_system_funcs)
91
-		{
92
-			foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val)
93
-			{
89
+		if($server->allow_system_funcs) {
90
+			foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val) {
94 91
 				$outAr[]=new xmlrpcval($key, 'string');
95 92
 			}
96 93
 		}
@@ -103,48 +100,34 @@  discard block
 block discarded – undo
103 100
 	function _xmlrpcs_methodSignature($server, $m)
104 101
 	{
105 102
 		// let accept as parameter both an xmlrpcval or string
106
-		if (is_object($m))
107
-		{
103
+		if (is_object($m)) {
108 104
 			$methName=$m->getParam(0);
109 105
 			$methName=$methName->scalarval();
110
-		}
111
-		else
112
-		{
106
+		} else {
113 107
 			$methName=$m;
114 108
 		}
115
-		if(strpos($methName, "system.") === 0)
116
-		{
109
+		if(strpos($methName, "system.") === 0) {
117 110
 			$dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1;
118
-		}
119
-		else
120
-		{
111
+		} else {
121 112
 			$dmap=$server->dmap; $sysCall=0;
122 113
 		}
123
-		if(isset($dmap[$methName]))
124
-		{
125
-			if(isset($dmap[$methName]['signature']))
126
-			{
114
+		if(isset($dmap[$methName])) {
115
+			if(isset($dmap[$methName]['signature'])) {
127 116
 				$sigs=array();
128
-				foreach($dmap[$methName]['signature'] as $inSig)
129
-				{
117
+				foreach($dmap[$methName]['signature'] as $inSig) {
130 118
 					$cursig=array();
131
-					foreach($inSig as $sig)
132
-					{
119
+					foreach($inSig as $sig) {
133 120
 						$cursig[]=new xmlrpcval($sig, 'string');
134 121
 					}
135 122
 					$sigs[]=new xmlrpcval($cursig, 'array');
136 123
 				}
137 124
 				$r=new xmlrpcresp(new xmlrpcval($sigs, 'array'));
138
-			}
139
-			else
140
-			{
125
+			} else {
141 126
 				// NB: according to the official docs, we should be returning a
142 127
 				// "none-array" here, which means not-an-array
143 128
 				$r=new xmlrpcresp(new xmlrpcval('undef', 'string'));
144 129
 			}
145
-		}
146
-		else
147
-		{
130
+		} else {
148 131
 			$r=new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']);
149 132
 		}
150 133
 		return $r;
@@ -156,36 +139,24 @@  discard block
 block discarded – undo
156 139
 	function _xmlrpcs_methodHelp($server, $m)
157 140
 	{
158 141
 		// let accept as parameter both an xmlrpcval or string
159
-		if (is_object($m))
160
-		{
142
+		if (is_object($m)) {
161 143
 			$methName=$m->getParam(0);
162 144
 			$methName=$methName->scalarval();
163
-		}
164
-		else
165
-		{
145
+		} else {
166 146
 			$methName=$m;
167 147
 		}
168
-		if(strpos($methName, "system.") === 0)
169
-		{
148
+		if(strpos($methName, "system.") === 0) {
170 149
 			$dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1;
171
-		}
172
-		else
173
-		{
150
+		} else {
174 151
 			$dmap=$server->dmap; $sysCall=0;
175 152
 		}
176
-		if(isset($dmap[$methName]))
177
-		{
178
-			if(isset($dmap[$methName]['docstring']))
179
-			{
153
+		if(isset($dmap[$methName])) {
154
+			if(isset($dmap[$methName]['docstring'])) {
180 155
 				$r=new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string');
181
-			}
182
-			else
183
-			{
156
+			} else {
184 157
 				$r=new xmlrpcresp(new xmlrpcval('', 'string'));
185 158
 			}
186
-		}
187
-		else
188
-		{
159
+		} else {
189 160
 			$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']);
190 161
 		}
191 162
 		return $r;
@@ -196,13 +167,11 @@  discard block
 block discarded – undo
196 167
 	$_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"'));
197 168
 	function _xmlrpcs_multicall_error($err)
198 169
 	{
199
-		if(is_string($err))
200
-		{
170
+		if(is_string($err)) {
201 171
 			$str = $GLOBALS['xmlrpcstr']["multicall_${err}"];
202 172
 			$code = $GLOBALS['xmlrpcerr']["multicall_${err}"];
203 173
 		}
204
-		else
205
-		{
174
+		else {
206 175
 			$code = $err->faultCode();
207 176
 			$str = $err->faultString();
208 177
 		}
@@ -214,40 +183,32 @@  discard block
 block discarded – undo
214 183
 
215 184
 	function _xmlrpcs_multicall_do_call($server, $call)
216 185
 	{
217
-		if($call->kindOf() != 'struct')
218
-		{
186
+		if($call->kindOf() != 'struct') {
219 187
 			return _xmlrpcs_multicall_error('notstruct');
220 188
 		}
221 189
 		$methName = @$call->structmem('methodName');
222
-		if(!$methName)
223
-		{
190
+		if(!$methName) {
224 191
 			return _xmlrpcs_multicall_error('nomethod');
225 192
 		}
226
-		if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string')
227
-		{
193
+		if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') {
228 194
 			return _xmlrpcs_multicall_error('notstring');
229 195
 		}
230
-		if($methName->scalarval() == 'system.multicall')
231
-		{
196
+		if($methName->scalarval() == 'system.multicall') {
232 197
 			return _xmlrpcs_multicall_error('recursion');
233 198
 		}
234 199
 
235 200
 		$params = @$call->structmem('params');
236
-		if(!$params)
237
-		{
201
+		if(!$params) {
238 202
 			return _xmlrpcs_multicall_error('noparams');
239 203
 		}
240
-		if($params->kindOf() != 'array')
241
-		{
204
+		if($params->kindOf() != 'array') {
242 205
 			return _xmlrpcs_multicall_error('notarray');
243 206
 		}
244 207
 		$numParams = $params->arraysize();
245 208
 
246 209
 		$msg = new xmlrpcmsg($methName->scalarval());
247
-		for($i = 0; $i < $numParams; $i++)
248
-		{
249
-			if(!$msg->addParam($params->arraymem($i)))
250
-			{
210
+		for($i = 0; $i < $numParams; $i++) {
211
+			if(!$msg->addParam($params->arraymem($i))) {
251 212
 				$i++;
252 213
 				return _xmlrpcs_multicall_error(new xmlrpcresp(0,
253 214
 					$GLOBALS['xmlrpcerr']['incorrect_params'],
@@ -257,8 +218,7 @@  discard block
 block discarded – undo
257 218
 
258 219
 		$result = $server->execute($msg);
259 220
 
260
-		if($result->faultCode() != 0)
261
-		{
221
+		if($result->faultCode() != 0) {
262 222
 			return _xmlrpcs_multicall_error($result);		// Method returned fault.
263 223
 		}
264 224
 
@@ -267,28 +227,22 @@  discard block
 block discarded – undo
267 227
 
268 228
 	function _xmlrpcs_multicall_do_call_phpvals($server, $call)
269 229
 	{
270
-		if(!is_array($call))
271
-		{
230
+		if(!is_array($call)) {
272 231
 			return _xmlrpcs_multicall_error('notstruct');
273 232
 		}
274
-		if(!array_key_exists('methodName', $call))
275
-		{
233
+		if(!array_key_exists('methodName', $call)) {
276 234
 			return _xmlrpcs_multicall_error('nomethod');
277 235
 		}
278
-		if (!is_string($call['methodName']))
279
-		{
236
+		if (!is_string($call['methodName'])) {
280 237
 			return _xmlrpcs_multicall_error('notstring');
281 238
 		}
282
-		if($call['methodName'] == 'system.multicall')
283
-		{
239
+		if($call['methodName'] == 'system.multicall') {
284 240
 			return _xmlrpcs_multicall_error('recursion');
285 241
 		}
286
-		if(!array_key_exists('params', $call))
287
-		{
242
+		if(!array_key_exists('params', $call)) {
288 243
 			return _xmlrpcs_multicall_error('noparams');
289 244
 		}
290
-		if(!is_array($call['params']))
291
-		{
245
+		if(!is_array($call['params'])) {
292 246
 			return _xmlrpcs_multicall_error('notarray');
293 247
 		}
294 248
 
@@ -296,13 +250,13 @@  discard block
 block discarded – undo
296 250
 		// base64 or datetime values, but they will be listed as strings here...
297 251
 		$numParams = count($call['params']);
298 252
 		$pt = array();
299
-		foreach($call['params'] as $val)
300
-			$pt[] = php_2_xmlrpc_type(gettype($val));
253
+		foreach($call['params'] as $val) {
254
+					$pt[] = php_2_xmlrpc_type(gettype($val));
255
+		}
301 256
 
302 257
 		$result = $server->execute($call['methodName'], $call['params'], $pt);
303 258
 
304
-		if($result->faultCode() != 0)
305
-		{
259
+		if($result->faultCode() != 0) {
306 260
 			return _xmlrpcs_multicall_error($result);		// Method returned fault.
307 261
 		}
308 262
 
@@ -313,21 +267,16 @@  discard block
 block discarded – undo
313 267
 	{
314 268
 		$result = array();
315 269
 		// let accept a plain list of php parameters, beside a single xmlrpc msg object
316
-		if (is_object($m))
317
-		{
270
+		if (is_object($m)) {
318 271
 			$calls = $m->getParam(0);
319 272
 			$numCalls = $calls->arraysize();
320
-			for($i = 0; $i < $numCalls; $i++)
321
-			{
273
+			for($i = 0; $i < $numCalls; $i++) {
322 274
 				$call = $calls->arraymem($i);
323 275
 				$result[$i] = _xmlrpcs_multicall_do_call($server, $call);
324 276
 			}
325
-		}
326
-		else
327
-		{
277
+		} else {
328 278
 			$numCalls=count($m);
329
-			for($i = 0; $i < $numCalls; $i++)
330
-			{
279
+			for($i = 0; $i < $numCalls; $i++) {
331 280
 				$result[$i] = _xmlrpcs_multicall_do_call_phpvals($server, $m[$i]);
332 281
 			}
333 282
 		}
@@ -378,38 +327,30 @@  discard block
 block discarded – undo
378 327
 	function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null)
379 328
 	{
380 329
 		// obey the @ protocol
381
-		if (error_reporting() == 0)
382
-			return;
330
+		if (error_reporting() == 0) {
331
+					return;
332
+		}
383 333
 
384 334
 		//if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING)
385
-		if($errcode != E_STRICT)
386
-		{
335
+		if($errcode != E_STRICT) {
387 336
 			$GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n";
388 337
 		}
389 338
 		// Try to avoid as much as possible disruption to the previous error handling
390 339
 		// mechanism in place
391
-		if($GLOBALS['_xmlrpcs_prev_ehandler'] == '')
392
-		{
340
+		if($GLOBALS['_xmlrpcs_prev_ehandler'] == '') {
393 341
 			// The previous error handler was the default: all we should do is log error
394 342
 			// to the default error log (if level high enough)
395
-			if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode))
396
-			{
343
+			if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) {
397 344
 				error_log($errstring);
398 345
 			}
399
-		}
400
-		else
401
-		{
346
+		} else {
402 347
 			// Pass control on to previous error handler, trying to avoid loops...
403
-			if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler')
404
-			{
348
+			if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') {
405 349
 				// NB: this code will NOT work on php < 4.0.2: only 2 params were used for error handlers
406
-				if(is_array($GLOBALS['_xmlrpcs_prev_ehandler']))
407
-				{
350
+				if(is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) {
408 351
 					// the following works both with static class methods and plain object methods as error handler
409 352
 					call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context));
410
-				}
411
-				else
412
-				{
353
+				} else {
413 354
 					$GLOBALS['_xmlrpcs_prev_ehandler']($errcode, $errstring, $filename, $lineno, $context);
414 355
 				}
415 356
 			}
@@ -502,8 +443,7 @@  discard block
 block discarded – undo
502 443
 		{
503 444
 			// if ZLIB is enabled, let the server by default accept compressed requests,
504 445
 			// and compress responses sent to clients that support them
505
-			if(function_exists('gzinflate'))
506
-			{
446
+			if(function_exists('gzinflate')) {
507 447
 				$this->accepted_compression = array('gzip', 'deflate');
508 448
 				$this->compress_response = true;
509 449
 			}
@@ -520,11 +460,9 @@  discard block
 block discarded – undo
520 460
 			 * instead, you can use the class add_to_map() function
521 461
 			 * to add functions manually (borrowed from SOAPX4)
522 462
 			 */
523
-			if($dispMap)
524
-			{
463
+			if($dispMap) {
525 464
 				$this->dmap = $dispMap;
526
-				if($serviceNow)
527
-				{
465
+				if($serviceNow) {
528 466
 					$this->service();
529 467
 				}
530 468
 			}
@@ -562,12 +500,10 @@  discard block
 block discarded – undo
562 500
 			// so we split it: system debug is base 64 encoded,
563 501
 			// user debug info should be encoded by the end user using the INTERNAL_ENCODING
564 502
 			$out = '';
565
-			if ($this->debug_info != '')
566
-			{
503
+			if ($this->debug_info != '') {
567 504
 				$out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n";
568 505
 			}
569
-			if($GLOBALS['_xmlrpc_debuginfo']!='')
570
-			{
506
+			if($GLOBALS['_xmlrpc_debuginfo']!='') {
571 507
 
572 508
 				$out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n";
573 509
 				// NB: a better solution MIGHT be to use CDATA, but we need to insert it
@@ -585,16 +521,12 @@  discard block
 block discarded – undo
585 521
 		*/
586 522
 		function service($data=null, $return_payload=false)
587 523
 		{
588
-			if ($data === null)
589
-			{
524
+			if ($data === null) {
590 525
 				// workaround for a known bug in php ver. 5.2.2 that broke $HTTP_RAW_POST_DATA
591 526
 				$ver = phpversion();
592
-				if ($ver[0] >= 5)
593
-				{
527
+				if ($ver[0] >= 5) {
594 528
 					$data = file_get_contents('php://input');
595
-				}
596
-				else
597
-				{
529
+				} else {
598 530
 					$data = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
599 531
 				}
600 532
 			}
@@ -604,49 +536,42 @@  discard block
 block discarded – undo
604 536
 			$this->debug_info = '';
605 537
 
606 538
 			// Echo back what we received, before parsing it
607
-			if($this->debug > 1)
608
-			{
539
+			if($this->debug > 1) {
609 540
 				$this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++");
610 541
 			}
611 542
 
612 543
 			$r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding);
613
-			if (!$r)
614
-			{
544
+			if (!$r) {
615 545
 				$r=$this->parseRequest($data, $req_charset);
616 546
 			}
617 547
 
618 548
 			// save full body of request into response, for more debugging usages
619 549
 			$r->raw_data = $raw_data;
620 550
 
621
-			if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors'])
622
-			{
551
+			if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) {
623 552
 				$this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" .
624 553
 					$GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++");
625 554
 			}
626 555
 
627 556
 			$payload=$this->xml_header($resp_charset);
628
-			if($this->debug > 0)
629
-			{
557
+			if($this->debug > 0) {
630 558
 				$payload = $payload . $this->serializeDebug($resp_charset);
631 559
 			}
632 560
 
633 561
 			// G. Giunta 2006-01-27: do not create response serialization if it has
634 562
 			// already happened. Helps building json magic
635
-			if (empty($r->payload))
636
-			{
563
+			if (empty($r->payload)) {
637 564
 				$r->serialize($resp_charset);
638 565
 			}
639 566
 			$payload = $payload . $r->payload;
640 567
 
641
-			if ($return_payload)
642
-			{
568
+			if ($return_payload) {
643 569
 				return $payload;
644 570
 			}
645 571
 
646 572
 			// if we get a warning/error that has output some text before here, then we cannot
647 573
 			// add a new header. We cannot say we are sending xml, either...
648
-			if(!headers_sent())
649
-			{
574
+			if(!headers_sent()) {
650 575
 				header('Content-Type: '.$r->content_type);
651 576
 				// we do not know if client actually told us an accepted charset, but if he did
652 577
 				// we have to tell him what we did
@@ -657,16 +582,12 @@  discard block
 block discarded – undo
657 582
 				// and php ini settings do not force it already
658 583
 				$php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler');
659 584
 				if($this->compress_response && function_exists('gzencode') && $resp_encoding != ''
660
-					&& $php_no_self_compress)
661
-				{
662
-					if(strpos($resp_encoding, 'gzip') !== false)
663
-					{
585
+					&& $php_no_self_compress) {
586
+					if(strpos($resp_encoding, 'gzip') !== false) {
664 587
 						$payload = gzencode($payload);
665 588
 						header("Content-Encoding: gzip");
666 589
 						header("Vary: Accept-Encoding");
667
-					}
668
-					elseif (strpos($resp_encoding, 'deflate') !== false)
669
-					{
590
+					} elseif (strpos($resp_encoding, 'deflate') !== false) {
670 591
 						$payload = gzcompress($payload);
671 592
 						header("Content-Encoding: deflate");
672 593
 						header("Vary: Accept-Encoding");
@@ -675,13 +596,10 @@  discard block
 block discarded – undo
675 596
 
676 597
 				// do not ouput content-length header if php is compressing output for us:
677 598
 				// it will mess up measurements
678
-				if($php_no_self_compress)
679
-				{
599
+				if($php_no_self_compress) {
680 600
 					header('Content-Length: ' . (int)strlen($payload));
681 601
 				}
682
-			}
683
-			else
684
-			{
602
+			} else {
685 603
 				error_log('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages');
686 604
 			}
687 605
 
@@ -706,12 +624,10 @@  discard block
 block discarded – undo
706 624
 				'function'	=> $function,
707 625
 				'docstring' => $doc
708 626
 			);
709
-			if ($sig)
710
-			{
627
+			if ($sig) {
711 628
 				$this->dmap[$methodname]['signature'] = $sig;
712 629
 			}
713
-			if ($sigdoc)
714
-			{
630
+			if ($sigdoc) {
715 631
 				$this->dmap[$methodname]['signature_docs'] = $sigdoc;
716 632
 			}
717 633
 		}
@@ -725,41 +641,28 @@  discard block
 block discarded – undo
725 641
 		function verifySignature($in, $sig)
726 642
 		{
727 643
 			// check each possible signature in turn
728
-			if (is_object($in))
729
-			{
644
+			if (is_object($in)) {
730 645
 				$numParams = $in->getNumParams();
731
-			}
732
-			else
733
-			{
646
+			} else {
734 647
 				$numParams = count($in);
735 648
 			}
736
-			foreach($sig as $cursig)
737
-			{
738
-				if(count($cursig)==$numParams+1)
739
-				{
649
+			foreach($sig as $cursig) {
650
+				if(count($cursig)==$numParams+1) {
740 651
 					$itsOK=1;
741
-					for($n=0; $n<$numParams; $n++)
742
-					{
743
-						if (is_object($in))
744
-						{
652
+					for($n=0; $n<$numParams; $n++) {
653
+						if (is_object($in)) {
745 654
 							$p=$in->getParam($n);
746
-							if($p->kindOf() == 'scalar')
747
-							{
655
+							if($p->kindOf() == 'scalar') {
748 656
 								$pt=$p->scalartyp();
749
-							}
750
-							else
751
-							{
657
+							} else {
752 658
 								$pt=$p->kindOf();
753 659
 							}
754
-						}
755
-						else
756
-						{
660
+						} else {
757 661
 							$pt= $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4...
758 662
 						}
759 663
 
760 664
 						// param index is $n+1, as first member of sig is return type
761
-						if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue'])
762
-						{
665
+						if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) {
763 666
 							$itsOK=0;
764 667
 							$pno=$n+1;
765 668
 							$wanted=$cursig[$n+1];
@@ -767,18 +670,15 @@  discard block
 block discarded – undo
767 670
 							break;
768 671
 						}
769 672
 					}
770
-					if($itsOK)
771
-					{
673
+					if($itsOK) {
772 674
 						return array(1,'');
773 675
 					}
774 676
 				}
775 677
 			}
776
-			if(isset($wanted))
777
-			{
678
+			if(isset($wanted)) {
778 679
 				return array(0, "Wanted ${wanted}, got ${got} at param ${pno}");
779 680
 			}
780
-			else
781
-			{
681
+			else {
782 682
 				return array(0, "No method signature matches number of parameters");
783 683
 			}
784 684
 		}
@@ -792,63 +692,46 @@  discard block
 block discarded – undo
792 692
 		{
793 693
 			// check if $_SERVER is populated: it might have been disabled via ini file
794 694
 			// (this is true even when in CLI mode)
795
-			if (count($_SERVER) == 0)
796
-			{
695
+			if (count($_SERVER) == 0) {
797 696
 				error_log('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated');
798 697
 			}
799 698
 
800
-			if($this->debug > 1)
801
-			{
802
-				if(function_exists('getallheaders'))
803
-				{
699
+			if($this->debug > 1) {
700
+				if(function_exists('getallheaders')) {
804 701
 					$this->debugmsg(''); // empty line
805
-					foreach(getallheaders() as $name => $val)
806
-					{
702
+					foreach(getallheaders() as $name => $val) {
807 703
 						$this->debugmsg("HEADER: $name: $val");
808 704
 					}
809 705
 				}
810 706
 
811 707
 			}
812 708
 
813
-			if(isset($_SERVER['HTTP_CONTENT_ENCODING']))
814
-			{
709
+			if(isset($_SERVER['HTTP_CONTENT_ENCODING'])) {
815 710
 				$content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']);
816
-			}
817
-			else
818
-			{
711
+			} else {
819 712
 				$content_encoding = '';
820 713
 			}
821 714
 
822 715
 			// check if request body has been compressed and decompress it
823
-			if($content_encoding != '' && strlen($data))
824
-			{
825
-				if($content_encoding == 'deflate' || $content_encoding == 'gzip')
826
-				{
716
+			if($content_encoding != '' && strlen($data)) {
717
+				if($content_encoding == 'deflate' || $content_encoding == 'gzip') {
827 718
 					// if decoding works, use it. else assume data wasn't gzencoded
828
-					if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression))
829
-					{
830
-						if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data))
831
-						{
719
+					if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) {
720
+						if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) {
832 721
 							$data = $degzdata;
833
-							if($this->debug > 1)
834
-							{
722
+							if($this->debug > 1) {
835 723
 								$this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++");
836 724
 							}
837
-						}
838
-						elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
839
-						{
725
+						} elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
840 726
 							$data = $degzdata;
841
-							if($this->debug > 1)
842
-								$this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++");
843
-						}
844
-						else
845
-						{
727
+							if($this->debug > 1) {
728
+															$this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++");
729
+							}
730
+						} else {
846 731
 							$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_decompress_fail'], $GLOBALS['xmlrpcstr']['server_decompress_fail']);
847 732
 							return $r;
848 733
 						}
849
-					}
850
-					else
851
-					{
734
+					} else {
852 735
 						//error_log('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
853 736
 						$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_cannot_decompress'], $GLOBALS['xmlrpcstr']['server_cannot_decompress']);
854 737
 						return $r;
@@ -858,41 +741,35 @@  discard block
 block discarded – undo
858 741
 
859 742
 			// check if client specified accepted charsets, and if we know how to fulfill
860 743
 			// the request
861
-			if ($this->response_charset_encoding == 'auto')
862
-			{
744
+			if ($this->response_charset_encoding == 'auto') {
863 745
 				$resp_encoding = '';
864
-				if (isset($_SERVER['HTTP_ACCEPT_CHARSET']))
865
-				{
746
+				if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
866 747
 					// here we should check if we can match the client-requested encoding
867 748
 					// with the encodings we know we can generate.
868 749
 					/// @todo we should parse q=0.x preferences instead of getting first charset specified...
869 750
 					$client_accepted_charsets = explode(',', strtoupper($_SERVER['HTTP_ACCEPT_CHARSET']));
870 751
 					// Give preference to internal encoding
871 752
 					$known_charsets = array($GLOBALS['xmlrpc_internalencoding'], 'UTF-8', 'ISO-8859-1', 'US-ASCII');
872
-					foreach ($known_charsets as $charset)
873
-					{
874
-						foreach ($client_accepted_charsets as $accepted)
875
-							if (strpos($accepted, $charset) === 0)
753
+					foreach ($known_charsets as $charset) {
754
+						foreach ($client_accepted_charsets as $accepted) {
755
+													if (strpos($accepted, $charset) === 0)
876 756
 							{
877 757
 								$resp_encoding = $charset;
758
+						}
878 759
 								break;
879 760
 							}
880
-						if ($resp_encoding)
881
-							break;
761
+						if ($resp_encoding) {
762
+													break;
763
+						}
882 764
 					}
883 765
 				}
884
-			}
885
-			else
886
-			{
766
+			} else {
887 767
 				$resp_encoding = $this->response_charset_encoding;
888 768
 			}
889 769
 
890
-			if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
891
-			{
770
+			if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
892 771
 				$resp_compression = $_SERVER['HTTP_ACCEPT_ENCODING'];
893
-			}
894
-			else
895
-			{
772
+			} else {
896 773
 				$resp_compression = '';
897 774
 			}
898 775
 
@@ -936,23 +813,21 @@  discard block
 block discarded – undo
936 813
 			$GLOBALS['_xh']['rt']='';
937 814
 
938 815
 			// decompose incoming XML into request structure
939
-			if ($req_encoding != '')
940
-			{
941
-				if (!in_array($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
942
-				// the following code might be better for mb_string enabled installs, but
816
+			if ($req_encoding != '') {
817
+				if (!in_array($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) {
818
+								// the following code might be better for mb_string enabled installs, but
943 819
 				// makes the lib about 200% slower...
944 820
 				//if (!is_valid_charset($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
945 821
 				{
946 822
 					error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$req_encoding);
823
+				}
947 824
 					$req_encoding = $GLOBALS['xmlrpc_defencoding'];
948 825
 				}
949 826
 				/// @BUG this will fail on PHP 5 if charset is not specified in the xml prologue,
950 827
 				// the encoding is not UTF8 and there are non-ascii chars in the text...
951 828
 				/// @todo use an ampty string for php 5 ???
952 829
 				$parser = xml_parser_create($req_encoding);
953
-			}
954
-			else
955
-			{
830
+			} else {
956 831
 				$parser = xml_parser_create();
957 832
 			}
958 833
 
@@ -963,23 +838,20 @@  discard block
 block discarded – undo
963 838
 			// we use the broadest one, ie. utf8
964 839
 			// This allows to send data which is native in various charset,
965 840
 			// by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding
966
-			if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
967
-			{
841
+			if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) {
968 842
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
969
-			}
970
-			else
971
-			{
843
+			} else {
972 844
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
973 845
 			}
974 846
 
975
-			if ($this->functions_parameters_type != 'xmlrpcvals')
976
-				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
977
-			else
978
-				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
847
+			if ($this->functions_parameters_type != 'xmlrpcvals') {
848
+							xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
849
+			} else {
850
+							xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
851
+			}
979 852
 			xml_set_character_data_handler($parser, 'xmlrpc_cd');
980 853
 			xml_set_default_handler($parser, 'xmlrpc_dh');
981
-			if(!xml_parse($parser, $data, 1))
982
-			{
854
+			if(!xml_parse($parser, $data, 1)) {
983 855
 				// return XML error as a faultCode
984 856
 				$r=new xmlrpcresp(0,
985 857
 				$GLOBALS['xmlrpcerrxml']+xml_get_error_code($parser),
@@ -987,41 +859,31 @@  discard block
 block discarded – undo
987 859
 					xml_error_string(xml_get_error_code($parser)),
988 860
 					xml_get_current_line_number($parser), xml_get_current_column_number($parser)));
989 861
 				xml_parser_free($parser);
990
-			}
991
-			elseif ($GLOBALS['_xh']['isf'])
992
-			{
862
+			} elseif ($GLOBALS['_xh']['isf']) {
993 863
 				xml_parser_free($parser);
994 864
 				$r=new xmlrpcresp(0,
995 865
 					$GLOBALS['xmlrpcerr']['invalid_request'],
996 866
 					$GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']);
997
-			}
998
-			else
999
-			{
867
+			} else {
1000 868
 				xml_parser_free($parser);
1001 869
 				// small layering violation in favor of speed and memory usage:
1002 870
 				// we should allow the 'execute' method handle this, but in the
1003 871
 				// most common scenario (xmlrpcvals type server with some methods
1004 872
 				// registered as phpvals) that would mean a useless encode+decode pass
1005
-				if ($this->functions_parameters_type != 'xmlrpcvals' || (isset($this->dmap[$GLOBALS['_xh']['method']]['parameters_type']) && ($this->dmap[$GLOBALS['_xh']['method']]['parameters_type'] == 'phpvals')))
1006
-				{
1007
-					if($this->debug > 1)
1008
-					{
873
+				if ($this->functions_parameters_type != 'xmlrpcvals' || (isset($this->dmap[$GLOBALS['_xh']['method']]['parameters_type']) && ($this->dmap[$GLOBALS['_xh']['method']]['parameters_type'] == 'phpvals'))) {
874
+					if($this->debug > 1) {
1009 875
 						$this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++");
1010 876
 					}
1011 877
 					$r = $this->execute($GLOBALS['_xh']['method'], $GLOBALS['_xh']['params'], $GLOBALS['_xh']['pt']);
1012
-				}
1013
-				else
1014
-				{
878
+				} else {
1015 879
 					// build an xmlrpcmsg object with data parsed from xml
1016 880
 					$m=new xmlrpcmsg($GLOBALS['_xh']['method']);
1017 881
 					// now add parameters in
1018
-					for($i=0; $i<count($GLOBALS['_xh']['params']); $i++)
1019
-					{
882
+					for($i=0; $i<count($GLOBALS['_xh']['params']); $i++) {
1020 883
 						$m->addParam($GLOBALS['_xh']['params'][$i]);
1021 884
 					}
1022 885
 
1023
-					if($this->debug > 1)
1024
-					{
886
+					if($this->debug > 1) {
1025 887
 						$this->debugmsg("\n+++PARSED+++\n".var_export($m, true)."\n+++END+++");
1026 888
 					}
1027 889
 					$r = $this->execute($m);
@@ -1040,19 +902,15 @@  discard block
 block discarded – undo
1040 902
 		*/
1041 903
 		function execute($m, $params=null, $paramtypes=null)
1042 904
 		{
1043
-			if (is_object($m))
1044
-			{
905
+			if (is_object($m)) {
1045 906
 				$methName = $m->method();
1046
-			}
1047
-			else
1048
-			{
907
+			} else {
1049 908
 				$methName = $m;
1050 909
 			}
1051 910
 			$sysCall = $this->allow_system_funcs && (strpos($methName, "system.") === 0);
1052 911
 			$dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap;
1053 912
 
1054
-			if(!isset($dmap[$methName]['function']))
1055
-			{
913
+			if(!isset($dmap[$methName]['function'])) {
1056 914
 				// No such method
1057 915
 				return new xmlrpcresp(0,
1058 916
 					$GLOBALS['xmlrpcerr']['unknown_method'],
@@ -1060,19 +918,14 @@  discard block
 block discarded – undo
1060 918
 			}
1061 919
 
1062 920
 			// Check signature
1063
-			if(isset($dmap[$methName]['signature']))
1064
-			{
921
+			if(isset($dmap[$methName]['signature'])) {
1065 922
 				$sig = $dmap[$methName]['signature'];
1066
-				if (is_object($m))
1067
-				{
923
+				if (is_object($m)) {
1068 924
 					list($ok, $errstr) = $this->verifySignature($m, $sig);
1069
-				}
1070
-				else
1071
-				{
925
+				} else {
1072 926
 					list($ok, $errstr) = $this->verifySignature($paramtypes, $sig);
1073 927
 				}
1074
-				if(!$ok)
1075
-				{
928
+				if(!$ok) {
1076 929
 					// Didn't match.
1077 930
 					return new xmlrpcresp(
1078 931
 						0,
@@ -1084,13 +937,11 @@  discard block
 block discarded – undo
1084 937
 
1085 938
 			$func = $dmap[$methName]['function'];
1086 939
 			// let the 'class::function' syntax be accepted in dispatch maps
1087
-			if(is_string($func) && strpos($func, '::'))
1088
-			{
940
+			if(is_string($func) && strpos($func, '::')) {
1089 941
 				$func = explode('::', $func);
1090 942
 			}
1091 943
 			// verify that function to be invoked is in fact callable
1092
-			if(!is_callable($func))
1093
-			{
944
+			if(!is_callable($func)) {
1094 945
 				error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler is not callable");
1095 946
 				return new xmlrpcresp(
1096 947
 					0,
@@ -1101,32 +952,22 @@  discard block
 block discarded – undo
1101 952
 
1102 953
 			// If debug level is 3, we should catch all errors generated during
1103 954
 			// processing of user function, and log them as part of response
1104
-			if($this->debug > 2)
1105
-			{
955
+			if($this->debug > 2) {
1106 956
 				$GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler');
1107 957
 			}
1108
-			try
1109
-			{
958
+			try {
1110 959
 				// Allow mixed-convention servers
1111
-				if (is_object($m))
1112
-				{
1113
-					if($sysCall)
1114
-					{
960
+				if (is_object($m)) {
961
+					if($sysCall) {
1115 962
 						$r = call_user_func($func, $this, $m);
1116
-					}
1117
-					else
1118
-					{
963
+					} else {
1119 964
 						$r = call_user_func($func, $m);
1120 965
 					}
1121
-					if (!is_a($r, 'xmlrpcresp'))
1122
-					{
966
+					if (!is_a($r, 'xmlrpcresp')) {
1123 967
 						error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler does not return an xmlrpcresp object");
1124
-						if (is_a($r, 'xmlrpcval'))
1125
-						{
968
+						if (is_a($r, 'xmlrpcval')) {
1126 969
 							$r = new xmlrpcresp($r);
1127
-						}
1128
-						else
1129
-						{
970
+						} else {
1130 971
 							$r = new xmlrpcresp(
1131 972
 								0,
1132 973
 								$GLOBALS['xmlrpcerr']['server_error'],
@@ -1134,54 +975,39 @@  discard block
 block discarded – undo
1134 975
 							);
1135 976
 						}
1136 977
 					}
1137
-				}
1138
-				else
1139
-				{
978
+				} else {
1140 979
 					// call a 'plain php' function
1141
-					if($sysCall)
1142
-					{
980
+					if($sysCall) {
1143 981
 						array_unshift($params, $this);
1144 982
 						$r = call_user_func_array($func, $params);
1145
-					}
1146
-					else
1147
-					{
983
+					} else {
1148 984
 						// 3rd API convention for method-handling functions: EPI-style
1149
-						if ($this->functions_parameters_type == 'epivals')
1150
-						{
985
+						if ($this->functions_parameters_type == 'epivals') {
1151 986
 							$r = call_user_func_array($func, array($methName, $params, $this->user_data));
1152 987
 							// mimic EPI behaviour: if we get an array that looks like an error, make it
1153 988
 							// an eror response
1154
-							if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r))
1155
-							{
989
+							if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) {
1156 990
 								$r = new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']);
1157
-							}
1158
-							else
1159
-							{
991
+							} else {
1160 992
 								// functions using EPI api should NOT return resp objects,
1161 993
 								// so make sure we encode the return type correctly
1162 994
 								$r = new xmlrpcresp(php_xmlrpc_encode($r, array('extension_api')));
1163 995
 							}
1164
-						}
1165
-						else
1166
-						{
996
+						} else {
1167 997
 							$r = call_user_func_array($func, $params);
1168 998
 						}
1169 999
 					}
1170 1000
 					// the return type can be either an xmlrpcresp object or a plain php value...
1171
-					if (!is_a($r, 'xmlrpcresp'))
1172
-					{
1001
+					if (!is_a($r, 'xmlrpcresp')) {
1173 1002
 						// what should we assume here about automatic encoding of datetimes
1174 1003
 						// and php classes instances???
1175 1004
 						$r = new xmlrpcresp(php_xmlrpc_encode($r, $this->phpvals_encoding_options));
1176 1005
 					}
1177 1006
 				}
1178
-			}
1179
-			catch(Exception $e)
1180
-			{
1007
+			} catch(Exception $e) {
1181 1008
 				// (barring errors in the lib) an uncatched exception happened
1182 1009
 				// in the called function, we wrap it in a proper error-response
1183
-				switch($this->exception_handling)
1184
-				{
1010
+				switch($this->exception_handling) {
1185 1011
 					case 2:
1186 1012
 						throw $e;
1187 1013
 						break;
@@ -1192,16 +1018,12 @@  discard block
 block discarded – undo
1192 1018
 						$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error']);
1193 1019
 				}
1194 1020
 			}
1195
-			if($this->debug > 2)
1196
-			{
1021
+			if($this->debug > 2) {
1197 1022
 				// note: restore the error handler we found before calling the
1198 1023
 				// user func, even if it has been changed inside the func itself
1199
-				if($GLOBALS['_xmlrpcs_prev_ehandler'])
1200
-				{
1024
+				if($GLOBALS['_xmlrpcs_prev_ehandler']) {
1201 1025
 					set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']);
1202
-				}
1203
-				else
1204
-				{
1026
+				} else {
1205 1027
 					restore_error_handler();
1206 1028
 				}
1207 1029
 			}
@@ -1223,12 +1045,9 @@  discard block
 block discarded – undo
1223 1045
 		*/
1224 1046
 		function xml_header($charset_encoding='')
1225 1047
 		{
1226
-			if ($charset_encoding != '')
1227
-			{
1048
+			if ($charset_encoding != '') {
1228 1049
 				return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?" . ">\n";
1229
-			}
1230
-			else
1231
-			{
1050
+			} else {
1232 1051
 				return "<?xml version=\"1.0\"?" . ">\n";
1233 1052
 			}
1234 1053
 		}
Please login to merge, or discard this patch.
Components/CSRFWhitelistAware.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,6 +3,8 @@
 block discarded – undo
3 3
 namespace Shopware\Components;
4 4
 
5 5
 if (!interface_exists('\Shopware\Components\CSRFWhitelistAware')) {
6
-    interface CSRFWhitelistAware {}
6
+    interface CSRFWhitelistAware
7
+    {
8
+}
7 9
 }
8 10
 
Please login to merge, or discard this patch.
Components/KlarnaCheckout/Checkout/BasicConnector.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -325,7 +325,8 @@
 block discarded – undo
325 325
      * @param bool $blIncludeDebugBacktrace
326 326
      * @return void
327 327
      */
328
-    public function klarnaLog($message, $logLevelMessage=1, $mPrintableElement=null) {
328
+    public function klarnaLog($message, $logLevelMessage=1, $mPrintableElement=null)
329
+    {
329 330
         $configname = 'klarnaLogLevel';
330 331
         $elementId = Shopware()->Db()->fetchOne('SELECT id FROM s_core_config_elements WHERE name = ?', [$configname]);
331 332
         $logLevelConfigSetting = Shopware()->Db()->fetchOne('SELECT value FROM s_core_config_values WHERE element_id = ?', [$elementId]);
Please login to merge, or discard this patch.
Components/KlarnaCheckout/Checkout/Order.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -264,7 +264,8 @@
 block discarded – undo
264 264
      * @param bool $blIncludeDebugBacktrace
265 265
      * @return void
266 266
      */
267
-    public function klarnaLog($message, $logLevelMessage=1) {
267
+    public function klarnaLog($message, $logLevelMessage=1)
268
+    {
268 269
         $configname = 'klarnaLogLevel';
269 270
         $elementId = Shopware()->Db()->fetchOne('SELECT id FROM s_core_config_elements WHERE name = ?', [$configname]);
270 271
         $logLevelConfigSetting = Shopware()->Db()->fetchOne('SELECT value FROM s_core_config_values WHERE element_id = ?', [$elementId]);
Please login to merge, or discard this patch.
Controllers/Frontend/PaymentKlarna.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -789,7 +789,8 @@
 block discarded – undo
789 789
                             $session->offsetGet('sRegisterFinished')
790 790
                         );
791 791
                     }
792
-                } catch (\Exception $ex) { /* do nothing */
792
+                } catch (\Exception $ex) {
793
+/* do nothing */
793 794
                     $this->plugin->klarnaLog("ERROR while creating User. Exception information:". $ex->getMessage(), 1);
794 795
                 }
795 796
             }
Please login to merge, or discard this patch.