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