Files
@ f43d1a4680a9
Branch filter:
Location: hot67beta/xmlrpc/client.php
f43d1a4680a9
5.2 KiB
text/x-php
menubar 0 to 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | <?php
/**
* @version $Id: client.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define( 'JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once JPATH_BASE.DS.'includes'.DS.'defines.php';
require_once JPATH_BASE.DS.'includes'.DS.'framework.php';
// Templates etc. are not available for the XMLRPC application, therefore this simple error handler
JError::setErrorHandling( E_ERROR, 'die' );
JError::setErrorHandling( E_WARNING, 'echo' );
JError::setErrorHandling( E_NOTICE, 'echo' );
// create the mainframe object
$mainframe =& JFactory::getApplication('xmlrpc');
// Ensure that this application is enabled
if (!($mainframe->getCfg('xmlrpc_server') && $mainframe->getCfg('debug'))) {
JError::raiseError(403, 'XML-RPC Client or Debugging not enabled.');
}
// Includes the required class file for the XML-RPC Client
jimport('phpxmlrpc.xmlrpc');
// Get default values for the XMLRPC server host and path
$uri = JURI::getInstance();
$host = $uri->getHost();
$path = $uri->getPath();
$path = dirname($path).'/';
$host = JRequest::getString( 'host', $host, 'post' );
$path = JRequest::getString( 'path', $path, 'post' );
$debug = JRequest::getVar( 'debug', 0, 'post', 'int' );
$task = JRequest::getVar( 'task', 0, 'post', 'cmd' );
$output = '';
$array = array();
if ($task)
{
if ($path)
{
$client = new xmlrpc_client($path, $host, 80);
}
else
{
$client = new xmlrpc_client('', $host);
}
$client->setDebug($debug);
switch ($task)
{
case 'list_methods':
{
jimport( 'joomla.html.html' );
$msg = new xmlrpcmsg('system.listMethods');
$xmlrpcdoc = $client->send($msg);
//echo var_dump($xmlrpcdoc);
//die;
if ($xmlrpcdoc->faultCode() == 0)
{
$result = $xmlrpcdoc->value();
$array = $result->scalarval();
}
else
{
print $xmlrpcdoc->faultString();
}
$methods = array();
for ($i=0; $i < sizeof($array); $i++)
{
$var = new xmlrpcval($array[$i]);
$array_method = $var->scalarval();
$methods[$i] = JHTML::_('select.option', $array_method->scalarval());
}
$output = 'Methods<br />';
$output .= JHTML::_('select.genericlist', $methods, 'method', 'size="10"', 'value', 'text' );
$output .= ' <input name="args" type="text" />';
$output .= ' <input name="task" type="submit" value="exec" />';
} break;
case 'exec':
{
$method = JRequest::getVar( 'method', '', '', 'cmd' );
$args = JRequest::getVar( 'args' );
$message = new xmlrpcmsg($method, array(new xmlrpcval(0, "int")));
$xmlrpcdoc = $client->send($message);
if ($xmlrpcdoc->faultCode()== 0)
{
$scalar_var = $xmlrpcdoc->value();
$output = var_export($scalar_var->scalarval(), true);
}
else
{
print $xmlrpcdoc->faultString();
}
} break;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="generator" content="PSPad editor, www.pspad.com" />
<title>Joomla! XML-RPC Test Client</title>
<style type="text/css">
body {
margin: 0px;
padding: 0px;
border: 0px;
background-color: #A69A76;
}
form {
margin: 0px;
padding: 0px;
border: 0px;
}
.page {
margin-left: auto;
margin-right: auto;
margin-top: 10px;
margin-bottom: 10px;
padding: 5px;
width:80%;
background-color: #F2EBDD;
text-align: left;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
td {
font-size: 11px;
color: #000000;
text-decoration: none;
line-height: 14px;
}
input {
border: 1px solid #AD5900;
background-color: #fff;
padding: 2px;
}
.int_h1 {
font-family: verdana;
font-size: 18px;
font-weight: bold;
}
.section_colour_bar{
height: 2px;
background-color:#AD5900;
}
.ctr {
text-align: center;
}
</style>
</head>
<body>
<form method="post">
<div class="ctr" align="center">
<div class="page" align="center">
<div style="background-color:#fff">
<div class="int_h1" style="padding: 3px 0 8px 5px;">Joomla! XML-RPC Test Client</div>
</div>
<div class="section_colour_bar"></div>
<table>
<tr>
<td>XML-RPC Host</td>
<td>
<input name="host" type="text" size="50" value="<?php echo $host; ?>" />
<small>Eg: www.test.com or http://james:bond@www.test.com/xmlrpc</small>
</td>
</tr>
<tr>
<td>Server File</td>
<td>
<input name="path" type="text" size="50" value="<?php echo $path; ?>" />
<input name="task" type="submit" value="list_methods" />
Debug:
<input name="debug" type="checkbox" value="1" <?php echo $debug ? 'checked="yes"' : ''; ?> />
</td>
</tr>
</table>
<?php echo $output; ?>
</div>
</div>
</form>
</body>
</html>
|