summaryrefslogtreecommitdiffstats
path: root/xmlrpc.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-07-02 13:44:49 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-07-02 13:44:49 +0000
commit6d572cbe19ffedb5b92d8528798c5683154bb185 (patch)
tree4cc943e8f399addf1a10c03386342110bcc9d584 /xmlrpc.php
parent034c1b3b665fa28816dfc6157d610c6d25fd54fe (diff)
downloadwordpress-mu-6d572cbe19ffedb5b92d8528798c5683154bb185.tar.gz
wordpress-mu-6d572cbe19ffedb5b92d8528798c5683154bb185.tar.xz
wordpress-mu-6d572cbe19ffedb5b92d8528798c5683154bb185.zip
WP Merge to rev 8216
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1344 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'xmlrpc.php')
-rw-r--r--xmlrpc.php67
1 files changed, 24 insertions, 43 deletions
diff --git a/xmlrpc.php b/xmlrpc.php
index 808e8d4..a9da86c 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -39,14 +39,11 @@ header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
<engineLink>http://wordpress.org/</engineLink>
<homePageLink><?php bloginfo_rss('url') ?></homePageLink>
<apis>
- <?php if ( get_option('enable_xmlrpc') ) :?>
<api name="WordPress" blogID="1" preferred="true" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" />
<api name="Movable Type" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" />
<api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" />
<api name="Blogger" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" />
- <?php endif; if ( get_option('enable_app') ) :?>
<api name="Atom" blogID="" preferred="false" apiLink="<?php echo apply_filters('atom_service_url', (get_bloginfo('url')."/wp-app.php/service"))?>" />
- <?php endif; ?>
</apis>
</service>
</rsd>
@@ -111,7 +108,7 @@ if ( isset($HTTP_RAW_POST_DATA) )
class wp_xmlrpc_server extends IXR_Server {
function wp_xmlrpc_server() {
- $xmlrpc_methods = array(
+ $this->methods = array(
// WordPress API
'wp.getUsersBlogs' => 'this:wp_getUsersBlogs',
'wp.getPage' => 'this:wp_getPage',
@@ -167,10 +164,8 @@ class wp_xmlrpc_server extends IXR_Server {
'mt.supportedMethods' => 'this:mt_supportedMethods',
'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
- 'mt.publishPost' => 'this:mt_publishPost'
- );
-
- $xmlrpc_functions = array (
+ 'mt.publishPost' => 'this:mt_publishPost',
+
// PingBack
'pingback.ping' => 'this:pingback_ping',
'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
@@ -179,13 +174,6 @@ class wp_xmlrpc_server extends IXR_Server {
'demo.addTwoNumbers' => 'this:addTwoNumbers'
);
- if ( get_option('enable_xmlrpc') )
- {
- $this->methods = array_merge($xmlrpc_methods,$xmlrpc_functions);
- } else {
- $this->methods = $xmlrpc_functions;
- }
-
$this->initialise_blog_option_info( );
$this->methods = apply_filters('xmlrpc_methods', $this->methods);
$this->IXR_Server($this->methods);
@@ -202,6 +190,11 @@ class wp_xmlrpc_server extends IXR_Server {
}
function login_pass_ok($user_login, $user_pass) {
+ if ( !get_option( 'enable_xmlrpc' ) ) {
+ $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
+ return false;
+ }
+
if (!user_pass_ok($user_login, $user_pass)) {
$this->error = new IXR_Error(403, __('Bad login/pass combination.'));
return false;
@@ -845,7 +838,7 @@ class wp_xmlrpc_server extends IXR_Server {
$post_id = (int) $args[3];
if( !$this->login_pass_ok( $username, $password ) ) {
- return new IXR_Error( 403, __( 'Bad login/pass combination.' ) );
+ return $this->error;
}
set_current_user( 0, $username );
@@ -873,7 +866,7 @@ class wp_xmlrpc_server extends IXR_Server {
$password = $args[2];
if( !$this->login_pass_ok( $username, $password ) ) {
- return new IXR_Error( 403, __( 'Bad login/pass combination.' ) );
+ return $this->error;
}
set_current_user( 0, $username );
@@ -895,7 +888,7 @@ class wp_xmlrpc_server extends IXR_Server {
$password = $args[2];
if( !$this->login_pass_ok( $username, $password ) ) {
- return new IXR_Error( 403, __( 'Bad login/pass combination.' ) );
+ return $this->error;
}
set_current_user( 0, $username );
@@ -916,7 +909,7 @@ class wp_xmlrpc_server extends IXR_Server {
$password = $args[2];
if( !$this->login_pass_ok( $username, $password ) ) {
- return new IXR_Error( 403, __( 'Bad login/pass combination.' ) );
+ return $this->error;
}
set_current_user( 0, $username );
@@ -939,7 +932,7 @@ class wp_xmlrpc_server extends IXR_Server {
$options = (array) $args[3];
if( !$this->login_pass_ok( $username, $password ) )
- return new IXR_Error( 403, __( 'Bad login/pass combination.' ) );
+ return $this->error;
$user = set_current_user( 0, $username );
@@ -978,7 +971,7 @@ class wp_xmlrpc_server extends IXR_Server {
$options = (array) $args[3];
if( !$this->login_pass_ok( $username, $password ) )
- return new IXR_Error( 403, __( 'Bad login/pass combination.' ) );
+ return $this->error;
$user = set_current_user( 0, $username );
if( !current_user_can( 'manage_options' ) )
@@ -1021,30 +1014,18 @@ class wp_xmlrpc_server extends IXR_Server {
do_action('xmlrpc_call', 'blogger.getUsersBlogs');
- $user = set_current_user(0, $user_login);
-
- $blogs = (array) get_blogs_of_user($user->ID);
-
- $struct = array();
-
- foreach ( $blogs as $blog ) {
- $blog_id = $blog->userblog_id;
-
- switch_to_blog($blog_id);
-
- $is_admin = current_user_can('level_8');
-
- $struct[] = array(
- 'isAdmin' => $is_admin,
- 'url' => get_option('home') . '/',
- 'blogid' => $blog_id,
- 'blogName' => get_option('blogname')
- );
+ set_current_user(0, $user_login);
+ $is_admin = current_user_can('manage_options');
- restore_current_blog();
- }
+ $struct = array(
+ 'isAdmin' => $is_admin,
+ 'url' => get_option('home') . '/',
+ 'blogid' => '1',
+ 'blogName' => get_option('blogname'),
+ 'xmlrpc' => get_option('home') . '/xmlrpc.php',
+ );
- return $struct;
+ return array($struct);
}