Updated documentation, fixed some misspellings
[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($username)) {
27 echo _("You need a valid user and password to access this page!");
28 exit;
29 }
30
31 // Refresh the language cookie.
32 if (isset($squirrelmail_language)) {
33 setcookie("squirrelmail_language", $squirrelmail_language, time()+2592000);
34 }
35
36
37 include ("../config/config.php");
38 include ("../functions/prefs.php");
39 include ("../functions/imap.php");
40 if (!isset($plugin_php))
41 include ("../functions/plugin.php");
42 if (!isset($auth_php))
43 include ("../functions/auth.php");
44 if (!isset($strings_php))
45 include ("../functions/strings.php");
46
47 if (!session_is_registered("user_is_logged_in") || $logged_in != 1) {
48 do_hook ("login_before");
49
50 $onetimepad = OneTimePadCreate(strlen($secretkey));
51 $key = OneTimePadEncrypt($secretkey, $onetimepad);
52 session_register("onetimepad");
53 // verify that username and password are correct
54 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
55 sqimap_logout($imapConnection);
56
57 setcookie("username", $username, 0, $base_uri);
58 setcookie("key", $key, 0, $base_uri);
59 setcookie("logged_in", 1, 0, $base_uri);
60
61 do_hook ("login_verified");
62 }
63
64 session_register ("user_is_logged_in");
65 $user_is_logged_in = true;
66
67 include ("../src/load_prefs.php");
68
69 echo "<html><head>\n";
70 echo "<TITLE>";
71 echo "$org_title";
72 echo "</TITLE>";
73 $ishelp = substr(getenv(REQUEST_URI),-8); // If calling help, set left frame to 300
74 if ($ishelp == "help.php") {
75 echo "<FRAMESET COLS=\"300, *\" NORESIZE=yes BORDER=0>";
76 } else {
77 echo "<FRAMESET COLS=\"$left_size, *\" NORESIZE BORDER=0>";
78 }
79
80 /**
81 There are three ways to call webmail.php
82 1. webmail.php
83 - This just loads the default entry screen.
84 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
85 - This loads the frames starting at the given values.
86 3. webmail.php?right_frame=folders.php
87 - Loads the frames with the Folder options in the right frame.
88
89 This was done to create a pure HTML way of refreshing the folder list since
90 we would like to use as little Javascript as possible.
91 **/
92 if ($right_frame == "right_main.php") {
93 $urlMailbox = urlencode($mailbox);
94 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
95 echo "<FRAME SRC=\"right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage\" NAME=\"right\">";
96 } else if ($right_frame == "options.php") {
97 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
98 echo "<FRAME SRC=\"options.php\" NAME=\"right\">";
99 } else if ($right_frame == "folders.php") {
100 $urlMailbox = urlencode($mailbox);
101 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
102 echo "<FRAME SRC=\"folders.php\" NAME=\"right\">";
103 } else {
104 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
105 if (!isset($just_logged_in)) $just_logged_in = 0;
106 echo "<FRAME SRC=\"right_main.php?just_logged_in=$just_logged_in\" NAME=\"right\">";
107 }
108
109 ?>
110 </FRAMESET>
111 </HEAD></HTML>