7392739d |
1 | <?php |
23d6bd09 |
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); |
525b7ae6 |
84 | session_register('delimiter'); |
23d6bd09 |
85 | |
86 | $username = $login_username; |
87 | session_register ('username'); |
88 | setcookie('key', $key, 0, $base_uri); |
23d6bd09 |
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 | |
7baf86a9 |
100 | /* parse the accepted content-types of the client */ |
101 | $attachment_common_types = array(); |
102 | $attachment_common_types_parsed = array(); |
103 | session_register('attachment_common_types'); |
104 | session_register('attachment_common_types_parsed'); |
105 | |
106 | if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT']) && |
107 | !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']])) |
108 | attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug); |
109 | if (isset($HTTP_ACCEPT) && |
110 | !isset($attachment_common_types_parsed[$HTTP_ACCEPT])) |
111 | attachment_common_parse($HTTP_ACCEPT, $debug); |
112 | |
113 | |
23d6bd09 |
114 | /* Complete autodetection of Javascript. */ |
357f1ae0 |
115 | checkForPrefs($data_dir, $username); |
23d6bd09 |
116 | $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); |
117 | $js_autodetect_results = (isset($js_autodetect_results) ? $js_autodetect_results : SMPREF_JS_OFF); |
118 | if ($javascript_setting == SMPREF_JS_AUTODETECT) { |
119 | if ($js_autodetect_results == SMPREF_JS_ON) { |
120 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); |
121 | } else { |
122 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
123 | } |
124 | } else { |
125 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
126 | } |
127 | |
128 | /* Compute the URL to forward the user to. */ |
129 | if(isset($rcptemail)) { |
130 | $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress='; |
131 | $redirect_url .= urlencode($rcptemail); |
132 | } else { |
133 | $redirect_url = 'webmail.php'; |
134 | } |
135 | |
136 | /* Send them off to the appropriate page. */ |
137 | header("Location: $redirect_url"); |
7baf86a9 |
138 | |
139 | |
140 | function attachment_common_parse($str, $debug) |
141 | { |
142 | global $attachment_common_types, $attachment_common_types_parsed; |
143 | |
144 | $attachment_common_types_parsed[$str] = true; |
145 | $types = explode(', ', $str); |
146 | |
147 | foreach ($types as $val) |
148 | { |
149 | // Ignore the ";q=1.0" stuff |
150 | if (strpos($val, ';') !== false) |
151 | $val = substr($val, 0, strpos($val, ';')); |
152 | |
153 | if (! isset($attachment_common_types[$val])) { |
154 | $attachment_common_types[$val] = true; |
155 | } |
156 | } |
157 | } |
158 | |
e0dcff78 |
159 | ?> |