Completed
Push — php51 ( 617621...a4e868 )
by Gaetano
16:05 queued 06:04
created
demo/client/mail.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@
 block discarded – undo
17 17
 include("xmlrpc.inc");
18 18
 
19 19
 // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off
20
-if (!isset($HTTP_POST_VARS) && isset($_POST))
20
+if (!isset($HTTP_POST_VARS) && isset($_POST)) {
21 21
 	$HTTP_POST_VARS = $_POST;
22
+}
22 23
 
23 24
 if (isset($HTTP_POST_VARS["server"]) && $HTTP_POST_VARS["server"]) {
24 25
 	if ($HTTP_POST_VARS["server"]=="Userland") {
Please login to merge, or discard this patch.
demo/client/zopetest.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
 		print "I received:" . htmlspecialchars($v->scalarval()) . "<br/>";
18 18
 		print "<hr/>I got this value back<br/>pre>" .
19 19
 		htmlentities($r->serialize()). "</pre>\n";
20
-	}
21
-	else
20
+	} else
22 21
 	{
23 22
 		print "An error occurred: ";
24 23
 		print "Code: " . htmlspecialchars($r->faultCode())
Please login to merge, or discard this patch.
demo/client/introspect.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
1
-<html>

<head><title>xmlrpc</title></head>

<body>

<h1>Introspect demo</h1>

<h2>Query server for available methods and their description</h2>

<h3>The code demonstrates usage of multicall and introspection methods</h3>

<?php

	include("xmlrpc.inc");



	function display_error($r)

	{

		print "An error occurred: ";

		print "Code: " . $r->faultCode()

			. " Reason: '" .$r->faultString()."'<br/>";

	}



	// 'new style' client constuctor

	$c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php");

	print "<h3>methods available at http://" . $c->server . $c->path .  "</h3>\n";



	$m = new xmlrpcmsg('system.listMethods');

	$r =& $c->send($m);

	if($r->faultCode())

	{

		display_error($r);

	}

	else

	{

		$v=$r->value();

		for($i=0; $i<$v->arraysize(); $i++)

		{

			$mname=$v->arraymem($i);

			print "<h4>" . $mname->scalarval() . "</h4>\n";



			// build messages first, add params later

			$m1  = new xmlrpcmsg('system.methodHelp');

			$m2  = new xmlrpcmsg('system.methodSignature');

			$val = new xmlrpcval($mname->scalarval(), "string");

			$m1->addParam($val);

			$m2->addParam($val);



			// send multiple messages in one pass.

			// If server does not support multicall, client will fall back to 2 separate calls

			$ms = array($m1, $m2);

			$rs =& $c->send($ms);



			if($rs[0]->faultCode())

			{

				display_error($rs[0]);

			}

			else

			{

				$val=$rs[0]->value();

				$txt=$val->scalarval();

				if($txt != "")

				{

					print "<h4>Documentation</h4><p>${txt}</p>\n";

				}

				else

				{

					print "<p>No documentation available.</p>\n";

				}

			}



			if($rs[1]->faultCode())

			{

				display_error($rs[1]);

			}

			else

			{

				print "<h4>Signature</h4><p>\n";

				$val = $rs[1]->value();

				if($val->kindOf()=="array")

				{

					for($j=0; $j<$val->arraysize(); $j++)

					{

						$x = $val->arraymem($j);

						$ret = $x->arraymem(0);

						print "<code>" . $ret->scalarval() . " "

							. $mname->scalarval() . "(";

						if($x->arraysize()>1)

						{

							for($k=1; $k<$x->arraysize(); $k++)

							{

								$y = $x->arraymem($k);

								print $y->scalarval();

								if($k < $x->arraysize()-1)

								{

									print ", ";

								}

							}

						}

						print ")</code><br/>\n";

					}

				}

				else

				{

					print "Signature unknown\n";

				}

				print "</p>\n";

			}

		}

	}

?>

</body>

</html>

2 1
\ No newline at end of file
2
+<html>

<head><title>xmlrpc</title></head>

<body>

<h1>Introspect demo</h1>

<h2>Query server for available methods and their description</h2>

<h3>The code demonstrates usage of multicall and introspection methods</h3>

<?php

	include("xmlrpc.inc");



	function display_error($r)

	{

		print "An error occurred: ";

		print "Code: " . $r->faultCode()

			. " Reason: '" .$r->faultString()."'<br/>";

	}



	// 'new style' client constuctor

	$c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php");

	print "<h3>methods available at http://" . $c->server . $c->path .  "</h3>\n";



	$m = new xmlrpcmsg('system.listMethods');

	$r =& $c->send($m);

	if($r->faultCode())

	{

		display_error($r);

	} else

	{

		$v=$r->value();

		for($i=0; $i<$v->arraysize(); $i++)

		{

			$mname=$v->arraymem($i);

			print "<h4>" . $mname->scalarval() . "</h4>\n";



			// build messages first, add params later

			$m1  = new xmlrpcmsg('system.methodHelp');

			$m2  = new xmlrpcmsg('system.methodSignature');

			$val = new xmlrpcval($mname->scalarval(), "string");

			$m1->addParam($val);

			$m2->addParam($val);



			// send multiple messages in one pass.

			// If server does not support multicall, client will fall back to 2 separate calls

			$ms = array($m1, $m2);

			$rs =& $c->send($ms);



			if($rs[0]->faultCode())

			{

				display_error($rs[0]);

			} else

			{

				$val=$rs[0]->value();

				$txt=$val->scalarval();

				if($txt != "")

				{

					print "<h4>Documentation</h4><p>${txt}</p>\n";

				} else

				{

					print "<p>No documentation available.</p>\n";

				}

			}



			if($rs[1]->faultCode())

			{

				display_error($rs[1]);

			} else

			{

				print "<h4>Signature</h4><p>\n";

				$val = $rs[1]->value();

				if($val->kindOf()=="array")

				{

					for($j=0; $j<$val->arraysize(); $j++)

					{

						$x = $val->arraymem($j);

						$ret = $x->arraymem(0);

						print "<code>" . $ret->scalarval() . " "

							. $mname->scalarval() . "(";

						if($x->arraysize()>1)

						{

							for($k=1; $k<$x->arraysize(); $k++)

							{

								$y = $x->arraymem($k);

								print $y->scalarval();

								if($k < $x->arraysize()-1)

								{

									print ", ";

								}

							}

						}

						print ")</code><br/>\n";

					}

				} else

				{

					print "Signature unknown\n";

				}

				print "</p>\n";

			}

		}

	}

?>

</body>

</html>

3 3
\ No newline at end of file
Please login to merge, or discard this patch.
demo/client/which.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
1
-<html>

<head><title>xmlrpc</title></head>

<body>

<h1>Which toolkit demo</h1>

<h2>Query server for toolkit information</h2>

<h3>The code demonstrates usage of the php_xmlrpc_decode function</h3>

<?php

	include("xmlrpc.inc");



	$f = new xmlrpcmsg('interopEchoTests.whichToolkit', array());

	$c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);

	$r = $c->send($f);

	if(!$r->faultCode())

	{

		$v = php_xmlrpc_decode($r->value());

		print "<pre>";

		print "name: " . htmlspecialchars($v["toolkitName"]) . "\n";

		print "version: " . htmlspecialchars($v["toolkitVersion"]) . "\n";

		print "docs: " . htmlspecialchars($v["toolkitDocsUrl"]) . "\n";

		print "os: " . htmlspecialchars($v["toolkitOperatingSystem"]) . "\n";

		print "</pre>";

	}

	else

	{

		print "An error occurred: ";

		print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'\n";

	}

?>

</body>

</html>

2 1
\ No newline at end of file
2
+<html>

<head><title>xmlrpc</title></head>

<body>

<h1>Which toolkit demo</h1>

<h2>Query server for toolkit information</h2>

<h3>The code demonstrates usage of the php_xmlrpc_decode function</h3>

<?php

	include("xmlrpc.inc");



	$f = new xmlrpcmsg('interopEchoTests.whichToolkit', array());

	$c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);

	$r = $c->send($f);

	if(!$r->faultCode())

	{

		$v = php_xmlrpc_decode($r->value());

		print "<pre>";

		print "name: " . htmlspecialchars($v["toolkitName"]) . "\n";

		print "version: " . htmlspecialchars($v["toolkitVersion"]) . "\n";

		print "docs: " . htmlspecialchars($v["toolkitDocsUrl"]) . "\n";

		print "os: " . htmlspecialchars($v["toolkitOperatingSystem"]) . "\n";

		print "</pre>";

	} else

	{

		print "An error occurred: ";

		print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'\n";

	}

?>

</body>

</html>

3 3
\ No newline at end of file
Please login to merge, or discard this patch.
doc/convert.php 1 patch
Braces   +17 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,18 +5,21 @@  discard block
 block discarded – undo
5 5
  * @copyright (c) 2007-2014 G. Giunta
6 6
  */
7 7
 
8
-if ($_SERVER['argc'] < 4)
8
+if ($_SERVER['argc'] < 4) {
9 9
     die("Usage: php convert.php docbook.xml \path\\to\stylesheet.xsl output-dir|output_file\n");
10
-else
10
+} else {
11 11
     echo "Starting xsl conversion process...\n";
12
+}
12 13
 
13 14
 $doc = $_SERVER['argv'][1];
14 15
 $xss = $_SERVER['argv'][2];
15 16
 
16
-if (!file_exists($doc))
17
+if (!file_exists($doc)) {
17 18
     die("KO: file $doc cannot be found\n");
18
-if (!file_exists($xss))
19
+}
20
+if (!file_exists($xss)) {
19 21
     die("KO: file $xss cannot be found\n");
22
+}
20 23
 
21 24
 // Load the XML source
22 25
 $xml = new DOMDocument;
@@ -28,10 +31,10 @@  discard block
 block discarded – undo
28 31
 $proc = new XSLTProcessor;
29 32
 if (version_compare(PHP_VERSION,'5.4',"<"))
30 33
 {
31
-    if(defined('XSL_SECPREF_WRITE_FILE'))
32
-        ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
33
-}
34
-else
34
+    if(defined('XSL_SECPREF_WRITE_FILE')) {
35
+            ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
36
+    }
37
+    } else
35 38
 {
36 39
     $proc->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
37 40
 }
