Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/wp-app.php

    r8267 r8399  
    207207                // authenticate regardless of the operation and set the current
    208208                // user. each handler will decide if auth is required or not.
    209                 $this->authenticate();
    210                 $u = wp_get_current_user();
    211                 if(!isset($u) || $u->ID == 0) {
     209                if(!$this->authenticate()) {
    212210                    if ($always_authenticate) {
    213211                        $this->auth_required('Credentials required.');
     
    395393
    396394        $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true;
     395        $post_status = ($publish) ? 'publish' : 'draft';
    397396
    398397        extract($entry);
     
    407406        $post_modified = $pubtimes[0];
    408407        $post_modified_gmt = $pubtimes[1];
    409 
    410         // let's not go backwards and make something draft again.
    411         if(!$publish && $post_status == 'draft') {
    412             $post_status = ($publish) ? 'publish' : 'draft';
    413         } elseif($publish) {
    414             $post_status = 'publish';
    415         }
    416408
    417409        $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt');
     
    10711063     */
    10721064    function authenticate() {
    1073         $login_data = array();
    1074         $already_md5 = false;
    1075 
    10761065        log_app("authenticate()",print_r($_ENV, true));
    10771066
     
    10851074        // If Basic Auth is working...
    10861075        if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
    1087             $login_data = array('login' => $_SERVER['PHP_AUTH_USER'],   'password' => $_SERVER['PHP_AUTH_PW']);
    1088             log_app("Basic Auth",$login_data['login']);
    1089         } else {
    1090             // else, do cookie-based authentication
    1091             if (function_exists('wp_get_cookie_login')) {
    1092                 $login_data = wp_get_cookie_login();
    1093                 $already_md5 = true;
     1076            log_app("Basic Auth",$_SERVER['PHP_AUTH_USER']);
     1077            $user = wp_authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
     1078            if ( $user && !is_wp_error($user) ) {
     1079                wp_set_current_user($user->ID);
     1080                log_app("authenticate()", $_SERVER['PHP_AUTH_USER']);
     1081                return true;
    10941082            }
    10951083        }
    10961084
    1097         // call wp_login and set current user
    1098         if (!empty($login_data) && wp_login($login_data['login'], $login_data['password'], $already_md5)) {
    1099              $current_user = new WP_User(0, $login_data['login']);
    1100              wp_set_current_user($current_user->ID);
    1101             log_app("authenticate()",$login_data['login']);
    1102         }
     1085        return false;
    11031086    }
    11041087
Note: See TracChangeset for help on using the changeset viewer.