/**
  * Output the content of the resource
  *
  * @param array $options An array of options for the output
  */
 public function outputContent(array $options = array())
 {
     if (empty($options['rpc_type'])) {
         $options['rpc_type'] = 'XML';
     }
     $resourceClass = 'mod' . $options['rpc_type'] . 'RPCResource';
     if (!$this->modx->resource instanceof $resourceClass) {
         $this->modx->log(modX::LOG_LEVEL_FATAL, 'Could not load ' . $options['rpc_type'] . '-RPC Server class.');
     }
     $this->modx->resource->process();
     $this->modx->resource->_output = $this->modx->resource->_content;
     /* collect any uncached element tags in the content and process them */
     $this->modx->getParser();
     $maxIterations = intval($this->modx->getOption('parser_max_iterations', null, 10));
     $this->modx->parser->processElementTags('', $this->modx->resource->_output, true, false, '[[', ']]', array(), $maxIterations);
     $this->modx->parser->processElementTags('', $this->modx->resource->_output, true, true, '[[', ']]', array(), $maxIterations);
     if (!$this->getServer()) {
         $this->modx->log(modX::LOG_LEVEL_FATAL, 'Could not load ' . $options['rpc_type'] . '-RPC Server.');
     }
     $this->server->service();
     ob_get_level() && @ob_end_flush();
     while (ob_get_level() && @ob_end_clean()) {
     }
     exit;
 }
 function index($request)
 {
     // Create an xmlrpc server, and set up the method calls
     $service = new xmlrpc_server(array("blogger.getUsersBlogs" => array("function" => array($this, "getUsersBlogs")), "metaWeblog.getRecentPosts" => array('function' => array($this, 'getRecentPosts')), 'metaWeblog.getCategories' => array('function' => array($this, 'getCategories'))), false);
     // Use nice php functions, and call the service
     $service->functions_parameters_type = 'phpvals';
     $service->service();
     // Tell SilverStripe not to try render a template
     return false;
 }
Esempio n. 3
0
	public function service()
	{
		$app = JFactory::getApplication();

		$params = JComponentHelper::getParams('com_xmlrpc');

		$plugin = $params->get('plugin', 'joomla');

		JPluginHelper::importPlugin('xmlrpc', strtolower($plugin));
		$allCalls = $app->triggerEvent('onGetWebServices');
		if(count($allCalls) < 1){
			JError::raiseError(404, JText::_('COM_XMLRPC_SERVICE_WAS_NOT_FOUND'));
		}

		$methodsArray = array();

		foreach ($allCalls as $calls) {
			$methodsArray = array_merge($methodsArray, $calls);
		}

		@mb_regex_encoding('UTF-8');
		@mb_internal_encoding('UTF-8');

		require_once dirname(__FILE__).'/libraries/phpxmlrpc/xmlrpc.php';
		require_once dirname(__FILE__).'/libraries/phpxmlrpc/xmlrpcs.php';
		require_once (JPATH_SITE.'/components/com_content/helpers/route.php');
		JTable::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_content/tables');

		$xmlrpc = new xmlrpc_server($methodsArray, false);
		$xmlrpc->functions_parameters_type = 'phpvals';

		$encoding = 'UTF-8';

		$xmlrpc->xml_header($encoding);
		$GLOBALS['xmlrpc_internalencoding'] = $encoding;
		$xmlrpc->setDebug($params->get('debug', JDEBUG));
		@ini_set( 'display_errors', $params->get('display_errors', 0));

		$data = file_get_contents('php://input');

		if(empty($data)){
			JError::raiseError(403, JText::_('COM_XMLRPC_INVALID_REQUEST'));
		}

		$xmlrpc->service($data);

		jexit();
	}