@@ -41,18 +44,19 @@  discard block
 block discarded – undo
41 44
 //{
42 45
     if (is_dir($_SERVER['argv'][3]))
43 46
     {
44
-        if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3])))
45
-            echo "setting param base.dir KO\n";
46
-    }
47
-    else
47
+        if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3]))) {
48
+                    echo "setting param base.dir KO\n";
49
+        }
50
+    } else
48 51
     {
49 52
         //echo "{$_SERVER['argv'][3]} is not a dir\n";
50 53
     }
51 54
 //}
52 55
 
53 56
 $out = $proc->transformToXML($xml);
54
-if (!is_dir($_SERVER['argv'][3]))
57
+if (!is_dir($_SERVER['argv'][3])) {
55 58
     file_put_contents($_SERVER['argv'][3], $out);
59
+}
56 60
 
57 61
 echo "OK\n";
58 62
 ?>
59 63
\ No newline at end of file
Please login to merge, or discard this patch.
lib/xmlrpc_wrappers.inc 1 patch
Braces   +46 added lines, -80 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
 				if(class_exists($phptype))
53 53
 				{
54 54
 					return $GLOBALS['xmlrpcStruct'];
55
-				}
56
-				else
55
+				} else
57 56
 				{
58 57
 					// unknown: might be any 'extended' xmlrpc type
59 58
 					return $GLOBALS['xmlrpcValue'];
@@ -163,14 +162,12 @@  discard block
 block discarded – undo
163 162
 			if(is_string($funcname[0]))
164 163
 			{
165 164
 				$plainfuncname = implode('::', $funcname);
166
-			}
167
-			elseif(is_object($funcname[0]))
165
+			} elseif(is_object($funcname[0]))
168 166
 			{
169 167
 				$plainfuncname = get_class($funcname[0]) . '->' . $funcname[1];
170 168
 			}
171 169
 			$exists = method_exists($funcname[0], $funcname[1]);
172
-		}
173
-		else
170
+		} else
174 171
 		{
175 172
 			$plainfuncname = $funcname;
176 173
 			$exists = function_exists($funcname);
@@ -180,25 +177,23 @@  discard block
 block discarded – undo
180 177
 		{
181 178
 			error_log('XML-RPC: function to be wrapped is not defined: '.$plainfuncname);
182 179
 			return false;
183
-		}
184
-		else
180
+		} else
185 181
 		{
186 182
 			// determine name of new php function
187 183
 			if($newfuncname == '')
188 184
 			{
189 185
 				if(is_array($funcname))
190 186
 				{
191
-					if(is_string($funcname[0]))
192
-						$xmlrpcfuncname = "{$prefix}_".implode('_', $funcname);
193
-					else
194
-						$xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]) . '_' . $funcname[1];
195
-				}
196
-				else
187
+					if(is_string($funcname[0])) {
188
+											$xmlrpcfuncname = "{$prefix}_".implode('_', $funcname);
189
+					} else {
190
+											$xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]) . '_' . $funcname[1];
191
+					}
192
+				} else
197 193
 				{
198 194
 					$xmlrpcfuncname = "{$prefix}_$funcname";
199 195
 				}
200
-			}
201
-			else
196
+			} else
202 197
 			{
203 198
 				$xmlrpcfuncname = $newfuncname;
204 199
 			}
@@ -237,8 +232,7 @@  discard block
 block discarded – undo
237 232
 					return false;
238 233
 				}
239 234
 				/// @todo add more checks for static vs. nonstatic?
240
-			}
241
-			else
235
+			} else
242 236
 			{
243 237
 				$func = new ReflectionFunction($funcname);
244 238
 			}
@@ -276,8 +270,7 @@  discard block
 block discarded – undo
276 270
 							$desc .= "\n";
277 271
 						}
278 272
 						$desc .= $doc;
279
-					}
280
-					elseif(strpos($doc, '@param') === 0)
273
+					} elseif(strpos($doc, '@param') === 0)
281 274
 					{
282 275
 						// syntax: @param type [$name] desc
283 276
 						if(preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches))
@@ -286,8 +279,7 @@  discard block
 block discarded – undo
286 279
 							{
287 280
 								//$paramDocs[$i]['type'] = explode('|', $matches[1]);
288 281
 								$paramDocs[$i]['type'] = 'mixed';
289
-							}
290
-							else
282
+							} else
291 283
 							{
292 284
 								$paramDocs[$i]['type'] = $matches[1];
293 285
 							}
@@ -295,8 +287,7 @@  discard block
 block discarded – undo
295 287
 							$paramDocs[$i]['doc'] = $matches[3];
296 288
 						}
297 289
 						$i++;
298
-					}
299
-					elseif(strpos($doc, '@return') === 0)
290
+					} elseif(strpos($doc, '@return') === 0)
300 291
 					{
301 292
 						// syntax: @return type desc
302 293
 						//$returns = preg_split('/\s+/', $doc);
@@ -348,8 +339,7 @@  discard block
 block discarded – undo
348 339
 				if ($decode_php_objects)
349 340
 				{
350 341
 					$innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i, array('decode_php_objs'));\n";
351
-				}
352
-				else
342
+				} else
353 343
 				{
354 344
 					$innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i);\n";
355 345
 				}
@@ -374,8 +364,7 @@  discard block
 block discarded – undo
374 364
 				// only known good synopsis = no parameters
375 365
 				$parsvariations[] = array();
376 366
 				$minpars = 0;
377
-			}
378
-			else
367
+			} else
379 368
 			{
380 369
 				$minpars = count($parsvariations[0]);
381 370
 			}
@@ -386,8 +375,7 @@  discard block
 block discarded – undo
386 375
 				// NB: this check needs to be done BEFORE decoding param values
387 376
 				$innercode = "\$paramcount = \$msg->getNumParams();\n" .
388 377
 				"if (\$paramcount < $minpars) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}');\n" . $innercode;
389
-			}
390
-			else
378
+			} else
391 379
 			{
392 380
 				$innercode = "\$paramcount = \$msg->getNumParams();\n" . $innercode;
393 381
 			}
@@ -400,8 +388,7 @@  discard block
 block discarded – undo
400 388
 				$GLOBALS['xmlrpcWPFObjHolder'][$xmlrpcfuncname] =& $funcname[0];
401 389
 				$innercode .= "\$obj =& \$GLOBALS['xmlrpcWPFObjHolder']['$xmlrpcfuncname'];\n";
402 390
 				$realfuncname = '$obj->'.$funcname[1];
403
-			}
404
-			else
391
+			} else
405 392
 			{
406 393
 				$realfuncname = $plainfuncname;
407 394
 			}
@@ -416,8 +403,7 @@  discard block
 block discarded – undo
416 403
 					if (isset($paramDocs[$i]['type']))
417 404
 					{
418 405
 						$sig[] = php_2_xmlrpc_type($paramDocs[$i]['type']);
419
-					}
420
-					else
406
+					} else
421 407
 					{
422 408
 						$sig[] = $GLOBALS['xmlrpcValue'];
423 409
 					}
@@ -433,13 +419,13 @@  discard block
 block discarded – undo
433 419
 			if($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64'])
434 420
 			{
435 421
 				$innercode .= "return new {$prefix}resp(new {$prefix}val(\$retval, '$returns'));";
436
-			}
437
-			else
422
+			} else
438 423
 			{
439
-				if ($encode_php_objects)
440
-					$innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval, array('encode_php_objs')));\n";
441
-				else
442
-					$innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval));\n";
424
+				if ($encode_php_objects) {
425
+									$innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval, array('encode_php_objs')));\n";
426
+				} else {
427
+									$innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval));\n";
428
+				}
443 429
 			}
444 430
 			// shall we exclude functions returning by ref?
445 431
 			// if($func->returnsReference())
@@ -556,8 +542,7 @@  discard block
 block discarded – undo
556 542
 		{
557 543
 			$signum = $extra_options;
558 544
 			$extra_options = array();
559
-		}
560
-		else
545
+		} else
561 546
 		{
562 547
 			$signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0;
563 548
 			$timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0;
@@ -578,8 +563,7 @@  discard block
 block discarded – undo
578 563
 		{
579 564
 			$decode_fault = true;
580 565
 			$fault_response = $extra_options['return_on_fault'];
581
-		}
582
-		else
566
+		} else
583 567
 		{
584 568
 			$decode_fault = false;
585 569
 			$fault_response = '';
@@ -598,8 +582,7 @@  discard block
 block discarded – undo
598 582
 		{
599 583
 			error_log('XML-RPC: could not retrieve method signature from remote server for method '.$methodname);
600 584
 			return false;
601
-		}
602
-		else
585
+		} else
603 586
 		{
604 587
 			$msig = $response->value();
605 588
 			if ($client->return_type != 'phpvals')
@@ -610,15 +593,13 @@  discard block
 block discarded – undo
610 593
 			{
611 594
 				error_log('XML-RPC: could not retrieve method signature nr.'.$signum.' from remote server for method '.$methodname);
612 595
 				return false;
613
-			}
614
-			else
596
+			} else
615 597
 			{
616 598
 				// pick a suitable name for the new function, avoiding collisions
617 599
 				if($newfuncname != '')
618 600
 				{
619 601
 					$xmlrpcfuncname = $newfuncname;
620
-				}
621
-				else
602
+				} else
622 603
 				{
623 604
 					// take care to insure that methodname is translated to valid
624 605
 					// php function name
@@ -664,14 +645,12 @@  discard block
 block discarded – undo
664 645
 					if($allOK)
665 646
 					{
666 647
 						return $xmlrpcfuncname;
667
-					}
668
-					else
648
+					} else
669 649
 					{
670 650
 						error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap remote method '.$methodname);
671 651
 						return false;
672 652
 					}
