Completed
Push — php51 ( 0b9f5a...6e24e2 )
by Gaetano
07:06
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.
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']);
@@ -909,8 +900,7 @@  discard block
 block discarded – undo
909 900
 			if($path == '' || $path[0] != '/')
910 901
 			{
911 902
 				$this->path='/'.$path;
912
-			}
913
-			else
903
+			} else
914 904
 			{
915 905
 				$this->path=$path;
916 906
 			}
@@ -999,8 +989,7 @@  discard block
 block discarded – undo
999 989
 			if ($is_dir)
1000 990
 			{
1001 991
 				$this->cacertdir = $cacert;
1002
-			}
1003
-			else
992
+			} else
1004 993
 			{
1005 994
 				$this->cacert = $cacert;
1006 995
 			}
@@ -1078,13 +1067,14 @@  discard block
 block discarded – undo
1078 1067
 		*/
1079 1068
 		function setAcceptedCompression($compmethod)
1080 1069
 		{
1081
-			if ($compmethod == 'any')
1082
-				$this->accepted_compression = array('gzip', 'deflate');
1083
-			else
1084
-				if ($compmethod == false )
1085
-					$this->accepted_compression = array();
1086
-				else
1087
-					$this->accepted_compression = array($compmethod);
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);
1077
+				}
1088 1078
 		}
1089 1079
 
