| 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 | |
|---|
| 27 | define('XOOPS_XMLRPC', 1); |
|---|
| 28 | include './mainfile.php'; |
|---|
| 29 | error_reporting(0); |
|---|
| 30 | include_once XOOPS_ROOT_PATH.'/class/xml/rpc/xmlrpctag.php'; |
|---|
| 31 | include_once XOOPS_ROOT_PATH.'/class/xml/rpc/xmlrpcparser.php'; |
|---|
| 32 | $response = new XoopsXmlRpcResponse(); |
|---|
| 33 | $parser = new XoopsXmlRpcParser(rawurldecode($GLOBALS['HTTP_RAW_POST_DATA'])); |
|---|
| 34 | if (!$parser->parse()) { |
|---|
| 35 | $response->add(new XoopsXmlRpcFault(102)); |
|---|
| 36 | } else { |
|---|
| 37 | $module_handler =& xoops_gethandler('module'); |
|---|
| 38 | $module =& $module_handler->getByDirname('news'); |
|---|
| 39 | if (!is_object($module)) { |
|---|
| 40 | $response->add(new XoopsXmlRpcFault(110)); |
|---|
| 41 | } else { |
|---|
| 42 | $methods = explode('.', $parser->getMethodName()); |
|---|
| 43 | switch ($methods[0]) { |
|---|
| 44 | case 'blogger': |
|---|
| 45 | include_once XOOPS_ROOT_PATH.'/class/xml/rpc/bloggerapi.php'; |
|---|
| 46 | $rpc_api = new BloggerApi($parser->getParam(), $response, $module); |
|---|
| 47 | break; |
|---|
| 48 | case 'metaWeblog': |
|---|
| 49 | include_once XOOPS_ROOT_PATH.'/class/xml/rpc/metaweblogapi.php'; |
|---|
| 50 | $rpc_api = new MetaWeblogApi($parser->getParam(), $response, $module); |
|---|
| 51 | break; |
|---|
| 52 | case 'mt': |
|---|
| 53 | include_once XOOPS_ROOT_PATH.'/class/xml/rpc/movabletypeapi.php'; |
|---|
| 54 | $rpc_api = new MovableTypeApi($parser->getParam(), $response, $module); |
|---|
| 55 | break; |
|---|
| 56 | case 'xoops': |
|---|
| 57 | default: |
|---|
| 58 | include_once XOOPS_ROOT_PATH.'/class/xml/rpc/xoopsapi.php'; |
|---|
| 59 | $rpc_api = new XoopsApi($parser->getParam(), $response, $module); |
|---|
| 60 | break; |
|---|
| 61 | } |
|---|
| 62 | $method = $methods[1]; |
|---|
| 63 | if (!method_exists($rpc_api, $method)) { |
|---|
| 64 | $response->add(new XoopsXmlRpcFault(107)); |
|---|
| 65 | } else { |
|---|
| 66 | $rpc_api->$method(); |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | $payload =& $response->render(); |
|---|
| 71 | //$fp = fopen(XOOPS_CACHE_PATH.'/xmllog.txt', 'w'); |
|---|
| 72 | //fwrite($fp, $payload); |
|---|
| 73 | //fclose($fp); |
|---|
| 74 | header('Server: XOOPS XML-RPC Server'); |
|---|
| 75 | header('Content-type: text/xml'); |
|---|
| 76 | header('Content-Length: '.strlen($payload)); |
|---|
| 77 | echo $payload; |
|---|
| 78 | ?> |
|---|