Warning removal
[squirrelmail.git] / src / login.php
1 <?php
2 /**
3 * login.php -- simple login screen
4 *
5 * Copyright (c) 1999-2001 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
22 if (($pos = strpos($rcptaddress, '?')) !== false) {
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 $$naame = $val;
31 }
32 }
33
34 /* At this point, we have parsed a lot of the mailto stuff. */
35 /* Let's do the rest -- CC, BCC, Subject, Body */
36 /* Note: They can all be case insensitive */
37 foreach ($GLOBALS as $k => $v) {
38 $key = strtolower($k);
39 $value = urlencode($v);
40 if ($key == 'cc') {
41 $rcptaddress .= '&send_to_cc=' . $value;
42 } else if ($key == 'bcc') {
43 $rcptaddress .= '&send_to_bcc=' . $value;
44 } else if ($key == 'subject') {
45 $rcptaddress .= '&subject=' . $value;
46 } else if ($key == 'body') {
47 $rcptaddress .= '&body=' . $value;
48 }
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 require_once('../functions/constants.php');
60
61 /*
62 * $squirrelmail_language is set by a cookie when the user selects
63 * language and logs out
64 */
65 set_up_language($squirrelmail_language, true);
66
67 /* Need the base URI to set the cookies. (Same code as in webmail.php). */
68 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
69 $base_uri = $regs[1];
70 @session_destroy();
71
72 /*
73 * In case the last session was not terminated properly, make sure
74 * we get a new one.
75 */
76 $cookie_params = session_get_cookie_params();
77 setcookie(session_name(),'',0,$cookie_params['path'].$cookie_params['domain']);
78 setcookie('username', '', 0, $base_uri);
79 setcookie('key', '', 0, $base_uri);
80 header ('Pragma: no-cache');
81
82 do_hook('login_cookie');
83
84 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
85 "\n\n" .
86 "<HTML>\n" .
87 "<HEAD>\n";
88
89 if ($theme_css != '') {
90 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
91 }
92
93 /* Output the javascript onload function. */
94 echo "<SCRIPT LANGUAGE=\"JavaScript\">\n" .
95 "<!--\n".
96 " function squirrelmail_loginpage_onload() {\n".
97 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
98 " document.forms[0].elements[0].focus();\n".
99 " }\n".
100 "// -->\n".
101 "</script>\n";
102
103 /* Set the title of this page. */
104 echo "<TITLE>$org_name - " . _("Login") . "</TITLE></HEAD>\n".
105 "<BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#0000CC VLINK=#0000CC ALINK=#0000CC onLoad='squirrelmail_loginpage_onload();'>\n".
106 "<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
107
108 $username_form_name = 'login_username';
109 $password_form_name = 'secretkey';
110 do_hook('login_top');
111
112 $loginname_value = (isset($loginname) ? htmlspecialchars($loginname) : '');
113
114 echo "<CENTER>".
115 " <IMG SRC=\"$org_logo\"><BR>\n".
116 ( $hide_sm_attributions ? '' :
117 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
118 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
119 "</CENTER>\n".
120
121 "<CENTER>\n".
122 "<TABLE COLS=1 WIDTH=350>\n".
123 " <TR><TD BGCOLOR=#DCDCDC>\n".
124 ' <B><CENTER>' . sprintf (_("%s Login"), $org_name) . "</CENTER></B>\n".
125 " </TD></TR>".
126 " <TR><TD BGCOLOR=\"#FFFFFF\"><TABLE COLS=2 WIDTH=\"100%\">\n".
127 " <TR>\n".
128 ' <TD WIDTH=30% ALIGN=right>' . _("Name:") . "</TD>\n".
129 " <TD WIDTH=* ALIGN=left>\n".
130 " <INPUT TYPE=TEXT NAME=\"$username_form_name\" VALUE=\"$loginname_value\">\n".
131 " </TD>\n".
132 " </TR>\n".
133 " <TR>\n".
134 ' <TD WIDTH="30%" ALIGN=right>' . _("Password:") . "</TD>\n".
135 " <TD WIDTH=* ALIGN=left>\n".
136 " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n".
137 " <INPUT TYPE=HIDDEN NAME=\"js_autodetect_results\" VALUE=\"" . SMPREF_JS_OFF . "\">\n".
138 " <INPUT TYPE=HIDDEN NAME=\"just_logged_in\" value=1>\n";
139 if ($rcptaddress != '') {
140 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
141 }
142 echo " </TD>\n".
143 " </TR>\n".
144 " </TABLE></TD></TR>\n".
145 " <TR><TD>\n".
146 ' <CENTER><INPUT TYPE=SUBMIT VALUE="' . _("Login") . "\"></CENTER>\n".
147 " </TD></TR>\n".
148 "</TABLE>\n".
149 "</CENTER>\n";
150
151 do_hook('login_form');
152 echo "</FORM>\n";
153
154 do_hook('login_bottom');
155 echo "</BODY>\n".
156 "</HTML>\n";
157 ?>