7392739d |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
cab99c3a |
4 | * redirect.php |
5 | * Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de> |
6 | * |
7 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
8 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
9 | * |
10 | * Prevents users from reposting their form data after a successful logout. |
11 | * |
12 | * $Id$ |
13 | */ |
35586184 |
14 | |
15 | require_once('../functions/i18n.php'); |
16 | require_once('../functions/strings.php'); |
17 | require_once('../config/config.php'); |
18 | require_once('../functions/prefs.php'); |
19 | require_once('../functions/imap.php'); |
20 | require_once('../functions/plugin.php'); |
21 | require_once('../functions/constants.php'); |
5a545dda |
22 | require_once('../functions/page_header.php'); |
cb48c245 |
23 | |
26707265 |
24 | // Remove slashes if PHP added them |
25 | if (get_magic_quotes_gpc()) { |
26 | global $REQUEST_METHOD; |
cab99c3a |
27 | |
5cc0b70e |
28 | if ($REQUEST_METHOD == 'POST') { |
26707265 |
29 | global $HTTP_POST_VARS; |
30 | RemoveSlashes($HTTP_POST_VARS); |
5cc0b70e |
31 | } else if ($REQUEST_METHOD == 'GET') { |
26707265 |
32 | global $HTTP_GET_VARS; |
33 | RemoveSlashes($HTTP_GET_VARS); |
34 | } |
35 | } |
36 | |
5c3b0995 |
37 | /* Before starting the session, the base URI must be known. Assuming */ |
38 | /* that this file is in the src/ subdirectory (or something). */ |
39 | ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); |
40 | $base_uri = $regs[1]; |
41 | |
42 | header('Pragma: no-cache'); |
43 | $location = get_location(); |
44 | |
45 | session_set_cookie_params (0, $base_uri); |
46 | session_start(); |
47 | |
48 | session_unregister ('user_is_logged_in'); |
49 | session_register ('base_uri'); |
50 | |
51 | if (! isset($squirrelmail_language) || |
52 | $squirrelmail_language == '' ) { |
53 | $squirrelmail_language = $squirrelmail_default_language; |
54 | } |
55 | set_up_language($squirrelmail_language, true); |
56 | /* Refresh the language cookie. */ |
57 | setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri); |
58 | |
59 | if (!isset($login_username)) { |
9be8198d |
60 | include_once( '../functions/display_messages.php' ); |
61 | logout_error( _("You must be logged in to access this page.") ); |
5c3b0995 |
62 | exit; |
63 | } |
64 | |
65 | if (!session_is_registered('user_is_logged_in')) { |
66 | do_hook ('login_before'); |
67 | |
68 | $onetimepad = OneTimePadCreate(strlen($secretkey)); |
69 | $key = OneTimePadEncrypt($secretkey, $onetimepad); |
70 | session_register('onetimepad'); |
71 | |
72 | /* Verify that username and password are correct. */ |
73 | if ($force_username_lowercase) { |
74 | $login_username = strtolower($login_username); |
23d6bd09 |
75 | } |
76 | |
5c3b0995 |
77 | $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); |
78 | if (!$imapConnection) { |
9be8198d |
79 | $errTitle = _("There was an error contacting the mail server."); |
80 | $errString = $errTitle . "<br>\n". |
81 | _("Contact your administrator for help."); |
82 | include_once( '../functions/display_messages.php' ); |
83 | logout_error( _("You must be logged in to access this page.") ); |
5c3b0995 |
84 | exit; |
23d6bd09 |
85 | } else { |
5c3b0995 |
86 | $delimiter = sqimap_get_delimiter ($imapConnection); |
23d6bd09 |
87 | } |
5c3b0995 |
88 | sqimap_logout($imapConnection); |
89 | session_register('delimiter'); |
90 | |
91 | $username = $login_username; |
92 | session_register ('username'); |
93 | setcookie('key', $key, 0, $base_uri); |
94 | do_hook ('login_verified'); |
95 | |
96 | } |
97 | |
98 | /* Set the login variables. */ |
99 | $user_is_logged_in = true; |
100 | $just_logged_in = true; |
101 | |
102 | /* And register with them with the session. */ |
103 | session_register ('user_is_logged_in'); |
104 | session_register ('just_logged_in'); |
105 | |
106 | /* parse the accepted content-types of the client */ |
107 | $attachment_common_types = array(); |
108 | $attachment_common_types_parsed = array(); |
109 | session_register('attachment_common_types'); |
110 | session_register('attachment_common_types_parsed'); |
111 | |
112 | $debug = false; |
113 | if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT']) && |
9be8198d |
114 | !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']])) { |
5c3b0995 |
115 | attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug); |
9be8198d |
116 | } |
5c3b0995 |
117 | if (isset($HTTP_ACCEPT) && |
9be8198d |
118 | !isset($attachment_common_types_parsed[$HTTP_ACCEPT])) { |
5c3b0995 |
119 | attachment_common_parse($HTTP_ACCEPT, $debug); |
9be8198d |
120 | } |
5c3b0995 |
121 | |
122 | /* Complete autodetection of Javascript. */ |
165829a3 |
123 | $javascript_setting = getPref |
124 | ($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); |
125 | $js_autodetect_results = (isset($js_autodetect_results) ? |
126 | $js_autodetect_results : SMPREF_JS_OFF); |
18f734b9 |
127 | /* See if it's set to "Always on" */ |
128 | $js_pref = SMPREF_JS_ON; |
129 | if ($javascript_setting != SMPREF_JS_ON){ |
130 | if ($javascript_setting == SMPREF_JS_AUTODETECT) { |
131 | if ($js_autodetect_results == SMPREF_JS_OFF) { |
132 | $js_pref = SMPREF_JS_OFF; |
133 | } |
23d6bd09 |
134 | } else { |
18f734b9 |
135 | $js_pref = SMPREF_JS_OFF; |
23d6bd09 |
136 | } |
5c3b0995 |
137 | } |
18f734b9 |
138 | /* Update the prefs */ |
139 | setPref($data_dir, $username, 'javascript_on', $js_pref); |
5c3b0995 |
140 | |
141 | /* Compute the URL to forward the user to. */ |
142 | if(isset($rcptemail)) { |
143 | $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress='; |
594d29a1 |
144 | $redirect_url .= $rcptemail; |
5c3b0995 |
145 | } else { |
146 | $redirect_url = 'webmail.php'; |
147 | } |
148 | |
149 | /* Send them off to the appropriate page. */ |
150 | header("Location: $redirect_url"); |
7baf86a9 |
151 | |
cab99c3a |
152 | /* --------------------- end main ----------------------- */ |
153 | |
154 | function attachment_common_parse($str, $debug) { |
155 | global $attachment_common_types, $attachment_common_types_parsed; |
156 | |
157 | $attachment_common_types_parsed[$str] = true; |
158 | $types = explode(', ', $str); |
159 | |
160 | foreach ($types as $val) { |
161 | // Ignore the ";q=1.0" stuff |
162 | if (strpos($val, ';') !== false) |
163 | $val = substr($val, 0, strpos($val, ';')); |
164 | |
165 | if (! isset($attachment_common_types[$val])) { |
166 | $attachment_common_types[$val] = true; |
167 | } |
168 | } |
169 | } |
170 | |
171 | |
9be8198d |
172 | ?> |