@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | method)</p> |
21 | 21 | <?php |
22 | 22 | |
23 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
23 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
24 | 24 | PhpXmlRpc\Autoloader::register(); |
25 | 25 | |
26 | 26 | if (isset($_POST["mailto"]) && $_POST["mailto"]) { |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | print "<fonr color=\"red\">"; |
45 | 45 | print "Mail send failed<br/>\n"; |
46 | 46 | print "Fault: "; |
47 | - print "Code: " . htmlspecialchars($resp->faultCode()) . |
|
48 | - " Reason: '" . htmlspecialchars($resp->faultString()) . "'<br/>"; |
|
47 | + print "Code: ".htmlspecialchars($resp->faultCode()). |
|
48 | + " Reason: '".htmlspecialchars($resp->faultString())."'<br/>"; |
|
49 | 49 | print "</font><br/>"; |
50 | 50 | } |
51 | 51 | } |
@@ -8,34 +8,34 @@ |
||
8 | 8 | <h3>The code demonstrates usage of automatic encoding/decoding of php variables into xmlrpc values</h3> |
9 | 9 | <?php |
10 | 10 | |
11 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
11 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
12 | 12 | PhpXmlRpc\Autoloader::register(); |
13 | 13 | |
14 | 14 | if (isset($_POST["stateno"]) && $_POST["stateno"] != "") { |
15 | - $stateNo = (integer)$_POST["stateno"]; |
|
15 | + $stateNo = (integer) $_POST["stateno"]; |
|
16 | 16 | $encoder = new PhpXmlRpc\Encoder(); |
17 | 17 | $req = new PhpXmlRpc\Request('examples.getStateName', |
18 | 18 | array($encoder->encode($stateNo)) |
19 | 19 | ); |
20 | - print "Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . "\n\n</pre>Debug info of server data follows...\n\n"; |
|
20 | + print "Sending the following request:<pre>\n\n".htmlentities($req->serialize())."\n\n</pre>Debug info of server data follows...\n\n"; |
|
21 | 21 | $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php"); |
22 | 22 | $client->setDebug(1); |
23 | 23 | $r = $client->send($req); |
24 | 24 | if (!$r->faultCode()) { |
25 | 25 | $v = $r->value(); |
26 | - print "<br/>State number <b>" . $stateNo . "</b> is <b>" |
|
27 | - . htmlspecialchars($encoder->decode($v)) . "</b><br/>"; |
|
26 | + print "<br/>State number <b>".$stateNo."</b> is <b>" |
|
27 | + . htmlspecialchars($encoder->decode($v))."</b><br/>"; |
|
28 | 28 | } else { |
29 | 29 | print "An error occurred: "; |
30 | - print "Code: " . htmlspecialchars($r->faultCode()) |
|
31 | - . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>"; |
|
30 | + print "Code: ".htmlspecialchars($r->faultCode()) |
|
31 | + . " Reason: '".htmlspecialchars($r->faultString())."'</pre><br/>"; |
|
32 | 32 | } |
33 | 33 | } else { |
34 | 34 | $stateNo = ""; |
35 | 35 | } |
36 | 36 | |
37 | 37 | print "<form action=\"getstatename.php\" method=\"POST\"> |
38 | -<input name=\"stateno\" value=\"" . $stateNo . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
|
38 | +<input name=\"stateno\" value=\"" . $stateNo."\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
|
39 | 39 | <p>Enter a state number to query its name</p>"; |
40 | 40 | |
41 | 41 | ?> |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | * @return Response |
458 | 458 | */ |
459 | 459 | protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, |
460 | - $username = '', $password = '', $authType = 1, $proxyHost = '', |
|
461 | - $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
|
462 | - $method='http') |
|
460 | + $username = '', $password = '', $authType = 1, $proxyHost = '', |
|
461 | + $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
|
462 | + $method='http') |
|
463 | 463 | { |
464 | 464 | if ($port == 0) { |
465 | 465 | $port = ( $method === "https" ) ? 443 : 80; |
@@ -636,9 +636,9 @@ discard block |
||
636 | 636 | * @return Response |
637 | 637 | */ |
638 | 638 | protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', |
639 | - $password = '', $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', |
|
640 | - $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
|
641 | - $keepAlive = false, $key = '', $keyPass = '', $sslVersion = 0) |
|
639 | + $password = '', $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', |
|
640 | + $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
|
641 | + $keepAlive = false, $key = '', $keyPass = '', $sslVersion = 0) |
|
642 | 642 | { |
643 | 643 | return $this->sendPayloadCURL($req, $server, $port, $timeout, $username, |
644 | 644 | $password, $authType, $cert, $certPass, $caCert, $caCertDir, $proxyHost, $proxyPort, |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | * @return Response |
675 | 675 | */ |
676 | 676 | protected function sendPayloadCURL($req, $server, $port, $timeout = 0, $username = '', |
677 | - $password = '', $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', |
|
678 | - $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'https', |
|
679 | - $keepAlive = false, $key = '', $keyPass = '', $sslVersion = 0) |
|
677 | + $password = '', $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', |
|
678 | + $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'https', |
|
679 | + $keepAlive = false, $key = '', $keyPass = '', $sslVersion = 0) |
|
680 | 680 | { |
681 | 681 | if (!function_exists('curl_init')) { |
682 | 682 | $this->errstr = 'CURL unavailable on this install'; |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | $server = $parts['host']; |
92 | 92 | $path = isset($parts['path']) ? $parts['path'] : ''; |
93 | 93 | if (isset($parts['query'])) { |
94 | - $path .= '?' . $parts['query']; |
|
94 | + $path .= '?'.$parts['query']; |
|
95 | 95 | } |
96 | 96 | if (isset($parts['fragment'])) { |
97 | - $path .= '#' . $parts['fragment']; |
|
97 | + $path .= '#'.$parts['fragment']; |
|
98 | 98 | } |
99 | 99 | if (isset($parts['port'])) { |
100 | 100 | $port = $parts['port']; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | } |
112 | 112 | if ($path == '' || $path[0] != '/') { |
113 | - $this->path = '/' . $path; |
|
113 | + $this->path = '/'.$path; |
|
114 | 114 | } else { |
115 | 115 | $this->path = $path; |
116 | 116 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | }*/ |
149 | 149 | |
150 | 150 | // initialize user_agent string |
151 | - $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion; |
|
151 | + $this->user_agent = PhpXmlRpc::$xmlrpcName.' '.PhpXmlRpc::$xmlrpcVersion; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -459,10 +459,10 @@ discard block |
||
459 | 459 | protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, |
460 | 460 | $username = '', $password = '', $authType = 1, $proxyHost = '', |
461 | 461 | $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
462 | - $method='http') |
|
462 | + $method = 'http') |
|
463 | 463 | { |
464 | 464 | if ($port == 0) { |
465 | - $port = ( $method === "https" ) ? 443 : 80; |
|
465 | + $port = ($method === "https") ? 443 : 80; |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | // Only create the payload if it was not created previously |
@@ -493,15 +493,15 @@ discard block |
||
493 | 493 | // thanks to Grant Rauscher <[email protected]> for this |
494 | 494 | $credentials = ''; |
495 | 495 | if ($username != '') { |
496 | - $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; |
|
496 | + $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n"; |
|
497 | 497 | if ($authType != 1) { |
498 | - error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0'); |
|
498 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0'); |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | 502 | $acceptedEncoding = ''; |
503 | 503 | if (is_array($this->accepted_compression) && count($this->accepted_compression)) { |
504 | - $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; |
|
504 | + $acceptedEncoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n"; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | $proxyCredentials = ''; |
@@ -512,18 +512,18 @@ discard block |
||
512 | 512 | $connectServer = $proxyHost; |
513 | 513 | $connectPort = $proxyPort; |
514 | 514 | $transport = "tcp"; |
515 | - $uri = 'http://' . $server . ':' . $port . $this->path; |
|
515 | + $uri = 'http://'.$server.':'.$port.$this->path; |
|
516 | 516 | if ($proxyUsername != '') { |
517 | 517 | if ($proxyAuthType != 1) { |
518 | - error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
518 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
519 | 519 | } |
520 | - $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n"; |
|
520 | + $proxyCredentials = 'Proxy-Authorization: Basic '.base64_encode($proxyUsername.':'.$proxyPassword)."\r\n"; |
|
521 | 521 | } |
522 | 522 | } else { |
523 | 523 | $connectServer = $server; |
524 | 524 | $connectPort = $port; |
525 | 525 | /// @todo if supporting https, we should support all its current options as well: peer name verification etc... |
526 | - $transport = ( $method === "https" ) ? "tls" : "tcp"; |
|
526 | + $transport = ($method === "https") ? "tls" : "tcp"; |
|
527 | 527 | $uri = $this->path; |
528 | 528 | } |
529 | 529 | |
@@ -534,56 +534,56 @@ discard block |
||
534 | 534 | $version = ''; |
535 | 535 | foreach ($this->cookies as $name => $cookie) { |
536 | 536 | if ($cookie['version']) { |
537 | - $version = ' $Version="' . $cookie['version'] . '";'; |
|
538 | - $cookieHeader .= ' ' . $name . '="' . $cookie['value'] . '";'; |
|
537 | + $version = ' $Version="'.$cookie['version'].'";'; |
|
538 | + $cookieHeader .= ' '.$name.'="'.$cookie['value'].'";'; |
|
539 | 539 | if ($cookie['path']) { |
540 | - $cookieHeader .= ' $Path="' . $cookie['path'] . '";'; |
|
540 | + $cookieHeader .= ' $Path="'.$cookie['path'].'";'; |
|
541 | 541 | } |
542 | 542 | if ($cookie['domain']) { |
543 | - $cookieHeader .= ' $Domain="' . $cookie['domain'] . '";'; |
|
543 | + $cookieHeader .= ' $Domain="'.$cookie['domain'].'";'; |
|
544 | 544 | } |
545 | 545 | if ($cookie['port']) { |
546 | - $cookieHeader .= ' $Port="' . $cookie['port'] . '";'; |
|
546 | + $cookieHeader .= ' $Port="'.$cookie['port'].'";'; |
|
547 | 547 | } |
548 | 548 | } else { |
549 | - $cookieHeader .= ' ' . $name . '=' . $cookie['value'] . ";"; |
|
549 | + $cookieHeader .= ' '.$name.'='.$cookie['value'].";"; |
|
550 | 550 | } |
551 | 551 | } |
552 | - $cookieHeader = 'Cookie:' . $version . substr($cookieHeader, 0, -1) . "\r\n"; |
|
552 | + $cookieHeader = 'Cookie:'.$version.substr($cookieHeader, 0, -1)."\r\n"; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | // omit port if 80 |
556 | - $port = ($port == 80) ? '' : (':' . $port); |
|
557 | - |
|
558 | - $op = 'POST ' . $uri . " HTTP/1.0\r\n" . |
|
559 | - 'User-Agent: ' . $this->user_agent . "\r\n" . |
|
560 | - 'Host: ' . $server . $port . "\r\n" . |
|
561 | - $credentials . |
|
562 | - $proxyCredentials . |
|
563 | - $acceptedEncoding . |
|
564 | - $encodingHdr . |
|
565 | - 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . |
|
566 | - $cookieHeader . |
|
567 | - 'Content-Type: ' . $req->content_type . "\r\nContent-Length: " . |
|
568 | - strlen($payload) . "\r\n\r\n" . |
|
556 | + $port = ($port == 80) ? '' : (':'.$port); |
|
557 | + |
|
558 | + $op = 'POST '.$uri." HTTP/1.0\r\n". |
|
559 | + 'User-Agent: '.$this->user_agent."\r\n". |
|
560 | + 'Host: '.$server.$port."\r\n". |
|
561 | + $credentials. |
|
562 | + $proxyCredentials. |
|
563 | + $acceptedEncoding. |
|
564 | + $encodingHdr. |
|
565 | + 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)."\r\n". |
|
566 | + $cookieHeader. |
|
567 | + 'Content-Type: '.$req->content_type."\r\nContent-Length: ". |
|
568 | + strlen($payload)."\r\n\r\n". |
|
569 | 569 | $payload; |
570 | 570 | |
571 | - if ($this->debug > 1) { |
|
571 | + if ($this->debug>1) { |
|
572 | 572 | Logger::instance()->debugMessage("---SENDING---\n$op\n---END---"); |
573 | 573 | } |
574 | 574 | |
575 | - if ($timeout > 0) { |
|
575 | + if ($timeout>0) { |
|
576 | 576 | $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $timeout); |
577 | 577 | } else { |
578 | 578 | $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr); |
579 | 579 | } |
580 | 580 | if ($fp) { |
581 | - if ($timeout > 0) { |
|
581 | + if ($timeout>0) { |
|
582 | 582 | stream_set_timeout($fp, $timeout); |
583 | 583 | } |
584 | 584 | } else { |
585 | - $this->errstr = 'Connect error: ' . $this->errstr; |
|
586 | - $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')'); |
|
585 | + $this->errstr = 'Connect error: '.$this->errstr; |
|
586 | + $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr.' ('.$this->errno.')'); |
|
587 | 587 | |
588 | 588 | return $r; |
589 | 589 | } |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | $encodingHdr = ''; |
725 | 725 | } |
726 | 726 | |
727 | - if ($this->debug > 1) { |
|
727 | + if ($this->debug>1) { |
|
728 | 728 | Logger::instance()->debugMessage("---SENDING---\n$payload\n---END---"); |
729 | 729 | } |
730 | 730 | |
731 | 731 | if (!$keepAlive || !$this->xmlrpc_curl_handle) { |
732 | - $curl = curl_init($method . '://' . $server . ':' . $port . $this->path); |
|
732 | + $curl = curl_init($method.'://'.$server.':'.$port.$this->path); |
|
733 | 733 | if ($keepAlive) { |
734 | 734 | $this->xmlrpc_curl_handle = $curl; |
735 | 735 | } |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | // results into variable |
741 | 741 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
742 | 742 | |
743 | - if ($this->debug > 1) { |
|
743 | + if ($this->debug>1) { |
|
744 | 744 | curl_setopt($curl, CURLOPT_VERBOSE, true); |
745 | 745 | /// @todo allow callers to redirect curlopt_stderr to some stream which can be buffered |
746 | 746 | } |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | } |
767 | 767 | } |
768 | 768 | // extra headers |
769 | - $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); |
|
769 | + $headers = array('Content-Type: '.$req->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)); |
|
770 | 770 | // if no keepalive is wanted, let the server know it in advance |
771 | 771 | if (!$keepAlive) { |
772 | 772 | $headers[] = 'Connection: close'; |
@@ -779,15 +779,15 @@ discard block |
||
779 | 779 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
780 | 780 | // timeout is borked |
781 | 781 | if ($timeout) { |
782 | - curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); |
|
782 | + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1); |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | if ($username && $password) { |
786 | - curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password); |
|
786 | + curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); |
|
787 | 787 | if (defined('CURLOPT_HTTPAUTH')) { |
788 | 788 | curl_setopt($curl, CURLOPT_HTTPAUTH, $authType); |
789 | 789 | } elseif ($authType != 1) { |
790 | - error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
790 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
791 | 791 | } |
792 | 792 | } |
793 | 793 | |
@@ -828,13 +828,13 @@ discard block |
||
828 | 828 | if ($proxyPort == 0) { |
829 | 829 | $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080 |
830 | 830 | } |
831 | - curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort); |
|
831 | + curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$proxyPort); |
|
832 | 832 | if ($proxyUsername) { |
833 | - curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword); |
|
833 | + curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername.':'.$proxyPassword); |
|
834 | 834 | if (defined('CURLOPT_PROXYAUTH')) { |
835 | 835 | curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType); |
836 | 836 | } elseif ($proxyAuthType != 1) { |
837 | - error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
837 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
838 | 838 | } |
839 | 839 | } |
840 | 840 | } |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | if (count($this->cookies)) { |
846 | 846 | $cookieHeader = ''; |
847 | 847 | foreach ($this->cookies as $name => $cookie) { |
848 | - $cookieHeader .= $name . '=' . $cookie['value'] . '; '; |
|
848 | + $cookieHeader .= $name.'='.$cookie['value'].'; '; |
|
849 | 849 | } |
850 | 850 | curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2)); |
851 | 851 | } |
@@ -856,13 +856,13 @@ discard block |
||
856 | 856 | |
857 | 857 | $result = curl_exec($curl); |
858 | 858 | |
859 | - if ($this->debug > 1) { |
|
859 | + if ($this->debug>1) { |
|
860 | 860 | $message = "---CURL INFO---\n"; |
861 | 861 | foreach (curl_getinfo($curl) as $name => $val) { |
862 | 862 | if (is_array($val)) { |
863 | 863 | $val = implode("\n", $val); |
864 | 864 | } |
865 | - $message .= $name . ': ' . $val . "\n"; |
|
865 | + $message .= $name.': '.$val."\n"; |
|
866 | 866 | } |
867 | 867 | $message .= "---END---"; |
868 | 868 | Logger::instance()->debugMessage($message); |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | /// @todo we should use a better check here - what if we get back '' or '0'? |
873 | 873 | |
874 | 874 | $this->errstr = 'no response'; |
875 | - $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl)); |
|
875 | + $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl)); |
|
876 | 876 | curl_close($curl); |
877 | 877 | if ($keepAlive) { |
878 | 878 | $this->xmlrpc_curl_handle = null; |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | $call['methodName'] = new Value($req->method(), 'string'); |
982 | 982 | $numParams = $req->getNumParams(); |
983 | 983 | $params = array(); |
984 | - for ($i = 0; $i < $numParams; $i++) { |
|
984 | + for ($i = 0; $i<$numParams; $i++) { |
|
985 | 985 | $params[$i] = $req->getParam($i); |
986 | 986 | } |
987 | 987 | $call['params'] = new Value($params, 'array'); |
@@ -1007,15 +1007,15 @@ discard block |
||
1007 | 1007 | /// @todo test this code branch... |
1008 | 1008 | $rets = $result->value(); |
1009 | 1009 | if (!is_array($rets)) { |
1010 | - return false; // bad return type from system.multicall |
|
1010 | + return false; // bad return type from system.multicall |
|
1011 | 1011 | } |
1012 | 1012 | $numRets = count($rets); |
1013 | 1013 | if ($numRets != count($reqs)) { |
1014 | - return false; // wrong number of return values. |
|
1014 | + return false; // wrong number of return values. |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | $response = array(); |
1018 | - for ($i = 0; $i < $numRets; $i++) { |
|
1018 | + for ($i = 0; $i<$numRets; $i++) { |
|
1019 | 1019 | $val = $rets[$i]; |
1020 | 1020 | if (!is_array($val)) { |
1021 | 1021 | return false; |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | switch (count($val)) { |
1024 | 1024 | case 1: |
1025 | 1025 | if (!isset($val[0])) { |
1026 | - return false; // Bad value |
|
1026 | + return false; // Bad value |
|
1027 | 1027 | } |
1028 | 1028 | // Normal return value |
1029 | 1029 | $response[$i] = new Response($val[0], 0, '', 'phpvals'); |
@@ -1051,19 +1051,19 @@ discard block |
||
1051 | 1051 | |
1052 | 1052 | $rets = $result->value(); |
1053 | 1053 | if ($rets->kindOf() != 'array') { |
1054 | - return false; // bad return type from system.multicall |
|
1054 | + return false; // bad return type from system.multicall |
|
1055 | 1055 | } |
1056 | 1056 | $numRets = $rets->count(); |
1057 | 1057 | if ($numRets != count($reqs)) { |
1058 | - return false; // wrong number of return values. |
|
1058 | + return false; // wrong number of return values. |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | $response = array(); |
1062 | - foreach($rets as $val) { |
|
1062 | + foreach ($rets as $val) { |
|
1063 | 1063 | switch ($val->kindOf()) { |
1064 | 1064 | case 'array': |
1065 | 1065 | if ($val->count() != 1) { |
1066 | - return false; // Bad value |
|
1066 | + return false; // Bad value |
|
1067 | 1067 | } |
1068 | 1068 | // Normal return value |
1069 | 1069 | $response[] = new Response($val[0]); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | return $xmlrpcVal->scalarval(); |
73 | 73 | case 'array': |
74 | 74 | $arr = array(); |
75 | - foreach($xmlrpcVal as $value) { |
|
75 | + foreach ($xmlrpcVal as $value) { |
|
76 | 76 | $arr[] = $this->decode($value, $options); |
77 | 77 | } |
78 | 78 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | case 'msg': |
103 | 103 | $paramCount = $xmlrpcVal->getNumParams(); |
104 | 104 | $arr = array(); |
105 | - for ($i = 0; $i < $paramCount; $i++) { |
|
105 | + for ($i = 0; $i<$paramCount; $i++) { |
|
106 | 106 | $arr[] = $this->decode($xmlrpcVal->getParam($i), $options); |
107 | 107 | } |
108 | 108 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | break; |
204 | 204 | case 'resource': |
205 | 205 | if (in_array('extension_api', $options)) { |
206 | - $xmlrpcVal = new Value((int)$phpVal, Value::$xmlrpcInt); |
|
206 | + $xmlrpcVal = new Value((int) $phpVal, Value::$xmlrpcInt); |
|
207 | 207 | } else { |
208 | 208 | $xmlrpcVal = new Value(); |
209 | 209 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | if (extension_loaded('mbstring')) { |
247 | 247 | $xmlVal = mb_convert_encoding($xmlVal, 'UTF-8', $valEncoding); |
248 | 248 | } else { |
249 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding); |
|
249 | + error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of xml text: '.$valEncoding); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | xml_parser_free($parser); |
281 | - if ($xmlRpcParser->_xh['isf'] > 1) { |
|
281 | + if ($xmlRpcParser->_xh['isf']>1) { |
|
282 | 282 | // test that $xmlrpc->_xh['value'] is an obj, too??? |
283 | 283 | |
284 | 284 | error_log($xmlRpcParser->_xh['isf_reason']); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | return $r; |
300 | 300 | case 'methodcall': |
301 | 301 | $req = new Request($xmlRpcParser->_xh['method']); |
302 | - for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) { |
|
302 | + for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) { |
|
303 | 303 | $req->addParam($xmlRpcParser->_xh['params'][$i]); |
304 | 304 | } |
305 | 305 |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | public function xml_header($charsetEncoding = '') |
35 | 35 | { |
36 | 36 | if ($charsetEncoding != '') { |
37 | - return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n"; |
|
37 | + return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?".">\n<methodCall>\n"; |
|
38 | 38 | } else { |
39 | - return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; |
|
39 | + return "<?xml version=\"1.0\"?".">\n<methodCall>\n"; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | public function createPayload($charsetEncoding = '') |
49 | 49 | { |
50 | 50 | if ($charsetEncoding != '') { |
51 | - $this->content_type = 'text/xml; charset=' . $charsetEncoding; |
|
51 | + $this->content_type = 'text/xml; charset='.$charsetEncoding; |
|
52 | 52 | } else { |
53 | 53 | $this->content_type = 'text/xml'; |
54 | 54 | } |
55 | 55 | $this->payload = $this->xml_header($charsetEncoding); |
56 | - $this->payload .= '<methodName>' . Charset::instance()->encodeEntities($this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n"; |
|
56 | + $this->payload .= '<methodName>'.Charset::instance()->encodeEntities($this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</methodName>\n"; |
|
57 | 57 | $this->payload .= "<params>\n"; |
58 | 58 | foreach ($this->params as $p) { |
59 | - $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) . |
|
59 | + $this->payload .= "<param>\n".$p->serialize($charsetEncoding). |
|
60 | 60 | "</param>\n"; |
61 | 61 | } |
62 | 62 | $this->payload .= "</params>\n"; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $this->httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array()); |
177 | 177 | |
178 | 178 | if ($data == '') { |
179 | - error_log('XML-RPC: ' . __METHOD__ . ': no response received from server.'); |
|
179 | + error_log('XML-RPC: '.__METHOD__.': no response received from server.'); |
|
180 | 180 | return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']); |
181 | 181 | } |
182 | 182 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $httpParser = new Http(); |
186 | 186 | try { |
187 | 187 | $this->httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug); |
188 | - } catch(\Exception $e) { |
|
188 | + } catch (\Exception $e) { |
|
189 | 189 | $r = new Response(0, $e->getCode(), $e->getMessage()); |
190 | 190 | // failed processing of HTTP response headers |
191 | 191 | // save into response obj the full payload received, for debugging |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib |
205 | 205 | $pos = strrpos($data, '</methodResponse>'); |
206 | 206 | if ($pos !== false) { |
207 | - $data = substr($data, 0, $pos + 17); |
|
207 | + $data = substr($data, 0, $pos+17); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | // try to 'guestimate' the character encoding of the received response |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | if ($start) { |
216 | 216 | $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
217 | 217 | $end = strpos($data, '-->', $start); |
218 | - $comments = substr($data, $start, $end - $start); |
|
219 | - Logger::instance()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t" . |
|
220 | - str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", $respEncoding); |
|
218 | + $comments = substr($data, $start, $end-$start); |
|
219 | + Logger::instance()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t". |
|
220 | + str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", $respEncoding); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | if (extension_loaded('mbstring')) { |
246 | 246 | $data = mb_convert_encoding($data, 'UTF-8', $respEncoding); |
247 | 247 | } else { |
248 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received response: ' . $respEncoding); |
|
248 | + error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received response: '.$respEncoding); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | xml_get_current_line_number($parser), xml_get_current_column_number($parser)); |
289 | 289 | } |
290 | 290 | error_log($errStr); |
291 | - $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' (' . $errStr . ')'); |
|
291 | + $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], PhpXmlRpc::$xmlrpcstr['invalid_return'].' ('.$errStr.')'); |
|
292 | 292 | xml_parser_free($parser); |
293 | 293 | if ($this->debug) { |
294 | 294 | print $errStr; |
@@ -301,13 +301,13 @@ discard block |
||
301 | 301 | } |
302 | 302 | xml_parser_free($parser); |
303 | 303 | // second error check: xml well formed but not xml-rpc compliant |
304 | - if ($xmlRpcParser->_xh['isf'] > 1) { |
|
304 | + if ($xmlRpcParser->_xh['isf']>1) { |
|
305 | 305 | if ($this->debug) { |
306 | 306 | /// @todo echo something for user? |
307 | 307 | } |
308 | 308 | |
309 | 309 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], |
310 | - PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']); |
|
310 | + PhpXmlRpc::$xmlrpcstr['invalid_return'].' '.$xmlRpcParser->_xh['isf_reason']); |
|
311 | 311 | } |
312 | 312 | // third error check: parsing of the response has somehow gone boink. |
313 | 313 | // NB: shall we omit this check, since we trust the parsing code? |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], |
319 | 319 | PhpXmlRpc::$xmlrpcstr['invalid_return']); |
320 | 320 | } else { |
321 | - if ($this->debug > 1) { |
|
321 | + if ($this->debug>1) { |
|
322 | 322 | Logger::instance()->debugMessage( |
323 | 323 | "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---" |
324 | 324 | ); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | - if (is_file($file = __DIR__ . str_replace(array('PhpXmlRpc\\', '\\'), '/', $class).'.php')) { |
|
32 | + if (is_file($file = __DIR__.str_replace(array('PhpXmlRpc\\', '\\'), '/', $class).'.php')) { |
|
33 | 33 | require $file; |
34 | 34 | } |
35 | 35 | } |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | |
23 | 23 | // read chunk-size, chunk-extension (if any) and crlf |
24 | 24 | // get the position of the linebreak |
25 | - $chunkEnd = strpos($buffer, "\r\n") + 2; |
|
25 | + $chunkEnd = strpos($buffer, "\r\n")+2; |
|
26 | 26 | $temp = substr($buffer, 0, $chunkEnd); |
27 | 27 | $chunkSize = hexdec(trim($temp)); |
28 | 28 | $chunkStart = $chunkEnd; |
29 | - while ($chunkSize > 0) { |
|
30 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize); |
|
29 | + while ($chunkSize>0) { |
|
30 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize); |
|
31 | 31 | |
32 | 32 | // just in case we got a broken connection |
33 | 33 | if ($chunkEnd == false) { |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | // read chunk-data and crlf |
42 | - $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
42 | + $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
43 | 43 | // append chunk-data to entity-body |
44 | 44 | $new .= $chunk; |
45 | 45 | // length := length + chunk-size |
46 | 46 | $length += strlen($chunk); |
47 | 47 | // read chunk-size and crlf |
48 | - $chunkStart = $chunkEnd + 2; |
|
48 | + $chunkStart = $chunkEnd+2; |
|
49 | 49 | |
50 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2; |
|
50 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2; |
|
51 | 51 | if ($chunkEnd == false) { |
52 | 52 | break; //just in case we got a broken connection |
53 | 53 | } |
54 | - $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
54 | + $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
55 | 55 | $chunkSize = hexdec(trim($temp)); |
56 | 56 | $chunkStart = $chunkEnd; |
57 | 57 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return array with keys 'headers' and 'cookies' |
69 | 69 | * @throws \Exception |
70 | 70 | */ |
71 | - public function parseResponseHeaders(&$data, $headersProcessed = false, $debug=0) |
|
71 | + public function parseResponseHeaders(&$data, $headersProcessed = false, $debug = 0) |
|
72 | 72 | { |
73 | 73 | $httpResponse = array('raw_data' => $data, 'headers'=> array(), 'cookies' => array()); |
74 | 74 | |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | // (even though it is not valid http) |
79 | 79 | $pos = strpos($data, "\r\n\r\n"); |
80 | 80 | if ($pos || is_int($pos)) { |
81 | - $bd = $pos + 4; |
|
81 | + $bd = $pos+4; |
|
82 | 82 | } else { |
83 | 83 | $pos = strpos($data, "\n\n"); |
84 | 84 | if ($pos || is_int($pos)) { |
85 | - $bd = $pos + 2; |
|
85 | + $bd = $pos+2; |
|
86 | 86 | } else { |
87 | 87 | // No separation between response headers and body: fault? |
88 | 88 | $bd = 0; |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | // maybe we could take them into account, too? |
94 | 94 | $data = substr($data, $bd); |
95 | 95 | } else { |
96 | - error_log('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed'); |
|
97 | - throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
96 | + error_log('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed'); |
|
97 | + throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -111,20 +111,20 @@ discard block |
||
111 | 111 | $data = substr($data, $pos); |
112 | 112 | } |
113 | 113 | if (!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) { |
114 | - $errstr = substr($data, 0, strpos($data, "\n") - 1); |
|
115 | - error_log('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr); |
|
116 | - throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
114 | + $errstr = substr($data, 0, strpos($data, "\n")-1); |
|
115 | + error_log('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr); |
|
116 | + throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // be tolerant to usage of \n instead of \r\n to separate headers and data |
120 | 120 | // (even though it is not valid http) |
121 | 121 | $pos = strpos($data, "\r\n\r\n"); |
122 | 122 | if ($pos || is_int($pos)) { |
123 | - $bd = $pos + 4; |
|
123 | + $bd = $pos+4; |
|
124 | 124 | } else { |
125 | 125 | $pos = strpos($data, "\n\n"); |
126 | 126 | if ($pos || is_int($pos)) { |
127 | - $bd = $pos + 2; |
|
127 | + $bd = $pos+2; |
|
128 | 128 | } else { |
129 | 129 | // No separation between response headers and body: fault? |
130 | 130 | // we could take some action here instead of going on... |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | while (list(, $line) = @each($ar)) { |
137 | 137 | // take care of multi-line headers and cookies |
138 | 138 | $arr = explode(':', $line, 2); |
139 | - if (count($arr) > 1) { |
|
139 | + if (count($arr)>1) { |
|
140 | 140 | $headerName = strtolower(trim($arr[0])); |
141 | 141 | /// @todo some other headers (the ones that allow a CSV list of values) |
142 | 142 | /// do allow many values to be passed using multiple header lines. |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | // glue together all received cookies, using a comma to separate them |
155 | 155 | // (same as php does with getallheaders()) |
156 | 156 | if (isset($httpResponse['headers'][$headerName])) { |
157 | - $httpResponse['headers'][$headerName] .= ', ' . trim($cookie); |
|
157 | + $httpResponse['headers'][$headerName] .= ', '.trim($cookie); |
|
158 | 158 | } else { |
159 | 159 | $httpResponse['headers'][$headerName] = trim($cookie); |
160 | 160 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | } elseif (isset($headerName)) { |
185 | 185 | /// @todo version1 cookies might span multiple lines, thus breaking the parsing above |
186 | - $httpResponse['headers'][$headerName] .= ' ' . trim($line); |
|
186 | + $httpResponse['headers'][$headerName] .= ' '.trim($line); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | // Decode chunked encoding sent by http 1.1 servers |
207 | 207 | if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') { |
208 | 208 | if (!$data = Http::decodeChunked($data)) { |
209 | - error_log('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server'); |
|
209 | + error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server'); |
|
210 | 210 | throw new \Exception(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail']); |
211 | 211 | } |
212 | 212 | } |
@@ -221,19 +221,19 @@ discard block |
||
221 | 221 | if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { |
222 | 222 | $data = $degzdata; |
223 | 223 | if ($debug) { |
224 | - Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
224 | + Logger::instance()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
225 | 225 | } |
226 | 226 | } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
227 | 227 | $data = $degzdata; |
228 | 228 | if ($debug) { |
229 | - Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
229 | + Logger::instance()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
230 | 230 | } |
231 | 231 | } else { |
232 | - error_log('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server'); |
|
232 | + error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server'); |
|
233 | 233 | throw new \Exception(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail']); |
234 | 234 | } |
235 | 235 | } else { |
236 | - error_log('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
236 | + error_log('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
237 | 237 | throw new \Exception(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress']); |
238 | 238 | } |
239 | 239 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | |
52 | 52 | private function __construct() |
53 | 53 | { |
54 | - for ($i = 0; $i < 32; $i++) { |
|
54 | + for ($i = 0; $i<32; $i++) { |
|
55 | 55 | $this->xml_iso88591_Entities["in"][] = chr($i); |
56 | 56 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
57 | 57 | } |
58 | 58 | |
59 | - for ($i = 160; $i < 256; $i++) { |
|
59 | + for ($i = 160; $i<256; $i++) { |
|
60 | 60 | $this->xml_iso88591_Entities["in"][] = chr($i); |
61 | 61 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
62 | 62 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $srcEncoding = PhpXmlRpc::$xmlrpc_internalencoding; |
95 | 95 | } |
96 | 96 | |
97 | - switch (strtoupper($srcEncoding . '_' . $destEncoding)) { |
|
97 | + switch (strtoupper($srcEncoding.'_'.$destEncoding)) { |
|
98 | 98 | case 'ISO-8859-1_': |
99 | 99 | case 'ISO-8859-1_US-ASCII': |
100 | 100 | $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | // NB: this will choke on invalid UTF-8, going most likely beyond EOF |
120 | 120 | $escapedData = ''; |
121 | 121 | // be kind to users creating string xmlrpc values out of different php types |
122 | - $data = (string)$data; |
|
122 | + $data = (string) $data; |
|
123 | 123 | $ns = strlen($data); |
124 | - for ($nn = 0; $nn < $ns; $nn++) { |
|
124 | + for ($nn = 0; $nn<$ns; $nn++) { |
|
125 | 125 | $ch = $data[$nn]; |
126 | 126 | $ii = ord($ch); |
127 | 127 | //1 7 0bbbbbbb (127) |
128 | - if ($ii < 128) { |
|
128 | + if ($ii<128) { |
|
129 | 129 | /// @todo shall we replace this with a (supposedly) faster str_replace? |
130 | 130 | switch ($ii) { |
131 | 131 | case 34: |
@@ -149,33 +149,33 @@ discard block |
||
149 | 149 | } //2 11 110bbbbb 10bbbbbb (2047) |
150 | 150 | elseif ($ii >> 5 == 6) { |
151 | 151 | $b1 = ($ii & 31); |
152 | - $ii = ord($data[$nn + 1]); |
|
152 | + $ii = ord($data[$nn+1]); |
|
153 | 153 | $b2 = ($ii & 63); |
154 | - $ii = ($b1 * 64) + $b2; |
|
154 | + $ii = ($b1 * 64)+$b2; |
|
155 | 155 | $ent = sprintf('&#%d;', $ii); |
156 | 156 | $escapedData .= $ent; |
157 | 157 | $nn += 1; |
158 | 158 | } //3 16 1110bbbb 10bbbbbb 10bbbbbb |
159 | 159 | elseif ($ii >> 4 == 14) { |
160 | 160 | $b1 = ($ii & 15); |
161 | - $ii = ord($data[$nn + 1]); |
|
161 | + $ii = ord($data[$nn+1]); |
|
162 | 162 | $b2 = ($ii & 63); |
163 | - $ii = ord($data[$nn + 2]); |
|
163 | + $ii = ord($data[$nn+2]); |
|
164 | 164 | $b3 = ($ii & 63); |
165 | - $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
|
165 | + $ii = ((($b1 * 64)+$b2) * 64)+$b3; |
|
166 | 166 | $ent = sprintf('&#%d;', $ii); |
167 | 167 | $escapedData .= $ent; |
168 | 168 | $nn += 2; |
169 | 169 | } //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
170 | 170 | elseif ($ii >> 3 == 30) { |
171 | 171 | $b1 = ($ii & 7); |
172 | - $ii = ord($data[$nn + 1]); |
|
172 | + $ii = ord($data[$nn+1]); |
|
173 | 173 | $b2 = ($ii & 63); |
174 | - $ii = ord($data[$nn + 2]); |
|
174 | + $ii = ord($data[$nn+2]); |
|
175 | 175 | $b3 = ($ii & 63); |
176 | - $ii = ord($data[$nn + 3]); |
|
176 | + $ii = ord($data[$nn+3]); |
|
177 | 177 | $b4 = ($ii & 63); |
178 | - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
|
178 | + $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4; |
|
179 | 179 | $ent = sprintf('&#%d;', $ii); |
180 | 180 | $escapedData .= $ent; |
181 | 181 | $nn += 3; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | default: |
205 | 205 | $escapedData = ''; |
206 | - error_log('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
206 | + error_log('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | return $escapedData; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | case 'iso88591': |
256 | 256 | return $this->xml_iso88591_Entities; |
257 | 257 | default: |
258 | - throw new \Exception('Unsupported charset: ' . $charset); |
|
258 | + throw new \Exception('Unsupported charset: '.$charset); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | // of PHP |
33 | 33 | $t = gmstrftime("%Y%m%dT%H:%M:%S", $timet); |
34 | 34 | } else { |
35 | - $t = strftime("%Y%m%dT%H:%M:%S", $timet - date('Z')); |
|
35 | + $t = strftime("%Y%m%dT%H:%M:%S", $timet-date('Z')); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 |