Added encryption of the password before it is stored in a cookie.
[squirrelmail.git] / src / login.php
1 <?php
2 /**
3 ** login.php -- simple login screen
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** This a simple login screen. Some housekeeping is done to clean
9 ** cookies and find language.
10 **
11 **/
12
13 if (!isset($config_php))
14 include("../config/config.php");
15 if (!isset($strings_php))
16 include("../functions/strings.php");
17 if (!isset($i18n_php))
18 include("../functions/i18n.php");
19 if (!isset($plugin_php))
20 include("../functions/plugin.php");
21
22 // let's check to see if they compiled with gettext support
23 if (!function_exists("_")) {
24 function _($string) {
25 return $string;
26 }
27 } else {
28 // $squirrelmail_language is set by a cookie when the user selects
29 // language and logs out
30
31 // Use HTTP content language negotiation if cookie not set
32 if (!isset($squirrelmail_language) && isset($HTTP_ACCEPT_LANGUAGE)) {
33 $squirrelmail_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
34 }
35
36 if (isset($squirrelmail_language)) {
37 if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
38 putenv("LC_ALL=".$squirrelmail_language);
39 bindtextdomain("squirrelmail", "../locale/");
40 textdomain("squirrelmail");
41 header ("Content-Type: text/html; charset=".$languages[$squirrelmail_language]["CHARSET"]);
42 }
43 }
44 }
45
46 // Need the base URI to set the cookies. (Same code as in webmail.php)
47 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
48 $base_uri = $regs[1];
49
50 setcookie("username", "", 0, $base_uri);
51 setcookie("key", "", 0, $base_uri);
52 setcookie("logged_in", 0, 0, $base_uri);
53
54 // In case the last session was not terminated properly, make sure
55 // we get a new one.
56 setcookie("PHPSESSID", "", 0, $base_uri);
57
58 echo "<HTML>";
59 echo "<HEAD><TITLE>";
60 echo $org_name . " - " . _("Login");
61 echo "</TITLE></HEAD>\n";
62 echo "<BODY TEXT=000000 BGCOLOR=#FFFFFF LINK=0000CC VLINK=0000CC ALINK=0000CC>\n";
63
64 echo "<FORM ACTION=\"webmail.php\" METHOD=\"POST\" NAME=f>\n";
65 echo "<CENTER><IMG SRC=\"$org_logo\"</CENTER>\n";
66 echo "<CENTER><SMALL>";
67 printf (_("SquirrelMail version %s"), $version);
68 echo "<BR>\n";
69 echo _("By the SquirrelMail Development Team");
70 echo "<BR></SMALL><CENTER>\n";
71 echo "<TABLE COLS=1 WIDTH=350>\n";
72 echo " <TR>\n";
73 echo " <TD BGCOLOR=#DCDCDC>\n";
74 echo " <B><CENTER>";
75 printf (_("%s Login"), $org_name);
76 echo "</CENTER></B>\n";
77 echo " </TD>\n";
78 echo " </TR><TR>\n";
79 echo " <TD BGCOLOR=#FFFFFF>\n";
80 echo " <TABLE COLS=2 WIDTH=100%>\n";
81 echo " <TR>\n";
82 echo " <TD WIDTH=30% ALIGN=right>\n";
83 echo _("Name:");
84 echo " </TD><TD WIDTH=* ALIGN=left>\n";
85 echo " <INPUT TYPE=TEXT NAME=username>\n";
86 echo " </TD>\n";
87 echo " </TR><TR>\n";
88 echo " <TD WIDTH=30% ALIGN=right>\n";
89 echo _("Password:");
90 echo " </TD><TD WIDTH=* ALIGN=left>\n";
91 echo " <INPUT TYPE=PASSWORD NAME=secretkey>\n";
92 echo " </TD>\n";
93 echo " </TABLE>\n";
94 echo " </TD>\n";
95 echo " </TR><TR>\n";
96 echo " <TD>\n";
97 echo " <CENTER><INPUT TYPE=SUBMIT VALUE=\"";
98 echo _("Login");
99 echo "\"></CENTER>\n";
100 echo " </TD>\n";
101 echo " </TR>\n";
102 echo "</TABLE>\n";
103 echo "<input type=hidden name=just_logged_in value=1>\n";
104 echo "</FORM>\n";
105 do_hook("login_bottom");
106 ?>
107 </BODY>
108 </HTML>
109