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