1090 1080
 		/**
@@ -1121,8 +1111,7 @@  discard block
 block discarded – undo
1121 1111
 				$this->cookies[$name]['domain'] = $domain;
1122 1112
 				$this->cookies[$name]['port'] = $port;
1123 1113
 				$this->cookies[$name]['version'] = 1;
1124
-			}
1125
-			else
1114
+			} else
1126 1115
 			{
1127 1116
 				$this->cookies[$name]['version'] = 0;
1128 1117
 			}
@@ -1169,8 +1158,7 @@  discard block
 block discarded – undo
1169 1158
 				// $msg is an array of xmlrpcmsg's
1170 1159
 				$r = $this->multicall($msg, $timeout, $method);
1171 1160
 				return $r;
1172
-			}
1173
-			elseif(is_string($msg))
1161
+			} elseif(is_string($msg))
1174 1162
 			{
1175 1163
 				$n = new xmlrpcmsg('');
1176 1164
 				$n->payload = $msg;
@@ -1204,8 +1192,7 @@  discard block
 block discarded – undo
1204 1192
 					$this->keypass,
1205 1193
 					$this->sslversion
1206 1194
 				);
1207
-			}
1208
-			elseif($method == 'http11')
1195
+			} elseif($method == 'http11')
1209 1196
 			{
1210 1197
 				$r =& $this->sendPayloadCURL(
1211 1198
 					$msg,
@@ -1227,8 +1214,7 @@  discard block
 block discarded – undo
1227 1214
 					'http',
1228 1215
 					$this->keepalive
1229 1216
 				);
1230
-			}
1231
-			else
1217
+			} else
1232 1218
 			{
1233 1219
 				$r =& $this->sendPayloadHTTP10(
1234 1220
 					$msg,
@@ -1279,8 +1265,7 @@  discard block
 block discarded – undo
1279 1265
 						$payload = $a;
1280 1266
 						$encoding_hdr = "Content-Encoding: gzip\r\n";
1281 1267
 					}
1282
-				}
1283
-				else
1268
+				} else
1284 1269
 				{
1285 1270
 					$a = @gzcompress($payload);
1286 1271
 					if($a)
@@ -1289,8 +1274,7 @@  discard block
 block discarded – undo
1289 1274
 						$encoding_hdr = "Content-Encoding: deflate\r\n";
1290 1275
 					}
1291 1276
 				}
1292
-			}
1293
-			else
1277
+			} else
1294 1278
 			{
1295 1279
 				$encoding_hdr = '';
1296 1280
 			}
@@ -1330,8 +1314,7 @@  discard block
 block discarded – undo
1330 1314
 					}
1331 1315
 					$proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n";
1332 1316
 				}
1333
-			}
1334
-			else
1317
+			} else
1335 1318
 			{
1336 1319
 				$connectserver = $server;
1337 1320
 				$connectport = $port;
@@ -1350,14 +1333,16 @@  discard block
 block discarded – undo
1350 1333
 					{
1351 1334
 						$version = ' $Version="' . $cookie['version'] . '";';
1352 1335
 						$cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";';
1353
-						if ($cookie['path'])
1354
-							$cookieheader .= ' $Path="' . $cookie['path'] . '";';
1355
-						if ($cookie['domain'])
1356
-							$cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
1357
-						if ($cookie['port'])
1358
-							$cookieheader .= ' $Port="' . $cookie['port'] . '";';
1359
-					}
1360
-					else
1336
+						if ($cookie['path']) {
1337
+													$cookieheader .= ' $Path="' . $cookie['path'] . '";';
1338
+						}
1339
+						if ($cookie['domain']) {
1340
+													$cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
1341
+						}
1342
+						if ($cookie['port']) {
1343
+													$cookieheader .= ' $Port="' . $cookie['port'] . '";';
1344
+						}
1345
+					} else
1361 1346
 					{
1362 1347
 						$cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";";
1363 1348
 					}
@@ -1391,8 +1376,7 @@  discard block
 block discarded – undo
1391 1376
 			if($timeout>0)
1392 1377
 			{
1393 1378
 				$fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout);
1394
-			}
1395
-			else
1379
+			} else
1396 1380
 			{
1397 1381
 				$fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr);
1398 1382
 			}
@@ -1402,8 +1386,7 @@  discard block
 block discarded – undo
1402 1386
 				{
1403 1387
 					stream_set_timeout($fp, $timeout);
1404 1388
 				}
1405
-			}
1406
-			else
1389
+			} else
1407 1390
 			{
1408 1391
 				$this->errstr='Connect error: '.$this->errstr;
1409 1392
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')');
@@ -1416,8 +1399,7 @@  discard block
 block discarded – undo
1416 1399
 				$this->errstr='Write error';
1417 1400
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr);
1418 1401
 				return $r;
1419
-			}
1420
-			else
1402
+			} else
1421 1403
 			{
1422 1404
 				// reset errno and errstr on successful socket connection
1423 1405
 				$this->errstr = '';
@@ -1484,8 +1466,7 @@  discard block
 block discarded – undo
1484 1466
 				if($method == 'http')
1485 1467
 				{
1486 1468
 					$port = 80;
1487
-				}
1488
-				else
1469
+				} else
1489 1470
 				{
1490 1471
 					$port = 443;
1491 1472
 				}
@@ -1509,8 +1490,7 @@  discard block
 block discarded – undo
1509 1490
 						$payload = $a;
1510 1491
 						$encoding_hdr = 'Content-Encoding: gzip';
1511 1492
 					}
1512
-				}
1513
-				else
1493
+				} else
1514 1494
 				{
1515 1495
 					$a = @gzcompress($payload);
1516 1496
 					if($a)
@@ -1519,8 +1499,7 @@  discard block
 block discarded – undo
1519 1499
 						$encoding_hdr = 'Content-Encoding: deflate';
1520 1500
 					}
1521 1501
 				}
1522
-			}
1523
-			else
1502
+			} else
1524 1503
 			{
1525 1504
 				$encoding_hdr = '';
1526 1505
 			}
@@ -1539,8 +1518,7 @@  discard block
 block discarded – undo
1539 1518
 				{
1540 1519
 					$this->xmlrpc_curl_handle = $curl;
1541 1520
 				}
1542
-			}
1543
-			else
1521
+			} else
1544 1522
 			{
1545 1523
 				$curl = $this->xmlrpc_curl_handle;
1546 1524
 			}
@@ -1571,9 +1549,9 @@  discard block
 block discarded – undo
1571 1549
 				if (count($this->accepted_compression) == 1)
1572 1550
 				{
1573 1551
 					curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]);
1574
-				}
1575
-				else
1576
-					curl_setopt($curl, CURLOPT_ENCODING, '');
1552
+				} else {
1553
+									curl_setopt($curl, CURLOPT_ENCODING, '');
1554
+				}
1577 1555
 			}
1578 1556
 			// extra headers
1579 1557
 			$headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
@@ -1601,8 +1579,7 @@  discard block
 block discarded – undo
1601 1579
 				if (defined('CURLOPT_HTTPAUTH'))
1602 1580
 				{
1603 1581
 					curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype);
1604
-				}
1605
-				else if ($authtype != 1)
1582
+				} else if ($authtype != 1)
1606 1583
 				{
1607 1584
 					error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
1608 1585
 				}
@@ -1669,8 +1646,7 @@  discard block
 block discarded – undo
1669 1646
 					if (defined('CURLOPT_PROXYAUTH'))
1670 1647
 					{
1671 1648
 						curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype);
1672
-					}
1673
-					else if ($proxyauthtype != 1)
1649
+					} else if ($proxyauthtype != 1)
1674 1650
 					{
1675 1651
 						error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1676 1652
 					}
@@ -1712,17 +1688,18 @@  discard block
 block discarded – undo
1712 1688
 				print "---END---\n</PRE>";
1713 1689
 			}
1714 1690
 
1715
-			if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'?
1691
+			if(!$result) {
1692
+			    /// @todo we should use a better check here - what if we get back '' or '0'?
1716 1693
 			{
1717
-				$this->errstr='no response';
1694
+				$this->errstr='no response';
1695
+			}
1718 1696
 				$resp=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl));
1719 1697
 				curl_close($curl);
1720 1698
 				if($keepalive)
1721 1699
 				{
1722 1700
 					$this->xmlrpc_curl_handle = null;
1723 1701
 				}
1724
-			}
1725
-			else
1702
+			} else
1726 1703
 			{
1727 1704
 				if(!$keepalive)
1728 1705
 				{
@@ -1774,8 +1751,7 @@  discard block
 block discarded – undo
1774 1751
 				{
1775 1752
 					// System.multicall succeeded
1776 1753
 					return $results;
1777
-				}
1778
-				else
1754
+				} else
1779 1755
 				{
1780 1756
 					// either system.multicall is unsupported by server,
1781 1757
 					// or call failed for some other reason.
@@ -1783,21 +1759,18 @@  discard block
 block discarded – undo
1783 1759
 					{
1784 1760
 						// Don't try it next time...
1785 1761
 						$this->no_multicall = true;
1786
-					}
1787
-					else
1762
+					} else
1788 1763
 					{
1789 1764
 						if (is_a($results, 'xmlrpcresp'))
1790 1765
 						{
1791 1766
 							$result = $results;
1792
-						}
1793
-						else
1767
+						} else
1794 1768
 						{
1795 1769
 							$result = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']);
1796 1770
 						}
1797 1771
 					}
1798 1772
 				}
1799
-			}
1800
-			else
1773
+			} else
1801 1774
 			{
1802 1775
 				// override fallback, in case careless user tries to do two
1803 1776
 				// opposite things at the same time
@@ -1813,8 +1786,7 @@  discard block
 block discarded – undo
1813 1786
 				{
1814 1787
 					$results[] =& $this->send($msg, $timeout, $method);
1815 1788
 				}
1816
-			}
1817
-			else
1789
+			} else
1818 1790
 			{
1819 1791
 				// user does NOT want to fallback on many single calls:
1820 1792
 				// since we should always return an array of responses,
@@ -1867,8 +1839,7 @@  discard block
 block discarded – undo
1867 1839
 			if ($this->return_type == 'xml')
1868 1840
 			{
1869 1841
 					return $rets;
1870
-			}
1871
-			else if ($this->return_type == 'phpvals')
1842
+			} else if ($this->return_type == 'phpvals')
1872 1843
 			{
1873 1844
 				///@todo test this code branch...
1874 1845
 				$rets = $result->value();
@@ -1918,8 +1889,7 @@  discard block
 block discarded – undo
1918 1889
 					}
1919 1890
 				}
1920 1891
 				return $response;
1921
-			}
1922
-			else // return type == 'xmlrpcvals'
1892
+			} else // return type == 'xmlrpcvals'
1923 1893
 			{
1924 1894
 				$rets = $result->value();
1925 1895
 				if($rets->kindOf() != 'array')
@@ -1998,8 +1968,7 @@  discard block
 block discarded – undo
1998 1968
 				$this->errno = $fcode;
1999 1969
 				$this->errstr = $fstr;
2000 1970
 				//$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later.
2001
-			}
2002
-			else
1971
+			} else
2003 1972
 			{
2004 1973
 				// successful response
2005 1974
 				$this->val = $val;
@@ -2009,18 +1978,15 @@  discard block
 block discarded – undo
2009 1978
 					if (is_object($this->val) && is_a($this->val, 'xmlrpcval'))
2010 1979
 					{
2011 1980
 						$this->valtyp = 'xmlrpcvals';
2012
-					}
2013
-					else if (is_string($this->val))
1981
+					} else if (is_string($this->val))
2014 1982
 					{
2015 1983
 						$this->valtyp = 'xml';
2016 1984
 
2017
-					}
2018
-					else
1985
+					} else
2019 1986
 					{
2020 1987
 						$this->valtyp = 'phpvals';
2021 1988
 					}
2022
-				}
2023
-				else
1989
+				} else
2024 1990
 				{
2025 1991
 					// user declares type of resp value: believe him
2026 1992
 					$this->valtyp = $valtyp;
@@ -2090,15 +2056,15 @@  discard block
 block discarded – undo
2090 2056
 		*/
