pulled out all the login stuff and error checking from each individual php file
[squirrelmail.git] / src / right_main.php
index 32715d63a8fbf95a047f0939eb3e06f2651082d7..3071e422e3105839f113bf4c2f66a75c0dbd52b8 100644 (file)
@@ -1,6 +1,6 @@
 <?
    /**
-    **  right_main.php3
+    **  right_main.php
     **
     **  This is where the mailboxes are listed.  This controls most of what
     **  goes on in SquirrelMail.
@@ -8,7 +8,7 @@
     **/
 
    if(!isset($logged_in)) {
-      echo "You must <a href=\"login.php3\">login</a> first.";
+      echo "You must <a href=\"login.php\">login</a> first.";
       exit;
    }
    if(!isset($username) || !isset($key)) {
 <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE">
 <FONT FACE="Arial,Helvetica">
 <?
-   include("../config/config.php3");
-   include("../functions/imap.php3");
-   include("../functions/strings.php3");
-   include("../functions/date.php3");
-   include("../functions/page_header.php3");
-   include("../functions/array.php3");
-   include("../functions/mailbox.php3");
-   include("../functions/mailbox_display.php3");
-   include("../functions/display_messages.php3");
+   include("../config/config.php");
+   include("../functions/imap.php");
+   include("../functions/strings.php");
+   include("../functions/date.php");
+   include("../functions/page_header.php");
+   include("../functions/array.php");
+   include("../functions/mailbox.php");
+   include("../functions/mailbox_display.php");
+   include("../functions/display_messages.php");
 
    /////////////////////////////////////////////////////////////////////////////////
    //
 
 
    // open a connection on the imap port (143)
-   $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString);
-   if (!$imapConnection) {
-      echo "Error connecting to IMAP Server.<br>";
-      echo "$errorNumber : $errorString<br>";
-      exit;
-   }
-   $serverInfo = fgets($imapConnection, 256);
-
-   // login
-   fputs($imapConnection, "1 login $username $key\n");
-   $read = fgets($imapConnection, 1024);
-   if (strpos($read, "NO")) {
-      error_username_password_incorrect();
-      exit;
-   }
+   $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
 
    // If the page has been loaded without a specific mailbox,
    //    just show a page of general info.
@@ -81,6 +67,7 @@
    showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort);
 
    // close the connection
+   fputs($imapConnection, "1 logout\n");
    fclose($imapConnection);
 ?>
 </FONT>