+ if ($response) {
+ if ($response->faultCode()) {
+ // call failed! echo out error msg!
+ //echo '<h2>'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'</h2>';
+ echo "<h3>$protoName call FAILED!</h3>\n";
+ echo "<p>Fault code: [" . htmlspecialchars($response->faultCode(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) .
+ "] Reason: '" . htmlspecialchars($response->faultString(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "'</p>\n";
+ echo(strftime("%d/%b/%Y:%H:%M:%S\n"));
+ } else {
+ // call succeeded: parse results
+ //echo '<h2>'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'</h2>';
+ printf("<h3>%s call(s) OK (%.2f secs.)</h3>\n", $protoName, $time);
+ echo(strftime("%d/%b/%Y:%H:%M:%S\n"));
+
+ switch ($action) {
+ case 'list':
+
+ $v = $response->value();
+ if ($v->kindOf() == "array") {
+ $max = $v->count();
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
+ echo "<thead>\n<tr><th>Method ($max)</th><th>Description</th></tr>\n</thead>\n<tbody>\n";
+ foreach($v as $i => $rec) {
+ if ($i % 2) {
+ $class = ' class="oddrow"';
+ } else {
+ $class = ' class="evenrow"';
+ }
+ echo("<tr><td$class>" . htmlspecialchars($rec->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "</td><td$class><form action=\"controller.php\" method=\"get\" target=\"frmcontroller\">" .
+ "<input type=\"hidden\" name=\"host\" value=\"" . htmlspecialchars($host, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"port\" value=\"" . htmlspecialchars($port, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"path\" value=\"" . htmlspecialchars($path, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($id, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"debug\" value=\"$debug\" />" .
+ "<input type=\"hidden\" name=\"username\" value=\"" . htmlspecialchars($username, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"password\" value=\"" . htmlspecialchars($password, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"authtype\" value=\"$authtype\" />" .
+ "<input type=\"hidden\" name=\"verifyhost\" value=\"$verifyhost\" />" .
+ "<input type=\"hidden\" name=\"verifypeer\" value=\"$verifypeer\" />" .
+ "<input type=\"hidden\" name=\"cainfo\" value=\"" . htmlspecialchars($cainfo, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxy\" value=\"" . htmlspecialchars($proxy, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxyuser\" value=\"" . htmlspecialchars($proxyuser, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxypwd\" value=\"" . htmlspecialchars($proxypwd, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"responsecompression\" value=\"$responsecompression\" />" .
+ "<input type=\"hidden\" name=\"requestcompression\" value=\"$requestcompression\" />" .
+ "<input type=\"hidden\" name=\"clientcookies\" value=\"" . htmlspecialchars($clientcookies, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"protocol\" value=\"$protocol\" />" .
+ "<input type=\"hidden\" name=\"timeout\" value=\"" . htmlspecialchars($timeout, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"method\" value=\"" . htmlspecialchars($rec->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "\" />" .
+ "<input type=\"hidden\" name=\"wstype\" value=\"$wstype\" />" .
+ "<input type=\"hidden\" name=\"action\" value=\"describe\" />" .
+ "<input type=\"hidden\" name=\"run\" value=\"now\" />" .
+ "<input type=\"submit\" value=\"Describe\" /></form></td>");
+ //echo("</tr>\n");
+
+ // generate the skeleton for method payload per possible tests
+ //$methodpayload="<methodCall>\n<methodName>".$rec->scalarval()."</methodName>\n<params>\n<param><value></value></param>\n</params>\n</methodCall>";
+
+ /*echo ("<form action=\"{$_SERVER['PHP_SELF']}\" method=\"get\"><td>".
+ "<input type=\"hidden\" name=\"host\" value=\"$host\" />".
+ "<input type=\"hidden\" name=\"port\" value=\"$port\" />".
+ "<input type=\"hidden\" name=\"path\" value=\"$path\" />".
+ "<input type=\"hidden\" name=\"method\" value=\"".$rec->scalarval()."\" />".
+ "<input type=\"hidden\" name=\"methodpayload\" value=\"$payload\" />".
+ "<input type=\"hidden\" name=\"action\" value=\"execute\" />".
+ "<input type=\"submit\" value=\"Test\" /></td></form>");*/
+ echo("</tr>\n");
+ }
+ echo "</tbody>\n</table>";
+ }
+ break;
+
+ case 'describe':
+
+ $r1 = $resp[0]->value();
+ $r2 = $resp[1]->value();
+
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
+ echo "<thead>\n<tr><th>Method</th><th>" . htmlspecialchars($method, ENT_COMPAT, $inputcharset) . "</th><th> </th><th> </th></tr>\n</thead>\n<tbody>\n";
+ $desc = htmlspecialchars($r1->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding);
+ if ($desc == "") {
+ $desc = "-";
+ }
+ echo "<tr><td class=\"evenrow\">Description</td><td colspan=\"3\" class=\"evenrow\">$desc</td></tr>\n";
+
+ if ($r2->kindOf() != "array") {
+ echo "<tr><td class=\"oddrow\">Signature</td><td class=\"oddrow\">Unknown</td><td class=\"oddrow\"> </td></tr>\n";
+ } else {
+ foreach($r2 as $i => $x) {
+ $payload = "";
+ $alt_payload = "";
+ if ($i + 1 % 2) {
+ $class = ' class="oddrow"';
+ } else {
+ $class = ' class="evenrow"';
+ }
+ echo "<tr><td$class>Signature " . ($i + 1) . "</td><td$class>";
+ if ($x->kindOf() == "array") {
+ $ret = $x[0];
+ echo "<code>OUT: " . htmlspecialchars($ret->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "<br />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) {
+ $type = $y->scalarval();
+ $payload .= '<param><value>';
+ switch($type) {
+ case 'undefined':
+ break;
+ case 'null';
+ $type = 'nil';
+ // fall thru intentionally
+ default:
+ $payload .= '<' .
+ htmlspecialchars($type, ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) .
+ '></' . htmlspecialchars($type, ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) .
+ '>';
+ }
+ $payload .= "</value></param>\n";
+ }
+ $alt_payload .= $y->scalarval();
+ if ($k < $x->count() - 1) {
+ $alt_payload .= ';';
+ echo ", ";
+ }
+ }
+ }
+ echo ")</code>";
+ } else {
+ echo 'Unknown';
+ }
+ echo '</td>';
+ // button to test this method
+ //$payload="<methodCall>\n<methodName>$method</methodName>\n<params>\n$payload</params>\n</methodCall>";
+ echo "<td$class><form action=\"controller.php\" target=\"frmcontroller\" method=\"get\">" .
+ "<input type=\"hidden\" name=\"host\" value=\"" . htmlspecialchars($host, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"port\" value=\"" . htmlspecialchars($port, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"path\" value=\"" . htmlspecialchars($path, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($id, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"debug\" value=\"$debug\" />" .
+ "<input type=\"hidden\" name=\"username\" value=\"" . htmlspecialchars($username, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"password\" value=\"" . htmlspecialchars($password, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"authtype\" value=\"$authtype\" />" .
+ "<input type=\"hidden\" name=\"verifyhost\" value=\"$verifyhost\" />" .
+ "<input type=\"hidden\" name=\"verifypeer\" value=\"$verifypeer\" />" .
+ "<input type=\"hidden\" name=\"cainfo\" value=\"" . htmlspecialchars($cainfo, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxy\" value=\"" . htmlspecialchars($proxy, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxyuser\" value=\"" . htmlspecialchars($proxyuser, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxypwd\" value=\"" . htmlspecialchars($proxypwd, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"responsecompression\" value=\"$responsecompression\" />" .
+ "<input type=\"hidden\" name=\"requestcompression\" value=\"$requestcompression\" />" .
+ "<input type=\"hidden\" name=\"clientcookies\" value=\"" . htmlspecialchars($clientcookies, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"protocol\" value=\"$protocol\" />" .
+ "<input type=\"hidden\" name=\"timeout\" value=\"" . htmlspecialchars($timeout, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"method\" value=\"" . htmlspecialchars($method, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"methodpayload\" value=\"" . htmlspecialchars($payload, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"altmethodpayload\" value=\"" . htmlspecialchars($alt_payload, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"wstype\" value=\"$wstype\" />" .
+ "<input type=\"hidden\" name=\"action\" value=\"execute\" />";
+ if ($wstype != 1) {
+ echo "<input type=\"submit\" value=\"Load method synopsis\" />";
+ }
+ echo "</form></td>\n";
+
+ echo "<td$class><form action=\"controller.php\" target=\"frmcontroller\" method=\"get\">" .
+ "<input type=\"hidden\" name=\"host\" value=\"" . htmlspecialchars($host, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"port\" value=\"" . htmlspecialchars($port, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"path\" value=\"" . htmlspecialchars($path, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($id, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"debug\" value=\"$debug\" />" .
+ "<input type=\"hidden\" name=\"username\" value=\"" . htmlspecialchars($username, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"password\" value=\"" . htmlspecialchars($password, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"authtype\" value=\"$authtype\" />" .
+ "<input type=\"hidden\" name=\"verifyhost\" value=\"$verifyhost\" />" .
+ "<input type=\"hidden\" name=\"verifypeer\" value=\"$verifypeer\" />" .
+ "<input type=\"hidden\" name=\"cainfo\" value=\"" . htmlspecialchars($cainfo, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxy\" value=\"" . htmlspecialchars($proxy, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxyuser\" value=\"" . htmlspecialchars($proxyuser, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"proxypwd\" value=\"" . htmlspecialchars($proxypwd, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"responsecompression\" value=\"$responsecompression\" />" .
+ "<input type=\"hidden\" name=\"requestcompression\" value=\"$requestcompression\" />" .
+ "<input type=\"hidden\" name=\"clientcookies\" value=\"" . htmlspecialchars($clientcookies, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"protocol\" value=\"$protocol\" />" .
+ "<input type=\"hidden\" name=\"timeout\" value=\"" . htmlspecialchars($timeout, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"method\" value=\"" . htmlspecialchars($method, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"methodsig\" value=\"" . $i . "\" />" .
+ "<input type=\"hidden\" name=\"methodpayload\" value=\"" . htmlspecialchars($payload, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"altmethodpayload\" value=\"" . htmlspecialchars($alt_payload, ENT_COMPAT, $inputcharset) . "\" />" .
+ "<input type=\"hidden\" name=\"wstype\" value=\"$wstype\" />" .
+ "<input type=\"hidden\" name=\"run\" value=\"now\" />" .
+ "<input type=\"hidden\" name=\"action\" value=\"wrap\" />" .
+ "<input type=\"submit\" value=\"Generate method call stub code\" />";
+ echo "</form></td></tr>\n";
+ }
+ }
+ echo "</tbody>\n</table>";
+
+ break;
+
+ case 'wrap':
+ $r1 = $resp[0]->value();
+ $r2 = $resp[1]->value();
+ if ($r2->kindOf() != "array" || $r2->count() <= $methodsig) {
+ echo "Error: signature unknown\n";
+ } else {
+ $mdesc = $r1->scalarval();
+ $encoder = new PhpXmlRpc\Encoder();
+ $msig = $encoder->decode($r2);
+ $msig = $msig[$methodsig];
+ $proto = $protocol == 2 ? 'https' : $protocol == 1 ? 'http11' : '';
+ if ($proxy == '' && $username == '' && !$requestcompression && !$responsecompression &&
+ $clientcookies == ''
+ ) {
+ $opts = 1; // simple client copy in stub code
+ } else {
+ $opts = 0; // complete client copy in stub code
+ }
+ if ($wstype == 1) {
+ $prefix = 'jsonrpc';
+ } else {
+ $prefix = 'xmlrpc';
+ }
+ $wrapper = new PhpXmlRpc\Wrapper();
+ $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 "<div id=\"phpcode\">\n";
+ highlight_string("<?php\n" . $code['docstring'] . $code['source'] . '?>');
+ echo "\n</div>";
+ //}
+ //else
+ //{
+ // echo 'Error while building php code stub...';
+ }
+
+ break;
+
+ case 'execute':
+ echo '<div id="response"><h2>Response:</h2>' . htmlspecialchars($response->serialize()) . '</div>';
+ break;
+
+ default: // give a warning