PageRenderTime 26ms CodeModel.GetById 11ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

/class/xml/rpc/xmlrpc.php

https://gitlab.com/VoyaTrax/vtCMS
PHP | 82 lines | 52 code | 3 blank | 27 comment | 7 complexity | 9dc127bdd4de8d61a8bcfe6b43dcd0b6 MD5 | raw file
 1<?php
 2//  ------------------------------------------------------------------------ //
 3//                XOOPS - PHP Content Management System                      //
 4//                    Copyright (c) 2000 XOOPS.org                           //
 5//                       <http://www.xoops.org/>                             //
 6//  ------------------------------------------------------------------------ //
 7//  This program is free software; you can redistribute it and/or modify     //
 8//  it under the terms of the GNU General Public License as published by     //
 9//  the Free Software Foundation; either version 2 of the License, or        //
10//  (at your option) any later version.                                      //
11//                                                                           //
12//  You may not change or alter any portion of this comment or credits       //
13//  of supporting developers from this source code or any supporting         //
14//  source code which is considered copyrighted (c) material of the          //
15//  original comment or credit authors.                                      //
16//                                                                           //
17//  This program is distributed in the hope that it will be useful,          //
18//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
19//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
20//  GNU General Public License for more details.                             //
21//                                                                           //
22//  You should have received a copy of the GNU General Public License        //
23//  along with this program; if not, write to the Free Software              //
24//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
25//  ------------------------------------------------------------------------ //
26
27define('XOOPS_XMLRPC', 1);
28include './mainfile.php';
29error_reporting(0);
30include_once XOOPS_ROOT_PATH.'/class/xml/rpc/xmlrpctag.php';
31include_once XOOPS_ROOT_PATH.'/class/xml/rpc/xmlrpcparser.php';
32
33global $xoopsErrorHandler;
34$xoopsErrorHandler->activate( false );
35
36$response = new XoopsXmlRpcResponse();
37$parser = new XoopsXmlRpcParser( rawurlencode( $GLOBALS['HTTP_RAW_POST_DATA'] ) );
38if (!$parser->parse()) {
39	$response->add(new XoopsXmlRpcFault(102));
40} else {
41	$module_handler =& xoops_gethandler('module');
42	$module =& $module_handler->getByDirname('news');
43	if (!is_object($module)) {
44		$response->add(new XoopsXmlRpcFault(110));
45	} else {
46		$methods = explode('.', $parser->getMethodName());
47		switch ($methods[0]) {
48		case 'blogger':
49			include_once XOOPS_ROOT_PATH.'/class/xml/rpc/bloggerapi.php';
50			$rpc_api = new BloggerApi($parser->getParam(), $response, $module);
51			break;
52		case 'metaWeblog':
53			include_once XOOPS_ROOT_PATH.'/class/xml/rpc/metaweblogapi.php';
54			$rpc_api = new MetaWeblogApi($parser->getParam(), $response, $module);
55			break;
56		case 'mt':
57			include_once XOOPS_ROOT_PATH.'/class/xml/rpc/movabletypeapi.php';
58			$rpc_api = new MovableTypeApi($parser->getParam(), $response, $module);
59			break;
60		case 'xoops':
61		default:
62			include_once XOOPS_ROOT_PATH.'/class/xml/rpc/xoopsapi.php';
63			$rpc_api = new XoopsApi($parser->getParam(), $response, $module);
64			break;
65		}
66		$method = $methods[1];
67		if (!method_exists($rpc_api, $method)) {
68			$response->add(new XoopsXmlRpcFault(107));
69		} else {
70			$rpc_api->$method();
71		}
72	}
73}
74$payload =& $response->render();
75//$fp = fopen(XOOPS_CACHE_PATH.'/xmllog.txt', 'w');
76//fwrite($fp, $payload);
77//fclose($fp);
78header('Server: XOOPS XML-RPC Server');
79header('Content-type: text/xml');
80header('Content-Length: '.strlen($payload));
81echo $payload;
82?>