6da9abd7c9e46fe0dfd18eb020a47281c3b3c46b
[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 if ($testingcookie != 1){
51 setcookie("TestCookie", "Checking cookies", 0 , $base_uri);
52 header("Location: " . $base_uri . "src/login.php?testingcookie=1");
53 }
54 if(!isset($TestCookie)){
55 $no_cookies = true;
56 } else {
57 // Cookies are enabled... Deleting test cookie.
58 setcookie("TestCookie", "", 0, $base_uri);
59 $no_cookies = false;
60 }
61
62 setcookie("username", "", 0, $base_uri);
63 setcookie("key", "", 0, $base_uri);
64 setcookie("logged_in", 0, 0, $base_uri);
65
66 // In case the last session was not terminated properly, make sure
67 // we get a new one.
68 setcookie("PHPSESSID", "", 0, $base_uri);
69
70 echo "<HTML>";
71 echo "<HEAD><TITLE>";
72 echo $org_name . " - " . _("Login");
73 echo "</TITLE></HEAD>\n";
74 echo "<BODY TEXT=000000 BGCOLOR=#FFFFFF LINK=0000CC VLINK=0000CC ALINK=0000CC>\n";
75 echo "<FORM ACTION=\"webmail.php\" METHOD=\"POST\" NAME=f>\n";
76 echo "<CENTER><IMG SRC=\"$org_logo\"</CENTER>\n";
77 echo "<CENTER><SMALL>";
78 printf (_("SquirrelMail version %s"), $version);
79 echo "<BR>\n";
80 echo _("By the SquirrelMail Development Team");
81 echo "<BR></SMALL><CENTER>\n";
82 echo "<TABLE COLS=1 WIDTH=350>\n";
83 echo " <TR>\n";
84 echo " <TD BGCOLOR=#DCDCDC>\n";
85 echo " <B><CENTER>";
86 printf (_("%s Login"), $org_name);
87 echo "</CENTER></B>\n";
88 echo " </TD>\n";
89 echo " </TR><TR>\n";
90 echo " <TD BGCOLOR=#FFFFFF>\n";
91 echo " <TABLE COLS=2 WIDTH=100%>\n";
92 echo " <TR>\n";
93 echo " <TD WIDTH=30% ALIGN=right>\n";
94 echo _("Name:");
95 echo " </TD><TD WIDTH=* ALIGN=left>\n";
96 echo " <INPUT TYPE=TEXT NAME=username>\n";
97 echo " </TD>\n";
98 echo " </TR><TR>\n";
99 echo " <TD WIDTH=30% ALIGN=right>\n";
100 echo _("Password:");
101 echo " </TD><TD WIDTH=* ALIGN=left>\n";
102 echo " <INPUT TYPE=PASSWORD NAME=secretkey>\n";
103 echo " </TD>\n";
104 echo " </TABLE>\n";
105 echo " </TD>\n";
106 echo " </TR><TR>\n";
107 echo " <TD>\n";
108 echo " <CENTER><INPUT TYPE=SUBMIT VALUE=\"";
109 echo _("Login");
110 echo "\"></CENTER>\n";
111 echo " </TD>\n";
112 echo " </TR>\n";
113 if ($no_cookies){
114 echo " <TR><TD>\n";
115 echo "<FONT COLOR=\"FF0000\"><CENTER>It appears that your browser is not accepting cookies.".
116 " Please make sure you have cookies enabled before proceding.</CENTER></FONT>";
117 echo " </TD></TR>\n";
118 }
119 echo "</TABLE>\n";
120 echo "<input type=hidden name=just_logged_in value=1>\n";
121 echo "</FORM>\n";
122 do_hook("login_bottom");
123 ?>
124 </BODY>
125 </HTML>
126