673
-				}
674
-				else
653
+				} else
675 654
 				{
676 655
 					$results['function'] = $xmlrpcfuncname;
677 656
 					return $results;
@@ -711,8 +690,7 @@  discard block
 block discarded – undo
711 690
 		{
712 691
 			error_log('XML-RPC: could not retrieve method list from remote server');
713 692
 			return false;
714
-		}
715
-		else
693
+		} else
716 694
 		{
717 695
 			$mlist = $response->value();
718 696
 			if ($client->return_type != 'phpvals')
@@ -723,15 +701,13 @@  discard block
 block discarded – undo
723 701
 			{
724 702
 				error_log('XML-RPC: could not retrieve meaningful method list from remote server');
725 703
 				return false;
726
-			}
727
-			else
704
+			} else
728 705
 			{
729 706
 				// pick a suitable name for the new function, avoiding collisions
730 707
 				if($newclassname != '')
731 708
 				{
732 709
 					$xmlrpcclassname = $newclassname;
733
-				}
734
-				else
710
+				} else
735 711
 				{
736 712
 					$xmlrpcclassname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
737 713
 						array('_', ''), $client->server).'_client';
@@ -766,8 +742,7 @@  discard block
 block discarded – undo
766 742
 								$source .= $methodwrap['docstring'];
767 743
 							}
768 744
 							$source .= $methodwrap['source']."\n";
769
-						}
770
-						else
745
+						} else
771 746
 						{
772 747
 							error_log('XML-RPC: will not create class method to wrap remote method '.$mname);
773 748
 						}
@@ -783,14 +758,12 @@  discard block
 block discarded – undo
783 758
 					if($allOK)
784 759
 					{
785 760
 						return $xmlrpcclassname;
786
-					}
787
-					else
761
+					} else
788 762
 					{
789 763
 						error_log('XML-RPC: could not create class '.$xmlrpcclassname.' to wrap remote server '.$client->server);
790 764
 						return false;
791 765
 					}
792
-				}
793
-				else
766
+				} else
794 767
 				{
795 768
 					return array('class' => $xmlrpcclassname, 'code' => $source, 'docstring' => '');
796 769
 				}
@@ -818,8 +791,7 @@  discard block
 block discarded – undo
818 791
 			$innercode = build_client_wrapper_code($client, $client_copy_mode, $prefix);
819 792
 			$innercode .= "\$client->setDebug(\$debug);\n";
820 793
 			$this_ = '';
821
-		}
822
-		else
794
+		} else
823 795
 		{
824 796
 			// client copy mode 2 == no client copy in emitted code
825 797
 			$innercode = '';
@@ -831,8 +803,7 @@  discard block
 block discarded – undo
831 803
 		{
832 804
 			// take care that PHP comment is not terminated unwillingly by method description
833 805
 			$mdesc = "/**\n* ".str_replace('*/', '* /', $mdesc)."\n";
834
-		}
835
-		else
806
+		} else
836 807
 		{
837 808
 			$mdesc = "/**\nFunction $xmlrpcfuncname\n";
838 809
 		}
@@ -849,14 +820,12 @@  discard block
 block discarded – undo
849 820
 			{
850 821
 				// only build directly xmlrpcvals when type is known and scalar
851 822
 				$innercode .= "\$p$i = new {$prefix}val(\$p$i, '$ptype');\n";
852
-			}
853
-			else
823
+			} else
854 824
 			{
855 825
 				if ($encode_php_objects)
856 826
 				{
857 827
 					$innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i, array('encode_php_objs'));\n";
858
-				}
859
-				else
828
+				} else
860 829
 				{
861 830
 					$innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i);\n";
862 831
 				}
@@ -878,21 +847,18 @@  discard block
 block discarded – undo
878 847
 			if (is_string($fault_response) && ((strpos($fault_response, '%faultCode%') !== false) || (strpos($fault_response, '%faultString%') !== false)))
879 848
 			{
880 849
 				$respcode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $fault_response)."')";
881
-			}
882
-			else
850
+			} else
883 851
 			{
884 852
 				$respcode = var_export($fault_response, true);
885 853
 			}
886
-		}
887
-		else
854
+		} else
888 855
 		{
889 856
 			$respcode = '$res';
890 857
 		}
891 858
 		if ($decode_php_objects)
892 859
 		{
893 860
 			$innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value(), array('decode_php_objs'));";
894
-		}
895
-		else
861
+		} else
896 862
 		{
897 863
 			$innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value());";
898 864
 		}
Please login to merge, or discard this patch.
lib/xmlrpcs.inc 1 patch
Braces   +58 added lines, -89 removed lines patch added patch discarded remove patch
@@ -106,16 +106,14 @@  discard block
 block discarded – undo
106 106
 		{
107 107
 			$methName=$m->getParam(0);
108 108
 			$methName=$methName->scalarval();
109
-		}
110
-		else
109
+		} else
111 110
 		{
112 111
 			$methName=$m;
113 112
 		}
114 113
 		if(strpos($methName, "system.") === 0)
115 114
 		{
116 115
 			$dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1;
117
-		}
118
-		else
116
+		} else
119 117
 		{
120 118
 			$dmap=$server->dmap; $sysCall=0;
121 119
 		}
@@ -134,15 +132,13 @@  discard block
 block discarded – undo
134 132
 					$sigs[]=new xmlrpcval($cursig, 'array');
135 133
 				}
136 134
 				$r=new xmlrpcresp(new xmlrpcval($sigs, 'array'));
137
-			}
138
-			else
135
+			} else
139 136
 			{
140 137
 				// NB: according to the official docs, we should be returning a
141 138
 				// "none-array" here, which means not-an-array
142 139
 				$r=new xmlrpcresp(new xmlrpcval('undef', 'string'));
143 140
 			}
144
-		}
145
-		else
141
+		} else
146 142
 		{
147 143
 			$r=new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']);
148 144
 		}
@@ -159,16 +155,14 @@  discard block
 block discarded – undo
159 155
 		{
160 156
 			$methName=$m->getParam(0);
161 157
 			$methName=$methName->scalarval();
162
-		}
163
-		else
158
+		} else
164 159
 		{
165 160
 			$methName=$m;
166 161
 		}
167 162
 		if(strpos($methName, "system.") === 0)
168 163
 		{
169 164
 			$dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1;
170
-		}
171
-		else
165
+		} else
172 166
 		{
173 167
 			$dmap=$server->dmap; $sysCall=0;
174 168
 		}
@@ -177,13 +171,11 @@  discard block
 block discarded – undo
177 171
 			if(isset($dmap[$methName]['docstring']))
178 172
 			{
179 173
 				$r=new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string');
180
-			}
181
-			else
174
+			} else
182 175
 			{
183 176
 				$r=new xmlrpcresp(new xmlrpcval('', 'string'));
184 177
 			}
185
-		}
186
-		else
178
+		} else
187 179
 		{
188 180
 			$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']);
189 181
 		}
@@ -295,8 +287,9 @@  discard block
 block discarded – undo
295 287
 		// base64 or datetime values, but they will be listed as strings here...
296 288
 		$numParams = count($call['params']);
297 289
 		$pt = array();
298
-		foreach($call['params'] as $val)
299
-			$pt[] = php_2_xmlrpc_type(gettype($val));
290
+		foreach($call['params'] as $val) {
291
+					$pt[] = php_2_xmlrpc_type(gettype($val));
292
+		}
300 293
 
301 294
 		$result = $server->execute($call['methodName'], $call['params'], $pt);
302 295
 
@@ -321,8 +314,7 @@  discard block
 block discarded – undo
321 314
 				$call = $calls->arraymem($i);
322 315
 				$result[$i] = _xmlrpcs_multicall_do_call($server, $call);
323 316
 			}
324
-		}
325
-		else
317
+		} else
326 318
 		{
327 319
 			$numCalls=count($m);
328 320
 			for($i = 0; $i < $numCalls; $i++)
@@ -377,8 +369,9 @@  discard block
 block discarded – undo
377 369
 	function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null)
378 370
 	{
379 371
 		// obey the @ protocol
380
-		if (error_reporting() == 0)
381
-			return;
372
+		if (error_reporting() == 0) {
373
+					return;
374
+		}
382 375
 
383 376
 		//if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING)
384 377
 		if($errcode != E_STRICT)
@@ -395,8 +388,7 @@  discard block
 block discarded – undo
395 388
 			{
396 389
 				error_log($errstring);
397 390
 			}
398
-		}
399
-		else
391
+		} else
400 392
 		{
401 393
 			// Pass control on to previous error handler, trying to avoid loops...
402 394
 			if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler')
@@ -406,8 +398,7 @@  discard block
 block discarded – undo
406 398
 				{
407 399
 					// the following works both with static class methods and plain object methods as error handler
408 400
 					call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context));
409
-				}
410
-				else
401
+				} else
411 402
 				{
412 403
 					$GLOBALS['_xmlrpcs_prev_ehandler']($errcode, $errstring, $filename, $lineno, $context);
413 404
 				}
@@ -663,8 +654,7 @@  discard block
 block discarded – undo
663 654
 						$payload = gzencode($payload);
664 655
 						header("Content-Encoding: gzip");
665 656
 						header("Vary: Accept-Encoding");
666
-					}
667
-					elseif (strpos($resp_encoding, 'deflate') !== false)
657
+					} elseif (strpos($resp_encoding, 'deflate') !== false)
668 658
 					{
669 659
 						$payload = gzcompress($payload);
670 660
 						header("Content-Encoding: deflate");
@@ -678,8 +668,7 @@  discard block
 block discarded – undo
678 668
 				{
679 669
 					header('Content-Length: ' . (int)strlen($payload));
680 670
 				}
681
-			}
682
-			else
671
+			} else
683 672
 			{
684 673
 				error_log('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages');
685 674
 			}
@@ -728,8 +717,7 @@  discard block
 block discarded – undo
728 717
 			if (is_object($in))
729 718
 			{
730 719
 				$numParams = $in->getNumParams();
731
-			}
732
-			else
720
+			} else
733 721
 			{
734 722
 				$numParams = count($in);
735 723
 			}
@@ -746,13 +734,11 @@  discard block
 block discarded – undo
746 734
 							if($p->kindOf() == 'scalar')
747 735
 							{
748 736
 								$pt=$p->scalartyp();
749
-							}
750
-							else
737
+							} else
751 738
 							{
752 739
 								$pt=$p->kindOf();
753 740
 							}
