Make WordPress Core

Changeset 10456


Ignore:
Timestamp:
01/29/2009 12:25:24 AM (18 years ago)
Author:
ryan
Message:

Use user returned from auth for XML-RPC logins. Props wnorris. fixes #8941

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r10383 r10456  
    239239         * @param string $user_pass User's password.
    240240         * @return bool Whether authentication passed.
     241         * @deprecated use wp_xmlrpc_server::login
     242         * @see wp_xmlrpc_server::login
    241243         */
    242244        function login_pass_ok($user_login, $user_pass) {
     
    251253                }
    252254                return true;
     255        }
     256
     257        /**
     258         * Log user in.
     259         *
     260         * @since 2.8
     261         *
     262         * @param string $username User's username.
     263         * @param string $password User's password.
     264         * @return mixed WP_User object if authentication passed, false otherwise
     265         */
     266        function login($username, $password) {
     267                if ( !get_option( 'enable_xmlrpc' ) ) {
     268                        $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') ) );
     269                        return false;
     270                }
     271
     272                $user = wp_authenticate($username, $password);
     273
     274                if (is_wp_error($user)) {
     275                        $this->error = new IXR_Error(403, __('Bad login/pass combination.'));
     276                        return false;
     277                }
     278
     279                set_current_user( $user->ID );
     280                return $user;
    253281        }
    254282
     
    418446                $password = $args[1];
    419447
    420                 if( !$this->login_pass_ok( $username, $password ) )
    421                         return $this->error;
     448                if ( !$user = $this->login($username, $password) ) {
     449                        return $this->error;
     450                }
    422451
    423452                do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
    424 
    425                 $user = set_current_user( 0, $username );
    426453
    427454                $blogs = (array) get_blogs_of_user( $user->ID );
     
    467494                $password       = $args[3];
    468495
    469                 if(!$this->login_pass_ok($username, $password)) {
    470                         return($this->error);
    471                 }
    472 
    473                 set_current_user( 0, $username );
     496                if ( !$user = $this->login($username, $password) ) {
     497                        return $this->error;
     498                }
     499
    474500                if( !current_user_can( 'edit_page', $page_id ) )
    475501                        return new IXR_Error( 401, __( 'Sorry, you can not edit this page.' ) );
     
    565591                $num_pages      = (int) $args[3];
    566592
    567                 if(!$this->login_pass_ok($username, $password)) {
    568                         return($this->error);
    569                 }
    570 
    571                 set_current_user( 0, $username );
     593                if ( !$user = $this->login($username, $password) ) {
     594                        return $this->error;
     595                }
     596
    572597                if( !current_user_can( 'edit_pages' ) )
    573598                        return new IXR_Error( 401, __( 'Sorry, you can not edit pages.' ) );
     
    617642                $publish        = $args[4];
    618643
    619                 if(!$this->login_pass_ok($username, $password)) {
    620                         return($this->error);
     644                if ( !$user = $this->login($username, $password) ) {
     645                        return $this->error;
    621646                }
    622647
    623648                do_action('xmlrpc_call', 'wp.newPage');
    624649
    625                 // Set the user context and check if they are allowed
    626                 // to add new pages.
    627                 $user = set_current_user(0, $username);
     650                // Make sure the user is allowed to add new pages.
    628651                if(!current_user_can("publish_pages")) {
    629652                        return(new IXR_Error(401, __("Sorry, you can not add new pages.")));
     
    653676                $page_id        = (int) $args[3];
    654677
    655                 if(!$this->login_pass_ok($username, $password)) {
    656                         return($this->error);
     678                if ( !$user = $this->login($username, $password) ) {
     679                        return $this->error;
    657680                }
    658681
     
    669692                }
    670693
    671                 // Set the user context and make sure they can delete pages.
    672                 set_current_user(0, $username);
     694                // Make sure the user can delete pages.
    673695                if(!current_user_can("delete_page", $page_id)) {
    674696                        return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page.")));
     
    701723                $publish        = $args[5];
    702724
    703                 if(!$this->login_pass_ok($username, $password)) {
    704                         return($this->error);
     725                if ( !$user = $this->login($username, $password) ) {
     726                        return $this->error;
    705727                }
    706728
     
    716738                }
    717739
    718                 // Set the user context and make sure they are allowed to edit pages.
    719                 set_current_user(0, $username);
     740                // Make sure the user is allowed to edit pages.
    720741                if(!current_user_can("edit_page", $page_id)) {
    721742                        return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page.")));
     
    755776                $password                               = $args[2];
    756777
    757                 if(!$this->login_pass_ok($username, $password)) {
    758                         return($this->error);
    759                 }
    760 
    761                 set_current_user( 0, $username );
     778                if ( !$user = $this->login($username, $password) ) {
     779                        return $this->error;
     780                }
     781
    762782                if( !current_user_can( 'edit_pages' ) )
    763783                        return new IXR_Error( 401, __( 'Sorry, you can not edit pages.' ) );
     
    809829                $password       = $args[2];
    810830
    811                 if(!$this->login_pass_ok($username, $password)) {
    812                         return($this->error);
    813                 }
    814 
    815                 set_current_user(0, $username);
     831                if ( !$user = $this->login($username, $password) ) {
     832                        return $this->error;
     833                }
     834
    816835                if(!current_user_can("edit_posts")) {
    817836                        return(new IXR_Error(401, __("Sorry, you can not edit posts on this blog.")));
     
    847866                $password               = $args[2];
    848867
    849                 if( !$this->login_pass_ok( $username, $password ) ) {
    850                         return $this->error;
    851                 }
    852 
    853                 set_current_user( 0, $username );
     868                if ( !$user = $this->login($username, $password) ) {
     869                        return $this->error;
     870                }
     871
    854872                if( !current_user_can( 'edit_posts' ) ) {
    855873                        return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) );
     
    892910                $category                               = $args[3];
    893911
    894                 if(!$this->login_pass_ok($username, $password)) {
    895                         return($this->error);
     912                if ( !$user = $this->login($username, $password) ) {
     913                        return $this->error;
    896914                }
    897915
    898916                do_action('xmlrpc_call', 'wp.newCategory');
    899917
    900                 // Set the user context and make sure they are
    901                 // allowed to add a category.
    902                 set_current_user(0, $username);
     918                // Make sure the user is allowed to add a category.
    903919                if(!current_user_can("manage_categories")) {
    904920                        return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
     
    952968                $category_id    = (int) $args[3];
    953969
    954                 if( !$this->login_pass_ok( $username, $password ) ) {
     970                if ( !$user = $this->login($username, $password) ) {
    955971                        return $this->error;
    956972                }
     
    958974                do_action('xmlrpc_call', 'wp.deleteCategory');
    959975
    960                 set_current_user(0, $username);
    961976                if( !current_user_can("manage_categories") ) {
    962977                        return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) );
     
    983998                $max_results                    = (int) $args[4];
    984999
    985                 if(!$this->login_pass_ok($username, $password)) {
    986                         return($this->error);
    987                 }
    988 
    989                 set_current_user(0, $username);
     1000                if ( !$user = $this->login($username, $password) ) {
     1001                        return $this->error;
     1002                }
     1003
    9901004                if( !current_user_can( 'edit_posts' ) )
    9911005                        return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this blog in order to view categories.' ) );
     
    10211035                $comment_id     = (int) $args[3];
    10221036
    1023                 if ( !$this->login_pass_ok( $username, $password ) )
    1024                         return $this->error;
    1025 
    1026                 set_current_user( 0, $username );
     1037                if ( !$user = $this->login($username, $password) ) {
     1038                        return $this->error;
     1039                }
     1040
    10271041                if ( !current_user_can( 'moderate_comments' ) )
    10281042                        return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
     
    10841098                $struct         = $args[3];
    10851099
    1086                 if ( !$this->login_pass_ok($username, $password) )
    1087                         return($this->error);
    1088 
    1089                 set_current_user( 0, $username );
     1100                if ( !$user = $this->login($username, $password) ) {
     1101                        return $this->error;
     1102                }
     1103
    10901104                if ( !current_user_can( 'moderate_comments' ) )
    10911105                        return new IXR_Error( 401, __( 'Sorry, you can not edit comments.' ) );
     
    11441158                $comment_ID     = (int) $args[3];
    11451159
    1146                 if ( !$this->login_pass_ok( $username, $password ) )
    1147                         return $this->error;
    1148 
    1149                 set_current_user( 0, $username );
     1160                if ( !$user = $this->login($username, $password) ) {
     1161                        return $this->error;
     1162                }
     1163
    11501164                if ( !current_user_can( 'moderate_comments' ) )
    11511165                        return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
     
    11761190                $content_struct = $args[4];
    11771191
    1178                 if ( !$this->login_pass_ok( $username, $password ) )
    1179                         return $this->error;
    1180 
    1181                 set_current_user( 0, $username );
     1192                if ( !$user = $this->login($username, $password) ) {
     1193                        return $this->error;
     1194                }
     1195
    11821196                if ( !current_user_can( 'moderate_comments' ) )
    11831197                        return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
     
    12501264                $allow_anon = apply_filters('xmlrpc_allow_anonymous_comments', false);
    12511265
    1252                 if ( !$this->login_pass_ok( $username, $password ) ) {
     1266                $user = $this->login($username, $password);
     1267
     1268                if ( !$user ) {
    12531269                        $logged_in = false;
    12541270                        if ( $allow_anon && get_option('comment_registration') )
     
    12581274                } else {
    12591275                        $logged_in = true;
    1260                         set_current_user( 0, $username );
    12611276                }
    12621277
     
    12751290
    12761291                if ( $logged_in ) {
    1277                         $user = wp_get_current_user();
    12781292                        $comment['comment_author'] = $wpdb->escape( $user->display_name );
    12791293                        $comment['comment_author_email'] = $wpdb->escape( $user->user_email );
     
    13271341                $password       = $args[2];
    13281342
    1329                 if ( !$this->login_pass_ok( $username, $password ) )
    1330                         return $this->error;
    1331 
    1332                 set_current_user( 0, $username );
     1343                if ( !$user = $this->login($username, $password) ) {
     1344                        return $this->error;
     1345                }
     1346
    13331347                if ( !current_user_can( 'moderate_comments' ) )
    13341348                        return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
     
    13551369                $post_id        = (int) $args[3];
    13561370
    1357                 if( !$this->login_pass_ok( $username, $password ) ) {
    1358                         return $this->error;
    1359                 }
    1360 
    1361                 set_current_user( 0, $username );
     1371                if ( !$user = $this->login($username, $password) ) {
     1372                        return $this->error;
     1373                }
     1374
    13621375                if( !current_user_can( 'edit_posts' ) ) {
    13631376                        return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) );
     
    13901403                $password       = $args[2];
    13911404
    1392                 if( !$this->login_pass_ok( $username, $password ) ) {
    1393                         return $this->error;
    1394                 }
    1395 
    1396                 set_current_user( 0, $username );
     1405                if ( !$user = $this->login($username, $password) ) {
     1406                        return $this->error;
     1407                }
     1408
    13971409                if( !current_user_can( 'edit_posts' ) ) {
    13981410                        return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
     
    14191431                $password       = $args[2];
    14201432
    1421                 if( !$this->login_pass_ok( $username, $password ) ) {
    1422                         return $this->error;
    1423                 }
    1424 
    1425                 set_current_user( 0, $username );
     1433                if ( !$user = $this->login($username, $password) ) {
     1434                        return $this->error;
     1435                }
     1436
    14261437                if( !current_user_can( 'edit_posts' ) ) {
    14271438                        return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
     
    14481459                $password       = $args[2];
    14491460
    1450                 if( !$this->login_pass_ok( $username, $password ) ) {
    1451                         return $this->error;
    1452                 }
    1453 
    1454                 set_current_user( 0, $username );
     1461                if ( !$user = $this->login($username, $password) ) {
     1462                        return $this->error;
     1463                }
     1464
    14551465                if( !current_user_can( 'edit_pages' ) ) {
    14561466                        return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
     
    14791489                $options        = (array) $args[3];
    14801490
    1481                 if( !$this->login_pass_ok( $username, $password ) )
    1482                         return $this->error;
    1483 
    1484                 $user = set_current_user( 0, $username );
     1491                if ( !$user = $this->login($username, $password) ) {
     1492                        return $this->error;
     1493                }
    14851494
    14861495                // If no specific options where asked for, return all of them
     
    15341543                $options        = (array) $args[3];
    15351544
    1536                 if( !$this->login_pass_ok( $username, $password ) )
    1537                         return $this->error;
    1538 
    1539                 $user = set_current_user( 0, $username );
     1545                if ( !$user = $this->login($username, $password) ) {
     1546                        return $this->error;
     1547                }
     1548
    15401549                if( !current_user_can( 'manage_options' ) )
    15411550                        return new IXR_Error( 403, __( 'You are not allowed to update options.' ) );
     
    15771586                $this->escape($args);
    15781587
    1579                 $user_login = $args[1];
    1580                 $user_pass  = $args[2];
    1581 
    1582                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     1588                $username = $args[1];
     1589                $password  = $args[2];
     1590
     1591                if ( !$user = $this->login($username, $password) ) {
    15831592                        return $this->error;
    15841593                }
     
    15861595                do_action('xmlrpc_call', 'blogger.getUsersBlogs');
    15871596
    1588                 set_current_user(0, $user_login);
    15891597                $is_admin = current_user_can('manage_options');
    15901598
     
    16141622                $this->escape($args);
    16151623
    1616                 $user_login = $args[1];
    1617                 $user_pass  = $args[2];
    1618 
    1619                 if (!$this->login_pass_ok($user_login, $user_pass)) {
    1620                         return $this->error;
    1621                 }
    1622 
    1623                 set_current_user( 0, $user_login );
     1624                $username = $args[1];
     1625                $password  = $args[2];
     1626
     1627                if ( !$user = $this->login($username, $password) ) {
     1628                        return $this->error;
     1629                }
     1630
    16241631                if( !current_user_can( 'edit_posts' ) )
    16251632                        return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this blog.' ) );
     
    16271634                do_action('xmlrpc_call', 'blogger.getUserInfo');
    16281635
    1629                 $user_data = get_userdatabylogin($user_login);
    1630 
    16311636                $struct = array(
    1632                         'nickname'  => $user_data->nickname,
    1633                         'userid'    => $user_data->ID,
    1634                         'url'       => $user_data->user_url,
    1635                         'lastname'  => $user_data->last_name,
    1636                         'firstname' => $user_data->first_name
     1637                        'nickname'  => $user->nickname,
     1638                        'userid'    => $user->ID,
     1639                        'url'       => $user->user_url,
     1640                        'lastname'  => $user->last_name,
     1641                        'firstname' => $user->first_name
    16371642                );
    16381643
     
    16531658
    16541659                $post_ID    = (int) $args[1];
    1655                 $user_login = $args[2];
    1656                 $user_pass  = $args[3];
    1657 
    1658                 if (!$this->login_pass_ok($user_login, $user_pass)) {
    1659                         return $this->error;
    1660                 }
    1661 
    1662                 set_current_user( 0, $user_login );
     1660                $username = $args[2];
     1661                $password  = $args[3];
     1662
     1663                if ( !$user = $this->login($username, $password) ) {
     1664                        return $this->error;
     1665                }
     1666
    16631667                if( !current_user_can( 'edit_post', $post_ID ) )
    16641668                        return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
     
    16971701
    16981702                $blog_ID    = (int) $args[1]; /* though we don't use it yet */
    1699                 $user_login = $args[2];
    1700                 $user_pass  = $args[3];
     1703                $username = $args[2];
     1704                $password  = $args[3];
    17011705                $num_posts  = $args[4];
    17021706
    1703                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     1707                if ( !$user = $this->login($username, $password) ) {
    17041708                        return $this->error;
    17051709                }
     
    17081712
    17091713                $posts_list = wp_get_recent_posts($num_posts);
    1710 
    1711                 set_current_user( 0, $user_login );
    17121714
    17131715                if (!$posts_list) {
     
    17571759
    17581760                $blog_ID    = (int) $args[1];
    1759                 $user_login = $args[2];
    1760                 $user_pass  = $args[3];
     1761                $username = $args[2];
     1762                $password  = $args[3];
    17611763                $template   = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
    17621764
    1763                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     1765                if ( !$user = $this->login($username, $password) ) {
    17641766                        return $this->error;
    17651767                }
     
    17671769                do_action('xmlrpc_call', 'blogger.getTemplate');
    17681770
    1769                 set_current_user(0, $user_login);
    17701771                if ( !current_user_can('edit_themes') ) {
    17711772                        return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
     
    17991800
    18001801                $blog_ID    = (int) $args[1];
    1801                 $user_login = $args[2];
    1802                 $user_pass  = $args[3];
     1802                $username = $args[2];
     1803                $password  = $args[3];
    18031804                $content    = $args[4];
    18041805                $template   = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
    18051806
    1806                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     1807                if ( !$user = $this->login($username, $password) ) {
    18071808                        return $this->error;
    18081809                }
     
    18101811                do_action('xmlrpc_call', 'blogger.setTemplate');
    18111812
    1812                 set_current_user(0, $user_login);
    18131813                if ( !current_user_can('edit_themes') ) {
    18141814                        return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
     
    18421842
    18431843                $blog_ID    = (int) $args[1]; /* though we don't use it yet */
    1844                 $user_login = $args[2];
    1845                 $user_pass  = $args[3];
     1844                $username = $args[2];
     1845                $password  = $args[3];
    18461846                $content    = $args[4];
    18471847                $publish    = $args[5];
    18481848
    1849                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     1849                if ( !$user = $this->login($username, $password) ) {
    18501850                        return $this->error;
    18511851                }
     
    18541854
    18551855                $cap = ($publish) ? 'publish_posts' : 'edit_posts';
    1856                 $user = set_current_user(0, $user_login);
    18571856                if ( !current_user_can($cap) )
    18581857                        return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.'));
     
    18981897
    18991898                $post_ID     = (int) $args[1];
    1900                 $user_login  = $args[2];
    1901                 $user_pass   = $args[3];
     1899                $username  = $args[2];
     1900                $password   = $args[3];
    19021901                $content     = $args[4];
    19031902                $publish     = $args[5];
    19041903
    1905                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     1904                if ( !$user = $this->login($username, $password) ) {
    19061905                        return $this->error;
    19071906                }
     
    19171916                $this->escape($actual_post);
    19181917
    1919                 set_current_user(0, $user_login);
    19201918                if ( !current_user_can('edit_post', $post_ID) )
    19211919                        return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));
     
    19541952
    19551953                $post_ID     = (int) $args[1];
    1956                 $user_login  = $args[2];
    1957                 $user_pass   = $args[3];
     1954                $username  = $args[2];
     1955                $password   = $args[3];
    19581956                $publish     = $args[4];
    19591957
    1960                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     1958                if ( !$user = $this->login($username, $password) ) {
    19611959                        return $this->error;
    19621960                }
     
    19701968                }
    19711969
    1972                 set_current_user(0, $user_login);
    19731970                if ( !current_user_can('edit_post', $post_ID) )
    19741971                        return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.'));
     
    19991996
    20001997                $blog_ID     = (int) $args[0]; // we will support this in the near future
    2001                 $user_login  = $args[1];
    2002                 $user_pass   = $args[2];
     1998                $username  = $args[1];
     1999                $password   = $args[2];
    20032000                $content_struct = $args[3];
    20042001                $publish     = $args[4];
    20052002
    2006                 if (!$this->login_pass_ok($user_login, $user_pass)) {
    2007                         return $this->error;
    2008                 }
    2009                 $user = set_current_user(0, $user_login);
     2003                if ( !$user = $this->login($username, $password) ) {
     2004                        return $this->error;
     2005                }
    20102006
    20112007                do_action('xmlrpc_call', 'metaWeblog.newPost');
     
    22972293
    22982294                $post_ID     = (int) $args[0];
    2299                 $user_login  = $args[1];
    2300                 $user_pass   = $args[2];
     2295                $username  = $args[1];
     2296                $password   = $args[2];
    23012297                $content_struct = $args[3];
    23022298                $publish     = $args[4];
    23032299
    2304                 if (!$this->login_pass_ok($user_login, $user_pass)) {
    2305                         return $this->error;
    2306                 }
    2307                 $user = set_current_user(0, $user_login);
     2300                if ( !$user = $this->login($username, $password) ) {
     2301                        return $this->error;
     2302                }
    23082303
    23092304                do_action('xmlrpc_call', 'metaWeblog.editPost');
     
    25622557
    25632558                $post_ID     = (int) $args[0];
    2564                 $user_login  = $args[1];
    2565                 $user_pass   = $args[2];
    2566 
    2567                 if (!$this->login_pass_ok($user_login, $user_pass)) {
    2568                         return $this->error;
    2569                 }
    2570 
    2571                 set_current_user( 0, $user_login );
     2559                $username  = $args[1];
     2560                $password   = $args[2];
     2561
     2562                if ( !$user = $this->login($username, $password) ) {
     2563                        return $this->error;
     2564                }
     2565
    25722566                if( !current_user_can( 'edit_post', $post_ID ) )
    25732567                        return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
     
    26742668
    26752669                $blog_ID     = (int) $args[0];
    2676                 $user_login  = $args[1];
    2677                 $user_pass   = $args[2];
     2670                $username  = $args[1];
     2671                $password   = $args[2];
    26782672                $num_posts   = (int) $args[3];
    26792673
    2680                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     2674                if ( !$user = $this->login($username, $password) ) {
    26812675                        return $this->error;
    26822676                }
     
    26892683                        return array( );
    26902684                }
    2691 
    2692                 set_current_user( 0, $user_login );
    26932685
    26942686                foreach ($posts_list as $entry) {
     
    27782770
    27792771                $blog_ID     = (int) $args[0];
    2780                 $user_login  = $args[1];
    2781                 $user_pass   = $args[2];
    2782 
    2783                 if (!$this->login_pass_ok($user_login, $user_pass)) {
    2784                         return $this->error;
    2785                 }
    2786 
    2787                 set_current_user( 0, $user_login );
     2772                $username  = $args[1];
     2773                $password   = $args[2];
     2774
     2775                if ( !$user = $this->login($username, $password) ) {
     2776                        return $this->error;
     2777                }
     2778
    27882779                if( !current_user_can( 'edit_posts' ) )
    27892780                        return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) );
     
    28262817
    28272818                $blog_ID     = (int) $args[0];
    2828                 $user_login  = $wpdb->escape($args[1]);
    2829                 $user_pass   = $wpdb->escape($args[2]);
     2819                $username  = $wpdb->escape($args[1]);
     2820                $password   = $wpdb->escape($args[2]);
    28302821                $data        = $args[3];
    28312822
     
    28362827                logIO('O', '(MW) Received '.strlen($bits).' bytes');
    28372828
    2838                 if ( !$this->login_pass_ok($user_login, $user_pass) )
    2839                         return $this->error;
     2829                if ( !$user = $this->login($username, $password) ) {
     2830                        return $this->error;
     2831                }
    28402832
    28412833                do_action('xmlrpc_call', 'metaWeblog.newMediaObject');
    28422834
    2843                 set_current_user(0, $user_login);
    28442835                if ( !current_user_can('upload_files') ) {
    28452836                        logIO('O', '(MW) User does not have upload_files capability');
     
    29112902
    29122903                $blog_ID     = (int) $args[0];
    2913                 $user_login  = $args[1];
    2914                 $user_pass   = $args[2];
     2904                $username  = $args[1];
     2905                $password   = $args[2];
    29152906                $num_posts   = (int) $args[3];
    29162907
    2917                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     2908                if ( !$user = $this->login($username, $password) ) {
    29182909                        return $this->error;
    29192910                }
     
    29272918                        return $this->error;
    29282919                }
    2929 
    2930                 set_current_user( 0, $user_login );
    29312920
    29322921                foreach ($posts_list as $entry) {
     
    29682957
    29692958                $blog_ID     = (int) $args[0];
    2970                 $user_login  = $args[1];
    2971                 $user_pass   = $args[2];
    2972 
    2973                 if (!$this->login_pass_ok($user_login, $user_pass)) {
    2974                         return $this->error;
    2975                 }
    2976 
    2977                 set_current_user( 0, $user_login );
     2959                $username  = $args[1];
     2960                $password   = $args[2];
     2961
     2962                if ( !$user = $this->login($username, $password) ) {
     2963                        return $this->error;
     2964                }
     2965
    29782966                if( !current_user_can( 'edit_posts' ) )
    29792967                        return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) );
     
    30082996
    30092997                $post_ID     = (int) $args[0];
    3010                 $user_login  = $args[1];
    3011                 $user_pass   = $args[2];
    3012 
    3013                 if (!$this->login_pass_ok($user_login, $user_pass)) {
    3014                         return $this->error;
    3015                 }
    3016 
    3017                 set_current_user( 0, $user_login );
     2998                $username  = $args[1];
     2999                $password   = $args[2];
     3000
     3001                if ( !$user = $this->login($username, $password) ) {
     3002                        return $this->error;
     3003                }
     3004
    30183005                if( !current_user_can( 'edit_post', $post_ID ) )
    30193006                        return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
     
    30503037
    30513038                $post_ID     = (int) $args[0];
    3052                 $user_login  = $args[1];
    3053                 $user_pass   = $args[2];
     3039                $username  = $args[1];
     3040                $password   = $args[2];
    30543041                $categories  = $args[3];
    30553042
    3056                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     3043                if ( !$user = $this->login($username, $password) ) {
    30573044                        return $this->error;
    30583045                }
     
    30603047                do_action('xmlrpc_call', 'mt.setPostCategories');
    30613048
    3062                 set_current_user(0, $user_login);
    30633049                if ( !current_user_can('edit_post', $post_ID) )
    30643050                        return new IXR_Error(401, __('Sorry, you can not edit this post.'));
     
    31623148
    31633149                $post_ID     = (int) $args[0];
    3164                 $user_login  = $args[1];
    3165                 $user_pass   = $args[2];
    3166 
    3167                 if (!$this->login_pass_ok($user_login, $user_pass)) {
     3150                $username  = $args[1];
     3151                $password   = $args[2];
     3152
     3153                if ( !$user = $this->login($username, $password) ) {
    31683154                        return $this->error;
    31693155                }
     
    31713157                do_action('xmlrpc_call', 'mt.publishPost');
    31723158
    3173                 set_current_user(0, $user_login);
    31743159                if ( !current_user_can('edit_post', $post_ID) )
    31753160                        return new IXR_Error(401, __('Sorry, you can not edit this post.'));
Note: See TracChangeset for help on using the changeset viewer.