Esempio n. 4
0
 public function display($cachable = false, $urlparams = array())
 {
     $mainframe = JFactory::getApplication();
     $methodsArray = $this->_getServices();
     $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
     $defaultEncoding = 'UTF-8';
     $xmlrpcServer->xml_header($defaultEncoding);
     $xmlrpc_internalencoding = $defaultEncoding;
     // debug level
     $xmlrpcServer->setDebug(0);
     // start the service
     $xmlrpcServer->service();
     exit;
 }
 public function import()
 {
     global $xmlrpcString, $xmlrpcBase64, $xmlrpc_internalencoding;
     /*
     		$db = JFactory::getDBO();
     		$query = $db->getQuery(true);
     		$query->select($db->quoteName('element'));
     		$query->from($db->quoteName('#__extensions'));
     		$query->where($db->quoteName('type') . ' = ' . $db->quote('library'));
     		$query->where($db->quoteName('element') . ' = ' . $db->quote('xmlrpc'));
     		$query->where($db->quoteName('enabled') . ' = 1');
     		$db->setQuery($query);
     		
     		if ($db->loadResult() == null)
     		{
     			echo '<?xml version="1.0"?>
     				<methodResponse><params><param><value><array><data><value><struct>
     				<member><name>code</name><value><int>15</int></value></member>
     				<member><name>string</name><value><string>XMLRC not supported</string></value></member>
     				</struct></value></data></array></value></param></params></methodResponse>';
     			return;	
     		}
     */
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_j2xml');
     $xmlrpcServer = new xmlrpc_server(array('j2xml.import' => array('function' => 'plgXMLRPCJ2XMLServices::import', 'docstring' => 'Import articles from xml file', 'signature' => array(array($xmlrpcString, $xmlrpcBase64, $xmlrpcString, $xmlrpcString)))), 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('UTF-8');
     $xmlrpc_internalencoding = 'UTF-8';
     // debug level
     $xmlrpcServer->setDebug($params->get('debug'));
     // start the service
     $xmlrpcServer->service();
 }
    global $xmlrpcName, $xmlrpcVersion, $SERVER_SOFTWARE;
    $ret = array("toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/", "toolkitName" => $xmlrpcName, "toolkitVersion" => $xmlrpcVersion, "toolkitOperatingSystem" => isset($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE']);
    return new xmlrpcresp(php_xmlrpc_encode($ret));
}
$o = new xmlrpc_server_methods_container();
$a = array("examples.getStateName" => array("function" => "findstate", "signature" => $findstate_sig, "docstring" => $findstate_doc), "examples.sortByAge" => array("function" => "agesorter", "signature" => $agesorter_sig, "docstring" => $agesorter_doc), "examples.addtwo" => array("function" => "addtwo", "signature" => $addtwo_sig, "docstring" => $addtwo_doc), "examples.addtwodouble" => array("function" => "addtwodouble", "signature" => $addtwodouble_sig, "docstring" => $addtwodouble_doc), "examples.stringecho" => array("function" => "stringecho", "signature" => $stringecho_sig, "docstring" => $stringecho_doc), "examples.echo" => array("function" => "echoback", "signature" => $echoback_sig, "docstring" => $echoback_doc), "examples.decode64" => array("function" => "echosixtyfour", "signature" => $echosixtyfour_sig, "docstring" => $echosixtyfour_doc), "examples.invertBooleans" => array("function" => "bitflipper", "signature" => $bitflipper_sig, "docstring" => $bitflipper_doc), "examples.generatePHPWarning" => array("function" => array($o, "phpwarninggenerator")), "examples.raiseException" => array("function" => array($o, "exceptiongenerator")), "examples.getallheaders" => array("function" => 'getallheaders_xmlrpc', "signature" => $getallheaders_sig, "docstring" => $getallheaders_doc), "examples.setcookies" => array("function" => 'setcookies', "signature" => $setcookies_sig, "docstring" => $setcookies_doc), "examples.getcookies" => array("function" => 'getcookies', "signature" => $getcookies_sig, "docstring" => $getcookies_doc), "mail.send" => array("function" => "mail_send", "signature" => $mail_send_sig, "docstring" => $mail_send_doc), "validator1.arrayOfStructsTest" => array("function" => "v1_arrayOfStructs", "signature" => $v1_arrayOfStructs_sig, "docstring" => $v1_arrayOfStructs_doc), "validator1.easyStructTest" => array("function" => "v1_easyStruct", "signature" => $v1_easyStruct_sig, "docstring" => $v1_easyStruct_doc), "validator1.echoStructTest" => array("function" => "v1_echoStruct", "signature" => $v1_echoStruct_sig, "docstring" => $v1_echoStruct_doc), "validator1.manyTypesTest" => array("function" => "v1_manyTypes", "signature" => $v1_manyTypes_sig, "docstring" => $v1_manyTypes_doc), "validator1.moderateSizeArrayCheck" => array("function" => "v1_moderateSizeArrayCheck", "signature" => $v1_moderateSizeArrayCheck_sig, "docstring" => $v1_moderateSizeArrayCheck_doc), "validator1.simpleStructReturnTest" => array("function" => "v1_simpleStructReturn", "signature" => $v1_simpleStructReturn_sig, "docstring" => $v1_simpleStructReturn_doc), "validator1.nestedStructTest" => array("function" => "v1_nestedStruct", "signature" => $v1_nestedStruct_sig, "docstring" => $v1_nestedStruct_doc), "validator1.countTheEntities" => array("function" => "v1_countTheEntities", "signature" => $v1_countTheEntities_sig, "docstring" => $v1_countTheEntities_doc), "interopEchoTests.echoString" => array("function" => "i_echoString", "signature" => $i_echoString_sig, "docstring" => $i_echoString_doc), "interopEchoTests.echoStringArray" => array("function" => "i_echoStringArray", "signature" => $i_echoStringArray_sig, "docstring" => $i_echoStringArray_doc), "interopEchoTests.echoInteger" => array("function" => "i_echoInteger", "signature" => $i_echoInteger_sig, "docstring" => $i_echoInteger_doc), "interopEchoTests.echoIntegerArray" => array("function" => "i_echoIntegerArray", "signature" => $i_echoIntegerArray_sig, "docstring" => $i_echoIntegerArray_doc), "interopEchoTests.echoFloat" => array("function" => "i_echoFloat", "signature" => $i_echoFloat_sig, "docstring" => $i_echoFloat_doc), "interopEchoTests.echoFloatArray" => array("function" => "i_echoFloatArray", "signature" => $i_echoFloatArray_sig, "docstring" => $i_echoFloatArray_doc), "interopEchoTests.echoStruct" => array("function" => "i_echoStruct", "signature" => $i_echoStruct_sig, "docstring" => $i_echoStruct_doc), "interopEchoTests.echoStructArray" => array("function" => "i_echoStructArray", "signature" => $i_echoStructArray_sig, "docstring" => $i_echoStructArray_doc), "interopEchoTests.echoValue" => array("function" => "i_echoValue", "signature" => $i_echoValue_sig, "docstring" => $i_echoValue_doc), "interopEchoTests.echoBase64" => array("function" => "i_echoBase64", "signature" => $i_echoBase64_sig, "docstring" => $i_echoBase64_doc), "interopEchoTests.echoDate" => array("function" => "i_echoDate", "signature" => $i_echoDate_sig, "docstring" => $i_echoDate_doc), "interopEchoTests.whichToolkit" => array("function" => "i_whichToolkit", "signature" => $i_whichToolkit_sig, "docstring" => $i_whichToolkit_doc));
if ($findstate2_sig) {
    $a['examples.php.getStateName'] = $findstate2_sig;
}
if ($findstate3_sig) {
    $a['examples.php2.getStateName'] = $findstate3_sig;
}
if ($findstate4_sig) {
    $a['examples.php3.getStateName'] = $findstate4_sig;
}
if ($findstate5_sig) {
    $a['examples.php4.getStateName'] = $findstate5_sig;
}
$s = new xmlrpc_server($a, false);
$s->setdebug(3);
$s->compress_response = true;
// out-of-band information: let the client manipulate the server operations.
// we do this to help the testsuite script: do not reproduce in production!
if (isset($_GET['RESPONSE_ENCODING'])) {
    $s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
}
if (isset($_GET['EXCEPTION_HANDLING'])) {
    $s->exception_handling = $_GET['EXCEPTION_HANDLING'];
}
$s->service();
// that should do all we need!
Esempio n. 7
0
/* used for global variables */
$GLOBALS['exttMbqVarArr']['microtime'] = microtime();
if (function_exists('set_magic_quotes_runtime')) {
    @set_magic_quotes_runtime(0);
}
if (isset($_SERVER['HTTP_X_PHPDEBUG']) && $_SERVER['HTTP_X_PHPDEBUG']) {
    error_reporting($_SERVER['HTTP_X_PHPDEBUG']);
} else {
    error_reporting(0);
    ini_set('display_errors', '0');
}
$mobiquo_dir = 'mobiquo';
include_once 'lib/classTTJson.php';
include_once 'lib/classTTConnection.php';
require 'pretreat.php';
define('SMF', 1);
require 'MbqDataPage.php';
require 'lib/xmlrpc.inc';
require 'lib/xmlrpcs.inc';
require 'server_define.php';
require 'mobiquo_common.php';
require 'mobiquo_action.php';
require 'env_setting.php';
require 'smf_entry.php';
require 'xmlrpcresp.php';
$rpcServer = new xmlrpc_server($server_param, false);
$rpcServer->setDebug(1);
$rpcServer->compress_response = true;
$rpcServer->response_charset_encoding = 'UTF-8';
$rpcServer->service($server_data);
exit;
Esempio n. 8
0
	(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
	ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

	The views and conclusions contained in the software and documentation are those
	of the authors and should not be interpreted as representing official policies,
	either expressed or implied, of the NAS4Free Project.
*/
require_once "config.inc";
require_once "util.inc";
require_once "system.inc";
require_once "XMLRPC/xmlrpc.inc";
require_once "XMLRPC/xmlrpcs.inc";
function xmlrpc_system_getinfo($xmlrpcmsg)
{
    $value = system_get_sysinfo();
    return new xmlrpcresp(php_xmlrpc_encode($value));
}
// When an XML-RPC request is sent to this script, it can be found in the
// raw post data.
$request_xml = file_get_contents("php://input");
if (empty($request_xml)) {
    die;
}
// Create XMLRPC server.
$xmlrpc_server = new xmlrpc_server(array("systemGetInfo" => array("function" => "xmlrpc_system_getinfo", "signature" => array(array($xmlrpcStruct)), "docstring" => "Get various system informations.")), false);
// Process request.
$xmlrpc_server->service($request_xml);
Esempio n. 9
0
ob_start();
include './include/xmlrpc.inc';
include './include/xmlrpcs.inc';
include './config/config.php';
include './mobiquo_common.php';
define('PHPBB_MSG_HANDLER', 'xmlrpc_error_handler');
register_shutdown_function('xmlrpc_shutdown');
include $phpbb_root_path . 'common.' . $phpEx;
error_reporting(MOBIQUO_DEBUG);
if (MOBIQUO_DEBUG == 0) {
    ob_start();
}
require './server_define.php';
require './env_setting.php';
require './xmlrpcresp.php';
if ($request_file && isset($server_param[$request_method])) {
    if (strpos($request_file, 'm_') === 0) {
        require './function/moderation.php';
    } else {
        require './function/' . $request_file . '.php';
    }
} else {
    require 'web.php';
    exit;
}
$rpcServer = new xmlrpc_server($server_param, false);
$rpcServer->setDebug(1);
$rpcServer->compress_response = 'true';
$rpcServer->response_charset_encoding = 'UTF-8';
$rpcServer->service();
exit;
Esempio n. 10
0
// 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();
Esempio n. 11
0
    if (strcmp($sAuthHash, $_GET['authHash']) != 0) {
        /* authentication failed - generate fault code and string */
        $aOutput = array('faultCode' => '-1', 'faultString' => 'authentication failed');
        $pResp = new xmlrpcresp(php_xmlrpc_encode($aOutput));
        echo $pResp->serialize();
    } else {
        /* authentication okay */
        /* set common signature for the methods */
        $aSignature = array(array($xmlrpcStruct, $xmlrpcStruct));
        $pMyGameClass = new TheGame();
        /* methods to be registered - $pMyGameClass is an instance of class TheGame */
        $aRegister = array('game.login' => array('function' => array($pMyGameClass, 'Login'), 'signature' => $aSignature), 'game.registerAndLogin' => array('function' => array($pMyGameClass, 'Register'), 'signature' => $aSignature), 'game.getUserStats' => array('function' => array($pMyGameClass, 'GetStats'), 'signature' => $aSignature), 'bookItem' => array('function' => array($pMyGameClass, 'BookItem'), 'signature' => $aSignature), 'blockedNotify' => array('function' => array($pMyGameClass, 'BlockedNotify'), 'signature' => $aSignature), 'getUserPaymentLanguage' => array('function' => array($pMyGameClass, 'GetUserPaymentLanguage'), 'signature' => $aSignature), 'getUserExchangeRate' => array('function' => array($pMyGameClass, 'GetUserExchangeRate'), 'signature' => $aSignature), 'currencySwap' => array('function' => array($pMyGameClass, 'CurrencySwap'), 'signature' => $aSignature));
        /* create server, set encoding and invoke */
        $pServer = new xmlrpc_server($aRegister, false);
        $pServer->response_charset_encoding = 'UTF-8';
        $pServer->service();
    }
}
/* example game class */
class TheGame
{
    function Login($pXml)
    {
        /* do your stuff here and return something like: */
        $aParams = php_xmlrpc_decode($pXml);
        $aParams = $aParams[0];
        $bpUserID = $aParams['bpUserID'];
        $login_id = $aParams['userID'];
        db("select * from user_accounts where login_id={$login_id} and bp_user_id={$bpUserID}");
        $data = dbr();
        if (dbc()) {
Esempio n. 12
0
require_once './lib/xmlrpcs.inc';
require_once './method_define.php';
require_once './api/forum.php';
require_once './api/topic.php';
require_once './api/subscription.php';
require_once './api/search.php';
require_once './api/user.php';
require_once './api/post.php';
require_once './api/moderation.php';
header('Mobiquo_is_login: '******'is_guest'] ? 'false' : 'true'));
header('Content-type: text/xml');
$rpcServer = new xmlrpc_server($methods, false);
$rpcServer->setDebug(1);
$rpcServer->compress_response = true;
$rpcServer->response_charset_encoding = 'UTF-8';
$pass = $rpcServer->service();
if ($pass !== false) {
    exit;
}
// Load settings and the database
loadMobiquoSettings();
// Parse the request
parseMobRequest();
// Are we closed?
if (!empty($context['in_maintenance']) && !$user_info['is_admin'] && !in_array($context['mob_request']['method'], array('get_config', 'login'))) {
    createErrorResponse(5, ' due to maintenance');
}
// Invalid method?
if (!function_exists('method_' . $context['mob_request']['method'])) {
    createErrorResponse('unknown_method', ' : ' . $context['mob_request']['method'], 'xmlrpc');
}
include BASEDIR . 'modules/Forums/nukebb.php';
// Initialise tapatalk
include MOBIDIR . 'include/xmlrpc.inc';
include MOBIDIR . 'include/xmlrpcs.inc';
require MOBIDIR . 'error_code.php';
require MOBIDIR . 'config/config.php';
$mobiquo_config = get_mobiquo_config();
if (empty($mobiquo_config['is_open'])) {
    header("{$_SERVER['SERVER_PROTOCOL']} 503 Service Unavailable");
    exit;
}
require MOBIDIR . 'mobiquo_common.php';
require MOBIDIR . 'server_define.php';
$phpEx = $mobiquo_config['php_extension'];
$xmlrpc_internalencoding = 'UTF-8';
$xmlrpcName = 'DragonflyCMS/' . CPG_NUKE . ' (PHP ' . PHP_MAJOR_VERSION . '; ' . PHP_SAPI . '; ' . PHP_OS . ') XML-RPC Tapatalk/3';
$xmlrpcVersion = 'v' . $mobiquo_config['sys_version'];
header('Mobiquo_is_login:'******'true' : 'false'));
// Get requested function and load file
$request_method_name = get_method_name();
if ($request_method_name && isset($server_param[$request_method_name])) {
    require MOBIDIR . 'function/' . $request_method_name . '.php';
}
$rpcServer = new xmlrpc_server($server_param, false);
$rpcServer->setDebug(2);
$rpcServer->allow_system_funcs = false;
$rpcServer->compress_response = 'false';
$rpcServer->response_charset_encoding = 'UTF-8';
$response = $rpcServer->service();
ini_restore('log_errors');
exit;
Esempio n. 14
0
            if (!$config['allow_avatar'] && $user->data['user_avatar_type']) {
                $error[] = $user->lang['AVATAR_NOT_ALLOWED'];
            } else {
                if ($user->data['user_avatar_type'] == AVATAR_UPLOAD && !$config['allow_avatar_upload'] || $user->data['user_avatar_type'] == AVATAR_REMOTE && !$config['allow_avatar_remote'] || $user->data['user_avatar_type'] == AVATAR_GALLERY && !$config['allow_avatar_local']) {
                    $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED'];
                }
            }
        }
    }
    $warn_msg = strip_tags(join("\n", $error));
}
require './server_define.php';
$rpcServer = new xmlrpc_server($server_param, false);
$rpcServer->setDebug(1);
$rpcServer->compress_response = 'true';
$rpcServer->response_charset_encoding = 'UTF-8';
$raw_data = '<?xml version="1.0"?><methodCall><methodName>' . $_POST['method_name'] . '</methodName><params></params></methodCall>';
$response = $rpcServer->service($raw_data);
function upload_attach_func()
{
    global $attachment_id, $group_id, $warn_msg;
    $xmlrpc_result = new xmlrpcval(array('attachment_id' => new xmlrpcval($attachment_id), 'group_id' => new xmlrpcval($group_id), 'result' => new xmlrpcval($attachment_id ? true : false, 'boolean'), 'result_text' => new xmlrpcval(strip_tags($warn_msg), 'base64')), 'struct');
    return new xmlrpcresp($xmlrpc_result);
}
function upload_avatar_func()
{
    global $status, $warn_msg;
    $xmlrpc_result = new xmlrpcval(array('result' => new xmlrpcval($status, 'boolean'), 'result_text' => new xmlrpcval($warn_msg, 'base64')), 'struct');
    return new xmlrpcresp($xmlrpc_result);
}
exit;
Esempio n. 15
0
 function service()
 {
     global $ErrorManager;
     $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_errorHandler'));
     xmlrpc_server::service();
     $ErrorManager->popErrorHandler();
 }
