7392739d |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4b4abf93 |
4 | * Prevents users from reposting their form data after a successful logout. |
5 | * |
6 | * Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de> |
7 | * |
47ccfad4 |
8 | * @copyright © 1999-2006 The SquirrelMail Project Team |
4b4abf93 |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
10 | * @version $Id$ |
11 | * @package squirrelmail |
12 | */ |
35586184 |
13 | |
30967a1e |
14 | /** |
15 | * Path for SquirrelMail required files. |
16 | * @ignore |
17 | */ |
86725763 |
18 | define('SM_PATH','../'); |
19 | |
20 | /* SquirrelMail required files. */ |
1e12d1ff |
21 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
22 | require_once(SM_PATH . 'functions/i18n.php'); |
23 | require_once(SM_PATH . 'functions/strings.php'); |
24 | require_once(SM_PATH . 'config/config.php'); |
25 | require_once(SM_PATH . 'functions/prefs.php'); |
26 | require_once(SM_PATH . 'functions/imap.php'); |
27 | require_once(SM_PATH . 'functions/plugin.php'); |
28 | require_once(SM_PATH . 'functions/constants.php'); |
29 | require_once(SM_PATH . 'functions/page_header.php'); |
cb48c245 |
30 | |
5c3b0995 |
31 | /* Before starting the session, the base URI must be known. Assuming */ |
32 | /* that this file is in the src/ subdirectory (or something). */ |
f3bc099d |
33 | $base_uri = sqm_baseuri(); |
5c3b0995 |
34 | |
35 | header('Pragma: no-cache'); |
36 | $location = get_location(); |
37 | |
dce66e00 |
38 | session_set_cookie_params (0, $base_uri); |
748ba6c0 |
39 | sqsession_is_active(); |
5c3b0995 |
40 | |
ad839713 |
41 | sqsession_unregister ('user_is_logged_in'); |
42 | sqsession_register ($base_uri, 'base_uri'); |
5c3b0995 |
43 | |
a32985a5 |
44 | /* get globals we me need */ |
5250f7e7 |
45 | sqGetGlobalVar('login_username', $login_username); |
46 | sqGetGlobalVar('secretkey', $secretkey); |
5250f7e7 |
47 | if(!sqGetGlobalVar('squirrelmail_language', $squirrelmail_language) || $squirrelmail_language == '') { |
134e4174 |
48 | $squirrelmail_language = $squirrelmail_default_language; |
a32985a5 |
49 | } |
c67e4479 |
50 | if (!sqgetGlobalVar('mailto', $mailto)) { |
51 | $mailto = ''; |
52 | } |
5250f7e7 |
53 | |
a32985a5 |
54 | /* end of get globals */ |
55 | |
5c3b0995 |
56 | set_up_language($squirrelmail_language, true); |
57 | /* Refresh the language cookie. */ |
3a1de9f1 |
58 | sqsetcookie('squirrelmail_language', $squirrelmail_language, time()+2592000, |
85b454a0 |
59 | $base_uri); |
5c3b0995 |
60 | |
61 | if (!isset($login_username)) { |
1e12d1ff |
62 | include_once(SM_PATH . 'functions/display_messages.php' ); |
91e0dccc |
63 | logout_error( _("You must be logged in to access this page.") ); |
5c3b0995 |
64 | exit; |
65 | } |
66 | |
d7c82551 |
67 | if (!sqsession_is_registered('user_is_logged_in')) { |
5c3b0995 |
68 | do_hook ('login_before'); |
69 | |
70 | $onetimepad = OneTimePadCreate(strlen($secretkey)); |
71 | $key = OneTimePadEncrypt($secretkey, $onetimepad); |
a32985a5 |
72 | sqsession_register($onetimepad, 'onetimepad'); |
5c3b0995 |
73 | |
fd1b516b |
74 | /* remove redundant spaces */ |
75 | $login_username = trim($login_username); |
76 | |
5c3b0995 |
77 | /* Verify that username and password are correct. */ |
78 | if ($force_username_lowercase) { |
79 | $login_username = strtolower($login_username); |
23d6bd09 |
80 | } |
81 | |
5c3b0995 |
82 | $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); |
44925ab0 |
83 | |
84 | $sqimap_capabilities = sqimap_capability($imapConnection); |
f027a882 |
85 | |
86 | /* Server side sorting control */ |
87 | if (isset($sqimap_capabilities['SORT']) && $sqimap_capabilities['SORT'] == true && |
88 | isset($disable_server_sort) && $disable_server_sort) { |
89 | unset($sqimap_capabilities['SORT']); |
90 | } |
91 | |
92 | /* Thread sort control */ |
93 | if (isset($sqimap_capabilities['THREAD']) && $sqimap_capabilities['THREAD'] == true && |
94 | isset($disable_thread_sort) && $disable_thread_sort) { |
95 | unset($sqimap_capabilities['THREAD']); |
96 | } |
97 | |
44925ab0 |
98 | sqsession_register($sqimap_capabilities, 'sqimap_capabilities'); |
99 | $delimiter = sqimap_get_delimiter ($imapConnection); |
100 | |
5c3b0995 |
101 | sqimap_logout($imapConnection); |
a32985a5 |
102 | sqsession_register($delimiter, 'delimiter'); |
103 | |
5c3b0995 |
104 | $username = $login_username; |
ad839713 |
105 | sqsession_register ($username, 'username'); |
3a1de9f1 |
106 | sqsetcookie('key', $key, false, $base_uri); |
5c3b0995 |
107 | do_hook ('login_verified'); |
108 | |
109 | } |
110 | |
111 | /* Set the login variables. */ |
112 | $user_is_logged_in = true; |
113 | $just_logged_in = true; |
114 | |
115 | /* And register with them with the session. */ |
a32985a5 |
116 | sqsession_register ($user_is_logged_in, 'user_is_logged_in'); |
117 | sqsession_register ($just_logged_in, 'just_logged_in'); |
5c3b0995 |
118 | |
119 | /* parse the accepted content-types of the client */ |
120 | $attachment_common_types = array(); |
121 | $attachment_common_types_parsed = array(); |
a32985a5 |
122 | sqsession_register($attachment_common_types, 'attachment_common_types'); |
123 | sqsession_register($attachment_common_types_parsed, 'attachment_common_types_parsed'); |
5c3b0995 |
124 | |
125 | $debug = false; |
a32985a5 |
126 | |
1e12d1ff |
127 | if ( sqgetGlobalVar('HTTP_ACCEPT', $http_accept, SQ_SERVER) && |
128 | !isset($attachment_common_types_parsed[$http_accept]) ) { |
129 | attachment_common_parse($http_accept, $debug); |
9be8198d |
130 | } |
5c3b0995 |
131 | |
132 | /* Complete autodetection of Javascript. */ |
1a531551 |
133 | checkForJavascript(); |
5c3b0995 |
134 | |
135 | /* Compute the URL to forward the user to. */ |
d7746ca5 |
136 | $redirect_url = $location . '/webmail.php'; |
cab6eaea |
137 | |
138 | if ( sqgetGlobalVar('session_expired_location', $session_expired_location, SQ_SESSION) ) { |
139 | sqsession_unregister('session_expired_location'); |
140 | $compose_new_win = getPref($data_dir, $username, 'compose_new_win', 0); |
141 | if ($compose_new_win) { |
d7746ca5 |
142 | // do not prefix $location here because $session_expired_location is set to PHP_SELF |
143 | // of the last page |
cab6eaea |
144 | $redirect_url = $session_expired_location; |
145 | } elseif ( strpos($session_expired_location, 'webmail.php') === FALSE ) { |
d7746ca5 |
146 | $redirect_url = $location.'/webmail.php?right_frame='.urldecode($session_expired_location); |
8e54a58b |
147 | } |
cab6eaea |
148 | unset($session_expired_location); |
149 | } |
c67e4479 |
150 | if($mailto != '') { |
d7746ca5 |
151 | $redirect_url = $location . '/webmail.php?right_frame=compose.php&mailto='; |
3e56c08d |
152 | $redirect_url .= urlencode($mailto); |
c67e4479 |
153 | } |
177dde45 |
154 | |
7bde5272 |
155 | /* Write session data and send them off to the appropriate page. */ |
156 | session_write_close(); |
5c3b0995 |
157 | header("Location: $redirect_url"); |
7baf86a9 |
158 | |
cab99c3a |
159 | /* --------------------- end main ----------------------- */ |
160 | |
161 | function attachment_common_parse($str, $debug) { |
162 | global $attachment_common_types, $attachment_common_types_parsed; |
163 | |
164 | $attachment_common_types_parsed[$str] = true; |
91e0dccc |
165 | |
166 | /* |
167 | * Replace ", " with "," and explode on that as Mozilla 1.x seems to |
20511953 |
168 | * use "," to seperate whilst IE, and earlier versions of Mozilla use |
169 | * ", " to seperate |
170 | */ |
91e0dccc |
171 | |
20511953 |
172 | $str = str_replace( ', ' , ',' , $str ); |
6c817138 |
173 | $types = explode(',', $str); |
cab99c3a |
174 | |
175 | foreach ($types as $val) { |
176 | // Ignore the ";q=1.0" stuff |
177 | if (strpos($val, ';') !== false) |
178 | $val = substr($val, 0, strpos($val, ';')); |
179 | |
180 | if (! isset($attachment_common_types[$val])) { |
181 | $attachment_common_types[$val] = true; |
182 | } |
183 | } |
39c7209f |
184 | sqsession_register($attachment_common_types, 'attachment_common_types'); |
cab99c3a |
185 | } |
186 | |
f8a1ed5a |
187 | ?> |