testing fase
[squirrelmail.git] / functions / auth.php
index 61fe9cf188263a9e6c58633e0cac3d9799444a7c..10c33294a30af5f971590ed54ed831bb69bd190c 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * auth.php
  *
- * Copyright (c) 1999-2001 The Squirrelmail Development Team
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * Contains functions used to do authentication.
  * $Id$
  */
 
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!!           ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION.             ***/
-/***    + Base level indent should begin at left margin, as    ***/
-/***      the require_once below.                              ***/
-/***    + All identation should consist of four space blocks   ***/
-/***    + Tab characters are evil.                             ***/
-/***    + all comments should use "slash-star ... star-slash"  ***/
-/***      style -- no pound characters, no slash-slash style   ***/
-/***    + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD      ***/
-/***      ALWAYS USE { AND } CHARACTERS!!!                     ***/
-/***    + Please use ' instead of ", when possible. Note "     ***/
-/***      should always be used in _( ) function calls.        ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
-
-require_once( '../functions/page_header.php' );
-
-    function is_logged_in () {
-        global $squirrelmail_language;
-
-        if ( session_is_registered('user_is_logged_in') )
-            return;
-
-        set_up_language($squirrelmail_language, true);
-
-        displayHtmlHeader( 'SquirrelMail', '', FALSE );
-
-        echo "<body bgcolor=\"ffffff\">\n" .
-            '<br><br><center><b>'.
-            _("You must be logged in to access this page.").'</b><br><br>'.
-            "<a href=\"../src/login.php\" target=\"_top\">"._("Go to the login page")."</a>\n".
-            "</center></body></html>\n";
+function is_logged_in() {
+
+    if ( session_is_registered('user_is_logged_in') ) {
+        return;
+    } else {
+        global $HTTP_POST_VARS, $PHP_SELF, $session_expired_post, 
+              $session_expired_location;
+
+        /*  First we store some information in the new session to prevent
+         *  information-loss.
+         */
+       $session_expired_post = $HTTP_POST_VARS;
+        $session_expired_location = $PHP_SELF;
+        if (!session_is_registered('session_expired_post')) {    
+           session_register('session_expired_post');
+        }
+        if (!session_is_registered('session_expired_location')) {
+           session_register('session_expired_location');
+        }
+        include_once( '../functions/display_messages.php' );
+        logout_error( _("You must be logged in to access this page.") );
         exit;
     }
+}
 
-?>
+?>
\ No newline at end of file