xmlrpc.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. // $HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed in PHP 7.0.
  16. // phpcs:disable PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.http_raw_post_dataDeprecatedRemoved
  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. // phpcs:enable
  25. /** Include the bootstrap for setting up WordPress environment */
  26. require_once __DIR__ . '/wp-load.php';
  27. if ( isset( $_GET['rsd'] ) ) { // http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html
  28. header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
  29. echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
  30. ?>
  31. <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
  32. <service>
  33. <engineName>WordPress</engineName>
  34. <engineLink>https://wordpress.org/</engineLink>
  35. <homePageLink><?php bloginfo_rss( 'url' ); ?></homePageLink>
  36. <apis>
  37. <api name="WordPress" blogID="1" preferred="true" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" />
  38. <api name="Movable Type" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" />
  39. <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" />
  40. <api name="Blogger" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" />
  41. <?php
  42. /**
  43. * Add additional APIs to the Really Simple Discovery (RSD) endpoint.
  44. *
  45. * @link http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html
  46. *
  47. * @since 3.5.0
  48. */
  49. do_action( 'xmlrpc_rsd_apis' );
  50. ?>
  51. </apis>
  52. </service>
  53. </rsd>
  54. <?php
  55. exit;
  56. }
  57. require_once ABSPATH . 'wp-admin/includes/admin.php';
  58. require_once ABSPATH . WPINC . '/class-IXR.php';
  59. require_once ABSPATH . WPINC . '/class-wp-xmlrpc-server.php';
  60. /**
  61. * Posts submitted via the XML-RPC interface get that title
  62. *
  63. * @name post_default_title
  64. * @var string
  65. */
  66. $post_default_title = '';
  67. /**
  68. * Filters the class used for handling XML-RPC requests.
  69. *
  70. * @since 3.1.0
  71. *
  72. * @param string $class The name of the XML-RPC server class.
  73. */
  74. $wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' );
  75. $wp_xmlrpc_server = new $wp_xmlrpc_server_class;
  76. // Fire off the request.
  77. $wp_xmlrpc_server->serve_request();
  78. exit;
  79. /**
  80. * logIO() - Writes logging info to a file.
  81. *
  82. * @deprecated 3.4.0 Use error_log()
  83. * @see error_log()
  84. *
  85. * @param string $io Whether input or output
  86. * @param string $msg Information describing logging reason.
  87. */
  88. function logIO( $io, $msg ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
  89. _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
  90. if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) {
  91. error_log( $io . ' - ' . $msg );
  92. }
  93. }