X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=debugger%2Faction.php;h=44d8a0011f1e230414b6b803e7e43df28879ba4d;hb=19b99735570521d8172f73124ade5997b9dca75d;hp=f77c8761f2783ad3bf96df906e35fc7f5e24dff9;hpb=c8a412d48733f671db6ba149659b816c2e14fd3a;p=plcapi.git diff --git a/debugger/action.php b/debugger/action.php index f77c876..44d8a00 100644 --- a/debugger/action.php +++ b/debugger/action.php @@ -8,6 +8,9 @@ * @todo use ob_start to catch debug info and echo it AFTER method call results? * @todo be smarter in creating client stub for proxy/auth cases: only set appropriate property of client obj **/ + +header('Content-Type: text/html; charset=utf-8'); + ?> @@ -104,11 +107,11 @@ if ($action) { if (!class_exists('jsonrpc_client')) { die('Error: to debug the jsonrpc protocol the jsonrpc.inc file is needed'); } - $clientClass = 'PhpJsRpc\client'; - $requestClass = 'PhpJsRpc\request'; + $clientClass = 'PhpJsRpc\Client'; + $requestClass = 'PhpJsRpc\Request'; $protoName = 'JSONRPC'; } else { - $clientClass = 'PhpXmlRpc\client'; + $clientClass = 'PhpXmlRpc\Client'; $requestClass = 'PhpXmlRpc\Request'; $protoName = 'XMLRPC'; } @@ -226,7 +229,7 @@ if ($action) { } } } else { - $msg[0]->payload = $msg[0]->xml_header() . + $msg[0]->payload = $msg[0]->xml_header($inputcharset) . '' . $method . "\n" . $payload . "\n" . $msg[0]->xml_footer(); @@ -239,7 +242,7 @@ if ($action) { // Before calling execute, echo out brief description of action taken + date and time ??? // this gives good user feedback for long-running methods... - echo '

' . htmlspecialchars($actionname) . ' on server ' . htmlspecialchars($server) . " ...

\n"; + echo '

' . htmlspecialchars($actionname, ENT_COMPAT, $inputcharset) . ' on server ' . htmlspecialchars($server, ENT_COMPAT, $inputcharset) . " ...

\n"; flush(); $response = null; @@ -248,8 +251,7 @@ if ($action) { echo '

Debug info:

'; } /// @todo use ob_start instead $resp = array(); - $mtime = explode(' ', microtime()); - $time = (float)$mtime[0] + (float)$mtime[1]; + $time = microtime(true); foreach ($msg as $message) { // catch errors: for older xmlrpc libs, send does not return by ref @$response = $client->send($message, $timeout, $httpprotocol); @@ -258,8 +260,7 @@ if ($action) { break; } } - $mtime = explode(' ', microtime()); - $time = (float)$mtime[0] + (float)$mtime[1] - $time; + $time = microtime(true) - $time; if ($debug) { echo "
\n"; } @@ -267,14 +268,14 @@ if ($action) { if ($response) { if ($response->faultCode()) { // call failed! echo out error msg! - //echo '

'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'

'; + //echo '

'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'

'; echo "

$protoName call FAILED!

\n"; - echo "

Fault code: [" . htmlspecialchars($response->faultCode()) . - "] Reason: '" . htmlspecialchars($response->faultString()) . "'

\n"; + echo "

Fault code: [" . htmlspecialchars($response->faultCode(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . + "] Reason: '" . htmlspecialchars($response->faultString(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "'

\n"; echo(strftime("%d/%b/%Y:%H:%M:%S\n")); } else { // call succeeded: parse results - //echo '

'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'

'; + //echo '

'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'

'; printf("

%s call(s) OK (%.2f secs.)

\n", $protoName, $time); echo(strftime("%d/%b/%Y:%H:%M:%S\n")); @@ -285,7 +286,7 @@ if ($action) { if ($v->kindOf() == "array") { $max = $v->arraysize(); echo "\n"; - echo "\n\n\n\n"; + echo "\n\n\n\n"; for ($i = 0; $i < $max; $i++) { $rec = $v->arraymem($i); if ($i % 2) { @@ -293,27 +294,27 @@ if ($action) { } else { $class = ' class="evenrow"'; } - echo("" . htmlspecialchars($rec->scalarval()) . "
" . - "" . - "" . - "" . - "" . + echo("
" . htmlspecialchars($rec->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "" . + "" . + "" . + "" . + "" . "" . - "" . - "" . + "" . + "" . "" . "" . "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . "" . - "" . + "" . "" . - "" . - "scalarval() . "\" />" . + "" . + "scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "\" />" . "" . "" . "" . @@ -343,18 +344,19 @@ if ($action) { $r2 = $resp[1]->value(); echo "
MethodDescription
Method ($max)Description
\n"; - echo "\n\n\n\n"; - $desc = htmlspecialchars($r1->scalarval()); + echo "\n\n\n\n"; + $desc = htmlspecialchars($r1->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding); if ($desc == "") { $desc = "-"; } echo "\n"; - $payload = ""; - $alt_payload = ""; + if ($r2->kindOf() != "array") { echo "\n"; } else { for ($i = 0; $i < $r2->arraysize(); $i++) { + $payload = ""; + $alt_payload = ""; if ($i + 1 % 2) { $class = ' class="oddrow"'; } else { @@ -364,13 +366,27 @@ if ($action) { $x = $r2->arraymem($i); if ($x->kindOf() == "array") { $ret = $x->arraymem(0); - echo "OUT: " . htmlspecialchars($ret->scalarval()) . "
IN: ("; + echo "OUT: " . htmlspecialchars($ret->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "
IN: ("; if ($x->arraysize() > 1) { for ($k = 1; $k < $x->arraysize(); $k++) { $y = $x->arraymem($k); - echo $y->scalarval(); + echo htmlspecialchars($y->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding); if ($wstype != 1) { - $payload = $payload . '<' . htmlspecialchars($y->scalarval()) . '>scalarval()) . ">\n"; + $type = $y->scalarval(); + $payload .= ''; + switch($type) { + case 'undefined': + break; + case 'null'; + $type = 'nil'; + // fall thru intentionally + default: + $payload .= '<' . + htmlspecialchars($type, ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . + '>'; + } + $payload .= "\n"; } $alt_payload .= $y->scalarval(); if ($k < $x->arraysize() - 1) { @@ -387,28 +403,28 @@ if ($action) { // button to test this method //$payload="\n$method\n\n$payload\n"; echo "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . - "" . - "" . + "" . + "" . "" . "" . "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . "" . - "" . + "" . "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . ""; if ($wstype != 1) { @@ -417,29 +433,29 @@ if ($action) { echo "\n"; echo "
" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . - "" . - "" . + "" . + "" . "" . "" . "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . "" . - "" . + "" . "" . - "" . - "" . + "" . + "" . "" . - "" . - "" . + "" . + "" . "" . "" . "" . @@ -465,18 +481,17 @@ if ($action) { if ($proxy == '' && $username == '' && !$requestcompression && !$responsecompression && $clientcookies == '' ) { - $opts = 0; // simple client copy in stub code + $opts = 1; // simple client copy in stub code } else { - $opts = 1; // complete client copy in stub code + $opts = 0; // complete client copy in stub code } if ($wstype == 1) { $prefix = 'jsonrpc'; } else { $prefix = 'xmlrpc'; } - //$code = wrap_xmlrpc_method($client, $method, $methodsig, 0, $proto, '', $opts); $wrapper = new PhpXmlRpc\Wrapper(); - $code = $wrapper->build_remote_method_wrapper_code($client, $method, str_replace('.', '_', $prefix . '_' . $method), $msig, $mdesc, $timeout, $proto, $opts, $prefix); + $code = $wrapper->buildWrapMethodSource($client, $method, array('timeout' => $timeout, 'protocol' => $proto, 'simple_client_copy' => $opts, 'prefix' => $prefix), str_replace('.', '_', $prefix . '_' . $method), $msig, $mdesc); //if ($code) //{ echo "
\n"; @@ -502,7 +517,7 @@ if ($action) { // no action taken yet: give some instructions on debugger usage ?> -

Instructions on usage of the debugger:

+

Instructions on usage of the debugger

  1. Run a 'list available methods' action against desired server
  2. If list of methods appears, click on 'describe method' for desired method
  3. @@ -516,18 +531,20 @@ if ($action) { } ?> -

    Example:

    +

    Example

    Server Address: phpxmlrpc.sourceforge.net
    Path: /server.php

    -

    Notice:

    +

    Notice

    all usernames and passwords entered on the above form will be written to the web server logs of this server. Use with care.

    Changelog

      +
    • 2015-05-30: fix problems with generating method payloads for NIL and Undefined parameters
    • +
    • 2015-04-19: fix problems with LATIN-1 characters in payload
    • 2007-02-20: add visual editor for method payload; allow strings, bools as jsonrpc msg id
    • 2006-06-26: support building php code stub for calling remote methods
    • 2006-05-25: better support for long running queries; check for no-curl installs
Method" . htmlspecialchars($method) . "  
Method" . htmlspecialchars($method, ENT_COMPAT, $inputcharset) . "  
Description$desc
SignatureUnknown