Textpattern PHP Cross Reference Content Management Systems

Source: /rpc/index.php - 150 lines - 4297 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * https://textpattern.com/
   6   *
   7   * XML-RPC Server for Textpattern 4.0.x
   8   * https://web.archive.org/web/20150119065246/http://txp.kusor.com/rpc-api
   9   *
  10   * Copyright (C) 2020 The Textpattern Development Team
  11   * Author: Pedro Palazón
  12   *
  13   * This file is part of Textpattern.
  14   *
  15   * Textpattern is free software; you can redistribute it and/or
  16   * modify it under the terms of the GNU General Public License
  17   * as published by the Free Software Foundation, version 2.
  18   *
  19   * Textpattern is distributed in the hope that it will be useful,
  20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22   * GNU General Public License for more details.
  23   *
  24   * You should have received a copy of the GNU General Public License
  25   * along with Textpattern. If not, see <https://www.gnu.org/licenses/>.
  26   */
  27  
  28  // TODO: change error reporting to E_ALL, including E_NOTICE to detect subtle bugs? See https://github.com/textpattern/textpattern/issues/1012
  29  error_reporting(E_ALL & ~E_NOTICE);
  30  
  31  // TODO: if display_errors is set to 0... who will ever see errors? See https://github.com/textpattern/textpattern/issues/1012
  32  ini_set("display_errors", "0");
  33  
  34  define('txpath', dirname(dirname(__FILE__)).'/textpattern');
  35  define('txpinterface', 'xmlrpc');
  36  
  37  require_once txpath.'/config.php';
  38  require_once txpath.'/lib/class.trace.php';
  39  
  40  $trace = new Trace();
  41  
  42  require_once txpath.'/lib/constants.php';
  43  require_once txpath.'/lib/txplib_db.php';
  44  require_once txpath.'/lib/txplib_misc.php';
  45  require_once txpath.'/lib/txplib_admin.php';
  46  require_once txpath.'/lib/admin_config.php';
  47  require_once txpath.'/lib/IXRClass.php';
  48  
  49  require_once txpath.'/vendors/Textpattern/Loader.php';
  50  
  51  $loader = new \Textpattern\Loader(txpath.'/vendors');
  52  $loader->register();
  53  
  54  $loader = new \Textpattern\Loader(txpath.'/lib');
  55  $loader->register();
  56  
  57  
  58  if ($connected && numRows(safe_query("show tables like '".PFX."textpattern'"))) {
  59      // TODO: where is dbversion used?
  60      $dbversion = safe_field('val', 'txp_prefs', "name = 'version'");
  61  
  62      // Hold it globally, instead of do several calls to the function.
  63      $prefs = get_prefs();
  64      extract($prefs);
  65  
  66      if (!defined('LANG')) {
  67          define("LANG", $language);
  68      }
  69  
  70      if (!defined('hu')) {
  71          define("hu", 'http://'.$siteurl.'/');
  72      }
  73  
  74      if (!defined('txrpcpath')) {
  75          define('txrpcpath', hu.'rpc/');
  76      }
  77  
  78      if (!empty($locale)) {
  79          setlocale(LC_ALL, $locale);
  80      }
  81  
  82      $textarray = load_lang(LANG);
  83  
  84  // TODO: include txplib_html instead of duplicating?
  85      // From txplib_html.php.
  86      if (!defined('t')) {
  87          define("t", "\t");
  88      }
  89  
  90      if (!defined('n')) {
  91          define("n", "\n");
  92      }
  93  
  94      if (!defined('br')) {
  95          define("br", "<br />");
  96      }
  97  
  98      if (!defined('sp')) {
  99          define("sp", "&#160;");
 100      }
 101  
 102      if (!defined('a')) {
 103          define("a", "&#38;");
 104      }
 105  }
 106  
 107  require_once txpath.'/lib/txplib_wrapper.php';
 108  require_once  'TXP_RPCServer.php';
 109  
 110  // Run the XML-RPC server.
 111  $server = new TXP_RPCServer();
 112  $server->serve();
 113  
 114  // TODO: remove before official release?
 115  // Save some debug logs.
 116  function write_log()
 117  {
 118      global $HTTP_RAW_POST_DATA;
 119  
 120      if (!defined('txpdmpfile')) {
 121          define('txpdmpfile', 'txpxmlrpc.txt');
 122      }
 123  
 124      $fp = @fopen(dirname(__FILE__).DIRECTORY_SEPARATOR.'xmlrpclog', 'a');
 125  
 126      if ($fp) {
 127          $lnsep = "\n================================\n";
 128          fwrite($fp, "\n$lnsep".strftime("%Y-%m-%d %H:%M:%S"));
 129          fwrite($fp, '[USER_AGENT] '.$_SERVER['HTTP_USER_AGENT']);
 130          fwrite($fp, $lnsep);
 131          fwrite($fp, '[ACCEPT_ENCODING] '.$_SERVER['HTTP_ACCEPT_ENCODING']);
 132  
 133          if (strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') !== false && is_callable('getallheaders')) {
 134              fwrite($fp, $lnsep);
 135              fwrite($fp, "Apache Request Headers:\n");
 136              fwrite($fp, $lnsep);
 137              $headers = getallheaders();
 138  
 139              foreach ($headers as $header => $value) {
 140                  fwrite($fp, "$header: $value \n");
 141              }
 142          }
 143  
 144          fwrite($fp, $lnsep);
 145          fwrite($fp, "Incoming data, usually utf-8 encoded:\n");
 146          fwrite($fp, $lnsep);
 147          fwrite($fp, $HTTP_RAW_POST_DATA);
 148          fclose($fp);
 149      }
 150  }

title

Description

title

Description

title

Description

title

title

Body