754
-						}
755
-						else
741
+						} else
756 742
 						{
757 743
 							$pt= $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4...
758 744
 						}
@@ -813,8 +799,7 @@  discard block
 block discarded – undo
813 799
 			if(isset($_SERVER['HTTP_CONTENT_ENCODING']))
814 800
 			{
815 801
 				$content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']);
816
-			}
817
-			else
802
+			} else
818 803
 			{
819 804
 				$content_encoding = '';
820 805
 			}
@@ -834,20 +819,18 @@  discard block
 block discarded – undo
834 819
 							{
835 820
 								$this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++");
836 821
 							}
837
-						}
838
-						elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
822
+						} elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
839 823
 						{
840 824
 							$data = $degzdata;
841
-							if($this->debug > 1)
842
-								$this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++");
843
-						}
844
-						else
825
+							if($this->debug > 1) {
826
+															$this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++");
827
+							}
828
+						} else
845 829
 						{
846 830
 							$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_decompress_fail'], $GLOBALS['xmlrpcstr']['server_decompress_fail']);
847 831
 							return $r;
848 832
 						}
849
-					}
850
-					else
833
+					} else
851 834
 					{
852 835
 						//error_log('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
853 836
 						$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_cannot_decompress'], $GLOBALS['xmlrpcstr']['server_cannot_decompress']);
@@ -871,18 +854,19 @@  discard block
 block discarded – undo
871 854
 					$known_charsets = array($GLOBALS['xmlrpc_internalencoding'], 'UTF-8', 'ISO-8859-1', 'US-ASCII');
872 855
 					foreach ($known_charsets as $charset)
873 856
 					{
874
-						foreach ($client_accepted_charsets as $accepted)
875
-							if (strpos($accepted, $charset) === 0)
857
+						foreach ($client_accepted_charsets as $accepted) {
858
+													if (strpos($accepted, $charset) === 0)
876 859
 							{
877
-								$resp_encoding = $charset;
860
+								$resp_encoding = $charset;
861
+						}
878 862
 								break;
879 863
 							}
880
-						if ($resp_encoding)
881
-							break;
864
+						if ($resp_encoding) {
865
+													break;
866
+						}
882 867
 					}
883 868
 				}
884
-			}
885
-			else
869
+			} else
886 870
 			{
887 871
 				$resp_encoding = $this->response_charset_encoding;
888 872
 			}
@@ -890,8 +874,7 @@  discard block
 block discarded – undo
890 874
 			if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
891 875
 			{
892 876
 				$resp_compression = $_SERVER['HTTP_ACCEPT_ENCODING'];
893
-			}
894
-			else
877
+			} else
895 878
 			{
896 879
 				$resp_compression = '';
897 880
 			}
@@ -968,16 +951,16 @@  discard block
 block discarded – undo
968 951
 			if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
969 952
 			{
970 953
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
971
-			}
972
-			else
954
+			} else
973 955
 			{
974 956
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
975 957
 			}
976 958
 
977
-			if ($this->functions_parameters_type != 'xmlrpcvals')
978
-				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
979
-			else
980
-				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
959
+			if ($this->functions_parameters_type != 'xmlrpcvals') {
960
+							xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
961
+			} else {
962
+							xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
963
+			}
981 964
 			xml_set_character_data_handler($parser, 'xmlrpc_cd');
982 965
 			xml_set_default_handler($parser, 'xmlrpc_dh');
983 966
 			if(!xml_parse($parser, $data, 1))
@@ -989,15 +972,13 @@  discard block
 block discarded – undo
989 972
 					xml_error_string(xml_get_error_code($parser)),
990 973
 					xml_get_current_line_number($parser), xml_get_current_column_number($parser)));
991 974
 				xml_parser_free($parser);
992
-			}
993
-			elseif ($GLOBALS['_xh']['isf'])
975
+			} elseif ($GLOBALS['_xh']['isf'])
994 976
 			{
995 977
 				xml_parser_free($parser);
996 978
 				$r=new xmlrpcresp(0,
997 979
 					$GLOBALS['xmlrpcerr']['invalid_request'],
998 980
 					$GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']);
999
-			}
1000
-			else
981
+			} else
1001 982
 			{
1002 983
 				xml_parser_free($parser);
1003 984
 				// small layering violation in favor of speed and memory usage:
@@ -1011,8 +992,7 @@  discard block
 block discarded – undo
1011 992
 						$this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++");
1012 993
 					}
1013 994
 					$r = $this->execute($GLOBALS['_xh']['method'], $GLOBALS['_xh']['params'], $GLOBALS['_xh']['pt']);
1014
-				}
1015
-				else
995
+				} else
1016 996
 				{
1017 997
 					// build an xmlrpcmsg object with data parsed from xml
1018 998
 					$m=new xmlrpcmsg($GLOBALS['_xh']['method']);
@@ -1045,8 +1025,7 @@  discard block
 block discarded – undo
1045 1025
 			if (is_object($m))
1046 1026
 			{
1047 1027
 				$methName = $m->method();
1048
-			}
1049
-			else
1028
+			} else
1050 1029
 			{
1051 1030
 				$methName = $m;
1052 1031
 			}
@@ -1068,8 +1047,7 @@  discard block
 block discarded – undo
1068 1047
 				if (is_object($m))
1069 1048
 				{
1070 1049
 					list($ok, $errstr) = $this->verifySignature($m, $sig);
1071
-				}
1072
-				else
1050
+				} else
1073 1051
 				{
1074 1052
 					list($ok, $errstr) = $this->verifySignature($paramtypes, $sig);
1075 1053
 				}
@@ -1115,8 +1093,7 @@  discard block
 block discarded – undo
1115 1093
 					if($sysCall)
1116 1094
 					{
1117 1095
 						$r = call_user_func($func, $this, $m);
1118
-					}
1119
-					else
1096
+					} else
1120 1097
 					{
1121 1098
 						$r = call_user_func($func, $m);
1122 1099
 					}
@@ -1126,8 +1103,7 @@  discard block
 block discarded – undo
1126 1103
 						if (is_a($r, 'xmlrpcval'))
1127 1104
 						{
1128 1105
 							$r = new xmlrpcresp($r);
1129
-						}
1130
-						else
1106
+						} else
1131 1107
 						{
1132 1108
 							$r = new xmlrpcresp(
1133 1109
 								0,
@@ -1136,16 +1112,14 @@  discard block
 block discarded – undo
1136 1112
 							);
1137 1113
 						}
1138 1114
 					}
1139
-				}
1140
-				else
1115
+				} else
1141 1116
 				{
1142 1117
 					// call a 'plain php' function
1143 1118
 					if($sysCall)
1144 1119
 					{
1145 1120
 						array_unshift($params, $this);
1146 1121
 						$r = call_user_func_array($func, $params);
1147
-					}
1148
-					else
1122
+					} else
1149 1123
 					{
1150 1124
 						// 3rd API convention for method-handling functions: EPI-style
1151 1125
 						if ($this->functions_parameters_type == 'epivals')
@@ -1156,15 +1130,13 @@  discard block
 block discarded – undo
1156 1130
 							if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r))
1157 1131
 							{
1158 1132
 								$r = new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']);
1159
-							}
1160
-							else
1133
+							} else
1161 1134
 							{
1162 1135
 								// functions using EPI api should NOT return resp objects,
1163 1136
 								// so make sure we encode the return type correctly
1164 1137
 								$r = new xmlrpcresp(php_xmlrpc_encode($r, array('extension_api')));
1165 1138
 							}
1166
-						}
1167
-						else
1139
+						} else
1168 1140
 						{
1169 1141
 							$r = call_user_func_array($func, $params);
1170 1142
 						}
@@ -1177,8 +1149,7 @@  discard block
 block discarded – undo
1177 1149
 						$r = new xmlrpcresp(php_xmlrpc_encode($r, $this->phpvals_encoding_options));
1178 1150
 					}
1179 1151
 				}
1180
-			}
1181
-			catch(Exception $e)
1152
+			} catch(Exception $e)
1182 1153
 			{
1183 1154
 				// (barring errors in the lib) an uncatched exception happened
1184 1155
 				// in the called function, we wrap it in a proper error-response
@@ -1201,8 +1172,7 @@  discard block
 block discarded – undo
1201 1172
 				if($GLOBALS['_xmlrpcs_prev_ehandler'])
1202 1173
 				{
1203 1174
 					set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']);
1204
-				}
1205
-				else
1175
+				} else
1206 1176
 				{
1207 1177
 					restore_error_handler();
1208 1178
 				}
@@ -1228,8 +1198,7 @@  discard block
 block discarded – undo
1228 1198
 			if ($charset_encoding != '')
1229 1199
 			{
1230 1200
 				return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?" . ">\n";
1231
-			}
1232
-			else
1201
+			} else
1233 1202
 			{
1234 1203
 				return "<?xml version=\"1.0\"?" . ">\n";
1235 1204
 			}
Please login to merge, or discard this patch.
lib/xmlrpc.inc 1 patch
Braces   +176 added lines, -250 removed lines patch added patch discarded remove patch
@@ -403,14 +403,12 @@  discard block
 block discarded – undo
403 403
 					$GLOBALS['_xh']['isf'] = 2;
404 404
 					$GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element';
405 405
 					return;
406
-				}
407
-				else
406
+				} else
408 407
 				{
409 408
 					$GLOBALS['_xh']['rt'] = strtolower($name);
410 409
 					$GLOBALS['_xh']['rt'] = strtolower($name);
411 410
 				}
412
-			}
413
-			else
411
+			} else
414 412
 			{
415 413
 				// not top level element: see if parent is OK
416 414
 				$parent = end($GLOBALS['_xh']['stack']);
@@ -566,21 +564,20 @@  discard block
 block discarded – undo
566 564
 						$temp = new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']);
567 565
 						// in case we got info about underlying php class, save it
568 566
 						// in the object we're rebuilding
569
-						if (isset($GLOBALS['_xh']['php_class']))
570
-							$temp->_php_class = $GLOBALS['_xh']['php_class'];
567
+						if (isset($GLOBALS['_xh']['php_class'])) {
568
+													$temp->_php_class = $GLOBALS['_xh']['php_class'];
569
+						}
571 570
 						// check if we are inside an array or struct:
572 571
 						// if value just built is inside an array, let's move it into array on the stack
573 572
 						$vscount = count($GLOBALS['_xh']['valuestack']);
574 573
 						if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
575 574
 						{
576 575
 							$GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp;
577
-						}
578
-						else
576
+						} else
579 577
 						{
580 578
 							$GLOBALS['_xh']['value'] = $temp;
581 579
 						}
