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