xmlrpc.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * XML-RPC protocol support for WordPress
  4. *
  5. * @package WordPress
  6. */
  7. /**
  8. * Whether this is an XML-RPC Request
  9. *
  10. * @var bool
  11. */
  12. define( 'XMLRPC_REQUEST', true );
  13. // Some browser-embedded clients send cookies. We don't want them.
  14. $_COOKIE = array();
  15. // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
  16. // but we can do it ourself.
  17. if ( ! isset( $HTTP_RAW_POST_DATA ) ) {
  18. $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
  19. }
  20. // fix for mozBlog and other cases where '<?xml' isn't on the very first line
  21. if ( isset( $HTTP_RAW_POST_DATA ) ) {
  22. $HTTP_RAW_POST_DATA = trim( $HTTP_RAW_POST_DATA );
  23. }
  24. /** Include the bootstrap for setting up WordPress environment */
  25. include( dirname( __FILE__ ) . '/wp-load.php' );
  26. if ( isset( $_GET['rsd'] ) ) { // http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html
  27. header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
  28. echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
  29. ?>
  30. <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
  31. <service>
  32. <engineName>WordPress</engineName>
  33. <engineLink>https://wordpress.org/</engineLink>
  34. <homePageLink><?php bloginfo_rss( 'url' ); ?></homePageLink>
  35. <apis>
  36. <api name="WordPress" blogID="1" preferred="true" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" />
  37. <api name="Movable Type" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" />
  38. <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" />
  39. <api name="Blogger" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" />
  40. <?php
  41. /**
  42. * Add additional APIs to the Really Simple Discovery (RSD) endpoint.
  43. *
  44. * @link http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html
  45. *
  46. * @since 3.5.0
  47. */
  48. do_action( 'xmlrpc_rsd_apis' );
  49. ?>
  50. </apis>
  51. </service>
  52. </rsd>
  53. <?php
  54. exit;
  55. }
  56. include_once( ABSPATH . 'wp-admin/includes/admin.php' );
  57. include_once( ABSPATH . WPINC . '/class-IXR.php' );
  58. include_once( ABSPATH . WPINC . '/class-wp-xmlrpc-server.php' );
  59. /**
  60. * Posts submitted via the XML-RPC interface get that title
  61. *
  62. * @name post_default_title
  63. * @var string
  64. */
  65. $post_default_title = '';
  66. /**
  67. * Filters the class used for handling XML-RPC requests.
  68. *
  69. * @since 3.1.0
  70. *
  71. * @param string $class The name of the XML-RPC server class.
  72. */
  73. $wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' );
  74. $wp_xmlrpc_server = new $wp_xmlrpc_server_class;
  75. // Fire off the request
  76. $wp_xmlrpc_server->serve_request();
  77. exit;
  78. /**
  79. * logIO() - Writes logging info to a file.
  80. *
  81. * @deprecated 3.4.0 Use error_log()
  82. * @see error_log()
  83. *
  84. * @param string $io Whether input or output
  85. * @param string $msg Information describing logging reason.
  86. */
  87. function logIO( $io, $msg ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
  88. _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
  89. if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) {
  90. error_log( $io . ' - ' . $msg );
  91. }
  92. }