bugfix
[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 require_once('../functions/html.php');
63
64 /*
65 * $squirrelmail_language is set by a cookie when the user selects
66 * language and logs out
67 */
68 set_up_language($squirrelmail_language, TRUE);
69
70 /**
71 * Find out the base URI to set cookies.
72 */
73 if (!function_exists('sqm_baseuri')){
74 require_once('../functions/display_messages.php');
75 }
76 $base_uri = sqm_baseuri();
77 @session_destroy();
78
79 /*
80 * In case the last session was not terminated properly, make sure
81 * we get a new one.
82 */
83 $cookie_params = session_get_cookie_params();
84 setcookie(session_name(), '', 0, $cookie_params['path'],
85 $cookie_params['domain']);
86 setcookie('username', '', 0, $base_uri);
87 setcookie('key', '', 0, $base_uri);
88 header('Pragma: no-cache');
89
90 do_hook('login_cookie');
91
92 /* Output the javascript onload function. */
93
94 $header = "<SCRIPT LANGUAGE=\"JavaScript\" type=\"text/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[' . (isset($loginname) ? 1 : 0) . "].focus();\n".
99 " }\n".
100 "// -->\n".
101 "</script>\n";
102 $custom_css = 'none';
103 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
104
105 /* Set the title of this page. */
106 echo '<body text="#000000" bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="squirrelmail_loginpage_onload();">';
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 /* Display width and height like good little people */
115 $width_and_height = '';
116 if (isset($org_logo_width) && is_int($org_logo_width) && $org_logo_width>0) {
117 $width_and_height = " width=\"$org_logo_width\"";
118 }
119 if (isset($org_logo_height) && is_int($org_logo_height) && $org_logo_height>0) {
120 $width_and_height .= " height=\"$org_logo_height\"";
121 }
122
123 $rcptaddress_input = '';
124 if ($rcptaddress != '') {
125 $rcptaddress_input = '<input type="hidden" name="rcptemail" value="htmlspecialchars(' . $rcptaddress . ')">';
126 }
127
128 echo "\n" . '<form action="redirect.php" method="post">' . "\n" .
129 html_tag( 'table',
130 html_tag( 'tr',
131 html_tag( 'td',
132 '<center>'.
133 '<img src="' . $org_logo . '" alt="' . sprintf(_("%s Logo"), $org_name) .'"' .
134 $width_and_height .'><br>' . "\n".
135 ( $hide_sm_attributions ? '' :
136 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br>' ."\n".
137 ' ' . _("By the SquirrelMail Development Team") . '<br></small>' . "\n" ) .
138 "<br>\n" .
139 html_tag( 'table',
140 html_tag( 'tr',
141 html_tag( 'td',
142 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
143 'center', '#DCDCDC' )
144 ) .
145 html_tag( 'tr',
146 html_tag( 'td', "\n" .
147 html_tag( 'table',
148 html_tag( 'tr',
149 html_tag( 'td',
150 _("Name:") ,
151 'right', '', 'width="30%"' ) .
152 html_tag( 'td',
153 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'">' ,
154 'left', '', 'width="*"' )
155 ) . "\n" .
156 html_tag( 'tr',
157 html_tag( 'td',
158 _("Password:") ,
159 'right', '', 'width="30%"' ) .
160 html_tag( 'td',
161 '<input type="password" name="' . $password_form_name . '">' . "\n" .
162 '<input type=hidden name="js_autodetect_results" value="SMPREF_JS_OFF">' . "\n" .
163 '<input type=hidden name="just_logged_in" value=1>' . "\n" .
164 $rcptaddress_input . "\n" ,
165 'left', '', 'width="*"' )
166 ) ,
167 'center', '#ffffff', 'border="0" cols="2" width="100%"' ) ,
168 'left', '#FFFFFF' )
169 ) .
170 html_tag( 'tr',
171 html_tag( 'td',
172 '<center><input type="submit" value="' . _("Login") . '"></center>',
173 'left' )
174 ),
175 '', '#ffffff', 'border="0" cols="1" width="350"' ),
176 'center' )
177 ) ,
178 '', '#ffffff', 'border="0" cellspacing="0" cellpadding="0" width="100%"' ) .
179 '</form>' . "\n";
180
181 do_hook('login_form');
182
183 do_hook('login_bottom');
184 echo "</body>\n".
185 "</html>\n";
186 ?>