source: trunk/blogs/xmlrpc.php @ 1941

Revision 1941, 3.2 KB checked in by Xiping.Wang, 4 months ago (diff)

[trunk] update wordpress to 3.3.1

Line 
1<?php
2/**
3 * XML-RPC protocol support for WordPress
4 *
5 * @package WordPress
6 */
7
8/**
9 * Whether this is a XMLRPC Request
10 *
11 * @var bool
12 */
13define('XMLRPC_REQUEST', true);
14
15// Some browser-embedded clients send cookies. We don't want them.
16$_COOKIE = array();
17
18// A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
19// but we can do it ourself.
20if ( !isset( $HTTP_RAW_POST_DATA ) ) {
21        $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
22}
23
24// fix for mozBlog and other cases where '<?xml' isn't on the very first line
25if ( isset($HTTP_RAW_POST_DATA) )
26        $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
27
28/** Include the bootstrap for setting up WordPress environment */
29include('./wp-load.php');
30
31if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
32header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
33?>
34<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
35<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
36  <service>
37    <engineName>WordPress</engineName>
38    <engineLink>http://wordpress.org/</engineLink>
39    <homePageLink><?php bloginfo_rss('url') ?></homePageLink>
40    <apis>
41      <api name="WordPress" blogID="1" preferred="true" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
42      <api name="Movable Type" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
43      <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
44      <api name="Blogger" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
45      <api name="Atom" blogID="" preferred="false" apiLink="<?php echo site_url('wp-app.php/service', 'rpc') ?>" />
46    </apis>
47  </service>
48</rsd>
49<?php
50exit;
51}
52
53include_once(ABSPATH . 'wp-admin/includes/admin.php');
54include_once(ABSPATH . WPINC . '/class-IXR.php');
55include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php');
56
57// Turn off all warnings and errors.
58// error_reporting(0);
59
60/**
61 * Posts submitted via the xmlrpc interface get that title
62 * @name post_default_title
63 * @var string
64 */
65$post_default_title = "";
66
67/**
68 * Whether to enable XMLRPC Logging.
69 *
70 * @name xmlrpc_logging
71 * @var int|bool
72 */
73$xmlrpc_logging = 0;
74
75/**
76 * logIO() - Writes logging info to a file.
77 *
78 * @uses $xmlrpc_logging
79 * @package WordPress
80 * @subpackage Logging
81 *
82 * @param string $io Whether input or output
83 * @param string $msg Information describing logging reason.
84 * @return bool Always return true
85 */
86function logIO($io,$msg) {
87        global $xmlrpc_logging;
88        if ($xmlrpc_logging) {
89                $fp = fopen("../xmlrpc.log","a+");
90                $date = gmdate("Y-m-d H:i:s ");
91                $iot = ($io == "I") ? " Input: " : " Output: ";
92                fwrite($fp, "\n\n".$date.$iot.$msg);
93                fclose($fp);
94        }
95        return true;
96}
97
98if ( isset($HTTP_RAW_POST_DATA) )
99        logIO("I", $HTTP_RAW_POST_DATA);
100
101// Make sure wp_die output is XML
102add_filter( 'wp_die_handler', '_xmlrpc_wp_die_filter' );
103
104// Allow for a plugin to insert a different class to handle requests.
105$wp_xmlrpc_server_class = apply_filters('wp_xmlrpc_server_class', 'wp_xmlrpc_server');
106$wp_xmlrpc_server = new $wp_xmlrpc_server_class;
107
108// Fire off the request
109$wp_xmlrpc_server->serve_request();
110?>
Note: See TracBrowser for help on using the repository browser.