582
-					}
583
-					else
580
+					} else
584 581
 					{
585 582
 						/// @todo this needs to treat correctly php-serialized objects,
586 583
 						/// since std deserializing is done by php_xmlrpc_decode,
@@ -611,8 +608,7 @@  discard block
 block discarded – undo
611 608
 					if ($name=='STRING')
612 609
 					{
613 610
 						$GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
614
-					}
615
-					elseif ($name=='DATETIME.ISO8601')
611
+					} elseif ($name=='DATETIME.ISO8601')
616 612
 					{
617 613
 						if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac']))
618 614
 						{
@@ -620,13 +616,11 @@  discard block
 block discarded – undo
620 616
 						}
621 617
 						$GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime'];
622 618
 						$GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
623
-					}
624
-					elseif ($name=='BASE64')
619
+					} elseif ($name=='BASE64')
625 620
 					{
626 621
 						/// @todo check for failure of base64 decoding / catch warnings
627 622
 						$GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']);
628
-					}
629
-					elseif ($name=='BOOLEAN')
623
+					} elseif ($name=='BOOLEAN')
630 624
 					{
631 625
 						// special case here: we translate boolean 1 or 0 into PHP
632 626
 						// constants true or false.
@@ -637,16 +631,15 @@  discard block
 block discarded – undo
637 631
 						if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0)
638 632
 						{
639 633
 							$GLOBALS['_xh']['value']=true;
640
-						}
641
-						else
634
+						} else
642 635
 						{
643 636
 							// 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']);
637
+							if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0) {
638
+															error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']);
639
+							}
646 640
 							$GLOBALS['_xh']['value']=false;
647 641
 						}
648
-					}
649
-					elseif ($name=='DOUBLE')
642
+					} elseif ($name=='DOUBLE')
650 643
 					{
651 644
 						// we have a DOUBLE
652 645
 						// we must check that only 0123456789-.<space> are characters here
@@ -656,14 +649,12 @@  discard block
 block discarded – undo
656 649
 							/// @todo: find a better way of throwing an error than this!
657 650
 							error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']);
658 651
 							$GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
659
-						}
660
-						else
652
+						} else
661 653
 						{
662 654
 							// it's ok, add it on
663 655
 							$GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac'];
664 656
 						}
665
-					}
666
-					else
657
+					} else
667 658
 					{
668 659
 						// we have an I4/INT
669 660
 						// we must check that only 0123456789-<space> are characters here
@@ -672,8 +663,7 @@  discard block
 block discarded – undo
672 663
 							/// @todo find a better way of throwing an error than this!
673 664
 							error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']);
674 665
 							$GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
675
-						}
676
-						else
666
+						} else
677 667
 						{
678 668
 							// it's ok, add it on
679 669
 							$GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac'];
@@ -693,8 +683,9 @@  discard block
 block discarded – undo
693 683
 					{
694 684
 						$vscount = count($GLOBALS['_xh']['valuestack']);
695 685
 						$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');
686
+					} else {
687
+											error_log('XML-RPC: missing VALUE inside STRUCT in received xml');
688
+					}
698 689
 					break;
699 690
 				case 'DATA':
700 691
 					//$GLOBALS['_xh']['ac']=''; // is this necessary?
@@ -718,9 +709,9 @@  discard block
 block discarded – undo
718 709
 					{
719 710
 						$GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value'];
720 711
 						$GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt'];
721
-					}
722
-					else
723
-						error_log('XML-RPC: missing VALUE inside PARAM in received xml');
712
+					} else {
713
+											error_log('XML-RPC: missing VALUE inside PARAM in received xml');
714
+					}
724 715
 					break;
725 716
 				case 'METHODNAME':
726 717
 					$GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']);
@@ -916,8 +907,7 @@  discard block
 block discarded – undo
916 907
 			if($path == '' || $path[0] != '/')
917 908
 			{
918 909
 				$this->path='/'.$path;
919
-			}
920
-			else
910
+			} else
921 911
 			{
922 912
 				$this->path=$path;
923 913
 			}
@@ -998,8 +988,7 @@  discard block
 block discarded – undo
998 988
 			if ($is_dir)
999 989
 			{
1000 990
 				$this->cacertdir = $cacert;
1001
-			}
1002
-			else
991
+			} else
1003 992
 			{
1004 993
 				$this->cacert = $cacert;
1005 994
 			}
@@ -1067,13 +1056,14 @@  discard block
 block discarded – undo
1067 1056
 		*/
1068 1057
 		function setAcceptedCompression($compmethod)
1069 1058
 		{
1070
-			if ($compmethod == 'any')
1071
-				$this->accepted_compression = array('gzip', 'deflate');
1072
-			else
1073
-				if ($compmethod == false )
1074
-					$this->accepted_compression = array();
1075
-				else
1076
-					$this->accepted_compression = array($compmethod);
1059
+			if ($compmethod == 'any') {
1060
+							$this->accepted_compression = array('gzip', 'deflate');
1061
+			} else
1062
+				if ($compmethod == false ) {
1063
+									$this->accepted_compression = array();
1064
+				} else {
1065
+									$this->accepted_compression = array($compmethod);
1066
+				}
1077 1067
 		}
1078 1068
 