2091 2057
 		function serialize($charset_encoding='')
2092 2058
 		{
2093
-			if ($charset_encoding != '')
2094
-				$this->content_type = 'text/xml; charset=' . $charset_encoding;
2095
-			else
2096
-				$this->content_type = 'text/xml';
2059
+			if ($charset_encoding != '') {
2060
+							$this->content_type = 'text/xml; charset=' . $charset_encoding;
2061
+			} else {
2062
+							$this->content_type = 'text/xml';
2063
+			}
2097 2064
 			if ($GLOBALS['xmlrpc_null_apache_encoding'])
2098 2065
 			{
2099 2066
 				$result = "<methodResponse xmlns:ex=\"".$GLOBALS['xmlrpc_null_apache_encoding_ns']."\">\n";
2100
-			}
2101
-			else
2067
+			} else
2102 2068
 			{
2103 2069
 			$result = "<methodResponse>\n";
2104 2070
 			}
@@ -2111,8 +2077,7 @@  discard block
 block discarded – undo
2111 2077
 "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" .
2112 2078
 xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" .
2113 2079
 "</struct>\n</value>\n</fault>";
2114
-			}
2115
-			else
2080
+			} else
2116 2081
 			{
2117 2082
 				if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval'))
2118 2083
 				{
@@ -2121,14 +2086,12 @@  discard block
 block discarded – undo
2121 2086
 						$result .= "<params>\n<param>\n" .
2122 2087
 							$this->val .
2123 2088
 							"</param>\n</params>";
2124
-					}
2125
-					else
2089
+					} else
2126 2090
 					{
2127 2091
 						/// @todo try to build something serializable?
2128 2092
 						die('cannot serialize xmlrpcresp objects whose content is native php values');
2129 2093
 					}
