utf-8 is already converted by ja_JP extra functions.
[squirrelmail.git] / src / login.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * login.php -- simple login screen
5 *
76911253 6 * Copyright (c) 1999-2003 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 *
12 * $Id$
13 */
8e2ed807 14
86725763 15/* Path for SquirrelMail required files. */
16define('SM_PATH','../');
17
18/* SquirrelMail required files. */
19require_once(SM_PATH . 'functions/strings.php');
20require_once(SM_PATH . 'config/config.php');
21require_once(SM_PATH . 'functions/i18n.php');
22require_once(SM_PATH . 'functions/plugin.php');
23require_once(SM_PATH . 'functions/constants.php');
24require_once(SM_PATH . 'functions/page_header.php');
25require_once(SM_PATH . 'functions/html.php');
a32985a5 26require_once(SM_PATH . 'functions/global.php');
ea348fd3 27require_once(SM_PATH . 'functions/imap_general.php');
98f2ee76 28
29/*
30 * $squirrelmail_language is set by a cookie when the user selects
31 * language and logs out
32 */
5e2b6751 33set_up_language($squirrelmail_language, TRUE, TRUE);
d4e84069 34
85b454a0 35/**
36 * Find out the base URI to set cookies.
37 */
f3bc099d 38if (!function_exists('sqm_baseuri')){
86725763 39 require_once(SM_PATH . 'functions/display_messages.php');
f3bc099d 40}
41$base_uri = sqm_baseuri();
8e2ed807 42
98f2ee76 43/*
44 * In case the last session was not terminated properly, make sure
45 * we get a new one.
46 */
5250f7e7 47
69146537 48sqsession_destroy();
49
98f2ee76 50header('Pragma: no-cache');
51
ea348fd3 52$imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
53$logindisabled = sqimap_capability($imap,'LOGINDISABLED');
54sqimap_logout($imap);
55if ($logindisabled) {
56 $string = "The IMAP server is reporting that logins are disabled.<br>";
57 if (!$use_imap_tls) {
58 $string .= "The use of TLS may allow SquirrelMail to login.<br>";
59 }
60 $string .= "Please contact your system administrator.";
61 error_box($string,$color);
62 exit;
63}
64
98f2ee76 65do_hook('login_cookie');
66
67/* Output the javascript onload function. */
68
d68323ff 69$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
98f2ee76 70 "<!--\n".
71 " function squirrelmail_loginpage_onload() {\n".
72 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
03ccb49b 73 " var textElements = 0;\n".
74 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
75 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
76 " textElements++;\n".
77 " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
78 " document.forms[0].elements[i].focus();\n".
79 " break;\n".
80 " }\n".
81 " }\n".
82 " }\n".
98f2ee76 83 " }\n".
84 "// -->\n".
85 "</script>\n";
dfb94cac 86
87if (@file_exists($theme[$theme_default]['PATH']))
88 @include ($theme[$theme_default]['PATH']);
89
98f2ee76 90displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
91
2e394e36 92echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" .
1cac3b9b 93 "\n" . '<form action="redirect.php" method="post">' . "\n";
98f2ee76 94
0fce910a 95$username_form_name = 'login_username';
96$password_form_name = 'secretkey';
98f2ee76 97do_hook('login_top');
98
5250f7e7 99$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
98f2ee76 100
78b2428e 101/* If they don't have a logo, don't bother.. */
102if (isset($org_logo) && $org_logo) {
103 /* Display width and height like good little people */
104 $width_and_height = '';
105 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
106 $org_logo_width>0) {
107 $width_and_height = " width=\"$org_logo_width\"";
108 }
109 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
110 $org_logo_height>0) {
111 $width_and_height .= " height=\"$org_logo_height\"";
112 }
98f2ee76 113}
3fde693b 114
c67e4479 115if(sqgetGlobalVar('mailto', $mailto)) {
116 $rcptaddress = '<input type="hidden" name="mailto" value="' . urlencode($mailto) . '" />' . "\n";
117} else {
118 $rcptaddress = '';
119}
1cac3b9b 120echo html_tag( 'table',
8e2ed807 121 html_tag( 'tr',
122 html_tag( 'td',
123 '<center>'.
78b2428e 124 ( isset($org_logo) && $org_logo
125 ? '<img src="' . $org_logo . '" alt="' .
126 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
127 ' /><br />' . "\n"
128 : '' ).
8a97a070 129 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
d68323ff 130 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
131 ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) .
8e2ed807 132 html_tag( 'table',
133 html_tag( 'tr',
134 html_tag( 'td',
135 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
dfb94cac 136 'center', $color[0] )
8e2ed807 137 ) .
138 html_tag( 'tr',
139 html_tag( 'td', "\n" .
140 html_tag( 'table',
141 html_tag( 'tr',
142 html_tag( 'td',
143 _("Name:") ,
144 'right', '', 'width="30%"' ) .
145 html_tag( 'td',
d68323ff 146 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'" />' ,
8e2ed807 147 'left', '', 'width="*"' )
148 ) . "\n" .
149 html_tag( 'tr',
150 html_tag( 'td',
151 _("Password:") ,
152 'right', '', 'width="30%"' ) .
153 html_tag( 'td',
d68323ff 154 '<input type="password" name="' . $password_form_name . '" />' . "\n" .
155 '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF" />' . "\n" .
c67e4479 156 $rcptaddress .
d68323ff 157 '<input type="hidden" name="just_logged_in" value="1" />' . "\n",
8e2ed807 158 'left', '', 'width="*"' )
159 ) ,
dfb94cac 160 'center', $color[4], 'border="0" width="100%"' ) ,
161 'left', $color[4] )
8e2ed807 162 ) .
163 html_tag( 'tr',
164 html_tag( 'td',
d68323ff 165 '<center><input type="submit" value="' . _("Login") . '" /></center>',
8e2ed807 166 'left' )
167 ),
dfb94cac 168 '', $color[4], 'border="0" width="350"' ) . '</center>',
8e2ed807 169 'center' )
170 ) ,
dfb94cac 171'', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
98f2ee76 172do_hook('login_form');
cbaf4cf1 173echo '</form>' . "\n";
98f2ee76 174
175do_hook('login_bottom');
8e2ed807 176echo "</body>\n".
177 "</html>\n";
178?>