Update
[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');
98f2ee76 27
28/*
29 * $squirrelmail_language is set by a cookie when the user selects
30 * language and logs out
31 */
32set_up_language($squirrelmail_language, TRUE);
d4e84069 33
85b454a0 34/**
35 * Find out the base URI to set cookies.
36 */
f3bc099d 37if (!function_exists('sqm_baseuri')){
86725763 38 require_once(SM_PATH . 'functions/display_messages.php');
f3bc099d 39}
40$base_uri = sqm_baseuri();
8e2ed807 41
98f2ee76 42/*
43 * In case the last session was not terminated properly, make sure
44 * we get a new one.
45 */
5250f7e7 46
69146537 47sqsession_destroy();
48
98f2ee76 49header('Pragma: no-cache');
50
51do_hook('login_cookie');
52
53/* Output the javascript onload function. */
54
d68323ff 55$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
98f2ee76 56 "<!--\n".
57 " function squirrelmail_loginpage_onload() {\n".
58 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
03ccb49b 59 " var textElements = 0;\n".
60 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
61 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
62 " textElements++;\n".
63 " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
64 " document.forms[0].elements[i].focus();\n".
65 " break;\n".
66 " }\n".
67 " }\n".
68 " }\n".
98f2ee76 69 " }\n".
70 "// -->\n".
71 "</script>\n";
a714cb95 72$custom_css = 'none';
98f2ee76 73displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
74
1cac3b9b 75echo '<body text="#000000" bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="squirrelmail_loginpage_onload();">' .
76 "\n" . '<form action="redirect.php" method="post">' . "\n";
98f2ee76 77
0fce910a 78$username_form_name = 'login_username';
79$password_form_name = 'secretkey';
98f2ee76 80do_hook('login_top');
81
5250f7e7 82$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
98f2ee76 83
78b2428e 84/* If they don't have a logo, don't bother.. */
85if (isset($org_logo) && $org_logo) {
86 /* Display width and height like good little people */
87 $width_and_height = '';
88 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
89 $org_logo_width>0) {
90 $width_and_height = " width=\"$org_logo_width\"";
91 }
92 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
93 $org_logo_height>0) {
94 $width_and_height .= " height=\"$org_logo_height\"";
95 }
98f2ee76 96}
3fde693b 97
1cac3b9b 98echo html_tag( 'table',
8e2ed807 99 html_tag( 'tr',
100 html_tag( 'td',
101 '<center>'.
78b2428e 102 ( isset($org_logo) && $org_logo
103 ? '<img src="' . $org_logo . '" alt="' .
104 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
105 ' /><br />' . "\n"
106 : '' ).
8a97a070 107 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
d68323ff 108 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
109 ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) .
8e2ed807 110 html_tag( 'table',
111 html_tag( 'tr',
112 html_tag( 'td',
113 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
114 'center', '#DCDCDC' )
115 ) .
116 html_tag( 'tr',
117 html_tag( 'td', "\n" .
118 html_tag( 'table',
119 html_tag( 'tr',
120 html_tag( 'td',
121 _("Name:") ,
122 'right', '', 'width="30%"' ) .
123 html_tag( 'td',
d68323ff 124 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'" />' ,
8e2ed807 125 'left', '', 'width="*"' )
126 ) . "\n" .
127 html_tag( 'tr',
128 html_tag( 'td',
129 _("Password:") ,
130 'right', '', 'width="30%"' ) .
131 html_tag( 'td',
d68323ff 132 '<input type="password" name="' . $password_form_name . '" />' . "\n" .
133 '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF" />' . "\n" .
134 '<input type="hidden" name="just_logged_in" value="1" />' . "\n",
8e2ed807 135 'left', '', 'width="*"' )
136 ) ,
12ff1cab 137 'center', '#ffffff', 'border="0" width="100%"' ) ,
8e2ed807 138 'left', '#FFFFFF' )
139 ) .
140 html_tag( 'tr',
141 html_tag( 'td',
d68323ff 142 '<center><input type="submit" value="' . _("Login") . '" /></center>',
8e2ed807 143 'left' )
144 ),
12ff1cab 145 '', '#ffffff', 'border="0" width="350"' ) . '</center>',
8e2ed807 146 'center' )
147 ) ,
cbaf4cf1 148'', '#ffffff', 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
98f2ee76 149do_hook('login_form');
cbaf4cf1 150echo '</form>' . "\n";
98f2ee76 151
152do_hook('login_bottom');
8e2ed807 153echo "</body>\n".
154 "</html>\n";
155?>