@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -include_once __DIR__ . '/../lib/xmlrpc.inc'; |
|
| 4 | -include_once __DIR__ . '/../lib/xmlrpcs.inc'; |
|
| 3 | +include_once __DIR__.'/../lib/xmlrpc.inc'; |
|
| 4 | +include_once __DIR__.'/../lib/xmlrpcs.inc'; |
|
| 5 | 5 | |
| 6 | -include_once __DIR__ . '/parse_args.php'; |
|
| 6 | +include_once __DIR__.'/parse_args.php'; |
|
| 7 | 7 | |
| 8 | -include_once __DIR__ . '/PolyfillTestCase.php'; |
|
| 8 | +include_once __DIR__.'/PolyfillTestCase.php'; |
|
| 9 | 9 | |
| 10 | 10 | use PHPUnit\Runner\BaseTestRunner; |
| 11 | 11 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | /// @todo it seems that old php versions can not automatically transform latin to utf8 upon xml parsing. |
| 104 | 104 | /// We should fix that, then re-enable this test |
| 105 | 105 | if (version_compare(PHP_VERSION, '5.6.0', '>=')) { |
| 106 | - $i = $e->decodeXml('<?xml version="1.0" encoding="ISO-8859-15" ?><value><string>' . $string . '</string></value>'); |
|
| 106 | + $i = $e->decodeXml('<?xml version="1.0" encoding="ISO-8859-15" ?><value><string>'.$string.'</string></value>'); |
|
| 107 | 107 | $this->assertEquals($string, $i->scalarVal()); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $this->me['struct'] = $val; |
| 130 | 130 | break; |
| 131 | 131 | default: |
| 132 | - $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": not a known type ($type)"); |
|
| 132 | + $this->getLogger()->errorLog("XML-RPC: ".__METHOD__.": not a known type ($type)"); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | if ($typeOf !== 1) { |
| 156 | - $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": not a scalar type ($type)"); |
|
| 156 | + $this->getLogger()->errorLog("XML-RPC: ".__METHOD__.": not a scalar type ($type)"); |
|
| 157 | 157 | return 0; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -170,10 +170,10 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | switch ($this->mytype) { |
| 172 | 172 | case 1: |
| 173 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': scalar xmlrpc value can have only one value'); |
|
| 173 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': scalar xmlrpc value can have only one value'); |
|
| 174 | 174 | return 0; |
| 175 | 175 | case 3: |
| 176 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot add anonymous scalar to struct xmlrpc value'); |
|
| 176 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': cannot add anonymous scalar to struct xmlrpc value'); |
|
| 177 | 177 | return 0; |
| 178 | 178 | case 2: |
| 179 | 179 | // we're adding a scalar value to an array here |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | return 1; |
| 216 | 216 | } else { |
| 217 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']'); |
|
| 217 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
| 218 | 218 | return 0; |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | return 1; |
| 246 | 246 | } else { |
| 247 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']'); |
|
| 247 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
| 248 | 248 | return 0; |
| 249 | 249 | } |
| 250 | 250 | } |
@@ -286,19 +286,19 @@ discard block |
||
| 286 | 286 | case 1: |
| 287 | 287 | switch ($typ) { |
| 288 | 288 | case static::$xmlrpcBase64: |
| 289 | - $rs .= "<{$typ}>" . base64_encode($val) . "</{$typ}>"; |
|
| 289 | + $rs .= "<{$typ}>".base64_encode($val)."</{$typ}>"; |
|
| 290 | 290 | break; |
| 291 | 291 | case static::$xmlrpcBoolean: |
| 292 | - $rs .= "<{$typ}>" . ($val ? '1' : '0') . "</{$typ}>"; |
|
| 292 | + $rs .= "<{$typ}>".($val ? '1' : '0')."</{$typ}>"; |
|
| 293 | 293 | break; |
| 294 | 294 | case static::$xmlrpcString: |
| 295 | 295 | // Do NOT use htmlentities, since it will produce named html entities, which are invalid xml |
| 296 | - $rs .= "<{$typ}>" . $this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</{$typ}>"; |
|
| 296 | + $rs .= "<{$typ}>".$this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</{$typ}>"; |
|
| 297 | 297 | break; |
| 298 | 298 | case static::$xmlrpcInt: |
| 299 | 299 | case static::$xmlrpcI4: |
| 300 | 300 | case static::$xmlrpcI8: |
| 301 | - $rs .= "<{$typ}>" . (int)$val . "</{$typ}>"; |
|
| 301 | + $rs .= "<{$typ}>".(int) $val."</{$typ}>"; |
|
| 302 | 302 | break; |
| 303 | 303 | case static::$xmlrpcDouble: |
| 304 | 304 | // avoid using standard conversion of float to string because it is locale-dependent, |
@@ -306,16 +306,16 @@ discard block |
||
| 306 | 306 | // sprintf('%F') could be most likely ok, but it fails e.g. on 2e-14. |
| 307 | 307 | // The code below tries its best at keeping max precision while avoiding exp notation, |
| 308 | 308 | // but there is of course no limit in the number of decimal places to be used... |
| 309 | - $rs .= "<{$typ}>" . preg_replace('/\\.?0+$/', '', number_format((double)$val, PhpXmlRpc::$xmlpc_double_precision, '.', '')) . "</{$typ}>"; |
|
| 309 | + $rs .= "<{$typ}>".preg_replace('/\\.?0+$/', '', number_format((double) $val, PhpXmlRpc::$xmlpc_double_precision, '.', ''))."</{$typ}>"; |
|
| 310 | 310 | break; |
| 311 | 311 | case static::$xmlrpcDateTime: |
| 312 | 312 | if (is_string($val)) { |
| 313 | 313 | $rs .= "<{$typ}>{$val}</{$typ}>"; |
| 314 | 314 | // DateTimeInterface is not present in php 5.4... |
| 315 | 315 | } elseif (is_a($val, 'DateTimeInterface') || is_a($val, 'DateTime')) { |
| 316 | - $rs .= "<{$typ}>" . $val->format('Ymd\TH:i:s') . "</{$typ}>"; |
|
| 316 | + $rs .= "<{$typ}>".$val->format('Ymd\TH:i:s')."</{$typ}>"; |
|
| 317 | 317 | } elseif (is_int($val)) { |
| 318 | - $rs .= "<{$typ}>" . date('Ymd\TH:i:s', $val) . "</{$typ}>"; |
|
| 318 | + $rs .= "<{$typ}>".date('Ymd\TH:i:s', $val)."</{$typ}>"; |
|
| 319 | 319 | } else { |
| 320 | 320 | // not really a good idea here: but what should we output anyway? left for backward compat... |
| 321 | 321 | $rs .= "<{$typ}>{$val}</{$typ}>"; |
@@ -337,14 +337,14 @@ discard block |
||
| 337 | 337 | case 3: |
| 338 | 338 | // struct |
| 339 | 339 | if ($this->_php_class) { |
| 340 | - $rs .= '<struct php_class="' . $this->_php_class . "\">\n"; |
|
| 340 | + $rs .= '<struct php_class="'.$this->_php_class."\">\n"; |
|
| 341 | 341 | } else { |
| 342 | 342 | $rs .= "<struct>\n"; |
| 343 | 343 | } |
| 344 | 344 | $charsetEncoder = $this->getCharsetEncoder(); |
| 345 | 345 | /** @var Value $val2 */ |
| 346 | 346 | foreach ($val as $key2 => $val2) { |
| 347 | - $rs .= '<member><name>' . $charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</name>\n"; |
|
| 347 | + $rs .= '<member><name>'.$charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</name>\n"; |
|
| 348 | 348 | //$rs.=$this->serializeval($val2); |
| 349 | 349 | $rs .= $val2->serialize($charsetEncoding); |
| 350 | 350 | $rs .= "</member>\n"; |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | $val = reset($this->me); |
| 380 | 380 | $typ = key($this->me); |
| 381 | 381 | |
| 382 | - return '<value>' . $this->serializedata($typ, $val, $charsetEncoding) . "</value>\n"; |
|
| 382 | + return '<value>'.$this->serializedata($typ, $val, $charsetEncoding)."</value>\n"; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | 'scalar' => $val, |
| 91 | 91 | 'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($val) |
| 92 | 92 | ); |
| 93 | - return (object)$xmlrpcVal; |
|
| 93 | + return (object) $xmlrpcVal; |
|
| 94 | 94 | case 'base64': |
| 95 | 95 | $xmlrpcVal = array( |
| 96 | 96 | 'xmlrpc_type' => 'base64', |
| 97 | 97 | 'scalar' => $val |
| 98 | 98 | ); |
| 99 | - return (object)$xmlrpcVal; |
|
| 99 | + return (object) $xmlrpcVal; |
|
| 100 | 100 | case 'string': |
| 101 | 101 | if (isset($options['extension_api_encoding'])) { |
| 102 | 102 | // if iconv is not available, we use mb_convert_encoding |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | case 'msg': |
| 166 | 166 | $paramCount = $xmlrpcVal->getNumParams(); |
| 167 | 167 | $arr = array(); |
| 168 | - for ($i = 0; $i < $paramCount; $i++) { |
|
| 168 | + for ($i = 0; $i<$paramCount; $i++) { |
|
| 169 | 169 | $arr[] = $this->decode($xmlrpcVal->getParam($i), $options); |
| 170 | 170 | } |
| 171 | 171 | return $arr; |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | break; |
| 292 | 292 | case 'resource': |
| 293 | 293 | if (in_array('extension_api', $options)) { |
| 294 | - $xmlrpcVal = new Value((int)$phpVal, Value::$xmlrpcInt); |
|
| 294 | + $xmlrpcVal = new Value((int) $phpVal, Value::$xmlrpcInt); |
|
| 295 | 295 | } else { |
| 296 | 296 | $xmlrpcVal = new Value(); |
| 297 | 297 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | if ($valEncoding == 'ISO-8859-1') { |
| 341 | 341 | $xmlVal = utf8_encode($xmlVal); |
| 342 | 342 | } else { |
| 343 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding); |
|
| 343 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of xml text: '.$valEncoding); |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $parserOptions |
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | - if ($xmlRpcParser->_xh['isf'] > 1) { |
|
| 365 | + if ($xmlRpcParser->_xh['isf']>1) { |
|
| 366 | 366 | // test that $xmlrpc->_xh['value'] is an obj, too??? |
| 367 | 367 | |
| 368 | 368 | $this->getLogger()->errorLog($xmlRpcParser->_xh['isf_reason']); |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | case 'methodcall': |
| 388 | 388 | $req = new Request($xmlRpcParser->_xh['method']); |
| 389 | - for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) { |
|
| 389 | + for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) { |
|
| 390 | 390 | $req->addParam($xmlRpcParser->_xh['params'][$i]); |
| 391 | 391 | } |
| 392 | 392 | return $req; |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | // read chunk-size, chunk-extension (if any) and crlf |
| 47 | 47 | // get the position of the linebreak |
| 48 | - $chunkEnd = strpos($buffer, "\r\n") + 2; |
|
| 48 | + $chunkEnd = strpos($buffer, "\r\n")+2; |
|
| 49 | 49 | $temp = substr($buffer, 0, $chunkEnd); |
| 50 | 50 | $chunkSize = hexdec(trim($temp)); |
| 51 | 51 | $chunkStart = $chunkEnd; |
| 52 | - while ($chunkSize > 0) { |
|
| 53 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize); |
|
| 52 | + while ($chunkSize>0) { |
|
| 53 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize); |
|
| 54 | 54 | |
| 55 | 55 | // just in case we got a broken connection |
| 56 | 56 | if ($chunkEnd == false) { |
@@ -62,19 +62,19 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // read chunk-data and crlf |
| 65 | - $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
| 65 | + $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
| 66 | 66 | // append chunk-data to entity-body |
| 67 | 67 | $new .= $chunk; |
| 68 | 68 | // length := length + chunk-size |
| 69 | 69 | $length += strlen($chunk); |
| 70 | 70 | // read chunk-size and crlf |
| 71 | - $chunkStart = $chunkEnd + 2; |
|
| 71 | + $chunkStart = $chunkEnd+2; |
|
| 72 | 72 | |
| 73 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2; |
|
| 73 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2; |
|
| 74 | 74 | if ($chunkEnd == false) { |
| 75 | 75 | break; // just in case we got a broken connection |
| 76 | 76 | } |
| 77 | - $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
| 77 | + $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
| 78 | 78 | $chunkSize = hexdec(trim($temp)); |
| 79 | 79 | $chunkStart = $chunkEnd; |
| 80 | 80 | } |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | // Look for CR/LF or simple LF as line separator (even though it is not valid http) |
| 104 | 104 | $pos = strpos($data, "\r\n\r\n"); |
| 105 | 105 | if ($pos || is_int($pos)) { |
| 106 | - $bd = $pos + 4; |
|
| 106 | + $bd = $pos+4; |
|
| 107 | 107 | } else { |
| 108 | 108 | $pos = strpos($data, "\n\n"); |
| 109 | 109 | if ($pos || is_int($pos)) { |
| 110 | - $bd = $pos + 2; |
|
| 110 | + $bd = $pos+2; |
|
| 111 | 111 | } else { |
| 112 | 112 | // No separation between response headers and body: fault? |
| 113 | 113 | $bd = 0; |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | // this filters out all http headers from proxy. maybe we could take them into account, too? |
| 118 | 118 | $data = substr($data, $bd); |
| 119 | 119 | } else { |
| 120 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed'); |
|
| 121 | - throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
| 120 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed'); |
|
| 121 | + throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if ($httpResponse['status_code'] !== '200') { |
| 154 | - $errstr = substr($data, 0, strpos($data, "\n") - 1); |
|
| 155 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr); |
|
| 156 | - throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']); |
|
| 154 | + $errstr = substr($data, 0, strpos($data, "\n")-1); |
|
| 155 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr); |
|
| 156 | + throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // be tolerant to usage of \n instead of \r\n to separate headers and data (even though it is not valid http) |
| 160 | 160 | $pos = strpos($data, "\r\n\r\n"); |
| 161 | 161 | if ($pos || is_int($pos)) { |
| 162 | - $bd = $pos + 4; |
|
| 162 | + $bd = $pos+4; |
|
| 163 | 163 | } else { |
| 164 | 164 | $pos = strpos($data, "\n\n"); |
| 165 | 165 | if ($pos || is_int($pos)) { |
| 166 | - $bd = $pos + 2; |
|
| 166 | + $bd = $pos+2; |
|
| 167 | 167 | } else { |
| 168 | 168 | // No separation between response headers and body: fault? |
| 169 | 169 | // we could take some action here instead of going on... |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | foreach ($ar as $line) { |
| 178 | 178 | // take care of multi-line headers and cookies |
| 179 | 179 | $arr = explode(':', $line, 2); |
| 180 | - if (count($arr) > 1) { |
|
| 180 | + if (count($arr)>1) { |
|
| 181 | 181 | $headerName = strtolower(trim($arr[0])); |
| 182 | 182 | /// @todo some other headers (the ones that allow a CSV list of values) do allow many values to be |
| 183 | 183 | /// passed using multiple header lines. |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | foreach ($cookies as $cookie) { |
| 195 | 195 | // glue together all received cookies, using a comma to separate them (same as php does with getallheaders()) |
| 196 | 196 | if (isset($httpResponse['headers'][$headerName])) { |
| 197 | - $httpResponse['headers'][$headerName] .= ', ' . trim($cookie); |
|
| 197 | + $httpResponse['headers'][$headerName] .= ', '.trim($cookie); |
|
| 198 | 198 | } else { |
| 199 | 199 | $httpResponse['headers'][$headerName] = trim($cookie); |
| 200 | 200 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | } elseif (isset($headerName)) { |
| 225 | 225 | /// @todo version1 cookies might span multiple lines, thus breaking the parsing above |
| 226 | - $httpResponse['headers'][$headerName] .= ' ' . trim($line); |
|
| 226 | + $httpResponse['headers'][$headerName] .= ' '.trim($line); |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | // Decode chunked encoding sent by http 1.1 servers |
| 247 | 247 | if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') { |
| 248 | 248 | if (!$data = static::decodeChunked($data)) { |
| 249 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server'); |
|
| 249 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server'); |
|
| 250 | 250 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail'], null, $httpResponse['status_code']); |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -261,19 +261,19 @@ discard block |
||
| 261 | 261 | if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { |
| 262 | 262 | $data = $degzdata; |
| 263 | 263 | if ($debug) { |
| 264 | - $this->getLogger()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
| 264 | + $this->getLogger()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
| 265 | 265 | } |
| 266 | 266 | } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
| 267 | 267 | $data = $degzdata; |
| 268 | 268 | if ($debug) { |
| 269 | - $this->getLogger()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
| 269 | + $this->getLogger()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
| 270 | 270 | } |
| 271 | 271 | } else { |
| 272 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server'); |
|
| 272 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server'); |
|
| 273 | 273 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail'], null, $httpResponse['status_code']); |
| 274 | 274 | } |
| 275 | 275 | } else { |
| 276 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
| 276 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
| 277 | 277 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress'], null, $httpResponse['status_code']); |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | public function parseAcceptHeader($header) |
| 294 | 294 | { |
| 295 | 295 | $accepted = array(); |
| 296 | - foreach(explode(',', $header) as $c) { |
|
| 296 | + foreach (explode(',', $header) as $c) { |
|
| 297 | 297 | if (preg_match('/^([^;]+); *q=([0-9.]+)/', $c, $matches)) { |
| 298 | 298 | $c = $matches[1]; |
| 299 | 299 | $w = $matches[2]; |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | if (count($this->xml_iso88591_Entities['in'])) { |
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | - for ($i = 0; $i < 32; $i++) { |
|
| 94 | + for ($i = 0; $i<32; $i++) { |
|
| 95 | 95 | $this->xml_iso88591_Entities["in"][] = chr($i); |
| 96 | 96 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /// @todo to be 'print safe', should we encode as well character 127 (DEL) ? |
| 100 | 100 | |
| 101 | - for ($i = 160; $i < 256; $i++) { |
|
| 101 | + for ($i = 160; $i<256; $i++) { |
|
| 102 | 102 | $this->xml_iso88591_Entities["in"][] = chr($i); |
| 103 | 103 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
| 104 | 104 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | break;*/ |
| 127 | 127 | |
| 128 | 128 | default: |
| 129 | - throw new \Exception('Unsupported table: ' . $tableName); |
|
| 129 | + throw new \Exception('Unsupported table: '.$tableName); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $srcEncoding = 'UTF-8'; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $conversion = strtoupper($srcEncoding . '_' . $destEncoding); |
|
| 181 | + $conversion = strtoupper($srcEncoding.'_'.$destEncoding); |
|
| 182 | 182 | |
| 183 | 183 | // list ordered with (expected) most common scenarios first |
| 184 | 184 | switch ($conversion) { |
@@ -196,20 +196,20 @@ discard block |
||
| 196 | 196 | // NB: this will choke on invalid UTF-8, going most likely beyond EOF |
| 197 | 197 | $escapedData = ''; |
| 198 | 198 | // be kind to users creating string xmlrpc values out of different php types |
| 199 | - $data = (string)$data; |
|
| 199 | + $data = (string) $data; |
|
| 200 | 200 | $ns = strlen($data); |
| 201 | - for ($nn = 0; $nn < $ns; $nn++) { |
|
| 201 | + for ($nn = 0; $nn<$ns; $nn++) { |
|
| 202 | 202 | $ch = $data[$nn]; |
| 203 | 203 | $ii = ord($ch); |
| 204 | 204 | // 7 bits in 1 byte: 0bbbbbbb (127) |
| 205 | - if ($ii < 32) { |
|
| 205 | + if ($ii<32) { |
|
| 206 | 206 | if ($conversion == 'UTF-8_US-ASCII') { |
| 207 | 207 | $escapedData .= sprintf('&#%d;', $ii); |
| 208 | 208 | } else { |
| 209 | 209 | $escapedData .= $ch; |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | - else if ($ii < 128) { |
|
| 212 | + else if ($ii<128) { |
|
| 213 | 213 | /// @todo shall we replace this with a (supposedly) faster str_replace? |
| 214 | 214 | /// @todo to be 'print safe', should we encode as well character 127 (DEL) ? |
| 215 | 215 | switch ($ii) { |
@@ -234,25 +234,25 @@ discard block |
||
| 234 | 234 | } // 11 bits in 2 bytes: 110bbbbb 10bbbbbb (2047) |
| 235 | 235 | elseif ($ii >> 5 == 6) { |
| 236 | 236 | $b1 = ($ii & 31); |
| 237 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
| 238 | - $ii = ($b1 * 64) + $b2; |
|
| 237 | + $b2 = (ord($data[$nn+1]) & 63); |
|
| 238 | + $ii = ($b1 * 64)+$b2; |
|
| 239 | 239 | $escapedData .= sprintf('&#%d;', $ii); |
| 240 | 240 | $nn += 1; |
| 241 | 241 | } // 16 bits in 3 bytes: 1110bbbb 10bbbbbb 10bbbbbb |
| 242 | 242 | elseif ($ii >> 4 == 14) { |
| 243 | 243 | $b1 = ($ii & 15); |
| 244 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
| 245 | - $b3 = (ord($data[$nn + 2]) & 63); |
|
| 246 | - $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
|
| 244 | + $b2 = (ord($data[$nn+1]) & 63); |
|
| 245 | + $b3 = (ord($data[$nn+2]) & 63); |
|
| 246 | + $ii = ((($b1 * 64)+$b2) * 64)+$b3; |
|
| 247 | 247 | $escapedData .= sprintf('&#%d;', $ii); |
| 248 | 248 | $nn += 2; |
| 249 | 249 | } // 21 bits in 4 bytes: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
| 250 | 250 | elseif ($ii >> 3 == 30) { |
| 251 | 251 | $b1 = ($ii & 7); |
| 252 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
| 253 | - $b3 = (ord($data[$nn + 2]) & 63); |
|
| 254 | - $b4 = (ord($data[$nn + 3]) & 63); |
|
| 255 | - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
|
| 252 | + $b2 = (ord($data[$nn+1]) & 63); |
|
| 253 | + $b3 = (ord($data[$nn+2]) & 63); |
|
| 254 | + $b4 = (ord($data[$nn+3]) & 63); |
|
| 255 | + $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4; |
|
| 256 | 256 | $escapedData .= sprintf('&#%d;', $ii); |
| 257 | 257 | $nn += 3; |
| 258 | 258 | } |
@@ -305,14 +305,14 @@ discard block |
||
| 305 | 305 | // If src is UTF8, we run htmlspecialchars before converting to the target charset, as |
| 306 | 306 | // htmlspecialchars has limited charset support, but it groks utf8 |
| 307 | 307 | if ($srcEncoding === 'UTF-8') { |
| 308 | - $data = htmlspecialchars($data, defined('ENT_XML1') ? ENT_XML1 | ENT_QUOTES : ENT_QUOTES, 'UTF-8'); |
|
| 308 | + $data = htmlspecialchars($data, defined('ENT_XML1') ? ENT_XML1 | ENT_QUOTES : ENT_QUOTES, 'UTF-8'); |
|
| 309 | 309 | } |
| 310 | 310 | if ($srcEncoding !== $destEncoding) { |
| 311 | 311 | $data = mb_convert_encoding($data, str_replace('US-ASCII', 'ASCII', $destEncoding), str_replace('US-ASCII', 'ASCII', $srcEncoding)); |
| 312 | 312 | } |
| 313 | 313 | if ($data === false) { |
| 314 | 314 | $escapedData = ''; |
| 315 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding via mbstring: failed..."); |
|
| 315 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding via mbstring: failed..."); |
|
| 316 | 316 | } else { |
| 317 | 317 | if ($srcEncoding === 'UTF-8') { |
| 318 | 318 | $escapedData = $data; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | } else { |
| 324 | 324 | $escapedData = ''; |
| 325 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
| 325 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | if (function_exists('mb_list_encodings')) { |
| 341 | 341 | $knownCharsets = array_unique(array_merge($knownCharsets, array_diff(mb_list_encodings(), array( |
| 342 | 342 | 'pass', 'auto', 'wchar', 'BASE64', 'UUENCODE', 'ASCII', 'HTML-ENTITIES', 'Quoted-Printable', |
| 343 | - '7bit','8bit', 'byte2be', 'byte2le', 'byte4be', 'byte4le' |
|
| 343 | + '7bit', '8bit', 'byte2be', 'byte2le', 'byte4be', 'byte4le' |
|
| 344 | 344 | )))); |
| 345 | 345 | } |
| 346 | 346 | return $knownCharsets; |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | case 'iso88591': |
| 395 | 395 | return $this->xml_iso88591_Entities; |
| 396 | 396 | default: |
| 397 | - throw new \Exception('Unsupported charset: ' . $charset); |
|
| 397 | + throw new \Exception('Unsupported charset: '.$charset); |
|
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | $server = $parts['host']; |
| 191 | 191 | $path = isset($parts['path']) ? $parts['path'] : ''; |
| 192 | 192 | if (isset($parts['query'])) { |
| 193 | - $path .= '?' . $parts['query']; |
|
| 193 | + $path .= '?'.$parts['query']; |
|
| 194 | 194 | } |
| 195 | 195 | if (isset($parts['fragment'])) { |
| 196 | - $path .= '#' . $parts['fragment']; |
|
| 196 | + $path .= '#'.$parts['fragment']; |
|
| 197 | 197 | } |
| 198 | 198 | if (isset($parts['port'])) { |
| 199 | 199 | $port = $parts['port']; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | if ($path == '' || $path[0] != '/') { |
| 212 | - $this->path = '/' . $path; |
|
| 212 | + $this->path = '/'.$path; |
|
| 213 | 213 | } else { |
| 214 | 214 | $this->path = $path; |
| 215 | 215 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | //$this->accepted_charset_encodings = $ch->knownCharsets(); |
| 242 | 242 | |
| 243 | 243 | // initialize user_agent string |
| 244 | - $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion; |
|
| 244 | + $this->user_agent = PhpXmlRpc::$xmlrpcName.' '.PhpXmlRpc::$xmlrpcVersion; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | */ |
| 666 | 666 | protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '', |
| 667 | 667 | $authType = 1, $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
| 668 | - $method='http') |
|
| 668 | + $method = 'http') |
|
| 669 | 669 | { |
| 670 | 670 | //trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED); |
| 671 | 671 | |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | * @param int $sslVersion |
| 699 | 699 | * @return Response |
| 700 | 700 | */ |
| 701 | - protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '', |
|
| 701 | + protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '', |
|
| 702 | 702 | $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0, |
| 703 | 703 | $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $keepAlive = false, $key = '', $keyPass = '', |
| 704 | 704 | $sslVersion = 0) |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | */ |
| 738 | 738 | protected function sendPayloadSocket($req, $server, $port, $timeout = 0, $username = '', $password = '', |
| 739 | 739 | $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0, |
| 740 | - $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method='http', $key = '', $keyPass = '', |
|
| 740 | + $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'http', $key = '', $keyPass = '', |
|
| 741 | 741 | $sslVersion = 0) |
| 742 | 742 | { |
| 743 | 743 | /// @todo log a warning if passed an unsupported method |
@@ -774,16 +774,16 @@ discard block |
||
| 774 | 774 | // thanks to Grant Rauscher <[email protected]> for this |
| 775 | 775 | $credentials = ''; |
| 776 | 776 | if ($username != '') { |
| 777 | - $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; |
|
| 777 | + $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n"; |
|
| 778 | 778 | if ($authType != 1) { |
| 779 | 779 | /// @todo make this a proper error, i.e. return a failure |
| 780 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0'); |
|
| 780 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0'); |
|
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | $acceptedEncoding = ''; |
| 785 | 785 | if (is_array($this->accepted_compression) && count($this->accepted_compression)) { |
| 786 | - $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; |
|
| 786 | + $acceptedEncoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n"; |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | $proxyCredentials = ''; |
@@ -795,13 +795,13 @@ discard block |
||
| 795 | 795 | $connectPort = $proxyPort; |
| 796 | 796 | $transport = 'tcp'; |
| 797 | 797 | /// @todo check: should we not use https in some cases? |
| 798 | - $uri = 'http://' . $server . ':' . $port . $this->path; |
|
| 798 | + $uri = 'http://'.$server.':'.$port.$this->path; |
|
| 799 | 799 | if ($proxyUsername != '') { |
| 800 | 800 | if ($proxyAuthType != 1) { |
| 801 | 801 | /// @todo make this a proper error, i.e. return a failure |
| 802 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
| 802 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
| 803 | 803 | } |
| 804 | - $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n"; |
|
| 804 | + $proxyCredentials = 'Proxy-Authorization: Basic '.base64_encode($proxyUsername.':'.$proxyPassword)."\r\n"; |
|
| 805 | 805 | } |
| 806 | 806 | } else { |
| 807 | 807 | $connectServer = $server; |
@@ -816,45 +816,45 @@ discard block |
||
| 816 | 816 | $version = ''; |
| 817 | 817 | foreach ($this->cookies as $name => $cookie) { |
| 818 | 818 | if ($cookie['version']) { |
| 819 | - $version = ' $Version="' . $cookie['version'] . '";'; |
|
| 820 | - $cookieHeader .= ' ' . $name . '="' . $cookie['value'] . '";'; |
|
| 819 | + $version = ' $Version="'.$cookie['version'].'";'; |
|
| 820 | + $cookieHeader .= ' '.$name.'="'.$cookie['value'].'";'; |
|
| 821 | 821 | if ($cookie['path']) { |
| 822 | - $cookieHeader .= ' $Path="' . $cookie['path'] . '";'; |
|
| 822 | + $cookieHeader .= ' $Path="'.$cookie['path'].'";'; |
|
| 823 | 823 | } |
| 824 | 824 | if ($cookie['domain']) { |
| 825 | - $cookieHeader .= ' $Domain="' . $cookie['domain'] . '";'; |
|
| 825 | + $cookieHeader .= ' $Domain="'.$cookie['domain'].'";'; |
|
| 826 | 826 | } |
| 827 | 827 | if ($cookie['port']) { |
| 828 | - $cookieHeader .= ' $Port="' . $cookie['port'] . '";'; |
|
| 828 | + $cookieHeader .= ' $Port="'.$cookie['port'].'";'; |
|
| 829 | 829 | } |
| 830 | 830 | } else { |
| 831 | - $cookieHeader .= ' ' . $name . '=' . $cookie['value'] . ";"; |
|
| 831 | + $cookieHeader .= ' '.$name.'='.$cookie['value'].";"; |
|
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | - $cookieHeader = 'Cookie:' . $version . substr($cookieHeader, 0, -1) . "\r\n"; |
|
| 834 | + $cookieHeader = 'Cookie:'.$version.substr($cookieHeader, 0, -1)."\r\n"; |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | // omit port if default |
| 838 | 838 | if (($port == 80 && in_array($method, array('http', 'http10'))) || ($port == 443 && $method == 'https')) { |
| 839 | - $port = ''; |
|
| 839 | + $port = ''; |
|
| 840 | 840 | } else { |
| 841 | - $port = ':' . $port; |
|
| 841 | + $port = ':'.$port; |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | - $op = 'POST ' . $uri . " HTTP/1.0\r\n" . |
|
| 845 | - 'User-Agent: ' . $this->user_agent . "\r\n" . |
|
| 846 | - 'Host: ' . $server . $port . "\r\n" . |
|
| 847 | - $credentials . |
|
| 848 | - $proxyCredentials . |
|
| 849 | - $acceptedEncoding . |
|
| 850 | - $encodingHdr . |
|
| 851 | - 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . |
|
| 852 | - $cookieHeader . |
|
| 853 | - 'Content-Type: ' . $req->content_type . "\r\nContent-Length: " . |
|
| 854 | - strlen($payload) . "\r\n\r\n" . |
|
| 844 | + $op = 'POST '.$uri." HTTP/1.0\r\n". |
|
| 845 | + 'User-Agent: '.$this->user_agent."\r\n". |
|
| 846 | + 'Host: '.$server.$port."\r\n". |
|
| 847 | + $credentials. |
|
| 848 | + $proxyCredentials. |
|
| 849 | + $acceptedEncoding. |
|
| 850 | + $encodingHdr. |
|
| 851 | + 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)."\r\n". |
|
| 852 | + $cookieHeader. |
|
| 853 | + 'Content-Type: '.$req->content_type."\r\nContent-Length: ". |
|
| 854 | + strlen($payload)."\r\n\r\n". |
|
| 855 | 855 | $payload; |
| 856 | 856 | |
| 857 | - if ($this->debug > 1) { |
|
| 857 | + if ($this->debug>1) { |
|
| 858 | 858 | $this->getLogger()->debugMessage("---SENDING---\n$op\n---END---"); |
| 859 | 859 | } |
| 860 | 860 | |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | |
| 882 | 882 | $context = stream_context_create($contextOptions); |
| 883 | 883 | |
| 884 | - if ($timeout <= 0) { |
|
| 884 | + if ($timeout<=0) { |
|
| 885 | 885 | $connectTimeout = ini_get('default_socket_timeout'); |
| 886 | 886 | } else { |
| 887 | 887 | $connectTimeout = $timeout; |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $connectTimeout, |
| 894 | 894 | STREAM_CLIENT_CONNECT, $context); |
| 895 | 895 | if ($fp) { |
| 896 | - if ($timeout > 0) { |
|
| 896 | + if ($timeout>0) { |
|
| 897 | 897 | stream_set_timeout($fp, $timeout, 0); |
| 898 | 898 | } |
| 899 | 899 | } else { |
@@ -902,8 +902,8 @@ discard block |
||
| 902 | 902 | $this->errstr = $err['message']; |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - $this->errstr = 'Connect error: ' . $this->errstr; |
|
| 906 | - $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')'); |
|
| 905 | + $this->errstr = 'Connect error: '.$this->errstr; |
|
| 906 | + $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr.' ('.$this->errno.')'); |
|
| 907 | 907 | |
| 908 | 908 | return $r; |
| 909 | 909 | } |
@@ -991,18 +991,18 @@ discard block |
||
| 991 | 991 | $keyPass, $sslVersion); |
| 992 | 992 | |
| 993 | 993 | if (!$curl) { |
| 994 | - return new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': error during curl initialization. Check php error log for details'); |
|
| 994 | + return new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': error during curl initialization. Check php error log for details'); |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | $result = curl_exec($curl); |
| 998 | 998 | |
| 999 | - if ($this->debug > 1) { |
|
| 999 | + if ($this->debug>1) { |
|
| 1000 | 1000 | $message = "---CURL INFO---\n"; |
| 1001 | 1001 | foreach (curl_getinfo($curl) as $name => $val) { |
| 1002 | 1002 | if (is_array($val)) { |
| 1003 | 1003 | $val = implode("\n", $val); |
| 1004 | 1004 | } |
| 1005 | - $message .= $name . ': ' . $val . "\n"; |
|
| 1005 | + $message .= $name.': '.$val."\n"; |
|
| 1006 | 1006 | } |
| 1007 | 1007 | $message .= '---END---'; |
| 1008 | 1008 | $this->getLogger()->debugMessage($message); |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | /// @todo we should use a better check here - what if we get back '' or '0'? |
| 1013 | 1013 | |
| 1014 | 1014 | $this->errstr = 'no response'; |
| 1015 | - $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl)); |
|
| 1015 | + $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl)); |
|
| 1016 | 1016 | curl_close($curl); |
| 1017 | 1017 | if ($keepAlive) { |
| 1018 | 1018 | $this->xmlrpc_curl_handle = null; |
@@ -1082,12 +1082,12 @@ discard block |
||
| 1082 | 1082 | // http, https |
| 1083 | 1083 | $protocol = $method; |
| 1084 | 1084 | if (strpos($protocol, ':') !== false) { |
| 1085 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'"); |
|
| 1085 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'"); |
|
| 1086 | 1086 | return false; |
| 1087 | 1087 | } |
| 1088 | 1088 | } |
| 1089 | 1089 | } |
| 1090 | - $curl = curl_init($protocol . '://' . $server . ':' . $port . $this->path); |
|
| 1090 | + $curl = curl_init($protocol.'://'.$server.':'.$port.$this->path); |
|
| 1091 | 1091 | if (!$curl) { |
| 1092 | 1092 | return false; |
| 1093 | 1093 | } |
@@ -1101,7 +1101,7 @@ discard block |
||
| 1101 | 1101 | // results into variable |
| 1102 | 1102 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
| 1103 | 1103 | |
| 1104 | - if ($this->debug > 1) { |
|
| 1104 | + if ($this->debug>1) { |
|
| 1105 | 1105 | curl_setopt($curl, CURLOPT_VERBOSE, true); |
| 1106 | 1106 | /// @todo allow callers to redirect curlopt_stderr to some stream which can be buffered |
| 1107 | 1107 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | } |
| 1127 | 1127 | } |
| 1128 | 1128 | // extra headers |
| 1129 | - $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); |
|
| 1129 | + $headers = array('Content-Type: '.$req->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)); |
|
| 1130 | 1130 | // if no keepalive is wanted, let the server know it in advance |
| 1131 | 1131 | if (!$keepAlive) { |
| 1132 | 1132 | $headers[] = 'Connection: close'; |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
| 1144 | 1144 | // timeout is borked |
| 1145 | 1145 | if ($timeout) { |
| 1146 | - curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); |
|
| 1146 | + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | switch ($method) { |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE); |
| 1159 | 1159 | } else { |
| 1160 | 1160 | /// @todo make this a proper error, i.e. return a failure |
| 1161 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. HTTP2 is not supported by the current PHP/curl install'); |
|
| 1161 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. HTTP2 is not supported by the current PHP/curl install'); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | break; |
| 1164 | 1164 | case 'h2': |
@@ -1167,12 +1167,12 @@ discard block |
||
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | if ($username && $password) { |
| 1170 | - curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password); |
|
| 1170 | + curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); |
|
| 1171 | 1171 | if (defined('CURLOPT_HTTPAUTH')) { |
| 1172 | 1172 | curl_setopt($curl, CURLOPT_HTTPAUTH, $authType); |
| 1173 | 1173 | } elseif ($authType != 1) { |
| 1174 | 1174 | /// @todo make this a proper error, i.e. return a failure |
| 1175 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
| 1175 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | } |
| 1178 | 1178 | |
@@ -1215,14 +1215,14 @@ discard block |
||
| 1215 | 1215 | if ($proxyPort == 0) { |
| 1216 | 1216 | $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080 |
| 1217 | 1217 | } |
| 1218 | - curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort); |
|
| 1218 | + curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$proxyPort); |
|
| 1219 | 1219 | if ($proxyUsername) { |
| 1220 | - curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword); |
|
| 1220 | + curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername.':'.$proxyPassword); |
|
| 1221 | 1221 | if (defined('CURLOPT_PROXYAUTH')) { |
| 1222 | 1222 | curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType); |
| 1223 | 1223 | } elseif ($proxyAuthType != 1) { |
| 1224 | 1224 | /// @todo make this a proper error, i.e. return a failure |
| 1225 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
| 1225 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | } |
| 1228 | 1228 | } |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | if (count($this->cookies)) { |
| 1233 | 1233 | $cookieHeader = ''; |
| 1234 | 1234 | foreach ($this->cookies as $name => $cookie) { |
| 1235 | - $cookieHeader .= $name . '=' . $cookie['value'] . '; '; |
|
| 1235 | + $cookieHeader .= $name.'='.$cookie['value'].'; '; |
|
| 1236 | 1236 | } |
| 1237 | 1237 | curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2)); |
| 1238 | 1238 | } |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | curl_setopt($curl, $opt, $val); |
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | - if ($this->debug > 1) { |
|
| 1244 | + if ($this->debug>1) { |
|
| 1245 | 1245 | $this->getLogger()->debugMessage("---SENDING---\n$payload\n---END---"); |
| 1246 | 1246 | } |
| 1247 | 1247 | |
@@ -1332,7 +1332,7 @@ discard block |
||
| 1332 | 1332 | $call['methodName'] = new Value($req->method(), 'string'); |
| 1333 | 1333 | $numParams = $req->getNumParams(); |
| 1334 | 1334 | $params = array(); |
| 1335 | - for ($i = 0; $i < $numParams; $i++) { |
|
| 1335 | + for ($i = 0; $i<$numParams; $i++) { |
|
| 1336 | 1336 | $params[$i] = $req->getParam($i); |
| 1337 | 1337 | } |
| 1338 | 1338 | $call['params'] = new Value($params, 'array'); |
@@ -1354,7 +1354,7 @@ discard block |
||
| 1354 | 1354 | $response = array(); |
| 1355 | 1355 | |
| 1356 | 1356 | if ($this->return_type == 'xml') { |
| 1357 | - for ($i = 0; $i < count($reqs); $i++) { |
|
| 1357 | + for ($i = 0; $i<count($reqs); $i++) { |
|
| 1358 | 1358 | $response[] = new Response($rets, 0, '', 'xml', $result->httpResponse()); |
| 1359 | 1359 | } |
| 1360 | 1360 | |
@@ -1362,21 +1362,21 @@ discard block |
||
| 1362 | 1362 | if (!is_array($rets)) { |
| 1363 | 1363 | // bad return type from system.multicall |
| 1364 | 1364 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1365 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': not an array', 'phpvals', $result->httpResponse()); |
|
| 1365 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': not an array', 'phpvals', $result->httpResponse()); |
|
| 1366 | 1366 | } |
| 1367 | 1367 | $numRets = count($rets); |
| 1368 | 1368 | if ($numRets != count($reqs)) { |
| 1369 | 1369 | // wrong number of return values. |
| 1370 | 1370 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1371 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': incorrect number of responses', 'phpvals', |
|
| 1371 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': incorrect number of responses', 'phpvals', |
|
| 1372 | 1372 | $result->httpResponse()); |
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | - for ($i = 0; $i < $numRets; $i++) { |
|
| 1375 | + for ($i = 0; $i<$numRets; $i++) { |
|
| 1376 | 1376 | $val = $rets[$i]; |
| 1377 | 1377 | if (!is_array($val)) { |
| 1378 | 1378 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1379 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array or struct", |
|
| 1379 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array or struct", |
|
| 1380 | 1380 | 'phpvals', $result->httpResponse()); |
| 1381 | 1381 | } |
| 1382 | 1382 | switch (count($val)) { |
@@ -1384,7 +1384,7 @@ discard block |
||
| 1384 | 1384 | if (!isset($val[0])) { |
| 1385 | 1385 | // Bad value |
| 1386 | 1386 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1387 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has no value", |
|
| 1387 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has no value", |
|
| 1388 | 1388 | 'phpvals', $result->httpResponse()); |
| 1389 | 1389 | } |
| 1390 | 1390 | // Normal return value |
@@ -1396,20 +1396,20 @@ discard block |
||
| 1396 | 1396 | if (!is_int($code)) { |
| 1397 | 1397 | /// @todo should we check that it is != 0? |
| 1398 | 1398 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1399 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
| 1399 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
| 1400 | 1400 | 'phpvals', $result->httpResponse()); |
| 1401 | 1401 | } |
| 1402 | 1402 | $str = @$val['faultString']; |
| 1403 | 1403 | if (!is_string($str)) { |
| 1404 | 1404 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1405 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no FaultString", |
|
| 1405 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no FaultString", |
|
| 1406 | 1406 | 'phpvals', $result->httpResponse()); |
| 1407 | 1407 | } |
| 1408 | 1408 | $response[$i] = new Response(0, $code, $str, 'phpvals', $result->httpResponse()); |
| 1409 | 1409 | break; |
| 1410 | 1410 | default: |
| 1411 | 1411 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1412 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
| 1412 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
| 1413 | 1413 | 'phpvals', $result->httpResponse()); |
| 1414 | 1414 | } |
| 1415 | 1415 | } |
@@ -1418,14 +1418,14 @@ discard block |
||
| 1418 | 1418 | // return type == 'xmlrpcvals' |
| 1419 | 1419 | if ($rets->kindOf() != 'array') { |
| 1420 | 1420 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1421 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array", 'xmlrpcvals', |
|
| 1421 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array", 'xmlrpcvals', |
|
| 1422 | 1422 | $result->httpResponse()); |
| 1423 | 1423 | } |
| 1424 | 1424 | $numRets = $rets->count(); |
| 1425 | 1425 | if ($numRets != count($reqs)) { |
| 1426 | 1426 | // wrong number of return values. |
| 1427 | 1427 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1428 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': incorrect number of responses', 'xmlrpcvals', |
|
| 1428 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': incorrect number of responses', 'xmlrpcvals', |
|
| 1429 | 1429 | $result->httpResponse()); |
| 1430 | 1430 | } |
| 1431 | 1431 | |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | case 'array': |
| 1435 | 1435 | if ($val->count() != 1) { |
| 1436 | 1436 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1437 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
| 1437 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
| 1438 | 1438 | 'phpvals', $result->httpResponse()); |
| 1439 | 1439 | } |
| 1440 | 1440 | // Normal return value |
@@ -1443,28 +1443,28 @@ discard block |
||
| 1443 | 1443 | case 'struct': |
| 1444 | 1444 | if ($val->count() != 2) { |
| 1445 | 1445 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1446 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
| 1446 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
| 1447 | 1447 | 'phpvals', $result->httpResponse()); |
| 1448 | 1448 | } |
| 1449 | 1449 | /** @var Value $code */ |
| 1450 | 1450 | $code = $val['faultCode']; |
| 1451 | 1451 | if ($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') { |
| 1452 | 1452 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1453 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
| 1453 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
| 1454 | 1454 | 'xmlrpcvals', $result->httpResponse()); |
| 1455 | 1455 | } |
| 1456 | 1456 | /** @var Value $str */ |
| 1457 | 1457 | $str = $val['faultString']; |
| 1458 | 1458 | if ($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') { |
| 1459 | 1459 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1460 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
| 1460 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
| 1461 | 1461 | 'xmlrpcvals', $result->httpResponse()); |
| 1462 | 1462 | } |
| 1463 | 1463 | $response[] = new Response(0, $code->scalarval(), $str->scalarval(), 'xmlrpcvals', $result->httpResponse()); |
| 1464 | 1464 | break; |
| 1465 | 1465 | default: |
| 1466 | 1466 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1467 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array or struct", |
|
| 1467 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array or struct", |
|
| 1468 | 1468 | 'xmlrpcvals', $result->httpResponse()); |
| 1469 | 1469 | } |
| 1470 | 1470 | } |