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
15 // reduces the files included in init.php
16 $sInitLocation = 'login';
19 * Include the SquirrelMail initialization file.
21 require('../include/init.php');
24 /* SquirrelMail required files. */
25 require_once(SM_PATH
. 'functions/imap_general.php');
26 require_once(SM_PATH
. 'functions/forms.php');
29 * $squirrelmail_language is set by a cookie when the user selects
30 * language and logs out
32 set_up_language($squirrelmail_language, TRUE, TRUE);
35 * In case the last session was not terminated properly, make sure
40 * PHP bug. http://bugs.php.net/11643 (warning, spammed bug tracker) and
41 * http://bugs.php.net/13834
42 * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other
43 * versions. Produces warning on login page. Bug should be fixed only in 4.3.0
45 @sqsession_is_active
();
50 * This detects if the IMAP server has logins disabled, and if so,
51 * squelches the display of the login form and puts up a message
52 * explaining the situation.
54 if($imap_auth_mech == 'login') {
56 * detect disabled login, only when imapServerAddress contains
57 * server address and not mapping. See sqimap_get_user_server()
59 if (substr($imapServerAddress, 0, 4) != "map:") {
60 $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
61 $logindisabled = sqimap_capability($imap,'LOGINDISABLED');
64 $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'.
65 _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />';
67 $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
69 $string .= _("Please contact your system administrator and report this error.");
70 error_box($string,$color);
76 do_hook('login_cookie');
78 $loginname_value = (sqGetGlobalVar('loginname', $loginname) ?
htmlspecialchars($loginname) : '');
80 /* Output the javascript onload function. */
81 $header = "<script 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 if (! isset($color) ||
! is_array($color)) {
102 // Add default color theme, if theme loading fails
104 $color[0] = '#dcdcdc'; /* light gray TitleBar */
105 $color[1] = '#800000'; /* red */
106 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
107 $color[4] = '#ffffff'; /* white Normal Background */
108 $color[7] = '#0000cc'; /* blue Links */
109 $color[8] = '#000000'; /* black Normal text */
112 * send out all the cookies
116 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
119 /* If they don't have a logo, don't bother.. */
121 if (isset($org_logo) && $org_logo) {
122 /* Display width and height like good little people */
123 $width_and_height = '';
124 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
126 $width_and_height = " width=\"$org_logo_width\"";
128 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
129 $org_logo_height>0) {
130 $width_and_height .= " height=\"$org_logo_height\"";
133 $logo_str = '<img src="'.$org_logo.'" ' .
134 'alt="'. sprintf(_("%s Logo"), $org_name).'" ' .
136 'class="sqm_loginImage" ' .
140 $sm_attribute_str = '';
141 if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
142 $sm_attribute_str = _("SquirrelMail Webmail Application")."<br />\n" .
143 _("By the SquirrelMail Project Team")."<br />\n";
146 $username_form_name = 'login_username';
147 $password_form_name = 'secretkey';
149 if(sqgetGlobalVar('mailto', $mailto)) {
150 $rcptaddress = addHidden('mailto', $mailto);
155 $password_field = addPwField($password_form_name).
156 addHidden('js_autodetect_results', SMPREF_JS_OFF
).
158 addHidden('just_logged_in', '1');
160 session_write_close();
162 $oTemplate->assign('logo_str', $logo_str);
163 $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
164 $oTemplate->assign('org_name_str', sprintf (_("%s Login"), $org_name));
165 $oTemplate->assign('login_field', addInput($username_form_name, $loginname_value));
166 $oTemplate->assign('password_field', $password_field);
167 $oTemplate->assign('submit_field', addSubmit(_("Login")));
169 $oTemplate->display('login.tpl');
171 // Turn off delayed error handling to make sure all errors are dumped.
172 #$oErrorHandler->delayedErrors(false);
174 #trigger_error('login');
175 $oTemplate->display('footer.tpl');