support for viewing headers of message/rfc822 attachments
[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');
3fde693b 62require_once('../functions/html.php');
98f2ee76 63
64/*
65 * $squirrelmail_language is set by a cookie when the user selects
66 * language and logs out
67 */
68set_up_language($squirrelmail_language, TRUE);
d4e84069 69
85b454a0 70/**
71 * Find out the base URI to set cookies.
72 */
f3bc099d 73if (!function_exists('sqm_baseuri')){
74 require_once('../functions/display_messages.php');
75}
76$base_uri = sqm_baseuri();
98f2ee76 77@session_destroy();
cb48c245 78
98f2ee76 79/*
80 * In case the last session was not terminated properly, make sure
81 * we get a new one.
82 */
83$cookie_params = session_get_cookie_params();
85b454a0 84setcookie(session_name(), '', 0, $cookie_params['path'],
85 $cookie_params['domain']);
98f2ee76 86setcookie('username', '', 0, $base_uri);
87setcookie('key', '', 0, $base_uri);
88header('Pragma: no-cache');
89
90do_hook('login_cookie');
91
92/* Output the javascript onload function. */
93
3fde693b 94$header = "<SCRIPT LANGUAGE=\"JavaScript\" type=\"text/javascript\">\n" .
98f2ee76 95 "<!--\n".
96 " function squirrelmail_loginpage_onload() {\n".
97 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
98 ' document.forms[0].elements[' . (isset($loginname) ? 1 : 0) . "].focus();\n".
99 " }\n".
100 "// -->\n".
101 "</script>\n";
a714cb95 102$custom_css = 'none';
98f2ee76 103displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
104
105/* Set the title of this page. */
3fde693b 106echo '<body text="#000000" bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="squirrelmail_loginpage_onload();">';
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 = '';
7407e21d 116if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
3fde693b 117 $width_and_height = " width=\"$org_logo_width\"";
b6e0c3b6 118}
7407e21d 119if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
3fde693b 120 $width_and_height .= " height=\"$org_logo_height\"";
b6e0c3b6 121}
122
3fde693b 123$rcptaddress_input = '';
98f2ee76 124if ($rcptaddress != '') {
3fde693b 125 $rcptaddress_input = '<input type="hidden" name="rcptemail" value="htmlspecialchars(' . $rcptaddress . ')">';
98f2ee76 126}
3fde693b 127
3af96461 128echo "\n" . '<form action="redirect.php" method="post">' . "\n" .
3fde693b 129html_tag( 'table',
130 html_tag( 'tr',
131 html_tag( 'td',
3fde693b 132 '<center>'.
133 '<img src="' . $org_logo . '" alt="' . sprintf(_("%s Logo"), $org_name) .'"' .
134 $width_and_height .'><br>' . "\n".
135 ( $hide_sm_attributions ? '' :
136 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br>' ."\n".
137 ' ' . _("By the SquirrelMail Development Team") . '<br></small>' . "\n" ) .
3fde693b 138 html_tag( 'table',
139 html_tag( 'tr',
140 html_tag( 'td',
141 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
3af96461 142 'center', '#DCDCDC' )
143 ) .
3fde693b 144 html_tag( 'tr',
145 html_tag( 'td', "\n" .
146 html_tag( 'table',
147 html_tag( 'tr',
148 html_tag( 'td',
149 _("Name:") ,
150 'right', '', 'width="30%"' ) .
151 html_tag( 'td',
152 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'">' ,
153 'left', '', 'width="*"' )
154 ) . "\n" .
155 html_tag( 'tr',
156 html_tag( 'td',
157 _("Password:") ,
158 'right', '', 'width="30%"' ) .
159 html_tag( 'td',
160 '<input type="password" name="' . $password_form_name . '">' . "\n" .
161 '<input type=hidden name="js_autodetect_results" value="SMPREF_JS_OFF">' . "\n" .
162 '<input type=hidden name="just_logged_in" value=1>' . "\n" .
163 $rcptaddress_input . "\n" ,
164 'left', '', 'width="*"' )
165 ) ,
3af96461 166 'center', '#ffffff', 'border="0" cols="2" width="100%"' ) ,
3fde693b 167 'left', '#FFFFFF' )
3af96461 168 ) .
3fde693b 169 html_tag( 'tr',
170 html_tag( 'td',
171 '<center><input type="submit" value="' . _("Login") . '"></center>',
172 'left' )
3af96461 173 ),
174 '', '#ffffff', 'border="0" cols="1" width="350"' ),
175 'center' )
3fde693b 176 ) ,
3af96461 177'', '#ffffff', 'border="0" cellspacing="0" cellpadding="0" width="100%"' ) .
178'</form>' . "\n";
98f2ee76 179
180do_hook('login_form');
98f2ee76 181
182do_hook('login_bottom');
3fde693b 183echo "</body>\n".
184 "</html>\n";
7407e21d 185?>