integrated xmailer plugin
[squirrelmail.git] / src / login.php
CommitLineData
59177427 1<?php
23d6bd09 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 */
21c3249f 13
23d6bd09 14 $rcptaddress = '';
15 if (isset($emailaddress)) {
16 if (stristr($emailaddress, 'mailto:')) {
17 $rcptaddress = substr($emailaddress, 7);
18 } else {
19 $rcptaddress = $emailaddress;
20 }
870fb6d3 21
23d6bd09 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 }
870fb6d3 33
23d6bd09 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 }
870fb6d3 50
23d6bd09 51 /* Double-encode in this fashion to get past redirect.php properly. */
52 $rcptaddress = urlencode($rcptaddress);
53 }
d4e84069 54
23d6bd09 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');
21c3249f 60
23d6bd09 61 /*
62 * $squirrelmail_language is set by a cookie when the user selects
63 * language and logs out
64 */
65 set_up_language($squirrelmail_language, true);
288491a4 66
23d6bd09 67 /* Need the base URI to set the cookies. (Same code as in webmail.php). */
68 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
69 $base_uri = $regs[1];
70 @session_destroy();
c6d6fe73 71
23d6bd09 72 /*
73 * In case the last session was not terminated properly, make sure
74 * we get a new one.
75 */
76 $cookie_params = session_get_cookie_params();
77 setcookie(session_name(),'',0,$cookie_params['path'].$cookie_params['domain']);
78 setcookie('username', '', 0, $base_uri);
79 setcookie('key', '', 0, $base_uri);
80 header ('Pragma: no-cache');
c6d6fe73 81
23d6bd09 82 do_hook('login_cookie');
1bfeac81 83
23d6bd09 84 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
85 "\n\n" .
86 "<HTML>\n" .
87 "<HEAD>\n";
1bfeac81 88
23d6bd09 89 if ($theme_css != "") {
90 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
91 }
9487c2ff 92
23d6bd09 93 /* Output the javascript onload function. */
94 echo "<SCRIPT LANGUAGE=\"JavaScript\">\n";
95 echo "<!--\n";
96 echo " function squirrelmail_loginpage_onload() {\n";
97 echo " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n";
98 echo " document.forms[0].elements[0].focus();\n";
99 echo " }\n";
100 echo "// -->\n";
101 echo "</script>\n";
102
103 /* Set the title of this page. */
104 echo "<TITLE>$org_name - " . _("Login") . "</TITLE></HEAD>\n";
105 echo "<BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#0000CC VLINK=#0000CC ALINK=#0000CC onLoad='squirrelmail_loginpage_onload();'>\n";
106 echo "<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
1899535f 107
23d6bd09 108 $username_form_name = 'login_username';
109 $password_form_name = 'secretkey';
110 do_hook('login_top');
111
112 $loginname_value = (isset($loginname) ? htmlspecialchars($loginname) : '');
1899535f 113
23d6bd09 114 echo "<CENTER><SMALL>";
115 echo " <IMG SRC=\"$org_logo\"><BR>\n";
116 echo ' ' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n";
117 echo ' ' . _("By the SquirrelMail Development Team") . "<BR>\n";
118 echo "</SMALL><CENTER>\n";
21c3249f 119
23d6bd09 120 echo "<TABLE COLS=1 WIDTH=350>\n";
121 echo " <TR><TD BGCOLOR=#DCDCDC>\n";
122 echo ' <B><CENTER>' . sprintf (_("%s Login"), $org_name) . "</CENTER></B>\n";
123 echo " </TD></TR>";
124 echo " <TR><TD BGCOLOR=\"#FFFFFF\"><TABLE COLS=2 WIDTH=\"100%\">\n";
125 echo " <TR>\n";
126 echo ' <TD WIDTH=30% ALIGN=right>' . _("Name:") . "</TD>\n";
127 echo " <TD WIDTH=* ALIGN=left>\n";
128 echo " <INPUT TYPE=TEXT NAME=\"$username_form_name\" VALUE=\"$loginname_value\">\n";
129 echo " </TD>\n";
130 echo " </TR>\n";
131 echo " <TR>\n";
132 echo ' <TD WIDTH="30%" ALIGN=right>' . _("Password:") . "</TD>\n";
133 echo " <TD WIDTH=* ALIGN=left>\n";
134 echo " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n";
135 echo " <INPUT TYPE=HIDDEN NAME=\"js_autodetect_results\" VALUE=\"" . SMPREF_JS_OFF . "\">\n";
136 echo " <INPUT TYPE=HIDDEN NAME=\"just_logged_in\" value=1>\n";
137 if ($rcptaddress != '') {
138 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
139 }
140 echo " </TD>\n";
141 echo " </TR>\n";
142 echo " </TABLE></TD></TR>\n";
143 echo " <TR><TD>\n";
144 echo ' <CENTER><INPUT TYPE=SUBMIT VALUE="' . _("Login") . "\"></CENTER>\n";
145 echo " </TD></TR>\n";
146 echo "</TABLE>\n";
147
148 do_hook('login_form');
149 echo "</FORM>\n";
150
151 do_hook('login_bottom');
152 echo "</BODY>\n";
153 echo "</HTML>\n";
154?>