2130
-				}
2131
-				else
2094
+				} else
2132 2095
 				{
2133 2096
 					$result .= "<params>\n<param>\n" .
2134 2097
 						$this->val->serialize($charset_encoding) .
@@ -2181,8 +2144,7 @@  discard block
 block discarded – undo
2181 2144
 			if ($charset_encoding != '')
2182 2145
 			{
2183 2146
 				return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?" . ">\n<methodCall>\n";
2184
-			}
2185
-			else
2147
+			} else
2186 2148
 			{
2187 2149
 				return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
2188 2150
 			}
@@ -2209,10 +2171,11 @@  discard block
 block discarded – undo
2209 2171
 		*/
2210 2172
 		function createPayload($charset_encoding='')
2211 2173
 		{
2212
-			if ($charset_encoding != '')
2213
-				$this->content_type = 'text/xml; charset=' . $charset_encoding;
2214
-			else
2215
-				$this->content_type = 'text/xml';
2174
+			if ($charset_encoding != '') {
2175
+							$this->content_type = 'text/xml; charset=' . $charset_encoding;
2176
+			} else {
2177
+							$this->content_type = 'text/xml';
2178
+			}
2216 2179
 			$this->payload=$this->xml_header($charset_encoding);
2217 2180
 			$this->payload.='<methodName>' . xmlrpc_encode_entitites($this->methodname, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</methodName>\n";
2218 2181
 			$this->payload.="<params>\n";
@@ -2266,8 +2229,7 @@  discard block
 block discarded – undo
2266 2229
 			{
2267 2230
 				$this->params[]=$par;
2268 2231
 				return true;
2269
-			}
2270
-			else
2232
+			} else
2271 2233
 			{
2272 2234
 				return false;
2273 2235
 			}
@@ -2328,15 +2290,13 @@  discard block
 block discarded – undo
2328 2290
 					if($pos || is_int($pos))
2329 2291
 					{
2330 2292
 						$bd = $pos+4;
2331
-					}
2332
-					else
2293
+					} else
2333 2294
 					{
2334 2295
 						$pos = strpos($data,"\n\n");
2335 2296
 						if($pos || is_int($pos))
2336 2297
 						{
2337 2298
 							$bd = $pos+2;
2338
-						}
2339
-						else
2299
+						} else
2340 2300
 						{
2341 2301
 							// No separation between response headers and body: fault?
2342 2302
 							$bd = 0;
@@ -2347,8 +2307,7 @@  discard block
 block discarded – undo
2347 2307
 						// this filters out all http headers from proxy.
2348 2308
 						// maybe we could take them into account, too?
2349 2309
 						$data = substr($data, $bd);
2350
-					}
2351
-					else
2310
+					} else
2352 2311
 					{
2353 2312
 						error_log('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed');
2354 2313
 						$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)');
@@ -2362,9 +2321,11 @@  discard block
 block discarded – undo
2362 2321
 					$pos = strpos($data, 'HTTP', 12);
2363 2322
 					// server sent a Continue header without any (valid) content following...
2364 2323
 					// give the client a chance to know it
2365
-					if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5
2324
+					if(!$pos && !is_int($pos)) {
2325
+					    // works fine in php 3, 4 and 5
2366 2326
 					{
2367
-						break;
2327
+						break;
2328
+					}
2368 2329
 					}
2369 2330
 					$data = substr($data, $pos);
2370 2331
 				}
@@ -2385,15 +2346,13 @@  discard block
 block discarded – undo
2385 2346
 				if($pos || is_int($pos))
