From b825566f55fd1aa4dab6b09145848e7d6e957fe5 Mon Sep 17 00:00:00 2001
From: gggeek
Date: Sat, 21 Feb 2015 18:31:37 +0000
Subject: [PATCH] Reformat source code: debugger
---
debugger/action.php | 934 +++++++++++++++++++++-------------------
debugger/common.php | 130 +++---
debugger/controller.php | 672 +++++++++++++++++------------
debugger/index.php | 21 +-
4 files changed, 948 insertions(+), 809 deletions(-)
diff --git a/debugger/action.php b/debugger/action.php
index 00af2a0..b12da80 100644
--- a/debugger/action.php
+++ b/debugger/action.php
@@ -8,519 +8,545 @@
* @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
**/
-
?>
- XMLRPC Debugger
-
-
+ XMLRPC Debugger
+
+
1)
- $pport = $pproxy[1];
- else
- $pport = 8080;
- $client->setProxy($pproxy[0], $pport, $proxyuser, $proxypwd);
+ $pproxy = explode(':', $proxy);
+ if (count($pproxy) > 1) {
+ $pport = $pproxy[1];
+ } else {
+ $pport = 8080;
+ }
+ $client->setProxy($pproxy[0], $pport, $proxyuser, $proxypwd);
}
- if ($protocol == 2)
- {
- $client->setSSLVerifyPeer($verifypeer);
- $client->setSSLVerifyHost($verifyhost);
- if ($cainfo)
- {
- $client->setCaCertificate($cainfo);
- }
- $httpprotocol = 'https';
+ if ($protocol == 2) {
+ $client->setSSLVerifyPeer($verifypeer);
+ $client->setSSLVerifyHost($verifyhost);
+ if ($cainfo) {
+ $client->setCaCertificate($cainfo);
+ }
+ $httpprotocol = 'https';
+ } elseif ($protocol == 1) {
+ $httpprotocol = 'http11';
+ } else {
+ $httpprotocol = 'http';
}
- else if ($protocol == 1)
- $httpprotocol = 'http11';
- else
- $httpprotocol = 'http';
- if ($username)
- $client->setCredentials($username, $password, $authtype);
+ if ($username) {
+ $client->setCredentials($username, $password, $authtype);
+ }
$client->setDebug($debug);
switch ($requestcompression) {
- case 0:
- $client->request_compression = '';
- break;
- case 1:
- $client->request_compression = 'gzip';
- break;
- case 2:
- $client->request_compression = 'deflate';
- break;
+ case 0:
+ $client->request_compression = '';
+ break;
+ case 1:
+ $client->request_compression = 'gzip';
+ break;
+ case 2:
+ $client->request_compression = 'deflate';
+ break;
}
switch ($responsecompression) {
- case 0:
- $client->accepted_compression = '';
- break;
- case 1:
- $client->accepted_compression = array('gzip');
- break;
- case 2:
- $client->accepted_compression = array('deflate');
- break;
- case 3:
- $client->accepted_compression = array('gzip', 'deflate');
- break;
+ case 0:
+ $client->accepted_compression = '';
+ break;
+ case 1:
+ $client->accepted_compression = array('gzip');
+ break;
+ case 2:
+ $client->accepted_compression = array('deflate');
+ break;
+ case 3:
+ $client->accepted_compression = array('gzip', 'deflate');
+ break;
}
$cookies = explode(',', $clientcookies);
- foreach ($cookies as $cookie)
- {
- if (strpos($cookie, '='))
- {
- $cookie = explode('=', $cookie);
- $client->setCookie(trim($cookie[0]), trim(@$cookie[1]));
- }
+ foreach ($cookies as $cookie) {
+ if (strpos($cookie, '=')) {
+ $cookie = explode('=', $cookie);
+ $client->setCookie(trim($cookie[0]), trim(@$cookie[1]));
+ }
}
$msg = array();
switch ($action) {
- case 'wrap':
- @include('xmlrpc_wrappers.inc');
- if (!function_exists('build_remote_method_wrapper_code'))
- {
- die('Error: to enable creation of method stubs the xmlrpc_wrappers.inc file is needed');
- }
+ case 'wrap':
+ @include 'xmlrpc_wrappers.inc';
+ if (!function_exists('build_remote_method_wrapper_code')) {
+ die('Error: to enable creation of method stubs the xmlrpc_wrappers.inc file is needed');
+ }
// fall thru intentionally
- case 'describe':
- case 'wrap':
- $msg[0] = new $msgclass('system.methodHelp', array(), $id);
- $msg[0]->addparam(new xmlrpcval($method));
- $msg[1] = new $msgclass('system.methodSignature', array(), $id+1);
- $msg[1]->addparam(new xmlrpcval($method));
- $actionname = 'Description of method "'.$method.'"';
- break;
- case 'list':
- $msg[0] = new $msgclass('system.listMethods', array(), $id);
- $actionname = 'List of available methods';
- break;
- case 'execute':
- if (!payload_is_safe($payload))
- die("Tsk tsk tsk, please stop it or I will have to call in the cops!");
- $msg[0] = new $msgclass($method, array(), $id);
- // hack! build xml payload by hand
- if ($wstype == 1)
- {
- $msg[0]->payload = "{\n".
- '"method": "' . $method . "\",\n\"params\": [" .
- $payload .
- "\n],\n\"id\": ";
- // fix: if user gave an empty string, use NULL, or we'll break json syntax
- if ($id == "")
- {
- $msg[0]->payload .= "null\n}";
+ case 'describe':
+ case 'wrap':
+ $msg[0] = new $msgclass('system.methodHelp', array(), $id);
+ $msg[0]->addparam(new xmlrpcval($method));
+ $msg[1] = new $msgclass('system.methodSignature', array(), $id + 1);
+ $msg[1]->addparam(new xmlrpcval($method));
+ $actionname = 'Description of method "' . $method . '"';
+ break;
+ case 'list':
+ $msg[0] = new $msgclass('system.listMethods', array(), $id);
+ $actionname = 'List of available methods';
+ break;
+ case 'execute':
+ if (!payload_is_safe($payload)) {
+ die("Tsk tsk tsk, please stop it or I will have to call in the cops!");
}
- else
- {
- if (is_numeric($id) || $id == 'false' || $id == 'true' || $id == 'null')
- {
- $msg[0]->payload .= "$id\n}";
- }
- else
- {
- $msg[0]->payload .= "\"$id\"\n}";
- }
+ $msg[0] = new $msgclass($method, array(), $id);
+ // hack! build xml payload by hand
+ if ($wstype == 1) {
+ $msg[0]->payload = "{\n" .
+ '"method": "' . $method . "\",\n\"params\": [" .
+ $payload .
+ "\n],\n\"id\": ";
+ // fix: if user gave an empty string, use NULL, or we'll break json syntax
+ if ($id == "") {
+ $msg[0]->payload .= "null\n}";
+ } else {
+ if (is_numeric($id) || $id == 'false' || $id == 'true' || $id == 'null') {
+ $msg[0]->payload .= "$id\n}";
+ } else {
+ $msg[0]->payload .= "\"$id\"\n}";
+ }
+ }
+ } else {
+ $msg[0]->payload = $msg[0]->xml_header() .
+ '' . $method . "\n" .
+ $payload .
+ "\n" . $msg[0]->xml_footer();
}
- }
- else
- $msg[0]->payload = $msg[0]->xml_header() .
- '' . $method . "\n" .
- $payload .
- "\n" . $msg[0]->xml_footer();
- $actionname = 'Execution of method '.$method;
- break;
- default: // give a warning
- $actionname = '[ERROR: unknown action] "'.$action.'"';
+ $actionname = 'Execution of method ' . $method;
+ break;
+ default: // give a warning
+ $actionname = '[ERROR: unknown action] "' . $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) . ' on server ' . htmlspecialchars($server) . " ...
\n";
flush();
$response = null;
// execute method(s)
- if ($debug)
- echo 'Debug info:
'; /// @todo use ob_start instead
+ if ($debug) {
+ echo '
Debug info:
';
+ } /// @todo use ob_start instead
$resp = array();
- $mtime = explode(' ',microtime());
+ $mtime = explode(' ', microtime());
$time = (float)$mtime[0] + (float)$mtime[1];
- foreach ($msg as $message)
- {
- // catch errors: for older xmlrpc libs, send does not return by ref
- @$response =& $client->send($message, $timeout, $httpprotocol);
- $resp[] = $response;
- if (!$response || $response->faultCode())
- break;
+ foreach ($msg as $message) {
+ // catch errors: for older xmlrpc libs, send does not return by ref
+ @$response = &$client->send($message, $timeout, $httpprotocol);
+ $resp[] = $response;
+ if (!$response || $response->faultCode()) {
+ break;
+ }
}
- $mtime = explode(' ',microtime());
+ $mtime = explode(' ', microtime());
$time = (float)$mtime[0] + (float)$mtime[1] - $time;
- if ($debug)
- echo "\n";
-
- if ($response)
- {
-
- if ($response->faultCode())
- {
- // call failed! echo out error msg!
- //echo '
'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'
';
- echo "
$protoname call FAILED!
\n";
- echo "
Fault code: [" . htmlspecialchars($response->faultCode()) .
- "] Reason: '" . htmlspecialchars($response->faultString()) . "'
\n";
- echo (strftime("%d/%b/%Y:%H:%M:%S\n"));
+ if ($debug) {
+ echo "
\n";
}
- else
- {
- // call succeeded: parse results
- //echo ''.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'
';
- printf ("%s call(s) OK (%.2f secs.)
\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->arraysize();
- echo "\n";
- echo "\nMethod | Description |
\n\n\n";
- for($i=0; $i < $max; $i++)
- {
- $rec = $v->arraymem($i);
- if ($i%2) $class=' class="oddrow"'; else $class = ' class="evenrow"';
- echo ("".htmlspecialchars($rec->scalarval())." | | ");
- //echo("
\n");
-
- // generate lo scheletro per il method payload per eventuali test
- //$methodpayload="\n".$rec->scalarval()."\n\n\n\n";
-
- /*echo ("");*/
- echo("\n");
- }
- echo "\n
";
- }
- break;
- case 'describe':
-
- $r1 = $resp[0]->value();
- $r2 = $resp[1]->value();
-
- echo "\n";
- echo "\nMethod | ".htmlspecialchars($method)." | | |
\n\n\n";
- $desc = htmlspecialchars($r1->scalarval());
- if ($desc == "")
- $desc = "-";
- echo "Description | $desc |
\n";
- $payload="";
- $alt_payload="";
- if ($r2->kindOf()!="array")
- echo "Signature | Unknown | |
\n";
- else
- {
- for($i=0; $i < $r2->arraysize(); $i++)
- {
- 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();
- if ($wstype != 1)
- {
- $payload = $payload . '<'.htmlspecialchars($y->scalarval()).'>'.htmlspecialchars($y->scalarval()).">\n";
- }
- $alt_payload .= $y->scalarval();
- if ($k < $x->arraysize()-1)
- {
- $alt_payload .= ';';
- echo ", ";
- }
- }
- }
- echo ") ";
+ if ($response) {
+ if ($response->faultCode()) {
+ // call failed! echo out error msg!
+ //echo ''.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'';
+ echo "$protoname call FAILED!\n";
+ echo "Fault code: [" . htmlspecialchars($response->faultCode()) .
+ "] Reason: '" . htmlspecialchars($response->faultString()) . "' \n";
+ echo(strftime("%d/%b/%Y:%H:%M:%S\n"));
+ } else {
+ // call succeeded: parse results
+ //echo ''.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'';
+ printf("%s call(s) OK (%.2f secs.)\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->arraysize();
+ echo "\n";
+ echo "\nMethod | Description | \n\n\n";
+ for ($i = 0; $i < $max; $i++) {
+ $rec = $v->arraymem($i);
+ if ($i % 2) {
+ $class = ' class="oddrow"';
+ } else {
+ $class = ' class="evenrow"';
+ }
+ echo("" . htmlspecialchars($rec->scalarval()) . " | | ");
+ //echo(" \n");
+
+ // generate lo scheletro per il method payload per eventuali test
+ //$methodpayload="\n".$rec->scalarval()."\n\n\n\n";
+
+ /*echo ("");*/
+ echo("\n");
+ }
+ echo "\n ";
+ }
+ break;
+
+ case 'describe':
+
+ $r1 = $resp[0]->value();
+ $r2 = $resp[1]->value();
+
+ echo "\n";
+ echo "\nMethod | " . htmlspecialchars($method) . " | | | \n\n\n";
+ $desc = htmlspecialchars($r1->scalarval());
+ if ($desc == "") {
+ $desc = "-";
+ }
+ echo "Description | $desc | \n";
+ $payload = "";
+ $alt_payload = "";
+ if ($r2->kindOf() != "array") {
+ echo "Signature | Unknown | | \n";
+ } else {
+ for ($i = 0; $i < $r2->arraysize(); $i++) {
+ 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();
+ if ($wstype != 1) {
+ $payload = $payload . '<' . htmlspecialchars($y->scalarval()) . '>' . htmlspecialchars($y->scalarval()) . ">\n";
+ }
+ $alt_payload .= $y->scalarval();
+ if ($k < $x->arraysize() - 1) {
+ $alt_payload .= ';';
+ echo ", ";
+ }
+ }
+ }
+ echo ") ";
+ } else {
+ echo 'Unknown';
+ }
+ echo ' | ';
+ //bottone per testare questo metodo
+ //$payload="\n$method\n\n$payload\n";
+ echo " | \n";
+
+ echo " | \n";
+ }
+ }
+ echo "\n ";
+
+ break;
+
+ case 'wrap':
+ $r1 = $resp[0]->value();
+ $r2 = $resp[1]->value();
+ if ($r2->kindOf() != "array" || $r2->arraysize() <= $methodsig) {
+ echo "Error: signature unknown\n";
+ } else {
+ $mdesc = $r1->scalarval();
+ $msig = php_xmlrpc_decode($r2);
+ $msig = $msig[$methodsig];
+ $proto = $protocol == 2 ? 'https' : $protocol == 1 ? 'http11' : '';
+ if ($proxy == '' && $username == '' && !$requestcompression && !$responsecompression &&
+ $clientcookies == ''
+ ) {
+ $opts = 0; // simple client copy in stub code
+ } else {
+ $opts = 1; // complete client copy in stub code
+ }
+ if ($wstype == 1) {
+ $prefix = 'jsonrpc';
+ } else {
+ $prefix = 'xmlrpc';
+ }
+ //$code = wrap_xmlrpc_method($client, $method, $methodsig, 0, $proto, '', $opts);
+ $code = build_remote_method_wrapper_code($client, $method, str_replace('.', '_', $prefix . '_' . $method), $msig, $mdesc, $timeout, $proto, $opts, $prefix);
+ //if ($code)
+ //{
+ echo "\n";
+ highlight_string("');
+ echo "\n ";
+ //}
+ //else
+ //{
+ // echo 'Error while building php code stub...';
+ }
+
+ break;
+
+ case 'execute':
+ echo 'Response:' . htmlspecialchars($response->serialize()) . '';
+ break;
+
+ default: // give a warning
}
- else
- {
- echo 'Unknown';
- }
- echo ' | ';
- //bottone per testare questo metodo
- //$payload="\n$method\n\n$payload\n";
- echo " | \n";
-
- echo " |
\n";
-
- }
- }
- echo "\n
";
-
- break;
-
- case 'wrap':
- $r1 = $resp[0]->value();
- $r2 = $resp[1]->value();
- if ($r2->kindOf()!="array" || $r2->arraysize() <= $methodsig)
- echo "Error: signature unknown\n";
- else
- {
- $mdesc = $r1->scalarval();
- $msig = php_xmlrpc_decode($r2);
- $msig = $msig[$methodsig];
- $proto = $protocol == 2 ? 'https' : $protocol == 1 ? 'http11' : '';
- if ($proxy == '' && $username == '' && !$requestcompression && !$responsecompression &&
- $clientcookies == '')
- {
- $opts = 0; // simple client copy in stub code
- }
- else
- {
- $opts = 1; // complete client copy in stub code
- }
- if ($wstype == 1)
- {
- $prefix = 'jsonrpc';
- }
- else
- {
- $prefix = 'xmlrpc';
- }
- //$code = wrap_xmlrpc_method($client, $method, $methodsig, 0, $proto, '', $opts);
- $code = build_remote_method_wrapper_code($client, $method, str_replace('.', '_', $prefix.'_'.$method), $msig, $mdesc, $timeout, $proto, $opts, $prefix);
- //if ($code)
- //{
- echo "\n";
- highlight_string("');
- echo "\n
";
- //}
- //else
- //{
- // echo 'Error while building php code stub...';
- }
-
- break;
-
- case 'execute':
- echo 'Response:
'.htmlspecialchars($response->serialize()).'
';
- break;
-
- default: // give a warning
- }
- } // if !$response->faultCode()
+ } // if !$response->faultCode()
} // if $response
- }
- else
- {
+} else {
// no action taken yet: give some instructions on debugger usage
-?>
-
-Instructions on usage of the debugger:
-
-- Run a 'list available methods' action against desired server
-- If list of methods appears, click on 'describe method' for desired method
-- To run method: click on 'load method synopsis' for desired method. This will load a skeleton for method call parameters in the form above. Complete all xmlrpc values with appropriate data and click 'Execute'
-
+ ?>
+
+ Instructions on usage of the debugger:
+
+ - Run a 'list available methods' action against desired server
+ - If list of methods appears, click on 'describe method' for desired method
+ - To run method: click on 'load method synopsis' for desired method. This will load a skeleton for method call
+ parameters in the form above. Complete all xmlrpc values with appropriate data and click 'Execute'
+
+
+ You will need to enable the CURL extension to use the HTTPS and HTTP 1.1 transports\n";
+ }
+ ?>
+
+ Example:
+
+ Server Address: phpxmlrpc.sourceforge.net
+ Path: /server.php
+
+
+ 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
+
+ - 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
+ - 2006-05-02: added support for JSON-RPC. Note that many interesting json-rpc features are not implemented
+ yet, such as notifications or multicall.
+
+ - 2006-04-22: added option for setting custom CA certs to verify peer with in SSLmode
+ - 2006-03-05: added option for setting Basic/Digest/NTLM auth type
+ - 2006-01-18: added option echoing to screen xmlrpc request before sending it ('More' debug)
+ - 2005-10-01: added option for setting cookies to be sent to server
+ - 2005-08-07: added switches for compression of requests and responses and http 1.1
+ - 2005-06-27: fixed possible security breach in parsing malformed xml
+ - 2005-06-24: fixed error with calling methods having parameters...
+
You will need to enable the CURL extension to use the HTTPS and HTTP 1.1 transports\n";
- }
-?>
-Example:
-
-Server Address: phpxmlrpc.sourceforge.net
-Path: /server.php
-
-
-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
-
-- 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
-- 2006-05-02: added support for JSON-RPC. Note that many interesting json-rpc features are not implemented yet, such as notifications or multicall.
-- 2006-04-22: added option for setting custom CA certs to verify peer with in SSLmode
-- 2006-03-05: added option for setting Basic/Digest/NTLM auth type
-- 2006-01-18: added option echoing to screen xmlrpc request before sending it ('More' debug)
-- 2005-10-01: added option for setting cookies to be sent to server
-- 2005-08-07: added switches for compression of requests and responses and http 1.1
-- 2005-06-27: fixed possible security breach in parsing malformed xml
-- 2005-06-24: fixed error with calling methods having parameters...
-
-
diff --git a/debugger/common.php b/debugger/common.php
index adaf366..83153bb 100644
--- a/debugger/common.php
+++ b/debugger/common.php
@@ -9,72 +9,74 @@
*/
// work around magic quotes
- if (get_magic_quotes_gpc())
- {
+if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
- array_map('stripslashes_deep', $value) :
- stripslashes($value);
+ array_map('stripslashes_deep', $value) :
+ stripslashes($value);
return $value;
}
- $_GET = array_map('stripslashes_deep', $_GET);
- }
+ $_GET = array_map('stripslashes_deep', $_GET);
+}
- if ( isset( $_GET['usepost'] ) && $_GET['usepost'] === 'true' )
- {
- $_GET = $_POST;
- }
+if (isset($_GET['usepost']) && $_GET['usepost'] === 'true') {
+ $_GET = $_POST;
+}
// recover input parameters
- $debug = false;
- $protocol = 0;
- $run = false;
- $wstype = 0;
- $id = '';
- if (isset($_GET['action']))
- {
- if (isset($_GET['wstype']) && $_GET['wstype'] == '1')
- {
- $wstype = 1;
- if (isset($_GET['id']))
- $id = $_GET['id'];
+$debug = false;
+$protocol = 0;
+$run = false;
+$wstype = 0;
+$id = '';
+if (isset($_GET['action'])) {
+ if (isset($_GET['wstype']) && $_GET['wstype'] == '1') {
+ $wstype = 1;
+ if (isset($_GET['id'])) {
+ $id = $_GET['id'];
+ }
}
$host = isset($_GET['host']) ? $_GET['host'] : 'localhost'; // using '' will trigger an xmlrpc error...
- if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2'))
- $protocol = $_GET['protocol'];
- if (strpos($host, 'http://') === 0)
- $host = substr($host, 7);
- else if (strpos($host, 'https://') === 0)
- {
- $host = substr($host, 8);
- $protocol = 2;
+ if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2')) {
+ $protocol = $_GET['protocol'];
+ }
+ if (strpos($host, 'http://') === 0) {
+ $host = substr($host, 7);
+ } elseif (strpos($host, 'https://') === 0) {
+ $host = substr($host, 8);
+ $protocol = 2;
}
$port = isset($_GET['port']) ? $_GET['port'] : '';
$path = isset($_GET['path']) ? $_GET['path'] : '';
// in case user forgot initial '/' in xmlrpc server path, add it back
- if ($path && ($path[0]) != '/')
- $path = '/'.$path;
+ if ($path && ($path[0]) != '/') {
+ $path = '/' . $path;
+ }
- if (isset($_GET['debug']) && ($_GET['debug'] == '1' || $_GET['debug'] == '2'))
- $debug = $_GET['debug'];
+ if (isset($_GET['debug']) && ($_GET['debug'] == '1' || $_GET['debug'] == '2')) {
+ $debug = $_GET['debug'];
+ }
$verifyhost = (isset($_GET['verifyhost']) && ($_GET['verifyhost'] == '1' || $_GET['verifyhost'] == '2')) ? $_GET['verifyhost'] : 0;
- if (isset($_GET['verifypeer']) && $_GET['verifypeer'] == '1')
- $verifypeer = true;
- else
- $verifypeer = false;
- $cainfo= isset($_GET['cainfo']) ? $_GET['cainfo'] : '';
+ if (isset($_GET['verifypeer']) && $_GET['verifypeer'] == '1') {
+ $verifypeer = true;
+ } else {
+ $verifypeer = false;
+ }
+ $cainfo = isset($_GET['cainfo']) ? $_GET['cainfo'] : '';
$proxy = isset($_GET['proxy']) ? $_GET['proxy'] : 0;
- if (strpos($proxy, 'http://') === 0)
- $proxy = substr($proxy, 7);
- $proxyuser= isset($_GET['proxyuser']) ? $_GET['proxyuser'] : '';
+ if (strpos($proxy, 'http://') === 0) {
+ $proxy = substr($proxy, 7);
+ }
+ $proxyuser = isset($_GET['proxyuser']) ? $_GET['proxyuser'] : '';
$proxypwd = isset($_GET['proxypwd']) ? $_GET['proxypwd'] : '';
$timeout = isset($_GET['timeout']) ? $_GET['timeout'] : 0;
- if (!is_numeric($timeout))
- $timeout = 0;
+ if (!is_numeric($timeout)) {
+ $timeout = 0;
+ }
$action = $_GET['action'];
$method = isset($_GET['method']) ? $_GET['method'] : '';
@@ -82,27 +84,28 @@
$payload = isset($_GET['methodpayload']) ? $_GET['methodpayload'] : '';
$alt_payload = isset($_GET['altmethodpayload']) ? $_GET['altmethodpayload'] : '';
- if (isset($_GET['run']) && $_GET['run'] == 'now')
- $run = true;
+ if (isset($_GET['run']) && $_GET['run'] == 'now') {
+ $run = true;
+ }
$username = isset($_GET['username']) ? $_GET['username'] : '';
$password = isset($_GET['password']) ? $_GET['password'] : '';
$authtype = (isset($_GET['authtype']) && ($_GET['authtype'] == '2' || $_GET['authtype'] == '8')) ? $_GET['authtype'] : 1;
- if (isset($_GET['requestcompression']) && ($_GET['requestcompression'] == '1' || $_GET['requestcompression'] == '2'))
- $requestcompression = $_GET['requestcompression'];
- else
- $requestcompression = 0;
- if (isset($_GET['responsecompression']) && ($_GET['responsecompression'] == '1' || $_GET['responsecompression'] == '2' || $_GET['responsecompression'] == '3'))
- $responsecompression = $_GET['responsecompression'];
- else
- $responsecompression = 0;
+ if (isset($_GET['requestcompression']) && ($_GET['requestcompression'] == '1' || $_GET['requestcompression'] == '2')) {
+ $requestcompression = $_GET['requestcompression'];
+ } else {
+ $requestcompression = 0;
+ }
+ if (isset($_GET['responsecompression']) && ($_GET['responsecompression'] == '1' || $_GET['responsecompression'] == '2' || $_GET['responsecompression'] == '3')) {
+ $responsecompression = $_GET['responsecompression'];
+ } else {
+ $responsecompression = 0;
+ }
$clientcookies = isset($_GET['clientcookies']) ? $_GET['clientcookies'] : '';
- }
- else
- {
+} else {
$host = '';
$port = '';
$path = '';
@@ -124,11 +127,10 @@
$requestcompression = 0;
$responsecompression = 0;
$clientcookies = '';
- }
+}
- // check input for known XMLRPC attacks against this or other libs
- function payload_is_safe($input)
- {
- return true;
- }
-?>
\ No newline at end of file
+// check input for known XMLRPC attacks against this or other libs
+function payload_is_safe($input)
+{
+ return true;
+}
diff --git a/debugger/controller.php b/debugger/controller.php
index 965b2ef..4db9990 100644
--- a/debugger/controller.php
+++ b/debugger/controller.php
@@ -8,314 +8,424 @@
* @todo switch params for http compression from 0,1,2 to values to be used directly
* @todo add a little bit more CSS formatting: we broke IE box model getting a width > 100%...
* @todo add support for more options, such as ntlm auth to proxy, or request charset encoding
- *
* @todo parse content of payload textarea to be fed to visual editor
* @todo add http no-cache headers
**/
- include(__DIR__.'/common.php');
- if ($action == '')
+include __DIR__ . '/common.php';
+if ($action == '') {
$action = 'list';
+}
- // relative path to the visual xmlrpc editing dialog
- $editorpath = '../../javascript/debugger/';
- $editorlibs = '../../javascript/lib/';
+// relative path to the visual xmlrpc editing dialog
+$editorpath = '../../javascript/debugger/';
+$editorlibs = '../../javascript/lib/';
?>
-XMLRPC Debugger
-
-
-
-
-
-
-
+
+
+
+
+
+ function displaydialogeditorbtn(show) {
+ if (show && ((typeof base64_decode) == 'function')) {
+ document.getElementById('methodpayloadbtn').innerHTML = '[Edit]';
+ }
+ else {
+ document.getElementById('methodpayloadbtn').innerHTML = '';
+ }
+ }
+
+ function activateeditor() {
+ var url = 'visualeditor.php?params=';
+ if (document.frmaction.wstype.value == "1")
+ url += '&type=jsonrpc';
+ var wnd = window.open(url, '_blank', 'width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1');
+ }
+
+ // if javascript version of the lib is found, allow it to send us params
+ function buildparams(base64data) {
+ if (typeof base64_decode == 'function') {
+ if (base64data == '0') // workaround for bug in base64_encode...
+ document.getElementById('methodpayload').value = '';
+ else
+ document.getElementById('methodpayload').value = base64_decode(base64data);
+ }
+ }
+
+ // use GET for ease of refresh, switch to POST when payload is too big to fit in url (in IE: 2048 bytes! see http://support.microsoft.com/kb/q208427/)
+ function switchFormMethod() {
+ /// @todo use a more precise calculation, adding the rest of the fields to the actual generated url lenght
+ if (document.frmaction.methodpayload.value.length > 1536) {
+ document.frmaction.action = 'action.php?usepost=true';
+ document.frmaction.method = 'post';
+ }
+ }
+
+ //-->
+
-
-XMLRPC
-/JSONRPC Debugger (based on the PHP-XMLRPC library)
+
+XMLRPC
+
+ /
+
+ JSONRPC Debugger (based on the PHP-XMLRPC library)
+
-
\ No newline at end of file
+
diff --git a/debugger/index.php b/debugger/index.php
index 2f30c9f..eff10ea 100644
--- a/debugger/index.php
+++ b/debugger/index.php
@@ -1,20 +1,21 @@
-XMLRPC Debugger
+ XMLRPC Debugger
-
\ No newline at end of file
+