Added support for using Squirrelmail without frames
[squirrelmail.git] / src / webmail.php
1 <?php
2
3 /**
4 * webmail.php -- Displays the main frameset
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail development team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file generates the main frameset. The files that are
10 * shown can be given as parameters. If the user is not logged in
11 * this file will verify username and password.
12 *
13 * $Id$
14 * @package squirrelmail
15 */
16
17 /** Path for SquirrelMail required files. */
18 define('SM_PATH','../');
19
20 /* SquirrelMail required files. */
21 require_once(SM_PATH . 'functions/strings.php');
22 require_once(SM_PATH . 'config/config.php');
23 require_once(SM_PATH . 'functions/prefs.php');
24 require_once(SM_PATH . 'functions/imap.php');
25 require_once(SM_PATH . 'functions/plugin.php');
26 require_once(SM_PATH . 'functions/i18n.php');
27 require_once(SM_PATH . 'functions/auth.php');
28 require_once(SM_PATH . 'functions/global.php');
29
30 if (!function_exists('sqm_baseuri')){
31 require_once(SM_PATH . 'functions/display_messages.php');
32 }
33 $base_uri = sqm_baseuri();
34
35 sqsession_is_active();
36
37 sqgetGlobalVar('username', $username, SQ_SESSION);
38 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
39 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
40 sqgetGlobalVar('use_frames', $use_frames, SQ_COOKIE);
41 sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
42
43 if ( isset($_SESSION['session_expired_post']) ) {
44 sqsession_unregister('session_expired_post');
45 }
46 global $plugins;
47
48 switch ($allow_frames) {
49 case 4: // if $use_frames unset, fall through to case 2
50 if (isset($use_frames))
51 break;
52 case 2: // Do not use frames
53 $use_frames = 0;
54 break;
55 case 3: // if $use_frames unset, fall through to case 1
56 if (isset($use_frames))
57 break;
58 default: // default is also to use frames
59 case 1: // use frames
60 $use_frames = 1;
61 break;
62 }
63
64 if(!sqgetGlobalVar('mailto', $mailto)) {
65 $mailto = '';
66 }
67
68 is_logged_in();
69
70 do_hook('webmail_top');
71
72 /**
73 * We'll need this to later have a noframes version
74 *
75 * Check if the user has a language preference, but no cookie.
76 * Send him a cookie with his language preference, if there is
77 * such discrepancy.
78 */
79 $my_language = getPref($data_dir, $username, 'language');
80 if ($my_language != $squirrelmail_language) {
81 setcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
82 }
83
84 set_up_language(getPref($data_dir, $username, 'language'));
85
86 if (isset($use_frames) && !$use_frames) {
87 if (!isset($right_frame))
88 $right_frame = '';
89 if ($right_frame == 'right_main.php') {
90 $urlMailbox = urlencode($mailbox);
91 $right_frame_url = "right_main.php?mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage";
92 } elseif ($right_frame == 'options.php') {
93 $right_frame_url = 'options.php';
94 } elseif ($right_frame == 'folders.php') {
95 $right_frame_url = 'folders.php';
96 } else if ($right_frame == '') {
97 $right_frame_url = 'right_main.php';
98 } else {
99 $right_frame_url = $right_frame;
100 }
101 header("Location: $right_frame_url");
102 }
103
104
105 echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n".
106 "<html><head>\n" .
107 "<title>$org_title</title>\n".
108 "</head>";
109
110 $left_size = getPref($data_dir, $username, 'left_size');
111 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
112
113 if (isset($languages[$squirrelmail_language]['DIR']) &&
114 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
115 $temp_location_of_bar = 'right';
116 } else {
117 $temp_location_of_bar = 'left';
118 }
119
120 if ($location_of_bar == '') {
121 $location_of_bar = $temp_location_of_bar;
122 }
123 $temp_location_of_bar = '';
124
125 if ($left_size == "") {
126 if (isset($default_left_size)) {
127 $left_size = $default_left_size;
128 }
129 else {
130 $left_size = 200;
131 }
132 }
133
134 if ($location_of_bar == 'right') {
135 echo "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
136 }
137 else {
138 echo "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
139 }
140
141 /*
142 * There are three ways to call webmail.php
143 * 1. webmail.php
144 * - This just loads the default entry screen.
145 * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
146 * - This loads the frames starting at the given values.
147 * 3. webmail.php?right_frame=folders.php
148 * - Loads the frames with the Folder options in the right frame.
149 *
150 * This was done to create a pure HTML way of refreshing the folder list since
151 * we would like to use as little Javascript as possible.
152 */
153 if (!isset($right_frame)) {
154 $right_frame = '';
155 }
156 if ($right_frame == 'right_main.php') {
157 $urlMailbox = urlencode($mailbox);
158 $right_frame_url =
159 "right_main.php?mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage";
160 } elseif ($right_frame == 'options.php') {
161 $right_frame_url = 'options.php';
162 } elseif ($right_frame == 'folders.php') {
163 $right_frame_url = 'folders.php';
164 } elseif ($right_frame == 'compose.php') {
165 $right_frame_url = 'compose.php?' . $mailto;
166 } else if ($right_frame == '') {
167 $right_frame_url = 'right_main.php';
168 } else {
169 $right_frame_url = $right_frame;
170 }
171
172 $left_frame = '<frame src="left_main.php" name="left" frameborder="1" title="'.
173 _("Folder List") ."\" />\n";
174 $right_frame = '<frame src="'.$right_frame_url.'" name="right" frameborder="1" title="'.
175 _("Message List") ."\" />\n";
176
177 if ($location_of_bar == 'right') {
178 echo $right_frame . $left_frame;
179 }
180 else {
181 echo $left_frame . $right_frame;
182 }
183 do_hook('webmail_bottom');
184 ?>
185 </frameset>
186 </html>