1079 1069
 		/**
@@ -1110,8 +1100,7 @@  discard block
 block discarded – undo
1110 1100
 				$this->cookies[$name]['domain'] = $domain;
1111 1101
 				$this->cookies[$name]['port'] = $port;
1112 1102
 				$this->cookies[$name]['version'] = 1;
1113
-			}
1114
-			else
1103
+			} else
1115 1104
 			{
1116 1105
 				$this->cookies[$name]['version'] = 0;
1117 1106
 			}
@@ -1158,8 +1147,7 @@  discard block
 block discarded – undo
1158 1147
 				// $msg is an array of xmlrpcmsg's
1159 1148
 				$r = $this->multicall($msg, $timeout, $method);
1160 1149
 				return $r;
1161
-			}
1162
-			elseif(is_string($msg))
1150
+			} elseif(is_string($msg))
1163 1151
 			{
1164 1152
 				$n = new xmlrpcmsg('');
1165 1153
 				$n->payload = $msg;
@@ -1192,8 +1180,7 @@  discard block
 block discarded – undo
1192 1180
 					$this->key,
1193 1181
 					$this->keypass
1194 1182
 				);
1195
-			}
1196
-			elseif($method == 'http11')
1183
+			} elseif($method == 'http11')
1197 1184
 			{
1198 1185
 				$r =& $this->sendPayloadCURL(
1199 1186
 					$msg,
@@ -1215,8 +1202,7 @@  discard block
 block discarded – undo
1215 1202
 					'http',
1216 1203
 					$this->keepalive
1217 1204
 				);
1218
-			}
1219
-			else
1205
+			} else
1220 1206
 			{
1221 1207
 				$r =& $this->sendPayloadHTTP10(
1222 1208
 					$msg,
@@ -1267,8 +1253,7 @@  discard block
 block discarded – undo
1267 1253
 						$payload = $a;
1268 1254
 						$encoding_hdr = "Content-Encoding: gzip\r\n";
1269 1255
 					}
1270
-				}
1271
-				else
1256
+				} else
1272 1257
 				{
1273 1258
 					$a = @gzcompress($payload);
1274 1259
 					if($a)
@@ -1277,8 +1262,7 @@  discard block
 block discarded – undo
1277 1262
 						$encoding_hdr = "Content-Encoding: deflate\r\n";
1278 1263
 					}
1279 1264
 				}
1280
-			}
1281
-			else
1265
+			} else
1282 1266
 			{
1283 1267
 				$encoding_hdr = '';
1284 1268
 			}
@@ -1318,8 +1302,7 @@  discard block
 block discarded – undo
1318 1302
 					}
1319 1303
 					$proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n";
1320 1304
 				}
1321
-			}
1322
-			else
1305
+			} else
1323 1306
 			{
1324 1307
 				$connectserver = $server;
1325 1308
 				$connectport = $port;
@@ -1338,14 +1321,16 @@  discard block
 block discarded – undo
1338 1321
 					{
1339 1322
 						$version = ' $Version="' . $cookie['version'] . '";';
1340 1323
 						$cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";';
1341
-						if ($cookie['path'])
1342
-							$cookieheader .= ' $Path="' . $cookie['path'] . '";';
1343
-						if ($cookie['domain'])
1344
-							$cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
1345
-						if ($cookie['port'])
1346
-							$cookieheader .= ' $Port="' . $cookie['port'] . '";';
1347
-					}
1348
-					else
1324
+						if ($cookie['path']) {
1325
+													$cookieheader .= ' $Path="' . $cookie['path'] . '";';
1326
+						}
1327
+						if ($cookie['domain']) {
1328
+													$cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
1329
+						}
1330
+						if ($cookie['port']) {
1331
+													$cookieheader .= ' $Port="' . $cookie['port'] . '";';
1332
+						}
1333
+					} else
1349 1334
 					{
1350 1335
 						$cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";";
1351 1336
 					}
@@ -1379,8 +1364,7 @@  discard block
 block discarded – undo
1379 1364
 			if($timeout>0)
1380 1365
 			{
1381 1366
 				$fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout);
1382
-			}
1383
-			else
1367
+			} else
1384 1368
 			{
1385 1369
 				$fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr);
1386 1370
 			}
@@ -1390,8 +1374,7 @@  discard block
 block discarded – undo
1390 1374
 				{
1391 1375
 					stream_set_timeout($fp, $timeout);
1392 1376
 				}
1393
-			}
1394
-			else
1377
+			} else
1395 1378
 			{
1396 1379
 				$this->errstr='Connect error: '.$this->errstr;
1397 1380
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')');
@@ -1404,8 +1387,7 @@  discard block
 block discarded – undo
1404 1387
 				$this->errstr='Write error';
1405 1388
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr);
1406 1389
 				return $r;
1407
-			}
1408
-			else
1390
+			} else
1409 1391
 			{
1410 1392
 				// reset errno and errstr on successful socket connection
1411 1393
 				$this->errstr = '';
@@ -1472,8 +1454,7 @@  discard block
 block discarded – undo
1472 1454
 				if($method == 'http')
1473 1455
 				{
1474 1456
 					$port = 80;
1475
-				}
1476
-				else
1457
+				} else
1477 1458
 				{
1478 1459
 					$port = 443;
1479 1460
 				}
@@ -1497,8 +1478,7 @@  discard block
 block discarded – undo
1497 1478
 						$payload = $a;
1498 1479
 						$encoding_hdr = 'Content-Encoding: gzip';
1499 1480
 					}
1500
-				}
1501
-				else
1481
+				} else
1502 1482
 				{
1503 1483
 					$a = @gzcompress($payload);
1504 1484
 					if($a)
@@ -1507,8 +1487,7 @@  discard block
 block discarded – undo
1507 1487
 						$encoding_hdr = 'Content-Encoding: deflate';
1508 1488
 					}
1509 1489
 				}
1510
-			}
1511
-			else
1490
+			} else
1512 1491
 			{
1513 1492
 				$encoding_hdr = '';
1514 1493
 			}
@@ -1527,8 +1506,7 @@  discard block
 block discarded – undo
1527 1506
 				{
1528 1507
 					$this->xmlrpc_curl_handle = $curl;
1529 1508
 				}
1530
-			}
1531
-			else
1509
+			} else
1532 1510
 			{
1533 1511
 				$curl = $this->xmlrpc_curl_handle;
1534 1512
 			}
@@ -1559,9 +1537,9 @@  discard block
 block discarded – undo
1559 1537
 				if (count($this->accepted_compression) == 1)
1560 1538
 				{
1561 1539
 					curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]);
1562
-				}
1563
-				else
1564
-					curl_setopt($curl, CURLOPT_ENCODING, '');
1540
+				} else {
1541
+									curl_setopt($curl, CURLOPT_ENCODING, '');
1542
+				}
1565 1543
 			}
1566 1544
 			// extra headers
1567 1545
 			$headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
@@ -1589,8 +1567,7 @@  discard block
 block discarded – undo
1589 1567
 				if (defined('CURLOPT_HTTPAUTH'))
1590 1568
 				{
1591 1569
 					curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype);
1592
-				}
1593
-				else if ($authtype != 1)
1570
+				} else if ($authtype != 1)
1594 1571
 				{
1595 1572
 					error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
1596 1573
 				}
@@ -1655,8 +1632,7 @@  discard block
 block discarded – undo
1655 1632
 					if (defined('CURLOPT_PROXYAUTH'))
1656 1633
 					{
1657 1634
 						curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype);
1658
-					}
1659
-					else if ($proxyauthtype != 1)
1635
+					} else if ($proxyauthtype != 1)
1660 1636
 					{
1661 1637
 						error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1662 1638
 					}
@@ -1698,17 +1674,18 @@  discard block
 block discarded – undo
1698 1674
 				print "---END---\n</PRE>";
1699 1675
 			}
1700 1676
 
1701
-			if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'?
1677
+			if(!$result) {
1678
+			    /// @todo we should use a better check here - what if we get back '' or '0'?
1702 1679
 			{
1703
-				$this->errstr='no response';
1680
+				$this->errstr='no response';
1681
+			}
1704 1682
 				$resp=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl));
1705 1683
 				curl_close($curl);
1706 1684
 				if($keepalive)
1707 1685
 				{
1708 1686
 					$this->xmlrpc_curl_handle = null;
1709 1687
 				}
1710
-			}
1711
-			else
1688
+			} else
1712 1689
 			{
1713 1690
 				if(!$keepalive)
1714 1691
 				{
@@ -1760,8 +1737,7 @@  discard block
 block discarded – undo
1760 1737
 				{
1761 1738
 					// System.multicall succeeded
1762 1739
 					return $results;
1763
-				}
1764
-				else
1740
+				} else
1765 1741
 				{
1766 1742
 					// either system.multicall is unsupported by server,
1767 1743
 					// or call failed for some other reason.
@@ -1769,21 +1745,18 @@  discard block
 block discarded – undo
1769 1745
 					{
1770 1746
 						// Don't try it next time...
1771 1747
 						$this->no_multicall = true;
1772
-					}
1773
-					else
1748
+					} else
1774 1749
 					{
1775 1750
 						if (is_a($results, 'xmlrpcresp'))
1776 1751
 						{
1777 1752
 							$result = $results;
1778
-						}
1779
-						else
1753
+						} else
1780 1754
 						{
1781 1755
 							$result = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']);
1782 1756
 						}
1783 1757
 					}
1784 1758
 				}
1785
-			}
1786
-			else
1759
+			} else
1787 1760
 			{
1788 1761
 				// override fallback, in case careless user tries to do two
1789 1762
 				// opposite things at the same time
@@ -1799,8 +1772,7 @@  discard block
 block discarded – undo
1799 1772
 				{
1800 1773
 					$results[] =& $this->send($msg, $timeout, $method);
1801 1774
 				}
1802
-			}
1803
-			else
1775
+			} else
1804 1776
 			{
1805 1777
 				// user does NOT want to fallback on many single calls:
1806 1778
 				// since we should always return an array of responses,
@@ -1853,8 +1825,7 @@  discard block
 block discarded – undo
1853 1825
 			if ($this->return_type == 'xml')
1854 1826
 			{
1855 1827
 					return $rets;
1856
-			}
1857
-			else if ($this->return_type == 'phpvals')
1828
+			} else if ($this->return_type == 'phpvals')
1858 1829
 			{
1859 1830
 				///@todo test this code branch...
1860 1831
 				$rets = $result->value();
@@ -1904,8 +1875,7 @@  discard block
 block discarded – undo
1904 1875
 					}
1905 1876
 				}
1906 1877
 				return $response;
1907
-			}
1908
-			else // return type == 'xmlrpcvals'
1878
+			} else // return type == 'xmlrpcvals'
1909 1879
 			{
1910 1880
 				$rets = $result->value();
1911 1881
 				if($rets->kindOf() != 'array')
@@ -1992,8 +1962,7 @@  discard block
 block discarded – undo
1992 1962
 				$this->errno = $fcode;
1993 1963
 				$this->errstr = $fstr;
1994 1964
 				//$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later.
1995
-			}
1996
-			else
1965
+			} else
1997 1966
 			{
1998 1967
 				// successful response
1999 1968
 				$this->val = $val;
@@ -2003,18 +1972,15 @@  discard block
 block discarded – undo
2003 1972
 					if (is_object($this->val) && is_a($this->val, 'xmlrpcval'))
2004 1973
 					{
2005 1974
 						$this->valtyp = 'xmlrpcvals';
2006
-					}
2007
-					else if (is_string($this->val))
1975
+					} else if (is_string($this->val))
2008 1976
 					{
2009 1977
 						$this->valtyp = 'xml';
2010 1978
 
2011
-					}
2012
-					else
1979
+					} else
2013 1980
 					{
2014 1981
 						$this->valtyp = 'phpvals';
2015 1982
 					}
2016
-				}
2017
-				else
1983
+				} else
2018 1984
 				{
2019 1985
 					// user declares type of resp value: believe him
2020 1986
 					$this->valtyp = $valtyp;
@@ -2076,15 +2042,15 @@  discard block
 block discarded – undo
2076 2042
 		*/
2077 2043
 		function serialize($charset_encoding='')
2078 2044
 		{
2079
-			if ($charset_encoding != '')
2080
-				$this->content_type = 'text/xml; charset=' . $charset_encoding;
2081
-			else
2082
-				$this->content_type = 'text/xml';
2045
+			if ($charset_encoding != '') {
2046
+							$this->content_type = 'text/xml; charset=' . $charset_encoding;
2047
+			} else {
2048
+							$this->content_type = 'text/xml';
2049
+			}
2083 2050
 			if ($GLOBALS['xmlrpc_null_apache_encoding'])
2084 2051
 			{
2085 2052
 				$result = "<methodResponse xmlns:ex=\"".$GLOBALS['xmlrpc_null_apache_encoding_ns']."\">\n";
2086
-			}
2087
-			else
2053
+			} else
2088 2054
 			{
2089 2055
 			$result = "<methodResponse>\n";
2090 2056
 			}
@@ -2097,8 +2063,7 @@  discard block
 block discarded – undo
2097 2063
 "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" .
2098 2064
 xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" .
2099 2065
 "</struct>\n</value>\n</fault>";
2100
-			}
2101
-			else
2066
+			} else
2102 2067
 			{
2103 2068
 				if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval'))
2104 2069
 				{
@@ -2107,14 +2072,12 @@  discard block
 block discarded – undo
2107 2072
 						$result .= "<params>\n<param>\n" .
2108 2073
 							$this->val .
2109 2074
 							"</param>\n</params>";
2110
-					}
2111
-					else
2075
+					} else
2112 2076
 					{
2113 2077
 						/// @todo try to build something serializable?
2114 2078
 						die('cannot serialize xmlrpcresp objects whose content is native php values');
2115 2079
 					}
2116
-				}
2117
-				else
2080
+				} else
2118 2081
 				{
2119 2082
 					$result .= "<params>\n<param>\n" .
2120 2083
 						$this->val->serialize($charset_encoding) .
@@ -2167,8 +2130,7 @@  discard block
 block discarded – undo
2167 2130
 			if ($charset_encoding != '')
2168 2131
 			{
2169 2132
 				return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?" . ">\n<methodCall>\n";
2170
-			}
2171
-			else
2133
+			} else
2172 2134
 			{
2173 2135
 				return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
2174 2136
 			}
@@ -2195,10 +2157,11 @@  discard block
 block discarded – undo
2195 2157
 		*/
2196 2158
 		function createPayload($charset_encoding='')
