Remove the hard coded colors, and use the default theme and css file (set in conf...
[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";
dfb94cac 72
73if (@file_exists($theme[$theme_default]['PATH']))
74 @include ($theme[$theme_default]['PATH']);
75
98f2ee76 76displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
77
dfb94cac 78echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" squirrelmail_loginpage_onload();>" .
1cac3b9b 79 "\n" . '<form action="redirect.php" method="post">' . "\n";
98f2ee76 80
0fce910a 81$username_form_name = 'login_username';
82$password_form_name = 'secretkey';
98f2ee76 83do_hook('login_top');
84
5250f7e7 85$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
98f2ee76 86
78b2428e 87/* If they don't have a logo, don't bother.. */
88if (isset($org_logo) && $org_logo) {
89 /* Display width and height like good little people */
90 $width_and_height = '';
91 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
92 $org_logo_width>0) {
93 $width_and_height = " width=\"$org_logo_width\"";
94 }
95 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
96 $org_logo_height>0) {
97 $width_and_height .= " height=\"$org_logo_height\"";
98 }
98f2ee76 99}
3fde693b 100
c67e4479 101if(sqgetGlobalVar('mailto', $mailto)) {
102 $rcptaddress = '<input type="hidden" name="mailto" value="' . urlencode($mailto) . '" />' . "\n";
103} else {
104 $rcptaddress = '';
105}
1cac3b9b 106echo html_tag( 'table',
8e2ed807 107 html_tag( 'tr',
108 html_tag( 'td',
109 '<center>'.
78b2428e 110 ( isset($org_logo) && $org_logo
111 ? '<img src="' . $org_logo . '" alt="' .
112 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
113 ' /><br />' . "\n"
114 : '' ).
8a97a070 115 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
d68323ff 116 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
117 ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) .
8e2ed807 118 html_tag( 'table',
119 html_tag( 'tr',
120 html_tag( 'td',
121 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
dfb94cac 122 'center', $color[0] )
8e2ed807 123 ) .
124 html_tag( 'tr',
125 html_tag( 'td', "\n" .
126 html_tag( 'table',
127 html_tag( 'tr',
128 html_tag( 'td',
129 _("Name:") ,
130 'right', '', 'width="30%"' ) .
131 html_tag( 'td',
d68323ff 132 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'" />' ,
8e2ed807 133 'left', '', 'width="*"' )
134 ) . "\n" .
135 html_tag( 'tr',
136 html_tag( 'td',
137 _("Password:") ,
138 'right', '', 'width="30%"' ) .
139 html_tag( 'td',
d68323ff 140 '<input type="password" name="' . $password_form_name . '" />' . "\n" .
141 '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF" />' . "\n" .
c67e4479 142 $rcptaddress .
d68323ff 143 '<input type="hidden" name="just_logged_in" value="1" />' . "\n",
8e2ed807 144 'left', '', 'width="*"' )
145 ) ,
dfb94cac 146 'center', $color[4], 'border="0" width="100%"' ) ,
147 'left', $color[4] )
8e2ed807 148 ) .
149 html_tag( 'tr',
150 html_tag( 'td',
d68323ff 151 '<center><input type="submit" value="' . _("Login") . '" /></center>',
8e2ed807 152 'left' )
153 ),
dfb94cac 154 '', $color[4], 'border="0" width="350"' ) . '</center>',
8e2ed807 155 'center' )
156 ) ,
dfb94cac 157'', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
98f2ee76 158do_hook('login_form');
cbaf4cf1 159echo '</form>' . "\n";
98f2ee76 160
161do_hook('login_bottom');
8e2ed807 162echo "</body>\n".
163 "</html>\n";
164?>