5122421ab912ddc9b252b028ca2974c539f54f4b
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-2007 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
15 /** This is the login page */
16 define('PAGE_NAME', 'login');
19 * Include the SquirrelMail initialization file.
21 require('../include/init.php');
23 /* SquirrelMail required files. */
24 require_once(SM_PATH
. 'functions/imap_general.php');
25 require_once(SM_PATH
. 'functions/forms.php');
28 * $squirrelmail_language is set by a cookie when the user selects
29 * language and logs out
31 set_up_language($squirrelmail_language, TRUE, TRUE);
34 * In case the last session was not terminated properly, make sure
35 * we get a new one, but make sure we preserve session_expired_*
37 if ( !empty($_SESSION['session_expired_post']) && !empty($_SESSION['session_expired_location']) ) {
38 $sep = $_SESSION['session_expired_post'];
39 $sel = $_SESSION['session_expired_location'];
42 @sqsession_is_active
();
44 sqsession_register($sep, 'session_expired_post');
45 sqsession_register($sel, 'session_expired_location');
48 @sqsession_is_active
();
53 * This detects if the IMAP server has logins disabled, and if so,
54 * squelches the display of the login form and puts up a message
55 * explaining the situation.
57 if($imap_auth_mech == 'login') {
59 * detect disabled login, only when imapServerAddress contains
60 * server address and not mapping. See sqimap_get_user_server()
62 if (substr($imapServerAddress, 0, 4) != "map:") {
63 $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
64 $logindisabled = sqimap_capability($imap,'LOGINDISABLED');
67 $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'.
68 _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />';
70 $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
72 $string .= _("Please contact your system administrator and report this error.");
74 // display footer (closes html tags) and stop script execution
75 $oTemplate->display('footer.tpl');
81 do_hook('login_cookie', $null);
83 $loginname_value = (sqGetGlobalVar('loginname', $loginname) ?
htmlspecialchars($loginname) : '');
85 //FIXME: should be part of the template, not the core!
86 /* Output the javascript onload function. */
87 $header = "<script type=\"text/javascript\">\n" .
89 " function squirrelmail_loginpage_onload() {\n".
90 " var textElements = 0;\n".
91 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
92 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
94 " if (textElements == " . (isset($loginname) ?
2 : 1) . ") {\n".
95 " document.forms[0].elements[i].focus();\n".
104 if (@file_exists
($theme[$theme_default]['PATH']))
105 @include
($theme[$theme_default]['PATH']);
107 if (! isset($color) ||
! is_array($color)) {
108 // Add default color theme, if theme loading fails
110 $color[0] = '#dcdcdc'; /* light gray TitleBar */
111 $color[1] = '#800000'; /* red */
112 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
113 $color[4] = '#ffffff'; /* white Normal Background */
114 $color[7] = '#0000cc'; /* blue Links */
115 $color[8] = '#000000'; /* black Normal text */
118 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
122 /* If they don't have a logo, don't bother.. */
124 if (isset($org_logo) && $org_logo) {
126 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
128 $width = $org_logo_width;
132 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
133 $org_logo_height>0) {
134 $height = $org_logo_height;
139 $logo_str = create_image($org_logo, sprintf(_("%s Logo"), $org_name),
140 $width, $height, '', 'sqm_loginImage');
144 $sm_attribute_str = '';
145 if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
146 $sm_attribute_str = _("SquirrelMail Webmail")."\n" .
147 _("By the SquirrelMail Project Team");
150 if(sqgetGlobalVar('mailtodata', $mailtodata)) {
151 $mailtofield = addHidden('mailtodata', $mailtodata);
156 $password_field = addPwField('secretkey');
157 $login_extra = addHidden('js_autodetect_results', SMPREF_JS_OFF
).
159 addHidden('just_logged_in', '1');
161 session_write_close();
163 $oTemplate->assign('logo_str', $logo_str);
164 $oTemplate->assign('logo_path', $org_logo);
165 $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
166 // i18n: The %s represents the service provider's name
167 $oTemplate->assign('org_name_str', sprintf (_("%s Login"), $org_name));
168 // i18n: The %s represents the service provider's name
169 $oTemplate->assign('org_logo_str', sprintf (_("The %s logo"), $org_name));
170 $oTemplate->assign('login_field_value', $loginname_value);
171 $oTemplate->assign('login_extra', $login_extra);
173 //FIXME: need to remove *ALL* HTML from this file!
174 echo '<body onload="squirrelmail_loginpage_onload()">'."\n";
175 echo '<form action="redirect.php" method="post" onsubmit="document.forms[0].js_autodetect_results.value='. SMPREF_JS_ON
.'">'."\n";
176 do_hook('login_top', $null);
178 $oTemplate->display('login.tpl');
180 //FIXME: need to remove *ALL* HTML from this file!
182 do_hook('login_bottom', $null);
184 // Turn off delayed error handling to make sure all errors are dumped.
185 $oErrorHandler->setDelayedErrors(false);
187 $oTemplate->display('footer.tpl');