Changeset 458

Show
Ignore:
Timestamp:
10/20/03 20:53:13 (5 years ago)
Author:
emc3
Message:

Cookies are now unique, based on siteurl, allowing multiple installs under a single domain name.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/b2-include/b2functions.php

    r456 r458  
    381381 
    382382function get_currentuserinfo() { // a bit like get_userdata(), on steroids 
    383     global $HTTP_COOKIE_VARS, $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5
     383    global $HTTP_COOKIE_VARS, $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5, $cookiehash
    384384    // *** retrieving user's data from cookies and db - no spoofing 
    385     $user_login = $HTTP_COOKIE_VARS['wordpressuser']; 
     385    $user_login = $HTTP_COOKIE_VARS['wordpressuser_'.$cookiehash]; 
    386386    $userdata = get_userdatabylogin($user_login); 
    387387    $user_level = $userdata->user_level; 
  • trunk/b2-include/b2template.functions.php

    r440 r458  
    599599function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') { 
    600600    global $id, $post, $more, $c, $withcomments, $page, $pages, $multipage, $numpages; 
    601     global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview
     601    global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash
    602602    global $querystring_start, $querystring_equal, $querystring_separator; 
    603603    global $pagenow; 
     
    605605     
    606606    if (!empty($post->post_password)) { // if there's a password 
    607         if ($HTTP_COOKIE_VARS['wp-postpass'] != $post->post_password) {  // and it doesn't match the cookie 
     607        if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) {  // and it doesn't match the cookie 
    608608            $output = get_the_password_form(); 
    609609            return $output; 
     
    693693function get_the_excerpt($fakeit = false) { 
    694694    global $id, $post; 
    695     global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview
     695    global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview, $cookiehash
    696696    $output = ''; 
    697697    $output = stripslashes($post->post_excerpt); 
    698698    if (!empty($post->post_password)) { // if there's a password 
    699         if ($HTTP_COOKIE_VARS['wp-postpass'] != $post->post_password) {  // and it doesn't match the cookie 
     699        if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) {  // and it doesn't match the cookie 
    700700            $output = "There is no excerpt because this is a protected post."; 
    701701            return $output; 
     
    11741174 
    11751175function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { 
    1176     global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS
     1176    global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash
    11771177    global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; 
    11781178    $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id"); 
     
    11821182    } else { 
    11831183        if (!empty($post->post_password)) { // if there's a password 
    1184             if ($HTTP_COOKIE_VARS['wp-postpass'] != $post->post_password) {  // and it doesn't match the cookie 
     1184            if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) {  // and it doesn't match the cookie 
    11851185                echo("Enter your password to view comments"); 
    11861186                return; 
  • trunk/b2comments.php

    r457 r458  
    55 
    66        if (!empty($post->post_password)) { // if there's a password 
    7             if ($HTTP_COOKIE_VARS['wp-postpass'] != $post->post_password) {  // and it doesn't match the cookie 
     7            if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) {  // and it doesn't match the cookie 
    88                echo("<p>Enter your password to view comments.<p>"); 
    99                return; 
     
    1111        } 
    1212 
    13         $comment_author = trim($HTTP_COOKIE_VARS["comment_author"]); 
    14         $comment_author_email = trim($HTTP_COOKIE_VARS["comment_author_email"]); 
    15         $comment_author_url = trim($HTTP_COOKIE_VARS["comment_author_url"]); 
     13        $comment_author = trim($HTTP_COOKIE_VARS["comment_author_".$cookiehash]); 
     14        $comment_author_email = trim($HTTP_COOKIE_VARS["comment_author_email_".$cookiehash]); 
     15        $comment_author_url = trim($HTTP_COOKIE_VARS["comment_author_url_".$cookiehash]); 
    1616 
    1717    $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date"); 
  • trunk/b2comments.post.php

    r407 r458  
    119119        $url = ' '; // this to make sure a cookie is set for 'no url' 
    120120 
    121     setcookie('comment_author', $author, time()+30000000); 
    122     setcookie('comment_author_email', $email, time()+30000000); 
    123     setcookie('comment_author_url', $url, time()+30000000); 
     121    setcookie('comment_author_'.$cookiehash, $author, time()+30000000); 
     122    setcookie('comment_author_email_'.$cookiehash, $email, time()+30000000); 
     123    setcookie('comment_author_url_'.$cookiehash, $url, time()+30000000); 
    124124 
    125125    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
  • trunk/b2commentspopup.php

    r457 r458  
    3232$comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date"); 
    3333$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $tableposts WHERE ID = $id"); 
    34 if (!empty($commentstatus->post_password) && $HTTP_COOKIE_VARS['wp-postpass'] != $commentstatus->post_password) {  // and it doesn't match the cookie 
     34if (!empty($commentstatus->post_password) && $HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $commentstatus->post_password) {  // and it doesn't match the cookie 
    3535    echo("<li>".get_the_password_form()."</li></ol>"); 
    3636} 
  • trunk/b2login.php

    r397 r458  
    4545case 'logout': 
    4646 
    47     setcookie('wordpressuser'); 
    48     setcookie('wordpresspass'); 
     47    setcookie('wordpressuser_'.$cookiehash); 
     48    setcookie('wordpresspass_'.$cookiehash); 
    4949    header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); 
    5050    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
     
    123123        $user_login = $log; 
    124124        $user_pass = $pwd; 
    125         setcookie('wordpressuser', $user_login, time()+31536000); 
     125        setcookie('wordpressuser_'.$cookiehash, $user_login, time()+31536000); 
    126126        if ($pass_is_md5) { 
    127             setcookie('wordpresspass', $user_pass, time()+31536000); 
    128         } else { 
    129             setcookie('wordpresspass', md5($user_pass), time()+31536000); 
    130         } 
    131         if (empty($HTTP_COOKIE_VARS['wordpressblogid'])) { 
    132             setcookie('wordpressblogid', 1,time()+31536000); 
     127            setcookie('wordpresspass_'.$cookiehash, $user_pass, time()+31536000); 
     128        } else { 
     129            setcookie('wordpresspass_'.$cookiehash, md5($user_pass), time()+31536000); 
     130        } 
     131        if (empty($HTTP_COOKIE_VARS['wordpressblogid_'.$cookiehash])) { 
     132            setcookie('wordpressblogid_'.$cookiehash, 1,time()+31536000); 
    133133        } 
    134134        header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); 
     
    232232default: 
    233233 
    234     if((!empty($HTTP_COOKIE_VARS['wordpressuser'])) && (!empty($HTTP_COOKIE_VARS['wordpresspass']))) { 
    235         $user_login = $HTTP_COOKIE_VARS['wordpressuser']; 
    236         $user_pass_md5 = $HTTP_COOKIE_VARS['wordpresspass']; 
     234    if((!empty($HTTP_COOKIE_VARS['wordpressuser_'.$cookiehash])) && (!empty($HTTP_COOKIE_VARS['wordpresspass_'.$cookiehash]))) { 
     235        $user_login = $HTTP_COOKIE_VARS['wordpressuser_'.$cookiehash]; 
     236        $user_pass_md5 = $HTTP_COOKIE_VARS['wordpresspass_'.$cookiehash]; 
    237237    } 
    238238 
     
    250250 
    251251    if ( !(checklogin()) ) { 
    252         if (!empty($HTTP_COOKIE_VARS['wordpressuser'])) { 
     252        if (!empty($HTTP_COOKIE_VARS['wordpressuser_'.$cookiehash])) { 
    253253            $error="Error: wrong login/password"; //, or your session has expired."; 
    254254        } 
  • trunk/wp-admin/b2profile.php

    r282 r458  
    8080        $newuser_pass = $HTTP_POST_VARS["pass1"]; 
    8181        $updatepassword = "user_pass='$newuser_pass', "; 
    82         setcookie("wordpresspass",md5($newuser_pass),time()+31536000); 
     82        setcookie("wordpresspass_".$cookiehash,md5($newuser_pass),time()+31536000); 
    8383    } 
    8484 
     
    116116 
    117117    $profiledata = get_userdata($user); 
    118     if ($HTTP_COOKIE_VARS['wordpressuser'] == $profiledata->user_login) 
     118    if ($HTTP_COOKIE_VARS['wordpressuser_'.$cookiehash] == $profiledata->user_login) 
    119119        header ('Location: b2profile.php'); 
    120120     
  • trunk/wp-admin/b2verifauth.php

    r221 r458  
    55/* checking login & pass in the database */ 
    66function veriflog() { 
    7     global $HTTP_COOKIE_VARS
     7    global $HTTP_COOKIE_VARS,$cookiehash
    88    global $tableusers, $wpdb; 
    99 
    10     if (!empty($HTTP_COOKIE_VARS["wordpressuser"])) { 
    11         $user_login = $HTTP_COOKIE_VARS["wordpressuser"]; 
    12         $user_pass_md5 = $HTTP_COOKIE_VARS["wordpresspass"]; 
     10    if (!empty($HTTP_COOKIE_VARS["wordpressuser_".$cookiehash])) { 
     11        $user_login = $HTTP_COOKIE_VARS["wordpressuser_".$cookiehash]; 
     12        $user_pass_md5 = $HTTP_COOKIE_VARS["wordpresspass_".$cookiehash]; 
    1313    } else { 
    1414        return false; 
     
    3939        header('Cache-Control: no-cache, must-revalidate'); 
    4040        header('Pragma: no-cache'); 
    41         if (!empty($HTTP_COOKIE_VARS["wordpressuser"])) { 
     41        if (!empty($HTTP_COOKIE_VARS["wordpressuser_".$cookiehash])) { 
    4242            $error="<strong>Error</strong>: wrong login or password"; 
    4343        } 
  • trunk/wp-admin/linkmanager.php

    r296 r458  
    8585} 
    8686 
    87 $links_show_cat_id = $HTTP_COOKIE_VARS["links_show_cat_id"]; 
    88 $links_show_order = $HTTP_COOKIE_VARS["links_show_order"]; 
     87$links_show_cat_id = $HTTP_COOKIE_VARS["links_show_cat_id_".$cookiehash]; 
     88$links_show_order = $HTTP_COOKIE_VARS["links_show_order_".$cookiehash]; 
    8989 
    9090if ($action2 != '') 
     
    264264             " WHERE link_id=$link_id"); 
    265265    } // end if save 
    266     setcookie('links_show_cat_id', $links_show_cat_id, time()+600); 
     266    setcookie('links_show_cat_id_'.$cookiehash, $links_show_cat_id, time()+600); 
    267267    header('Location: '.$this_file); 
    268268    break; 
     
    289289    } 
    290290    $links_show_cat_id = $cat_id; 
    291     setcookie("links_show_cat_id", $links_show_cat_id, time()+600); 
     291    setcookie("links_show_cat_id_".$cookiehash, $links_show_cat_id, time()+600); 
    292292    header('Location: '.$this_file); 
    293293    break; 
     
    442442    $links_show_order = $order_by; 
    443443 
    444     setcookie('links_show_cat_id', $links_show_cat_id, time()+600); 
    445     setcookie('links_show_order', $links_show_order, time()+600); 
     444    setcookie('links_show_cat_id_'.$cookiehash, $links_show_cat_id, time()+600); 
     445    setcookie('links_show_order_'.$cookiehash, $links_show_order, time()+600); 
    446446    $standalone=0; 
    447447    include_once ("./b2header.php"); 
  • trunk/wp-pass.php

    r323 r458  
    66  -- Matt 
    77*/ 
    8  
    9 setcookie('wp-postpass', $HTTP_POST_VARS['post_password'], time()+60*60*24*30); 
     8include_once('wp-config.php'); 
     9setcookie('wp-postpass_'.$cookiehash, $HTTP_POST_VARS['post_password'], time()+60*60*24*30); 
    1010header('Location: ' . $HTTP_SERVER_VARS['HTTP_REFERER']); 
    1111 
  • trunk/wp-settings.php

    r417 r458  
    6363    $querystring_separator = '&amp;'; 
    6464    //} 
     65    // Used to guarantee unique cookies 
     66    $cookiehash = md5($siteurl); 
     67 
    6568} //end !$_wp_installing 
    6669?>