@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | $server = $parts['host']; |
137 | 137 | $path = isset($parts['path']) ? $parts['path'] : ''; |
138 | 138 | if (isset($parts['query'])) { |
139 | - $path .= '?' . $parts['query']; |
|
139 | + $path .= '?'.$parts['query']; |
|
140 | 140 | } |
141 | 141 | if (isset($parts['fragment'])) { |
142 | - $path .= '#' . $parts['fragment']; |
|
142 | + $path .= '#'.$parts['fragment']; |
|
143 | 143 | } |
144 | 144 | if (isset($parts['port'])) { |
145 | 145 | $port = $parts['port']; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | if ($path == '' || $path[0] != '/') { |
158 | - $this->path = '/' . $path; |
|
158 | + $this->path = '/'.$path; |
|
159 | 159 | } else { |
160 | 160 | $this->path = $path; |
161 | 161 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | }*/ |
194 | 194 | |
195 | 195 | // initialize user_agent string |
196 | - $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion; |
|
196 | + $this->user_agent = PhpXmlRpc::$xmlrpcName.' '.PhpXmlRpc::$xmlrpcVersion; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | */ |
567 | 567 | protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '', |
568 | 568 | $authType = 1, $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
569 | - $method='http') |
|
569 | + $method = 'http') |
|
570 | 570 | { |
571 | 571 | return $this->sendPayloadSocket($req, $server, $port, $timeout, $username, $password, $authType, null, null, |
572 | 572 | null, null, $proxyHost, $proxyPort, $proxyUsername, $proxyPassword, $proxyAuthType); |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * @param int $sslVersion |
597 | 597 | * @return Response |
598 | 598 | */ |
599 | - protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '', |
|
599 | + protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '', |
|
600 | 600 | $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0, |
601 | 601 | $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $keepAlive = false, $key = '', $keyPass = '', |
602 | 602 | $sslVersion = 0) |
@@ -631,11 +631,11 @@ discard block |
||
631 | 631 | */ |
632 | 632 | protected function sendPayloadSocket($req, $server, $port, $timeout = 0, $username = '', $password = '', |
633 | 633 | $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0, |
634 | - $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method='http', $key = '', $keyPass = '', |
|
634 | + $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'http', $key = '', $keyPass = '', |
|
635 | 635 | $sslVersion = 0) |
636 | 636 | { |
637 | 637 | if ($port == 0) { |
638 | - $port = ( $method === 'https' ) ? 443 : 80; |
|
638 | + $port = ($method === 'https') ? 443 : 80; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | // Only create the payload if it was not created previously |
@@ -666,15 +666,15 @@ discard block |
||
666 | 666 | // thanks to Grant Rauscher <[email protected]> for this |
667 | 667 | $credentials = ''; |
668 | 668 | if ($username != '') { |
669 | - $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; |
|
669 | + $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n"; |
|
670 | 670 | if ($authType != 1) { |
671 | - error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0'); |
|
671 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0'); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | |
675 | 675 | $acceptedEncoding = ''; |
676 | 676 | if (is_array($this->accepted_compression) && count($this->accepted_compression)) { |
677 | - $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; |
|
677 | + $acceptedEncoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n"; |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | $proxyCredentials = ''; |
@@ -685,17 +685,17 @@ discard block |
||
685 | 685 | $connectServer = $proxyHost; |
686 | 686 | $connectPort = $proxyPort; |
687 | 687 | $transport = 'tcp'; |
688 | - $uri = 'http://' . $server . ':' . $port . $this->path; |
|
688 | + $uri = 'http://'.$server.':'.$port.$this->path; |
|
689 | 689 | if ($proxyUsername != '') { |
690 | 690 | if ($proxyAuthType != 1) { |
691 | - error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
691 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
692 | 692 | } |
693 | - $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n"; |
|
693 | + $proxyCredentials = 'Proxy-Authorization: Basic '.base64_encode($proxyUsername.':'.$proxyPassword)."\r\n"; |
|
694 | 694 | } |
695 | 695 | } else { |
696 | 696 | $connectServer = $server; |
697 | 697 | $connectPort = $port; |
698 | - $transport = ( $method === 'https' ) ? 'tls' : 'tcp'; |
|
698 | + $transport = ($method === 'https') ? 'tls' : 'tcp'; |
|
699 | 699 | $uri = $this->path; |
700 | 700 | } |
701 | 701 | |
@@ -706,45 +706,45 @@ discard block |
||
706 | 706 | $version = ''; |
707 | 707 | foreach ($this->cookies as $name => $cookie) { |
708 | 708 | if ($cookie['version']) { |
709 | - $version = ' $Version="' . $cookie['version'] . '";'; |
|
710 | - $cookieHeader .= ' ' . $name . '="' . $cookie['value'] . '";'; |
|
709 | + $version = ' $Version="'.$cookie['version'].'";'; |
|
710 | + $cookieHeader .= ' '.$name.'="'.$cookie['value'].'";'; |
|
711 | 711 | if ($cookie['path']) { |
712 | - $cookieHeader .= ' $Path="' . $cookie['path'] . '";'; |
|
712 | + $cookieHeader .= ' $Path="'.$cookie['path'].'";'; |
|
713 | 713 | } |
714 | 714 | if ($cookie['domain']) { |
715 | - $cookieHeader .= ' $Domain="' . $cookie['domain'] . '";'; |
|
715 | + $cookieHeader .= ' $Domain="'.$cookie['domain'].'";'; |
|
716 | 716 | } |
717 | 717 | if ($cookie['port']) { |
718 | - $cookieHeader .= ' $Port="' . $cookie['port'] . '";'; |
|
718 | + $cookieHeader .= ' $Port="'.$cookie['port'].'";'; |
|
719 | 719 | } |
720 | 720 | } else { |
721 | - $cookieHeader .= ' ' . $name . '=' . $cookie['value'] . ";"; |
|
721 | + $cookieHeader .= ' '.$name.'='.$cookie['value'].";"; |
|
722 | 722 | } |
723 | 723 | } |
724 | - $cookieHeader = 'Cookie:' . $version . substr($cookieHeader, 0, -1) . "\r\n"; |
|
724 | + $cookieHeader = 'Cookie:'.$version.substr($cookieHeader, 0, -1)."\r\n"; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | // omit port if default |
728 | 728 | if (($port == 80 && in_array($method, array('http', 'http10'))) || ($port == 443 && $method == 'https')) { |
729 | - $port = ''; |
|
729 | + $port = ''; |
|
730 | 730 | } else { |
731 | - $port = ':' . $port; |
|
731 | + $port = ':'.$port; |
|
732 | 732 | } |
733 | 733 | |
734 | - $op = 'POST ' . $uri . " HTTP/1.0\r\n" . |
|
735 | - 'User-Agent: ' . $this->user_agent . "\r\n" . |
|
736 | - 'Host: ' . $server . $port . "\r\n" . |
|
737 | - $credentials . |
|
738 | - $proxyCredentials . |
|
739 | - $acceptedEncoding . |
|
740 | - $encodingHdr . |
|
741 | - 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . |
|
742 | - $cookieHeader . |
|
743 | - 'Content-Type: ' . $req->content_type . "\r\nContent-Length: " . |
|
744 | - strlen($payload) . "\r\n\r\n" . |
|
734 | + $op = 'POST '.$uri." HTTP/1.0\r\n". |
|
735 | + 'User-Agent: '.$this->user_agent."\r\n". |
|
736 | + 'Host: '.$server.$port."\r\n". |
|
737 | + $credentials. |
|
738 | + $proxyCredentials. |
|
739 | + $acceptedEncoding. |
|
740 | + $encodingHdr. |
|
741 | + 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)."\r\n". |
|
742 | + $cookieHeader. |
|
743 | + 'Content-Type: '.$req->content_type."\r\nContent-Length: ". |
|
744 | + strlen($payload)."\r\n\r\n". |
|
745 | 745 | $payload; |
746 | 746 | |
747 | - if ($this->debug > 1) { |
|
747 | + if ($this->debug>1) { |
|
748 | 748 | Logger::instance()->debugMessage("---SENDING---\n$op\n---END---"); |
749 | 749 | } |
750 | 750 | |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | } |
771 | 771 | $context = stream_context_create($contextOptions); |
772 | 772 | |
773 | - if ($timeout <= 0) { |
|
773 | + if ($timeout<=0) { |
|
774 | 774 | $connectTimeout = ini_get('default_socket_timeout'); |
775 | 775 | } else { |
776 | 776 | $connectTimeout = $timeout; |
@@ -782,12 +782,12 @@ discard block |
||
782 | 782 | $fp = stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $connectTimeout, |
783 | 783 | STREAM_CLIENT_CONNECT, $context); |
784 | 784 | if ($fp) { |
785 | - if ($timeout > 0) { |
|
785 | + if ($timeout>0) { |
|
786 | 786 | stream_set_timeout($fp, $timeout); |
787 | 787 | } |
788 | 788 | } else { |
789 | - $this->errstr = 'Connect error: ' . $this->errstr; |
|
790 | - $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')'); |
|
789 | + $this->errstr = 'Connect error: '.$this->errstr; |
|
790 | + $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr.' ('.$this->errno.')'); |
|
791 | 791 | |
792 | 792 | return $r; |
793 | 793 | } |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | $encodingHdr = ''; |
895 | 895 | } |
896 | 896 | |
897 | - if ($this->debug > 1) { |
|
897 | + if ($this->debug>1) { |
|
898 | 898 | Logger::instance()->debugMessage("---SENDING---\n$payload\n---END---"); |
899 | 899 | } |
900 | 900 | |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | } else { |
905 | 905 | $protocol = $method; |
906 | 906 | } |
907 | - $curl = curl_init($protocol . '://' . $server . ':' . $port . $this->path); |
|
907 | + $curl = curl_init($protocol.'://'.$server.':'.$port.$this->path); |
|
908 | 908 | if ($keepAlive) { |
909 | 909 | $this->xmlrpc_curl_handle = $curl; |
910 | 910 | } |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | // results into variable |
916 | 916 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
917 | 917 | |
918 | - if ($this->debug > 1) { |
|
918 | + if ($this->debug>1) { |
|
919 | 919 | curl_setopt($curl, CURLOPT_VERBOSE, true); |
920 | 920 | /// @todo allow callers to redirect curlopt_stderr to some stream which can be buffered |
921 | 921 | } |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | } |
942 | 942 | } |
943 | 943 | // extra headers |
944 | - $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); |
|
944 | + $headers = array('Content-Type: '.$req->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)); |
|
945 | 945 | // if no keepalive is wanted, let the server know it in advance |
946 | 946 | if (!$keepAlive) { |
947 | 947 | $headers[] = 'Connection: close'; |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
959 | 959 | // timeout is borked |
960 | 960 | if ($timeout) { |
961 | - curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); |
|
961 | + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | if ($method == 'http10') { |
@@ -968,11 +968,11 @@ discard block |
||
968 | 968 | } |
969 | 969 | |
970 | 970 | if ($username && $password) { |
971 | - curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password); |
|
971 | + curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); |
|
972 | 972 | if (defined('CURLOPT_HTTPAUTH')) { |
973 | 973 | curl_setopt($curl, CURLOPT_HTTPAUTH, $authType); |
974 | 974 | } elseif ($authType != 1) { |
975 | - error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
975 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
976 | 976 | } |
977 | 977 | } |
978 | 978 | |
@@ -1013,13 +1013,13 @@ discard block |
||
1013 | 1013 | if ($proxyPort == 0) { |
1014 | 1014 | $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080 |
1015 | 1015 | } |
1016 | - curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort); |
|
1016 | + curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$proxyPort); |
|
1017 | 1017 | if ($proxyUsername) { |
1018 | - curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword); |
|
1018 | + curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername.':'.$proxyPassword); |
|
1019 | 1019 | if (defined('CURLOPT_PROXYAUTH')) { |
1020 | 1020 | curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType); |
1021 | 1021 | } elseif ($proxyAuthType != 1) { |
1022 | - error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
1022 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | } |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | if (count($this->cookies)) { |
1031 | 1031 | $cookieHeader = ''; |
1032 | 1032 | foreach ($this->cookies as $name => $cookie) { |
1033 | - $cookieHeader .= $name . '=' . $cookie['value'] . '; '; |
|
1033 | + $cookieHeader .= $name.'='.$cookie['value'].'; '; |
|
1034 | 1034 | } |
1035 | 1035 | curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2)); |
1036 | 1036 | } |
@@ -1041,13 +1041,13 @@ discard block |
||
1041 | 1041 | |
1042 | 1042 | $result = curl_exec($curl); |
1043 | 1043 | |
1044 | - if ($this->debug > 1) { |
|
1044 | + if ($this->debug>1) { |
|
1045 | 1045 | $message = "---CURL INFO---\n"; |
1046 | 1046 | foreach (curl_getinfo($curl) as $name => $val) { |
1047 | 1047 | if (is_array($val)) { |
1048 | 1048 | $val = implode("\n", $val); |
1049 | 1049 | } |
1050 | - $message .= $name . ': ' . $val . "\n"; |
|
1050 | + $message .= $name.': '.$val."\n"; |
|
1051 | 1051 | } |
1052 | 1052 | $message .= '---END---'; |
1053 | 1053 | Logger::instance()->debugMessage($message); |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | /// @todo we should use a better check here - what if we get back '' or '0'? |
1058 | 1058 | |
1059 | 1059 | $this->errstr = 'no response'; |
1060 | - $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl)); |
|
1060 | + $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl)); |
|
1061 | 1061 | curl_close($curl); |
1062 | 1062 | if ($keepAlive) { |
1063 | 1063 | $this->xmlrpc_curl_handle = null; |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | $call['methodName'] = new Value($req->method(), 'string'); |
1168 | 1168 | $numParams = $req->getNumParams(); |
1169 | 1169 | $params = array(); |
1170 | - for ($i = 0; $i < $numParams; $i++) { |
|
1170 | + for ($i = 0; $i<$numParams; $i++) { |
|
1171 | 1171 | $params[$i] = $req->getParam($i); |
1172 | 1172 | } |
1173 | 1173 | $call['params'] = new Value($params, 'array'); |
@@ -1193,15 +1193,15 @@ discard block |
||
1193 | 1193 | /// @todo test this code branch... |
1194 | 1194 | $rets = $result->value(); |
1195 | 1195 | if (!is_array($rets)) { |
1196 | - return false; // bad return type from system.multicall |
|
1196 | + return false; // bad return type from system.multicall |
|
1197 | 1197 | } |
1198 | 1198 | $numRets = count($rets); |
1199 | 1199 | if ($numRets != count($reqs)) { |
1200 | - return false; // wrong number of return values. |
|
1200 | + return false; // wrong number of return values. |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | $response = array(); |
1204 | - for ($i = 0; $i < $numRets; $i++) { |
|
1204 | + for ($i = 0; $i<$numRets; $i++) { |
|
1205 | 1205 | $val = $rets[$i]; |
1206 | 1206 | if (!is_array($val)) { |
1207 | 1207 | return false; |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | switch (count($val)) { |
1210 | 1210 | case 1: |
1211 | 1211 | if (!isset($val[0])) { |
1212 | - return false; // Bad value |
|
1212 | + return false; // Bad value |
|
1213 | 1213 | } |
1214 | 1214 | // Normal return value |
1215 | 1215 | $response[$i] = new Response($val[0], 0, '', 'phpvals'); |
@@ -1237,19 +1237,19 @@ discard block |
||
1237 | 1237 | |
1238 | 1238 | $rets = $result->value(); |
1239 | 1239 | if ($rets->kindOf() != 'array') { |
1240 | - return false; // bad return type from system.multicall |
|
1240 | + return false; // bad return type from system.multicall |
|
1241 | 1241 | } |
1242 | 1242 | $numRets = $rets->count(); |
1243 | 1243 | if ($numRets != count($reqs)) { |
1244 | - return false; // wrong number of return values. |
|
1244 | + return false; // wrong number of return values. |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | $response = array(); |
1248 | - foreach($rets as $val) { |
|
1248 | + foreach ($rets as $val) { |
|
1249 | 1249 | switch ($val->kindOf()) { |
1250 | 1250 | case 'array': |
1251 | 1251 | if ($val->count() != 1) { |
1252 | - return false; // Bad value |
|
1252 | + return false; // Bad value |
|
1253 | 1253 | } |
1254 | 1254 | // Normal return value |
1255 | 1255 | $response[] = new Response($val[0]); |