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