PageRenderTime 61ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/cpulogger-server/public_html/xmlrpc/debugger/controller.php

https://gitlab.com/komputer007123/cpulogger
PHP | 321 lines | 284 code | 16 blank | 21 comment | 73 complexity | ff47be8f728bfff45651bc6d7a5544df MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: controller.php 11 2009-03-17 09:17:49Z ggiunta $
  4. * @author Gaetano Giunta
  5. * @copyright (C) 2005-2009 G. Giunta
  6. * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
  7. *
  8. * @todo add links to documentation from every option caption
  9. * @todo switch params for http compression from 0,1,2 to values to be used directly
  10. * @todo add a little bit more CSS formatting: we broke IE box model getting a width > 100%...
  11. * @todo add support for more options, such as ntlm auth to proxy, or request charset encoding
  12. *
  13. * @todo parse content of payload textarea to be fed to visual editor
  14. * @todo add http no-cache headers
  15. **/
  16. include(getcwd().'/common.php');
  17. if ($action == '')
  18. $action = 'list';
  19. // relative path to the visual xmlrpc editing dialog
  20. $editorpath = '../../javascript/';
  21. ?>
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  23. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <title>XMLRPC Debugger</title>
  27. <meta name="robots" content="index,nofollow" />
  28. <script type="text/javascript" language="Javascript">
  29. if (window.name!='frmcontroller')
  30. top.location.replace('index.php?run='+escape(self.location));
  31. </script>
  32. <!-- xmlrpc/jsonrpc base library -->
  33. <script type="text/javascript" src="<?php echo $editorpath; ?>xmlrpc_lib.js"></script>
  34. <script type="text/javascript" src="<?php echo $editorpath; ?>jsonrpc_lib.js"></script>
  35. <style type="text/css">
  36. <!--
  37. html {overflow: -moz-scrollbars-vertical;}
  38. body {padding: 0.5em; background-color: #EEEEEE; font-family: Verdana, Arial, Helvetica; font-size: 8pt;}
  39. h1 {font-size: 12pt; margin: 0.5em;}
  40. h2 {font-size: 10pt; display: inline; vertical-align: top;}
  41. table {border: 1px solid gray; margin-bottom: 0.5em; padding: 0.25em; width: 100%;}
  42. #methodpayload {display: inline;}
  43. td {vertical-align: top; font-family: Verdana, Arial, Helvetica; font-size: 8pt;}
  44. .labelcell {text-align: right;}
  45. -->
  46. </style>
  47. <script language="JavaScript" type="text/javascript">
  48. <!--
  49. function verifyserver()
  50. {
  51. if (document.frmaction.host.value == '')
  52. {
  53. alert('Please insert a server name or address');
  54. return false;
  55. }
  56. if (document.frmaction.path.value == '')
  57. document.frmaction.path.value = '/';
  58. var action = '';
  59. for (counter = 0; counter < document.frmaction.action.length; counter++)
  60. if (document.frmaction.action[counter].checked)
  61. {
  62. action = document.frmaction.action[counter].value;
  63. }
  64. if (document.frmaction.method.value == '' && (action == 'execute' || action == 'wrap' || action == 'describe'))
  65. {
  66. alert('Please insert a method name');
  67. return false;
  68. }
  69. if (document.frmaction.authtype.value != '1' && document.frmaction.username.value == '')
  70. {
  71. alert('No username for authenticating to server: authentication disabled');
  72. }
  73. return true;
  74. }
  75. function switchaction()
  76. {
  77. // reset html layout depending on action to be taken
  78. var action = '';
  79. for (counter = 0; counter < document.frmaction.action.length; counter++)
  80. if (document.frmaction.action[counter].checked)
  81. {
  82. action = document.frmaction.action[counter].value;
  83. }
  84. if (action == 'execute')
  85. {
  86. document.frmaction.methodpayload.disabled = false;
  87. displaydialogeditorbtn(true);//if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = false;
  88. document.frmaction.method.disabled = false;
  89. document.frmaction.methodpayload.rows = 10;
  90. }
  91. else
  92. {
  93. document.frmaction.methodpayload.rows = 1;
  94. if (action == 'describe' || action == 'wrap')
  95. {
  96. document.frmaction.methodpayload.disabled = true;
  97. displaydialogeditorbtn(false); //if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = true;
  98. document.frmaction.method.disabled = false;
  99. }
  100. else // list
  101. {
  102. document.frmaction.methodpayload.disabled = true;
  103. displaydialogeditorbtn(false); //if (document.getElementById('methodpayloadbtn') != undefined) document.getElementById('methodpayloadbtn').disabled = false;
  104. document.frmaction.method.disabled = true;
  105. }
  106. }
  107. }
  108. function switchssl()
  109. {
  110. if (document.frmaction.protocol.value != '2')
  111. {
  112. document.frmaction.verifypeer.disabled = true;
  113. document.frmaction.verifyhost.disabled = true;
  114. document.frmaction.cainfo.disabled = true;
  115. }
  116. else
  117. {
  118. document.frmaction.verifypeer.disabled = false;
  119. document.frmaction.verifyhost.disabled = false;
  120. document.frmaction.cainfo.disabled = false;
  121. }
  122. }
  123. function switchauth()
  124. {
  125. if (document.frmaction.protocol.value != '0')
  126. {
  127. document.frmaction.authtype.disabled = false;
  128. }
  129. else
  130. {
  131. document.frmaction.authtype.disabled = true;
  132. document.frmaction.authtype.value = 1;
  133. }
  134. }
  135. function swicthcainfo()
  136. {
  137. if (document.frmaction.verifypeer.checked == true)
  138. {
  139. document.frmaction.cainfo.disabled = false;
  140. }
  141. else
  142. {
  143. document.frmaction.cainfo.disabled = true;
  144. }
  145. }
  146. function switchtransport(is_json)
  147. {
  148. if (is_json == 0)
  149. {
  150. document.getElementById("idcell").style.visibility = 'hidden';
  151. document.frmjsonrpc.yes.checked = false;
  152. document.frmxmlrpc.yes.checked = true;
  153. document.frmaction.wstype.value="0";
  154. }
  155. else
  156. {
  157. document.getElementById("idcell").style.visibility = 'visible';
  158. document.frmjsonrpc.yes.checked = true;
  159. document.frmxmlrpc.yes.checked = false;
  160. document.frmaction.wstype.value="1";
  161. }
  162. }
  163. function displaydialogeditorbtn(show)
  164. {
  165. if (show && ((typeof base64_decode) == 'function'))
  166. {
  167. document.getElementById('methodpayloadbtn').innerHTML = '[<a href="#" onclick="activateeditor(); return false;">Edit</a>]';
  168. }
  169. else
  170. {
  171. document.getElementById('methodpayloadbtn').innerHTML = '';
  172. }
  173. }
  174. function activateeditor()
  175. {
  176. var url = '<?php echo $editorpath; ?>visualeditor.php?params=<?php echo $alt_payload; ?>';
  177. if (document.frmaction.wstype.value == "1")
  178. url += '&type=jsonrpc';
  179. var wnd = window.open(url, '_blank', 'width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1');
  180. }
  181. // if javascript version of the lib is found, allow it to send us params
  182. function buildparams(base64data)
  183. {
  184. if (typeof base64_decode == 'function')
  185. {
  186. if (base64data == '0') // workaround for bug in base64_encode...
  187. document.getElementById('methodpayload').value = '';
  188. else
  189. document.getElementById('methodpayload').value = base64_decode(base64data);
  190. }
  191. }
  192. // 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/)
  193. function switchFormMethod()
  194. {
  195. /// @todo use a more precise calculation, adding the rest of the fields to the actual generated url lenght
  196. if (document.frmaction.methodpayload.value.length > 1536 )
  197. {
  198. document.frmaction.action = 'action.php?usepost=true';
  199. document.frmaction.method = 'post';
  200. }
  201. }
  202. //-->
  203. </script>
  204. </head>
  205. <body onload="switchtransport(<?php echo $wstype;?>); switchaction(); switchssl(); switchauth(); swicthcainfo();<?php if ($run) echo ' document.forms[2].submit();'; ?>">
  206. <h1>XMLRPC <form name="frmxmlrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(0);"/></form>
  207. /<form name="frmjsonrpc" style="display: inline;" action="."><input name="yes" type="radio" onclick="switchtransport(1);"/></form>JSONRPC Debugger (based on the <a href="http://phpxmlrpc.sourceforge.net">PHP-XMLRPC</a> library)</h1>
  208. <form name="frmaction" method="get" action="action.php" target="frmaction" onSubmit="switchFormMethod();"
  209. >
  210. <table id="serverblock">
  211. <tr>
  212. <td><h2>Target server</h2></td>
  213. <td class="labelcell">Address:</td><td><input type="text" name="host" value="<?php echo htmlspecialchars($host); ?>" /></td>
  214. <td class="labelcell">Port:</td><td><input type="text" name="port" value="<?php echo htmlspecialchars($port); ?>" size="5" maxlength="5" /></td>
  215. <td class="labelcell">Path:</td><td><input type="text" name="path" value="<?php echo htmlspecialchars($path); ?>" /></td>
  216. </tr>
  217. </table>
  218. <table id="actionblock">
  219. <tr>
  220. <td><h2>Action</h2></td>
  221. <td>List available methods<input type="radio" name="action" value="list"<?php if ($action=='list') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
  222. <td>Describe method<input type="radio" name="action" value="describe"<?php if ($action=='describe') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
  223. <td>Execute method<input type="radio" name="action" value="execute"<?php if ($action=='execute') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
  224. <td>Generate stub for method call<input type="radio" name="action" value="wrap"<?php if ($action=='wrap') echo ' checked="checked"'; ?> onclick="switchaction();" /></td>
  225. </tr>
  226. </table>
  227. <input type="hidden" name="methodsig" value="<?php echo htmlspecialchars($methodsig); ?>" />
  228. <table id="methodblock">
  229. <tr>
  230. <td><h2>Method</h2></td>
  231. <td class="labelcell">Name:</td><td><input type="text" name="method" value="<?php echo htmlspecialchars($method); ?>" /></td>
  232. <td class="labelcell">Payload:<br/><div id="methodpayloadbtn"></div></td><td><textarea id="methodpayload" name="methodpayload" rows="1" cols="40"><?php echo htmlspecialchars($payload); ?></textarea></td>
  233. <td class="labelcell" id="idcell">Msg id: <input type="text" name="id" size="3" value="<?php echo htmlspecialchars($id); ?>"/></td>
  234. <td><input type="hidden" name="wstype" value="<?php echo $wstype;?>" />
  235. <input type="submit" value="Execute" onclick="return verifyserver();"/></td>
  236. </tr>
  237. </table>
  238. <table id="optionsblock">
  239. <tr>
  240. <td><h2>Client options</h2></td>
  241. <td class="labelcell">Show debug info:</td><td><select name="debug">
  242. <option value="0"<?php if ($debug == 0) echo ' selected="selected"'; ?>>No</option>
  243. <option value="1"<?php if ($debug == 1) echo ' selected="selected"'; ?>>Yes</option>
  244. <option value="2"<?php if ($debug == 2) echo ' selected="selected"'; ?>>More</option>
  245. </select>
  246. </td>
  247. <td class="labelcell">Timeout:</td><td><input type="text" name="timeout" size="3" value="<?php if ($timeout > 0) echo $timeout; ?>" /></td>
  248. <td class="labelcell">Protocol:</td><td><select name="protocol" onchange="switchssl(); switchauth(); swicthcainfo();">
  249. <option value="0"<?php if ($protocol == 0) echo ' selected="selected"'; ?>>HTTP 1.0</option>
  250. <option value="1"<?php if ($protocol == 1) echo ' selected="selected"'; ?>>HTTP 1.1</option>
  251. <option value="2"<?php if ($protocol == 2) echo ' selected="selected"'; ?>>HTTPS</option>
  252. </select></td>
  253. </tr>
  254. <tr>
  255. <td class="labelcell">AUTH:</td>
  256. <td class="labelcell">Username:</td><td><input type="text" name="username" value="<?php echo htmlspecialchars($username); ?>" /></td>
  257. <td class="labelcell">Pwd:</td><td><input type="password" name="password" value="<?php echo htmlspecialchars($password); ?>" /></td>
  258. <td class="labelcell">Type</td><td><select name="authtype">
  259. <option value="1"<?php if ($authtype == 1) echo ' selected="selected"'; ?>>Basic</option>
  260. <option value="2"<?php if ($authtype == 2) echo ' selected="selected"'; ?>>Digest</option>
  261. <option value="8"<?php if ($authtype == 8) echo ' selected="selected"'; ?>>NTLM</option>
  262. </select></td>
  263. <td></td>
  264. </tr>
  265. <tr>
  266. <td class="labelcell">SSL:</td>
  267. <td class="labelcell">Verify Host's CN:</td><td><select name="verifyhost">
  268. <option value="0"<?php if ($verifyhost == 0) echo ' selected="selected"'; ?>>No</option>
  269. <option value="1"<?php if ($verifyhost == 1) echo ' selected="selected"'; ?>>Check CN existance</option>
  270. <option value="2"<?php if ($verifyhost == 2) echo ' selected="selected"'; ?>>Check CN match</option>
  271. </select></td>
  272. <td class="labelcell">Verify Cert:</td><td><input type="checkbox" value="1" name="verifypeer" onclick="swicthcainfo();"<?php if ($verifypeer) echo ' checked="checked"'; ?> /></td>
  273. <td class="labelcell">CA Cert file:</td><td><input type="text" name="cainfo" value="<?php echo htmlspecialchars($cainfo); ?>" /></td>
  274. </tr>
  275. <tr>
  276. <td class="labelcell">PROXY:</td>
  277. <td class="labelcell">Server:</td><td><input type="text" name="proxy" value="<?php echo htmlspecialchars($proxy); ?>" /></td>
  278. <td class="labelcell">Proxy user:</td><td><input type="text" name="proxyuser" value="<?php echo htmlspecialchars($proxyuser); ?>" /></td>
  279. <td class="labelcell">Proxy pwd:</td><td><input type="password" name="proxypwd" value="<?php echo htmlspecialchars($proxypwd); ?>" /></td>
  280. </tr>
  281. <tr>
  282. <td class="labelcell">COMPRESSION:</td>
  283. <td class="labelcell">Request:</td><td><select name="requestcompression">
  284. <option value="0"<?php if ($requestcompression == 0) echo ' selected="selected"'; ?>>None</option>
  285. <option value="1"<?php if ($requestcompression == 1) echo ' selected="selected"'; ?>>Gzip</option>
  286. <option value="2"<?php if ($requestcompression == 2) echo ' selected="selected"'; ?>>Deflate</option>
  287. </select></td>
  288. <td class="labelcell">Response:</td><td><select name="responsecompression">
  289. <option value="0"<?php if ($responsecompression == 0) echo ' selected="selected"'; ?>>None</option>
  290. <option value="1"<?php if ($responsecompression == 1) echo ' selected="selected"'; ?>>Gzip</option>
  291. <option value="2"<?php if ($responsecompression == 2) echo ' selected="selected"'; ?>>Deflate</option>
  292. <option value="3"<?php if ($responsecompression == 3) echo ' selected="selected"'; ?>>Any</option>
  293. </select></td>
  294. <td></td>
  295. </tr>
  296. <tr>
  297. <td class="labelcell">COOKIES:</td>
  298. <td colspan="4" class="labelcell"><input type="text" name="clientcookies" size="80" value="<?php echo htmlspecialchars($clientcookies); ?>" /></td>
  299. <td colspan="2">Format: 'cookie1=value1, cookie2=value2'</td>
  300. </tr>
  301. </table>
  302. </form>
  303. </body>
  304. </html>