IMAP server error intercepted before PHP error.
[squirrelmail.git] / functions / imap_general.php
index 8bd2485aee551001430052b15421889c12bb489e..bc6b4f8eac886a90dc42e6de7b08cc18ecb047fd 100755 (executable)
@@ -1,28 +1,46 @@
 <?php
 
-   /**
-    *   imap.php
-    *
-    *   Copyright (c) 1999-2001 The Squirrelmail Development Team
-    *   Licensed under the GNU GPL. For full terms see the file COPYING.
-    *
-    *   This implements all functions that do general imap functions.
-    *
-    *   $Id$
-    */
-
-    /**
-    * Unique SessionId
-    *
-    * Sets an unique session id in order to avoid simultanous sessions crash.
-    *
-    * @return  string  a 4 chars unique string
-    */
-    function sqimap_session_id() {
+/**
+ *   imap.php
+ *
+ *   Copyright (c) 1999-2001 The SquirrelMail Development Team
+ *   Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *   This implements all functions that do general imap functions.
+ *
+ *   $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 function definition and comments start 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. ***/
+/*****************************************************************/
+
+/**
+ * Unique SessionId
+ *
+ * Sets an unique session id in order to avoid simultanous sessions crash.
+ *
+ * @return     string  a 4 chars unique string
+ */
+function sqimap_session_id() {
+
+        global $data_dir, $username;
 
         $IMAPSessionID = substr(session_id(), -4);
         if( $IMAPSessionID == '' ) {
-            $IMAPSessionID = GenerateRandomString(4, '', 7);
+            $IMAPSessionID = 'A001';
         }
 
         return( $IMAPSessionID );
 
       $imap_stream = fsockopen ( $imap_server_address, $imap_port,
                                  $error_number, $error_string, 15);
+      if( !$imap_stream ) {
+          return FALSE;
+      }
       $server_info = fgets ($imap_stream, 1024);
         
       // Decrypt the password