Completed
Push — php51 ( 7c6ae5...63ffec )
by Gaetano
06:17
created
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
 					}
@@ -3305,16 +3246,14 @@  discard block
 block discarded – undo
3305 3246
 		if(!$utc)
3306 3247
 		{
3307 3248
 			$t=strftime("%Y%m%dT%H:%M:%S", $timet);
3308
-		}
3309
-		else
3249
+		} else
3310 3250
 		{
3311 3251
 			if(function_exists('gmstrftime'))
3312 3252
 			{
3313 3253
 				// gmstrftime doesn't exist in some versions
3314 3254
 				// of PHP
3315 3255
 				$t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
3316
-			}
3317
-			else
3256
+			} else
3318 3257
 			{
3319 3258
 				$t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z'));
3320 3259
 			}
@@ -3336,8 +3275,7 @@  discard block
 block discarded – undo
3336 3275
 			if($utc)
3337 3276
 			{
3338 3277
 				$t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3339
-			}
3340
-			else
3278
+			} else
3341 3279
 			{
3342 3280
 				$t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3343 3281
 			}
@@ -3405,8 +3343,7 @@  discard block
 block discarded – undo
3405 3343
 						$result = new Datetime();
3406 3344
 						$result->setTimestamp($out);
3407 3345
 						return $result;
3408
-					}
3409
-					elseif (is_a($out, 'Datetime'))
3346
+					} elseif (is_a($out, 'Datetime'))
3410 3347
 					{
3411 3348
 						return $out;
3412 3349
 					}
@@ -3435,8 +3372,7 @@  discard block
 block discarded – undo
3435 3372
 						$obj->$key = php_xmlrpc_decode($value, $options);
3436 3373
 					}
3437 3374
 					return $obj;
3438
-				}
3439
-				else
3375
+				} else
3440 3376
 				{
3441 3377
 					$arr = array();
3442 3378
 					while(list($key,$value)=$xmlrpc_val->structeach())
@@ -3462,8 +3398,7 @@  discard block
 block discarded – undo
3462 3398
 	if(function_exists('xmlrpc_decode'))
3463 3399
 	{
3464 3400
 		define('XMLRPC_EPI_ENABLED','1');
3465
-	}
3466
-	else
3401
+	} else
3467 3402
 	{
3468 3403
 		define('XMLRPC_EPI_ENABLED','0');
3469 3404
 	}
@@ -3491,10 +3426,11 @@  discard block
 block discarded – undo
3491 3426
 		switch($type)
3492 3427
 		{
3493 3428
 			case 'string':
3494
-				if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val))
3495
-					$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3496
-				else
3497
-					$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3429
+				if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) {
3430
+									$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3431
+				} else {
3432
+									$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3433
+				}
3498 3434
 				break;
3499 3435
 			case 'integer':
3500 3436
 				$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']);
@@ -3529,8 +3465,7 @@  discard block
 block discarded – undo
3529 3465
 				if($ko)
3530 3466
 				{
3531 3467
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
3532
-				}
3533
-				else
3468
+				} else
3534 3469
 				{
3535 3470
 					$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcArray']);
3536 3471
 				}
@@ -3539,12 +3474,10 @@  discard block
 block discarded – undo
3539 3474
 				if(is_a($php_val, 'xmlrpcval'))
3540 3475
 				{
3541 3476
 					$xmlrpc_val = $php_val;
3542
-				}
3543
-				else if(is_a($php_val, 'DateTime'))
3477
+				} else if(is_a($php_val, 'DateTime'))
3544 3478
 				{
3545 3479
 					$xmlrpc_val = new xmlrpcval($php_val->format('Ymd\TH:i:s'), $GLOBALS['xmlrpcStruct']);
3546
-				}
3547
-				else
3480
+				} else
3548 3481
 				{
3549 3482
 					$arr = array();
3550 3483
                     foreach($php_val as $k => $v)
@@ -3564,12 +3497,10 @@  discard block
 block discarded – undo
3564 3497
 				if (in_array('extension_api', $options))
3565 3498
 				{
3566 3499
 					$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcString']);
3567
-				}
3568
-				else if (in_array('null_extension', $options))
3500
+				} else if (in_array('null_extension', $options))
3569 3501
 				{
3570 3502
 					$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcNull']);
3571
-				}
3572
-				else
3503
+				} else
3573 3504
 				{
3574 3505
 					$xmlrpc_val = new xmlrpcval();
3575 3506
 				}
@@ -3578,8 +3509,7 @@  discard block
 block discarded – undo
3578 3509
 				if (in_array('extension_api', $options))
