Moved opening form tag up before login_top hook so plugins like password_forget will...
[squirrelmail.git] / src / login.php
1 <?php
2
3 /**
4 * login.php -- simple login screen
5 *
6 * Copyright (c) 1999-2003 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 /* Path for SquirrelMail required files. */
16 define('SM_PATH','../');
17
18 /* SquirrelMail required files. */
19 require_once(SM_PATH . 'functions/strings.php');
20 require_once(SM_PATH . 'config/config.php');
21 require_once(SM_PATH . 'functions/i18n.php');
22 require_once(SM_PATH . 'functions/plugin.php');
23 require_once(SM_PATH . 'functions/constants.php');
24 require_once(SM_PATH . 'functions/page_header.php');
25 require_once(SM_PATH . 'functions/html.php');
26 require_once(SM_PATH . 'functions/global.php');
27
28 /*
29 * $squirrelmail_language is set by a cookie when the user selects
30 * language and logs out
31 */
32 set_up_language($squirrelmail_language, TRUE);
33
34 /**
35 * Find out the base URI to set cookies.
36 */
37 if (!function_exists('sqm_baseuri')){
38 require_once(SM_PATH . 'functions/display_messages.php');
39 }
40 $base_uri = sqm_baseuri();
41
42 /*
43 * In case the last session was not terminated properly, make sure
44 * we get a new one.
45 */
46
47 sqsession_destroy();
48
49 header('Pragma: no-cache');
50
51 do_hook('login_cookie');
52
53 /* Output the javascript onload function. */
54
55 $header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
56 "<!--\n".
57 " function squirrelmail_loginpage_onload() {\n".
58 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
59 " var textElements = 0;\n".
60 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
61 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
62 " textElements++;\n".
63 " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
64 " document.forms[0].elements[i].focus();\n".
65 " break;\n".
66 " }\n".
67 " }\n".
68 " }\n".
69 " }\n".
70 "// -->\n".
71 "</script>\n";
72 $custom_css = 'none';
73 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
74
75 echo '<body text="#000000" bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="squirrelmail_loginpage_onload();">' .
76 "\n" . '<form action="redirect.php" method="post">' . "\n";
77
78 $username_form_name = 'login_username';
79 $password_form_name = 'secretkey';
80 do_hook('login_top');
81
82 $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
83
84 /* If they don't have a logo, don't bother.. */
85 if (isset($org_logo) && $org_logo) {
86 /* Display width and height like good little people */
87 $width_and_height = '';
88 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
89 $org_logo_width>0) {
90 $width_and_height = " width=\"$org_logo_width\"";
91 }
92 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
93 $org_logo_height>0) {
94 $width_and_height .= " height=\"$org_logo_height\"";
95 }
96 }
97 global $shootMyFootOff;
98 if (check_php_version(4,3) and !isset($shootMyFootOff)) {
99 echo '<center><hr width="75%">' . "\n";
100 echo '<h2>PHP 4.3.x has been detected</h2>' . "\n";
101 echo '</center><p>The SquirrelMail team does not recommend the use of PHP 4.3.x with';
102 echo ' this software. Please see the <a href="http://www.squirrelmail.org">SquirrelMail';
103 echo ' website</a>, or the documentation that came with SquirrelMail for more information.</p>';
104 echo '<p>This warning can be disabled by either downgrading PHP, or inserting';
105 echo '"$shootMyFootOff = true;" in config/config_local.php.</p>' . "\n";
106 echo '<center><hr width="75%"></center>' . "\n";
107 echo "\n";
108 }
109
110 echo html_tag( 'table',
111 html_tag( 'tr',
112 html_tag( 'td',
113 '<center>'.
114 ( isset($org_logo) && $org_logo
115 ? '<img src="' . $org_logo . '" alt="' .
116 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
117 ' /><br />' . "\n"
118 : '' ).
119 ( $hide_sm_attributions ? '' :
120 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
121 ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) .
122 html_tag( 'table',
123 html_tag( 'tr',
124 html_tag( 'td',
125 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
126 'center', '#DCDCDC' )
127 ) .
128 html_tag( 'tr',
129 html_tag( 'td', "\n" .
130 html_tag( 'table',
131 html_tag( 'tr',
132 html_tag( 'td',
133 _("Name:") ,
134 'right', '', 'width="30%"' ) .
135 html_tag( 'td',
136 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'" />' ,
137 'left', '', 'width="*"' )
138 ) . "\n" .
139 html_tag( 'tr',
140 html_tag( 'td',
141 _("Password:") ,
142 'right', '', 'width="30%"' ) .
143 html_tag( 'td',
144 '<input type="password" name="' . $password_form_name . '" />' . "\n" .
145 '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF" />' . "\n" .
146 '<input type="hidden" name="just_logged_in" value="1" />' . "\n",
147 'left', '', 'width="*"' )
148 ) ,
149 'center', '#ffffff', 'border="0" width="100%"' ) ,
150 'left', '#FFFFFF' )
151 ) .
152 html_tag( 'tr',
153 html_tag( 'td',
154 '<center><input type="submit" value="' . _("Login") . '" /></center>',
155 'left' )
156 ),
157 '', '#ffffff', 'border="0" width="350"' ) . '</center>',
158 'center' )
159 ) ,
160 '', '#ffffff', 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
161 do_hook('login_form');
162 echo '</form>' . "\n";
163
164 do_hook('login_bottom');
165 echo "</body>\n".
166 "</html>\n";
167 ?>