2386 2347
 				{
2387 2348
 					$bd = $pos+4;
2388
-				}
2389
-				else
2349
+				} else
2390 2350
 				{
2391 2351
 					$pos = strpos($data,"\n\n");
2392 2352
 					if($pos || is_int($pos))
2393 2353
 					{
2394 2354
 						$bd = $pos+2;
2395
-					}
2396
-					else
2355
+					} else
2397 2356
 					{
2398 2357
 						// No separation between response headers and body: fault?
2399 2358
 						// we could take some action here instead of going on...
@@ -2420,8 +2379,7 @@  discard block
 block discarded – undo
2420 2379
 								// version 2 cookies:
2421 2380
 								// there could be many cookies on one line, comma separated
2422 2381
 								$cookies = explode(',', $arr[1]);
2423
-							}
2424
-							else
2382
+							} else
2425 2383
 							{
2426 2384
 								$cookies = array($arr[1]);
2427 2385
 							}
@@ -2429,10 +2387,11 @@  discard block
 block discarded – undo
2429 2387
 							{
2430 2388
 								// glue together all received cookies, using a comma to separate them
2431 2389
 								// (same as php does with getallheaders())
2432
-								if (isset($GLOBALS['_xh']['headers'][$header_name]))
2433
-									$GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie);
2434
-								else
2435
-									$GLOBALS['_xh']['headers'][$header_name] = trim($cookie);
2390
+								if (isset($GLOBALS['_xh']['headers'][$header_name])) {
2391
+																	$GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie);
2392
+								} else {
2393
+																	$GLOBALS['_xh']['headers'][$header_name] = trim($cookie);
2394
+								}
2436 2395
 								// parse cookie attributes, in case user wants to correctly honour them
2437 2396
 								// feature creep: only allow rfc-compliant cookie attributes?
2438 2397
 								// @todo support for server sending multiple time cookie with same name, but using different PATHs
@@ -2448,8 +2407,7 @@  discard block
 block discarded – undo
2448 2407
 										$cookiename = $tag;
2449 2408
 										$GLOBALS['_xh']['cookies'][$tag] = array();
2450 2409
 										$GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val);
2451
-									}
2452
-									else
2410
+									} else
2453 2411
 									{
2454 2412
 										if ($tag != 'value')
2455 2413
 										{
@@ -2458,13 +2416,11 @@  discard block
 block discarded – undo
2458 2416
 									}
2459 2417
 								}
2460 2418
 							}
2461
-						}
2462
-						else
2419
+						} else
2463 2420
 						{
2464 2421
 							$GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]);
2465 2422
 						}
2466
-					}
2467
-					elseif(isset($header_name))
2423
+					} elseif(isset($header_name))
2468 2424
 					{
2469 2425
 						///	@todo version1 cookies might span multiple lines, thus breaking the parsing above
2470 2426
 						$GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line);
@@ -2515,23 +2471,22 @@  discard block
 block discarded – undo
2515 2471
 								if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data))
2516 2472
 								{
2517 2473
 									$data = $degzdata;
2518
-									if($this->debug)
2519
-									print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2520
-								}
2521
-								elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
2474
+									if($this->debug) {
2475
+																		print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2476
+									}
2477
+								} elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
2522 2478
 								{
2523 2479
 									$data = $degzdata;
2524
-									if($this->debug)
2525
-									print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2526
-								}
2527
-								else
2480
+									if($this->debug) {
2481
+																		print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2482
+									}
2483
+								} else
2528 2484
 								{
2529 2485
 									error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server');
2530 2486
 									$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']);
2531 2487
 									return $r;
2532 2488
 								}
2533
-							}
2534
-							else
2489
+							} else
2535 2490
 							{
2536 2491
 								error_log('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
2537 2492
 								$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']);
@@ -2584,8 +2539,7 @@  discard block
 block discarded – undo
2584 2539
 					$r->raw_data = $data;
2585 2540
 					return $r;
2586 2541
 				}
2587
-			}
2588
-			else
2542
+			} else
2589 2543
 			{
2590 2544
 				$GLOBALS['_xh']['headers'] = array();
2591 2545
 				$GLOBALS['_xh']['cookies'] = array();
@@ -2665,8 +2619,7 @@  discard block
 block discarded – undo
2665 2619
 			if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
2666 2620
 			{
2667 2621
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
2668
-			}
2669
-			else
2622
+			} else
2670 2623
 			{
2671 2624
 				xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
2672 2625
 			}
@@ -2674,8 +2627,7 @@  discard block
 block discarded – undo
2674 2627
 			if ($return_type == 'phpvals')
2675 2628
 			{
2676 2629
 				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
2677
-			}
2678
-			else
2630
+			} else
2679 2631
 			{
2680 2632
 				xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
2681 2633
 			}
@@ -2690,8 +2642,7 @@  discard block
 block discarded – undo
2690 2642
 				if((xml_get_current_line_number($parser)) == 1)
