Much more graceful way of not showing logged-in pages to logged-out users
authorTom Gilder <tomgilder@users.mediawiki.org>
Tue, 18 Jan 2005 03:06:20 +0000 (03:06 +0000)
committerTom Gilder <tomgilder@users.mediawiki.org>
Tue, 18 Jan 2005 03:06:20 +0000 (03:06 +0000)
includes/OutputPage.php
includes/User.php

index 2903e0d..60ce7dd 100644 (file)
@@ -112,7 +112,7 @@ class OutputPage {
                        $ismodsince = wfTimestamp( TS_MW, strtotime( $modsince ) );
                        wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
                        wfDebug( "--  we might send Last-Modified : $lastmod\n", false );
-                       if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && !$wgUser->wasLoggedInAt( $ismodsince )) {
+                       if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) {
                                # Make sure you're in a place you can leave when you call us!
                                header( "HTTP/1.0 304 Not Modified" );
                                $this->mLastModified = $lastmod;
index c347f30..036d883 100644 (file)
@@ -153,7 +153,7 @@ class User {
                $fname = 'User::loadDefaults' . $n;
                wfProfileIn( $fname );
                
-               global $wgContLang, $wgIP;
+               global $wgContLang, $wgIP, $wgDBname;
                global $wgNamespacesToBeSearchedDefault;
 
                $this->mId = 0;
@@ -175,9 +175,16 @@ class User {
                unset( $this->mSkin );
                $this->mDataLoaded = false;
                $this->mBlockedby = -1; # Unset
-               $this->mTouched = '0'; # Allow any pages to be cached
                $this->setToken(); # Random
                $this->mHash = false;
+
+               if ( isset( $_COOKIE[$wgDBname.'LoggedOut'] ) ) {
+                       $this->mTouched = wfTimestamp( TS_MW, $_COOKIE[$wgDBname.'LoggedOut'] );
+               }
+               else {
+                       $this->mTouched = '0'; # Allow any pages to be cached
+               }
+
                wfProfileOut( $fname );
        }
 
@@ -899,10 +906,6 @@ class User {
                } else {
                        setcookie( $wgDBname.'Token', '', time() - 3600 );
                }
-
-               # Clear previous logged out time, set logged in time
-               setcookie( $wgDBname.'LoggedOut', '', time() - 3600, $wgCookiePath, $wgCookieDomain );
-               setcookie( $wgDBname.'LoggedIn', wfTimestampNow(), time() + 86400, $wgCookiePath, $wgCookieDomain );
        }
 
        /**
@@ -1184,20 +1187,6 @@ class User {
                }
                return false;
        }
-
-       /**
-        * Check if the user was logged on at a certain timestamp, but no longer is.
-        * @param int $timestamp Timestamp to check.
-        * @return bool True if user was logged in.
-        */
-       function wasLoggedInAt( $timestamp ) {
-               global $wgDBname;
-
-               if ( !$this->getID() && isset( $_COOKIE[$wgDBname.'LoggedIn'] ) && isset( $_COOKIE[$wgDBname.'LoggedOut'] ) )
-                       return ( $timestamp >= $_COOKIE[$wgDBname.'LoggedIn'] && $timestamp <= $_COOKIE[$wgDBname.'LoggedOut'] );
-               else
-                       return false;
-       }
 }
 
 ?>