86ac26545285f96b3590bcab58dc3a1c6497abb5
[squirrelmail.git] / src / webmail.php
1 <?php
2
3 /**
4 * webmail.php -- Displays the main frameset
5 *
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 *
10 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @version $Id$
13 * @package squirrelmail
14 */
15
16 /**
17 * Path for SquirrelMail required files.
18 * @ignore
19 */
20 define('SM_PATH','../');
21
22 /* SquirrelMail required files. */
23 require_once(SM_PATH . 'functions/global.php');
24 require_once(SM_PATH . 'functions/strings.php');
25 require_once(SM_PATH . 'config/config.php');
26 require_once(SM_PATH . 'functions/prefs.php');
27 require_once(SM_PATH . 'functions/imap.php');
28 require_once(SM_PATH . 'functions/plugin.php');
29 require_once(SM_PATH . 'functions/i18n.php');
30 require_once(SM_PATH . 'functions/auth.php');
31
32 $base_uri = sqm_baseuri();
33
34 sqsession_is_active();
35
36 sqgetGlobalVar('username', $username, SQ_SESSION);
37 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
38 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
39
40 if (sqgetGlobalVar('sort', $sort)) {
41 $sort = (int) $sort;
42 }
43
44 if (sqgetGlobalVar('startMessage', $startMessage)) {
45 $startMessage = (int) $startMessage;
46 }
47
48 if (!sqgetGlobalVar('mailbox', $mailbox)) {
49 $mailbox = 'INBOX';
50 }
51
52 sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
53
54 if ( isset($_SESSION['session_expired_post']) ) {
55 sqsession_unregister('session_expired_post');
56 }
57 if(!sqgetGlobalVar('mailto', $mailto)) {
58 $mailto = '';
59 }
60
61 is_logged_in();
62
63 do_hook('webmail_top');
64
65 /**
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 */
72 $my_language = getPref($data_dir, $username, 'language');
73 if ($my_language != $squirrelmail_language) {
74 sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
75 }
76
77 $err=set_up_language(getPref($data_dir, $username, 'language'));
78
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".
81 "<html><head>\n" .
82 "<meta name=\"robots\" content=\"noindex,nofollow\">\n" .
83 "<title>$org_title</title>\n".
84 "</head>";
85
86 // Japanese translation used without mbstring support
87 if ($err==2) {
88 echo $output.
89 "<body>\n".
90 "<p>You need to have PHP installed with the multibyte string function \n".
91 "enabled (using configure option --enable-mbstring).</p>\n".
92 "<p>System assumed that you accidently switched to Japanese translation \n".
93 "and reverted your language preference to English.</p>\n".
94 "<p>Please refresh this page in order to use webmail.</p>\n".
95 "</body></html>";
96 return;
97 }
98
99 $left_size = getPref($data_dir, $username, 'left_size');
100 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
101
102 if (isset($languages[$squirrelmail_language]['DIR']) &&
103 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
104 $temp_location_of_bar = 'right';
105 } else {
106 $temp_location_of_bar = 'left';
107 }
108
109 if ($location_of_bar == '') {
110 $location_of_bar = $temp_location_of_bar;
111 }
112 $temp_location_of_bar = '';
113
114 if ($left_size == "") {
115 if (isset($default_left_size)) {
116 $left_size = $default_left_size;
117 }
118 else {
119 $left_size = 200;
120 }
121 }
122
123 if ($location_of_bar == 'right') {
124 $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
125 }
126 else {
127 $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
128 }
129
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.
141 *
142 * The test for // should catch any attempt to include off-site webpages into
143 * our frameset.
144 */
145
146 if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
147 $right_frame = '';
148 }
149
150 if ( strpos($right_frame,'?') ) {
151 $right_frame_file = substr($right_frame,0,strpos($right_frame,'?'));
152 } else {
153 $right_frame_file = $right_frame;
154 }
155
156 switch($right_frame) {
157 case 'right_main.php':
158 $right_frame_url = "right_main.php?mailbox=".urlencode($mailbox)
159 . (!empty($sort)?"&amp;sort=$sort":'')
160 . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
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 }
178
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
184 if ($location_of_bar == 'right') {
185 $output .= $right_frame . $left_frame;
186 }
187 else {
188 $output .= $left_frame . $right_frame;
189 }
190 $ret = concat_hook_function('webmail_bottom', $output);
191 if($ret != '') {
192 $output = $ret;
193 }
194 echo $output;
195
196 ?>
197 </frameset>
198 </html>