Browse Source

Pref file now isn't created if the login failed

Luke Ehresman 25 years ago
parent
commit
4e30e8862c
5 changed files with 22 additions and 13 deletions
  1. 2 1
      functions/imap.php
  2. 6 4
      src/left_main.php
  3. 8 2
      src/load_prefs.php
  4. 6 4
      src/right_main.php
  5. 0 2
      src/webmail.php

+ 2 - 1
functions/imap.php

@@ -106,6 +106,7 @@
          echo "SERVER SAYS: $read<BR>";
          echo "SERVER SAYS: $read<BR>";
       }
       }
 
 
+      /** If the login attempt was UNsuccessful, lets see why **/
       if (substr($read, 0, 7) != "a001 OK") {
       if (substr($read, 0, 7) != "a001 OK") {
          if (!$hide) {
          if (!$hide) {
             if (substr($read, 0, 8) == "a001 BAD") {
             if (substr($read, 0, 8) == "a001 BAD") {
@@ -113,7 +114,7 @@
                exit;
                exit;
             }
             }
             else if (substr($read, 0, 7) == "a001 NO") {
             else if (substr($read, 0, 7) == "a001 NO") {
-               echo "<BR>";
+               echo "<HTML><BODY BGCOLOR=FFFFFF><BR>";
                echo "<TABLE COLS=1 WIDTH=70% NOBORDER BGCOLOR=FFFFFF ALIGN=CENTER>";
                echo "<TABLE COLS=1 WIDTH=70% NOBORDER BGCOLOR=FFFFFF ALIGN=CENTER>";
                echo "   <TR>";
                echo "   <TR>";
                echo "      <TD BGCOLOR=\"DCDCDC\">";
                echo "      <TD BGCOLOR=\"DCDCDC\">";

+ 6 - 4
src/left_main.php

@@ -20,8 +20,6 @@
    include("../functions/imap.php");
    include("../functions/imap.php");
    include("../functions/mailbox.php");
    include("../functions/mailbox.php");
 
 
-   include("../src/load_prefs.php");
-
    function formatMailboxName($imapConnection, $mailbox, $delimeter, $color) {
    function formatMailboxName($imapConnection, $mailbox, $delimeter, $color) {
       require ("../config/config.php");
       require ("../config/config.php");
 
 
@@ -67,11 +65,15 @@
       return $line;
       return $line;
    }
    }
 
 
-   echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
-   echo "<FONT FACE=\"Arial,Helvetica\">";
    // open a connection on the imap port (143)
    // open a connection on the imap port (143)
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
 
 
+   /** If it was a successful login, lets load their preferences **/
+   include("../src/load_prefs.php");
+   checkForPrefs($data_dir, $username);
+   echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
+   echo "<FONT FACE=\"Arial,Helvetica\">";
+
    getFolderList($imapConnection, $boxes);
    getFolderList($imapConnection, $boxes);
 
 
    echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
    echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";

+ 8 - 2
src/load_prefs.php

@@ -4,9 +4,15 @@
 
 
    $chosen_theme = getPref($data_dir, $username, "chosen_theme");
    $chosen_theme = getPref($data_dir, $username, "chosen_theme");
 
 
-   if (isset($chosen_theme)) {
+   if ((isset($chosen_theme)) && (file_exists($chosen_theme))) {
       require("$chosen_theme");
       require("$chosen_theme");
    } else {
    } else {
-      require($theme[0]["PATH"]);
+      if (file_exists($theme[0]["PATH"])) {
+         require($theme[0]["PATH"]);
+      } else {
+         echo "Theme: " . $theme[0]["PATH"] . " was not found.<BR>";
+         echo "Exiting abnormally";
+         exit;
+      }
    }
    }
 ?>
 ?>

+ 6 - 4
src/right_main.php

@@ -29,10 +29,6 @@
    include("../functions/mailbox_display.php");
    include("../functions/mailbox_display.php");
    include("../functions/display_messages.php");
    include("../functions/display_messages.php");
 
 
-   include("../src/load_prefs.php");
-
-   echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
-   echo "<FONT FACE=\"Arial,Helvetica\">";
    /////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////
    //
    //
    // incoming variables from URL:
    // incoming variables from URL:
@@ -51,6 +47,12 @@
    // open a connection on the imap port (143)
    // open a connection on the imap port (143)
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
 
 
+   /** If it was a successful login, lets load their preferences **/
+   include("../src/load_prefs.php");
+   checkForPrefs($data_dir, $username);
+   echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+   echo "<FONT FACE=\"Arial,Helvetica\">";
+
    // If the page has been loaded without a specific mailbox,
    // If the page has been loaded without a specific mailbox,
    //    just show a page of general info.
    //    just show a page of general info.
    if (!isset($mailbox)) {
    if (!isset($mailbox)) {

+ 0 - 2
src/webmail.php

@@ -36,8 +36,6 @@
     This was done to create a pure HTML way of refreshing the folder list since
     This was done to create a pure HTML way of refreshing the folder list since
     we would like to use as little Javascript as possible.
     we would like to use as little Javascript as possible.
 **/
 **/
-   checkForPrefs($data_dir, $username);
-
    if ($right_frame == "right_main.php") {
    if ($right_frame == "right_main.php") {
       $urlMailbox = urlencode($mailbox);
       $urlMailbox = urlencode($mailbox);
       echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
       echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";