2691 2643
 				{
2692 2644
 					$errstr = 'XML error at line 1, check URL';
2693
-				}
2694
-				else
2645
+				} else
2695 2646
 				{
2696 2647
 					$errstr = sprintf('XML error: %s at line %d, column %d',
2697 2648
 						xml_error_string(xml_get_error_code($parser)),
@@ -2730,8 +2681,7 @@  discard block
 block discarded – undo
2730 2681
 				// indicating something odd went on
2731 2682
 				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'],
2732 2683
 					$GLOBALS['xmlrpcstr']['invalid_return']);
2733
-			}
2734
-			else
2684
+			} else
2735 2685
 			{
2736 2686
 				if ($this->debug)
2737 2687
 				{
@@ -2755,8 +2705,7 @@  discard block
 block discarded – undo
2755 2705
 						$errstr_v = $v->structmem('faultString');
2756 2706
 						$errno = $errno_v->scalarval();
2757 2707
 						$errstr = $errstr_v->scalarval();
2758
-					}
2759
-					else
2708
+					} else
2760 2709
 					{
2761 2710
 						$errno = $v['faultCode'];
2762 2711
 						$errstr = $v['faultString'];
@@ -2769,8 +2718,7 @@  discard block
 block discarded – undo
2769 2718
 					}
2770 2719
 
2771 2720
 					$r = new xmlrpcresp(0, $errno, $errstr);
2772
-				}
2773
-				else
2721
+				} else
2774 2722
 				{
2775 2723
 					$r=new xmlrpcresp($v, 0, '', $return_type);
2776 2724
 				}
@@ -2878,8 +2826,7 @@  discard block
 block discarded – undo
2878 2826
 				if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false')))
2879 2827
 				{
2880 2828
 					$val=true;
2881
-				}
2882
-				else
2829
+				} else
2883 2830
 				{
2884 2831
 					$val=false;
2885 2832
 				}
@@ -2924,14 +2871,12 @@  discard block
 block discarded – undo
2924 2871
 				$this->mytype=$GLOBALS['xmlrpcTypes']['array'];
2925 2872
 				$this->me['array']=$vals;
2926 2873
 				return 1;
2927
-			}
2928
-			elseif($this->mytype==2)
2874
+			} elseif($this->mytype==2)
2929 2875
 			{
2930 2876
 				// we're adding to an array here
2931 2877
 				$this->me['array'] = array_merge($this->me['array'], $vals);
2932 2878
 				return 1;
2933
-			}
2934
-			else
2879
+			} else
2935 2880
 			{
2936 2881
 				error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
2937 2882
 				return 0;
@@ -2953,14 +2898,12 @@  discard block
 block discarded – undo
2953 2898
 				$this->mytype=$GLOBALS['xmlrpcTypes']['struct'];
2954 2899
 				$this->me['struct']=$vals;
2955 2900
 				return 1;
2956
-			}
2957
-			elseif($this->mytype==3)
2901
+			} elseif($this->mytype==3)
2958 2902
 			{
2959 2903
 				// we're adding to a struct here
2960 2904
 				$this->me['struct'] = array_merge($this->me['struct'], $vals);
2961 2905
 				return 1;
2962
-			}
2963
-			else
2906
+			} else
2964 2907
 			{
2965 2908
 				error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
2966 2909
 				return 0;
@@ -3064,8 +3007,7 @@  discard block
 block discarded – undo
3064 3007
 							if ($GLOBALS['xmlrpc_null_apache_encoding'])
3065 3008
 							{
3066 3009
 								$rs.="<ex:nil/>";
3067
-							}
3068
-							else
3010
+							} else
3069 3011
 							{
3070 3012
 								$rs.="<nil/>";
3071 3013
 							}
@@ -3081,8 +3023,7 @@  discard block
 block discarded – undo
3081 3023
 					if ($this->_php_class)
3082 3024
 					{
3083 3025
 						$rs.='<struct php_class="' . $this->_php_class . "\">\n";
3084
-					}
3085
-					else
3026
+					} else
3086 3027
 					{
3087 3028
 						$rs.="<struct>\n";
3088 3029
 					}
@@ -3310,16 +3251,14 @@  discard block
 block discarded – undo
3310 3251
 		if(!$utc)
3311 3252
 		{
3312 3253
 			$t=strftime("%Y%m%dT%H:%M:%S", $timet);
3313
-		}
3314
-		else
3254
+		} else
3315 3255
 		{
3316 3256
 			if(function_exists('gmstrftime'))
3317 3257
 			{
3318 3258
 				// gmstrftime doesn't exist in some versions
3319 3259
 				// of PHP
3320 3260
 				$t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
3321
-			}
3322
-			else
3261
+			} else
3323 3262
 			{
3324 3263
 				$t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z'));
3325 3264
 			}
@@ -3341,8 +3280,7 @@  discard block
 block discarded – undo
