fixing phpdoc warnings re:SM_PATH. Moving Id tags to @version
[squirrelmail.git] / src / login.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * login.php -- simple login screen
5 *
82d304a0 6 * Copyright (c) 1999-2004 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();
54
98f2ee76 55header('Pragma: no-cache');
56
8f6f9ba5 57/**
58 * This detects if the IMAP server has logins disabled, and if so,
59 * squelches the display of the login form and puts up a message
60 * explaining the situation.
61 */
6d611a76 62if($imap_auth_mech == 'login') {
63 $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
64 $logindisabled = sqimap_capability($imap,'LOGINDISABLED');
65 sqimap_logout($imap);
66 if ($logindisabled) {
67 $string = "The IMAP server is reporting that logins are disabled.<br>";
68 if (!$use_imap_tls) {
69 $string .= "The use of TLS may allow SquirrelMail to login.<br>";
70 }
71 $string .= "Please contact your system administrator.";
72 error_box($string,$color);
73 exit;
ea348fd3 74 }
ea348fd3 75}
76
98f2ee76 77do_hook('login_cookie');
78
79/* Output the javascript onload function. */
80
d68323ff 81$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
98f2ee76 82 "<!--\n".
83 " function squirrelmail_loginpage_onload() {\n".
03ccb49b 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".
87 " textElements++;\n".
88 " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
89 " document.forms[0].elements[i].focus();\n".
90 " break;\n".
91 " }\n".
92 " }\n".
93 " }\n".
98f2ee76 94 " }\n".
95 "// -->\n".
96 "</script>\n";
dfb94cac 97
98if (@file_exists($theme[$theme_default]['PATH']))
99 @include ($theme[$theme_default]['PATH']);
100
98f2ee76 101displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
102
2e394e36 103echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" .
ae958cd3 104 "\n" . '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value=\'' . SMPREF_JS_ON .'\';">' . "\n";
98f2ee76 105
0fce910a 106$username_form_name = 'login_username';
107$password_form_name = 'secretkey';
98f2ee76 108do_hook('login_top');
109
5250f7e7 110$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
98f2ee76 111
78b2428e 112/* If they don't have a logo, don't bother.. */
113if (isset($org_logo) && $org_logo) {
114 /* Display width and height like good little people */
115 $width_and_height = '';
116 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
117 $org_logo_width>0) {
118 $width_and_height = " width=\"$org_logo_width\"";
119 }
120 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
121 $org_logo_height>0) {
122 $width_and_height .= " height=\"$org_logo_height\"";
123 }
98f2ee76 124}
3fde693b 125
c67e4479 126if(sqgetGlobalVar('mailto', $mailto)) {
a34d6890 127 $rcptaddress = addHidden('mailto', $mailto);
c67e4479 128} else {
129 $rcptaddress = '';
130}
1cac3b9b 131echo html_tag( 'table',
8e2ed807 132 html_tag( 'tr',
133 html_tag( 'td',
134 '<center>'.
78b2428e 135 ( isset($org_logo) && $org_logo
136 ? '<img src="' . $org_logo . '" alt="' .
137 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
138 ' /><br />' . "\n"
139 : '' ).
8a97a070 140 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
d68323ff 141 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
142 ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) .
8e2ed807 143 html_tag( 'table',
144 html_tag( 'tr',
145 html_tag( 'td',
146 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
dfb94cac 147 'center', $color[0] )
8e2ed807 148 ) .
149 html_tag( 'tr',
150 html_tag( 'td', "\n" .
151 html_tag( 'table',
152 html_tag( 'tr',
153 html_tag( 'td',
154 _("Name:") ,
155 'right', '', 'width="30%"' ) .
156 html_tag( 'td',
a34d6890 157 addInput($username_form_name, $loginname_value),
8e2ed807 158 'left', '', 'width="*"' )
159 ) . "\n" .
160 html_tag( 'tr',
161 html_tag( 'td',
162 _("Password:") ,
163 'right', '', 'width="30%"' ) .
164 html_tag( 'td',
a34d6890 165 addPwField($password_form_name).
166 addHidden('js_autodetect_results', SMPREF_JS_OFF).
c67e4479 167 $rcptaddress .
a34d6890 168 addHidden('just_logged_in', '1'),
8e2ed807 169 'left', '', 'width="*"' )
170 ) ,
dfb94cac 171 'center', $color[4], 'border="0" width="100%"' ) ,
172 'left', $color[4] )
8e2ed807 173 ) .
174 html_tag( 'tr',
175 html_tag( 'td',
a34d6890 176 '<center>'. addSubmit(_("Login")) .'</center>',
8e2ed807 177 'left' )
178 ),
dfb94cac 179 '', $color[4], 'border="0" width="350"' ) . '</center>',
8e2ed807 180 'center' )
181 ) ,
dfb94cac 182'', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
98f2ee76 183do_hook('login_form');
cbaf4cf1 184echo '</form>' . "\n";
98f2ee76 185
186do_hook('login_bottom');
8e2ed807 187echo "</body>\n".
188 "</html>\n";
dcc1cc82 189?>