| 1 | <?php |
| 2 | /** |
| 3 | * redirect.php |
| 4 | * Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de> |
| 5 | * |
| 6 | * Copyright (c) 1999-2001 The Squirrelmail Development Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * Prevents users from reposting their form data after a successful logout. |
| 10 | * |
| 11 | * $Id$ |
| 12 | */ |
| 13 | |
| 14 | require_once('../functions/i18n.php'); |
| 15 | require_once('../functions/strings.php'); |
| 16 | require_once('../config/config.php'); |
| 17 | |
| 18 | /* Before starting the session, the base URI must be known. Assuming */ |
| 19 | /* that this file is in the src/ subdirectory (or something). */ |
| 20 | ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); |
| 21 | $base_uri = $regs[1]; |
| 22 | |
| 23 | header('Pragma: no-cache'); |
| 24 | $location = get_location(); |
| 25 | |
| 26 | session_set_cookie_params (0, $base_uri); |
| 27 | session_start(); |
| 28 | |
| 29 | session_unregister ('user_is_logged_in'); |
| 30 | session_register ('base_uri'); |
| 31 | |
| 32 | if (! isset($squirrelmail_language)) { |
| 33 | $squirrelmail_language = ''; |
| 34 | } |
| 35 | set_up_language($squirrelmail_language, true); |
| 36 | |
| 37 | if (!isset($login_username)) { |
| 38 | echo "<HTML><BODY BGCOLOR=\"#ffffff\">\n"; |
| 39 | echo "<BR><BR>\n"; |
| 40 | echo "<CENTER>\n"; |
| 41 | echo ' <B>' . _("You must be logged in to access this page.") . "</B><BR>"; |
| 42 | echo ' <A HREF="../src/login.php">' . _("Go to the login page") . "</A>\n"; |
| 43 | echo "</CENTER>\n"; |
| 44 | echo "</BODY></HTML>\n"; |
| 45 | exit; |
| 46 | } |
| 47 | |
| 48 | /* Refresh the language cookie. */ |
| 49 | if (isset($squirrelmail_language)) { |
| 50 | setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri); |
| 51 | } |
| 52 | |
| 53 | require_once('../functions/prefs.php'); |
| 54 | require_once('../functions/imap.php'); |
| 55 | require_once('../functions/plugin.php'); |
| 56 | require_once('../functions/constants.php'); |
| 57 | |
| 58 | if (!session_is_registered('user_is_logged_in')) { |
| 59 | do_hook ('login_before'); |
| 60 | |
| 61 | $onetimepad = OneTimePadCreate(strlen($secretkey)); |
| 62 | $key = OneTimePadEncrypt($secretkey, $onetimepad); |
| 63 | session_register('onetimepad'); |
| 64 | |
| 65 | /* Verify that username and password are correct. */ |
| 66 | if ($force_username_lowercase) { |
| 67 | $login_username = strtolower($login_username); |
| 68 | } |
| 69 | |
| 70 | $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); |
| 71 | if (!$imapConnection) { |
| 72 | echo "<html><body bgcolor=\"#ffffff\">\n"; |
| 73 | echo "<br><br>"; |
| 74 | echo "<center>"; |
| 75 | echo "<b>"._("There was an error contacting the mail server.")."</b><br>"; |
| 76 | echo _("Contact your administrator for help.")."\n"; |
| 77 | echo "</center>"; |
| 78 | echo "</body></html>\n"; |
| 79 | exit; |
| 80 | } else { |
| 81 | $delimiter = sqimap_get_delimiter ($imapConnection); |
| 82 | } |
| 83 | sqimap_logout($imapConnection); |
| 84 | |
| 85 | $username = $login_username; |
| 86 | session_register ('username'); |
| 87 | setcookie('key', $key, 0, $base_uri); |
| 88 | setcookie('delimiter', $delimiter, 0, $base_uri); |
| 89 | do_hook ('login_verified'); |
| 90 | } |
| 91 | |
| 92 | /* Set the login variables. */ |
| 93 | $user_is_logged_in = true; |
| 94 | $just_logged_in = true; |
| 95 | |
| 96 | /* And register with them with the session. */ |
| 97 | session_register ('user_is_logged_in'); |
| 98 | session_register ('just_logged_in'); |
| 99 | |
| 100 | /* Complete autodetection of Javascript. */ |
| 101 | $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); |
| 102 | $js_autodetect_results = (isset($js_autodetect_results) ? $js_autodetect_results : SMPREF_JS_OFF); |
| 103 | if ($javascript_setting == SMPREF_JS_AUTODETECT) { |
| 104 | if ($js_autodetect_results == SMPREF_JS_ON) { |
| 105 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); |
| 106 | } else { |
| 107 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
| 108 | } |
| 109 | } else { |
| 110 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
| 111 | } |
| 112 | |
| 113 | /* Compute the URL to forward the user to. */ |
| 114 | if(isset($rcptemail)) { |
| 115 | $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress='; |
| 116 | $redirect_url .= urlencode($rcptemail); |
| 117 | } else { |
| 118 | $redirect_url = 'webmail.php'; |
| 119 | } |
| 120 | |
| 121 | /* Send them off to the appropriate page. */ |
| 122 | header("Location: $redirect_url"); |
| 123 | ?> |