4 * login.php -- simple login screen
6 * This a simple login screen. Some housekeeping is done to clean
7 * cookies and find language.
9 * @copyright © 1999-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
16 * Path for SquirrelMail required files.
19 define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'functions/strings.php');
23 require_once(SM_PATH
. 'config/config.php');
24 require_once(SM_PATH
. 'functions/i18n.php');
25 require_once(SM_PATH
. 'functions/plugin.php');
26 require_once(SM_PATH
. 'functions/constants.php');
27 require_once(SM_PATH
. 'functions/page_header.php');
28 require_once(SM_PATH
. 'functions/html.php');
29 require_once(SM_PATH
. 'functions/global.php');
30 require_once(SM_PATH
. 'functions/imap_general.php');
31 require_once(SM_PATH
. 'functions/forms.php');
34 * $squirrelmail_language is set by a cookie when the user selects
35 * language and logs out
37 set_up_language($squirrelmail_language, TRUE, TRUE);
40 * Find out the base URI to set cookies.
42 if (!function_exists('sqm_baseuri')){
43 require_once(SM_PATH
. 'functions/display_messages.php');
45 $base_uri = sqm_baseuri();
48 * In case the last session was not terminated properly, make sure
54 * PHP bug. http://bugs.php.net/11643 (warning, spammed bug tracker) and
55 * http://bugs.php.net/13834
56 * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other
57 * versions. Produces warning on login page. Bug should be fixed only in 4.3.0
60 header('Pragma: no-cache');
63 * This detects if the IMAP server has logins disabled, and if so,
64 * squelches the display of the login form and puts up a message
65 * explaining the situation.
67 if($imap_auth_mech == 'login') {
69 * detect disabled login, only when imapServerAddress contains
70 * server address and not mapping. See sqimap_get_user_server()
72 if (substr($imapServerAddress, 0, 4) != "map:") {
73 $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
74 $logindisabled = sqimap_capability($imap,'LOGINDISABLED');
77 $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'.
78 _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />';
80 $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
82 $string .= _("Please contact your system administrator and report this error.");
83 error_box($string,$color);
89 do_hook('login_cookie');
91 $loginname_value = (sqGetGlobalVar('loginname', $loginname) ?
htmlspecialchars($loginname) : '');
93 /* Output the javascript onload function. */
95 $header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
97 " function squirrelmail_loginpage_onload() {\n".
98 " var textElements = 0;\n".
99 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
100 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
101 " textElements++;\n".
102 " if (textElements == " . (isset($loginname) ?
2 : 1) . ") {\n".
103 " document.forms[0].elements[i].focus();\n".
112 if (@file_exists
($theme[$theme_default]['PATH']))
113 @include
($theme[$theme_default]['PATH']);
115 if (! isset($color) ||
! is_array($color)) {
116 // Add default color theme, if theme loading fails
118 $color[0] = '#dcdcdc'; /* light gray TitleBar */
119 $color[1] = '#800000'; /* red */
120 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
121 $color[4] = '#ffffff'; /* white Normal Background */
122 $color[7] = '#0000cc'; /* blue Links */
123 $color[8] = '#000000'; /* black Normal text */
126 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE, FALSE, FALSE );
128 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" .
129 "\n" . '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value=\'' . SMPREF_JS_ON
.'\';">' . "\n";
131 $username_form_name = 'login_username';
132 $password_form_name = 'secretkey';
133 do_hook('login_top');
135 /* If they don't have a logo, don't bother.. */
136 if (isset($org_logo) && $org_logo) {
137 /* Display width and height like good little people */
138 $width_and_height = '';
139 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
141 $width_and_height = " width=\"$org_logo_width\"";
143 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
144 $org_logo_height>0) {
145 $width_and_height .= " height=\"$org_logo_height\"";
149 if(sqgetGlobalVar('mailto', $mailto)) {
150 $rcptaddress = addHidden('mailto', $mailto);
154 echo html_tag( 'table',
157 '<div style="text-align: center;">'.
158 ( isset($org_logo) && $org_logo
159 ?
'<img src="' . $org_logo . '" alt="' .
160 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
163 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ?
'' :
164 '<small>' . _("SquirrelMail Webmail Application") . '<br />' ."\n".
165 ' ' . _("By the SquirrelMail Project Team") . '<br /></small>' . "\n" ) .
169 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
170 'center', $color[0] )
173 html_tag( 'td', "\n" .
178 'right', '', 'width="30%"' ) .
180 addInput($username_form_name, $loginname_value),
181 'left', '', 'width="*"' )
186 'right', '', 'width="30%"' ) .
188 addPwField($password_form_name).
189 addHidden('js_autodetect_results', SMPREF_JS_OFF
).
191 addHidden('just_logged_in', '1'),
192 'left', '', 'width="*"' )
194 concat_hook_function('login_form') ,
195 'center', $color[4], 'border="0" width="100%"' ) ,
200 '<div style="text-align: center;">'. addSubmit(_("Login")) .'</div>',
203 '', $color[4], 'border="0" width="350"' ) . '</div>',
206 '', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
207 echo '</form>' . "\n";
209 do_hook('login_bottom');