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
';
$output .= JHTML::_('select.genericlist', $methods, 'method', 'size="10"', 'value', 'text' );
$output .= ' ';
$output .= ' ';
} 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;
}
}
?>