df1a1b9a54103b67a6d15f5d110f9836f406f79f
[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
129 html_tag( 'table',
130 html_tag( 'tr',
131 html_tag( 'td',
132 "\n" . '<form action="redirect.php" method="post">' . "\n" .
133 '<center>'.
134 '<img src="' . $org_logo . '" alt="' . sprintf(_("%s Logo"), $org_name) .'"' .
135 $width_and_height .'><br>' . "\n".
136 ( $hide_sm_attributions ? '' :
137 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br>' ."\n".
138 ' ' . _("By the SquirrelMail Development Team") . '<br></small>' . "\n" ) .
139 "<br>\n" .
140
141 html_tag( 'table',
142 html_tag( 'tr',
143 html_tag( 'td',
144 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
145 'left', '#DCDCDC' )
146 ) . "\n" .
147 html_tag( 'tr',
148 html_tag( 'td', "\n" .
149 html_tag( 'table',
150 html_tag( 'tr',
151 html_tag( 'td',
152 _("Name:") ,
153 'right', '', 'width="30%"' ) .
154 html_tag( 'td',
155 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'">' ,
156 'left', '', 'width="*"' )
157 ) . "\n" .
158 html_tag( 'tr',
159 html_tag( 'td',
160 _("Password:") ,
161 'right', '', 'width="30%"' ) .
162 html_tag( 'td',
163 '<input type="password" name="' . $password_form_name . '">' . "\n" .
164 '<input type=hidden name="js_autodetect_results" value="SMPREF_JS_OFF">' . "\n" .
165 '<input type=hidden name="just_logged_in" value=1>' . "\n" .
166 $rcptaddress_input . "\n" ,
167 'left', '', 'width="*"' )
168 ) ,
169 '', '', '', 'border="0" cols="2" width="100%"' ) ,
170 'left', '#FFFFFF' )
171 ) . "\n" .
172 html_tag( 'tr',
173 html_tag( 'td',
174 '<center><input type="submit" value="' . _("Login") . '"></center>',
175 'left' )
176 ) . "\n" ,
177 '', '', 'border="0" cols="1" width="350"' ) .
178 '</form>' . "\n",
179 'left' )
180 ) ,
181 '', '', 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
182
183 do_hook('login_form');
184
185 do_hook('login_bottom');
186 echo "</body>\n".
187 "</html>\n";
188 ?>