Changeset 1768

Show
Ignore:
Timestamp:
10/10/04 18:02:30 (4 years ago)
Author:
saxmatt
Message:

Move to cookiehash define, use wp_login() function for auth.php.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/auth.php

    r1429 r1768  
    11<?php 
    2  
    32require_once('../wp-config.php'); 
    43 
    5 /* Checking login & pass in the database */ 
    6 function veriflog() { 
    7     global $cookiehash; 
    8     global $wpdb; 
    9  
    10     if (!empty($_COOKIE['wordpressuser_' . $cookiehash])) { 
    11         $user_login = $_COOKIE['wordpressuser_' . $cookiehash]; 
    12         $user_pass_md5 = $_COOKIE['wordpresspass_' . $cookiehash]; 
    13     } else { 
    14         return false; 
    15     } 
    16  
    17     if ('' == $user_login) 
    18         return false; 
    19     if (!$user_pass_md5) 
    20         return false; 
    21  
    22     $login = $wpdb->get_row("SELECT user_login, user_pass FROM $wpdb->users WHERE user_login = '$user_login'"); 
    23  
    24     if (!$login) { 
    25         return false; 
    26  
    27     } else { 
    28         if ($login->user_login == $user_login && md5($login->user_pass) == $user_pass_md5) { 
    29             return true; 
    30         } else { 
    31             return false; 
    32         } 
    33     } 
    34 
    35  
    36 if ( !veriflog() ) { 
     4if ( !empty($_COOKIE['wordpressuser_' . COOKIEHASH]) && !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH) ) { 
    375    header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); 
    386    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
    397    header('Cache-Control: no-cache, must-revalidate'); 
    408    header('Pragma: no-cache'); 
    41     if (!empty($_COOKIE['wordpressuser_' . $cookiehash])) { 
    42         $error= __("<strong>Error</strong>: wrong login or password."); 
    43     } 
    44     $redir = 'Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']); 
    45     header($redir); 
     9 
     10    header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']); 
    4611    exit(); 
    4712} 
  • trunk/wp-admin/link-manager.php

    r1599 r1768  
    7474} 
    7575 
    76 $links_show_cat_id = $_COOKIE['links_show_cat_id_' . $cookiehash]; 
    77 $links_show_order = $_COOKIE['links_show_order_' . $cookiehash]; 
     76$links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH]; 
     77$links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH]; 
    7878 
    7979if ('' != $_POST['assign']) $action = 'assign'; 
     
    270270      WHERE link_id=$link_id"); 
    271271    } // end if save 
    272     setcookie('links_show_cat_id_' . $cookiehash, $links_show_cat_id, time()+600); 
     272    setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); 
    273273    header('Location: ' . $this_file); 
    274274    break; 
     
    297297    } 
    298298    $links_show_cat_id = $cat_id; 
    299     setcookie("links_show_cat_id_".$cookiehash, $links_show_cat_id, time()+600); 
     299    setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); 
    300300    header('Location: '.$this_file); 
    301301    break; 
     
    568568    $links_show_order = $order_by; 
    569569 
    570     setcookie('links_show_cat_id_'.$cookiehash, $links_show_cat_id, time()+600); 
    571     setcookie('links_show_order_'.$cookiehash, $links_show_order, time()+600); 
     570    setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); 
     571    setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600); 
    572572    $standalone=0; 
    573573    include_once ("./admin-header.php"); 
  • trunk/wp-admin/profile.php

    r1599 r1768  
    8080        $newuser_pass = $_POST["pass1"]; 
    8181        $updatepassword = "user_pass=MD5('$newuser_pass'), "; 
    82         setcookie('wordpresspass_'.$cookiehash, " ", time() - 31536000, COOKIEPATH); 
    83         setcookie('wordpresspass_'.$cookiehash, md5(md5($newuser_pass)), time() + 31536000, COOKIEPATH); 
     82        setcookie('wordpresspass_' . COOKIEHASH, " ", time() - 31536000, COOKIEPATH); 
     83        setcookie('wordpresspass_' . COOKIEHASH, md5(md5($newuser_pass)), time() + 31536000, COOKIEPATH); 
    8484    } 
    8585 
  • trunk/wp-comments-popup.php

    r1763 r1768  
    3232<?php 
    3333// this line is WordPress' motor, do not delete it. 
    34 $comment_author = (isset($_COOKIE['comment_author_'.$cookiehash])) ? trim($_COOKIE['comment_author_'.$cookiehash]) : ''; 
    35 $comment_author_email = (isset($_COOKIE['comment_author_email_'.$cookiehash])) ? trim($_COOKIE['comment_author_email_'.$cookiehash]) : ''; 
    36 $comment_author_url = (isset($_COOKIE['comment_author_url_'.$cookiehash])) ? trim($_COOKIE['comment_author_url_'.$cookiehash]) : ''; 
     34$comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : ''; 
     35$comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : ''; 
     36$comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : ''; 
    3737$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date"); 
    3838$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id"); 
    39 if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'.$cookiehash] != $commentstatus->post_password) {  // and it doesn't match the cookie 
     39if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) {  // and it doesn't match the cookie 
    4040    echo(get_the_password_form()); 
    4141} else { ?> 
  • trunk/wp-comments.php

    r1607 r1768  
    1 <?php if ( !empty($post->post_password) && $_COOKIE['wp-postpass_'.$cookiehash] != $post->post_password) : ?> 
     1<?php if ( !empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) : ?> 
    22<p><?php _e('Enter your password to view comments.'); ?></p> 
    33<?php return; endif; ?> 
  • trunk/wp-includes/functions.php

    r1764 r1768  
    157157 
    158158function get_currentuserinfo() { // a bit like get_userdata(), on steroids 
    159     global $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5, $cookiehash
     159    global $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5
    160160    // *** retrieving user's data from cookies and db - no spoofing 
    161161 
    162     if (isset($_COOKIE['wordpressuser_' . $cookiehash]))  
    163         $user_login = $_COOKIE['wordpressuser_' . $cookiehash]; 
     162    if (isset($_COOKIE['wordpressuser_' . COOKIEHASH]))  
     163        $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH]; 
    164164    $userdata = get_userdatabylogin($user_login); 
    165165    $user_level = $userdata->user_level; 
     
    18911891} 
    18921892 
     1893function wp_login($username, $password, $already_md5 = false) { 
     1894    global $wpdb, $error; 
     1895 
     1896    if ( !$username ) 
     1897        return false; 
     1898 
     1899    if ( !$password ) { 
     1900        $error = __('<strong>Error</strong>: The password field is empty.'); 
     1901        return false; 
     1902    } 
     1903 
     1904    $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); 
     1905 
     1906    if (!$login) { 
     1907        $error = __('<strong>Error</strong>: Wrong login.'); 
     1908        return false; 
     1909    } else { 
     1910 
     1911        if ( ($login->user_login == $username && $login->user_pass == $password) || ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) ) { 
     1912            return true; 
     1913        } else { 
     1914            $error = __('<strong>Error</strong>: Incorrect password.'); 
     1915            $pwd = ''; 
     1916            return false; 
     1917        } 
     1918    } 
     1919} 
     1920 
    18931921?> 
  • trunk/wp-includes/template-functions-comment.php

    r1726 r1768  
    1818 
    1919function comments_template() { 
    20     global $withcomments, $post, $wpdb, $id, $comment, $cookiehash
     20    global $withcomments, $post, $wpdb, $id, $comment
    2121 
    2222    if ( is_single() || $withcomments ) : 
    2323        $req = get_settings('require_name_email'); 
    24         $comment_author = isset($_COOKIE['comment_author_'.$cookiehash]) ? trim(stripslashes($_COOKIE['comment_author_'.$cookiehash])) : ''; 
    25         $comment_author_email = isset($_COOKIE['comment_author_email_'.$cookiehash]) ? trim(stripslashes($_COOKIE['comment_author_email_'.$cookiehash])) : ''; 
    26         $comment_author_url = isset($_COOKIE['comment_author_url_'.$cookiehash]) ? trim(stripslashes($_COOKIE['comment_author_url_'.$cookiehash])) : ''; 
     24        $comment_author = isset($_COOKIE['comment_author_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_'.COOKIEHASH])) : ''; 
     25        $comment_author_email = isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH])) : ''; 
     26        $comment_author_url = isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH])) : ''; 
    2727        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date"); 
    2828 
     
    9191 
    9292function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { 
    93     global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $cookiehash
     93    global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb
    9494    global $querystring_start, $querystring_equal, $querystring_separator; 
    9595    global $comment_count_cache; 
     
    106106    } else { 
    107107        if (!empty($post->post_password)) { // if there's a password 
    108             if ($_COOKIE['wp-postpass_'.$cookiehash] != $post->post_password) {  // and it doesn't match the cookie 
     108            if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie 
    109109                echo('Enter your password to view comments'); 
    110110                return; 
  • trunk/wp-includes/template-functions-post.php

    r1766 r1768  
    9898function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { 
    9999    global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages; 
    100     global $preview, $cookiehash
     100    global $preview
    101101    global $pagenow; 
    102102    $output = ''; 
    103103 
    104104    if (!empty($post->post_password)) { // if there's a password 
    105         if (stripslashes($_COOKIE['wp-postpass_'.$cookiehash]) != $post->post_password) {  // and it doesn't match the cookie 
     105        if (stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {  // and it doesn't match the cookie 
    106106            $output = get_the_password_form(); 
    107107            return $output; 
     
    177177function get_the_excerpt($fakeit = true) { 
    178178    global $id, $post; 
    179     global $cookiehash; 
    180179    $output = ''; 
    181180    $output = $post->post_excerpt; 
    182181    if (!empty($post->post_password)) { // if there's a password 
    183         if ($_COOKIE['wp-postpass_'.$cookiehash] != $post->post_password) {  // and it doesn't match the cookie 
     182        if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie 
    184183            $output = __('There is no excerpt because this is a protected post.'); 
    185184            return $output; 
  • trunk/wp-login.php

    r1754 r1768  
    149149    } 
    150150 
    151     if ( !login($log, $pwd) ) { 
    152        header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); 
    153        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
    154        header('Cache-Control: no-cache, must-revalidate'); 
    155         header('Pragma: no-cache'); 
    156     } else
     151    header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); 
     152    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
     153    header('Cache-Control: no-cache, must-revalidate'); 
     154    header('Pragma: no-cache'); 
     155 
     156    if ( wp_login($log, $pwd) )
    157157        $user_login = $log; 
    158158        $user_pass = $pwd; 
     
    160160        setcookie('wordpresspass_'. COOKIEHASH, md5($user_pass), time() + 31536000, COOKIEPATH); 
    161161 
    162         header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); 
    163         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
    164         header('Cache-Control: no-cache, must-revalidate'); 
    165         header('Pragma: no-cache'); 
    166  
    167162        if ($is_IIS) 
    168163            header("Refresh: 0;url=$redirect_to"); 
     
    176171    } 
    177172 
    178     if ( login($user_login, $user_pass_md5, true) ) { 
     173    if ( wp_login($user_login, $user_pass_md5, true) ) { 
    179174        header('Expires: Wed, 5 Jun 1979 23:41:00 GMT'); // Michel's birthday 
    180175        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
  • trunk/wp-settings.php

    r1734 r1768  
    6969 
    7070    // Used to guarantee unique hash cookies 
    71     $cookiehash = md5(get_settings('siteurl')); 
     71    $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4 
    7272    define('COOKIEHASH', $cookiehash);  
    7373endif;