Added auth.php to put authentication functions in one place. Added a
[squirrelmail.git] / src / webmail.php
1 <?php
2 /**
3 ** webmail.php
4 **
5 ** This simply creates the frames.
6 **
7 **/
8
9 session_start();
10
11 if(!isset($username)) {
12 echo _("You need a valid user and password to access this page!");
13 exit;
14 }
15
16 setcookie("username", $username, 0, "/");
17 setcookie("key", $key, 0, "/");
18 setcookie("logged_in", 1, 0, "/");
19
20 // Refresh the language cookie.
21 if (isset($squirrelmail_language)) {
22 setcookie("squirrelmail_language", $squirrelmail_language, time()+2592000);
23 }
24
25 include ("../config/config.php");
26 include ("../functions/prefs.php");
27 include ("../functions/imap.php");
28 if (!isset($plugin_php))
29 include ("../functions/plugin.php");
30 if (!isset($auth_php))
31 include ("../functions/auth.php");
32
33 if (session_is_registered("user_is_logged_in")) {
34 do_hook ("login_before");
35 // verify that username and password are correct
36 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
37 do_hook ("login_verified");
38 }
39
40 session_register ("user_is_logged_in");
41 $user_is_logged_in = true;
42
43 include ("../src/load_prefs.php");
44
45 echo "<html><head>\n";
46 echo "<TITLE>";
47 echo "$org_title";
48 echo "</TITLE>";
49 $ishelp = substr(getenv(REQUEST_URI),-8); // If calling help, set left frame to 300
50 if ($ishelp == "help.php") {
51 echo "<FRAMESET COLS=\"300, *\" NORESIZE BORDER=0>";
52 } else {
53 echo "<FRAMESET COLS=\"$left_size, *\" NORESIZE BORDER=0>";
54 }
55
56 /**
57 There are four ways to call webmail.php
58 1. webmail.php
59 - This just loads the default entry screen.
60 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
61 - This loads the frames starting at the given values.
62 3. webmail.php?right_frame=folders.php
63 - Loads the frames with the Folder options in the right frame.
64 4. webmail.php?right_frame=help.php
65 - Lets the left frame set up different menu for help and calls the right frame.
66
67 This was done to create a pure HTML way of refreshing the folder list since
68 we would like to use as little Javascript as possible.
69 **/
70 if ($right_frame == "right_main.php") {
71 $urlMailbox = urlencode($mailbox);
72 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
73 echo "<FRAME SRC=\"right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage\" NAME=\"right\">";
74 } else if ($right_frame == "folders.php") {
75 $urlMailbox = urlencode($mailbox);
76 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
77 echo "<FRAME SRC=\"folders.php\" NAME=\"right\">";
78 } else if ($right_frame == "help.php") {
79 echo "<FRAME SRC=\"left_help.php\" NAME=\"left\">";
80 echo "<FRAME SRC=\"help.php\" NAME=\"right\">";
81 } else {
82 echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";
83 echo "<FRAME SRC=\"right_main.php\" NAME=\"right\">";
84 }
85
86 ?>
87 </FRAMESET>
88 </HEAD></HTML>