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