OK, so it wants a trailing slash...
[squirrelmail.git] / src / login.php
1 <?php
2
3 /**
4 * login.php -- simple login screen
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This a simple login screen. Some housekeeping is done to clean
10 * cookies and find language.
11 *
12 * $Id$
13 */
14
15 $rcptaddress = '';
16 if (isset($emailaddress)) {
17 if (stristr($emailaddress, 'mailto:')) {
18 $rcptaddress = substr($emailaddress, 7);
19 } else {
20 $rcptaddress = $emailaddress;
21 }
22
23 if (($pos = strpos($rcptaddress, '?')) !== false) {
24 $a = substr($rcptaddress, $pos + 1);
25 $rcptaddress = substr($rcptaddress, 0, $pos);
26 $a = explode('=', $a, 2);
27 if (isset($a[1])) {
28 $name = urldecode($a[0]);
29 $val = urldecode($a[1]);
30 global $$name;
31 $$name = $val;
32 }
33 }
34
35 /* At this point, we have parsed a lot of the mailto stuff. */
36 /* Let's do the rest -- CC, BCC, Subject, Body */
37 /* Note: They can all be case insensitive */
38 foreach ($GLOBALS as $k => $v) {
39 $key = strtolower($k);
40 $value = urlencode($v);
41 if ($key == 'cc') {
42 $rcptaddress .= '&amp;send_to_cc=' . $value;
43 } else if ($key == 'bcc') {
44 $rcptaddress .= '&amp;send_to_bcc=' . $value;
45 } else if ($key == 'subject') {
46 $rcptaddress .= '&amp;subject=' . $value;
47 } else if ($key == 'body') {
48 $rcptaddress .= '&amp;body=' . $value;
49 }
50 }
51
52 /* Double-encode in this fashion to get past redirect.php properly. */
53 $rcptaddress = urlencode($rcptaddress);
54 }
55
56 require_once('../functions/strings.php');
57 require_once('../config/config.php');
58 require_once('../functions/i18n.php');
59 require_once('../functions/plugin.php');
60 require_once('../functions/constants.php');
61 require_once('../functions/page_header.php');
62
63 /*
64 * $squirrelmail_language is set by a cookie when the user selects
65 * language and logs out
66 */
67 set_up_language($squirrelmail_language, TRUE);
68
69 /**
70 * Find out the base URI to set cookies.
71 */
72 $base_uri = dirname(dirname($PHP_SELF)) . "/";
73 @session_destroy();
74
75 /*
76 * In case the last session was not terminated properly, make sure
77 * we get a new one.
78 */
79 $cookie_params = session_get_cookie_params();
80 setcookie(session_name(), '', 0, $cookie_params['path'],
81 $cookie_params['domain']);
82 setcookie('username', '', 0, $base_uri);
83 setcookie('key', '', 0, $base_uri);
84 header('Pragma: no-cache');
85
86 do_hook('login_cookie');
87
88 /* Output the javascript onload function. */
89
90 $header = "<SCRIPT LANGUAGE=\"JavaScript\">\n" .
91 "<!--\n".
92 " function squirrelmail_loginpage_onload() {\n".
93 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
94 ' document.forms[0].elements[' . (isset($loginname) ? 1 : 0) . "].focus();\n".
95 " }\n".
96 "// -->\n".
97 "</script>\n";
98 $custom_css = 'none';
99 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
100
101 /* Set the title of this page. */
102 echo '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000CC" VLINK="#0000CC" ALINK="#0000CC" onLoad="squirrelmail_loginpage_onload();">'.
103 "\n<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
104
105 $username_form_name = 'login_username';
106 $password_form_name = 'secretkey';
107 do_hook('login_top');
108
109 $loginname_value = (isset($loginname) ? htmlspecialchars($loginname) : '');
110
111 /* Display width and height like good little people */
112 $width_and_height = '';
113 if (isset($org_logo_width) && is_int($org_logo_width) && $org_logo_width>0) {
114 $width_and_height = " WIDTH=\"$org_logo_width\"";
115 }
116 if (isset($org_logo_height) && is_int($org_logo_height) && $org_logo_height>0) {
117 $width_and_height .= " HEIGHT=\"$org_logo_height\"";
118 }
119
120 echo '<CENTER>'.
121 " <IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) .
122 "\"$width_and_height><BR>\n".
123 ( $hide_sm_attributions ? '' :
124 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
125 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
126 "</CENTER>\n".
127
128 "<CENTER>\n".
129 "<TABLE COLS=1 WIDTH=350>\n".
130 " <TR><TD ALIGN=CENTER BGCOLOR=\"#DCDCDC\">\n".
131 ' <B>' . sprintf (_("%s Login"), $org_name) . "</B>\n".
132 " </TD></TR>".
133 " <TR><TD BGCOLOR=\"#FFFFFF\"><TABLE COLS=2 WIDTH=\"100%\">\n".
134 " <TR>\n".
135 ' <TD WIDTH="30%" ALIGN=right>' . _("Name:") . "</TD>\n".
136 " <TD WIDTH=\"*\" ALIGN=left>\n".
137 " <INPUT TYPE=TEXT NAME=\"$username_form_name\" VALUE=\"$loginname_value\">\n".
138 " </TD>\n".
139 " </TR>\n".
140 " <TR>\n".
141 ' <TD WIDTH="30%" ALIGN=right>' . _("Password:") . "</TD>\n".
142 " <TD WIDTH=\"*\" ALIGN=left>\n".
143 " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n".
144 " <INPUT TYPE=HIDDEN NAME=\"js_autodetect_results\" VALUE=\"" . SMPREF_JS_OFF . "\">\n".
145 " <INPUT TYPE=HIDDEN NAME=\"just_logged_in\" value=1>\n";
146 if ($rcptaddress != '') {
147 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
148 }
149 echo " </TD>\n".
150 " </TR>\n".
151 " </TABLE></TD></TR>\n".
152 " <TR><TD>\n".
153 ' <CENTER><INPUT TYPE=SUBMIT VALUE="' . _("Login") . "\"></CENTER>\n".
154 " </TD></TR>\n".
155 "</TABLE>\n".
156 "</CENTER>\n";
157
158 do_hook('login_form');
159 echo "</FORM>\n";
160
161 do_hook('login_bottom');
162 echo "</BODY>\n".
163 "</HTML>\n";
164 ?>