Added auth.php to put authentication functions in one place. Added a
authorgustavf <gustavf@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 29 Jun 2000 12:46:49 +0000 (12:46 +0000)
committergustavf <gustavf@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 29 Jun 2000 12:46:49 +0000 (12:46 +0000)
function there to check if the user is logged in without having to
connect to the IMAP server. Using this function in compose.php as a
test.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@570 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/auth.php [new file with mode: 0644]
src/compose.php
src/webmail.php

diff --git a/functions/auth.php b/functions/auth.php
new file mode 100644 (file)
index 0000000..594567f
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ ** auth.php
+ **
+ ** Contains functions used to do authentication.
+ **
+ **/
+
+   $auth_php = true;
+
+   function is_logged_in () {
+      if (!session_is_registered("user_is_logged_in")) {
+         echo _("You must login first.");
+         echo "</body></html>\n\n";
+         exit;
+      } else {
+         return true;
+      }
+   }
+
+?>
index daae7b63b2f32fbffbe94e44f4a945513886d706..000b2264a4193eb022df089108e62f91d0a7930b 100644 (file)
@@ -25,6 +25,8 @@
       include("../functions/smtp.php");
    if (!isset($display_messages_php))
       include("../functions/display_messages.php");
+   if (!isset($auth_php))
+      include ("../functions/auth.php");
 
    include("../src/load_prefs.php");
 
          showInputForm();
       }
    } else if ($html_addr_search_done) {
-      $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+      is_logged_in();
       displayPageHeader($color, $mailbox);
 
       $body = stripslashes($body);
       //* can think of a better way, please implement it.
       include ("addrbook_search_html.php");
    } else if (isset($attach)) {
-      $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+      is_logged_in();
       displayPageHeader($color, $mailbox);
 
       $localfilename = md5("$attachfile, $attachfile_name, $REMOTE_IP, $REMOTE_PORT, $UNIQUE_ID, and everything else that may add entropy");
       
       showInputForm();
    } else if (isset($do_delete)) {
-      $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+      is_logged_in();
       displayPageHeader($color, $mailbox);
 
       while (list($key, $localname) = each($delete)) {
 
       showInputForm();
    } else {
-      $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+      is_logged_in();
       displayPageHeader($color, $mailbox);
 
       $newmail = true;
index 33a0aca7ab235ece7c972d56cbef3360cd2f1536..6a1eae8da33a0b55a2361babab6f0588cd9b9f58 100644 (file)
    include ("../functions/imap.php");
    if (!isset($plugin_php))
       include ("../functions/plugin.php");
+   if (!isset($auth_php))
+      include ("../functions/auth.php");
 
-   if ($is_logged_in != true) {
+   if (session_is_registered("user_is_logged_in")) {
       do_hook ("login_before");
       // verify that username and password are correct
       $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
       do_hook ("login_verified");
    }
 
-   session_register ("is_logged_in");
-   $is_logged_in = true;
+   session_register ("user_is_logged_in");
+   $user_is_logged_in = true;
 
    include ("../src/load_prefs.php");
 
-   echo "<html><head\n";
+   echo "<html><head>\n";
    echo "<TITLE>";
    echo "$org_title";
    echo "</TITLE>";