Delivery notifications and Read notifications are currently treated as identical...
[squirrelmail.git] / src / login.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * login.php -- simple login screen
5 *
35586184 6 * This a simple login screen. Some housekeeping is done to clean
7 * cookies and find language.
8 *
47ccfad4 9 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
30967a1e 11 * @version $Id$
8f6f9ba5 12 * @package squirrelmail
35586184 13 */
8e2ed807 14
202bcbcc 15// reduces the files included in init.php
16$sInitLocation = 'login';
17
30967a1e 18/**
202bcbcc 19 * Include the SquirrelMail initialization file.
30967a1e 20 */
202bcbcc 21require('../include/init.php');
22
86725763 23
24/* SquirrelMail required files. */
ea348fd3 25require_once(SM_PATH . 'functions/imap_general.php');
a34d6890 26require_once(SM_PATH . 'functions/forms.php');
98f2ee76 27
8f6f9ba5 28/**
98f2ee76 29 * $squirrelmail_language is set by a cookie when the user selects
30 * language and logs out
31 */
5e2b6751 32set_up_language($squirrelmail_language, TRUE, TRUE);
d4e84069 33
c6f28eb1 34/**
98f2ee76 35 * In case the last session was not terminated properly, make sure
c6f28eb1 36 * we get a new one, but make sure we preserve session_expired_*
98f2ee76 37 */
07a52f9f 38/**
39 * PHP bug. http://bugs.php.net/11643 (warning, spammed bug tracker) and
40 * http://bugs.php.net/13834
202bcbcc 41 * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other
07a52f9f 42 * versions. Produces warning on login page. Bug should be fixed only in 4.3.0
43 */
c6f28eb1 44if ( !empty($_SESSION['session_expired_post']) && !empty($_SESSION['session_expired_location']) ) {
45 $sep = $_SESSION['session_expired_post'];
46 $sel = $_SESSION['session_expired_location'];
47
48 sqsession_destroy();
49
50 sqsession_is_active();
51 $_SESSION=array();
52 sqsession_register($sep, 'session_expired_post');
53 sqsession_register($sel, 'session_expired_location');
54} else {
55 sqsession_destroy();
56 @sqsession_is_active();
57 $_SESSION=array();
58}
98f2ee76 59
8f6f9ba5 60/**
91e0dccc 61 * This detects if the IMAP server has logins disabled, and if so,
8f6f9ba5 62 * squelches the display of the login form and puts up a message
63 * explaining the situation.
64 */
6d611a76 65if($imap_auth_mech == 'login') {
c0c5cf6a 66 /**
f8a1ed5a 67 * detect disabled login, only when imapServerAddress contains
c0c5cf6a 68 * server address and not mapping. See sqimap_get_user_server()
69 */
70 if (substr($imapServerAddress, 0, 4) != "map:") {
71 $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
72 $logindisabled = sqimap_capability($imap,'LOGINDISABLED');
73 sqimap_logout($imap);
74 if ($logindisabled) {
75 $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'.
76 _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />';
77 if (!$use_imap_tls) {
78 $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
79 }
80 $string .= _("Please contact your system administrator and report this error.");
1b858d86 81 error_box($string);
82 // display footer (closes html tags) and stop script execution
83 $oTemplate->display('footer.tpl');
c0c5cf6a 84 exit;
6d611a76 85 }
ea348fd3 86 }
ea348fd3 87}
88
98f2ee76 89do_hook('login_cookie');
90
bca2d025 91$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
92
98f2ee76 93/* Output the javascript onload function. */
2c92ea9d 94$header = "<script type=\"text/javascript\">\n" .
98f2ee76 95 "<!--\n".
96 " function squirrelmail_loginpage_onload() {\n".
03ccb49b 97 " var textElements = 0;\n".
98 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
99 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
100 " textElements++;\n".
101 " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
102 " document.forms[0].elements[i].focus();\n".
103 " break;\n".
104 " }\n".
105 " }\n".
106 " }\n".
98f2ee76 107 " }\n".
108 "// -->\n".
109 "</script>\n";
dfb94cac 110
111if (@file_exists($theme[$theme_default]['PATH']))
112 @include ($theme[$theme_default]['PATH']);
113
832dc1e2 114if (! isset($color) || ! is_array($color)) {
115 // Add default color theme, if theme loading fails
116 $color = array();
117 $color[0] = '#dcdcdc'; /* light gray TitleBar */
118 $color[1] = '#800000'; /* red */
119 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
120 $color[4] = '#ffffff'; /* white Normal Background */
121 $color[7] = '#0000cc'; /* blue Links */
122 $color[8] = '#000000'; /* black Normal text */
123}
1d537493 124/**
125 * send out all the cookies
126 */
127sqsetcookieflush();
832dc1e2 128
c5330196 129displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
98f2ee76 130
98f2ee76 131
78b2428e 132/* If they don't have a logo, don't bother.. */
c5330196 133$logo_str = '';
78b2428e 134if (isset($org_logo) && $org_logo) {
135 /* Display width and height like good little people */
136 $width_and_height = '';
137 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
138 $org_logo_width>0) {
602a123e 139 $width_and_height = "width=\"$org_logo_width\" ";
78b2428e 140 }
141 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
142 $org_logo_height>0) {
602a123e 143 $width_and_height .= "height=\"$org_logo_height\" ";
78b2428e 144 }
f5dcd7f3 145
c5330196 146 $logo_str = '<img src="'.$org_logo.'" ' .
1b858d86 147 'alt="'. sprintf(_("%s Logo"), $org_name).'" ' .
148 $width_and_height .
602a123e 149 'class="sqm_loginImage" /><br />'."\n";
c5330196 150}
151
152$sm_attribute_str = '';
beebd508 153if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
c5330196 154 $sm_attribute_str = _("SquirrelMail Webmail Application")."<br />\n" .
155 _("By the SquirrelMail Project Team")."<br />\n";
98f2ee76 156}
3fde693b 157
c67e4479 158if(sqgetGlobalVar('mailto', $mailto)) {
a34d6890 159 $rcptaddress = addHidden('mailto', $mailto);
c67e4479 160} else {
161 $rcptaddress = '';
162}
c5330196 163
84d10885 164$password_field = addPwField('secretkey');
2f04c558 165$login_extra = addHidden('js_autodetect_results', SMPREF_JS_OFF).
166 $rcptaddress .
31633bef 167 addHidden('just_logged_in', '1');
168$plugin_extra = concat_hook_function('login_form');
c5330196 169
202bcbcc 170session_write_close();
171
c5330196 172$oTemplate->assign('logo_str', $logo_str);
84d10885 173$oTemplate->assign('logo_path', $org_logo);
c5330196 174$oTemplate->assign('sm_attribute_str', $sm_attribute_str);
175$oTemplate->assign('org_name_str', sprintf (_("%s Login"), $org_name));
2f04c558 176$oTemplate->assign('login_field_value', $loginname_value);
177$oTemplate->assign('login_extra', $login_extra);
31633bef 178$oTemplate->assign('plugin_extra', $plugin_extra);
2f04c558 179
84d10885 180echo '<body onLoad="squirrelmail_loginpage_onload()">'."\n";
2f04c558 181echo '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value='. SMPREF_JS_ON .'">'."\n";
182do_hook('login_top');
c5330196 183
184$oTemplate->display('login.tpl');
f5dcd7f3 185
2f04c558 186echo "</form>\n";
187do_hook('login_bottom');
188
f5dcd7f3 189// Turn off delayed error handling to make sure all errors are dumped.
84d10885 190$oErrorHandler->setDelayedErrors(false);
f5dcd7f3 191
f5dcd7f3 192$oTemplate->display('footer.tpl');
c6f28eb1 193?>