添加到 trunk

+YUCHENG HU+

git-svn-id: https://svn.code.sf.net/p/hawebs/svn@155 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-06-12 18:41:24 +00:00
parent 5db78d937d
commit bd0e0cd8e5
7 changed files with 445 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
+212
View File
@@ -0,0 +1,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:[email protected]/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>
@@ -0,0 +1,75 @@
<?php
/**
* @version $Id: application.php 10823 2008-08-27 17:18:14Z tcp $
* @package Joomla
* @subpackage Installation
* @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.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
/**
* Joomla! XML-RPC Application class
*
* Provide many supporting API functions
*
* @package Joomla
* @final
*/
class JXMLRPC extends JApplication
{
/**
* The encoding (default: UTF-8)
*
* @var string
* @access protected
*/
var $_encoding = null;
/**
* Class constructor
*
* @access protected
* @param array An optional associative array of configuration settings.
* Recognized key values include 'clientId' (this list is not meant to be comprehensive).
*/
function __construct($config = array())
{
$config['clientId'] = 3;
parent::__construct($config);
//Set the encoding
$this->_encoding = "UTF-8";
//Set the root in the URI based on the application name
JURI::root(null, str_replace('/'.$this->getName(), '', JURI::base(true)));
}
/**
* Get the charset encoding
*
* @return string the charset encoding
* @since 1.5
*/
function getEncoding() {
return $this->_encoding;
}
/**
* Set the charset encoding
*
* @var $encoding The encoding of the charset
*/
function setEncoding($encoding) {
$this->_encoding = $encoding;
}
}
?>
@@ -0,0 +1,31 @@
<?php
/**
* @version $Id: defines.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Installation
* @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.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
//Joomla framework path definitions
$parts = explode( DS, JPATH_BASE );
array_pop( $parts );
define( 'JPATH_ROOT', implode( DS, $parts ) );
define( 'JPATH_SITE', JPATH_ROOT );
define( 'JPATH_CONFIGURATION', JPATH_ROOT );
define( 'JPATH_INSTALLATION', JPATH_ROOT . DS . 'installation' );
define( 'JPATH_ADMINISTRATOR', JPATH_ROOT . DS . 'administrator' );
define( 'JPATH_XMLRPC', JPATH_ROOT . DS . 'xmlrpc' );
define( 'JPATH_LIBRARIES', JPATH_ROOT . DS . 'libraries' );
define( 'JPATH_PLUGINS', JPATH_ROOT . DS . 'plugins' );
define( 'JPATH_CACHE', JPATH_BASE . DS . 'cache');
?>
@@ -0,0 +1,67 @@
<?php
/**
* @version $Id: framework.php 10382 2008-06-01 06:56:02Z pasamio $
* @package Joomla
* @subpackage Installation
* @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.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
/*
* Joomla! system checks
*/
@set_magic_quotes_runtime( 0 );
@ini_set('zend.ze1_compatibility_mode', '0');
if (!file_exists( JPATH_CONFIGURATION . DS . 'configuration.php' ) || (filesize( JPATH_CONFIGURATION . DS . 'configuration.php' ) < 10)) {
// TODO: Throw 500 error
header( 'Location: ../installation/index.php' );
exit();
}
/*
* Joomla! system startup
*/
// System includes
require_once( JPATH_LIBRARIES .DS.'joomla'.DS.'import.php');
// Pre-Load configuration
require_once( JPATH_CONFIGURATION .DS.'configuration.php' );
// System configuration
$CONFIG = new JConfig();
if (@$CONFIG->error_reporting === 0) {
error_reporting( 0 );
} else if (@$CONFIG->error_reporting > 0) {
error_reporting( $CONFIG->error_reporting );
ini_set( 'display_errors', 1 );
}
unset( $CONFIG );
/*
* Joomla! framework loading
*/
// Include object abstract class
require_once(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'utilities'.DS.'compat'.DS.'compat.php');
// Joomla! library imports
jimport( 'joomla.environment.uri' );
jimport( 'joomla.user.user' );
jimport( 'joomla.event.event');
jimport( 'joomla.event.dispatcher');
jimport( 'joomla.plugin.helper' );
jimport( 'joomla.utilities.string' );
?>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
+58
View File
@@ -0,0 +1,58 @@
<?php
/**
*
* @version $Id: index.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Installation
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software and parts of it may contain or be derived from 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';
// We want to echo the errors so that the xmlrpc client has a chance to capture them in the payload
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')) {
JError::raiseError(403, 'XML-RPC Server not enabled.');
}
// Includes the required class file for the XML-RPC Server
jimport('phpxmlrpc.xmlrpc');
jimport('phpxmlrpc.xmlrpcs');
// load all available remote calls
JPluginHelper::importPlugin( 'xmlrpc' );
$allCalls = $mainframe->triggerEvent( 'onGetWebServices' );
$methodsArray = array();
foreach ($allCalls as $calls) {
$methodsArray = array_merge($methodsArray, $calls);
}
$xmlrpcServer = new xmlrpc_server($methodsArray, false);
// allow casting to be defined by that actual values passed
$xmlrpcServer->functions_parameters_type = 'phpvals';
// define UTF-8 as the internal encoding for the XML-RPC server
$xmlrpcServer->xml_header($mainframe->getEncoding());
$xmlrpc_internalencoding = $mainframe->getEncoding();
// debug level
$xmlrpcServer->setDebug(0);
// start the service
$xmlrpcServer->service();
?>