7392739d |
1 | <?php |
895905c0 |
2 | |
23d6bd09 |
3 | /** |
895905c0 |
4 | ** redirect.php |
5 | ** Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de> |
6 | ** |
7 | ** Copyright (c) 1999-2001 The Squirrelmail Development 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 | **/ |
23d6bd09 |
14 | |
15 | require_once('../functions/i18n.php'); |
16 | require_once('../functions/strings.php'); |
17 | require_once('../config/config.php'); |
cb48c245 |
18 | require_once('../functions/prefs.php'); |
19 | require_once('../functions/imap.php'); |
20 | require_once('../functions/plugin.php'); |
21 | require_once('../functions/constants.php'); |
22 | |
23 | function attachment_common_parse($str, $debug) { |
24 | global $attachment_common_types, $attachment_common_types_parsed; |
25 | |
26 | $attachment_common_types_parsed[$str] = true; |
27 | $types = explode(', ', $str); |
28 | |
29 | foreach ($types as $val) |
30 | { |
31 | // Ignore the ";q=1.0" stuff |
32 | if (strpos($val, ';') !== false) |
33 | $val = substr($val, 0, strpos($val, ';')); |
34 | |
35 | if (! isset($attachment_common_types[$val])) { |
36 | $attachment_common_types[$val] = true; |
37 | } |
38 | } |
39 | } |
40 | |
23d6bd09 |
41 | |
42 | /* Before starting the session, the base URI must be known. Assuming */ |
43 | /* that this file is in the src/ subdirectory (or something). */ |
44 | ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); |
45 | $base_uri = $regs[1]; |
46 | |
47 | header('Pragma: no-cache'); |
48 | $location = get_location(); |
49 | |
50 | session_set_cookie_params (0, $base_uri); |
51 | session_start(); |
52 | |
53 | session_unregister ('user_is_logged_in'); |
54 | session_register ('base_uri'); |
55 | |
cb48c245 |
56 | if (! isset($squirrelmail_language) || |
57 | $squirrelmail_language == '' ) { |
58 | $squirrelmail_language = $squirrelmail_default_language; |
23d6bd09 |
59 | } |
60 | set_up_language($squirrelmail_language, true); |
cb48c245 |
61 | /* Refresh the language cookie. */ |
62 | setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri); |
23d6bd09 |
63 | |
64 | if (!isset($login_username)) { |
cb48c245 |
65 | echo "<HTML><BODY BGCOLOR=\"#ffffff\">\n" . |
66 | "<BR> <BR>\n" . |
67 | "<CENTER>\n" . |
68 | '<B>' . _("You must be logged in to access this page.") . "</B><BR>" . |
69 | '<A HREF="../src/login.php">' . _("Go to the login page") . "</A>\n" . |
70 | "</CENTER>\n" . |
71 | "</BODY></HTML>\n"; |
23d6bd09 |
72 | exit; |
73 | } |
74 | |
23d6bd09 |
75 | if (!session_is_registered('user_is_logged_in')) { |
76 | do_hook ('login_before'); |
77 | |
78 | $onetimepad = OneTimePadCreate(strlen($secretkey)); |
79 | $key = OneTimePadEncrypt($secretkey, $onetimepad); |
80 | session_register('onetimepad'); |
81 | |
82 | /* Verify that username and password are correct. */ |
83 | if ($force_username_lowercase) { |
84 | $login_username = strtolower($login_username); |
85 | } |
cb48c245 |
86 | |
23d6bd09 |
87 | $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); |
88 | if (!$imapConnection) { |
cb48c245 |
89 | echo "<html><body bgcolor=\"#ffffff\">\n". |
90 | "<br> <br>\n". |
91 | "<center>\n". |
92 | '<b>' . _("There was an error contacting the mail server.") . "</b><br>\n". |
93 | _("Contact your administrator for help.") . "\n". |
94 | "</center>\n". |
95 | "</body></html>\n"; |
23d6bd09 |
96 | exit; |
97 | } else { |
98 | $delimiter = sqimap_get_delimiter ($imapConnection); |
99 | } |
100 | sqimap_logout($imapConnection); |
525b7ae6 |
101 | session_register('delimiter'); |
23d6bd09 |
102 | |
103 | $username = $login_username; |
104 | session_register ('username'); |
105 | setcookie('key', $key, 0, $base_uri); |
23d6bd09 |
106 | do_hook ('login_verified'); |
107 | } |
108 | |
109 | /* Set the login variables. */ |
110 | $user_is_logged_in = true; |
111 | $just_logged_in = true; |
112 | |
113 | /* And register with them with the session. */ |
114 | session_register ('user_is_logged_in'); |
115 | session_register ('just_logged_in'); |
116 | |
7baf86a9 |
117 | /* parse the accepted content-types of the client */ |
118 | $attachment_common_types = array(); |
119 | $attachment_common_types_parsed = array(); |
120 | session_register('attachment_common_types'); |
121 | session_register('attachment_common_types_parsed'); |
122 | |
bbdd6ddb |
123 | $debug = false; |
7baf86a9 |
124 | if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT']) && |
125 | !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']])) |
126 | attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug); |
127 | if (isset($HTTP_ACCEPT) && |
128 | !isset($attachment_common_types_parsed[$HTTP_ACCEPT])) |
129 | attachment_common_parse($HTTP_ACCEPT, $debug); |
130 | |
131 | |
23d6bd09 |
132 | /* Complete autodetection of Javascript. */ |
357f1ae0 |
133 | checkForPrefs($data_dir, $username); |
23d6bd09 |
134 | $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); |
135 | $js_autodetect_results = (isset($js_autodetect_results) ? $js_autodetect_results : SMPREF_JS_OFF); |
136 | if ($javascript_setting == SMPREF_JS_AUTODETECT) { |
137 | if ($js_autodetect_results == SMPREF_JS_ON) { |
138 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); |
139 | } else { |
140 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
141 | } |
142 | } else { |
143 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
144 | } |
145 | |
146 | /* Compute the URL to forward the user to. */ |
147 | if(isset($rcptemail)) { |
148 | $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress='; |
149 | $redirect_url .= urlencode($rcptemail); |
150 | } else { |
151 | $redirect_url = 'webmail.php'; |
152 | } |
153 | |
154 | /* Send them off to the appropriate page. */ |
155 | header("Location: $redirect_url"); |
7baf86a9 |
156 | |
e0dcff78 |
157 | ?> |