remove trailing lines
[squirrelmail.git] / src / login.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * login.php -- simple login screen
5 *
15e6162e 6 * Copyright (c) 1999-2002 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 */
21c3249f 14
35586184 15$rcptaddress = '';
16if (isset($emailaddress)) {
98f2ee76 17 if (stristr($emailaddress, 'mailto:')) {
18 $rcptaddress = substr($emailaddress, 7);
19 } else {
20 $rcptaddress = $emailaddress;
21 }
22
23 if (($pos = strpos($rcptaddress, '?')) !== false) {
24 $a = substr($rcptaddress, $pos + 1);
25 $rcptaddress = substr($rcptaddress, 0, $pos);
26 $a = explode('=', $a, 2);
27 if (isset($a[1])) {
28 $name = urldecode($a[0]);
29 $val = urldecode($a[1]);
30 global $$name;
8675ae42 31 $$name = $val;
23d6bd09 32 }
98f2ee76 33 }
34
35 /* At this point, we have parsed a lot of the mailto stuff. */
36 /* Let's do the rest -- CC, BCC, Subject, Body */
37 /* Note: They can all be case insensitive */
38 foreach ($GLOBALS as $k => $v) {
39 $key = strtolower($k);
40 $value = urlencode($v);
41 if ($key == 'cc') {
5e9e90fd 42 $rcptaddress .= '&amp;send_to_cc=' . $value;
98f2ee76 43 } else if ($key == 'bcc') {
5e9e90fd 44 $rcptaddress .= '&amp;send_to_bcc=' . $value;
98f2ee76 45 } else if ($key == 'subject') {
5e9e90fd 46 $rcptaddress .= '&amp;subject=' . $value;
98f2ee76 47 } else if ($key == 'body') {
5e9e90fd 48 $rcptaddress .= '&amp;body=' . $value;
23d6bd09 49 }
23d6bd09 50 }
98f2ee76 51
52 /* Double-encode in this fashion to get past redirect.php properly. */
53 $rcptaddress = urlencode($rcptaddress);
54}
55
56require_once('../functions/strings.php');
57require_once('../config/config.php');
58require_once('../functions/i18n.php');
59require_once('../functions/plugin.php');
60require_once('../functions/constants.php');
61require_once('../functions/page_header.php');
62
63/*
64 * $squirrelmail_language is set by a cookie when the user selects
65 * language and logs out
66 */
67set_up_language($squirrelmail_language, TRUE);
d4e84069 68
85b454a0 69/**
70 * Find out the base URI to set cookies.
71 */
f3bc099d 72if (!function_exists('sqm_baseuri')){
73 require_once('../functions/display_messages.php');
74}
75$base_uri = sqm_baseuri();
98f2ee76 76@session_destroy();
cb48c245 77
98f2ee76 78/*
79 * In case the last session was not terminated properly, make sure
80 * we get a new one.
81 */
82$cookie_params = session_get_cookie_params();
85b454a0 83setcookie(session_name(), '', 0, $cookie_params['path'],
84 $cookie_params['domain']);
98f2ee76 85setcookie('username', '', 0, $base_uri);
86setcookie('key', '', 0, $base_uri);
87header('Pragma: no-cache');
88
89do_hook('login_cookie');
90
91/* Output the javascript onload function. */
92
93$header = "<SCRIPT LANGUAGE=\"JavaScript\">\n" .
94 "<!--\n".
95 " function squirrelmail_loginpage_onload() {\n".
96 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
97 ' document.forms[0].elements[' . (isset($loginname) ? 1 : 0) . "].focus();\n".
98 " }\n".
99 "// -->\n".
100 "</script>\n";
a714cb95 101$custom_css = 'none';
98f2ee76 102displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
103
104/* Set the title of this page. */
4da8e94a 105echo '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000CC" VLINK="#0000CC" ALINK="#0000CC" onLoad="squirrelmail_loginpage_onload();">'.
106 "\n<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
98f2ee76 107
0fce910a 108$username_form_name = 'login_username';
109$password_form_name = 'secretkey';
98f2ee76 110do_hook('login_top');
111
112$loginname_value = (isset($loginname) ? htmlspecialchars($loginname) : '');
113
b6e0c3b6 114/* Display width and height like good little people */
4da8e94a 115$width_and_height = '';
b6e0c3b6 116if (isset($org_logo_width) && is_int($org_logo_width) && $org_logo_width>0) {
117 $width_and_height = " WIDTH=\"$org_logo_width\"";
118}
119if (isset($org_logo_height) && is_int($org_logo_height) && $org_logo_height>0) {
120 $width_and_height .= " HEIGHT=\"$org_logo_height\"";
121}
122
4da8e94a 123echo '<CENTER>'.
b6e0c3b6 124 " <IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) .
125 "\"$width_and_height><BR>\n".
98f2ee76 126 ( $hide_sm_attributions ? '' :
127 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
128 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
129 "</CENTER>\n".
130
131 "<CENTER>\n".
132 "<TABLE COLS=1 WIDTH=350>\n".
133 " <TR><TD ALIGN=CENTER BGCOLOR=\"#DCDCDC\">\n".
134 ' <B>' . sprintf (_("%s Login"), $org_name) . "</B>\n".
135 " </TD></TR>".
136 " <TR><TD BGCOLOR=\"#FFFFFF\"><TABLE COLS=2 WIDTH=\"100%\">\n".
137 " <TR>\n".
138 ' <TD WIDTH="30%" ALIGN=right>' . _("Name:") . "</TD>\n".
139 " <TD WIDTH=\"*\" ALIGN=left>\n".
0fce910a 140 " <INPUT TYPE=TEXT NAME=\"$username_form_name\" VALUE=\"$loginname_value\">\n".
98f2ee76 141 " </TD>\n".
142 " </TR>\n".
143 " <TR>\n".
144 ' <TD WIDTH="30%" ALIGN=right>' . _("Password:") . "</TD>\n".
145 " <TD WIDTH=\"*\" ALIGN=left>\n".
0fce910a 146 " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n".
98f2ee76 147 " <INPUT TYPE=HIDDEN NAME=\"js_autodetect_results\" VALUE=\"" . SMPREF_JS_OFF . "\">\n".
148 " <INPUT TYPE=HIDDEN NAME=\"just_logged_in\" value=1>\n";
149if ($rcptaddress != '') {
150 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
151}
152echo " </TD>\n".
153 " </TR>\n".
154 " </TABLE></TD></TR>\n".
155 " <TR><TD>\n".
156 ' <CENTER><INPUT TYPE=SUBMIT VALUE="' . _("Login") . "\"></CENTER>\n".
157 " </TD></TR>\n".
158 "</TABLE>\n".
159 "</CENTER>\n";
160
161do_hook('login_form');
162echo "</FORM>\n";
163
164do_hook('login_bottom');
165echo "</BODY>\n".
166 "</HTML>\n";
4da8e94a 167?>