Getting ready for 1.2.0 release.
[squirrelmail.git] / src / login.php
1 <?php
2
3 /**
4 * login.php -- simple login screen
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
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 */
14
15 /*****************************************************************/
16 /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
17 /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
18 /*** + Base level indent should begin at left margin, as ***/
19 /*** the first two lines below look. ***/
20 /*** + All identation should consist of four space blocks ***/
21 /*** + Tab characters are evil. ***/
22 /*** + all comments should use "slash-star ... star-slash" ***/
23 /*** style -- no pound characters, no slash-slash style ***/
24 /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
25 /*** ALWAYS USE { AND } CHARACTERS!!! ***/
26 /*** + Please use ' instead of ", when possible. Note " ***/
27 /*** should always be used in _( ) function calls. ***/
28 /*** Thank you for your help making the SM code more readable. ***/
29 /*****************************************************************/
30
31 $rcptaddress = '';
32 if (isset($emailaddress)) {
33 if (stristr($emailaddress, 'mailto:')) {
34 $rcptaddress = substr($emailaddress, 7);
35 } else {
36 $rcptaddress = $emailaddress;
37 }
38
39 if (($pos = strpos($rcptaddress, '?')) !== false) {
40 $a = substr($rcptaddress, $pos + 1);
41 $rcptaddress = substr($rcptaddress, 0, $pos);
42 $a = explode('=', $a, 2);
43 if (isset($a[1])) {
44 $name = urldecode($a[0]);
45 $val = urldecode($a[1]);
46 global $$name;
47 $$naame = $val;
48 }
49 }
50
51 /* At this point, we have parsed a lot of the mailto stuff. */
52 /* Let's do the rest -- CC, BCC, Subject, Body */
53 /* Note: They can all be case insensitive */
54 foreach ($GLOBALS as $k => $v) {
55 $key = strtolower($k);
56 $value = urlencode($v);
57 if ($key == 'cc') {
58 $rcptaddress .= '&send_to_cc=' . $value;
59 } else if ($key == 'bcc') {
60 $rcptaddress .= '&send_to_bcc=' . $value;
61 } else if ($key == 'subject') {
62 $rcptaddress .= '&subject=' . $value;
63 } else if ($key == 'body') {
64 $rcptaddress .= '&body=' . $value;
65 }
66 }
67
68 /* Double-encode in this fashion to get past redirect.php properly. */
69 $rcptaddress = urlencode($rcptaddress);
70 }
71
72
73
74 require_once('../functions/strings.php');
75 require_once('../config/config.php');
76 require_once('../functions/i18n.php');
77 require_once('../functions/plugin.php');
78 require_once('../functions/constants.php');
79 require_once('../functions/page_header.php');
80
81 /*
82 * $squirrelmail_language is set by a cookie when the user selects
83 * language and logs out
84 */
85 set_up_language($squirrelmail_language, true);
86
87 /* Need the base URI to set the cookies. (Same code as in webmail.php). */
88 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
89 $base_uri = $regs[1];
90 @session_destroy();
91
92 /*
93 * In case the last session was not terminated properly, make sure
94 * we get a new one.
95 */
96 $cookie_params = session_get_cookie_params();
97 setcookie(session_name(),'',0,$cookie_params['path'].$cookie_params['domain']);
98 setcookie('username', '', 0, $base_uri);
99 setcookie('key', '', 0, $base_uri);
100 header ('Pragma: no-cache');
101
102 do_hook('login_cookie');
103
104 /* Output the javascript onload function. */
105 displayHtmlHeader( "$org_name - " . _("Login"),
106 "<SCRIPT LANGUAGE=\"JavaScript\">\n" .
107 "<!--\n".
108 " function squirrelmail_loginpage_onload() {\n".
109 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
110 " document.forms[0].elements[0].focus();\n".
111 " }\n".
112 "// -->\n".
113 "</script>\n", FALSE );
114
115 /* Set the title of this page. */
116 echo "<BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#0000CC VLINK=#0000CC ALINK=#0000CC onLoad='squirrelmail_loginpage_onload();'>\n".
117 "<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
118
119 $username_form_name = 'login_username';
120 $password_form_name = 'secretkey';
121 do_hook('login_top');
122
123 $loginname_value = (isset($loginname) ? htmlspecialchars($loginname) : '');
124
125 echo "<CENTER>".
126 " <IMG SRC=\"$org_logo\"><BR>\n".
127 ( $hide_sm_attributions ? '' :
128 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
129 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
130 "</CENTER>\n".
131
132 "<CENTER>\n".
133 "<TABLE COLS=1 WIDTH=350>\n".
134 " <TR><TD BGCOLOR=#DCDCDC>\n".
135 ' <B><CENTER>' . sprintf (_("%s Login"), $org_name) . "</CENTER></B>\n".
136 " </TD></TR>".
137 " <TR><TD BGCOLOR=\"#FFFFFF\"><TABLE COLS=2 WIDTH=\"100%\">\n".
138 " <TR>\n".
139 ' <TD WIDTH=30% ALIGN=right>' . _("Name:") . "</TD>\n".
140 " <TD WIDTH=* ALIGN=left>\n".
141 " <INPUT TYPE=TEXT NAME=\"$username_form_name\" VALUE=\"$loginname_value\">\n".
142 " </TD>\n".
143 " </TR>\n".
144 " <TR>\n".
145 ' <TD WIDTH="30%" ALIGN=right>' . _("Password:") . "</TD>\n".
146 " <TD WIDTH=* ALIGN=left>\n".
147 " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n".
148 " <INPUT TYPE=HIDDEN NAME=\"js_autodetect_results\" VALUE=\"" . SMPREF_JS_OFF . "\">\n".
149 " <INPUT TYPE=HIDDEN NAME=\"just_logged_in\" value=1>\n";
150 if ($rcptaddress != '') {
151 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
152 }
153 echo " </TD>\n".
154 " </TR>\n".
155 " </TABLE></TD></TR>\n".
156 " <TR><TD>\n".
157 ' <CENTER><INPUT TYPE=SUBMIT VALUE="' . _("Login") . "\"></CENTER>\n".
158 " </TD></TR>\n".
159 "</TABLE>\n".
160 "</CENTER>\n";
161
162 do_hook('login_form');
163 echo "</FORM>\n";
164
165 do_hook('login_bottom');
166 echo "</BODY>\n".
167 "</HTML>\n";
168 ?>