@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | $server = $parts['host']; |
294 | 294 | $path = isset($parts['path']) ? $parts['path'] : ''; |
295 | 295 | if (isset($parts['query'])) { |
296 | - $path .= '?' . $parts['query']; |
|
296 | + $path .= '?'.$parts['query']; |
|
297 | 297 | } |
298 | 298 | if (isset($parts['fragment'])) { |
299 | - $path .= '#' . $parts['fragment']; |
|
299 | + $path .= '#'.$parts['fragment']; |
|
300 | 300 | } |
301 | 301 | if (isset($parts['port'])) { |
302 | 302 | $port = $parts['port']; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | } |
313 | 313 | } |
314 | 314 | if ($path == '' || $path[0] != '/') { |
315 | - $this->path = '/' . $path; |
|
315 | + $this->path = '/'.$path; |
|
316 | 316 | } else { |
317 | 317 | $this->path = $path; |
318 | 318 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | //$this->accepted_charset_encodings = $ch->knownCharsets(); |
345 | 345 | |
346 | 346 | // initialize user_agent string |
347 | - $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion; |
|
347 | + $this->user_agent = PhpXmlRpc::$xmlrpcName.' '.PhpXmlRpc::$xmlrpcVersion; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | */ |
771 | 771 | protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '', |
772 | 772 | $authType = 1, $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
773 | - $method='http') |
|
773 | + $method = 'http') |
|
774 | 774 | { |
775 | 775 | //trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED); |
776 | 776 | |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | * @param int $sslVersion |
804 | 804 | * @return Response |
805 | 805 | */ |
806 | - protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '', |
|
806 | + protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '', |
|
807 | 807 | $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0, |
808 | 808 | $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $keepAlive = false, $key = '', $keyPass = '', |
809 | 809 | $sslVersion = 0) |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | */ |
843 | 843 | protected function sendPayloadSocket($req, $server, $port, $timeout = 0, $username = '', $password = '', |
844 | 844 | $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0, |
845 | - $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method='http', $key = '', $keyPass = '', |
|
845 | + $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'http', $key = '', $keyPass = '', |
|
846 | 846 | $sslVersion = 0) |
847 | 847 | { |
848 | 848 | /// @todo log a warning if passed an unsupported method |
@@ -879,16 +879,16 @@ discard block |
||
879 | 879 | // thanks to Grant Rauscher <[email protected]> for this |
880 | 880 | $credentials = ''; |
881 | 881 | if ($username != '') { |
882 | - $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; |
|
882 | + $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n"; |
|
883 | 883 | if ($authType != 1) { |
884 | 884 | /// @todo make this a proper error, i.e. return a failure |
885 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0'); |
|
885 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0'); |
|
886 | 886 | } |
887 | 887 | } |
888 | 888 | |
889 | 889 | $acceptedEncoding = ''; |
890 | 890 | if (is_array($this->accepted_compression) && count($this->accepted_compression)) { |
891 | - $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; |
|
891 | + $acceptedEncoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n"; |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | $proxyCredentials = ''; |
@@ -900,13 +900,13 @@ discard block |
||
900 | 900 | $connectPort = $proxyPort; |
901 | 901 | $transport = 'tcp'; |
902 | 902 | /// @todo check: should we not use https in some cases? |
903 | - $uri = 'http://' . $server . ':' . $port . $this->path; |
|
903 | + $uri = 'http://'.$server.':'.$port.$this->path; |
|
904 | 904 | if ($proxyUsername != '') { |
905 | 905 | if ($proxyAuthType != 1) { |
906 | 906 | /// @todo make this a proper error, i.e. return a failure |
907 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
907 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
908 | 908 | } |
909 | - $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n"; |
|
909 | + $proxyCredentials = 'Proxy-Authorization: Basic '.base64_encode($proxyUsername.':'.$proxyPassword)."\r\n"; |
|
910 | 910 | } |
911 | 911 | } else { |
912 | 912 | $connectServer = $server; |
@@ -921,45 +921,45 @@ discard block |
||
921 | 921 | $version = ''; |
922 | 922 | foreach ($this->cookies as $name => $cookie) { |
923 | 923 | if ($cookie['version']) { |
924 | - $version = ' $Version="' . $cookie['version'] . '";'; |
|
925 | - $cookieHeader .= ' ' . $name . '="' . $cookie['value'] . '";'; |
|
924 | + $version = ' $Version="'.$cookie['version'].'";'; |
|
925 | + $cookieHeader .= ' '.$name.'="'.$cookie['value'].'";'; |
|
926 | 926 | if ($cookie['path']) { |
927 | - $cookieHeader .= ' $Path="' . $cookie['path'] . '";'; |
|
927 | + $cookieHeader .= ' $Path="'.$cookie['path'].'";'; |
|
928 | 928 | } |
929 | 929 | if ($cookie['domain']) { |
930 | - $cookieHeader .= ' $Domain="' . $cookie['domain'] . '";'; |
|
930 | + $cookieHeader .= ' $Domain="'.$cookie['domain'].'";'; |
|
931 | 931 | } |
932 | 932 | if ($cookie['port']) { |
933 | - $cookieHeader .= ' $Port="' . $cookie['port'] . '";'; |
|
933 | + $cookieHeader .= ' $Port="'.$cookie['port'].'";'; |
|
934 | 934 | } |
935 | 935 | } else { |
936 | - $cookieHeader .= ' ' . $name . '=' . $cookie['value'] . ";"; |
|
936 | + $cookieHeader .= ' '.$name.'='.$cookie['value'].";"; |
|
937 | 937 | } |
938 | 938 | } |
939 | - $cookieHeader = 'Cookie:' . $version . substr($cookieHeader, 0, -1) . "\r\n"; |
|
939 | + $cookieHeader = 'Cookie:'.$version.substr($cookieHeader, 0, -1)."\r\n"; |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | // omit port if default |
943 | 943 | if (($port == 80 && in_array($method, array('http', 'http10'))) || ($port == 443 && $method == 'https')) { |
944 | - $port = ''; |
|
944 | + $port = ''; |
|
945 | 945 | } else { |
946 | - $port = ':' . $port; |
|
946 | + $port = ':'.$port; |
|
947 | 947 | } |
948 | 948 | |
949 | - $op = 'POST ' . $uri . " HTTP/1.0\r\n" . |
|
950 | - 'User-Agent: ' . $this->user_agent . "\r\n" . |
|
951 | - 'Host: ' . $server . $port . "\r\n" . |
|
952 | - $credentials . |
|
953 | - $proxyCredentials . |
|
954 | - $acceptedEncoding . |
|
955 | - $encodingHdr . |
|
956 | - 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . |
|
957 | - $cookieHeader . |
|
958 | - 'Content-Type: ' . $req->content_type . "\r\nContent-Length: " . |
|
959 | - strlen($payload) . "\r\n\r\n" . |
|
949 | + $op = 'POST '.$uri." HTTP/1.0\r\n". |
|
950 | + 'User-Agent: '.$this->user_agent."\r\n". |
|
951 | + 'Host: '.$server.$port."\r\n". |
|
952 | + $credentials. |
|
953 | + $proxyCredentials. |
|
954 | + $acceptedEncoding. |
|
955 | + $encodingHdr. |
|
956 | + 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)."\r\n". |
|
957 | + $cookieHeader. |
|
958 | + 'Content-Type: '.$req->content_type."\r\nContent-Length: ". |
|
959 | + strlen($payload)."\r\n\r\n". |
|
960 | 960 | $payload; |
961 | 961 | |
962 | - if ($this->debug > 1) { |
|
962 | + if ($this->debug>1) { |
|
963 | 963 | $this->getLogger()->debugMessage("---SENDING---\n$op\n---END---"); |
964 | 964 | } |
965 | 965 | |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | |
987 | 987 | $context = stream_context_create($contextOptions); |
988 | 988 | |
989 | - if ($timeout <= 0) { |
|
989 | + if ($timeout<=0) { |
|
990 | 990 | $connectTimeout = ini_get('default_socket_timeout'); |
991 | 991 | } else { |
992 | 992 | $connectTimeout = $timeout; |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $connectTimeout, |
999 | 999 | STREAM_CLIENT_CONNECT, $context); |
1000 | 1000 | if ($fp) { |
1001 | - if ($timeout > 0) { |
|
1001 | + if ($timeout>0) { |
|
1002 | 1002 | stream_set_timeout($fp, $timeout, 0); |
1003 | 1003 | } |
1004 | 1004 | } else { |
@@ -1007,8 +1007,8 @@ discard block |
||
1007 | 1007 | $this->errstr = $err['message']; |
1008 | 1008 | } |
1009 | 1009 | |
1010 | - $this->errstr = 'Connect error: ' . $this->errstr; |
|
1011 | - $r = new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')'); |
|
1010 | + $this->errstr = 'Connect error: '.$this->errstr; |
|
1011 | + $r = new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr.' ('.$this->errno.')'); |
|
1012 | 1012 | |
1013 | 1013 | return $r; |
1014 | 1014 | } |
@@ -1096,18 +1096,18 @@ discard block |
||
1096 | 1096 | $keyPass, $sslVersion); |
1097 | 1097 | |
1098 | 1098 | if (!$curl) { |
1099 | - return new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': error during curl initialization. Check php error log for details'); |
|
1099 | + return new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': error during curl initialization. Check php error log for details'); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | $result = curl_exec($curl); |
1103 | 1103 | |
1104 | - if ($this->debug > 1) { |
|
1104 | + if ($this->debug>1) { |
|
1105 | 1105 | $message = "---CURL INFO---\n"; |
1106 | 1106 | foreach (curl_getinfo($curl) as $name => $val) { |
1107 | 1107 | if (is_array($val)) { |
1108 | 1108 | $val = implode("\n", $val); |
1109 | 1109 | } |
1110 | - $message .= $name . ': ' . $val . "\n"; |
|
1110 | + $message .= $name.': '.$val."\n"; |
|
1111 | 1111 | } |
1112 | 1112 | $message .= '---END---'; |
1113 | 1113 | $this->getLogger()->debugMessage($message); |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | /// @todo we should use a better check here - what if we get back '' or '0'? |
1118 | 1118 | |
1119 | 1119 | $this->errstr = 'no response'; |
1120 | - $resp = new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl)); |
|
1120 | + $resp = new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl)); |
|
1121 | 1121 | curl_close($curl); |
1122 | 1122 | if ($keepAlive) { |
1123 | 1123 | $this->xmlrpc_curl_handle = null; |
@@ -1187,12 +1187,12 @@ discard block |
||
1187 | 1187 | // http, https |
1188 | 1188 | $protocol = $method; |
1189 | 1189 | if (strpos($protocol, ':') !== false) { |
1190 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'"); |
|
1190 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'"); |
|
1191 | 1191 | return false; |
1192 | 1192 | } |
1193 | 1193 | } |
1194 | 1194 | } |
1195 | - $curl = curl_init($protocol . '://' . $server . ':' . $port . $this->path); |
|
1195 | + $curl = curl_init($protocol.'://'.$server.':'.$port.$this->path); |
|
1196 | 1196 | if (!$curl) { |
1197 | 1197 | return false; |
1198 | 1198 | } |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | // results into variable |
1207 | 1207 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
1208 | 1208 | |
1209 | - if ($this->debug > 1) { |
|
1209 | + if ($this->debug>1) { |
|
1210 | 1210 | curl_setopt($curl, CURLOPT_VERBOSE, true); |
1211 | 1211 | /// @todo redirect curlopt_stderr to some stream which can be piped to the logger |
1212 | 1212 | } |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | } |
1232 | 1232 | } |
1233 | 1233 | // extra headers |
1234 | - $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); |
|
1234 | + $headers = array('Content-Type: '.$req->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)); |
|
1235 | 1235 | // if no keepalive is wanted, let the server know it in advance |
1236 | 1236 | if (!$keepAlive) { |
1237 | 1237 | $headers[] = 'Connection: close'; |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
1249 | 1249 | // timeout is borked |
1250 | 1250 | if ($timeout) { |
1251 | - curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); |
|
1251 | + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | switch ($method) { |
@@ -1263,7 +1263,7 @@ discard block |
||
1263 | 1263 | curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE); |
1264 | 1264 | } else { |
1265 | 1265 | /// @todo make this a proper error, i.e. return a failure |
1266 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. HTTP2 is not supported by the current PHP/curl install'); |
|
1266 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. HTTP2 is not supported by the current PHP/curl install'); |
|
1267 | 1267 | } |
1268 | 1268 | break; |
1269 | 1269 | case 'h2': |
@@ -1272,12 +1272,12 @@ discard block |
||
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | if ($username && $password) { |
1275 | - curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password); |
|
1275 | + curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); |
|
1276 | 1276 | if (defined('CURLOPT_HTTPAUTH')) { |
1277 | 1277 | curl_setopt($curl, CURLOPT_HTTPAUTH, $authType); |
1278 | 1278 | } elseif ($authType != 1) { |
1279 | 1279 | /// @todo make this a proper error, i.e. return a failure |
1280 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
1280 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
1281 | 1281 | } |
1282 | 1282 | } |
1283 | 1283 | |
@@ -1320,14 +1320,14 @@ discard block |
||
1320 | 1320 | if ($proxyPort == 0) { |
1321 | 1321 | $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080 |
1322 | 1322 | } |
1323 | - curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort); |
|
1323 | + curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$proxyPort); |
|
1324 | 1324 | if ($proxyUsername) { |
1325 | - curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword); |
|
1325 | + curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername.':'.$proxyPassword); |
|
1326 | 1326 | if (defined('CURLOPT_PROXYAUTH')) { |
1327 | 1327 | curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType); |
1328 | 1328 | } elseif ($proxyAuthType != 1) { |
1329 | 1329 | /// @todo make this a proper error, i.e. return a failure |
1330 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
1330 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
1331 | 1331 | } |
1332 | 1332 | } |
1333 | 1333 | } |
@@ -1337,7 +1337,7 @@ discard block |
||
1337 | 1337 | if (count($this->cookies)) { |
1338 | 1338 | $cookieHeader = ''; |
1339 | 1339 | foreach ($this->cookies as $name => $cookie) { |
1340 | - $cookieHeader .= $name . '=' . $cookie['value'] . '; '; |
|
1340 | + $cookieHeader .= $name.'='.$cookie['value'].'; '; |
|
1341 | 1341 | } |
1342 | 1342 | curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2)); |
1343 | 1343 | } |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | curl_setopt($curl, $opt, $val); |
1347 | 1347 | } |
1348 | 1348 | |
1349 | - if ($this->debug > 1) { |
|
1349 | + if ($this->debug>1) { |
|
1350 | 1350 | $this->getLogger()->debugMessage("---SENDING---\n$payload\n---END---"); |
1351 | 1351 | } |
1352 | 1352 | |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | $call['methodName'] = new Value($req->method(), 'string'); |
1438 | 1438 | $numParams = $req->getNumParams(); |
1439 | 1439 | $params = array(); |
1440 | - for ($i = 0; $i < $numParams; $i++) { |
|
1440 | + for ($i = 0; $i<$numParams; $i++) { |
|
1441 | 1441 | $params[$i] = $req->getParam($i); |
1442 | 1442 | } |
1443 | 1443 | $call['params'] = new Value($params, 'array'); |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | $response = array(); |
1460 | 1460 | |
1461 | 1461 | if ($this->return_type == 'xml') { |
1462 | - for ($i = 0; $i < count($reqs); $i++) { |
|
1462 | + for ($i = 0; $i<count($reqs); $i++) { |
|
1463 | 1463 | $response[] = new Response($rets, 0, '', 'xml', $result->httpResponse()); |
1464 | 1464 | } |
1465 | 1465 | |
@@ -1467,21 +1467,21 @@ discard block |
||
1467 | 1467 | if (!is_array($rets)) { |
1468 | 1468 | // bad return type from system.multicall |
1469 | 1469 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1470 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': not an array', 'phpvals', $result->httpResponse()); |
|
1470 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': not an array', 'phpvals', $result->httpResponse()); |
|
1471 | 1471 | } |
1472 | 1472 | $numRets = count($rets); |
1473 | 1473 | if ($numRets != count($reqs)) { |
1474 | 1474 | // wrong number of return values. |
1475 | 1475 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1476 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': incorrect number of responses', 'phpvals', |
|
1476 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': incorrect number of responses', 'phpvals', |
|
1477 | 1477 | $result->httpResponse()); |
1478 | 1478 | } |
1479 | 1479 | |
1480 | - for ($i = 0; $i < $numRets; $i++) { |
|
1480 | + for ($i = 0; $i<$numRets; $i++) { |
|
1481 | 1481 | $val = $rets[$i]; |
1482 | 1482 | if (!is_array($val)) { |
1483 | 1483 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1484 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array or struct", |
|
1484 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array or struct", |
|
1485 | 1485 | 'phpvals', $result->httpResponse()); |
1486 | 1486 | } |
1487 | 1487 | switch (count($val)) { |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | if (!isset($val[0])) { |
1490 | 1490 | // Bad value |
1491 | 1491 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1492 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has no value", |
|
1492 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has no value", |
|
1493 | 1493 | 'phpvals', $result->httpResponse()); |
1494 | 1494 | } |
1495 | 1495 | // Normal return value |
@@ -1501,20 +1501,20 @@ discard block |
||
1501 | 1501 | if (!is_int($code)) { |
1502 | 1502 | /// @todo should we check that it is != 0? |
1503 | 1503 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1504 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
1504 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
1505 | 1505 | 'phpvals', $result->httpResponse()); |
1506 | 1506 | } |
1507 | 1507 | $str = @$val['faultString']; |
1508 | 1508 | if (!is_string($str)) { |
1509 | 1509 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1510 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no FaultString", |
|
1510 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no FaultString", |
|
1511 | 1511 | 'phpvals', $result->httpResponse()); |
1512 | 1512 | } |
1513 | 1513 | $response[$i] = new Response(0, $code, $str, 'phpvals', $result->httpResponse()); |
1514 | 1514 | break; |
1515 | 1515 | default: |
1516 | 1516 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1517 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
1517 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
1518 | 1518 | 'phpvals', $result->httpResponse()); |
1519 | 1519 | } |
1520 | 1520 | } |
@@ -1523,14 +1523,14 @@ discard block |
||
1523 | 1523 | // return type == 'xmlrpcvals' |
1524 | 1524 | if ($rets->kindOf() != 'array') { |
1525 | 1525 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1526 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array", 'xmlrpcvals', |
|
1526 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array", 'xmlrpcvals', |
|
1527 | 1527 | $result->httpResponse()); |
1528 | 1528 | } |
1529 | 1529 | $numRets = $rets->count(); |
1530 | 1530 | if ($numRets != count($reqs)) { |
1531 | 1531 | // wrong number of return values. |
1532 | 1532 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1533 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': incorrect number of responses', 'xmlrpcvals', |
|
1533 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': incorrect number of responses', 'xmlrpcvals', |
|
1534 | 1534 | $result->httpResponse()); |
1535 | 1535 | } |
1536 | 1536 | |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | case 'array': |
1540 | 1540 | if ($val->count() != 1) { |
1541 | 1541 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1542 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
1542 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
1543 | 1543 | 'phpvals', $result->httpResponse()); |
1544 | 1544 | } |
1545 | 1545 | // Normal return value |
@@ -1548,28 +1548,28 @@ discard block |
||
1548 | 1548 | case 'struct': |
1549 | 1549 | if ($val->count() != 2) { |
1550 | 1550 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1551 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
1551 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
1552 | 1552 | 'phpvals', $result->httpResponse()); |
1553 | 1553 | } |
1554 | 1554 | /** @var Value $code */ |
1555 | 1555 | $code = $val['faultCode']; |
1556 | 1556 | if ($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') { |
1557 | 1557 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1558 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
1558 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
1559 | 1559 | 'xmlrpcvals', $result->httpResponse()); |
1560 | 1560 | } |
1561 | 1561 | /** @var Value $str */ |
1562 | 1562 | $str = $val['faultString']; |
1563 | 1563 | if ($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') { |
1564 | 1564 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1565 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
1565 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
1566 | 1566 | 'xmlrpcvals', $result->httpResponse()); |
1567 | 1567 | } |
1568 | 1568 | $response[] = new Response(0, $code->scalarval(), $str->scalarval(), 'xmlrpcvals', $result->httpResponse()); |
1569 | 1569 | break; |
1570 | 1570 | default: |
1571 | 1571 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
1572 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array or struct", |
|
1572 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array or struct", |
|
1573 | 1573 | 'xmlrpcvals', $result->httpResponse()); |
1574 | 1574 | } |
1575 | 1575 | } |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | public function xml_header($charsetEncoding = '') |
110 | 110 | { |
111 | 111 | if ($charsetEncoding != '') { |
112 | - return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n"; |
|
112 | + return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?".">\n<methodCall>\n"; |
|
113 | 113 | } else { |
114 | - return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; |
|
114 | + return "<?xml version=\"1.0\"?".">\n<methodCall>\n"; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -134,16 +134,16 @@ discard block |
||
134 | 134 | public function createPayload($charsetEncoding = '') |
135 | 135 | { |
136 | 136 | if ($charsetEncoding != '') { |
137 | - $this->content_type = 'text/xml; charset=' . $charsetEncoding; |
|
137 | + $this->content_type = 'text/xml; charset='.$charsetEncoding; |
|
138 | 138 | } else { |
139 | 139 | $this->content_type = 'text/xml'; |
140 | 140 | } |
141 | 141 | $this->payload = $this->xml_header($charsetEncoding); |
142 | - $this->payload .= '<methodName>' . $this->getCharsetEncoder()->encodeEntities( |
|
143 | - $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n"; |
|
142 | + $this->payload .= '<methodName>'.$this->getCharsetEncoder()->encodeEntities( |
|
143 | + $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</methodName>\n"; |
|
144 | 144 | $this->payload .= "<params>\n"; |
145 | 145 | foreach ($this->params as $p) { |
146 | - $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) . |
|
146 | + $this->payload .= "<param>\n".$p->serialize($charsetEncoding). |
|
147 | 147 | "</param>\n"; |
148 | 148 | } |
149 | 149 | $this->payload .= "</params>\n"; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function parseResponse($data = '', $headersProcessed = false, $returnType = XMLParser::RETURN_XMLRPCVALS) |
260 | 260 | { |
261 | - if ($this->debug > 0) { |
|
261 | + if ($this->debug>0) { |
|
262 | 262 | $this->getLogger()->debugMessage("---GOT---\n$data\n---END---"); |
263 | 263 | } |
264 | 264 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $this->httpResponse = $httpResponse; |
267 | 267 | |
268 | 268 | if ($data == '') { |
269 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': no response received from server.'); |
|
269 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': no response received from server.'); |
|
270 | 270 | return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']); |
271 | 271 | } |
272 | 272 | |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | if (substr($data, 0, 4) == 'HTTP') { |
275 | 275 | $httpParser = new Http(); |
276 | 276 | try { |
277 | - $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug > 0); |
|
277 | + $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug>0); |
|
278 | 278 | } catch (HttpException $e) { |
279 | 279 | // failed processing of HTTP response headers |
280 | 280 | // save into response obj the full payload received, for debugging |
281 | 281 | return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data, 'status_code', $e->statusCode())); |
282 | - } catch(\Exception $e) { |
|
282 | + } catch (\Exception $e) { |
|
283 | 283 | return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data)); |
284 | 284 | } |
285 | 285 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib |
294 | 294 | $pos = strrpos($data, '</methodResponse>'); |
295 | 295 | if ($pos !== false) { |
296 | - $data = substr($data, 0, $pos + 17); |
|
296 | + $data = substr($data, 0, $pos+17); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | // try to 'guestimate' the character encoding of the received response |
@@ -302,20 +302,20 @@ discard block |
||
302 | 302 | $data |
303 | 303 | ); |
304 | 304 | |
305 | - if ($this->debug >= 0) { |
|
305 | + if ($this->debug>=0) { |
|
306 | 306 | $this->httpResponse = $httpResponse; |
307 | 307 | } else { |
308 | 308 | $httpResponse = null; |
309 | 309 | } |
310 | 310 | |
311 | - if ($this->debug > 0) { |
|
311 | + if ($this->debug>0) { |
|
312 | 312 | $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
313 | 313 | if ($start) { |
314 | 314 | $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
315 | 315 | $end = strpos($data, '-->', $start); |
316 | - $comments = substr($data, $start, $end - $start); |
|
317 | - $this->getLogger()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t" . |
|
318 | - str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", $respEncoding); |
|
316 | + $comments = substr($data, $start, $end-$start); |
|
317 | + $this->getLogger()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t". |
|
318 | + str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", $respEncoding); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | if ($respEncoding == 'ISO-8859-1') { |
338 | 338 | $data = utf8_encode($data); |
339 | 339 | } else { |
340 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received response: ' . $respEncoding); |
|
340 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': unsupported charset encoding of received response: '.$respEncoding); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | } |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | // there could be proxies meddling with the request, or network data corruption... |
364 | 364 | |
365 | 365 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_xml'], |
366 | - PhpXmlRpc::$xmlrpcstr['invalid_xml'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', |
|
366 | + PhpXmlRpc::$xmlrpcstr['invalid_xml'].' '.$xmlRpcParser->_xh['isf_reason'], '', |
|
367 | 367 | $httpResponse |
368 | 368 | ); |
369 | 369 | |
370 | - if ($this->debug > 0) { |
|
370 | + if ($this->debug>0) { |
|
371 | 371 | $this->getLogger()->debugMessage($xmlRpcParser->_xh['isf_reason']); |
372 | 372 | } |
373 | 373 | } |
374 | 374 | // second error check: xml well-formed but not xml-rpc compliant |
375 | 375 | elseif ($xmlRpcParser->_xh['isf'] == 2) { |
376 | 376 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_not_compliant'], |
377 | - PhpXmlRpc::$xmlrpcstr['xml_not_compliant'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', |
|
377 | + PhpXmlRpc::$xmlrpcstr['xml_not_compliant'].' '.$xmlRpcParser->_xh['isf_reason'], '', |
|
378 | 378 | $httpResponse |
379 | 379 | ); |
380 | 380 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | // third error check: parsing of the response has somehow gone boink. |
387 | 387 | /// @todo shall we omit this check, since we trust the parsing code? |
388 | - elseif ($xmlRpcParser->_xh['isf'] > 3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) { |
|
388 | + elseif ($xmlRpcParser->_xh['isf']>3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) { |
|
389 | 389 | // something odd has happened and it's time to generate a client side error indicating something odd went on |
390 | 390 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_parsing_error'], PhpXmlRpc::$xmlrpcstr['xml_parsing_error'], |
391 | 391 | '', $httpResponse |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /// @todo echo something for the user? |
395 | 395 | } else { |
396 | - if ($this->debug > 1) { |
|
396 | + if ($this->debug>1) { |
|
397 | 397 | $this->getLogger()->debugMessage( |
398 | 398 | "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---" |
399 | 399 | ); |