Ticket #7157: xmlrpc_disabled.diff

File xmlrpc_disabled.diff, 6.1 kB (added by ryan, 5 months ago)
  • xmlrpc.php

    old new  
    111111class wp_xmlrpc_server extends IXR_Server { 
    112112 
    113113        function wp_xmlrpc_server() { 
    114                 $xmlrpc_methods = array( 
     114                $this->methods = array( 
    115115                        // WordPress API 
    116116                        'wp.getUsersBlogs'              => 'this:wp_getUsersBlogs', 
    117117                        'wp.getPage'                    => 'this:wp_getPage', 
     
    167167                        'mt.supportedMethods' => 'this:mt_supportedMethods', 
    168168                        'mt.supportedTextFilters' => 'this:mt_supportedTextFilters', 
    169169                        'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', 
    170                         'mt.publishPost' => 'this:mt_publishPost' 
    171                 ); 
    172                  
    173                 $xmlrpc_functions = array ( 
     170                        'mt.publishPost' => 'this:mt_publishPost', 
     171 
    174172                        // PingBack 
    175173                        'pingback.ping' => 'this:pingback_ping', 
    176174                        'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', 
     
    179177                        'demo.addTwoNumbers' => 'this:addTwoNumbers' 
    180178                ); 
    181179 
    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                  
     180                $this->enabled = ( get_option('enable_xmlrpc') ) ? true : false; 
    189181                $this->initialise_blog_option_info( ); 
    190182                $this->methods = apply_filters('xmlrpc_methods', $this->methods); 
    191183                $this->IXR_Server($this->methods); 
     
    328320         * wp_getUsersBlogs 
    329321         */ 
    330322        function wp_getUsersBlogs( $args ) { 
     323                if ( ! $this->enabled ) 
     324                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     325 
    331326                // If this isn't on WPMU then just use blogger_getUsersBlogs 
    332327                if( !function_exists( 'is_site_admin' ) ) { 
    333328                        array_unshift( $args, 1 ); 
     
    375370         * wp_getPage 
    376371         */ 
    377372        function wp_getPage($args) { 
     373                if ( ! $this->enabled ) 
     374                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     375         
    378376                $this->escape($args); 
    379377 
    380378                $blog_id        = (int) $args[0]; 
     
    469467         * wp_getPages 
    470468         */ 
    471469        function wp_getPages($args) { 
     470                if ( ! $this->enabled ) 
     471                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     472 
    472473                $this->escape($args); 
    473474 
    474475                $blog_id        = (int) $args[0]; 
     
    513514         * wp_newPage 
    514515         */ 
    515516        function wp_newPage($args) { 
     517                if ( ! $this->enabled ) 
     518                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     519 
    516520                // Items not escaped here will be escaped in newPost. 
    517521                $username       = $this->escape($args[1]); 
    518522                $password       = $this->escape($args[2]); 
     
    544548         * wp_deletePage 
    545549         */ 
    546550        function wp_deletePage($args) { 
     551                if ( ! $this->enabled ) 
     552                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     553 
    547554                $this->escape($args); 
    548555 
    549556                $blog_id        = (int) $args[0]; 
     
    587594         * wp_editPage 
    588595         */ 
    589596        function wp_editPage($args) { 
     597                if ( ! $this->enabled ) 
     598                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     599 
    590600                // Items not escaped here will be escaped in editPost. 
    591601                $blog_id        = (int) $args[0]; 
    592602                $page_id        = (int) $this->escape($args[1]); 
     
    637647         * wp_getPageList 
    638648         */ 
    639649        function wp_getPageList($args) { 
     650                if ( ! $this->enabled ) 
     651                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     652 
    640653                global $wpdb; 
    641654 
    642655                $this->escape($args); 
     
    688701         * wp_getAuthors 
    689702         */ 
    690703        function wp_getAuthors($args) { 
     704                if ( ! $this->enabled ) 
     705                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
    691706 
    692707                $this->escape($args); 
    693708 
     
    723738         * wp_newCategory 
    724739         */ 
    725740        function wp_newCategory($args) { 
     741                if ( ! $this->enabled ) 
     742                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     743 
    726744                $this->escape($args); 
    727745 
    728746                $blog_id                                = (int) $args[0]; 
     
    779797         * wp_deleteCategory 
    780798         */ 
    781799        function wp_deleteCategory($args) { 
     800                if ( ! $this->enabled ) 
     801                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     802 
    782803                $this->escape($args); 
    783804 
    784805                $blog_id                = (int) $args[0]; 
     
    806827         * wp_suggestCategories 
    807828         */ 
    808829        function wp_suggestCategories($args) { 
     830                if ( ! $this->enabled ) 
     831                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     832 
    809833                $this->escape($args); 
    810834 
    811835                $blog_id                                = (int) $args[0]; 
     
    837861        } 
    838862 
    839863        function wp_getCommentCount( $args ) { 
     864                if ( ! $this->enabled ) 
     865                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     866 
    840867                $this->escape($args); 
    841868 
    842869                $blog_id        = (int) $args[0]; 
     
    866893 
    867894 
    868895        function wp_getPostStatusList( $args ) { 
     896                if ( ! $this->enabled ) 
     897                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     898 
    869899                $this->escape( $args ); 
    870900 
    871901                $blog_id        = (int) $args[0]; 
     
    888918 
    889919 
    890920        function wp_getPageStatusList( $args ) { 
     921                if ( ! $this->enabled ) 
     922                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     923 
    891924                $this->escape( $args ); 
    892925 
    893926                $blog_id        = (int) $args[0]; 
     
    909942        } 
    910943 
    911944        function wp_getPageTemplates( $args ) { 
     945                if ( ! $this->enabled ) 
     946                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     947 
    912948                $this->escape( $args ); 
    913949 
    914950                $blog_id        = (int) $args[0]; 
     
    931967        } 
    932968 
    933969        function wp_getOptions( $args ) { 
     970                if ( ! $this->enabled ) 
     971                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     972 
    934973                $this->escape( $args ); 
    935974 
    936975                $blog_id        = (int) $args[0]; 
     
    9701009        } 
    9711010 
    9721011        function wp_setOptions( $args ) { 
     1012                if ( ! $this->enabled ) 
     1013                        return new IXR_Error( 401, __( 'XML-RPC is not enabled for this blog. Enable it through Settings->Writing' ) ); 
     1014 
    9731015                $this->escape( $args ); 
    9741016 
    9751017                $blog_id        = (int) $args[0];