Adding template for error box.
[squirrelmail.git] / src / webmail.php
CommitLineData
59177427 1<?php
c6d6fe73 2
864b1c33 3/**
15e6162e 4 * webmail.php -- Displays the main frameset
5 *
15e6162e 6 * This file generates the main frameset. The files that are
7 * shown can be given as parameters. If the user is not logged in
8 * this file will verify username and password.
9 *
47ccfad4 10 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
30967a1e 12 * @version $Id$
8f6f9ba5 13 * @package squirrelmail
15e6162e 14 */
21c3249f 15
30967a1e 16/**
17 * Path for SquirrelMail required files.
18 * @ignore
19 */
86725763 20define('SM_PATH','../');
21
22/* SquirrelMail required files. */
434d4114 23require_once(SM_PATH . 'functions/global.php');
86725763 24require_once(SM_PATH . 'functions/strings.php');
25require_once(SM_PATH . 'config/config.php');
26require_once(SM_PATH . 'functions/prefs.php');
27require_once(SM_PATH . 'functions/imap.php');
28require_once(SM_PATH . 'functions/plugin.php');
29require_once(SM_PATH . 'functions/i18n.php');
30require_once(SM_PATH . 'functions/auth.php');
245a6892 31
f3bc099d 32$base_uri = sqm_baseuri();
88fa922a 33
748ba6c0 34sqsession_is_active();
a32985a5 35
f38b7cf0 36sqgetGlobalVar('username', $username, SQ_SESSION);
37sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
38sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
dcc1cc82 39
ef8d36ad 40if (sqgetGlobalVar('sort', $sort)) {
41 $sort = (int) $sort;
42}
43
44if (sqgetGlobalVar('startMessage', $startMessage)) {
45 $startMessage = (int) $startMessage;
46}
47
a2b193bc 48if (!sqgetGlobalVar('mailbox', $mailbox)) {
ef8d36ad 49 $mailbox = 'INBOX';
50}
51
f38b7cf0 52sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
53
db6a9192 54if ( isset($_SESSION['session_expired_post']) ) {
55 sqsession_unregister('session_expired_post');
56}
c67e4479 57if(!sqgetGlobalVar('mailto', $mailto)) {
58 $mailto = '';
59}
a32985a5 60
864b1c33 61is_logged_in();
1b187352 62
148ee1ef 63do_hook('webmail_top');
64
15e6162e 65/**
864b1c33 66 * We'll need this to later have a noframes version
67 *
68 * Check if the user has a language preference, but no cookie.
69 * Send him a cookie with his language preference, if there is
70 * such discrepancy.
71 */
871ab9eb 72$my_language = getPref($data_dir, $username, 'language');
864b1c33 73if ($my_language != $squirrelmail_language) {
3a1de9f1 74 sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
864b1c33 75}
cf47d363 76
53da506b 77$err=set_up_language(getPref($data_dir, $username, 'language'));
441f2d33 78
151562a7 79$output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"\n".
80 " \"http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd\">\n".
0e3b9a5a 81 "<html><head>\n" .
f8a1ed5a 82 "<meta name=\"robots\" content=\"noindex,nofollow\">\n" .
0e3b9a5a 83 "<title>$org_title</title>\n".
84 "</head>";
65c3ec94 85
53da506b 86// Japanese translation used without mbstring support
87if ($err==2) {
0e3b9a5a 88 echo $output.
89 "<body>\n".
238d4cfc 90 "<p>You need to have PHP installed with the multibyte string function \n".
134e4174 91 "enabled (using configure option --enable-mbstring).</p>\n".
92 "<p>System assumed that you accidently switched to Japanese translation \n".
53da506b 93 "and reverted your language preference to English.</p>\n".
134e4174 94 "<p>Please refresh this page in order to use webmail.</p>\n".
95 "</body></html>";
53da506b 96 return;
97}
98
871ab9eb 99$left_size = getPref($data_dir, $username, 'left_size');
100$location_of_bar = getPref($data_dir, $username, 'location_of_bar');
fab3baa6 101
0c660770 102if (isset($languages[$squirrelmail_language]['DIR']) &&
103 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
fab3baa6 104 $temp_location_of_bar = 'right';
105} else {
106 $temp_location_of_bar = 'left';
107}
108
864b1c33 109if ($location_of_bar == '') {
fab3baa6 110 $location_of_bar = $temp_location_of_bar;
864b1c33 111}
fab3baa6 112$temp_location_of_bar = '';
113
864b1c33 114if ($left_size == "") {
115 if (isset($default_left_size)) {
f740c049 116 $left_size = $default_left_size;
864b1c33 117 }
118 else {
119 $left_size = 200;
120 }
65c3ec94 121}
122
864b1c33 123if ($location_of_bar == 'right') {
0e3b9a5a 124 $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
864b1c33 125}
126else {
0e3b9a5a 127 $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
864b1c33 128}
ad6787f0 129
864b1c33 130/*
131 * There are three ways to call webmail.php
132 * 1. webmail.php
133 * - This just loads the default entry screen.
134 * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
135 * - This loads the frames starting at the given values.
136 * 3. webmail.php?right_frame=folders.php
137 * - Loads the frames with the Folder options in the right frame.
138 *
139 * This was done to create a pure HTML way of refreshing the folder list since
140 * we would like to use as little Javascript as possible.
0a03f924 141 *
142 * The test for // should catch any attempt to include off-site webpages into
143 * our frameset.
864b1c33 144 */
f3fa1c10 145
0a03f924 146if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
793cc001 147 $right_frame = '';
91e0dccc 148}
f3fa1c10 149
9a186afe 150if ( strpos($right_frame,'?') ) {
151 $right_frame_file = substr($right_frame,0,strpos($right_frame,'?'));
152} else {
153 $right_frame_file = $right_frame;
154}
155
02d8345e 156switch($right_frame) {
157 case 'right_main.php':
158 $right_frame_url = "right_main.php?mailbox=".urlencode($mailbox)
ef8d36ad 159 . (!empty($sort)?"&amp;sort=$sort":'')
160 . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
02d8345e 161 break;
162 case 'options.php':
163 $right_frame_url = 'options.php';
164 break;
165 case 'folders.php':
166 $right_frame_url = 'folders.php';
167 break;
168 case 'compose.php':
169 $right_frame_url = 'compose.php?' . $mailto;
170 break;
171 case '':
172 $right_frame_url = 'right_main.php';
173 break;
174 default:
175 $right_frame_url = urlencode($right_frame);
176 break;
177}
9a732bb6 178
da9a8410 179$left_frame = '<frame src="left_main.php" name="left" frameborder="1" title="'.
180 _("Folder List") ."\" />\n";
181$right_frame = '<frame src="'.$right_frame_url.'" name="right" frameborder="1" title="'.
182 _("Message List") ."\" />\n";
183
864b1c33 184if ($location_of_bar == 'right') {
0e3b9a5a 185 $output .= $right_frame . $left_frame;
864b1c33 186}
187else {
0e3b9a5a 188 $output .= $left_frame . $right_frame;
864b1c33 189}
0e3b9a5a 190$ret = concat_hook_function('webmail_bottom', $output);
191if($ret != '') {
192 $output = $ret;
193}
194echo $output;
a2b193bc 195
ad6787f0 196?>
d68323ff 197</frameset>
0a03f924 198</html>