Esempio n. 16
0
<?php

if (isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
    if (defined('XMLRPCDBG')) {
        logfile(array($GLOBALS['HTTP_RAW_POST_DATA']), 'xmlrpcdbglog');
    }
}
include_once FLGR_COMMON . '/rfunctions.php';
$xmlrpc_server = new xmlrpc_server($manifesto_xmlrpc, false);
//dbg($xmlrpc_server, 'server object');
$xmlrpc_server->setdebug(3);
//$xmlrpc_server->compress_response = true;
$xmlrpc_server->compress_response = false;
//$xmlrpc_server->allow_system_funcs = false;
$xmlrpc_server->debug = false;
// out-of-band information: let the client manipulate the server operations.
// we do this to help the testsuite script: do not reproduce in production!
if (isset($_GET['RESPONSE_ENCODING'])) {
    $xmlrpc_server->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
}
$xmlrpc_server->service();
// that should do all we need!
exit;
 /**
  * Handles incoming requests to the kapost service
  */
 public function index()
 {
     //If the request is not a post request 404
     if (!$this->request->isPOST()) {
         return ErrorPage::response_for(404);
     }
     //If the request is not the kapost user agent 404
     if (self::config()->check_user_agent == true && $this->request->getHeader('User-Agent') != 'Kapost XMLRPC::Client') {
         return ErrorPage::response_for(404);
     }
     $methods = array_fill_keys($this->exposed_methods, array('function' => array($this, 'handleRPCMethod')));
     //Disable Content Negotiator and send the text/xml header (which kapost expects)
     ContentNegotiator::config()->enabled = false;
     $this->response->addHeader('Content-Type', 'text/xml');
     $server = new xmlrpc_server($methods, false);
     $server->compress_response = true;
     if (Director::isDev()) {
         $server->setDebug(3);
         //Base 64 encoded debug information is included in the response
     }
     //Tell XML-RPC to re-throw the exception rather than trap it so we can allow the SilverStripe's normal error handling along side sending the xmlrpc response
     $server->exception_handling = 2;
     //Force the internal encoding of the XMLRPC library to utf-8
     $GLOBALS['xmlrpc_internalencoding'] = self::config()->database_charset;
     try {
         return $server->service($this->request->getBody(), true);
     } catch (Exception $e) {
         //Call on SS_Log to log the error
         SS_Log::log($e, SS_Log::ERR);
         //Allow exceptions to handle the response
         $results = $this->extend('onException', $e);
         if ($results && is_array($results)) {
             $results = array_filter($results, function ($v) {
                 return !is_null($v) && $v instanceof xmlrpcresp;
             });
             if (count($results) > 0) {
                 $this->generateErrorResponse($server, array_shift($results));
             }
         }
         //If we're in dev mode relay the actual message to the client
         if (Director::isDev()) {
             $response = new xmlrpcresp(0, $e->getCode() + 100, _t('KapostService.ERROR_MESSAGE', '_{message} in {file} line {line_number}', array('message' => $e->getMessage(), 'file' => $e->getFile(), 'line_number' => $e->getLine())));
         } else {
             $response = new xmlrpcresp(0, 17, _t('KapostService.SERVER_ERROR', '_Internal server error'));
         }
         return $this->generateErrorResponse($server, $response);
     }
 }
    }
    mysql_query("UPDATE " . $mosConfig_dbprefix . "radiotv_channel SET " . "name='" . addcslashes($tiny_data['name'], "'") . "'," . "description='" . addcslashes($tiny_data['description'], "'") . "'," . "changed=1 " . "WHERE id=" . $tiny_data['id'] . ";");
    return new xmlrpcresp(new xmlrpcval($new, "int"));
}
function reset_channel()
{
    global $mosConfig_dbprefix;
    mysql_query("UPDATE " . $mosConfig_dbprefix . "radiotv_channel SET changed=0;");
    return new xmlrpcresp(new xmlrpcval(1, "int"));
}
function delete_channel()
{
    global $mosConfig_dbprefix;
    $result = mysql_query("SELECT count(*) FROM " . $mosConfig_dbprefix . "radiotv_channel WHERE changed=0;");
    $row = mysql_fetch_row($result);
    $delete = $row[0];
    if ($delete) {
        mysql_query("DELETE FROM " . $mosConfig_dbprefix . "radiotv_channel WHERE changed=0;");
    }
    return new xmlrpcresp(new xmlrpcval($delete, "int"));
}
function reset_channel_program()
{
    global $mosConfig_dbprefix;
    mysql_query("DELETE FROM " . $mosConfig_dbprefix . "radiotv_channel_program_rel WHERE 1=1;");
    return new xmlrpcresp(new xmlrpcval(1, "int"));
}
$server = new xmlrpc_server(array("get_table" => array("function" => "get_table", "signature" => array(array($xmlrpcInt, $xmlrpcString, $xmlrpcStruct))), "set_table" => array("function" => "set_table", "signature" => array(array($xmlrpcInt, $xmlrpcString, $xmlrpcStruct))), "reset_table" => array("function" => "reset_table", "signature" => array(array($xmlrpcInt, $xmlrpcString))), "delete_table" => array("function" => "delete_table", "signature" => array(array($xmlrpcInt, $xmlrpcString, $xmlrpcString))), "delete_items" => array("function" => "delete_items", "signature" => array(array($xmlrpcInt, $xmlrpcString, $xmlrpcArray, $xmlrpcString))), "get_channel" => array("function" => "get_channel", "signature" => array(array($xmlrpcArray))), "set_channel" => array("function" => "set_channel", "signature" => array(array($xmlrpcInt, $xmlrpcStruct))), "reset_channel" => array("function" => "reset_channel", "signature" => array(array($xmlrpcInt))), "delete_channel" => array("function" => "delete_channel", "signature" => array(array($xmlrpcInt))), "reset_channel_program" => array("function" => "reset_channel_program", "signature" => array(array($xmlrpcInt)))), false);
$server->functions_parameters_type = 'phpvals';
$server->service();
 /**
  * Handles incoming requests to the kapost service
  */
 public function index()
 {
     //If the request is not a post request 404
     if (!$this->request->isPOST()) {
         return ErrorPage::response_for(404);
     }
     //If the request is not the kapost user agent 404
     if (self::config()->check_user_agent == true && $this->request->getHeader('User-Agent') != 'Kapost XMLRPC::Client') {
         return ErrorPage::response_for(404);
     }
     $methods = array_fill_keys($this->exposed_methods, array('function' => array($this, 'handleRPCMethod')));
     //Disable Content Negotiator and send the text/xml header (which kapost expects)
     ContentNegotiator::config()->enabled = false;
     $this->response->addHeader('Content-Type', 'text/xml');
     $server = new xmlrpc_server($methods, false);
     $server->compress_response = true;
     if (Director::isDev()) {
         $server->setDebug(3);
         //Base 64 encoded debug information is included in the response
         $server->exception_handling = 2;
         //Exception's sent to the client
     }
     //Force the internal encoding of the XMLRPC library to utf-8
     $GLOBALS['xmlrpc_internalencoding'] = self::config()->database_charset;
     return $server->service($this->request->getBody(), true);
 }