@@ -24,9 +24,6 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @param xmlrpc_client client object, properly set up to connect to server |
| 26 | 26 | * @param string remote function name |
| 27 | - * @param mixed $parameter1 |
|
| 28 | - * @param mixed $parameter2 |
|
| 29 | - * @param mixed $parameter3 ... |
|
| 30 | 27 | * @return xmlrpcresp or false on error |
| 31 | 28 | */ |
| 32 | 29 | function xmlrpccall_simple() |
@@ -35,8 +35,7 @@ |
||
| 35 | 35 | { |
| 36 | 36 | // Incorrect |
| 37 | 37 | return false; |
| 38 | - } |
|
| 39 | - else |
|
| 38 | + } else |
|
| 40 | 39 | { |
| 41 | 40 | $varargs = func_get_args(); |
| 42 | 41 | $client = array_shift($varargs); |
@@ -1239,6 +1239,7 @@ discard block |
||
| 1239 | 1239 | |
| 1240 | 1240 | /** |
| 1241 | 1241 | * @access private |
| 1242 | + * @param integer $port |
|
| 1242 | 1243 | */ |
| 1243 | 1244 | function &sendPayloadHTTP10($msg, $server, $port, $timeout=0, |
| 1244 | 1245 | $username='', $password='', $authtype=1, $proxyhost='', |
@@ -1427,6 +1428,7 @@ discard block |
||
| 1427 | 1428 | |
| 1428 | 1429 | /** |
| 1429 | 1430 | * @access private |
| 1431 | + * @param integer $port |
|
| 1430 | 1432 | */ |
| 1431 | 1433 | function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='', |
| 1432 | 1434 | $password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='', |
@@ -1818,6 +1820,8 @@ discard block |
||
| 1818 | 1820 | * Returns either an array of xmlrpcreponses, an xmlrpc error response |
| 1819 | 1821 | * or false (when received response does not respect valid multicall syntax) |
| 1820 | 1822 | * @access private |
| 1823 | + * @param integer $timeout |
|
| 1824 | + * @param string $method |
|
| 1821 | 1825 | */ |
| 1822 | 1826 | function _try_multicall($msgs, $timeout, $method) |
| 1823 | 1827 | {
|
@@ -2044,7 +2048,7 @@ discard block |
||
| 2044 | 2048 | |
| 2045 | 2049 | /** |
| 2046 | 2050 | * Returns the value received by the server. |
| 2047 | - * @return mixed the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects |
|
| 2051 | + * @return integer the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects |
|
| 2048 | 2052 | * @access public |
| 2049 | 2053 | */ |
| 2050 | 2054 | function value() |
@@ -2145,7 +2149,7 @@ discard block |
||
| 2145 | 2149 | |
| 2146 | 2150 | /** |
| 2147 | 2151 | * @param string $meth the name of the method to invoke |
| 2148 | - * @param array $pars array of parameters to be passed to the method (xmlrpcval objects) |
|
| 2152 | + * @param integer $pars array of parameters to be passed to the method (xmlrpcval objects) |
|
| 2149 | 2153 | */ |
| 2150 | 2154 | function __construct($meth, $pars=0) |
| 2151 | 2155 | {
|
@@ -2302,6 +2306,7 @@ discard block |
||
| 2302 | 2306 | /** |
| 2303 | 2307 | * Parses HTTP headers and separates them from data. |
| 2304 | 2308 | * @access private |
| 2309 | + * @param string $data |
|
| 2305 | 2310 | */ |
| 2306 | 2311 | function &parseResponseHeaders(&$data, $headers_processed=false) |
| 2307 | 2312 | {
|
@@ -2784,7 +2789,7 @@ discard block |
||
| 2784 | 2789 | } |
| 2785 | 2790 | |
| 2786 | 2791 | /** |
| 2787 | - * @param mixed $val |
|
| 2792 | + * @param integer $val |
|
| 2788 | 2793 | * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed |
| 2789 | 2794 | */ |
| 2790 | 2795 | function __construct($val=-1, $type='') |
@@ -2843,7 +2848,7 @@ discard block |
||
| 2843 | 2848 | |
| 2844 | 2849 | /** |
| 2845 | 2850 | * Add a single php value to an (unitialized) xmlrpcval |
| 2846 | - * @param mixed $val |
|
| 2851 | + * @param boolean $val |
|
| 2847 | 2852 | * @param string $type |
| 2848 | 2853 | * @return int 1 or 0 on failure |
| 2849 | 2854 | */ |
@@ -403,14 +403,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 718 | 709 | {
|
| 719 | 710 | $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value']; |
| 720 | 711 | $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt']; |
| 721 | - } |
|
| 722 | - else |
|
| 723 | - error_log('XML-RPC: missing VALUE inside PARAM in received xml');
|
|
| 712 | + } else { |
|
| 713 | + error_log('XML-RPC: missing VALUE inside PARAM in received xml'); |
|
| 714 | + } |
|
| 724 | 715 | break; |
| 725 | 716 | case 'METHODNAME': |
| 726 | 717 | $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']);
|
@@ -916,8 +907,7 @@ discard block |
||
| 916 | 907 | if($path == '' || $path[0] != '/') |
| 917 | 908 | {
|
| 918 | 909 | $this->path='/'.$path; |
| 919 | - } |
|
| 920 | - else |
|
| 910 | + } else |
|
| 921 | 911 | {
|
| 922 | 912 | $this->path=$path; |
| 923 | 913 | } |
@@ -998,8 +988,7 @@ discard block |
||
| 998 | 988 | if ($is_dir) |
| 999 | 989 | {
|
| 1000 | 990 | $this->cacertdir = $cacert; |
| 1001 | - } |
|
| 1002 | - else |
|
| 991 | + } else |
|
| 1003 | 992 | {
|
| 1004 | 993 | $this->cacert = $cacert; |
| 1005 | 994 | } |
@@ -1067,13 +1056,14 @@ discard block |
||
| 1067 | 1056 | */ |
| 1068 | 1057 | function setAcceptedCompression($compmethod) |
| 1069 | 1058 | {
|
| 1070 | - if ($compmethod == 'any') |
|
| 1071 | - $this->accepted_compression = array('gzip', 'deflate');
|
|
| 1072 | - else |
|
| 1073 | - if ($compmethod == false ) |
|
| 1074 | - $this->accepted_compression = array(); |
|
| 1075 | - else |
|
| 1076 | - $this->accepted_compression = array($compmethod); |
|
| 1059 | + if ($compmethod == 'any') { |
|
| 1060 | + $this->accepted_compression = array('gzip', 'deflate'); |
|
| 1061 | + } else |
|
| 1062 | + if ($compmethod == false ) { |
|
| 1063 | + $this->accepted_compression = array(); |
|
| 1064 | + } else { |
|
| 1065 | + $this->accepted_compression = array($compmethod); |
|
| 1066 | + } |
|
| 1077 | 1067 | } |
| 1078 | 1068 | |
| 1079 | 1069 | /** |
@@ -1110,8 +1100,7 @@ discard block |
||
| 1110 | 1100 | $this->cookies[$name]['domain'] = $domain; |
| 1111 | 1101 | $this->cookies[$name]['port'] = $port; |
| 1112 | 1102 | $this->cookies[$name]['version'] = 1; |
| 1113 | - } |
|
| 1114 | - else |
|
| 1103 | + } else |
|
| 1115 | 1104 | {
|
| 1116 | 1105 | $this->cookies[$name]['version'] = 0; |
| 1117 | 1106 | } |
@@ -1158,8 +1147,7 @@ discard block |
||
| 1158 | 1147 | // $msg is an array of xmlrpcmsg's |
| 1159 | 1148 | $r = $this->multicall($msg, $timeout, $method); |
| 1160 | 1149 | return $r; |
| 1161 | - } |
|
| 1162 | - elseif(is_string($msg)) |
|
| 1150 | + } elseif(is_string($msg)) |
|
| 1163 | 1151 | {
|
| 1164 | 1152 | $n = new xmlrpcmsg('');
|
| 1165 | 1153 | $n->payload = $msg; |
@@ -1192,8 +1180,7 @@ discard block |
||
| 1192 | 1180 | $this->key, |
| 1193 | 1181 | $this->keypass |
| 1194 | 1182 | ); |
| 1195 | - } |
|
| 1196 | - elseif($method == 'http11') |
|
| 1183 | + } elseif($method == 'http11') |
|
| 1197 | 1184 | {
|
| 1198 | 1185 | $r =& $this->sendPayloadCURL( |
| 1199 | 1186 | $msg, |
@@ -1215,8 +1202,7 @@ discard block |
||
| 1215 | 1202 | 'http', |
| 1216 | 1203 | $this->keepalive |
| 1217 | 1204 | ); |
| 1218 | - } |
|
| 1219 | - else |
|
| 1205 | + } else |
|
| 1220 | 1206 | {
|
| 1221 | 1207 | $r =& $this->sendPayloadHTTP10( |
| 1222 | 1208 | $msg, |
@@ -1267,8 +1253,7 @@ discard block |
||
| 1267 | 1253 | $payload = $a; |
| 1268 | 1254 | $encoding_hdr = "Content-Encoding: gzip\r\n"; |
| 1269 | 1255 | } |
| 1270 | - } |
|
| 1271 | - else |
|
| 1256 | + } else |
|
| 1272 | 1257 | {
|
| 1273 | 1258 | $a = @gzcompress($payload); |
| 1274 | 1259 | if($a) |
@@ -1277,8 +1262,7 @@ discard block |
||
| 1277 | 1262 | $encoding_hdr = "Content-Encoding: deflate\r\n"; |
| 1278 | 1263 | } |
| 1279 | 1264 | } |
| 1280 | - } |
|
| 1281 | - else |
|
| 1265 | + } else |
|
| 1282 | 1266 | {
|
| 1283 | 1267 | $encoding_hdr = ''; |
| 1284 | 1268 | } |
@@ -1318,8 +1302,7 @@ discard block |
||
| 1318 | 1302 | } |
| 1319 | 1303 | $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n"; |
| 1320 | 1304 | } |
| 1321 | - } |
|
| 1322 | - else |
|
| 1305 | + } else |
|
| 1323 | 1306 | {
|
| 1324 | 1307 | $connectserver = $server; |
| 1325 | 1308 | $connectport = $port; |
@@ -1338,14 +1321,16 @@ discard block |
||
| 1338 | 1321 | {
|
| 1339 | 1322 | $version = ' $Version="' . $cookie['version'] . '";'; |
| 1340 | 1323 | $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";'; |
| 1341 | - if ($cookie['path']) |
|
| 1342 | - $cookieheader .= ' $Path="' . $cookie['path'] . '";'; |
|
| 1343 | - if ($cookie['domain']) |
|
| 1344 | - $cookieheader .= ' $Domain="' . $cookie['domain'] . '";'; |
|
| 1345 | - if ($cookie['port']) |
|
| 1346 | - $cookieheader .= ' $Port="' . $cookie['port'] . '";'; |
|
| 1347 | - } |
|
| 1348 | - else |
|
| 1324 | + if ($cookie['path']) { |
|
| 1325 | + $cookieheader .= ' $Path="' . $cookie['path'] . '";'; |
|
| 1326 | + } |
|
| 1327 | + if ($cookie['domain']) { |
|
| 1328 | + $cookieheader .= ' $Domain="' . $cookie['domain'] . '";'; |
|
| 1329 | + } |
|
| 1330 | + if ($cookie['port']) { |
|
| 1331 | + $cookieheader .= ' $Port="' . $cookie['port'] . '";'; |
|
| 1332 | + } |
|
| 1333 | + } else |
|
| 1349 | 1334 | {
|
| 1350 | 1335 | $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";"; |
| 1351 | 1336 | } |
@@ -1379,8 +1364,7 @@ discard block |
||
| 1379 | 1364 | if($timeout>0) |
| 1380 | 1365 | {
|
| 1381 | 1366 | $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout); |
| 1382 | - } |
|
| 1383 | - else |
|
| 1367 | + } else |
|
| 1384 | 1368 | {
|
| 1385 | 1369 | $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr); |
| 1386 | 1370 | } |
@@ -1390,8 +1374,7 @@ discard block |
||
| 1390 | 1374 | {
|
| 1391 | 1375 | stream_set_timeout($fp, $timeout); |
| 1392 | 1376 | } |
| 1393 | - } |
|
| 1394 | - else |
|
| 1377 | + } else |
|
| 1395 | 1378 | {
|
| 1396 | 1379 | $this->errstr='Connect error: '.$this->errstr; |
| 1397 | 1380 | $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')');
|
@@ -1404,8 +1387,7 @@ discard block |
||
| 1404 | 1387 | $this->errstr='Write error'; |
| 1405 | 1388 | $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr); |
| 1406 | 1389 | return $r; |
| 1407 | - } |
|
| 1408 | - else |
|
| 1390 | + } else |
|
| 1409 | 1391 | {
|
| 1410 | 1392 | // reset errno and errstr on successful socket connection |
| 1411 | 1393 | $this->errstr = ''; |
@@ -1472,8 +1454,7 @@ discard block |
||
| 1472 | 1454 | if($method == 'http') |
| 1473 | 1455 | {
|
| 1474 | 1456 | $port = 80; |
| 1475 | - } |
|
| 1476 | - else |
|
| 1457 | + } else |
|
| 1477 | 1458 | {
|
| 1478 | 1459 | $port = 443; |
| 1479 | 1460 | } |
@@ -1497,8 +1478,7 @@ discard block |
||
| 1497 | 1478 | $payload = $a; |
| 1498 | 1479 | $encoding_hdr = 'Content-Encoding: gzip'; |
| 1499 | 1480 | } |
| 1500 | - } |
|
| 1501 | - else |
|
| 1481 | + } else |
|
| 1502 | 1482 | {
|
| 1503 | 1483 | $a = @gzcompress($payload); |
| 1504 | 1484 | if($a) |
@@ -1507,8 +1487,7 @@ discard block |
||
| 1507 | 1487 | $encoding_hdr = 'Content-Encoding: deflate'; |
| 1508 | 1488 | } |
| 1509 | 1489 | } |
| 1510 | - } |
|
| 1511 | - else |
|
| 1490 | + } else |
|
| 1512 | 1491 | {
|
| 1513 | 1492 | $encoding_hdr = ''; |
| 1514 | 1493 | } |
@@ -1527,8 +1506,7 @@ discard block |
||
| 1527 | 1506 | {
|
| 1528 | 1507 | $this->xmlrpc_curl_handle = $curl; |
| 1529 | 1508 | } |
| 1530 | - } |
|
| 1531 | - else |
|
| 1509 | + } else |
|
| 1532 | 1510 | {
|
| 1533 | 1511 | $curl = $this->xmlrpc_curl_handle; |
| 1534 | 1512 | } |
@@ -1559,9 +1537,9 @@ discard block |
||
| 1559 | 1537 | if (count($this->accepted_compression) == 1) |
| 1560 | 1538 | {
|
| 1561 | 1539 | curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]); |
| 1562 | - } |
|
| 1563 | - else |
|
| 1564 | - curl_setopt($curl, CURLOPT_ENCODING, ''); |
|
| 1540 | + } else { |
|
| 1541 | + curl_setopt($curl, CURLOPT_ENCODING, ''); |
|
| 1542 | + } |
|
| 1565 | 1543 | } |
| 1566 | 1544 | // extra headers |
| 1567 | 1545 | $headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
|
@@ -1589,8 +1567,7 @@ discard block |
||
| 1589 | 1567 | if (defined('CURLOPT_HTTPAUTH'))
|
| 1590 | 1568 | {
|
| 1591 | 1569 | curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype); |
| 1592 | - } |
|
| 1593 | - else if ($authtype != 1) |
|
| 1570 | + } else if ($authtype != 1) |
|
| 1594 | 1571 | {
|
| 1595 | 1572 | error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
|
| 1596 | 1573 | } |
@@ -1655,8 +1632,7 @@ discard block |
||
| 1655 | 1632 | if (defined('CURLOPT_PROXYAUTH'))
|
| 1656 | 1633 | {
|
| 1657 | 1634 | curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype); |
| 1658 | - } |
|
| 1659 | - else if ($proxyauthtype != 1) |
|
| 1635 | + } else if ($proxyauthtype != 1) |
|
| 1660 | 1636 | {
|
| 1661 | 1637 | error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
|
| 1662 | 1638 | } |
@@ -1698,17 +1674,18 @@ discard block |
||
| 1698 | 1674 | print "---END---\n</PRE>"; |
| 1699 | 1675 | } |
| 1700 | 1676 | |
| 1701 | - if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'? |
|
| 1677 | + if(!$result) { |
|
| 1678 | + /// @todo we should use a better check here - what if we get back '' or '0'? |
|
| 1702 | 1679 | {
|
| 1703 | - $this->errstr='no response'; |
|
| 1680 | + $this->errstr='no response'; |
|
| 1681 | + } |
|
| 1704 | 1682 | $resp=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl)); |
| 1705 | 1683 | curl_close($curl); |
| 1706 | 1684 | if($keepalive) |
| 1707 | 1685 | {
|
| 1708 | 1686 | $this->xmlrpc_curl_handle = null; |
| 1709 | 1687 | } |
| 1710 | - } |
|
| 1711 | - else |
|
| 1688 | + } else |
|
| 1712 | 1689 | {
|
| 1713 | 1690 | if(!$keepalive) |
| 1714 | 1691 | {
|
@@ -1760,8 +1737,7 @@ discard block |
||
| 1760 | 1737 | {
|
| 1761 | 1738 | // System.multicall succeeded |
| 1762 | 1739 | return $results; |
| 1763 | - } |
|
| 1764 | - else |
|
| 1740 | + } else |
|
| 1765 | 1741 | {
|
| 1766 | 1742 | // either system.multicall is unsupported by server, |
| 1767 | 1743 | // or call failed for some other reason. |
@@ -1769,21 +1745,18 @@ discard block |
||
| 1769 | 1745 | {
|
| 1770 | 1746 | // Don't try it next time... |
| 1771 | 1747 | $this->no_multicall = true; |
| 1772 | - } |
|
| 1773 | - else |
|
| 1748 | + } else |
|
| 1774 | 1749 | {
|
| 1775 | 1750 | if (is_a($results, 'xmlrpcresp')) |
| 1776 | 1751 | {
|
| 1777 | 1752 | $result = $results; |
| 1778 | - } |
|
| 1779 | - else |
|
| 1753 | + } else |
|
| 1780 | 1754 | {
|
| 1781 | 1755 | $result = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']); |
| 1782 | 1756 | } |
| 1783 | 1757 | } |
| 1784 | 1758 | } |
| 1785 | - } |
|
| 1786 | - else |
|
| 1759 | + } else |
|
| 1787 | 1760 | {
|
| 1788 | 1761 | // override fallback, in case careless user tries to do two |
| 1789 | 1762 | // opposite things at the same time |
@@ -1799,8 +1772,7 @@ discard block |
||
| 1799 | 1772 | {
|
| 1800 | 1773 | $results[] =& $this->send($msg, $timeout, $method); |
| 1801 | 1774 | } |
| 1802 | - } |
|
| 1803 | - else |
|
| 1775 | + } else |
|
| 1804 | 1776 | {
|
| 1805 | 1777 | // user does NOT want to fallback on many single calls: |
| 1806 | 1778 | // since we should always return an array of responses, |
@@ -1853,8 +1825,7 @@ discard block |
||
| 1853 | 1825 | if ($this->return_type == 'xml') |
| 1854 | 1826 | {
|
| 1855 | 1827 | return $rets; |
| 1856 | - } |
|
| 1857 | - else if ($this->return_type == 'phpvals') |
|
| 1828 | + } else if ($this->return_type == 'phpvals') |
|
| 1858 | 1829 | {
|
| 1859 | 1830 | ///@todo test this code branch... |
| 1860 | 1831 | $rets = $result->value(); |
@@ -1904,8 +1875,7 @@ discard block |
||
| 1904 | 1875 | } |
| 1905 | 1876 | } |
| 1906 | 1877 | return $response; |
| 1907 | - } |
|
| 1908 | - else // return type == 'xmlrpcvals' |
|
| 1878 | + } else // return type == 'xmlrpcvals' |
|
| 1909 | 1879 | {
|
| 1910 | 1880 | $rets = $result->value(); |
| 1911 | 1881 | if($rets->kindOf() != 'array') |
@@ -1992,8 +1962,7 @@ discard block |
||
| 1992 | 1962 | $this->errno = $fcode; |
| 1993 | 1963 | $this->errstr = $fstr; |
| 1994 | 1964 | //$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later. |
| 1995 | - } |
|
| 1996 | - else |
|
| 1965 | + } else |
|
| 1997 | 1966 | {
|
| 1998 | 1967 | // successful response |
| 1999 | 1968 | $this->val = $val; |
@@ -2003,18 +1972,15 @@ discard block |
||
| 2003 | 1972 | if (is_object($this->val) && is_a($this->val, 'xmlrpcval')) |
| 2004 | 1973 | {
|
| 2005 | 1974 | $this->valtyp = 'xmlrpcvals'; |
| 2006 | - } |
|
| 2007 | - else if (is_string($this->val)) |
|
| 1975 | + } else if (is_string($this->val)) |
|
| 2008 | 1976 | {
|
| 2009 | 1977 | $this->valtyp = 'xml'; |
| 2010 | 1978 | |
| 2011 | - } |
|
| 2012 | - else |
|
| 1979 | + } else |
|
| 2013 | 1980 | {
|
| 2014 | 1981 | $this->valtyp = 'phpvals'; |
| 2015 | 1982 | } |
| 2016 | - } |
|
| 2017 | - else |
|
| 1983 | + } else |
|
| 2018 | 1984 | {
|
| 2019 | 1985 | // user declares type of resp value: believe him |
| 2020 | 1986 | $this->valtyp = $valtyp; |
@@ -2076,15 +2042,15 @@ discard block |
||
| 2076 | 2042 | */ |
| 2077 | 2043 | function serialize($charset_encoding='') |
| 2078 | 2044 | {
|
| 2079 | - if ($charset_encoding != '') |
|
| 2080 | - $this->content_type = 'text/xml; charset=' . $charset_encoding; |
|
| 2081 | - else |
|
| 2082 | - $this->content_type = 'text/xml'; |
|
| 2045 | + if ($charset_encoding != '') { |
|
| 2046 | + $this->content_type = 'text/xml; charset=' . $charset_encoding; |
|
| 2047 | + } else { |
|
| 2048 | + $this->content_type = 'text/xml'; |
|
| 2049 | + } |
|
| 2083 | 2050 | if ($GLOBALS['xmlrpc_null_apache_encoding']) |
| 2084 | 2051 | {
|
| 2085 | 2052 | $result = "<methodResponse xmlns:ex=\"".$GLOBALS['xmlrpc_null_apache_encoding_ns']."\">\n"; |
| 2086 | - } |
|
| 2087 | - else |
|
| 2053 | + } else |
|
| 2088 | 2054 | {
|
| 2089 | 2055 | $result = "<methodResponse>\n"; |
| 2090 | 2056 | } |
@@ -2097,8 +2063,7 @@ discard block |
||
| 2097 | 2063 | "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" . |
| 2098 | 2064 | xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" . |
| 2099 | 2065 | "</struct>\n</value>\n</fault>"; |
| 2100 | - } |
|
| 2101 | - else |
|
| 2066 | + } else |
|
| 2102 | 2067 | {
|
| 2103 | 2068 | if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval')) |
| 2104 | 2069 | {
|
@@ -2107,14 +2072,12 @@ discard block |
||
| 2107 | 2072 | $result .= "<params>\n<param>\n" . |
| 2108 | 2073 | $this->val . |
| 2109 | 2074 | "</param>\n</params>"; |
| 2110 | - } |
|
| 2111 | - else |
|
| 2075 | + } else |
|
| 2112 | 2076 | {
|
| 2113 | 2077 | /// @todo try to build something serializable? |
| 2114 | 2078 | die('cannot serialize xmlrpcresp objects whose content is native php values');
|
| 2115 | 2079 | } |
| 2116 | - } |
|
| 2117 | - else |
|
| 2080 | + } else |
|
| 2118 | 2081 | {
|
| 2119 | 2082 | $result .= "<params>\n<param>\n" . |
| 2120 | 2083 | $this->val->serialize($charset_encoding) . |
@@ -2167,8 +2130,7 @@ discard block |
||
| 2167 | 2130 | if ($charset_encoding != '') |
| 2168 | 2131 | {
|
| 2169 | 2132 | return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?" . ">\n<methodCall>\n"; |
| 2170 | - } |
|
| 2171 | - else |
|
| 2133 | + } else |
|
| 2172 | 2134 | {
|
| 2173 | 2135 | return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; |
| 2174 | 2136 | } |
@@ -2195,10 +2157,11 @@ discard block |
||
| 2195 | 2157 | */ |
| 2196 | 2158 | function createPayload($charset_encoding='') |
| 2197 | 2159 | {
|
| 2198 | - if ($charset_encoding != '') |
|
| 2199 | - $this->content_type = 'text/xml; charset=' . $charset_encoding; |
|
| 2200 | - else |
|
| 2201 | - $this->content_type = 'text/xml'; |
|
| 2160 | + if ($charset_encoding != '') { |
|
| 2161 | + $this->content_type = 'text/xml; charset=' . $charset_encoding; |
|
| 2162 | + } else { |
|
| 2163 | + $this->content_type = 'text/xml'; |
|
| 2164 | + } |
|
| 2202 | 2165 | $this->payload=$this->xml_header($charset_encoding); |
| 2203 | 2166 | $this->payload.='<methodName>' . xmlrpc_encode_entitites($this->methodname, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</methodName>\n"; |
| 2204 | 2167 | $this->payload.="<params>\n"; |
@@ -2252,8 +2215,7 @@ discard block |
||
| 2252 | 2215 | {
|
| 2253 | 2216 | $this->params[]=$par; |
| 2254 | 2217 | return true; |
| 2255 | - } |
|
| 2256 | - else |
|
| 2218 | + } else |
|
| 2257 | 2219 | {
|
| 2258 | 2220 | return false; |
| 2259 | 2221 | } |
@@ -2314,15 +2276,13 @@ discard block |
||
| 2314 | 2276 | if($pos || is_int($pos)) |
| 2315 | 2277 | {
|
| 2316 | 2278 | $bd = $pos+4; |
| 2317 | - } |
|
| 2318 | - else |
|
| 2279 | + } else |
|
| 2319 | 2280 | {
|
| 2320 | 2281 | $pos = strpos($data,"\n\n"); |
| 2321 | 2282 | if($pos || is_int($pos)) |
| 2322 | 2283 | {
|
| 2323 | 2284 | $bd = $pos+2; |
| 2324 | - } |
|
| 2325 | - else |
|
| 2285 | + } else |
|
| 2326 | 2286 | {
|
| 2327 | 2287 | // No separation between response headers and body: fault? |
| 2328 | 2288 | $bd = 0; |
@@ -2333,8 +2293,7 @@ discard block |
||
| 2333 | 2293 | // this filters out all http headers from proxy. |
| 2334 | 2294 | // maybe we could take them into account, too? |
| 2335 | 2295 | $data = substr($data, $bd); |
| 2336 | - } |
|
| 2337 | - else |
|
| 2296 | + } else |
|
| 2338 | 2297 | {
|
| 2339 | 2298 | error_log('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed');
|
| 2340 | 2299 | $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)'); |
@@ -2348,9 +2307,11 @@ discard block |
||
| 2348 | 2307 | $pos = strpos($data, 'HTTP', 12); |
| 2349 | 2308 | // server sent a Continue header without any (valid) content following... |
| 2350 | 2309 | // give the client a chance to know it |
| 2351 | - if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5 |
|
| 2310 | + if(!$pos && !is_int($pos)) { |
|
| 2311 | + // works fine in php 3, 4 and 5 |
|
| 2352 | 2312 | {
|
| 2353 | - break; |
|
| 2313 | + break; |
|
| 2314 | + } |
|
| 2354 | 2315 | } |
| 2355 | 2316 | $data = substr($data, $pos); |
| 2356 | 2317 | } |
@@ -2371,15 +2332,13 @@ discard block |
||
| 2371 | 2332 | if($pos || is_int($pos)) |
| 2372 | 2333 | {
|
| 2373 | 2334 | $bd = $pos+4; |
| 2374 | - } |
|
| 2375 | - else |
|
| 2335 | + } else |
|
| 2376 | 2336 | {
|
| 2377 | 2337 | $pos = strpos($data,"\n\n"); |
| 2378 | 2338 | if($pos || is_int($pos)) |
| 2379 | 2339 | {
|
| 2380 | 2340 | $bd = $pos+2; |
| 2381 | - } |
|
| 2382 | - else |
|
| 2341 | + } else |
|
| 2383 | 2342 | {
|
| 2384 | 2343 | // No separation between response headers and body: fault? |
| 2385 | 2344 | // we could take some action here instead of going on... |
@@ -2406,8 +2365,7 @@ discard block |
||
| 2406 | 2365 | // version 2 cookies: |
| 2407 | 2366 | // there could be many cookies on one line, comma separated |
| 2408 | 2367 | $cookies = explode(',', $arr[1]);
|
| 2409 | - } |
|
| 2410 | - else |
|
| 2368 | + } else |
|
| 2411 | 2369 | {
|
| 2412 | 2370 | $cookies = array($arr[1]); |
| 2413 | 2371 | } |
@@ -2415,10 +2373,11 @@ discard block |
||
| 2415 | 2373 | {
|
| 2416 | 2374 | // glue together all received cookies, using a comma to separate them |
| 2417 | 2375 | // (same as php does with getallheaders()) |
| 2418 | - if (isset($GLOBALS['_xh']['headers'][$header_name])) |
|
| 2419 | - $GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie); |
|
| 2420 | - else |
|
| 2421 | - $GLOBALS['_xh']['headers'][$header_name] = trim($cookie); |
|
| 2376 | + if (isset($GLOBALS['_xh']['headers'][$header_name])) { |
|
| 2377 | + $GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie); |
|
| 2378 | + } else { |
|
| 2379 | + $GLOBALS['_xh']['headers'][$header_name] = trim($cookie); |
|
| 2380 | + } |
|
| 2422 | 2381 | // parse cookie attributes, in case user wants to correctly honour them |
| 2423 | 2382 | // feature creep: only allow rfc-compliant cookie attributes? |
| 2424 | 2383 | // @todo support for server sending multiple time cookie with same name, but using different PATHs |
@@ -2434,8 +2393,7 @@ discard block |
||
| 2434 | 2393 | $cookiename = $tag; |
| 2435 | 2394 | $GLOBALS['_xh']['cookies'][$tag] = array(); |
| 2436 | 2395 | $GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val); |
| 2437 | - } |
|
| 2438 | - else |
|
| 2396 | + } else |
|
| 2439 | 2397 | {
|
| 2440 | 2398 | if ($tag != 'value') |
| 2441 | 2399 | {
|
@@ -2444,13 +2402,11 @@ discard block |
||
| 2444 | 2402 | } |
| 2445 | 2403 | } |
| 2446 | 2404 | } |
| 2447 | - } |
|
| 2448 | - else |
|
| 2405 | + } else |
|
| 2449 | 2406 | {
|
| 2450 | 2407 | $GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]); |
| 2451 | 2408 | } |
| 2452 | - } |
|
| 2453 | - elseif(isset($header_name)) |
|
| 2409 | + } elseif(isset($header_name)) |
|
| 2454 | 2410 | {
|
| 2455 | 2411 | /// @todo version1 cookies might span multiple lines, thus breaking the parsing above |
| 2456 | 2412 | $GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line); |
@@ -2501,23 +2457,22 @@ discard block |
||
| 2501 | 2457 | if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) |
| 2502 | 2458 | {
|
| 2503 | 2459 | $data = $degzdata; |
| 2504 | - if($this->debug) |
|
| 2505 | - print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; |
|
| 2506 | - } |
|
| 2507 | - elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) |
|
| 2460 | + if($this->debug) { |
|
| 2461 | + print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; |
|
| 2462 | + } |
|
| 2463 | + } elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) |
|
| 2508 | 2464 | {
|
| 2509 | 2465 | $data = $degzdata; |
| 2510 | - if($this->debug) |
|
| 2511 | - print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; |
|
| 2512 | - } |
|
| 2513 | - else |
|
| 2466 | + if($this->debug) { |
|
| 2467 | + print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; |
|
| 2468 | + } |
|
| 2469 | + } else |
|
| 2514 | 2470 | {
|
| 2515 | 2471 | error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server');
|
| 2516 | 2472 | $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']); |
| 2517 | 2473 | return $r; |
| 2518 | 2474 | } |
| 2519 | - } |
|
| 2520 | - else |
|
| 2475 | + } else |
|
| 2521 | 2476 | {
|
| 2522 | 2477 | error_log('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
|
| 2523 | 2478 | $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']); |
@@ -2570,8 +2525,7 @@ discard block |
||
| 2570 | 2525 | $r->raw_data = $data; |
| 2571 | 2526 | return $r; |
| 2572 | 2527 | } |
| 2573 | - } |
|
| 2574 | - else |
|
| 2528 | + } else |
|
| 2575 | 2529 | {
|
| 2576 | 2530 | $GLOBALS['_xh']['headers'] = array(); |
| 2577 | 2531 | $GLOBALS['_xh']['cookies'] = array(); |
@@ -2651,8 +2605,7 @@ discard block |
||
| 2651 | 2605 | if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
|
| 2652 | 2606 | {
|
| 2653 | 2607 | xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); |
| 2654 | - } |
|
| 2655 | - else |
|
| 2608 | + } else |
|
| 2656 | 2609 | {
|
| 2657 | 2610 | xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); |
| 2658 | 2611 | } |
@@ -2660,8 +2613,7 @@ discard block |
||
| 2660 | 2613 | if ($return_type == 'phpvals') |
| 2661 | 2614 | {
|
| 2662 | 2615 | xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); |
| 2663 | - } |
|
| 2664 | - else |
|
| 2616 | + } else |
|
| 2665 | 2617 | {
|
| 2666 | 2618 | xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); |
| 2667 | 2619 | } |
@@ -2676,8 +2628,7 @@ discard block |
||
| 2676 | 2628 | if((xml_get_current_line_number($parser)) == 1) |
| 2677 | 2629 | {
|
| 2678 | 2630 | $errstr = 'XML error at line 1, check URL'; |
| 2679 | - } |
|
| 2680 | - else |
|
| 2631 | + } else |
|
| 2681 | 2632 | {
|
| 2682 | 2633 | $errstr = sprintf('XML error: %s at line %d, column %d',
|
| 2683 | 2634 | xml_error_string(xml_get_error_code($parser)), |
@@ -2716,8 +2667,7 @@ discard block |
||
| 2716 | 2667 | // indicating something odd went on |
| 2717 | 2668 | $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], |
| 2718 | 2669 | $GLOBALS['xmlrpcstr']['invalid_return']); |
| 2719 | - } |
|
| 2720 | - else |
|
| 2670 | + } else |
|
| 2721 | 2671 | {
|
| 2722 | 2672 | if ($this->debug) |
| 2723 | 2673 | {
|
@@ -2741,8 +2691,7 @@ discard block |
||
| 2741 | 2691 | $errstr_v = $v->structmem('faultString');
|
| 2742 | 2692 | $errno = $errno_v->scalarval(); |
| 2743 | 2693 | $errstr = $errstr_v->scalarval(); |
| 2744 | - } |
|
| 2745 | - else |
|
| 2694 | + } else |
|
| 2746 | 2695 | {
|
| 2747 | 2696 | $errno = $v['faultCode']; |
| 2748 | 2697 | $errstr = $v['faultString']; |
@@ -2755,8 +2704,7 @@ discard block |
||
| 2755 | 2704 | } |
| 2756 | 2705 | |
| 2757 | 2706 | $r = new xmlrpcresp(0, $errno, $errstr); |
| 2758 | - } |
|
| 2759 | - else |
|
| 2707 | + } else |
|
| 2760 | 2708 | {
|
| 2761 | 2709 | $r=new xmlrpcresp($v, 0, '', $return_type); |
| 2762 | 2710 | } |
@@ -2864,8 +2812,7 @@ discard block |
||
| 2864 | 2812 | if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false'))) |
| 2865 | 2813 | {
|
| 2866 | 2814 | $val=true; |
| 2867 | - } |
|
| 2868 | - else |
|
| 2815 | + } else |
|
| 2869 | 2816 | {
|
| 2870 | 2817 | $val=false; |
| 2871 | 2818 | } |
@@ -2910,14 +2857,12 @@ discard block |
||
| 2910 | 2857 | $this->mytype=$GLOBALS['xmlrpcTypes']['array']; |
| 2911 | 2858 | $this->me['array']=$vals; |
| 2912 | 2859 | return 1; |
| 2913 | - } |
|
| 2914 | - elseif($this->mytype==2) |
|
| 2860 | + } elseif($this->mytype==2) |
|
| 2915 | 2861 | {
|
| 2916 | 2862 | // we're adding to an array here |
| 2917 | 2863 | $this->me['array'] = array_merge($this->me['array'], $vals); |
| 2918 | 2864 | return 1; |
| 2919 | - } |
|
| 2920 | - else |
|
| 2865 | + } else |
|
| 2921 | 2866 | {
|
| 2922 | 2867 | error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
|
| 2923 | 2868 | return 0; |
@@ -2939,14 +2884,12 @@ discard block |
||
| 2939 | 2884 | $this->mytype=$GLOBALS['xmlrpcTypes']['struct']; |
| 2940 | 2885 | $this->me['struct']=$vals; |
| 2941 | 2886 | return 1; |
| 2942 | - } |
|
| 2943 | - elseif($this->mytype==3) |
|
| 2887 | + } elseif($this->mytype==3) |
|
| 2944 | 2888 | {
|
| 2945 | 2889 | // we're adding to a struct here |
| 2946 | 2890 | $this->me['struct'] = array_merge($this->me['struct'], $vals); |
| 2947 | 2891 | return 1; |
| 2948 | - } |
|
| 2949 | - else |
|
| 2892 | + } else |
|
| 2950 | 2893 | {
|
| 2951 | 2894 | error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
|
| 2952 | 2895 | return 0; |
@@ -3050,8 +2993,7 @@ discard block |
||
| 3050 | 2993 | if ($GLOBALS['xmlrpc_null_apache_encoding']) |
| 3051 | 2994 | {
|
| 3052 | 2995 | $rs.="<ex:nil/>"; |
| 3053 | - } |
|
| 3054 | - else |
|
| 2996 | + } else |
|
| 3055 | 2997 | {
|
| 3056 | 2998 | $rs.="<nil/>"; |
| 3057 | 2999 | } |
@@ -3067,8 +3009,7 @@ discard block |
||
| 3067 | 3009 | if ($this->_php_class) |
| 3068 | 3010 | {
|
| 3069 | 3011 | $rs.='<struct php_class="' . $this->_php_class . "\">\n"; |
| 3070 | - } |
|
| 3071 | - else |
|
| 3012 | + } else |
|
| 3072 | 3013 | {
|
| 3073 | 3014 | $rs.="<struct>\n"; |
| 3074 | 3015 | } |
@@ -3296,16 +3237,14 @@ discard block |
||
| 3296 | 3237 | if(!$utc) |
| 3297 | 3238 | {
|
| 3298 | 3239 | $t=strftime("%Y%m%dT%H:%M:%S", $timet);
|
| 3299 | - } |
|
| 3300 | - else |
|
| 3240 | + } else |
|
| 3301 | 3241 | {
|
| 3302 | 3242 | if(function_exists('gmstrftime'))
|
| 3303 | 3243 | {
|
| 3304 | 3244 | // gmstrftime doesn't exist in some versions |
| 3305 | 3245 | // of PHP |
| 3306 | 3246 | $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
|
| 3307 | - } |
|
| 3308 | - else |
|
| 3247 | + } else |
|
| 3309 | 3248 | {
|
| 3310 | 3249 | $t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z'));
|
| 3311 | 3250 | } |
@@ -3327,8 +3266,7 @@ discard block |
||
| 3327 | 3266 | if($utc) |
| 3328 | 3267 | {
|
| 3329 | 3268 | $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
| 3330 | - } |
|
| 3331 | - else |
|
| 3269 | + } else |
|
| 3332 | 3270 | {
|
| 3333 | 3271 | $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
| 3334 | 3272 | } |
@@ -3396,8 +3334,7 @@ discard block |
||
| 3396 | 3334 | $result = new Datetime(); |
| 3397 | 3335 | $result->setTimestamp($out); |
| 3398 | 3336 | return $result; |
| 3399 | - } |
|
| 3400 | - elseif (is_a($out, 'Datetime')) |
|
| 3337 | + } elseif (is_a($out, 'Datetime')) |
|
| 3401 | 3338 | {
|
| 3402 | 3339 | return $out; |
| 3403 | 3340 | } |
@@ -3426,8 +3363,7 @@ discard block |
||
| 3426 | 3363 | $obj->$key = php_xmlrpc_decode($value, $options); |
| 3427 | 3364 | } |
| 3428 | 3365 | return $obj; |
| 3429 | - } |
|
| 3430 | - else |
|
| 3366 | + } else |
|
| 3431 | 3367 | {
|
| 3432 | 3368 | $arr = array(); |
| 3433 | 3369 | while(list($key,$value)=$xmlrpc_val->structeach()) |
@@ -3453,8 +3389,7 @@ discard block |
||
| 3453 | 3389 | if(function_exists('xmlrpc_decode'))
|
| 3454 | 3390 | {
|
| 3455 | 3391 | define('XMLRPC_EPI_ENABLED','1');
|
| 3456 | - } |
|
| 3457 | - else |
|
| 3392 | + } else |
|
| 3458 | 3393 | {
|
| 3459 | 3394 | define('XMLRPC_EPI_ENABLED','0');
|
| 3460 | 3395 | } |
@@ -3482,10 +3417,11 @@ discard block |
||
| 3482 | 3417 | switch($type) |
| 3483 | 3418 | {
|
| 3484 | 3419 | case 'string': |
| 3485 | - if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val))
|
|
| 3486 | - $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']); |
|
| 3487 | - else |
|
| 3488 | - $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']); |
|
| 3420 | + if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) { |
|
| 3421 | + $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']); |
|
| 3422 | + } else { |
|
| 3423 | + $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']); |
|
| 3424 | + } |
|
| 3489 | 3425 | break; |
| 3490 | 3426 | case 'integer': |
| 3491 | 3427 | $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']); |
@@ -3520,8 +3456,7 @@ discard block |
||
| 3520 | 3456 | if($ko) |
| 3521 | 3457 | {
|
| 3522 | 3458 | $xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']); |
| 3523 | - } |
|
| 3524 | - else |
|
| 3459 | + } else |
|
| 3525 | 3460 | {
|
| 3526 | 3461 | $xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcArray']); |
| 3527 | 3462 | } |
@@ -3530,12 +3465,10 @@ discard block |
||
| 3530 | 3465 | if(is_a($php_val, 'xmlrpcval')) |
| 3531 | 3466 | {
|
| 3532 | 3467 | $xmlrpc_val = $php_val; |
| 3533 | - } |
|
| 3534 | - else if(is_a($php_val, 'DateTime')) |
|
| 3468 | + } else if(is_a($php_val, 'DateTime')) |
|
| 3535 | 3469 | {
|
| 3536 | 3470 | $xmlrpc_val = new xmlrpcval($php_val->format('Ymd\TH:i:s'), $GLOBALS['xmlrpcStruct']);
|
| 3537 | - } |
|
| 3538 | - else |
|
| 3471 | + } else |
|
| 3539 | 3472 | {
|
| 3540 | 3473 | $arr = array(); |
| 3541 | 3474 | reset($php_val); |
@@ -3556,12 +3489,10 @@ discard block |
||
| 3556 | 3489 | if (in_array('extension_api', $options))
|
| 3557 | 3490 | {
|
| 3558 | 3491 | $xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcString']);
|
| 3559 | - } |
|
| 3560 | - else if (in_array('null_extension', $options))
|
|
| 3492 | + } else if (in_array('null_extension', $options))
|
|
| 3561 | 3493 | {
|
| 3562 | 3494 | $xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcNull']);
|
| 3563 | - } |
|
| 3564 | - else |
|
| 3495 | + } else |
|
| 3565 | 3496 | {
|
| 3566 | 3497 | $xmlrpc_val = new xmlrpcval(); |
| 3567 | 3498 | } |
@@ -3570,8 +3501,7 @@ discard block |
||
| 3570 | 3501 | if (in_array('extension_api', $options))
|
| 3571 | 3502 | {
|
| 3572 | 3503 | $xmlrpc_val = new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']); |
| 3573 | - } |
|
| 3574 | - else |
|
| 3504 | + } else |
|
| 3575 | 3505 | {
|
| 3576 | 3506 | $xmlrpc_val = new xmlrpcval(); |
| 3577 | 3507 | } |
@@ -3633,8 +3563,7 @@ discard block |
||
| 3633 | 3563 | if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
|
| 3634 | 3564 | {
|
| 3635 | 3565 | xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); |
| 3636 | - } |
|
| 3637 | - else |
|
| 3566 | + } else |
|
| 3638 | 3567 | {
|
| 3639 | 3568 | xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); |
| 3640 | 3569 | } |
@@ -3651,9 +3580,11 @@ discard block |
||
| 3651 | 3580 | return false; |
| 3652 | 3581 | } |
| 3653 | 3582 | xml_parser_free($parser); |
| 3654 | - if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too??? |
|
| 3583 | + if ($GLOBALS['_xh']['isf'] > 1) { |
|
| 3584 | + // test that $GLOBALS['_xh']['value'] is an obj, too??? |
|
| 3655 | 3585 | {
|
| 3656 | - error_log($GLOBALS['_xh']['isf_reason']); |
|
| 3586 | + error_log($GLOBALS['_xh']['isf_reason']); |
|
| 3587 | + } |
|
| 3657 | 3588 | return false; |
| 3658 | 3589 | } |
| 3659 | 3590 | switch ($GLOBALS['_xh']['rt']) |
@@ -3665,8 +3596,7 @@ discard block |
||
| 3665 | 3596 | $vc = $v->structmem('faultCode');
|
| 3666 | 3597 | $vs = $v->structmem('faultString');
|
| 3667 | 3598 | $r = new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval()); |
| 3668 | - } |
|
| 3669 | - else |
|
| 3599 | + } else |
|
| 3670 | 3600 | {
|
| 3671 | 3601 | $r = new xmlrpcresp($v); |
| 3672 | 3602 | } |
@@ -3787,12 +3717,10 @@ discard block |
||
| 3787 | 3717 | if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk))
|
| 3788 | 3718 | {
|
| 3789 | 3719 | return 'UCS-4'; |
| 3790 | - } |
|
| 3791 | - elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
|
|
| 3720 | + } elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
|
|
| 3792 | 3721 | {
|
| 3793 | 3722 | return 'UTF-16'; |
| 3794 | - } |
|
| 3795 | - elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
|
|
| 3723 | + } elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
|
|
| 3796 | 3724 | {
|
| 3797 | 3725 | return 'UTF-8'; |
| 3798 | 3726 | } |
@@ -3815,8 +3743,7 @@ discard block |
||
| 3815 | 3743 | if($encoding_prefs) |
| 3816 | 3744 | {
|
| 3817 | 3745 | $enc = mb_detect_encoding($xmlchunk, $encoding_prefs); |
| 3818 | - } |
|
| 3819 | - else |
|
| 3746 | + } else |
|
| 3820 | 3747 | {
|
| 3821 | 3748 | $enc = mb_detect_encoding($xmlchunk); |
| 3822 | 3749 | } |
@@ -3827,8 +3754,7 @@ discard block |
||
| 3827 | 3754 | $enc = 'US-'.$enc; |
| 3828 | 3755 | } |
| 3829 | 3756 | return $enc; |
| 3830 | - } |
|
| 3831 | - else |
|
| 3757 | + } else |
|
| 3832 | 3758 | {
|
| 3833 | 3759 | // no encoding specified: as per HTTP1.1 assume it is iso-8859-1? |
| 3834 | 3760 | // Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types |
@@ -3851,12 +3777,10 @@ discard block |
||
| 3851 | 3777 | if (preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlChunk))
|
| 3852 | 3778 | {
|
| 3853 | 3779 | return true; |
| 3854 | - } |
|
| 3855 | - elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlChunk))
|
|
| 3780 | + } elseif (preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlChunk))
|
|
| 3856 | 3781 | {
|
| 3857 | 3782 | return true; |
| 3858 | - } |
|
| 3859 | - elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlChunk))
|
|
| 3783 | + } elseif (preg_match('/^(\xEF\xBB\xBF)/', $xmlChunk))
|
|
| 3860 | 3784 | {
|
| 3861 | 3785 | return true; |
| 3862 | 3786 | } |
@@ -3891,16 +3815,18 @@ discard block |
||
| 3891 | 3815 | 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8', |
| 3892 | 3816 | 'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN') |
| 3893 | 3817 | ); |
| 3894 | - if (is_string($validlist)) |
|
| 3895 | - $validlist = explode(',', $validlist);
|
|
| 3896 | - if (@in_array(strtoupper($encoding), $validlist)) |
|
| 3897 | - return true; |
|
| 3898 | - else |
|
| 3899 | - {
|
|
| 3900 | - if (array_key_exists($encoding, $charset_supersets)) |
|
| 3901 | - foreach ($validlist as $allowed) |
|
| 3818 | + if (is_string($validlist)) { |
|
| 3819 | + $validlist = explode(',', $validlist); |
|
| 3820 | + } |
|
| 3821 | + if (@in_array(strtoupper($encoding), $validlist)) { |
|
| 3822 | + return true; |
|
| 3823 | + } else |
|
| 3824 | + {
|
|
| 3825 | + if (array_key_exists($encoding, $charset_supersets)) { |
|
| 3826 | + foreach ($validlist as $allowed) |
|
| 3902 | 3827 | if (in_array($allowed, $charset_supersets[$encoding])) |
| 3903 | - return true; |
|
| 3828 | + return true; |
|
| 3829 | + } |
|
| 3904 | 3830 | return false; |
| 3905 | 3831 | } |
| 3906 | 3832 | } |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | * @param xmlrpc_client $client an xmlrpc client set up correctly to communicate with target server |
| 538 | 538 | * @param string $methodname the xmlrpc method to be mapped to a php function |
| 539 | - * @param array $extra_options array of options that specify conversion details. valid options include |
|
| 539 | + * @param integer $extra_options array of options that specify conversion details. valid options include |
|
| 540 | 540 | * integer signum the index of the method signature to use in mapping (if method exposes many sigs) |
| 541 | 541 | * integer timeout timeout (in secs) to be used when executing function/calling remote method |
| 542 | 542 | * string protocol 'http' (default), 'http11' or 'https' |
@@ -805,6 +805,8 @@ discard block |
||
| 805 | 805 | * valid php code is emitted. |
| 806 | 806 | * Note: real spaghetti code follows... |
| 807 | 807 | * @access private |
| 808 | + * @param xmlrpc_client $client |
|
| 809 | + * @param string $methodname |
|
| 808 | 810 | */ |
| 809 | 811 | function build_remote_method_wrapper_code($client, $methodname, $xmlrpcfuncname, |
| 810 | 812 | $msig, $mdesc='', $timeout=0, $protocol='', $client_copy_mode=0, $prefix='xmlrpc', |
@@ -52,8 +52,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -502,8 +502,8 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | /** |
| 505 | - * @param array $dispmap the dispatch map with definition of exposed services |
|
| 506 | - * @param boolean $servicenow set to false to prevent the server from running upon construction |
|
| 505 | + * @param array $dispMap the dispatch map with definition of exposed services |
|
| 506 | + * @param boolean $serviceNow set to false to prevent the server from running upon construction |
|
| 507 | 507 | */ |
| 508 | 508 | function __construct($dispMap=null, $serviceNow=true) |
| 509 | 509 | {
|
@@ -785,7 +785,8 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | /** |
| 787 | 787 | * Parse http headers received along with xmlrpc request. If needed, inflate request |
| 788 | - * @return mixed null on success or an xmlrpcresp |
|
| 788 | + * @param string $data |
|
| 789 | + * @return xmlrpcresp|null null on success or an xmlrpcresp |
|
| 789 | 790 | * @access private |
| 790 | 791 | */ |
| 791 | 792 | function parseRequestHeaders(&$data, &$req_encoding, &$resp_encoding, &$resp_compression) |
@@ -106,16 +106,14 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -42,15 +42,17 @@ discard block |
||
| 42 | 42 | if (isset($_GET['wstype']) && $_GET['wstype'] == '1') |
| 43 | 43 | { |
| 44 | 44 | $wstype = 1; |
| 45 | - if (isset($_GET['id'])) |
|
| 46 | - $id = $_GET['id']; |
|
| 45 | + if (isset($_GET['id'])) { |
|
| 46 | + $id = $_GET['id']; |
|
| 47 | + } |
|
| 47 | 48 | } |
| 48 | 49 | $host = isset($_GET['host']) ? $_GET['host'] : 'localhost'; // using '' will trigger an xmlrpc error... |
| 49 | - if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2')) |
|
| 50 | - $protocol = $_GET['protocol']; |
|
| 51 | - if (strpos($host, 'http://') === 0) |
|
| 52 | - $host = substr($host, 7); |
|
| 53 | - else if (strpos($host, 'https://') === 0) |
|
| 50 | + if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2')) { |
|
| 51 | + $protocol = $_GET['protocol']; |
|
| 52 | + } |
|
| 53 | + if (strpos($host, 'http://') === 0) { |
|
| 54 | + $host = substr($host, 7); |
|
| 55 | + } else if (strpos($host, 'https://') === 0) |
|
| 54 | 56 | { |
| 55 | 57 | $host = substr($host, 8); |
| 56 | 58 | $protocol = 2; |
@@ -58,26 +60,31 @@ discard block |
||
| 58 | 60 | $port = isset($_GET['port']) ? $_GET['port'] : ''; |
| 59 | 61 | $path = isset($_GET['path']) ? $_GET['path'] : ''; |
| 60 | 62 | // in case user forgot initial '/' in xmlrpc server path, add it back |
| 61 | - if ($path && ($path[0]) != '/') |
|
| 62 | - $path = '/'.$path; |
|
| 63 | + if ($path && ($path[0]) != '/') { |
|
| 64 | + $path = '/'.$path; |
|
| 65 | + } |
|
| 63 | 66 | |
| 64 | - if (isset($_GET['debug']) && ($_GET['debug'] == '1' || $_GET['debug'] == '2')) |
|
| 65 | - $debug = $_GET['debug']; |
|
| 67 | + if (isset($_GET['debug']) && ($_GET['debug'] == '1' || $_GET['debug'] == '2')) { |
|
| 68 | + $debug = $_GET['debug']; |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | $verifyhost = (isset($_GET['verifyhost']) && ($_GET['verifyhost'] == '1' || $_GET['verifyhost'] == '2')) ? $_GET['verifyhost'] : 0; |
| 68 | - if (isset($_GET['verifypeer']) && $_GET['verifypeer'] == '1') |
|
| 69 | - $verifypeer = true; |
|
| 70 | - else |
|
| 71 | - $verifypeer = false; |
|
| 72 | + if (isset($_GET['verifypeer']) && $_GET['verifypeer'] == '1') { |
|
| 73 | + $verifypeer = true; |
|
| 74 | + } else { |
|
| 75 | + $verifypeer = false; |
|
| 76 | + } |
|
| 72 | 77 | $cainfo= isset($_GET['cainfo']) ? $_GET['cainfo'] : ''; |
| 73 | 78 | $proxy = isset($_GET['proxy']) ? $_GET['proxy'] : 0; |
| 74 | - if (strpos($proxy, 'http://') === 0) |
|
| 75 | - $proxy = substr($proxy, 7); |
|
| 79 | + if (strpos($proxy, 'http://') === 0) { |
|
| 80 | + $proxy = substr($proxy, 7); |
|
| 81 | + } |
|
| 76 | 82 | $proxyuser= isset($_GET['proxyuser']) ? $_GET['proxyuser'] : ''; |
| 77 | 83 | $proxypwd = isset($_GET['proxypwd']) ? $_GET['proxypwd'] : ''; |
| 78 | 84 | $timeout = isset($_GET['timeout']) ? $_GET['timeout'] : 0; |
| 79 | - if (!is_numeric($timeout)) |
|
| 80 | - $timeout = 0; |
|
| 85 | + if (!is_numeric($timeout)) { |
|
| 86 | + $timeout = 0; |
|
| 87 | + } |
|
| 81 | 88 | $action = $_GET['action']; |
| 82 | 89 | |
| 83 | 90 | $method = isset($_GET['method']) ? $_GET['method'] : ''; |
@@ -85,26 +92,28 @@ discard block |
||
| 85 | 92 | $payload = isset($_GET['methodpayload']) ? $_GET['methodpayload'] : ''; |
| 86 | 93 | $alt_payload = isset($_GET['altmethodpayload']) ? $_GET['altmethodpayload'] : ''; |
| 87 | 94 | |
| 88 | - if (isset($_GET['run']) && $_GET['run'] == 'now') |
|
| 89 | - $run = true; |
|
| 95 | + if (isset($_GET['run']) && $_GET['run'] == 'now') { |
|
| 96 | + $run = true; |
|
| 97 | + } |
|
| 90 | 98 | |
| 91 | 99 | $username = isset($_GET['username']) ? $_GET['username'] : ''; |
| 92 | 100 | $password = isset($_GET['password']) ? $_GET['password'] : ''; |
| 93 | 101 | |
| 94 | 102 | $authtype = (isset($_GET['authtype']) && ($_GET['authtype'] == '2' || $_GET['authtype'] == '8')) ? $_GET['authtype'] : 1; |
| 95 | 103 | |
| 96 | - if (isset($_GET['requestcompression']) && ($_GET['requestcompression'] == '1' || $_GET['requestcompression'] == '2')) |
|
| 97 | - $requestcompression = $_GET['requestcompression']; |
|
| 98 | - else |
|
| 99 | - $requestcompression = 0; |
|
| 100 | - if (isset($_GET['responsecompression']) && ($_GET['responsecompression'] == '1' || $_GET['responsecompression'] == '2' || $_GET['responsecompression'] == '3')) |
|
| 101 | - $responsecompression = $_GET['responsecompression']; |
|
| 102 | - else |
|
| 103 | - $responsecompression = 0; |
|
| 104 | + if (isset($_GET['requestcompression']) && ($_GET['requestcompression'] == '1' || $_GET['requestcompression'] == '2')) { |
|
| 105 | + $requestcompression = $_GET['requestcompression']; |
|
| 106 | + } else { |
|
| 107 | + $requestcompression = 0; |
|
| 108 | + } |
|
| 109 | + if (isset($_GET['responsecompression']) && ($_GET['responsecompression'] == '1' || $_GET['responsecompression'] == '2' || $_GET['responsecompression'] == '3')) { |
|
| 110 | + $responsecompression = $_GET['responsecompression']; |
|
| 111 | + } else { |
|
| 112 | + $responsecompression = 0; |
|
| 113 | + } |
|
| 104 | 114 | |
| 105 | 115 | $clientcookies = isset($_GET['clientcookies']) ? $_GET['clientcookies'] : ''; |
| 106 | - } |
|
| 107 | - else |
|
| 116 | + } else |
|
| 108 | 117 | { |
| 109 | 118 | $host = ''; |
| 110 | 119 | $port = ''; |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | |
| 43 | 43 | // make sure the script waits long enough for the call to complete... |
| 44 | - if ($timeout) |
|
| 45 | - set_time_limit($timeout+10); |
|
| 44 | + if ($timeout) { |
|
| 45 | + set_time_limit($timeout+10); |
|
| 46 | + } |
|
| 46 | 47 | |
| 47 | 48 | include('xmlrpc.inc'); |
| 48 | 49 | if ($wstype == 1) |
@@ -55,8 +56,7 @@ discard block |
||
| 55 | 56 | $clientclass = 'jsonrpc_client'; |
| 56 | 57 | $msgclass = 'jsonrpcmsg'; |
| 57 | 58 | $protoname = 'JSONRPC'; |
| 58 | - } |
|
| 59 | - else |
|
| 59 | + } else |
|
| 60 | 60 | { |
| 61 | 61 | $clientclass = 'xmlrpc_client'; |
| 62 | 62 | $msgclass = 'xmlrpcmsg'; |
@@ -74,17 +74,17 @@ discard block |
||
| 74 | 74 | if ($protocol == 2) |
| 75 | 75 | { |
| 76 | 76 | $server = 'https://'.$server; |
| 77 | - } |
|
| 78 | - else |
|
| 77 | + } else |
|
| 79 | 78 | { |
| 80 | 79 | $server = 'http://'.$server; |
| 81 | 80 | } |
| 82 | 81 | if ($proxy != '') { |
| 83 | 82 | $pproxy = explode(':', $proxy); |
| 84 | - if (count($pproxy) > 1) |
|
| 85 | - $pport = $pproxy[1]; |
|
| 86 | - else |
|
| 87 | - $pport = 8080; |
|
| 83 | + if (count($pproxy) > 1) { |
|
| 84 | + $pport = $pproxy[1]; |
|
| 85 | + } else { |
|
| 86 | + $pport = 8080; |
|
| 87 | + } |
|
| 88 | 88 | $client->setProxy($pproxy[0], $pport, $proxyuser, $proxypwd); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -97,14 +97,15 @@ discard block |
||
| 97 | 97 | $client->setCaCertificate($cainfo); |
| 98 | 98 | } |
| 99 | 99 | $httpprotocol = 'https'; |
| 100 | + } else if ($protocol == 1) { |
|
| 101 | + $httpprotocol = 'http11'; |
|
| 102 | + } else { |
|
| 103 | + $httpprotocol = 'http'; |
|
| 100 | 104 | } |
| 101 | - else if ($protocol == 1) |
|
| 102 | - $httpprotocol = 'http11'; |
|
| 103 | - else |
|
| 104 | - $httpprotocol = 'http'; |
|
| 105 | 105 | |
| 106 | - if ($username) |
|
| 107 | - $client->setCredentials($username, $password, $authtype); |
|
| 106 | + if ($username) { |
|
| 107 | + $client->setCredentials($username, $password, $authtype); |
|
| 108 | + } |
|
| 108 | 109 | |
| 109 | 110 | $client->setDebug($debug); |
| 110 | 111 | |
@@ -168,8 +169,9 @@ discard block |
||
| 168 | 169 | $actionname = 'List of available methods'; |
| 169 | 170 | break; |
| 170 | 171 | case 'execute': |
| 171 | - if (!payload_is_safe($payload)) |
|
| 172 | - die("Tsk tsk tsk, please stop it or I will have to call in the cops!"); |
|
| 172 | + if (!payload_is_safe($payload)) { |
|
| 173 | + die("Tsk tsk tsk, please stop it or I will have to call in the cops!"); |
|
| 174 | + } |
|
| 173 | 175 | $msg[0] = new $msgclass($method, null, $id); |
| 174 | 176 | // hack! build xml payload by hand |
| 175 | 177 | if ($wstype == 1) |
@@ -182,24 +184,22 @@ discard block |
||
| 182 | 184 | if ($id == "") |
| 183 | 185 | { |
| 184 | 186 | $msg[0]->payload .= "null\n}"; |
| 185 | - } |
|
| 186 | - else |
|
| 187 | + } else |
|
| 187 | 188 | { |
| 188 | 189 | if (is_numeric($id) || $id == 'false' || $id == 'true' || $id == 'null') |
| 189 | 190 | { |
| 190 | 191 | $msg[0]->payload .= "$id\n}"; |
| 191 | - } |
|
| 192 | - else |
|
| 192 | + } else |
|
| 193 | 193 | { |
| 194 | 194 | $msg[0]->payload .= "\"$id\"\n}"; |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - } |
|
| 198 | - else |
|
| 199 | - $msg[0]->payload = $msg[0]->xml_header($inputcharset) . |
|
| 197 | + } else { |
|
| 198 | + $msg[0]->payload = $msg[0]->xml_header($inputcharset) . |
|
| 200 | 199 | '<methodName>' . $method . "</methodName>\n<params>" . |
| 201 | 200 | $payload . |
| 202 | 201 | "</params>\n" . $msg[0]->xml_footer(); |
| 202 | + } |
|
| 203 | 203 | $actionname = 'Execution of method '.$method; |
| 204 | 204 | break; |
| 205 | 205 | default: // give a warning |
@@ -213,8 +213,10 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | $response = null; |
| 215 | 215 | // execute method(s) |
| 216 | - if ($debug) |
|
| 217 | - echo '<div class="dbginfo"><h2>Debug info:</h2>'; /// @todo use ob_start instead |
|
| 216 | + if ($debug) { |
|
| 217 | + echo '<div class="dbginfo"><h2>Debug info:</h2>'; |
|
| 218 | + } |
|
| 219 | + /// @todo use ob_start instead |
|
| 218 | 220 | $resp = array(); |
| 219 | 221 | $mtime = explode(' ',microtime()); |
| 220 | 222 | $time = (float)$mtime[0] + (float)$mtime[1]; |
@@ -223,13 +225,15 @@ discard block |
||
| 223 | 225 | // catch errors: for older xmlrpc libs, send does not return by ref |
| 224 | 226 | @$response =& $client->send($message, $timeout, $httpprotocol); |
| 225 | 227 | $resp[] = $response; |
| 226 | - if (!$response || $response->faultCode()) |
|
| 227 | - break; |
|
| 228 | + if (!$response || $response->faultCode()) { |
|
| 229 | + break; |
|
| 230 | + } |
|
| 228 | 231 | } |
| 229 | 232 | $mtime = explode(' ',microtime()); |
| 230 | 233 | $time = (float)$mtime[0] + (float)$mtime[1] - $time; |
| 231 | - if ($debug) |
|
| 232 | - echo "</div>\n"; |
|
| 234 | + if ($debug) { |
|
| 235 | + echo "</div>\n"; |
|
| 236 | + } |
|
| 233 | 237 | |
| 234 | 238 | if ($response) |
| 235 | 239 | { |
@@ -242,8 +246,7 @@ discard block |
||
| 242 | 246 | echo "<p>Fault code: [" . htmlspecialchars($response->faultCode(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']) . |
| 243 | 247 | "] Reason: '" . htmlspecialchars($response->faultString(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']) . "'</p>\n"; |
| 244 | 248 | echo (strftime("%d/%b/%Y:%H:%M:%S\n")); |
| 245 | - } |
|
| 246 | - else |
|
| 249 | + } else |
|
| 247 | 250 | { |
| 248 | 251 | // call succeeded: parse results |
| 249 | 252 | //echo '<h2>'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'</h2>'; |
@@ -263,7 +266,11 @@ discard block |
||
| 263 | 266 | for($i=0; $i < $max; $i++) |
| 264 | 267 | { |
| 265 | 268 | $rec = $v->arraymem($i); |
| 266 | - if ($i%2) $class=' class="oddrow"'; else $class = ' class="evenrow"'; |
|
| 269 | + if ($i%2) { |
|
| 270 | + $class=' class="oddrow"'; |
|
| 271 | + } else { |
|
| 272 | + $class = ' class="evenrow"'; |
|
| 273 | + } |
|
| 267 | 274 | echo ("<tr><td$class>".htmlspecialchars($rec->scalarval(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding'])."</td><td$class><form action=\"controller.php\" method=\"get\" target=\"frmcontroller\">". |
| 268 | 275 | "<input type=\"hidden\" name=\"host\" value=\"".htmlspecialchars($host, ENT_COMPAT, $inputcharset)."\" />". |
| 269 | 276 | "<input type=\"hidden\" name=\"port\" value=\"".htmlspecialchars($port, ENT_COMPAT, $inputcharset)."\" />". |
@@ -316,18 +323,23 @@ discard block |
||
| 316 | 323 | echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n"; |
| 317 | 324 | echo "<thead>\n<tr><th>Method</th><th>".htmlspecialchars($method, ENT_COMPAT, $inputcharset)."</th><th> </th><th> </th></tr>\n</thead>\n<tbody>\n"; |
| 318 | 325 | $desc = htmlspecialchars($r1->scalarval(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']); |
| 319 | - if ($desc == "") |
|
| 320 | - $desc = "-"; |
|
| 326 | + if ($desc == "") { |
|
| 327 | + $desc = "-"; |
|
| 328 | + } |
|
| 321 | 329 | echo "<tr><td class=\"evenrow\">Description</td><td colspan=\"3\" class=\"evenrow\">$desc</td></tr>\n"; |
| 322 | 330 | $payload=""; |
| 323 | 331 | $alt_payload=""; |
| 324 | - if ($r2->kindOf()!="array") |
|
| 325 | - echo "<tr><td class=\"oddrow\">Signature</td><td class=\"oddrow\">Unknown</td><td class=\"oddrow\"> </td></tr>\n"; |
|
| 326 | - else |
|
| 332 | + if ($r2->kindOf()!="array") { |
|
| 333 | + echo "<tr><td class=\"oddrow\">Signature</td><td class=\"oddrow\">Unknown</td><td class=\"oddrow\"> </td></tr>\n"; |
|
| 334 | + } else |
|
| 327 | 335 | { |
| 328 | 336 | for($i=0; $i < $r2->arraysize(); $i++) |
| 329 | 337 | { |
| 330 | - if ($i+1%2) $class=' class="oddrow"'; else $class = ' class="evenrow"'; |
|
| 338 | + if ($i+1%2) { |
|
| 339 | + $class=' class="oddrow"'; |
|
| 340 | + } else { |
|
| 341 | + $class = ' class="evenrow"'; |
|
| 342 | + } |
|
| 331 | 343 | echo "<tr><td$class>Signature ".($i+1)."</td><td$class>"; |
| 332 | 344 | $x = $r2->arraymem($i); |
| 333 | 345 | if ($x->kindOf()=="array") |
@@ -353,8 +365,7 @@ discard block |
||
| 353 | 365 | } |
| 354 | 366 | } |
| 355 | 367 | echo ")</code>"; |
| 356 | - } |
|
| 357 | - else |
|
| 368 | + } else |
|
| 358 | 369 | { |
| 359 | 370 | echo 'Unknown'; |
| 360 | 371 | } |
@@ -386,8 +397,9 @@ discard block |
||
| 386 | 397 | "<input type=\"hidden\" name=\"altmethodpayload\" value=\"".htmlspecialchars($alt_payload, ENT_COMPAT, $inputcharset)."\" />". |
| 387 | 398 | "<input type=\"hidden\" name=\"wstype\" value=\"$wstype\" />". |
| 388 | 399 | "<input type=\"hidden\" name=\"action\" value=\"execute\" />"; |
| 389 | - if ($wstype != 1) |
|
| 390 | - echo "<input type=\"submit\" value=\"Load method synopsis\" />"; |
|
| 400 | + if ($wstype != 1) { |
|
| 401 | + echo "<input type=\"submit\" value=\"Load method synopsis\" />"; |
|
| 402 | + } |
|
| 391 | 403 | echo "</form></td>\n"; |
| 392 | 404 | |
| 393 | 405 | echo "<td$class><form action=\"controller.php\" target=\"frmcontroller\" method=\"get\">". |
@@ -429,9 +441,9 @@ discard block |
||
| 429 | 441 | case 'wrap': |
| 430 | 442 | $r1 = $resp[0]->value(); |
| 431 | 443 | $r2 = $resp[1]->value(); |
| 432 | - if ($r2->kindOf()!="array" || $r2->arraysize() <= $methodsig) |
|
| 433 | - echo "Error: signature unknown\n"; |
|
| 434 | - else |
|
| 444 | + if ($r2->kindOf()!="array" || $r2->arraysize() <= $methodsig) { |
|
| 445 | + echo "Error: signature unknown\n"; |
|
| 446 | + } else |
|
| 435 | 447 | { |
| 436 | 448 | $mdesc = $r1->scalarval(); |
| 437 | 449 | $msig = php_xmlrpc_decode($r2); |
@@ -441,16 +453,14 @@ discard block |
||
| 441 | 453 | $clientcookies == '') |
| 442 | 454 | { |
| 443 | 455 | $opts = 0; // simple client copy in stub code |
| 444 | - } |
|
| 445 | - else |
|
| 456 | + } else |
|
| 446 | 457 | { |
| 447 | 458 | $opts = 1; // complete client copy in stub code |
| 448 | 459 | } |
| 449 | 460 | if ($wstype == 1) |
| 450 | 461 | { |
| 451 | 462 | $prefix = 'jsonrpc'; |
| 452 | - } |
|
| 453 | - else |
|
| 463 | + } else |
|
| 454 | 464 | { |
| 455 | 465 | $prefix = 'xmlrpc'; |
| 456 | 466 | } |
@@ -477,8 +487,7 @@ discard block |
||
| 477 | 487 | } |
| 478 | 488 | } // if !$response->faultCode() |
| 479 | 489 | } // if $response |
| 480 | - } |
|
| 481 | - else |
|
| 490 | + } else |
|
| 482 | 491 | { |
| 483 | 492 | // no action taken yet: give some instructions on debugger usage |
| 484 | 493 | ?> |
@@ -3,8 +3,9 @@ |
||
| 3 | 3 | if (isset($_GET['run'])) |
| 4 | 4 | { |
| 5 | 5 | $path = parse_url($_GET['run']); |
| 6 | - if (isset($path['query'])) |
|
| 7 | - $query = '?'.$path['query']; |
|
| 6 | + if (isset($path['query'])) { |
|
| 7 | + $query = '?'.$path['query']; |
|
| 8 | + } |
|
| 8 | 9 | } |
| 9 | 10 | ?> |
| 10 | 11 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | **/ |
| 15 | 15 | |
| 16 | 16 | include(dirname(__FILE__).'/common.php'); |
| 17 | - if ($action == '') |
|
| 18 | - $action = 'list'; |
|
| 17 | + if ($action == '') { |
|
| 18 | + $action = 'list'; |
|
| 19 | + } |
|
| 19 | 20 | |
| 20 | 21 | // relative path to the visual xmlrpc editing dialog |
| 21 | 22 | $editorpath = '../../javascript/debugger/'; |
@@ -214,7 +215,10 @@ discard block |
||
| 214 | 215 | //--> |
| 215 | 216 | </script> |
| 216 | 217 | </head> |
| 217 | -<body onload="switchtransport(<?php echo $wstype;?>); switchaction(); switchssl(); switchauth(); swicthcainfo();<?php if ($run) echo ' document.forms[2].submit();'; ?>"> |
|
| 218 | +<body onload="switchtransport(<?php echo $wstype;?>); switchaction(); switchssl(); switchauth(); swicthcainfo();<?php if ($run) { |
|
| 219 | + echo ' document.forms[2].submit();'; |
|
| 220 | +} |
|
| 221 | +?>"> |
|
| 218 | 222 | <h1>XMLRPC <form name="frmxmlrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(0);"/></form> |
| 219 | 223 | /<form name="frmjsonrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(1);"/></form>JSONRPC Debugger (based on the <a href="http://phpxmlrpc.sourceforge.net">PHP-XMLRPC</a> library)</h1> |
| 220 | 224 | <form name="frmaction" method="get" action="action.php" target="frmaction" onSubmit="switchFormMethod();" |
@@ -232,10 +236,22 @@ discard block |
||
| 232 | 236 | <table id="actionblock"> |
| 233 | 237 | <tr> |
| 234 | 238 | <td><h2>Action</h2></td> |
| 235 | -<td>List available methods<input type="radio" name="action" value="list"<?php if ($action=='list') echo ' checked="checked"'; ?> onclick="switchaction();" /></td> |
|
| 236 | -<td>Describe method<input type="radio" name="action" value="describe"<?php if ($action=='describe') echo ' checked="checked"'; ?> onclick="switchaction();" /></td> |
|
| 237 | -<td>Execute method<input type="radio" name="action" value="execute"<?php if ($action=='execute') echo ' checked="checked"'; ?> onclick="switchaction();" /></td> |
|
| 238 | -<td>Generate stub for method call<input type="radio" name="action" value="wrap"<?php if ($action=='wrap') echo ' checked="checked"'; ?> onclick="switchaction();" /></td> |
|
| 239 | +<td>List available methods<input type="radio" name="action" value="list"<?php if ($action=='list') { |
|
| 240 | + echo ' checked="checked"'; |
|
| 241 | +} |
|
| 242 | +?> onclick="switchaction();" /></td> |
|
| 243 | +<td>Describe method<input type="radio" name="action" value="describe"<?php if ($action=='describe') { |
|
| 244 | + echo ' checked="checked"'; |
|
| 245 | +} |
|
| 246 | +?> onclick="switchaction();" /></td> |
|
| 247 | +<td>Execute method<input type="radio" name="action" value="execute"<?php if ($action=='execute') { |
|
| 248 | + echo ' checked="checked"'; |
|
| 249 | +} |
|
| 250 | +?> onclick="switchaction();" /></td> |
|
| 251 | +<td>Generate stub for method call<input type="radio" name="action" value="wrap"<?php if ($action=='wrap') { |
|
| 252 | + echo ' checked="checked"'; |
|
| 253 | +} |
|
| 254 | +?> onclick="switchaction();" /></td> |
|
| 239 | 255 | </tr> |
| 240 | 256 | </table> |
| 241 | 257 | <input type="hidden" name="methodsig" value="<?php echo htmlspecialchars($methodsig, ENT_COMPAT, $inputcharset); ?>" /> |
@@ -255,16 +271,37 @@ discard block |
||
| 255 | 271 | <tr> |
| 256 | 272 | <td><h2>Client options</h2></td> |
| 257 | 273 | <td class="labelcell">Show debug info:</td><td><select name="debug"> |
| 258 | -<option value="0"<?php if ($debug == 0) echo ' selected="selected"'; ?>>No</option> |
|
| 259 | -<option value="1"<?php if ($debug == 1) echo ' selected="selected"'; ?>>Yes</option> |
|
| 260 | -<option value="2"<?php if ($debug == 2) echo ' selected="selected"'; ?>>More</option> |
|
| 274 | +<option value="0"<?php if ($debug == 0) { |
|
| 275 | + echo ' selected="selected"'; |
|
| 276 | +} |
|
| 277 | +?>>No</option> |
|
| 278 | +<option value="1"<?php if ($debug == 1) { |
|
| 279 | + echo ' selected="selected"'; |
|
| 280 | +} |
|
| 281 | +?>>Yes</option> |
|
| 282 | +<option value="2"<?php if ($debug == 2) { |
|
| 283 | + echo ' selected="selected"'; |
|
| 284 | +} |
|
| 285 | +?>>More</option> |
|
| 261 | 286 | </select> |
| 262 | 287 | </td> |
| 263 | -<td class="labelcell">Timeout:</td><td><input type="text" name="timeout" size="3" value="<?php if ($timeout > 0) echo $timeout; ?>" /></td> |
|
| 288 | +<td class="labelcell">Timeout:</td><td><input type="text" name="timeout" size="3" value="<?php if ($timeout > 0) { |
|
| 289 | + echo $timeout; |
|
| 290 | +} |
|
| 291 | +?>" /></td> |
|
| 264 | 292 | <td class="labelcell">Protocol:</td><td><select name="protocol" onchange="switchssl(); switchauth(); swicthcainfo();"> |
| 265 | -<option value="0"<?php if ($protocol == 0) echo ' selected="selected"'; ?>>HTTP 1.0</option> |
|
| 266 | -<option value="1"<?php if ($protocol == 1) echo ' selected="selected"'; ?>>HTTP 1.1</option> |
|
| 267 | -<option value="2"<?php if ($protocol == 2) echo ' selected="selected"'; ?>>HTTPS</option> |
|
| 293 | +<option value="0"<?php if ($protocol == 0) { |
|
| 294 | + echo ' selected="selected"'; |
|
| 295 | +} |
|
| 296 | +?>>HTTP 1.0</option> |
|
| 297 | +<option value="1"<?php if ($protocol == 1) { |
|
| 298 | + echo ' selected="selected"'; |
|
| 299 | +} |
|
| 300 | +?>>HTTP 1.1</option> |
|
| 301 | +<option value="2"<?php if ($protocol == 2) { |
|
| 302 | + echo ' selected="selected"'; |
|
| 303 | +} |
|
| 304 | +?>>HTTPS</option> |
|
| 268 | 305 | </select></td> |
| 269 | 306 | </tr> |
| 270 | 307 | <tr> |
@@ -272,20 +309,41 @@ discard block |
||
| 272 | 309 | <td class="labelcell">Username:</td><td><input type="text" name="username" value="<?php echo htmlspecialchars($username, ENT_COMPAT, $inputcharset); ?>" /></td> |
| 273 | 310 | <td class="labelcell">Pwd:</td><td><input type="password" name="password" value="<?php echo htmlspecialchars($password, ENT_COMPAT, $inputcharset); ?>" /></td> |
| 274 | 311 | <td class="labelcell">Type</td><td><select name="authtype"> |
| 275 | -<option value="1"<?php if ($authtype == 1) echo ' selected="selected"'; ?>>Basic</option> |
|
| 276 | -<option value="2"<?php if ($authtype == 2) echo ' selected="selected"'; ?>>Digest</option> |
|
| 277 | -<option value="8"<?php if ($authtype == 8) echo ' selected="selected"'; ?>>NTLM</option> |
|
| 312 | +<option value="1"<?php if ($authtype == 1) { |
|
| 313 | + echo ' selected="selected"'; |
|
| 314 | +} |
|
| 315 | +?>>Basic</option> |
|
| 316 | +<option value="2"<?php if ($authtype == 2) { |
|
| 317 | + echo ' selected="selected"'; |
|
| 318 | +} |
|
| 319 | +?>>Digest</option> |
|
| 320 | +<option value="8"<?php if ($authtype == 8) { |
|
| 321 | + echo ' selected="selected"'; |
|
| 322 | +} |
|
| 323 | +?>>NTLM</option> |
|
| 278 | 324 | </select></td> |
| 279 | 325 | <td></td> |
| 280 | 326 | </tr> |
| 281 | 327 | <tr> |
| 282 | 328 | <td class="labelcell">SSL:</td> |
| 283 | 329 | <td class="labelcell">Verify Host's CN:</td><td><select name="verifyhost"> |
| 284 | -<option value="0"<?php if ($verifyhost == 0) echo ' selected="selected"'; ?>>No</option> |
|
| 285 | -<option value="1"<?php if ($verifyhost == 1) echo ' selected="selected"'; ?>>Check CN existance</option> |
|
| 286 | -<option value="2"<?php if ($verifyhost == 2) echo ' selected="selected"'; ?>>Check CN match</option> |
|
| 330 | +<option value="0"<?php if ($verifyhost == 0) { |
|
| 331 | + echo ' selected="selected"'; |
|
| 332 | +} |
|
| 333 | +?>>No</option> |
|
| 334 | +<option value="1"<?php if ($verifyhost == 1) { |
|
| 335 | + echo ' selected="selected"'; |
|
| 336 | +} |
|
| 337 | +?>>Check CN existance</option> |
|
| 338 | +<option value="2"<?php if ($verifyhost == 2) { |
|
| 339 | + echo ' selected="selected"'; |
|
| 340 | +} |
|
| 341 | +?>>Check CN match</option> |
|
| 287 | 342 | </select></td> |
| 288 | -<td class="labelcell">Verify Cert:</td><td><input type="checkbox" value="1" name="verifypeer" onclick="swicthcainfo();"<?php if ($verifypeer) echo ' checked="checked"'; ?> /></td> |
|
| 343 | +<td class="labelcell">Verify Cert:</td><td><input type="checkbox" value="1" name="verifypeer" onclick="swicthcainfo();"<?php if ($verifypeer) { |
|
| 344 | + echo ' checked="checked"'; |
|
| 345 | +} |
|
| 346 | +?> /></td> |
|
| 289 | 347 | <td class="labelcell">CA Cert file:</td><td><input type="text" name="cainfo" value="<?php echo htmlspecialchars($cainfo, ENT_COMPAT, $inputcharset); ?>" /></td> |
| 290 | 348 | </tr> |
| 291 | 349 | <tr> |
@@ -297,15 +355,36 @@ discard block |
||
| 297 | 355 | <tr> |
| 298 | 356 | <td class="labelcell">COMPRESSION:</td> |
| 299 | 357 | <td class="labelcell">Request:</td><td><select name="requestcompression"> |
| 300 | -<option value="0"<?php if ($requestcompression == 0) echo ' selected="selected"'; ?>>None</option> |
|
| 301 | -<option value="1"<?php if ($requestcompression == 1) echo ' selected="selected"'; ?>>Gzip</option> |
|
| 302 | -<option value="2"<?php if ($requestcompression == 2) echo ' selected="selected"'; ?>>Deflate</option> |
|
| 358 | +<option value="0"<?php if ($requestcompression == 0) { |
|
| 359 | + echo ' selected="selected"'; |
|
| 360 | +} |
|
| 361 | +?>>None</option> |
|
| 362 | +<option value="1"<?php if ($requestcompression == 1) { |
|
| 363 | + echo ' selected="selected"'; |
|
| 364 | +} |
|
| 365 | +?>>Gzip</option> |
|
| 366 | +<option value="2"<?php if ($requestcompression == 2) { |
|
| 367 | + echo ' selected="selected"'; |
|
| 368 | +} |
|
| 369 | +?>>Deflate</option> |
|
| 303 | 370 | </select></td> |
| 304 | 371 | <td class="labelcell">Response:</td><td><select name="responsecompression"> |
| 305 | -<option value="0"<?php if ($responsecompression == 0) echo ' selected="selected"'; ?>>None</option> |
|
| 306 | -<option value="1"<?php if ($responsecompression == 1) echo ' selected="selected"'; ?>>Gzip</option> |
|
| 307 | -<option value="2"<?php if ($responsecompression == 2) echo ' selected="selected"'; ?>>Deflate</option> |
|
| 308 | -<option value="3"<?php if ($responsecompression == 3) echo ' selected="selected"'; ?>>Any</option> |
|
| 372 | +<option value="0"<?php if ($responsecompression == 0) { |
|
| 373 | + echo ' selected="selected"'; |
|
| 374 | +} |
|
| 375 | +?>>None</option> |
|
| 376 | +<option value="1"<?php if ($responsecompression == 1) { |
|
| 377 | + echo ' selected="selected"'; |
|
| 378 | +} |
|
| 379 | +?>>Gzip</option> |
|
| 380 | +<option value="2"<?php if ($responsecompression == 2) { |
|
| 381 | + echo ' selected="selected"'; |
|
| 382 | +} |
|
| 383 | +?>>Deflate</option> |
|
| 384 | +<option value="3"<?php if ($responsecompression == 3) { |
|
| 385 | + echo ' selected="selected"'; |
|
| 386 | +} |
|
| 387 | +?>>Any</option> |
|
| 309 | 388 | </select></td> |
| 310 | 389 | <td></td> |
| 311 | 390 | </tr> |
@@ -28,8 +28,7 @@ discard block |
||
| 28 | 28 | if(dba_exists($countID, $dbh)) |
| 29 | 29 | { |
| 30 | 30 | $count=dba_fetch($countID, $dbh); |
| 31 | - } |
|
| 32 | - else |
|
| 31 | + } else |
|
| 33 | 32 | { |
| 34 | 33 | $count=0; |
| 35 | 34 | } |
@@ -48,8 +47,7 @@ discard block |
||
| 48 | 47 | if($err) |
| 49 | 48 | { |
| 50 | 49 | return new xmlrpcresp(0, $xmlrpcerruser, $err); |
| 51 | - } |
|
| 52 | - else |
|
| 50 | + } else |
|
| 53 | 51 | { |
| 54 | 52 | // otherwise, we create the right response |
| 55 | 53 | // with the state name |
@@ -72,8 +70,7 @@ discard block |
||
| 72 | 70 | if(XMLRPC_EPI_ENABLED == '1') |
| 73 | 71 | { |
| 74 | 72 | $msgID=xmlrpc_decode($m->getParam(0)); |
| 75 | - } |
|
| 76 | - else |
|
| 73 | + } else |
|
| 77 | 74 | { |
| 78 | 75 | $msgID=php_xmlrpc_decode($m->getParam(0)); |
| 79 | 76 | } |
@@ -100,8 +97,7 @@ discard block |
||
| 100 | 97 | if($err) |
| 101 | 98 | { |
| 102 | 99 | return new xmlrpcresp(0, $xmlrpcerruser, $err); |
| 103 | - } |
|
| 104 | - else |
|
| 100 | + } else |
|
| 105 | 101 | { |
| 106 | 102 | // otherwise, we create the right response |
| 107 | 103 | // with the state name |