wp/xmlrpc.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 21 48c4eec2b7e6
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    13 define( 'XMLRPC_REQUEST', true );
    13 define( 'XMLRPC_REQUEST', true );
    14 
    14 
    15 // Some browser-embedded clients send cookies. We don't want them.
    15 // Some browser-embedded clients send cookies. We don't want them.
    16 $_COOKIE = array();
    16 $_COOKIE = array();
    17 
    17 
    18 // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
    18 // $HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed in PHP 7.0.
    19 // but we can do it ourself.
    19 // phpcs:disable PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.http_raw_post_dataDeprecatedRemoved
    20 if ( ! isset( $HTTP_RAW_POST_DATA ) ) {
    20 if ( ! isset( $HTTP_RAW_POST_DATA ) ) {
    21 	$HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
    21 	$HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
    22 }
    22 }
    23 
    23 
    24 // fix for mozBlog and other cases where '<?xml' isn't on the very first line
    24 // Fix for mozBlog and other cases where '<?xml' isn't on the very first line.
    25 if ( isset( $HTTP_RAW_POST_DATA ) ) {
    25 if ( isset( $HTTP_RAW_POST_DATA ) ) {
    26 	$HTTP_RAW_POST_DATA = trim( $HTTP_RAW_POST_DATA );
    26 	$HTTP_RAW_POST_DATA = trim( $HTTP_RAW_POST_DATA );
    27 }
    27 }
       
    28 // phpcs:enable
    28 
    29 
    29 /** Include the bootstrap for setting up WordPress environment */
    30 /** Include the bootstrap for setting up WordPress environment */
    30 include( dirname( __FILE__ ) . '/wp-load.php' );
    31 require_once __DIR__ . '/wp-load.php';
    31 
    32 
    32 if ( isset( $_GET['rsd'] ) ) { // http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html
    33 if ( isset( $_GET['rsd'] ) ) { // http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html
    33 	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
    34 	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
    34 	echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
    35 	echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
    35 	?>
    36 	?>
    58 </rsd>
    59 </rsd>
    59 	<?php
    60 	<?php
    60 	exit;
    61 	exit;
    61 }
    62 }
    62 
    63 
    63 include_once( ABSPATH . 'wp-admin/includes/admin.php' );
    64 require_once ABSPATH . 'wp-admin/includes/admin.php';
    64 include_once( ABSPATH . WPINC . '/class-IXR.php' );
    65 require_once ABSPATH . WPINC . '/class-IXR.php';
    65 include_once( ABSPATH . WPINC . '/class-wp-xmlrpc-server.php' );
    66 require_once ABSPATH . WPINC . '/class-wp-xmlrpc-server.php';
    66 
    67 
    67 /**
    68 /**
    68  * Posts submitted via the XML-RPC interface get that title
    69  * Posts submitted via the XML-RPC interface get that title
    69  *
    70  *
    70  * @name post_default_title
    71  * @name post_default_title
    80  * @param string $class The name of the XML-RPC server class.
    81  * @param string $class The name of the XML-RPC server class.
    81  */
    82  */
    82 $wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' );
    83 $wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' );
    83 $wp_xmlrpc_server       = new $wp_xmlrpc_server_class;
    84 $wp_xmlrpc_server       = new $wp_xmlrpc_server_class;
    84 
    85 
    85 // Fire off the request
    86 // Fire off the request.
    86 $wp_xmlrpc_server->serve_request();
    87 $wp_xmlrpc_server->serve_request();
    87 
    88 
    88 exit;
    89 exit;
    89 
    90 
    90 /**
    91 /**
    94  * @see error_log()
    95  * @see error_log()
    95  *
    96  *
    96  * @param string $io Whether input or output
    97  * @param string $io Whether input or output
    97  * @param string $msg Information describing logging reason.
    98  * @param string $msg Information describing logging reason.
    98  */
    99  */
    99 function logIO( $io, $msg ) {
   100 function logIO( $io, $msg ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
   100 	_deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
   101 	_deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
   101 	if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) {
   102 	if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) {
   102 		error_log( $io . ' - ' . $msg );
   103 		error_log( $io . ' - ' . $msg );
   103 	}
   104 	}
   104 }
   105 }