better default for printer_friendly option
[squirrelmail.git] / src / login.php
1 <?php
2 /**
3 * login.php -- simple login screen
4 *
5 * Copyright (c) 1999-2001 The Squirrelmail Development Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This a simple login screen. Some housekeeping is done to clean
9 * cookies and find language.
10 *
11 * $Id$
12 */
13
14 $rcptaddress = '';
15 if (isset($emailaddress)) {
16 if (stristr($emailaddress, 'mailto:')) {
17 $rcptaddress = substr($emailaddress, 7);
18 } else {
19 $rcptaddress = $emailaddress;
20 }
21
22 if (($pos = strpos($rcptaddress, '?')) !== false) {
23 $a = substr($rcptaddress, $pos + 1);
24 $rcptaddress = substr($rcptaddress, 0, $pos);
25 $a = explode('=', $a, 2);
26 if (isset($a[1])) {
27 $name = urldecode($a[0]);
28 $val = urldecode($a[1]);
29 global $$name;
30 $$naame = $val;
31 }
32 }
33
34 /* At this point, we have parsed a lot of the mailto stuff. */
35 /* Let's do the rest -- CC, BCC, Subject, Body */
36 /* Note: They can all be case insensitive */
37 foreach ($GLOBALS as $k => $v) {
38 $key = strtolower($k);
39 $value = urlencode($v);
40 if ($key == 'cc') {
41 $rcptaddress .= '&send_to_cc=' . $value;
42 } else if ($key == 'bcc') {
43 $rcptaddress .= '&send_to_bcc=' . $value;
44 } else if ($key == 'subject') {
45 $rcptaddress .= '&subject=' . $value;
46 } else if ($key == 'body') {
47 $rcptaddress .= '&body=' . $value;
48 }
49 }
50
51 /* Double-encode in this fashion to get past redirect.php properly. */
52 $rcptaddress = urlencode($rcptaddress);
53 }
54
55 require_once('../functions/strings.php');
56 require_once('../config/config.php');
57 require_once('../functions/i18n.php');
58 require_once('../functions/plugin.php');
59 require_once('../functions/constants.php');
60 require_once('../functions/page_header.php');
61
62 /*
63 * $squirrelmail_language is set by a cookie when the user selects
64 * language and logs out
65 */
66 set_up_language($squirrelmail_language, true);
67
68 /* Need the base URI to set the cookies. (Same code as in webmail.php). */
69 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
70 $base_uri = $regs[1];
71 @session_destroy();
72
73 /*
74 * In case the last session was not terminated properly, make sure
75 * we get a new one.
76 */
77 $cookie_params = session_get_cookie_params();
78 setcookie(session_name(),'',0,$cookie_params['path'].$cookie_params['domain']);
79 setcookie('username', '', 0, $base_uri);
80 setcookie('key', '', 0, $base_uri);
81 header ('Pragma: no-cache');
82
83 do_hook('login_cookie');
84
85 /* Output the javascript onload function. */
86 displayHtmlHeader( "$org_name - " . _("Login"),
87 "<SCRIPT LANGUAGE=\"JavaScript\">\n" .
88 "<!--\n".
89 " function squirrelmail_loginpage_onload() {\n".
90 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
91 " document.forms[0].elements[0].focus();\n".
92 " }\n".
93 "// -->\n".
94 "</script>\n", FALSE );
95
96 /* Set the title of this page. */
97 echo "<BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#0000CC VLINK=#0000CC ALINK=#0000CC onLoad='squirrelmail_loginpage_onload();'>\n".
98 "<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
99
100 $username_form_name = 'login_username';
101 $password_form_name = 'secretkey';
102 do_hook('login_top');
103
104 $loginname_value = (isset($loginname) ? htmlspecialchars($loginname) : '');
105
106 echo "<CENTER>".
107 " <IMG SRC=\"$org_logo\"><BR>\n".
108 ( $hide_sm_attributions ? '' :
109 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
110 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
111 "</CENTER>\n".
112
113 "<CENTER>\n".
114 "<TABLE COLS=1 WIDTH=350>\n".
115 " <TR><TD BGCOLOR=#DCDCDC>\n".
116 ' <B><CENTER>' . sprintf (_("%s Login"), $org_name) . "</CENTER></B>\n".
117 " </TD></TR>".
118 " <TR><TD BGCOLOR=\"#FFFFFF\"><TABLE COLS=2 WIDTH=\"100%\">\n".
119 " <TR>\n".
120 ' <TD WIDTH=30% ALIGN=right>' . _("Name:") . "</TD>\n".
121 " <TD WIDTH=* ALIGN=left>\n".
122 " <INPUT TYPE=TEXT NAME=\"$username_form_name\" VALUE=\"$loginname_value\">\n".
123 " </TD>\n".
124 " </TR>\n".
125 " <TR>\n".
126 ' <TD WIDTH="30%" ALIGN=right>' . _("Password:") . "</TD>\n".
127 " <TD WIDTH=* ALIGN=left>\n".
128 " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n".
129 " <INPUT TYPE=HIDDEN NAME=\"js_autodetect_results\" VALUE=\"" . SMPREF_JS_OFF . "\">\n".
130 " <INPUT TYPE=HIDDEN NAME=\"just_logged_in\" value=1>\n";
131 if ($rcptaddress != '') {
132 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
133 }
134 echo " </TD>\n".
135 " </TR>\n".
136 " </TABLE></TD></TR>\n".
137 " <TR><TD>\n".
138 ' <CENTER><INPUT TYPE=SUBMIT VALUE="' . _("Login") . "\"></CENTER>\n".
139 " </TD></TR>\n".
140 "</TABLE>\n".
141 "</CENTER>\n";
142
143 do_hook('login_form');
144 echo "</FORM>\n";
145
146 do_hook('login_bottom');
147 echo "</BODY>\n".
148 "</HTML>\n";
149 ?>