@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ . "/_prepend.php"; |
|
| 2 | +require_once __DIR__."/_prepend.php"; |
|
| 3 | 3 | |
| 4 | 4 | output('<html lang="en"> |
| 5 | 5 | <head><title>phpxmlrpc - Introspect demo</title></head> |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | function display_error($r) |
| 18 | 18 | { |
| 19 | 19 | output("An error occurred: "); |
| 20 | - output("Code: " . $r->faultCode() . " Reason: '" . $r->faultString() . "'<br/>"); |
|
| 20 | + output("Code: ".$r->faultCode()." Reason: '".$r->faultString()."'<br/>"); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | $client = new Client(XMLRPCSERVER); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $client->return_type = XMLRPCParser::RETURN_PHP; |
| 26 | 26 | |
| 27 | 27 | // First off, let's retrieve the list of methods available on the remote server |
| 28 | -output("<h3>methods available at http://" . $client->server . $client->path . "</h3>\n"); |
|
| 28 | +output("<h3>methods available at http://".$client->server.$client->path."</h3>\n"); |
|
| 29 | 29 | $req = new Request('system.listMethods'); |
| 30 | 30 | $resp = $client->send($req); |
| 31 | 31 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | // Then, retrieve the signature and help text of each available method |
| 49 | 49 | foreach ($v as $methodName) { |
| 50 | - output("<h4>" . htmlspecialchars($methodName) . "</h4>\n"); |
|
| 50 | + output("<h4>".htmlspecialchars($methodName)."</h4>\n"); |
|
| 51 | 51 | // build requests first, add params later |
| 52 | 52 | $r1 = new PhpXmlRpc\Request('system.methodHelp'); |
| 53 | 53 | $r2 = new PhpXmlRpc\Request('system.methodSignature'); |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | continue; |
| 84 | 84 | } |
| 85 | 85 | $ret = $sig[0]; |
| 86 | - output("<code>" . htmlspecialchars($ret) . " " |
|
| 87 | - . htmlspecialchars($methodName) . "("); |
|
| 88 | - if (count($sig) > 1) { |
|
| 89 | - for ($k = 1; $k < count($sig); $k++) { |
|
| 86 | + output("<code>".htmlspecialchars($ret)." " |
|
| 87 | + . htmlspecialchars($methodName)."("); |
|
| 88 | + if (count($sig)>1) { |
|
| 89 | + for ($k = 1; $k<count($sig); $k++) { |
|
| 90 | 90 | output(htmlspecialchars($sig[$k])); |
| 91 | - if ($k < count($sig) - 1) { |
|
| 91 | + if ($k<count($sig)-1) { |
|
| 92 | 92 | output(", "); |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @license code licensed under the BSD License: see file license.txt |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -require_once __DIR__ . "/_prepend.php"; |
|
| 18 | +require_once __DIR__."/_prepend.php"; |
|
| 19 | 19 | |
| 20 | 20 | // *** NB: WE BLOCK THIS FROM RUNNING BY DEFAULT IN CASE ACCESS IS GRANTED TO IT IN PRODUCTION BY MISTAKE *** |
| 21 | 21 | // Comment out the following safeguard if you want to use it as is, but remember: this is an open relay !!! |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | // fe. any url using the 'file://' protocol might be considered a hacking attempt |
| 47 | 47 | $client = new Client($url); |
| 48 | 48 | |
| 49 | - if ($req->getNumParams() > 3) { |
|
| 49 | + if ($req->getNumParams()>3) { |
|
| 50 | 50 | // we have to set some options onto the client. |
| 51 | 51 | // Note that if we do not untaint the received values, warnings might be generated... |
| 52 | 52 | $options = $encoder->decode($req->getParam(3)); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $client->setSSLVerifyPeer($val); |
| 69 | 69 | break; |
| 70 | 70 | case 'Timeout': |
| 71 | - $timeout = (integer)$val; |
|
| 71 | + $timeout = (integer) $val; |
|
| 72 | 72 | break; |
| 73 | 73 | } // switch |
| 74 | 74 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /// X-forwarded-for anyway, unless they consider this server as trusted...) |
| 82 | 82 | $reqMethod = $req->getParam(1)->scalarval(); |
| 83 | 83 | $req = new Request($reqMethod); |
| 84 | - if ($req->getNumParams() > 1) { |
|
| 84 | + if ($req->getNumParams()>1) { |
|
| 85 | 85 | $pars = $req->getParam(2); |
| 86 | 86 | foreach ($pars as $par) { |
| 87 | 87 | $req->addParam($par); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // add debug info into response we give back to caller |
| 92 | - Server::xmlrpc_debugmsg("Sending to server $url the payload: " . $req->serialize()); |
|
| 92 | + Server::xmlrpc_debugmsg("Sending to server $url the payload: ".$req->serialize()); |
|
| 93 | 93 | |
| 94 | 94 | return $client->send($req, $timeout); |
| 95 | 95 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public static function xmlrpc_debugmsg($msg) |
| 235 | 235 | { |
| 236 | - static::$_xmlrpc_debuginfo .= $msg . "\n"; |
|
| 236 | + static::$_xmlrpc_debuginfo .= $msg."\n"; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public static function error_occurred($msg) |
| 247 | 247 | { |
| 248 | - static::$_xmlrpcs_occurred_errors .= $msg . "\n"; |
|
| 248 | + static::$_xmlrpcs_occurred_errors .= $msg."\n"; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -266,10 +266,10 @@ discard block |
||
| 266 | 266 | // user debug info should be encoded by the end user using the INTERNAL_ENCODING |
| 267 | 267 | $out = ''; |
| 268 | 268 | if ($this->debug_info != '') { |
| 269 | - $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n" . base64_encode($this->debug_info) . "\n-->\n"; |
|
| 269 | + $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; |
|
| 270 | 270 | } |
| 271 | 271 | if (static::$_xmlrpc_debuginfo != '') { |
| 272 | - $out .= "<!-- DEBUG INFO:\n" . $this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n-->\n"; |
|
| 272 | + $out .= "<!-- DEBUG INFO:\n".$this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."\n-->\n"; |
|
| 273 | 273 | // NB: a better solution MIGHT be to use CDATA, but we need to insert it |
| 274 | 274 | // into return payload AFTER the beginning tag |
| 275 | 275 | //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', static::$_xmlrpc_debuginfo) . "\n]]>\n"; |
@@ -298,8 +298,8 @@ discard block |
||
| 298 | 298 | $this->debug_info = ''; |
| 299 | 299 | |
| 300 | 300 | // Save what we received, before parsing it |
| 301 | - if ($this->debug > 1) { |
|
| 302 | - $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); |
|
| 301 | + if ($this->debug>1) { |
|
| 302 | + $this->debugmsg("+++GOT+++\n".$data."\n+++END+++"); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $r = $this->parseRequestHeaders($data, $reqCharset, $respCharset, $respEncoding); |
@@ -313,21 +313,21 @@ discard block |
||
| 313 | 313 | $r->raw_data = $rawData; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors != '') { |
|
| 317 | - $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . |
|
| 318 | - static::$_xmlrpcs_occurred_errors . "+++END+++"); |
|
| 316 | + if ($this->debug>2 && static::$_xmlrpcs_occurred_errors != '') { |
|
| 317 | + $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n". |
|
| 318 | + static::$_xmlrpcs_occurred_errors."+++END+++"); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | $payload = $this->xml_header($respCharset); |
| 322 | - if ($this->debug > 0) { |
|
| 323 | - $payload = $payload . $this->serializeDebug($respCharset); |
|
| 322 | + if ($this->debug>0) { |
|
| 323 | + $payload = $payload.$this->serializeDebug($respCharset); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | // Do not create response serialization if it has already happened. Helps building json magic |
| 327 | 327 | if (empty($r->payload)) { |
| 328 | 328 | $r->serialize($respCharset); |
| 329 | 329 | } |
| 330 | - $payload = $payload . $r->payload; |
|
| 330 | + $payload = $payload.$r->payload; |
|
| 331 | 331 | |
| 332 | 332 | if ($returnPayload) { |
| 333 | 333 | return $payload; |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | // if we get a warning/error that has output some text before here, then we cannot |
| 337 | 337 | // add a new header. We cannot say we are sending xml, either... |
| 338 | 338 | if (!headers_sent()) { |
| 339 | - header('Content-Type: ' . $r->content_type); |
|
| 339 | + header('Content-Type: '.$r->content_type); |
|
| 340 | 340 | // we do not know if client actually told us an accepted charset, but if it did we have to tell it what we did |
| 341 | 341 | header("Vary: Accept-Charset"); |
| 342 | 342 | |
@@ -359,10 +359,10 @@ discard block |
||
| 359 | 359 | // Note that Apache/mod_php will add (and even alter!) the Content-Length header on its own, but only for |
| 360 | 360 | // responses up to 8000 bytes |
| 361 | 361 | if ($phpNoSelfCompress) { |
| 362 | - header('Content-Length: ' . (int)strlen($payload)); |
|
| 362 | + header('Content-Length: '.(int) strlen($payload)); |
|
| 363 | 363 | } |
| 364 | 364 | } else { |
| 365 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages'); |
|
| 365 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages'); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | print $payload; |
@@ -417,9 +417,9 @@ discard block |
||
| 417 | 417 | $numParams = count($in); |
| 418 | 418 | } |
| 419 | 419 | foreach ($sigs as $curSig) { |
| 420 | - if (count($curSig) == $numParams + 1) { |
|
| 420 | + if (count($curSig) == $numParams+1) { |
|
| 421 | 421 | $itsOK = 1; |
| 422 | - for ($n = 0; $n < $numParams; $n++) { |
|
| 422 | + for ($n = 0; $n<$numParams; $n++) { |
|
| 423 | 423 | if (is_object($in)) { |
| 424 | 424 | $p = $in->getParam($n); |
| 425 | 425 | if ($p->kindOf() == 'scalar') { |
@@ -432,10 +432,10 @@ discard block |
||
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | // param index is $n+1, as first member of sig is return type |
| 435 | - if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) { |
|
| 435 | + if ($pt != $curSig[$n+1] && $curSig[$n+1] != Value::$xmlrpcValue) { |
|
| 436 | 436 | $itsOK = 0; |
| 437 | - $pno = $n + 1; |
|
| 438 | - $wanted = $curSig[$n + 1]; |
|
| 437 | + $pno = $n+1; |
|
| 438 | + $wanted = $curSig[$n+1]; |
|
| 439 | 439 | $got = $pt; |
| 440 | 440 | break; |
| 441 | 441 | } |
@@ -462,10 +462,10 @@ discard block |
||
| 462 | 462 | // check if $_SERVER is populated: it might have been disabled via ini file |
| 463 | 463 | // (this is true even when in CLI mode) |
| 464 | 464 | if (count($_SERVER) == 0) { |
| 465 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated'); |
|
| 465 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated'); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ($this->debug > 1) { |
|
| 468 | + if ($this->debug>1) { |
|
| 469 | 469 | if (function_exists('getallheaders')) { |
| 470 | 470 | $this->debugmsg(''); // empty line |
| 471 | 471 | foreach (getallheaders() as $name => $val) { |
@@ -490,13 +490,13 @@ discard block |
||
| 490 | 490 | if (function_exists('gzinflate') && in_array($contentEncoding, $this->accepted_compression)) { |
| 491 | 491 | if ($contentEncoding == 'deflate' && $degzdata = @gzuncompress($data)) { |
| 492 | 492 | $data = $degzdata; |
| 493 | - if ($this->debug > 1) { |
|
| 494 | - $this->debugmsg("\n+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++"); |
|
| 493 | + if ($this->debug>1) { |
|
| 494 | + $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
| 495 | 495 | } |
| 496 | 496 | } elseif ($contentEncoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
| 497 | 497 | $data = $degzdata; |
| 498 | - if ($this->debug > 1) { |
|
| 499 | - $this->debugmsg("+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++"); |
|
| 498 | + if ($this->debug>1) { |
|
| 499 | + $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
| 500 | 500 | } |
| 501 | 501 | } else { |
| 502 | 502 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_decompress_fail'], |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | if ($reqEncoding == 'ISO-8859-1') { |
| 590 | 590 | $data = utf8_encode($data); |
| 591 | 591 | } else { |
| 592 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $reqEncoding); |
|
| 592 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$reqEncoding); |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | } |
@@ -608,18 +608,18 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | $xmlRpcParser = $this->getParser(); |
| 610 | 610 | $xmlRpcParser->parse($data, $this->functions_parameters_type, XMLParser::ACCEPT_REQUEST, $options); |
| 611 | - if ($xmlRpcParser->_xh['isf'] > 2) { |
|
| 611 | + if ($xmlRpcParser->_xh['isf']>2) { |
|
| 612 | 612 | // (BC) we return XML error as a faultCode |
| 613 | 613 | preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches); |
| 614 | 614 | $r = new Response( |
| 615 | 615 | 0, |
| 616 | - PhpXmlRpc::$xmlrpcerrxml + (int)$matches[1], |
|
| 616 | + PhpXmlRpc::$xmlrpcerrxml+(int) $matches[1], |
|
| 617 | 617 | $xmlRpcParser->_xh['isf_reason']); |
| 618 | 618 | } elseif ($xmlRpcParser->_xh['isf']) { |
| 619 | 619 | $r = new Response( |
| 620 | 620 | 0, |
| 621 | 621 | PhpXmlRpc::$xmlrpcerr['invalid_request'], |
| 622 | - PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']); |
|
| 622 | + PhpXmlRpc::$xmlrpcstr['invalid_request'].' '.$xmlRpcParser->_xh['isf_reason']); |
|
| 623 | 623 | } else { |
| 624 | 624 | // small layering violation in favor of speed and memory usage: |
| 625 | 625 | // we should allow the 'execute' method handle this, but in the |
@@ -631,20 +631,20 @@ discard block |
||
| 631 | 631 | ($this->dmap[$xmlRpcParser->_xh['method']]['parameters_type'] != 'xmlrpcvals') |
| 632 | 632 | ) |
| 633 | 633 | ) { |
| 634 | - if ($this->debug > 1) { |
|
| 635 | - $this->debugmsg("\n+++PARSED+++\n" . var_export($xmlRpcParser->_xh['params'], true) . "\n+++END+++"); |
|
| 634 | + if ($this->debug>1) { |
|
| 635 | + $this->debugmsg("\n+++PARSED+++\n".var_export($xmlRpcParser->_xh['params'], true)."\n+++END+++"); |
|
| 636 | 636 | } |
| 637 | 637 | $r = $this->execute($xmlRpcParser->_xh['method'], $xmlRpcParser->_xh['params'], $xmlRpcParser->_xh['pt']); |
| 638 | 638 | } else { |
| 639 | 639 | // build a Request object with data parsed from xml |
| 640 | 640 | $req = new Request($xmlRpcParser->_xh['method']); |
| 641 | 641 | // now add parameters in |
| 642 | - for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) { |
|
| 642 | + for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) { |
|
| 643 | 643 | $req->addParam($xmlRpcParser->_xh['params'][$i]); |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - if ($this->debug > 1) { |
|
| 647 | - $this->debugmsg("\n+++PARSED+++\n" . var_export($req, true) . "\n+++END+++"); |
|
| 646 | + if ($this->debug>1) { |
|
| 647 | + $this->debugmsg("\n+++PARSED+++\n".var_export($req, true)."\n+++END+++"); |
|
| 648 | 648 | } |
| 649 | 649 | $r = $this->execute($req); |
| 650 | 650 | } |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | return new Response( |
| 697 | 697 | 0, |
| 698 | 698 | PhpXmlRpc::$xmlrpcerr['incorrect_params'], |
| 699 | - PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": {$errStr}" |
|
| 699 | + PhpXmlRpc::$xmlrpcstr['incorrect_params'].": {$errStr}" |
|
| 700 | 700 | ); |
| 701 | 701 | } |
| 702 | 702 | } |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | |
| 710 | 710 | if (is_array($func)) { |
| 711 | 711 | if (is_object($func[0])) { |
| 712 | - $funcName = get_class($func[0]) . '->' . $func[1]; |
|
| 712 | + $funcName = get_class($func[0]).'->'.$func[1]; |
|
| 713 | 713 | } else { |
| 714 | 714 | $funcName = implode('::', $func); |
| 715 | 715 | } |
@@ -721,17 +721,17 @@ discard block |
||
| 721 | 721 | |
| 722 | 722 | // verify that function to be invoked is in fact callable |
| 723 | 723 | if (!is_callable($func)) { |
| 724 | - $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable"); |
|
| 724 | + $this->getLogger()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler is not callable"); |
|
| 725 | 725 | return new Response( |
| 726 | 726 | 0, |
| 727 | 727 | PhpXmlRpc::$xmlrpcerr['server_error'], |
| 728 | - PhpXmlRpc::$xmlrpcstr['server_error'] . ": no function matches method" |
|
| 728 | + PhpXmlRpc::$xmlrpcstr['server_error'].": no function matches method" |
|
| 729 | 729 | ); |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | // If debug level is 3, we should catch all errors generated during |
| 733 | 733 | // processing of user function, and log them as part of response |
| 734 | - if ($this->debug > 2) { |
|
| 734 | + if ($this->debug>2) { |
|
| 735 | 735 | self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler')); |
| 736 | 736 | } |
| 737 | 737 | |
@@ -744,14 +744,14 @@ discard block |
||
| 744 | 744 | $r = call_user_func($func, $req); |
| 745 | 745 | } |
| 746 | 746 | if (!is_a($r, 'PhpXmlRpc\Response')) { |
| 747 | - $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r)); |
|
| 747 | + $this->getLogger()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler does not return an xmlrpc response object but a ".gettype($r)); |
|
| 748 | 748 | if (is_a($r, 'PhpXmlRpc\Value')) { |
| 749 | 749 | $r = new Response($r); |
| 750 | 750 | } else { |
| 751 | 751 | $r = new Response( |
| 752 | 752 | 0, |
| 753 | 753 | PhpXmlRpc::$xmlrpcerr['server_error'], |
| 754 | - PhpXmlRpc::$xmlrpcstr['server_error'] . ": function does not return xmlrpc response object" |
|
| 754 | + PhpXmlRpc::$xmlrpcstr['server_error'].": function does not return xmlrpc response object" |
|
| 755 | 755 | ); |
| 756 | 756 | } |
| 757 | 757 | } |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | // mimic EPI behaviour: if we get an array that looks like an error, make it |
| 768 | 768 | // an error response |
| 769 | 769 | if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) { |
| 770 | - $r = new Response(0, (integer)$r['faultCode'], (string)$r['faultString']); |
|
| 770 | + $r = new Response(0, (integer) $r['faultCode'], (string) $r['faultString']); |
|
| 771 | 771 | } else { |
| 772 | 772 | // functions using EPI api should NOT return resp objects, |
| 773 | 773 | // so make sure we encode the return type correctly |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | // proper error-response |
| 791 | 791 | switch ($this->exception_handling) { |
| 792 | 792 | case 2: |
| 793 | - if ($this->debug > 2) { |
|
| 793 | + if ($this->debug>2) { |
|
| 794 | 794 | if (self::$_xmlrpcs_prev_ehandler) { |
| 795 | 795 | set_error_handler(self::$_xmlrpcs_prev_ehandler); |
| 796 | 796 | } else { |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | // proper error-response |
| 814 | 814 | switch ($this->exception_handling) { |
| 815 | 815 | case 2: |
| 816 | - if ($this->debug > 2) { |
|
| 816 | + if ($this->debug>2) { |
|
| 817 | 817 | if (self::$_xmlrpcs_prev_ehandler) { |
| 818 | 818 | set_error_handler(self::$_xmlrpcs_prev_ehandler); |
| 819 | 819 | } else { |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_error'], PhpXmlRpc::$xmlrpcstr['server_error']); |
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | - if ($this->debug > 2) { |
|
| 835 | + if ($this->debug>2) { |
|
| 836 | 836 | // note: restore the error handler we found before calling the |
| 837 | 837 | // user func, even if it has been changed inside the func itself |
| 838 | 838 | if (self::$_xmlrpcs_prev_ehandler) { |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | */ |
| 854 | 854 | protected function debugmsg($string) |
| 855 | 855 | { |
| 856 | - $this->debug_info .= $string . "\n"; |
|
| 856 | + $this->debug_info .= $string."\n"; |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
@@ -863,9 +863,9 @@ discard block |
||
| 863 | 863 | protected function xml_header($charsetEncoding = '') |
| 864 | 864 | { |
| 865 | 865 | if ($charsetEncoding != '') { |
| 866 | - return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n"; |
|
| 866 | + return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?".">\n"; |
|
| 867 | 867 | } else { |
| 868 | - return "<?xml version=\"1.0\"?" . ">\n"; |
|
| 868 | + return "<?xml version=\"1.0\"?".">\n"; |
|
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | $i++; // for error message, we count params from 1 |
| 1137 | 1137 | return static::_xmlrpcs_multicall_error(new Response(0, |
| 1138 | 1138 | PhpXmlRpc::$xmlrpcerr['incorrect_params'], |
| 1139 | - PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i)); |
|
| 1139 | + PhpXmlRpc::$xmlrpcstr['incorrect_params'].": probable xml error in param ".$i)); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | } |
| 1142 | 1142 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | } |
| 1218 | 1218 | } else { |
| 1219 | 1219 | $numCalls = count($req); |
| 1220 | - for ($i = 0; $i < $numCalls; $i++) { |
|
| 1220 | + for ($i = 0; $i<$numCalls; $i++) { |
|
| 1221 | 1221 | $result[$i] = static::_xmlrpcs_multicall_do_call_phpvals($server, $req[$i]); |
| 1222 | 1222 | } |
| 1223 | 1223 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $moe = $sno["moe"]; |
| 37 | 37 | $larry = $sno["larry"]; |
| 38 | 38 | $curly = $sno["curly"]; |
| 39 | - $num = $moe->scalarval() + $larry->scalarval() + $curly->scalarval(); |
|
| 39 | + $num = $moe->scalarval()+$larry->scalarval()+$curly->scalarval(); |
|
| 40 | 40 | |
| 41 | 41 | return new Response(new Value($num, Value::$xmlrpcInt)); |
| 42 | 42 | } |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | $ar = $req->getParam(0); |
| 79 | 79 | $sz = $ar->count(); |
| 80 | 80 | $first = $ar[0]; |
| 81 | - $last = $ar[$sz - 1]; |
|
| 81 | + $last = $ar[$sz-1]; |
|
| 82 | 82 | |
| 83 | - return new Response(new Value($first->scalarval() . $last->scalarval(), Value::$xmlrpcString)); |
|
| 83 | + return new Response(new Value($first->scalarval().$last->scalarval(), Value::$xmlrpcString)); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $v1_simpleStructReturn_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcInt)); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $larry = $fools["larry"]; |
| 114 | 114 | $moe = $fools["moe"]; |
| 115 | 115 | |
| 116 | - return new Response(new Value($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), Value::$xmlrpcInt)); |
|
| 116 | + return new Response(new Value($curly->scalarval()+$larry->scalarval()+$moe->scalarval(), Value::$xmlrpcInt)); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $v1_countTheEntities_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcString)); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $ap = 0; |
| 128 | 128 | $qu = 0; |
| 129 | 129 | $amp = 0; |
| 130 | - for ($i = 0; $i < strlen($str); $i++) { |
|
| 130 | + for ($i = 0; $i<strlen($str); $i++) { |
|
| 131 | 131 | $c = substr($str, $i, 1); |
| 132 | 132 | switch ($c) { |
| 133 | 133 | case ">": |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | function plain_findstate($stateNo) |
| 28 | 28 | { |
| 29 | - if (isset(exampleMethods::$stateNames[$stateNo - 1])) { |
|
| 29 | + if (isset(exampleMethods::$stateNames[$stateNo - 1])) { |
|
| 30 | 30 | return exampleMethods::$stateNames[$stateNo - 1]; |
| 31 | 31 | } else { |
| 32 | 32 | // not, there so complain |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | function plain_findstate($stateNo) |
| 28 | 28 | { |
| 29 | - if (isset(exampleMethods::$stateNames[$stateNo - 1])) { |
|
| 30 | - return exampleMethods::$stateNames[$stateNo - 1]; |
|
| 29 | + if (isset(exampleMethods::$stateNames[$stateNo-1])) { |
|
| 30 | + return exampleMethods::$stateNames[$stateNo-1]; |
|
| 31 | 31 | } else { |
| 32 | 32 | // not, there so complain |
| 33 | - throw new Exception("I don't have a state for the index '" . $stateNo . "'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser); |
|
| 33 | + throw new Exception("I don't have a state for the index '".$stateNo."'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $findstate10_sig = array( |
| 126 | 126 | /// @todo add a demo and test with closure usage |
| 127 | - "function" => function ($req) { return exampleMethods::findState($req); }, |
|
| 127 | + "function" => function($req) { return exampleMethods::findState($req); }, |
|
| 128 | 128 | "signature" => array(array(Value::$xmlrpcString, Value::$xmlrpcInt)), |
| 129 | - "docstring" => 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the ' . |
|
| 129 | + "docstring" => 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the '. |
|
| 130 | 130 | 'index of that state name in an alphabetic order.', |
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | -$findstate11_sig = $wrapper->wrapPhpFunction(function ($stateNo) { return plain_findstate($stateNo); }); |
|
| 133 | +$findstate11_sig = $wrapper->wrapPhpFunction(function($stateNo) { return plain_findstate($stateNo); }); |
|
| 134 | 134 | |
| 135 | 135 | /// @todo do we really need a new instance ? |
| 136 | 136 | $c = new handlersContainer(); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $namespaceSignatures = $wrapper->wrapPhpClass($c, array('prefix' => 'namespacetest.', 'replace_class_name' => true, 'method_filter' => '/^findState$/', 'method_type' => 'static')); |
| 141 | 141 | |
| 142 | -$returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true)); |
|
| 142 | +$returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true)); |
|
| 143 | 143 | |
| 144 | 144 | return array_merge( |
| 145 | 145 | array( |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | $snv = $sno->scalarval(); |
| 54 | 54 | |
| 55 | 55 | // look it up in our array (zero-based) |
| 56 | - if (isset(self::$stateNames[$snv - 1])) { |
|
| 57 | - $stateName = self::$stateNames[$snv - 1]; |
|
| 56 | + if (isset(self::$stateNames[$snv-1])) { |
|
| 57 | + $stateName = self::$stateNames[$snv-1]; |
|
| 58 | 58 | } else { |
| 59 | 59 | // not there, so complain |
| 60 | - $err = "I don't have a state for the index '" . $snv . "'"; |
|
| 60 | + $err = "I don't have a state for the index '".$snv."'"; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if ($err != '') { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $s = $req->getParam(0); |
| 132 | 132 | $t = $req->getParam(1); |
| 133 | 133 | |
| 134 | - return new Response(new Value($s->scalarval() + $t->scalarval(), Value::$xmlrpcInt)); |
|
| 134 | + return new Response(new Value($s->scalarval()+$t->scalarval(), Value::$xmlrpcInt)); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public static $addtwodouble_sig = array(array('double', 'double', 'double')); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $s = $req->getParam(0); |
| 142 | 142 | $t = $req->getParam(1); |
| 143 | 143 | |
| 144 | - return new Response(new Value($s->scalarval() + $t->scalarval(), Value::$xmlrpcDouble)); |
|
| 144 | + return new Response(new Value($s->scalarval()+$t->scalarval(), Value::$xmlrpcDouble)); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public static $stringecho_sig = array(array('string', 'string')); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | public static function echoBack($req) |
| 158 | 158 | { |
| 159 | 159 | // just sends back a string with what I got sent to me, that's all (escaping for xml is automatic) |
| 160 | - $s = "I got the following message:\n" . $req->serialize(); |
|
| 160 | + $s = "I got the following message:\n".$req->serialize(); |
|
| 161 | 161 | |
| 162 | 162 | return new Response(new Value($s)); |
| 163 | 163 | } |
@@ -230,17 +230,17 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | /// @todo in real life, we should check for presence of return characters to avoid header injection! |
| 232 | 232 | |
| 233 | - $msgHdr = "From: " . $mFrom->scalarval() . "\n"; |
|
| 234 | - $msgHdr .= "To: " . $mTo->scalarval() . "\n"; |
|
| 233 | + $msgHdr = "From: ".$mFrom->scalarval()."\n"; |
|
| 234 | + $msgHdr .= "To: ".$mTo->scalarval()."\n"; |
|
| 235 | 235 | |
| 236 | 236 | if ($mCc->scalarval() != "") { |
| 237 | - $msgHdr .= "Cc: " . $mCc->scalarval() . "\n"; |
|
| 237 | + $msgHdr .= "Cc: ".$mCc->scalarval()."\n"; |
|
| 238 | 238 | } |
| 239 | 239 | if ($mBcc->scalarval() != "") { |
| 240 | - $msgHdr .= "Bcc: " . $mBcc->scalarval() . "\n"; |
|
| 240 | + $msgHdr .= "Bcc: ".$mBcc->scalarval()."\n"; |
|
| 241 | 241 | } |
| 242 | 242 | if ($mMime->scalarval() != "") { |
| 243 | - $msgHdr .= "Content-type: " . $mMime->scalarval() . "\n"; |
|
| 243 | + $msgHdr .= "Content-type: ".$mMime->scalarval()."\n"; |
|
| 244 | 244 | } |
| 245 | 245 | $msgHdr .= "X-Mailer: XML-RPC for PHP mailer 1.0"; |
| 246 | 246 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ . "/_prepend.php"; |
|
| 2 | +require_once __DIR__."/_prepend.php"; |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Demoing the code-generation capabilities of the library: create a client class which exposes a bunch of methods |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | 23 | // the generated code does not have an autoloader included - we need to add in one |
| 24 | -$autoloader = __DIR__ . "/_prepend.php"; |
|
| 24 | +$autoloader = __DIR__."/_prepend.php"; |
|
| 25 | 25 | |
| 26 | 26 | $targetFile = '/tmp/MyClient.php'; |
| 27 | 27 | $generated = file_put_contents($targetFile, |
| 28 | - "<?php\n\n" . |
|
| 29 | - "require_once '$autoloader';\n\n" . |
|
| 28 | + "<?php\n\n". |
|
| 29 | + "require_once '$autoloader';\n\n". |
|
| 30 | 30 | $code['code'] |
| 31 | 31 | ); |
| 32 | 32 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | $client = new MyClient(); |
| 47 | 47 | $sorted = $client->examples_sortByAge(array( |
| 48 | 48 | array('name' => 'Dave', 'age' => 24), |
| 49 | - array('name' => 'Edd', 'age' => 45), |
|
| 50 | - array('name' => 'Joe', 'age' => 37), |
|
| 49 | + array('name' => 'Edd', 'age' => 45), |
|
| 50 | + array('name' => 'Joe', 'age' => 37), |
|
| 51 | 51 | array('name' => 'Fred', 'age' => 27), |
| 52 | 52 | )); |
| 53 | 53 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ . "/_prepend.php"; |
|
| 2 | +require_once __DIR__."/_prepend.php"; |
|
| 3 | 3 | |
| 4 | 4 | require_once __DIR__.'/methodProviders/CommentManager.php'; |
| 5 | 5 | |
@@ -22,19 +22,19 @@ discard block |
||
| 22 | 22 | // generate a file with a class definition |
| 23 | 23 | |
| 24 | 24 | // the generated code does not have an autoloader included - we need to add in one |
| 25 | -$autoloader = __DIR__ . "/_prepend.php"; |
|
| 25 | +$autoloader = __DIR__."/_prepend.php"; |
|
| 26 | 26 | |
| 27 | 27 | file_put_contents($targetClassFile, |
| 28 | - "<?php\n\n" . |
|
| 29 | - "require_once '$autoloader';\n\n" . |
|
| 28 | + "<?php\n\n". |
|
| 29 | + "require_once '$autoloader';\n\n". |
|
| 30 | 30 | "class MyServerClass {\n\n" |
| 31 | 31 | ) || die('uh oh'); |
| 32 | 32 | |
| 33 | 33 | // we mangle a bit the code we get from wrapPhpClass to generate a php class instead of a bunch of functions |
| 34 | 34 | |
| 35 | -foreach($code as $methodName => $methodDef) { |
|
| 36 | - file_put_contents($targetClassFile, 'public static ' . $methodDef['source'] . "\n\n", FILE_APPEND) || die('uh oh'); |
|
| 37 | - $code[$methodName]['function'] = 'MyServerClass::' . $methodDef['function']; |
|
| 35 | +foreach ($code as $methodName => $methodDef) { |
|
| 36 | + file_put_contents($targetClassFile, 'public static '.$methodDef['source']."\n\n", FILE_APPEND) || die('uh oh'); |
|
| 37 | + $code[$methodName]['function'] = 'MyServerClass::'.$methodDef['function']; |
|
| 38 | 38 | unset($code[$methodName]['source']); |
| 39 | 39 | } |
| 40 | 40 | file_put_contents($targetClassFile, "}\n", FILE_APPEND) || die('uh oh'); |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | // generate the separate file with the xml-rpc server and dispatch map |
| 43 | 43 | |
| 44 | 44 | file_put_contents($targetServerFile, |
| 45 | - "<?php\n\n" . |
|
| 45 | + "<?php\n\n". |
|
| 46 | 46 | |
| 47 | - "require_once '$autoloader';\n\n" . |
|
| 47 | + "require_once '$autoloader';\n\n". |
|
| 48 | 48 | |
| 49 | - "require_once '$targetClassFile';\n\n" . |
|
| 49 | + "require_once '$targetClassFile';\n\n". |
|
| 50 | 50 | |
| 51 | 51 | // NB: since we are running the generated code within the same script, the existing CommentManager instance will be |
| 52 | 52 | // available for usage by the methods of MyServerClass, as we keep a reference to them within the variable Wrapper::$objHolder |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | // Wrapper::$objHolder['xmlrpc_CommentManager_addComment'] = $cm; |
| 57 | 57 | // Wrapper::$objHolder['xmlrpc_CommentManager_getComments'] = $cm; |
| 58 | 58 | |
| 59 | - '$dm = ' . var_export($code, true) . ";\n" . |
|
| 60 | - '$s = new \PhpXmlRpc\Server($dm, false);' . "\n" . |
|
| 61 | - '$s->setDebug(2);' . "\n" . |
|
| 62 | - '$s->exception_handling = 1;' . "\n" . |
|
| 63 | - '$s->service();' . "\n" |
|
| 59 | + '$dm = '.var_export($code, true).";\n". |
|
| 60 | + '$s = new \PhpXmlRpc\Server($dm, false);'."\n". |
|
| 61 | + '$s->setDebug(2);'."\n". |
|
| 62 | + '$s->exception_handling = 1;'."\n". |
|
| 63 | + '$s->service();'."\n" |
|
| 64 | 64 | ) || die('uh oh'); |
| 65 | 65 | |
| 66 | 66 | // test that everything worked by running it in realtime |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * `$functions_parameters_type` and `$exception_handling` |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -require_once __DIR__ . "/_prepend.php"; |
|
| 11 | +require_once __DIR__."/_prepend.php"; |
|
| 12 | 12 | |
| 13 | 13 | require_once __DIR__.'/methodProviders/CommentManager.php'; |
| 14 | 14 | |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | $addComment_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcString, Value::$xmlrpcString, Value::$xmlrpcString)); |
| 21 | 21 | |
| 22 | -$addComment_doc = 'Adds a comment to an item. The first parameter is the item ID, the second the name of the commenter, ' . |
|
| 22 | +$addComment_doc = 'Adds a comment to an item. The first parameter is the item ID, the second the name of the commenter, '. |
|
| 23 | 23 | 'and the third is the comment itself. Returns the number of comments against that ID.'; |
| 24 | 24 | |
| 25 | 25 | $getComments_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcString)); |
| 26 | 26 | |
| 27 | -$getComments_doc = 'Returns an array of comments for a given ID, which is the sole argument. Each array item is a struct ' . |
|
| 27 | +$getComments_doc = 'Returns an array of comments for a given ID, which is the sole argument. Each array item is a struct '. |
|
| 28 | 28 | 'containing name and comment text.'; |
| 29 | 29 | |
| 30 | 30 | $srv = new Server(array( |