Add index.html to Development subdir, rename README.russian_apache to
[squirrelmail.git] / src / login.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * login.php -- simple login screen
5 *
6c84ba1e 6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This a simple login screen. Some housekeeping is done to clean
10 * cookies and find language.
11 *
30967a1e 12 * @version $Id$
8f6f9ba5 13 * @package squirrelmail
35586184 14 */
8e2ed807 15
30967a1e 16/**
17 * Path for SquirrelMail required files.
18 * @ignore
19 */
86725763 20define('SM_PATH','../');
21
22/* SquirrelMail required files. */
23require_once(SM_PATH . 'functions/strings.php');
24require_once(SM_PATH . 'config/config.php');
25require_once(SM_PATH . 'functions/i18n.php');
26require_once(SM_PATH . 'functions/plugin.php');
27require_once(SM_PATH . 'functions/constants.php');
28require_once(SM_PATH . 'functions/page_header.php');
29require_once(SM_PATH . 'functions/html.php');
a32985a5 30require_once(SM_PATH . 'functions/global.php');
ea348fd3 31require_once(SM_PATH . 'functions/imap_general.php');
a34d6890 32require_once(SM_PATH . 'functions/forms.php');
98f2ee76 33
8f6f9ba5 34/**
98f2ee76 35 * $squirrelmail_language is set by a cookie when the user selects
36 * language and logs out
37 */
5e2b6751 38set_up_language($squirrelmail_language, TRUE, TRUE);
d4e84069 39
85b454a0 40/**
41 * Find out the base URI to set cookies.
42 */
f3bc099d 43if (!function_exists('sqm_baseuri')){
86725763 44 require_once(SM_PATH . 'functions/display_messages.php');
f3bc099d 45}
46$base_uri = sqm_baseuri();
8e2ed807 47
98f2ee76 48/*
49 * In case the last session was not terminated properly, make sure
50 * we get a new one.
51 */
5250f7e7 52
69146537 53sqsession_destroy();
91e0dccc 54
98f2ee76 55header('Pragma: no-cache');
56
8f6f9ba5 57/**
91e0dccc 58 * This detects if the IMAP server has logins disabled, and if so,
8f6f9ba5 59 * squelches the display of the login form and puts up a message
60 * explaining the situation.
61 */
6d611a76 62if($imap_auth_mech == 'login') {
c0c5cf6a 63 /**
f8a1ed5a 64 * detect disabled login, only when imapServerAddress contains
c0c5cf6a 65 * server address and not mapping. See sqimap_get_user_server()
66 */
67 if (substr($imapServerAddress, 0, 4) != "map:") {
68 $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
69 $logindisabled = sqimap_capability($imap,'LOGINDISABLED');
70 sqimap_logout($imap);
71 if ($logindisabled) {
72 $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'.
73 _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />';
74 if (!$use_imap_tls) {
75 $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
76 }
77 $string .= _("Please contact your system administrator and report this error.");
78 error_box($string,$color);
79 exit;
6d611a76 80 }
ea348fd3 81 }
ea348fd3 82}
83
98f2ee76 84do_hook('login_cookie');
85
86/* Output the javascript onload function. */
87
d68323ff 88$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
98f2ee76 89 "<!--\n".
90 " function squirrelmail_loginpage_onload() {\n".
03ccb49b 91 " var textElements = 0;\n".
92 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
93 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
94 " textElements++;\n".
95 " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
96 " document.forms[0].elements[i].focus();\n".
97 " break;\n".
98 " }\n".
99 " }\n".
100 " }\n".
98f2ee76 101 " }\n".
102 "// -->\n".
103 "</script>\n";
dfb94cac 104
105if (@file_exists($theme[$theme_default]['PATH']))
106 @include ($theme[$theme_default]['PATH']);
107
98f2ee76 108displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
109
2e394e36 110echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" .
ae958cd3 111 "\n" . '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value=\'' . SMPREF_JS_ON .'\';">' . "\n";
98f2ee76 112
0fce910a 113$username_form_name = 'login_username';
114$password_form_name = 'secretkey';
98f2ee76 115do_hook('login_top');
116
5250f7e7 117$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
98f2ee76 118
78b2428e 119/* If they don't have a logo, don't bother.. */
120if (isset($org_logo) && $org_logo) {
121 /* Display width and height like good little people */
122 $width_and_height = '';
123 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
124 $org_logo_width>0) {
125 $width_and_height = " width=\"$org_logo_width\"";
126 }
127 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
128 $org_logo_height>0) {
129 $width_and_height .= " height=\"$org_logo_height\"";
130 }
98f2ee76 131}
3fde693b 132
c67e4479 133if(sqgetGlobalVar('mailto', $mailto)) {
a34d6890 134 $rcptaddress = addHidden('mailto', $mailto);
c67e4479 135} else {
136 $rcptaddress = '';
137}
1cac3b9b 138echo html_tag( 'table',
8e2ed807 139 html_tag( 'tr',
140 html_tag( 'td',
141 '<center>'.
78b2428e 142 ( isset($org_logo) && $org_logo
143 ? '<img src="' . $org_logo . '" alt="' .
144 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
145 ' /><br />' . "\n"
146 : '' ).
8a97a070 147 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
8b5c49cd 148 '<small>' . _("SquirrelMail Webmail Application") . '<br />' ."\n".
8bc594ba 149 ' ' . _("By the SquirrelMail Project Team") . '<br /></small>' . "\n" ) .
8e2ed807 150 html_tag( 'table',
151 html_tag( 'tr',
152 html_tag( 'td',
153 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
dfb94cac 154 'center', $color[0] )
8e2ed807 155 ) .
156 html_tag( 'tr',
157 html_tag( 'td', "\n" .
158 html_tag( 'table',
159 html_tag( 'tr',
160 html_tag( 'td',
161 _("Name:") ,
162 'right', '', 'width="30%"' ) .
163 html_tag( 'td',
134e4174 164 addInput($username_form_name, $loginname_value),
8e2ed807 165 'left', '', 'width="*"' )
166 ) . "\n" .
167 html_tag( 'tr',
168 html_tag( 'td',
169 _("Password:") ,
170 'right', '', 'width="30%"' ) .
171 html_tag( 'td',
134e4174 172 addPwField($password_form_name).
173 addHidden('js_autodetect_results', SMPREF_JS_OFF).
c67e4479 174 $rcptaddress .
134e4174 175 addHidden('just_logged_in', '1'),
8e2ed807 176 'left', '', 'width="*"' )
177 ) ,
dfb94cac 178 'center', $color[4], 'border="0" width="100%"' ) ,
179 'left', $color[4] )
91e0dccc 180 ) .
8e2ed807 181 html_tag( 'tr',
182 html_tag( 'td',
a34d6890 183 '<center>'. addSubmit(_("Login")) .'</center>',
8e2ed807 184 'left' )
185 ),
dfb94cac 186 '', $color[4], 'border="0" width="350"' ) . '</center>',
8e2ed807 187 'center' )
188 ) ,
dfb94cac 189'', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
98f2ee76 190do_hook('login_form');
cbaf4cf1 191echo '</form>' . "\n";
98f2ee76 192
193do_hook('login_bottom');
134e4174 194?>
f8a1ed5a 195</body></html>