2197 2159
 		{
2198
-			if ($charset_encoding != '')
2199
-				$this->content_type = 'text/xml; charset=' . $charset_encoding;
2200
-			else
2201
-				$this->content_type = 'text/xml';
2160
+			if ($charset_encoding != '') {
2161
+							$this->content_type = 'text/xml; charset=' . $charset_encoding;
2162
+			} else {
2163
+							$this->content_type = 'text/xml';
2164
+			}
2202 2165
 			$this->payload=$this->xml_header($charset_encoding);
2203 2166
 			$this->payload.='<methodName>' . xmlrpc_encode_entitites($this->methodname, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</methodName>\n";
2204 2167
 			$this->payload.="<params>\n";
@@ -2252,8 +2215,7 @@  discard block
 block discarded – undo
2252 2215
 			{
2253 2216
 				$this->params[]=$par;
2254 2217
 				return true;
2255
-			}
2256
-			else
2218
+			} else
2257 2219
 			{
2258 2220
 				return false;
2259 2221
 			}
@@ -2314,15 +2276,13 @@  discard block
 block discarded – undo
2314 2276
 					if($pos || is_int($pos))
2315 2277
 					{
2316 2278
 						$bd = $pos+4;
2317
-					}
2318
-					else
2279
+					} else
2319 2280
 					{
2320 2281
 						$pos = strpos($data,"\n\n");
2321 2282
 						if($pos || is_int($pos))
2322 2283
 						{
2323 2284
 							$bd = $pos+2;
2324
-						}
2325
-						else
2285
+						} else
2326 2286
 						{
2327 2287
 							// No separation between response headers and body: fault?
2328 2288
 							$bd = 0;
@@ -2333,8 +2293,7 @@  discard block
 block discarded – undo
2333 2293
 						// this filters out all http headers from proxy.
2334 2294
 						// maybe we could take them into account, too?
2335 2295
 						$data = substr($data, $bd);
2336
-					}
2337
-					else
2296
+					} else
2338 2297
 					{
2339 2298
 						error_log('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed');
2340 2299
 						$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)');
@@ -2348,9 +2307,11 @@  discard block
 block discarded – undo
2348 2307
 					$pos = strpos($data, 'HTTP', 12);
2349 2308
 					// server sent a Continue header without any (valid) content following...
2350 2309
 					// give the client a chance to know it
2351
-					if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5
2310
+					if(!$pos && !is_int($pos)) {
2311
+					    // works fine in php 3, 4 and 5
2352 2312
 					{
2353
-						break;
2313
+						break;
2314
+					}
2354 2315
 					}
2355 2316
 					$data = substr($data, $pos);
2356 2317
 				}
@@ -2371,15 +2332,13 @@  discard block
 block discarded – undo
2371 2332
 				if($pos || is_int($pos))
2372 2333
 				{
2373 2334
 					$bd = $pos+4;
2374
-				}
2375
-				else
2335
+				} else
2376 2336
 				{
2377 2337
 					$pos = strpos($data,"\n\n");
2378 2338
 					if($pos || is_int($pos))
2379 2339
 					{
2380 2340
 						$bd = $pos+2;
2381
-					}
2382
-					else
2341
+					} else
2383 2342
 					{
2384 2343
 						// No separation between response headers and body: fault?
2385 2344
 						// we could take some action here instead of going on...
@@ -2406,8 +2365,7 @@  discard block
 block discarded – undo
2406 2365
 								// version 2 cookies:
2407 2366
 								// there could be many cookies on one line, comma separated
2408 2367
 								$cookies = explode(',', $arr[1]);
2409
-							}
2410
-							else
2368
+							} else
2411 2369
 							{
2412 2370
 								$cookies = array($arr[1]);
2413 2371
 							}
@@ -2415,10 +2373,11 @@  discard block
 block discarded – undo
2415 2373
 							{
2416 2374
 								// glue together all received cookies, using a comma to separate them
2417 2375
 								// (same as php does with getallheaders())
2418
-								if (isset($GLOBALS['_xh']['headers'][$header_name]))
2419
-									$GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie);
2420
-								else
2421
-									$GLOBALS['_xh']['headers'][$header_name] = trim($cookie);
2376
+								if (isset($GLOBALS['_xh']['headers'][$header_name])) {
2377
+																	$GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie);
2378
+								} else {
2379
+																	$GLOBALS['_xh']['headers'][$header_name] = trim($cookie);
2380
+								}
2422 2381
 								// parse cookie attributes, in case user wants to correctly honour them
2423 2382
 								// feature creep: only allow rfc-compliant cookie attributes?
2424 2383
 								// @todo support for server sending multiple time cookie with same name, but using different PATHs
@@ -2434,8 +2393,7 @@  discard block
 block discarded – undo
2434 2393
 										$cookiename = $tag;
2435 2394
 										$GLOBALS['_xh']['cookies'][$tag] = array();
2436 2395
 										$GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val);
2437
-									}
2438
-									else
2396
+									} else
2439 2397
 									{
2440 2398
 										if ($tag != 'value')
2441 2399
 										{
@@ -2444,13 +2402,11 @@  discard block
 block discarded – undo
2444 2402
 									}
2445 2403
 								}
2446 2404
 							}
2447
-						}
2448
-						else
2405
+						} else
2449 2406
 						{
2450 2407
 							$GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]);
2451 2408
 						}
2452
-					}
2453
-					elseif(isset($header_name))
2409
+					} elseif(isset($header_name))
2454 2410
 					{
2455 2411
 						///	@todo version1 cookies might span multiple lines, thus breaking the parsing above
2456 2412
 						$GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line);
@@ -2501,23 +2457,22 @@  discard block
 block discarded – undo
2501 2457
 								if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data))
2502 2458
 								{
2503 2459
 									$data = $degzdata;
2504
-									if($this->debug)
2505
-									print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2506
-								}
2507
-								elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
2460
+									if($this->debug) {
2461
+																		print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2462
+									}
2463
+								} elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
2508 2464
 								{
2509 2465
 									$data = $degzdata;
2510
-									if($this->debug)
2511
-									print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2512
-								}
2513
-								else
2466
+									if($this->debug) {
2467
+																		print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2468
+									}
2469
+								} else
2514 2470
 								{
2515 2471
 									error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server');
2516 2472
 									$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']);
2517 2473
 									return $r;
2518 2474
 								}
2519
-							}
2520
-							else
2475
+							} else
2521 2476
 							{
2522 2477
 								error_log('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
2523 2478
 								$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']);
@@ -2570,8 +2525,7 @@  discard block
 block discarded – undo
2570 2525
 					$r->raw_data = $data;
2571 2526
 					return $r;
2572 2527
 				}
2573
-			}
2574
-			else
2528
+			} else
2575 2529
 			{
2576 2530
 				$GLOBALS['_xh']['headers'] = array();
2577 2531
 				$GLOBALS['_xh']['cookies'] = array();
@@ -2651,8 +2605,7 @@  discard block
 block discarded – undo
2651 2605
 			if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
2652 2606
 			{
2653 2607
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
2654
-			}
2655
-			else
2608
+			} else
2656 2609
 			{
2657 2610
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
2658 2611
 			}
@@ -2660,8 +2613,7 @@  discard block
 block discarded – undo
2660 2613
 			if ($return_type == 'phpvals')
2661 2614
 			{
2662 2615
 				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
2663
-			}
2664
-			else
2616
+			} else
2665 2617
 			{
2666 2618
 				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
2667 2619
 			}
@@ -2676,8 +2628,7 @@  discard block
 block discarded – undo
2676 2628
 				if((xml_get_current_line_number($parser)) == 1)
2677 2629
 				{
2678 2630
 					$errstr = 'XML error at line 1, check URL';
2679
-				}
2680
-				else
2631
+				} else
2681 2632
 				{
2682 2633
 					$errstr = sprintf('XML error: %s at line %d, column %d',
2683 2634
 						xml_error_string(xml_get_error_code($parser)),
@@ -2716,8 +2667,7 @@  discard block
 block discarded – undo
2716 2667
 				// indicating something odd went on
2717 2668
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'],
2718 2669
 					$GLOBALS['xmlrpcstr']['invalid_return']);
2719
-			}
2720
-			else
2670
+			} else
2721 2671
 			{
2722 2672
 				if ($this->debug)
2723 2673
 				{
@@ -2741,8 +2691,7 @@  discard block
 block discarded – undo
2741 2691
 						$errstr_v = $v->structmem('faultString');
2742 2692
 						$errno = $errno_v->scalarval();
2743 2693
 						$errstr = $errstr_v->scalarval();
2744
-					}
2745
-					else
2694
+					} else
2746 2695
 					{
2747 2696
 						$errno = $v['faultCode'];
2748 2697
 						$errstr = $v['faultString'];
@@ -2755,8 +2704,7 @@  discard block
 block discarded – undo
2755 2704
 					}
2756 2705
 
2757 2706
 					$r = new xmlrpcresp(0, $errno, $errstr);
2758
-				}
2759
-				else
2707
+				} else
2760 2708
 				{
2761 2709
 					$r=new xmlrpcresp($v, 0, '', $return_type);
2762 2710
 				}
@@ -2864,8 +2812,7 @@  discard block
 block discarded – undo
2864 2812
 				if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false')))
2865 2813
 				{
2866 2814
 					$val=true;
2867
-				}
2868
-				else
2815
+				} else
2869 2816
 				{
2870 2817
 					$val=false;
2871 2818
 				}
@@ -2910,14 +2857,12 @@  discard block
 block discarded – undo
2910 2857
 				$this->mytype=$GLOBALS['xmlrpcTypes']['array'];
2911 2858
 				$this->me['array']=$vals;
2912 2859
 				return 1;
