xmlrpc.php 3.0 KB

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