Changeset 1344 for trunk/xmlrpc.php

Show
Ignore:
Timestamp:
07/02/08 13:44:49 (5 months ago)
Author:
donncha
Message:

WP Merge to rev 8216

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/xmlrpc.php

    r1336 r1344  
    4040    <homePageLink><?php bloginfo_rss('url') ?></homePageLink> 
    4141    <apis> 
    42     <?php if ( get_option('enable_xmlrpc') ) :?> 
    4342      <api name="WordPress" blogID="1" preferred="true" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" /> 
    4443      <api name="Movable Type" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" /> 
    4544      <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" /> 
    4645      <api name="Blogger" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('wpurl') ?>/xmlrpc.php" /> 
    47     <?php endif; if ( get_option('enable_app') ) :?> 
    4846      <api name="Atom" blogID="" preferred="false" apiLink="<?php echo apply_filters('atom_service_url', (get_bloginfo('url')."/wp-app.php/service"))?>" /> 
    49     <?php endif; ?> 
    5047    </apis> 
    5148  </service> 
     
    112109 
    113110        function wp_xmlrpc_server() { 
    114                 $xmlrpc_methods = array( 
     111                $this->methods = array( 
    115112                        // WordPress API 
    116113                        'wp.getUsersBlogs'              => 'this:wp_getUsersBlogs', 
     
    168165                        'mt.supportedTextFilters' => 'this:mt_supportedTextFilters', 
    169166                        'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', 
    170                         'mt.publishPost' => 'this:mt_publishPost' 
    171                 ); 
    172                  
    173                 $xmlrpc_functions = array ( 
     167                        'mt.publishPost' => 'this:mt_publishPost', 
     168 
    174169                        // PingBack 
    175170                        'pingback.ping' => 'this:pingback_ping', 
     
    180175                ); 
    181176 
    182                 if ( get_option('enable_xmlrpc') ) 
    183                 { 
    184                         $this->methods = array_merge($xmlrpc_methods,$xmlrpc_functions); 
    185                 } else { 
    186                         $this->methods = $xmlrpc_functions; 
    187                 } 
    188                  
    189177                $this->initialise_blog_option_info( ); 
    190178                $this->methods = apply_filters('xmlrpc_methods', $this->methods); 
     
    203191 
    204192        function login_pass_ok($user_login, $user_pass) { 
     193                if ( !get_option( 'enable_xmlrpc' ) ) { 
     194                        $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') ) ); 
     195                        return false; 
     196                } 
     197 
    205198                if (!user_pass_ok($user_login, $user_pass)) { 
    206199                        $this->error = new IXR_Error(403, __('Bad login/pass combination.')); 
     
    846839 
    847840                if( !$this->login_pass_ok( $username, $password ) ) { 
    848                         return new IXR_Error( 403, __( 'Bad login/pass combination.' ) )
     841                        return $this->error
    849842                } 
    850843 
     
    874867 
    875868                if( !$this->login_pass_ok( $username, $password ) ) { 
    876                         return new IXR_Error( 403, __( 'Bad login/pass combination.' ) )
     869                        return $this->error
    877870                } 
    878871 
     
    896889 
    897890                if( !$this->login_pass_ok( $username, $password ) ) { 
    898                         return new IXR_Error( 403, __( 'Bad login/pass combination.' ) )
     891                        return $this->error
    899892                } 
    900893 
     
    917910 
    918911                if( !$this->login_pass_ok( $username, $password ) ) { 
    919                         return new IXR_Error( 403, __( 'Bad login/pass combination.' ) )
     912                        return $this->error
    920913                } 
    921914 
     
    940933 
    941934                if( !$this->login_pass_ok( $username, $password ) ) 
    942                         return new IXR_Error( 403, __( 'Bad login/pass combination.' ) )
     935                        return $this->error
    943936 
    944937                $user = set_current_user( 0, $username ); 
     
    979972 
    980973                if( !$this->login_pass_ok( $username, $password ) ) 
    981                         return new IXR_Error( 403, __( 'Bad login/pass combination.' ) )
     974                        return $this->error
    982975 
    983976                $user = set_current_user( 0, $username ); 
     
    10221015                do_action('xmlrpc_call', 'blogger.getUsersBlogs'); 
    10231016 
    1024                 $user = set_current_user(0, $user_login); 
    1025  
    1026                 $blogs = (array) get_blogs_of_user($user->ID); 
    1027  
    1028                 $struct = array(); 
    1029  
    1030                 foreach ( $blogs as $blog ) { 
    1031                         $blog_id = $blog->userblog_id; 
    1032  
    1033                         switch_to_blog($blog_id); 
    1034  
    1035                         $is_admin = current_user_can('level_8'); 
    1036  
    1037                         $struct[] = array( 
    1038                                 'isAdmin'  => $is_admin, 
    1039                                 'url'      => get_option('home') . '/', 
    1040                                 'blogid'   => $blog_id, 
    1041                                 'blogName' => get_option('blogname') 
    1042                         ); 
    1043  
    1044                         restore_current_blog(); 
    1045                 } 
    1046  
    1047                 return $struct; 
     1017                set_current_user(0, $user_login); 
     1018                $is_admin = current_user_can('manage_options'); 
     1019 
     1020                $struct = array( 
     1021                        'isAdmin'  => $is_admin, 
     1022                        'url'      => get_option('home') . '/', 
     1023                        'blogid'   => '1', 
     1024                        'blogName' => get_option('blogname'), 
     1025                        'xmlrpc'   => get_option('home') . '/xmlrpc.php', 
     1026                ); 
     1027 
     1028                return array($struct); 
    10481029        } 
    10491030