3579 3510
 				{
3580 3511
 					$xmlrpc_val = new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']);
3581
-				}
3582
-				else
3512
+				} else
3583 3513
 				{
3584 3514
 					$xmlrpc_val = new xmlrpcval();
3585 3515
 				}
@@ -3641,8 +3571,7 @@  discard block
 block discarded – undo
3641 3571
 		if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
3642 3572
 		{
3643 3573
 			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
3644
-		}
3645
-		else
3574
+		} else
3646 3575
 		{
3647 3576
 			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
3648 3577
 		}
@@ -3659,9 +3588,11 @@  discard block
 block discarded – undo
3659 3588
 			return false;
3660 3589
 		}
3661 3590
 		xml_parser_free($parser);
3662
-		if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too???
3591
+		if ($GLOBALS['_xh']['isf'] > 1) {
3592
+		    // test that $GLOBALS['_xh']['value'] is an obj, too???
3663 3593
 		{
3664
-			error_log($GLOBALS['_xh']['isf_reason']);
3594
+			error_log($GLOBALS['_xh']['isf_reason']);
3595
+		}
3665 3596
 			return false;
3666 3597
 		}
3667 3598
 		switch ($GLOBALS['_xh']['rt'])
@@ -3673,8 +3604,7 @@  discard block
 block discarded – undo
3673 3604
 					$vc = $v->structmem('faultCode');
3674 3605
 					$vs = $v->structmem('faultString');
3675 3606
 					$r = new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval());
3676
-				}
3677
-				else
3607
+				} else
3678 3608
 				{
3679 3609
 					$r = new xmlrpcresp($v);
3680 3610
 				}
@@ -3795,12 +3725,10 @@  discard block
 block discarded – undo
3795 3725
 		if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk))
3796 3726
 		{
3797 3727
 			return 'UCS-4';
3798
-		}
3799
-		elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
3728
+		} elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
3800 3729
 		{
3801 3730
 			return 'UTF-16';
3802
-		}
3803
-		elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
3731
+		} elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
3804 3732
 		{
3805 3733
 			return 'UTF-8';
3806 3734
 		}
@@ -3823,8 +3751,7 @@  discard block
 block discarded – undo
3823 3751
 			if($encoding_prefs)
3824 3752
 			{
3825 3753
 				$enc = mb_detect_encoding($xmlchunk, $encoding_prefs);
3826
-			}
3827
-			else
3754
+			} else
3828 3755
 			{
3829 3756
 				$enc = mb_detect_encoding($xmlchunk);
3830 3757
 			}
@@ -3835,8 +3762,7 @@  discard block
 block discarded – undo
3835 3762
 				$enc = 'US-'.$enc;
3836 3763
 			}
3837 3764
 			return $enc;
3838
-		}
3839
-		else
3765
+		} else
3840 3766
 		{
3841 3767
 			// no encoding specified: as per HTTP1.1 assume it is iso-8859-1?
3842 3768
 			// Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types
@@ -3859,12 +3785,10 @@  discard block
 block discarded – undo
3859 3785
 		if (preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlChunk))
3860 3786
 		{
3861 3787
 			return true;
3862
-		}
3863
-		elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlChunk))
3788
+		} elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlChunk))
3864 3789
 		{
3865 3790
 			return true;
3866
-		}
3867
-		elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlChunk))
3791
+		} elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlChunk))
3868 3792
 		{
3869 3793
 			return true;
3870 3794
 		}
@@ -3899,16 +3823,18 @@  discard block
 block discarded – undo
3899 3823
 				'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8',
3900 3824
 				'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN')
3901 3825
 		);
3902
-		if (is_string($validlist))
3903
-			$validlist = explode(',', $validlist);
3904
-		if (@in_array(strtoupper($encoding), $validlist))
3905
-			return true;
3906
-		else
3907
-		{
3908
-			if (array_key_exists($encoding, $charset_supersets))
3909
-				foreach ($validlist as $allowed)
3826
+		if (is_string($validlist)) {
3827
+					$validlist = explode(',', $validlist);
3828
+		}
3829
+		if (@in_array(strtoupper($encoding), $validlist)) {
3830
+					return true;
3831
+		} else
3832
+		{
3833
+			if (array_key_exists($encoding, $charset_supersets)) {
3834
+							foreach ($validlist as $allowed)
3910 3835
 					if (in_array($allowed, $charset_supersets[$encoding]))
3911
-						return true;
3836
+						return true;
3837
+			}
3912 3838
 			return false;
3913 3839
 		}
3914 3840
 	}
Please login to merge, or discard this patch.