3341 3280
 			if($utc)
3342 3281
 			{
3343 3282
 				$t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3344
-			}
3345
-			else
3283
+			} else
3346 3284
 			{
3347 3285
 				$t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3348 3286
 			}
@@ -3410,8 +3348,7 @@  discard block
 block discarded – undo
3410 3348
 						$result = new Datetime();
3411 3349
 						$result->setTimestamp($out);
3412 3350
 						return $result;
3413
-					}
3414
-					elseif (is_a($out, 'Datetime'))
3351
+					} elseif (is_a($out, 'Datetime'))
3415 3352
 					{
3416 3353
 						return $out;
3417 3354
 					}
@@ -3440,8 +3377,7 @@  discard block
 block discarded – undo
3440 3377
 						$obj->$key = php_xmlrpc_decode($value, $options);
3441 3378
 					}
3442 3379
 					return $obj;
3443
-				}
3444
-				else
3380
+				} else
3445 3381
 				{
3446 3382
 					$arr = array();
3447 3383
 					while(list($key,$value)=$xmlrpc_val->structeach())
@@ -3467,8 +3403,7 @@  discard block
 block discarded – undo
3467 3403
 	if(function_exists('xmlrpc_decode'))
3468 3404
 	{
3469 3405
 		define('XMLRPC_EPI_ENABLED','1');
3470
-	}
3471
-	else
3406
+	} else
3472 3407
 	{
3473 3408
 		define('XMLRPC_EPI_ENABLED','0');
3474 3409
 	}
@@ -3496,10 +3431,11 @@  discard block
 block discarded – undo
3496 3431
 		switch($type)
3497 3432
 		{
3498 3433
 			case 'string':
3499
-				if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val))
3500
-					$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3501
-				else
3502
-					$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3434
+				if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) {
3435
+									$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3436
+				} else {
3437
+									$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3438
+				}
3503 3439
 				break;
3504 3440
 			case 'integer':
3505 3441
 				$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']);
@@ -3534,8 +3470,7 @@  discard block
 block discarded – undo
3534 3470
 				if($ko)
3535 3471
 				{
3536 3472
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
3537
-				}
3538
-				else
3473
+				} else
3539 3474
 				{
3540 3475
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcArray']);
3541 3476
 				}
@@ -3544,12 +3479,10 @@  discard block
 block discarded – undo
3544 3479
 				if(is_a($php_val, 'xmlrpcval'))
3545 3480
 				{
3546 3481
 					$xmlrpc_val = $php_val;
3547
-				}
3548
-				else if(is_a($php_val, 'DateTime'))
3482
+				} else if(is_a($php_val, 'DateTime'))
3549 3483
 				{
3550 3484
 					$xmlrpc_val = new xmlrpcval($php_val->format('Ymd\TH:i:s'), $GLOBALS['xmlrpcStruct']);
3551
-				}
3552
-				else
3485
+				} else
3553 3486
 				{
3554 3487
 					$arr = array();
3555 3488
 					reset($php_val);
@@ -3570,12 +3503,10 @@  discard block
 block discarded – undo
3570 3503
 				if (in_array('extension_api', $options))
3571 3504
 				{
3572 3505
 					$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcString']);
3573
-				}
3574
-				else if (in_array('null_extension', $options))
3506
+				} else if (in_array('null_extension', $options))
3575 3507
 				{
3576 3508
 					$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcNull']);
3577
-				}
3578
-				else
3509
+				} else
3579 3510
 				{
3580 3511
 					$xmlrpc_val = new xmlrpcval();
3581 3512
 				}
@@ -3584,8 +3515,7 @@  discard block
 block discarded – undo
3584 3515
 				if (in_array('extension_api', $options))
3585 3516
 				{
3586 3517
 					$xmlrpc_val = new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']);
3587
-				}
3588
-				else
3518
+				} else
3589 3519
 				{
3590 3520
 					$xmlrpc_val = new xmlrpcval();
3591 3521
 				}
@@ -3647,8 +3577,7 @@  discard block
 block discarded – undo
3647 3577
 		if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
3648 3578
 		{
3649 3579
 			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
3650
-		}
3651
-		else
3580
+		} else
3652 3581
 		{
3653 3582
 			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
3654 3583
 		}
@@ -3665,9 +3594,11 @@  discard block
 block discarded – undo
3665 3594
 			return false;
3666 3595
 		}
3667 3596
 		xml_parser_free($parser);
3668
-		if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too???
3597
+		if ($GLOBALS['_xh']['isf'] > 1) {
3598
+		    // test that $GLOBALS['_xh']['value'] is an obj, too???
3669 3599
 		{
3670
-			error_log($GLOBALS['_xh']['isf_reason']);
3600
+			error_log($GLOBALS['_xh']['isf_reason']);
3601
+		}
3671 3602
 			return false;
3672 3603
 		}
