4 * login.php -- simple login screen
6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This a simple login screen. Some housekeeping is done to clean
10 * cookies and find language.
13 * @package squirrelmail
17 * Path for SquirrelMail required files.
20 define('SM_PATH','../');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'functions/strings.php');
24 require_once(SM_PATH
. 'config/config.php');
25 require_once(SM_PATH
. 'functions/i18n.php');
26 require_once(SM_PATH
. 'functions/plugin.php');
27 require_once(SM_PATH
. 'functions/constants.php');
28 require_once(SM_PATH
. 'functions/page_header.php');
29 require_once(SM_PATH
. 'functions/html.php');
30 require_once(SM_PATH
. 'functions/global.php');
31 require_once(SM_PATH
. 'functions/imap_general.php');
32 require_once(SM_PATH
. 'functions/forms.php');
35 * $squirrelmail_language is set by a cookie when the user selects
36 * language and logs out
38 set_up_language($squirrelmail_language, TRUE, TRUE);
41 * Find out the base URI to set cookies.
43 if (!function_exists('sqm_baseuri')){
44 require_once(SM_PATH
. 'functions/display_messages.php');
46 $base_uri = sqm_baseuri();
49 * In case the last session was not terminated properly, make sure
55 header('Pragma: no-cache');
58 * This detects if the IMAP server has logins disabled, and if so,
59 * squelches the display of the login form and puts up a message
60 * explaining the situation.
62 if($imap_auth_mech == 'login') {
63 $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
64 $logindisabled = sqimap_capability($imap,'LOGINDISABLED');
67 $string = _("The IMAP server is reporting that logins are disabled.").'<br />';
69 $string .= _("The use of TLS may allow SquirrelMail to login.").'<br />';
71 $string .= _("Please contact your system administrator and report this error.");
72 error_box($string,$color);
77 do_hook('login_cookie');
79 /* Output the javascript onload function. */
81 $header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
83 " function squirrelmail_loginpage_onload() {\n".
84 " var textElements = 0;\n".
85 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
86 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
88 " if (textElements == " . (isset($loginname) ?
2 : 1) . ") {\n".
89 " document.forms[0].elements[i].focus();\n".
98 if (@file_exists
($theme[$theme_default]['PATH']))
99 @include
($theme[$theme_default]['PATH']);
101 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
103 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" .
104 "\n" . '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value=\'' . SMPREF_JS_ON
.'\';">' . "\n";
106 $username_form_name = 'login_username';
107 $password_form_name = 'secretkey';
108 do_hook('login_top');
110 $loginname_value = (sqGetGlobalVar('loginname', $loginname) ?
htmlspecialchars($loginname) : '');
112 /* If they don't have a logo, don't bother.. */
113 if (isset($org_logo) && $org_logo) {
114 /* Display width and height like good little people */
115 $width_and_height = '';
116 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
118 $width_and_height = " width=\"$org_logo_width\"";
120 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
121 $org_logo_height>0) {
122 $width_and_height .= " height=\"$org_logo_height\"";
126 if(sqgetGlobalVar('mailto', $mailto)) {
127 $rcptaddress = addHidden('mailto', $mailto);
131 echo html_tag( 'table',
135 ( isset($org_logo) && $org_logo
136 ?
'<img src="' . $org_logo . '" alt="' .
137 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
140 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ?
'' :
141 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
142 ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) .
146 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
147 'center', $color[0] )
150 html_tag( 'td', "\n" .
155 'right', '', 'width="30%"' ) .
157 addInput($username_form_name, $loginname_value),
158 'left', '', 'width="*"' )
163 'right', '', 'width="30%"' ) .
165 addPwField($password_form_name).
166 addHidden('js_autodetect_results', SMPREF_JS_OFF
).
168 addHidden('just_logged_in', '1'),
169 'left', '', 'width="*"' )
171 'center', $color[4], 'border="0" width="100%"' ) ,
176 '<center>'. addSubmit(_("Login")) .'</center>',
179 '', $color[4], 'border="0" width="350"' ) . '</center>',
182 '', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
183 do_hook('login_form');
184 echo '</form>' . "\n";
186 do_hook('login_bottom');