2913
-			}
2914
-			elseif($this->mytype==2)
2860
+			} elseif($this->mytype==2)
2915 2861
 			{
2916 2862
 				// we're adding to an array here
2917 2863
 				$this->me['array'] = array_merge($this->me['array'], $vals);
2918 2864
 				return 1;
2919
-			}
2920
-			else
2865
+			} else
2921 2866
 			{
2922 2867
 				error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
2923 2868
 				return 0;
@@ -2939,14 +2884,12 @@  discard block
 block discarded – undo
2939 2884
 				$this->mytype=$GLOBALS['xmlrpcTypes']['struct'];
2940 2885
 				$this->me['struct']=$vals;
2941 2886
 				return 1;
2942
-			}
2943
-			elseif($this->mytype==3)
2887
+			} elseif($this->mytype==3)
2944 2888
 			{
2945 2889
 				// we're adding to a struct here
2946 2890
 				$this->me['struct'] = array_merge($this->me['struct'], $vals);
2947 2891
 				return 1;
2948
-			}
2949
-			else
2892
+			} else
2950 2893
 			{
2951 2894
 				error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
2952 2895
 				return 0;
@@ -3050,8 +2993,7 @@  discard block
 block discarded – undo
3050 2993
 							if ($GLOBALS['xmlrpc_null_apache_encoding'])
3051 2994
 							{
3052 2995
 								$rs.="<ex:nil/>";
3053
-							}
3054
-							else
2996
+							} else
3055 2997
 							{
3056 2998
 								$rs.="<nil/>";
3057 2999
 							}
@@ -3067,8 +3009,7 @@  discard block
 block discarded – undo
3067 3009
 					if ($this->_php_class)
3068 3010
 					{
3069 3011
 						$rs.='<struct php_class="' . $this->_php_class . "\">\n";
3070
-					}
3071
-					else
3012
+					} else
3072 3013
 					{
3073 3014
 						$rs.="<struct>\n";
3074 3015
 					}
@@ -3296,16 +3237,14 @@  discard block
 block discarded – undo
3296 3237
 		if(!$utc)
3297 3238
 		{
3298 3239
 			$t=strftime("%Y%m%dT%H:%M:%S", $timet);
3299
-		}
3300
-		else
3240
+		} else
3301 3241
 		{
3302 3242
 			if(function_exists('gmstrftime'))
3303 3243
 			{
3304 3244
 				// gmstrftime doesn't exist in some versions
3305 3245
 				// of PHP
3306 3246
 				$t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
3307
-			}
3308
-			else
3247
+			} else
3309 3248
 			{
3310 3249
 				$t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z'));
3311 3250
 			}
@@ -3327,8 +3266,7 @@  discard block
 block discarded – undo
3327 3266
 			if($utc)
3328 3267
 			{
3329 3268
 				$t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3330
-			}
3331
-			else
3269
+			} else
3332 3270
 			{
3333 3271
 				$t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3334 3272
 			}
@@ -3396,8 +3334,7 @@  discard block
 block discarded – undo
3396 3334
 						$result = new Datetime();
3397 3335
 						$result->setTimestamp($out);
3398 3336
 						return $result;
3399
-					}
3400
-					elseif (is_a($out, 'Datetime'))
3337
+					} elseif (is_a($out, 'Datetime'))
3401 3338
 					{
3402 3339
 						return $out;
3403 3340
 					}
@@ -3426,8 +3363,7 @@  discard block
 block discarded – undo
3426 3363
 						$obj->$key = php_xmlrpc_decode($value, $options);
3427 3364
 					}
3428 3365
 					return $obj;
3429
-				}
3430
-				else
3366
+				} else
3431 3367
 				{
3432 3368
 					$arr = array();
3433 3369
 					while(list($key,$value)=$xmlrpc_val->structeach())
@@ -3453,8 +3389,7 @@  discard block
 block discarded – undo
3453 3389
 	if(function_exists('xmlrpc_decode'))
3454 3390
 	{
3455 3391
 		define('XMLRPC_EPI_ENABLED','1');
3456
-	}
3457
-	else
3392
+	} else
3458 3393
 	{
3459 3394
 		define('XMLRPC_EPI_ENABLED','0');
3460 3395
 	}
@@ -3482,10 +3417,11 @@  discard block
 block discarded – undo
3482 3417
 		switch($type)
3483 3418
 		{
3484 3419
 			case 'string':
3485
-				if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val))
3486
-					$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3487
-				else
3488
-					$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3420
+				if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) {
3421
+									$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3422
+				} else {
3423
+									$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3424
+				}
3489 3425
 				break;
3490 3426
 			case 'integer':
3491 3427
 				$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']);
@@ -3520,8 +3456,7 @@  discard block
 block discarded – undo
3520 3456
 				if($ko)
3521 3457
 				{
3522 3458
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
3523
-				}
3524
-				else
3459
+				} else
3525 3460
 				{
3526 3461
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcArray']);
3527 3462
 				}
@@ -3530,12 +3465,10 @@  discard block
 block discarded – undo
3530 3465
 				if(is_a($php_val, 'xmlrpcval'))
3531 3466
 				{
3532 3467
 					$xmlrpc_val = $php_val;
3533
-				}
3534
-				else if(is_a($php_val, 'DateTime'))
3468
+				} else if(is_a($php_val, 'DateTime'))
3535 3469
 				{
3536 3470
 					$xmlrpc_val = new xmlrpcval($php_val->format('Ymd\TH:i:s'), $GLOBALS['xmlrpcStruct']);
3537
-				}
3538
-				else
3471
+				} else
3539 3472
 				{
3540 3473
 					$arr = array();
3541 3474
 					reset($php_val);
@@ -3556,12 +3489,10 @@  discard block
 block discarded – undo
3556 3489
 				if (in_array('extension_api', $options))
3557 3490
 				{
3558 3491
 					$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcString']);
3559
-				}
3560
-				else if (in_array('null_extension', $options))
3492
+				} else if (in_array('null_extension', $options))
3561 3493
 				{
3562 3494
 					$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcNull']);
3563
-				}
3564
-				else
3495
+				} else
3565 3496
 				{
3566 3497
 					$xmlrpc_val = new xmlrpcval();
3567 3498
 				}
@@ -3570,8 +3501,7 @@  discard block
 block discarded – undo
3570 3501
 				if (in_array('extension_api', $options))
3571 3502
 				{
3572 3503
 					$xmlrpc_val = new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']);
3573
-				}
3574
-				else
3504
+				} else
3575 3505
 				{
3576 3506
 					$xmlrpc_val = new xmlrpcval();
3577 3507
 				}
@@ -3633,8 +3563,7 @@  discard block
 block discarded – undo
3633 3563
 		if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
3634 3564
 		{
3635 3565
 			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
3636
-		}
3637
-		else
3566
+		} else
3638 3567
 		{
3639 3568
 			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
3640 3569
 		}
@@ -3651,9 +3580,11 @@  discard block
 block discarded – undo
3651 3580
 			return false;
3652 3581
 		}
3653 3582
 		xml_parser_free($parser);
3654
-		if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too???
3583
+		if ($GLOBALS['_xh']['isf'] > 1) {
3584
+		    // test that $GLOBALS['_xh']['value'] is an obj, too???
3655 3585
 		{
3656
-			error_log($GLOBALS['_xh']['isf_reason']);
3586
+			error_log($GLOBALS['_xh']['isf_reason']);
3587
+		}
3657 3588
 			return false;
3658 3589
 		}
3659 3590
 		switch ($GLOBALS['_xh']['rt'])
@@ -3665,8 +3596,7 @@  discard block
 block discarded – undo
3665 3596
 					$vc = $v->structmem('faultCode');
3666 3597
 					$vs = $v->structmem('faultString');
3667 3598
 					$r = new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval());
3668
-				}
3669
-				else
3599
+				} else
3670 3600
 				{
3671 3601
 					$r = new xmlrpcresp($v);
3672 3602
 				}
@@ -3787,12 +3717,10 @@  discard block
 block discarded – undo
3787 3717
 		if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk))
3788 3718
 		{
3789 3719
 			return 'UCS-4';
3790
-		}
3791
-		elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
3720
+		} elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
3792 3721
 		{
3793 3722
 			return 'UTF-16';
3794
-		}
3795
-		elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
3723
+		} elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
3796 3724
 		{
3797 3725
 			return 'UTF-8';
3798 3726
 		}
@@ -3815,8 +3743,7 @@  discard block
 block discarded – undo
3815 3743
 			if($encoding_prefs)
3816 3744
 			{
3817 3745
 				$enc = mb_detect_encoding($xmlchunk, $encoding_prefs);
3818
-			}
3819
-			else
3746
+			} else
3820 3747
 			{
3821 3748
 				$enc = mb_detect_encoding($xmlchunk);
3822 3749
 			}
@@ -3827,8 +3754,7 @@  discard block
 block discarded – undo
3827 3754
 				$enc = 'US-'.$enc;
3828 3755
 			}
3829 3756
 			return $enc;
3830
-		}
3831
-		else
3757
+		} else
3832 3758
 		{
3833 3759
 			// no encoding specified: as per HTTP1.1 assume it is iso-8859-1?
3834 3760
 			// Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types
@@ -3851,12 +3777,10 @@  discard block
 block discarded – undo
3851 3777
 		if (preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlChunk))
3852 3778
 		{
3853 3779
 			return true;
3854
-		}
3855
-		elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlChunk))
3780
+		} elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlChunk))
3856 3781
 		{
3857 3782
 			return true;
3858
-		}
3859
-		elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlChunk))
3783
+		} elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlChunk))
3860 3784
 		{
3861 3785
 			return true;
3862 3786
 		}
@@ -3891,16 +3815,18 @@  discard block
 block discarded – undo
3891 3815
 				'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8',
3892 3816
 				'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN')
3893 3817
 		);
3894
-		if (is_string($validlist))
3895
-			$validlist = explode(',', $validlist);
3896
-		if (@in_array(strtoupper($encoding), $validlist))
3897
-			return true;
3898
-		else
3899
-		{
3900
-			if (array_key_exists($encoding, $charset_supersets))
3901
-				foreach ($validlist as $allowed)
3818
+		if (is_string($validlist)) {
3819
+					$validlist = explode(',', $validlist);
3820
+		}
3821
+		if (@in_array(strtoupper($encoding), $validlist)) {
3822
+					return true;
3823
+		} else
3824
+		{
3825
+			if (array_key_exists($encoding, $charset_supersets)) {
3826
+							foreach ($validlist as $allowed)
3902 3827
 					if (in_array($allowed, $charset_supersets[$encoding]))
3903
-						return true;
3828
+						return true;
3829
+			}
3904 3830
 			return false;
3905 3831
 		}
3906 3832
 	}
Please login to merge, or discard this patch.