b2evolution PHP Cross Reference Blogging Systems

Source: /xmlsrv/xmlrpc.php - 88 lines - 2924 bytes - Text - Print

Description: XML-RPC APIs This file implements the XML-RPC handler, to be called by remote clients.

   1  <?php
   2  /**
   3   * XML-RPC APIs
   4   *
   5   * This file implements the XML-RPC handler, to be called by remote clients.
   6   *
   7   * b2evolution - {@link http://b2evolution.net/}
   8   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
   9   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  10   *
  11   * @package xmlsrv
  12   *
  13   * @version $Id: xmlrpc.php 6136 2014-03-08 07:59:48Z manuel $
  14   */
  15  
  16  // use xmlrpc_debugmsg() to add debug messages to responses or logIO() to
  17  // log them to a local file (preferred).
  18  
  19  /**
  20   * Initialize everything:
  21   */
  22  
  23  if( isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST' )
  24  {
  25      header('Content-Type: text/plain');
  26      die('XML-RPC server accepts POST requests only.');
  27  }
  28  
  29  // Disable Cookies
  30  $_COOKIE = array();
  31  
  32  if( ! isset($HTTP_RAW_POST_DATA) )
  33  {
  34      $HTTP_RAW_POST_DATA = implode("\r\n", file('php://input'));
  35  }
  36  // Trim requests (used by XML-RPC library); fix for mozBlog and other cases where '<?xml' isn't on the very first line
  37  $HTTP_RAW_POST_DATA = trim( $HTTP_RAW_POST_DATA );
  38  
  39  
  40  require_once dirname(__FILE__).'/../conf/_config.php';
  41  require_once $inc_path.'_main.inc.php';
  42  load_funcs('xmlrpc/model/_xmlrpc.funcs.php');
  43  
  44  if( CANUSEXMLRPC !== TRUE || ! $Settings->get('general_xmlrpc') )
  45  {    // We cannot use XML-RPC: send an error response ( "17 Internal server error" ).
  46      $errMessage = CANUSEXMLRPC !== TRUE
  47                      ? ( 'Cannot use XML-RPC. Probably the server is missing the XML extension. Error: '.CANUSEXMLRPC )
  48                      : 'XML-RPC services are disabled on this system.';
  49      $errResponse = new xmlrpcresp( 0, 17, $errMessage );
  50      die( $errResponse->serialize() );
  51  }
  52  
  53  
  54  // We can't display standard error messages. We must return XMLRPC responses.
  55  $DB->halt_on_error = false;
  56  $DB->show_errors = false;
  57  
  58  $post_default_title = ''; // posts submitted via the xmlrpc interface get that title
  59  
  60  
  61  /**
  62   * Array defining the available Remote Procedure Calls:
  63   */
  64  $xmlrpc_procs = array();
  65  
  66  
  67  // Load APIs:
  68  include_once $inc_path.'xmlrpc/apis/_blogger.api.php';
  69  include_once $inc_path.'xmlrpc/apis/_b2.api.php';
  70  include_once $inc_path.'xmlrpc/apis/_metaweblog.api.php';
  71  include_once $inc_path.'xmlrpc/apis/_mt.api.php';
  72  include_once $inc_path.'xmlrpc/apis/_wordpress.api.php';
  73  
  74  
  75  // fp> xmlrpc.php should actually only load the function/api/plugin to execute once it has been identified
  76  // fp> maybe it would make sense to register xmlrpc apis/functions in a DB table (before making plugins)
  77  // fp> it would probably make sense to have *all* xmlrpc methods implemented as plugins (maybe 1 plugin per API; it should be possible to add a single func to an API with an additional plugin)
  78  
  79  load_funcs('xmlrpc/model/_xmlrpcs.funcs.php'); // This will add generic remote calls
  80  
  81  // Set up the XML-RPC server:
  82  $s = new xmlrpc_server( $xmlrpc_procs, false );
  83  // Use the request encoding for the response:
  84  $s->response_charset_encoding = 'auto';
  85  // DO THE SERVING:
  86  $s->service();
  87  
  88  ?>

title

Description

title

Description

title

Description

title

title

Body