Switch over to support for real IMAP sequence numbers (from A001 ->). Needed
authorbrong <brong@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 12 Jan 2002 11:37:40 +0000 (11:37 +0000)
committerbrong <brong@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 12 Jan 2002 11:37:40 +0000 (11:37 +0000)
to fix my own function to only call sqimap_session_id() once!

Note: the old API is still there in its entirity, this is just another way to
call things.  With the changing sequence numbers though, any function working
with sqimap_session_id() must cache the result for testing against the
response of any command sent.

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

functions/imap_general.php

index ccec8ba10b691b1cc9cc15a72b9c1bf9d190dcbb..a2e6bac355d36b2816f8ac11d099dc7a05364ac2 100755 (executable)
@@ -21,16 +21,14 @@ require_once('../functions/display_messages.php');
  *
  * @return     string  a 4 chars unique string
  */
-function sqimap_session_id() {
 
-    global $data_dir, $username;
+global $sqimap_session_id;
+$sqimap_session_id = 1;
+function sqimap_session_id() {
 
-    $IMAPSessionID = substr(session_id(), -4);
-    if( $IMAPSessionID == '' ) {
-        $IMAPSessionID = 'A001';
-    }
+    global $data_dir, $username, $sqimap_session_id;
 
-    return( $IMAPSessionID );
+    return( sprintf("A%03d", $sqimap_session_id++) );
 }
 
 /******************************************************************************
@@ -39,14 +37,16 @@ function sqimap_session_id() {
 ******************************************************************************/
 
 function sqimap_run_command_list ($imap_stream, $query, $handle_errors, &$response, &$message) {
-    fputs ($imap_stream, sqimap_session_id() . ' ' . $query . "\r\n");
-    $read = sqimap_read_data_list ($imap_stream, sqimap_session_id(), $handle_errors, $response, $message);
+    $sid = sqimap_session_id();
+    fputs ($imap_stream, $sid . ' ' . $query . "\r\n");
+    $read = sqimap_read_data_list ($imap_stream, $sid, $handle_errors, $response, $message);
     return $read;
 }
 
 function sqimap_run_command ($imap_stream, $query, $handle_errors, &$response, &$message) {
-    fputs ($imap_stream, sqimap_session_id() . ' ' . $query . "\r\n");
-    $read = sqimap_read_data ($imap_stream, sqimap_session_id(), $handle_errors, $response, $message);
+    $sid = sqimap_session_id();
+    fputs ($imap_stream, $sid . ' ' . $query . "\r\n");
+    $read = sqimap_read_data ($imap_stream, $sid, $handle_errors, $response, $message);
     return $read;
 }
 
@@ -319,7 +319,7 @@ function sqimap_get_delimiter ($imap_stream = false) {
  */
 function sqimap_get_num_messages ($imap_stream, $mailbox) {
 
-    $read_ary = sqimap_run_command ($imap_stream, " EXAMINE \"$mailbox\"", true, $result, $message);
+    $read_ary = sqimap_run_command ($imap_stream, "EXAMINE \"$mailbox\"", true, $result, $message);
     for ($i = 0; $i < count($read_ary); $i++) {
      if (ereg("[^ ]+ +([^ ]+) +EXISTS", $read_ary[$i], $regs)) {
         return $regs[1];