phpdoc updates
[squirrelmail.git] / src / webmail.php
... / ...
CommitLineData
1<?php
2
3/**
4 * webmail.php -- Displays the main frameset
5 *
6 * Copyright (c) 1999-2004 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. */
18define('SM_PATH','../');
19
20/* SquirrelMail required files. */
21require_once(SM_PATH . 'functions/strings.php');
22require_once(SM_PATH . 'config/config.php');
23require_once(SM_PATH . 'functions/prefs.php');
24require_once(SM_PATH . 'functions/imap.php');
25require_once(SM_PATH . 'functions/plugin.php');
26require_once(SM_PATH . 'functions/i18n.php');
27require_once(SM_PATH . 'functions/auth.php');
28require_once(SM_PATH . 'functions/global.php');
29
30if (!function_exists('sqm_baseuri')){
31 require_once(SM_PATH . 'functions/display_messages.php');
32}
33$base_uri = sqm_baseuri();
34
35sqsession_is_active();
36
37sqgetGlobalVar('username', $username, SQ_SESSION);
38sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
39sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
40
41sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
42
43if ( isset($_SESSION['session_expired_post']) ) {
44 sqsession_unregister('session_expired_post');
45}
46if(!sqgetGlobalVar('mailto', $mailto)) {
47 $mailto = '';
48}
49
50is_logged_in();
51
52do_hook('webmail_top');
53
54/**
55 * We'll need this to later have a noframes version
56 *
57 * Check if the user has a language preference, but no cookie.
58 * Send him a cookie with his language preference, if there is
59 * such discrepancy.
60 */
61$my_language = getPref($data_dir, $username, 'language');
62if ($my_language != $squirrelmail_language) {
63 setcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
64}
65
66$err=set_up_language(getPref($data_dir, $username, 'language'));
67
68$output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n".
69 "<html><head>\n" .
70 "<title>$org_title</title>\n".
71 "</head>";
72
73// Japanese translation used without mbstring support
74if ($err==2) {
75 echo $output.
76 "<body>\n".
77 "<p>You need to have php4 installed with the multibyte string function \n".
78 "enabled (using configure option --enable-mbstring).</p>\n".
79 "<p>System assumed that you accidently switched to Japanese translation \n".
80 "and reverted your language preference to English.</p>\n".
81 "<p>Please refresh this page in order to use webmail.</p>\n".
82 "</body></html>";
83 return;
84}
85
86$left_size = getPref($data_dir, $username, 'left_size');
87$location_of_bar = getPref($data_dir, $username, 'location_of_bar');
88
89if (isset($languages[$squirrelmail_language]['DIR']) &&
90 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
91 $temp_location_of_bar = 'right';
92} else {
93 $temp_location_of_bar = 'left';
94}
95
96if ($location_of_bar == '') {
97 $location_of_bar = $temp_location_of_bar;
98}
99$temp_location_of_bar = '';
100
101if ($left_size == "") {
102 if (isset($default_left_size)) {
103 $left_size = $default_left_size;
104 }
105 else {
106 $left_size = 200;
107 }
108}
109
110if ($location_of_bar == 'right') {
111 $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
112}
113else {
114 $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
115}
116
117/*
118 * There are three ways to call webmail.php
119 * 1. webmail.php
120 * - This just loads the default entry screen.
121 * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
122 * - This loads the frames starting at the given values.
123 * 3. webmail.php?right_frame=folders.php
124 * - Loads the frames with the Folder options in the right frame.
125 *
126 * This was done to create a pure HTML way of refreshing the folder list since
127 * we would like to use as little Javascript as possible.
128 */
129if (!isset($right_frame)) {
130 $right_frame = '';
131}
132if ($right_frame == 'right_main.php') {
133 $urlMailbox = urlencode($mailbox);
134 $right_frame_url =
135 "right_main.php?mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage";
136} elseif ($right_frame == 'options.php') {
137 $right_frame_url = 'options.php';
138} elseif ($right_frame == 'folders.php') {
139 $right_frame_url = 'folders.php';
140} elseif ($right_frame == 'compose.php') {
141 $right_frame_url = 'compose.php?' . $mailto;
142} else if ($right_frame == '') {
143 $right_frame_url = 'right_main.php';
144} else {
145 $right_frame_url = $right_frame;
146}
147
148$left_frame = '<frame src="left_main.php" name="left" frameborder="1" title="'.
149 _("Folder List") ."\" />\n";
150$right_frame = '<frame src="'.$right_frame_url.'" name="right" frameborder="1" title="'.
151 _("Message List") ."\" />\n";
152
153if ($location_of_bar == 'right') {
154 $output .= $right_frame . $left_frame;
155}
156else {
157 $output .= $left_frame . $right_frame;
158}
159$ret = concat_hook_function('webmail_bottom', $output);
160if($ret != '') {
161 $output = $ret;
162}
163echo $output;
164?>
165</frameset>
166</html>