X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=debugger%2Faction.php;h=0d0a649eda2849dfed7bb893da0eca3bd076d032;hb=ac1be9e3d16b57c4ff926c0f3f766fc971f1750c;hp=7bb07f50f12d05c06a039b6ed738714595061211;hpb=eaeefaf3ab806831c00824b6c102037c7296c289;p=plcapi.git diff --git a/debugger/action.php b/debugger/action.php index 7bb07f5..0d0a649 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'); + ?> @@ -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; @@ -265,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")); @@ -281,37 +284,36 @@ if ($action) { $v = $response->value(); if ($v->kindOf() == "array") { - $max = $v->arraysize(); + $max = $v->count(); echo "\n"; - echo "\n\n\n\n"; - for ($i = 0; $i < $max; $i++) { - $rec = $v->arraymem($i); + echo "\n\n\n\n"; + foreach($v as $i => $rec) { if ($i % 2) { $class = ' class="oddrow"'; } 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) . "\" />" . "" . "" . "" . @@ -341,37 +343,51 @@ 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++) { + foreach($r2 as $i => $x) { + $payload = ""; + $alt_payload = ""; if ($i + 1 % 2) { $class = ' class="oddrow"'; } else { $class = ' class="evenrow"'; } echo "Signature " . ($i + 1) . ""; - $x = $r2->arraymem($i); if ($x->kindOf() == "array") { - $ret = $x->arraymem(0); - echo "OUT: " . htmlspecialchars($ret->scalarval()) . "
IN: ("; - if ($x->arraysize() > 1) { - for ($k = 1; $k < $x->arraysize(); $k++) { - $y = $x->arraymem($k); - echo $y->scalarval(); + $ret = $x[0]; + echo "OUT: " . htmlspecialchars($ret->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "
IN: ("; + if ($x->count() > 1) { + foreach($x as $k => $y) { + if ($k == 0) continue; + 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) { + if ($k < $x->count() - 1) { $alt_payload .= ';'; echo ", "; } @@ -385,28 +401,28 @@ if ($action) { // button to test this method //$payload="\n$method\n\n$payload\n"; echo "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . - "" . - "" . + "" . + "" . "" . "" . "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . "" . - "" . + "" . "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . ""; if ($wstype != 1) { @@ -415,29 +431,29 @@ if ($action) { echo "\n"; echo "
" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . - "" . - "" . + "" . + "" . "" . "" . "" . - "" . - "" . - "" . - "" . + "" . + "" . + "" . + "" . "" . "" . - "" . + "" . "" . - "" . - "" . + "" . + "" . "" . - "" . - "" . + "" . + "" . "" . "" . "" . @@ -452,7 +468,7 @@ if ($action) { case 'wrap': $r1 = $resp[0]->value(); $r2 = $resp[1]->value(); - if ($r2->kindOf() != "array" || $r2->arraysize() <= $methodsig) { + if ($r2->kindOf() != "array" || $r2->count() <= $methodsig) { echo "Error: signature unknown\n"; } else { $mdesc = $r1->scalarval(); @@ -463,18 +479,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"; @@ -526,6 +541,8 @@ if ($action) {

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