From 41600f7d5363dfb79aadb45b10756ae63e45ba28 Mon Sep 17 00:00:00 2001 From: brong Date: Sat, 12 Jan 2002 11:37:40 +0000 Subject: [PATCH] Switch over to support for real IMAP sequence numbers (from A001 ->). Needed 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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index ccec8ba1..a2e6bac3 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -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]; -- 2.25.1