f8acbebb3001d3509ab9a527a6d73410cce8677c
[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 ** $Id$
12 **/
13
14 $rcptaddress = '';
15 if (isset($emailaddress)) {
16 if (stristr($emailaddress, 'mailto:'))
17 $rcptaddress = substr($emailaddress, 7);
18 else
19 $rcptaddress = $emailaddress;
20
21 if (($pos = strpos($rcptaddress, '?')) !== false)
22 {
23 $a = substr($rcptaddress, $pos + 1);
24 $rcptaddress = substr($rcptaddress, 0, $pos);
25 $a = explode('=', $a, 2);
26 if (isset($a[1])) {
27 $name = urldecode($a[0]);
28 $val = urldecode($a[1]);
29 global $$name;
30 $$name = $val;
31 }
32 }
33
34 // At this point, we have parsed a lot of the mailto stuff. Let's
35 // do the rest -- CC, BCC, Subject, Body
36 // Note: They can all be case insensitive
37 foreach ($GLOBALS as $k => $v)
38 {
39 $key = strtolower($k);
40 $value = urlencode($v);
41 if ($key == 'cc')
42 $rcptaddress .= '&send_to_cc=' . $value;
43 elseif ($key == 'bcc')
44 $rcptaddress .= '&send_to_bcc=' . $value;
45 elseif ($key == 'subject')
46 $rcptaddress .= '&subject=' . $value;
47 elseif ($key == 'body')
48 $rcptaddress .= '&body=' . $value;
49 }
50
51 // Double-encode in this fashion to get past redirect.php properly
52 $rcptaddress = urlencode($rcptaddress);
53 }
54
55 require_once('../functions/strings.php');
56 require_once('../config/config.php');
57 require_once('../functions/i18n.php');
58 require_once('../functions/plugin.php');
59
60 // $squirrelmail_language is set by a cookie when the user selects
61 // language and logs out
62 set_up_language($squirrelmail_language, true);
63
64 // Need the base URI to set the cookies. (Same code as in webmail.php)
65 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
66 $base_uri = $regs[1];
67
68 setcookie("username", '', 0, $base_uri);
69 setcookie("key", '', 0, $base_uri);
70 header ("Pragma: no-cache");
71
72 // In case the last session was not terminated properly, make sure
73 // we get a new one.
74 $cookie_params = session_get_cookie_params();
75 setcookie(session_name(),"",0,$cookie_params["domain"].$cookie_params["path"]);
76
77 do_hook('login_cookie');
78 echo "<HTML>";
79 echo "<HEAD><TITLE>";
80 echo $org_name . " - " . _("Login");
81 echo "</TITLE></HEAD>\n";
82 echo "<BODY TEXT=000000 BGCOLOR=#FFFFFF LINK=0000CC VLINK=0000CC ALINK=0000CC>\n";
83 echo "<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
84
85 $username_form_name = 'login_username';
86 $password_form_name = 'secretkey';
87 do_hook('login_top');
88
89 echo "<CENTER><IMG SRC=\"$org_logo\"></CENTER>\n";
90 echo "<CENTER><SMALL>";
91 printf (_("SquirrelMail version %s"), $version);
92 echo "<BR>\n";
93 echo _("By the SquirrelMail Development Team");
94 echo "<BR></SMALL><CENTER>\n";
95 echo "<TABLE COLS=1 WIDTH=350>\n";
96 echo " <TR>\n";
97 echo " <TD BGCOLOR=#DCDCDC>\n";
98 echo " <B><CENTER>";
99 printf (_("%s Login"), $org_name);
100 echo "</CENTER></B>\n";
101 echo " </TD>\n";
102 echo " </TR><TR>\n";
103 echo " <TD BGCOLOR=#FFFFFF>\n";
104 echo " <TABLE COLS=2 WIDTH=100%>\n";
105 echo " <TR>\n";
106 echo " <TD WIDTH=30% ALIGN=right>\n";
107 echo _("Name:");
108 echo " </TD><TD WIDTH=* ALIGN=left>\n";
109 echo " <INPUT TYPE=TEXT NAME=\"$username_form_name\"";
110 if (isset($loginname))
111 echo " value=\"" . htmlspecialchars($loginname) . "\"";
112 echo ">\n";
113 echo " </TD>\n";
114 echo " </TR><TR>\n";
115 echo " <TD WIDTH=30% ALIGN=right>\n";
116 echo _("Password:");
117 echo " </TD><TD WIDTH=* ALIGN=left>\n";
118 echo " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n";
119 echo " </TD>\n";
120 if ($rcptaddress != '') {
121 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
122 }
123 echo " </TR>\n";
124 echo " </TABLE>\n";
125 echo " </TD>\n";
126 echo " </TR><TR>\n";
127 echo " <TD>\n";
128 echo " <CENTER><INPUT TYPE=SUBMIT VALUE=\"";
129 echo _("Login");
130 echo "\"></CENTER>\n";
131 echo " </TD>\n";
132 echo " </TR>\n";
133 echo "</TABLE>\n";
134 echo "<input type=hidden name=just_logged_in value=1>\n";
135 do_hook('login_form');
136 echo "</FORM>\n";
137 do_hook("login_bottom");
138 ?>
139 </BODY>
140 </HTML>
141