Removed extra SMALL tags, they were already incased in a
[squirrelmail.git] / src / redirect.php
... / ...
CommitLineData
1<?php
2
3/**
4* redirect.php
5* Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de>
6*
7* Copyright (c) 1999-2004 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* @package squirrelmail
14*/
15
16/** Path for SquirrelMail required files. */
17define('SM_PATH','../');
18
19/* SquirrelMail required files. */
20require_once(SM_PATH . 'functions/global.php');
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');
29
30/* Before starting the session, the base URI must be known. Assuming */
31/* that this file is in the src/ subdirectory (or something). */
32if (!function_exists('sqm_baseuri')){
33 require_once(SM_PATH . 'functions/display_messages.php');
34}
35$base_uri = sqm_baseuri();
36
37header('Pragma: no-cache');
38$location = get_location();
39
40session_set_cookie_params (0, $base_uri);
41sqsession_is_active();
42
43sqsession_unregister ('user_is_logged_in');
44sqsession_register ($base_uri, 'base_uri');
45
46/* get globals we me need */
47sqGetGlobalVar('login_username', $login_username);
48sqGetGlobalVar('secretkey', $secretkey);
49if(!sqGetGlobalVar('squirrelmail_language', $squirrelmail_language) || $squirrelmail_language == '') {
50 $squirrelmail_language = $squirrelmail_default_language;
51}
52if (!sqgetGlobalVar('mailto', $mailto)) {
53 $mailto = '';
54}
55
56/* end of get globals */
57
58set_up_language($squirrelmail_language, true);
59/* Refresh the language cookie. */
60setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,
61 $base_uri);
62
63if (!isset($login_username)) {
64 include_once(SM_PATH . 'functions/display_messages.php' );
65 logout_error( _("You must be logged in to access this page.") );
66 exit;
67}
68
69if (!sqsession_is_registered('user_is_logged_in')) {
70 do_hook ('login_before');
71
72 $onetimepad = OneTimePadCreate(strlen($secretkey));
73 $key = OneTimePadEncrypt($secretkey, $onetimepad);
74 sqsession_register($onetimepad, 'onetimepad');
75
76 /* remove redundant spaces */
77 $login_username = trim($login_username);
78
79 /* Verify that username and password are correct. */
80 if ($force_username_lowercase) {
81 $login_username = strtolower($login_username);
82 }
83
84 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
85
86 $sqimap_capabilities = sqimap_capability($imapConnection);
87 sqsession_register($sqimap_capabilities, 'sqimap_capabilities');
88 $delimiter = sqimap_get_delimiter ($imapConnection);
89
90 sqimap_logout($imapConnection);
91 sqsession_register($delimiter, 'delimiter');
92
93 $username = $login_username;
94 sqsession_register ($username, 'username');
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. */
105sqsession_register ($user_is_logged_in, 'user_is_logged_in');
106sqsession_register ($just_logged_in, 'just_logged_in');
107
108/* parse the accepted content-types of the client */
109$attachment_common_types = array();
110$attachment_common_types_parsed = array();
111sqsession_register($attachment_common_types, 'attachment_common_types');
112sqsession_register($attachment_common_types_parsed, 'attachment_common_types_parsed');
113
114$debug = false;
115
116if ( sqgetGlobalVar('HTTP_ACCEPT', $http_accept, SQ_SERVER) &&
117 !isset($attachment_common_types_parsed[$http_accept]) ) {
118 attachment_common_parse($http_accept, $debug);
119}
120
121/* Complete autodetection of Javascript. */
122checkForJavascript();
123
124/* Compute the URL to forward the user to. */
125$redirect_url = $location . '/webmail.php';
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) {
131 // do not prefix $location here because $session_expired_location is set to PHP_SELF
132 // of the last page
133 $redirect_url = $session_expired_location;
134 } elseif ( strpos($session_expired_location, 'webmail.php') === FALSE ) {
135 $redirect_url = $location.'/webmail.php?right_frame='.urldecode($session_expired_location);
136 }
137 unset($session_expired_location);
138}
139if($mailto != '') {
140 $redirect_url = $location . '/webmail.php?right_frame=compose.php&mailto=';
141 $redirect_url .= $mailto;
142}
143
144/* Write session data and send them off to the appropriate page. */
145session_write_close();
146header("Location: $redirect_url");
147
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;
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 );
162 $types = explode(',', $str);
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 }
173 $_SESSION['attachment_common_types'] = $attachment_common_types;
174}
175
176
177?>