3673 3604
 		switch ($GLOBALS['_xh']['rt'])
@@ -3679,8 +3610,7 @@  discard block
 block discarded – undo
3679 3610
 					$vc = $v->structmem('faultCode');
3680 3611
 					$vs = $v->structmem('faultString');
3681 3612
 					$r = new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval());
3682
-				}
3683
-				else
3613
+				} else
3684 3614
 				{
3685 3615
 					$r = new xmlrpcresp($v);
3686 3616
 				}
@@ -3801,12 +3731,10 @@  discard block
 block discarded – undo
3801 3731
 		if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk))
3802 3732
 		{
3803 3733
 			return 'UCS-4';
3804
-		}
3805
-		elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
3734
+		} elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
3806 3735
 		{
3807 3736
 			return 'UTF-16';
3808
-		}
3809
-		elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
3737
+		} elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
3810 3738
 		{
3811 3739
 			return 'UTF-8';
3812 3740
 		}
@@ -3829,8 +3757,7 @@  discard block
 block discarded – undo
3829 3757
 			if($encoding_prefs)
3830 3758
 			{
3831 3759
 				$enc = mb_detect_encoding($xmlchunk, $encoding_prefs);
3832
-			}
3833
-			else
3760
+			} else
3834 3761
 			{
3835 3762
 				$enc = mb_detect_encoding($xmlchunk);
3836 3763
 			}
@@ -3841,8 +3768,7 @@  discard block
 block discarded – undo
3841 3768
 				$enc = 'US-'.$enc;
3842 3769
 			}
3843 3770
 			return $enc;
3844
-		}
3845
-		else
3771
+		} else
3846 3772
 		{
3847 3773
 			// no encoding specified: as per HTTP1.1 assume it is iso-8859-1?
3848 3774
 			// Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types
@@ -3865,12 +3791,10 @@  discard block
 block discarded – undo
3865 3791
 		if (preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlChunk))
3866 3792
 		{
3867 3793
 			return true;
3868
-		}
3869
-		elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlChunk))
3794
+		} elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlChunk))
3870 3795
 		{
3871 3796
 			return true;
3872
-		}
3873
-		elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlChunk))
3797
+		} elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlChunk))
3874 3798
 		{
3875 3799
 			return true;
3876 3800
 		}
@@ -3905,16 +3829,18 @@  discard block
 block discarded – undo
3905 3829
 				'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8',
3906 3830
 				'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN')
3907 3831
 		);
3908
-		if (is_string($validlist))
3909
-			$validlist = explode(',', $validlist);
3910
-		if (@in_array(strtoupper($encoding), $validlist))
3911
-			return true;
3912
-		else
3913
-		{
3914
-			if (array_key_exists($encoding, $charset_supersets))
3915
-				foreach ($validlist as $allowed)
3832
+		if (is_string($validlist)) {
3833
+					$validlist = explode(',', $validlist);
3834
+		}
3835
+		if (@in_array(strtoupper($encoding), $validlist)) {
3836
+					return true;
3837
+		} else
3838
+		{
3839
+			if (array_key_exists($encoding, $charset_supersets)) {
3840
+							foreach ($validlist as $allowed)
3916 3841
 					if (in_array($allowed, $charset_supersets[$encoding]))
3917
-						return true;
3842
+						return true;
3843
+			}
3918 3844
 			return false;
3919 3845
 		}
3920 3846
 	}
Please login to merge, or discard this patch.
doc/convert.php 1 patch
Braces   +18 added lines, -15 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,16 +31,15 @@  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
     if(is_callable(array($proc, 'setSecurityPreferences')))
37 40
     {
38 41
         $proc->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
39
-    }
40
-    else
42
+    } else
41 43
     {
42 44
         $proc->setSecurityPrefs(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
43 45
     }
@@ -48,18 +50,19 @@  discard block
 block discarded – undo
48 50
 //{
49 51
     if (is_dir($_SERVER['argv'][3]))
50 52
     {
51
-        if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3])))
52
-            echo "setting param base.dir KO\n";
53
-    }
54
-    else
53
+        if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3]))) {
54
+                    echo "setting param base.dir KO\n";
55
+        }
56
+    } else
55 57
     {
56 58
         //echo "{$_SERVER['argv'][3]} is not a dir\n";
57 59
     }
58 60
 //}
59 61
 
60 62
 $out = $proc->transformToXML($xml);
61
-if (!is_dir($_SERVER['argv'][3]))
63
+if (!is_dir($_SERVER['argv'][3])) {
62 64
     file_put_contents($_SERVER['argv'][3], $out);
65
+}
63 66
 
64 67
 echo "OK\n";
65 68
 ?>
66 69
\ No newline at end of file
Please login to merge, or discard this patch.