- $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
-
- $sqimap_capabilities = sqimap_capability($imapConnection);
- sqsession_register($sqimap_capabilities, 'sqimap_capabilities');
- $delimiter = sqimap_get_delimiter ($imapConnection);
-
- sqimap_logout($imapConnection);
- sqsession_register($delimiter, 'delimiter');
-
- $username = $login_username;
- sqsession_register ($username, 'username');
- setcookie('key', $key, 0, $base_uri);
-
- switch ($allow_frames) {
- case 4: // if $use_frames unset, fall through to case 2
- if (isset($_POST['set_use_frames'])) {
- $use_frames = $_POST['set_use_frames'];
- break;
- }
- case 2: // Do not use frames
- $use_frames = 0;
- break;
- case 3: // if $use_frames unset, fall through to case 1
- if (isset($_POST['set_use_frames'])) {
- $use_frames = $_POST['set_use_frames'];
- break;
- }
- default: // default is also to use frames
- case 1: // use frames
- $use_frames = 1;
- break;
- }
+/* Verify that username and password are correct. */
+$imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
+/* From now on we are logged it. If the login failed then sqimap_login handles it */
+
+/* regenerate the session id to avoid session hyijacking */
+//FIXME! IMPORTANT! SOMEONE PLEASE EXPLAIN THE SECURITY CONCERN HERE; THIS session_destroy() BORKS ANY SESSION INFORMATION ADDED ON THE LOGIN PAGE (SPECIFICALLY THE SESSION RESTORE DATA, BUT ALSO ANYTHING ADDED BY PLUGINS, ETC)... I HAVE DISABLED THIS (AND NOTE THAT THE LOGIN PAGE ALREADY EXECUTES A session_destroy() (see includes/init.php)), SO PLEASE, WHOEVER ADDED THIS, PLEASE ANALYSE THIS SITUATION AND COMMENT ON IF IT IS OK LIKE THIS!! WHAT HIJACKING ISSUES ARE WE SUPPOSED TO BE PREVENTING HERE?
+//sqsession_destroy();
+//@sqsession_is_active();
+//session_regenerate_id();
+/**
+* The cookie part. session_start and session_regenerate_session normally set
+* their own cookie. SquirrelMail sets another cookie which overwites the
+* php cookies. The sqsetcookie function sets the cookie by using the header
+* function which gives us full control how the cookie is set. We do that
+* to add the HttpOnly cookie attribute which blocks javascript access on
+* IE6 SP1.
+*/
+sqsetcookie(session_name(),session_id(),false,$base_uri);
+sqsetcookie('key', $key, false, $base_uri);
+
+sqsession_register($onetimepad, 'onetimepad');
+
+$sqimap_capabilities = sqimap_capability($imapConnection);
+
+/* Server side sorting control */
+if (isset($sqimap_capabilities['SORT']) && $sqimap_capabilities['SORT'] == true &&
+ isset($disable_server_sort) && $disable_server_sort) {
+ unset($sqimap_capabilities['SORT']);
+}
+
+/* Thread sort control */
+if (isset($sqimap_capabilities['THREAD']) && $sqimap_capabilities['THREAD'] == true &&
+ isset($disable_thread_sort) && $disable_thread_sort) {
+ unset($sqimap_capabilities['THREAD']);
+}