Ticket #7157: xmlrpc.php.diff

File xmlrpc.php.diff, 4.1 KB (added by josephscott, 4 years ago)
  • xmlrpc.php

     
    3939    <engineLink>http://wordpress.org/</engineLink> 
    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> 
    5249</rsd> 
     
    111108class wp_xmlrpc_server extends IXR_Server { 
    112109 
    113110        function wp_xmlrpc_server() { 
    114                 $xmlrpc_methods = array( 
     111                $this->methods = array( 
    115112                        // WordPress API 
    116113                        'wp.getUsersBlogs'              => 'this:wp_getUsersBlogs', 
    117114                        'wp.getPage'                    => 'this:wp_getPage', 
     
    167164                        'mt.supportedMethods' => 'this:mt_supportedMethods', 
    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', 
    176171                        'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', 
     
    179174                        'demo.addTwoNumbers' => 'this:addTwoNumbers' 
    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); 
    191179                $this->IXR_Server($this->methods); 
     
    202190        } 
    203191 
    204192        function login_pass_ok($user_login, $user_pass) { 
     193                if( !get_option( 'enable_xmlrpc' ) ) { 
     194                        $this->error = new IXR_Error( 405, __( 'XML-RPC servies are disabled on this blog.  An admin user can enable them at ' . get_bloginfo( 'wpurl' ) . '/wp-admin/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.')); 
    207200                        return false; 
     
    845838                $post_id        = (int) $args[3]; 
    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 
    851844                set_current_user( 0, $username ); 
     
    873866                $password       = $args[2]; 
    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 
    879872                set_current_user( 0, $username ); 
     
    895888                $password       = $args[2]; 
    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 
    901894                set_current_user( 0, $username ); 
     
    916909                $password       = $args[2]; 
    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 
    922915                set_current_user( 0, $username ); 
     
    939932                $options        = (array) $args[3]; 
    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 ); 
    945938 
     
    978971                $options        = (array) $args[3]; 
    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 ); 
    984977                if( !current_user_can( 'manage_options' ) )