Fixed some problems with cookies bein set wrong when logging in/out.
[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
20 // let's check to see if they compiled with gettext support
21 if (!function_exists("_")) {
22 function _($string) {
23 return $string;
24 }
25 } else {
26 // $squirrelmail_language is set by a cookie when the user selects
27 // language and logs out
28
29 // Use HTTP content language negotiation if cookie not set
30 if (!isset($squirrelmail_language) && isset($HTTP_ACCEPT_LANGUAGE)) {
31 $squirrelmail_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
32 }
33
34 if (isset($squirrelmail_language)) {
35 if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
36 putenv("LC_ALL=".$squirrelmail_language);
37 bindtextdomain("squirrelmail", "../locale/");
38 textdomain("squirrelmail");
39 header ("Content-Type: text/html; charset=".$languages[$squirrelmail_language]["CHARSET"]);
40 }
41 }
42 }
43
44 // Need the base URI to set the cookies. (Same code as in webmail.php)
45 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
46 $base_uri = $regs[1];
47
48 setcookie("username", "", 0, $base_uri);
49 setcookie("key", "", 0, $base_uri);
50 setcookie("logged_in", 0, 0, $base_uri);
51
52 // In case the last session was not terminated properly, make sure
53 // we get a new one.
54 setcookie("PHPSESSID", "", 0, $base_uri);
55
56 echo "<HTML>";
57 echo "<HEAD><TITLE>";
58 echo _("SquirrelMail Login");
59 echo "</TITLE></HEAD>\n";
60 echo "<BODY TEXT=000000 BGCOLOR=#FFFFFF LINK=0000CC VLINK=0000CC ALINK=0000CC>\n";
61
62 echo "<FORM ACTION=\"webmail.php\" METHOD=\"POST\" NAME=f>\n";
63 echo "<CENTER><IMG SRC=\"$org_logo\"</CENTER>\n";
64 echo "<CENTER><SMALL>";
65 printf (_("SquirrelMail version %s"), $version);
66 echo "<BR>\n";
67 echo _("By the SquirrelMail Development Team");
68 echo "<BR></SMALL><CENTER>\n";
69 echo "<TABLE COLS=1 WIDTH=350>\n";
70 echo " <TR>\n";
71 echo " <TD BGCOLOR=#DCDCDC>\n";
72 echo " <B><CENTER>";
73 printf (_("%s Login"), $org_name);
74 echo "</CENTER></B>\n";
75 echo " </TD>\n";
76 echo " </TR><TR>\n";
77 echo " <TD BGCOLOR=#FFFFFF>\n";
78 echo " <TABLE COLS=2 WIDTH=100%>\n";
79 echo " <TR>\n";
80 echo " <TD WIDTH=30% ALIGN=right>\n";
81 echo _("Name:");
82 echo " </TD><TD WIDTH=* ALIGN=left>\n";
83 echo " <INPUT TYPE=TEXT NAME=username>\n";
84 echo " </TD>\n";
85 echo " </TR><TR>\n";
86 echo " <TD WIDTH=30% ALIGN=right>\n";
87 echo _("Password:");
88 echo " </TD><TD WIDTH=* ALIGN=left>\n";
89 echo " <INPUT TYPE=PASSWORD NAME=key>\n";
90 echo " </TD>\n";
91 echo " </TABLE>\n";
92 echo " </TD>\n";
93 echo " </TR><TR>\n";
94 echo " <TD>\n";
95 echo " <CENTER><INPUT TYPE=SUBMIT VALUE=\"";
96 echo _("Login");
97 echo "\"></CENTER>\n";
98 echo " </TD>\n";
99 echo " </TR>\n";
100 echo "</TABLE>\n";
101 echo "</FORM>\n";
102 ?>
103 </BODY>
104 </HTML>
105