little fix
[squirrelmail.git] / src / webmail.php
1 <?php
2
3 /**
4 ** webmail.php -- Displays the main frameset
5 **
6 ** Copyright (c) 1999-2000 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 **/
14
15 // Before starting the session, the base URI must be known.
16 // Assuming that this file is in the src/ subdirectory (or
17 // something).
18 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
19 $base_uri = $regs[1];
20
21 session_set_cookie_params (0, $base_uri);
22 session_start();
23
24 session_register ("base_uri");
25
26 if (!isset($i18n_php))
27 include ("../functions/i18n.php");
28
29 if(!isset($username)) {
30 set_up_language($squirrelmail_language);
31 echo _("You need a valid user and password to access this page!");
32 exit;
33 }
34
35 // Refresh the language cookie.
36 if (isset($squirrelmail_language)) {
37 setcookie("squirrelmail_language", $squirrelmail_language, time()+2592000);
38 }
39
40 include ("../config/config.php");
41 include ("../functions/prefs.php");
42 include ("../functions/imap.php");
43 if (!isset($plugin_php))
44 include ("../functions/plugin.php");
45 if (!isset($auth_php))
46 include ("../functions/auth.php");
47 if (!isset($strings_php))
48 include ("../functions/strings.php");
49
50 if ($force_username_lowercase)
51 $username = strtolower($username);
52
53 if (!session_is_registered("user_is_logged_in") || $logged_in != 1) {
54 do_hook ("login_before");
55
56 $onetimepad = OneTimePadCreate(strlen($secretkey));
57 $key = OneTimePadEncrypt($secretkey, $onetimepad);
58 session_register("onetimepad");
59 // verify that username and password are correct
60 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
61 sqimap_logout($imapConnection);
62
63 setcookie("username", $username, 0, $base_uri);
64 setcookie("key", $key, 0, $base_uri);
65 setcookie("logged_in", 1, 0, $base_uri);
66
67 do_hook ("login_verified");
68 }
69
70 session_register ("user_is_logged_in");
71 $user_is_logged_in = true;
72
73 include ("../src/load_prefs.php");
74
75 // We'll need this to later have a noframes version
76 set_up_language(getPref($data_dir, $username, "language"));
77
78 echo "<html><head>\n";
79 echo "<TITLE>";
80 echo "$org_title";
81 echo "</TITLE>";
82 $ishelp = substr(getenv(REQUEST_URI),-8); // If calling help, set left frame to 300
83
84 if (ishelp == 'help.php')
85 $bar_size = 300;
86 else
87 $bar_size = $left_size;
88
89 if ($location_of_bar == 'right')
90 {
91 echo "<FRAMESET COLS=\"*, $left_size\" NORESIZE=yes BORDER=0>";
92 } else {
93 echo "<FRAMESET COLS=\"$left_size, *\" NORESIZE BORDER=0>";
94 }
95
96 /**
97 There are three ways to call webmail.php
98 1. webmail.php
99 - This just loads the default entry screen.
100 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
101 - This loads the frames starting at the given values.
102 3. webmail.php?right_frame=folders.php
103 - Loads the frames with the Folder options in the right frame.
104
105 This was done to create a pure HTML way of refreshing the folder list since
106 we would like to use as little Javascript as possible.
107 **/
108 if ($right_frame == "right_main.php") {
109 $urlMailbox = urlencode($mailbox);
110 $right_frame_url = "right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage";
111 } else if ($right_frame == "options.php") {
112 $right_frame_url = "options.php";
113 } else if ($right_frame == "folders.php") {
114 $right_frame_url = "folders.php";
115 } else {
116 if (!isset($just_logged_in)) $just_logged_in = 0;
117 $right_frame_url = "right_main.php?just_logged_in=$just_logged_in";
118 }
119
120 if ($location_of_bar == 'right')
121 {
122 echo "<FRAME SRC=\"$right_frame_url\" NAME=\"right\">";
123 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
124 }
125 else
126 {
127 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
128 echo "<FRAME SRC=\"$right_frame_url\" NAME=\"right\">";
129 }
130
131 ?>
132 </FRAMESET>
133 </HEAD></HTML>