Lots of changes for variable initialization - clean up, really,
[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
d68323ff 75echo '<body text="#000000" bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="squirrelmail_loginpage_onload();">';
98f2ee76 76
0fce910a 77$username_form_name = 'login_username';
78$password_form_name = 'secretkey';
98f2ee76 79do_hook('login_top');
80
5250f7e7 81$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
98f2ee76 82
78b2428e 83/* If they don't have a logo, don't bother.. */
84if (isset($org_logo) && $org_logo) {
85 /* Display width and height like good little people */
86 $width_and_height = '';
87 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
88 $org_logo_width>0) {
89 $width_and_height = " width=\"$org_logo_width\"";
90 }
91 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
92 $org_logo_height>0) {
93 $width_and_height .= " height=\"$org_logo_height\"";
94 }
98f2ee76 95}
f11c804f 96global $shootMyFootOff;
97if (check_php_version(4,3) and !isset($shootMyFootOff)) {
98 echo '<center><hr width="75%">' . "\n";
99 echo '<h2>PHP 4.3.x has been detected</h2>' . "\n";
100 echo '</center><p>The SquirrelMail team does not recommend the use of PHP 4.3.x with';
101 echo ' this software. Please see the <a href="http://www.squirrelmail.org">SquirrelMail';
102 echo ' website</a>, or the documentation that came with SquirrelMail for more information.</p>';
103 echo '<p>This warning can be disabled by either downgrading PHP, or inserting';
104 echo '"$shootMyFootOff = true;" in config/config_local.php.</p>' . "\n";
105 echo '<center><hr width="75%"></center>' . "\n";
106 echo "\n";
107}
3fde693b 108
8e2ed807 109echo "\n" . '<form action="redirect.php" method="post">' . "\n" .
110html_tag( 'table',
111 html_tag( 'tr',
112 html_tag( 'td',
113 '<center>'.
78b2428e 114 ( isset($org_logo) && $org_logo
115 ? '<img src="' . $org_logo . '" alt="' .
116 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
117 ' /><br />' . "\n"
118 : '' ).
8e2ed807 119 ( $hide_sm_attributions ? '' :
d68323ff 120 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
121 ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) .
8e2ed807 122 html_tag( 'table',
123 html_tag( 'tr',
124 html_tag( 'td',
125 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
126 'center', '#DCDCDC' )
127 ) .
128 html_tag( 'tr',
129 html_tag( 'td', "\n" .
130 html_tag( 'table',
131 html_tag( 'tr',
132 html_tag( 'td',
133 _("Name:") ,
134 'right', '', 'width="30%"' ) .
135 html_tag( 'td',
d68323ff 136 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'" />' ,
8e2ed807 137 'left', '', 'width="*"' )
138 ) . "\n" .
139 html_tag( 'tr',
140 html_tag( 'td',
141 _("Password:") ,
142 'right', '', 'width="30%"' ) .
143 html_tag( 'td',
d68323ff 144 '<input type="password" name="' . $password_form_name . '" />' . "\n" .
145 '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF" />' . "\n" .
146 '<input type="hidden" name="just_logged_in" value="1" />' . "\n",
8e2ed807 147 'left', '', 'width="*"' )
148 ) ,
12ff1cab 149 'center', '#ffffff', 'border="0" width="100%"' ) ,
8e2ed807 150 'left', '#FFFFFF' )
151 ) .
152 html_tag( 'tr',
153 html_tag( 'td',
d68323ff 154 '<center><input type="submit" value="' . _("Login") . '" /></center>',
8e2ed807 155 'left' )
156 ),
12ff1cab 157 '', '#ffffff', 'border="0" width="350"' ) . '</center>',
8e2ed807 158 'center' )
159 ) ,
cbaf4cf1 160'', '#ffffff', 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
98f2ee76 161do_hook('login_form');
cbaf4cf1 162echo '</form>' . "\n";
98f2ee76 163
164do_hook('login_bottom');
8e2ed807 165echo "</body>\n".
166 "</html>\n";
167?>