switched doctype to standard compliance mode
[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
30967a1e 15/**
16 * Path for SquirrelMail required files.
17 * @ignore
18 */
86725763 19define('SM_PATH','../');
20
21/* SquirrelMail required files. */
22require_once(SM_PATH . 'functions/strings.php');
23require_once(SM_PATH . 'config/config.php');
24require_once(SM_PATH . 'functions/i18n.php');
25require_once(SM_PATH . 'functions/plugin.php');
26require_once(SM_PATH . 'functions/constants.php');
27require_once(SM_PATH . 'functions/page_header.php');
28require_once(SM_PATH . 'functions/html.php');
a32985a5 29require_once(SM_PATH . 'functions/global.php');
ea348fd3 30require_once(SM_PATH . 'functions/imap_general.php');
a34d6890 31require_once(SM_PATH . 'functions/forms.php');
98f2ee76 32
8f6f9ba5 33/**
98f2ee76 34 * $squirrelmail_language is set by a cookie when the user selects
35 * language and logs out
36 */
5e2b6751 37set_up_language($squirrelmail_language, TRUE, TRUE);
d4e84069 38
85b454a0 39/**
40 * Find out the base URI to set cookies.
41 */
f3bc099d 42if (!function_exists('sqm_baseuri')){
86725763 43 require_once(SM_PATH . 'functions/display_messages.php');
f3bc099d 44}
45$base_uri = sqm_baseuri();
8e2ed807 46
98f2ee76 47/*
48 * In case the last session was not terminated properly, make sure
49 * we get a new one.
50 */
5250f7e7 51
69146537 52sqsession_destroy();
07a52f9f 53/**
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
58 */
59@sqsession_start();
98f2ee76 60header('Pragma: no-cache');
61
8f6f9ba5 62/**
91e0dccc 63 * This detects if the IMAP server has logins disabled, and if so,
8f6f9ba5 64 * squelches the display of the login form and puts up a message
65 * explaining the situation.
66 */
6d611a76 67if($imap_auth_mech == 'login') {
c0c5cf6a 68 /**
f8a1ed5a 69 * detect disabled login, only when imapServerAddress contains
c0c5cf6a 70 * server address and not mapping. See sqimap_get_user_server()
71 */
72 if (substr($imapServerAddress, 0, 4) != "map:") {
73 $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
74 $logindisabled = sqimap_capability($imap,'LOGINDISABLED');
75 sqimap_logout($imap);
76 if ($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 />';
79 if (!$use_imap_tls) {
80 $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
81 }
82 $string .= _("Please contact your system administrator and report this error.");
83 error_box($string,$color);
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. */
94
d68323ff 95$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
98f2ee76 96 "<!--\n".
97 " function squirrelmail_loginpage_onload() {\n".
03ccb49b 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".
104 " break;\n".
105 " }\n".
106 " }\n".
107 " }\n".
98f2ee76 108 " }\n".
109 "// -->\n".
110 "</script>\n";
dfb94cac 111
112if (@file_exists($theme[$theme_default]['PATH']))
113 @include ($theme[$theme_default]['PATH']);
114
832dc1e2 115if (! isset($color) || ! is_array($color)) {
116 // Add default color theme, if theme loading fails
117 $color = array();
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 */
124}
125
cbd8c251 126displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE, FALSE, FALSE );
98f2ee76 127
2e394e36 128echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" .
ae958cd3 129 "\n" . '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value=\'' . SMPREF_JS_ON .'\';">' . "\n";
98f2ee76 130
0fce910a 131$username_form_name = 'login_username';
132$password_form_name = 'secretkey';
98f2ee76 133do_hook('login_top');
134
78b2428e 135/* If they don't have a logo, don't bother.. */
136if (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) &&
140 $org_logo_width>0) {
141 $width_and_height = " width=\"$org_logo_width\"";
142 }
143 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
144 $org_logo_height>0) {
145 $width_and_height .= " height=\"$org_logo_height\"";
146 }
98f2ee76 147}
3fde693b 148
c67e4479 149if(sqgetGlobalVar('mailto', $mailto)) {
a34d6890 150 $rcptaddress = addHidden('mailto', $mailto);
c67e4479 151} else {
152 $rcptaddress = '';
153}
1cac3b9b 154echo html_tag( 'table',
8e2ed807 155 html_tag( 'tr',
156 html_tag( 'td',
157 '<center>'.
78b2428e 158 ( isset($org_logo) && $org_logo
159 ? '<img src="' . $org_logo . '" alt="' .
160 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
161 ' /><br />' . "\n"
162 : '' ).
8a97a070 163 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
8b5c49cd 164 '<small>' . _("SquirrelMail Webmail Application") . '<br />' ."\n".
8bc594ba 165 ' ' . _("By the SquirrelMail Project Team") . '<br /></small>' . "\n" ) .
8e2ed807 166 html_tag( 'table',
167 html_tag( 'tr',
168 html_tag( 'td',
169 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
dfb94cac 170 'center', $color[0] )
8e2ed807 171 ) .
172 html_tag( 'tr',
173 html_tag( 'td', "\n" .
174 html_tag( 'table',
175 html_tag( 'tr',
176 html_tag( 'td',
177 _("Name:") ,
178 'right', '', 'width="30%"' ) .
179 html_tag( 'td',
134e4174 180 addInput($username_form_name, $loginname_value),
8e2ed807 181 'left', '', 'width="*"' )
182 ) . "\n" .
183 html_tag( 'tr',
184 html_tag( 'td',
185 _("Password:") ,
186 'right', '', 'width="30%"' ) .
187 html_tag( 'td',
134e4174 188 addPwField($password_form_name).
189 addHidden('js_autodetect_results', SMPREF_JS_OFF).
c67e4479 190 $rcptaddress .
134e4174 191 addHidden('just_logged_in', '1'),
a2b193bc 192 'left', '', 'width="*"' )
16436d92 193 ) .
194 concat_hook_function('login_form') ,
a2b193bc 195 'center', $color[4], 'border="0" width="100%"' ) ,
196 'left', $color[4] )
197 ) .
198 html_tag( 'tr',
199 html_tag( 'td',
200 '<center>'. addSubmit(_("Login")) .'</center>',
201 'left' )
202 ),
203 '', $color[4], 'border="0" width="350"' ) . '</center>',
204 'center' )
205 ) ,
206 '', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
cbaf4cf1 207echo '</form>' . "\n";
98f2ee76 208
209do_hook('login_bottom');
a2b193bc 210
134e4174 211?>
cbd8c251 212</body></html>