Began rework of options page. Also added 3 plugins (filters, translate, and squirrels...
[squirrelmail.git] / src / login.php
1 <?php
2 /**
3 ** login.php -- simple login screen
4 **
5 ** Copyright (c) 1999-2000 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 if (($pos = strpos($rcptaddress, '?')) !== false)
22 {
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 $$name = $val;
31 }
32 }
33
34 // At this point, we have parsed a lot of the mailto stuff. Let's
35 // do the rest -- CC, BCC, Subject, Body
36 // Note: They can all be case insensitive
37 foreach ($GLOBALS as $k => $v)
38 {
39 $key = strtolower($k);
40 $value = urlencode($v);
41 if ($key == 'cc')
42 $rcptaddress .= '&send_to_cc=' . $value;
43 elseif ($key == 'bcc')
44 $rcptaddress .= '&send_to_bcc=' . $value;
45 elseif ($key == 'subject')
46 $rcptaddress .= '&subject=' . $value;
47 elseif ($key == 'body')
48 $rcptaddress .= '&body=' . $value;
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
60 // $squirrelmail_language is set by a cookie when the user selects
61 // language and logs out
62 set_up_language($squirrelmail_language, true);
63
64 // Need the base URI to set the cookies. (Same code as in webmail.php)
65 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
66 $base_uri = $regs[1];
67
68 @session_destroy();
69 // In case the last session was not terminated properly, make sure
70 // we get a new one.
71 $cookie_params = session_get_cookie_params();
72 setcookie(session_name(),'',0,$cookie_params['path'].$cookie_params['domain']);
73 setcookie('username', '', 0, $base_uri);
74 setcookie('key', '', 0, $base_uri);
75 header ('Pragma: no-cache');
76
77 do_hook('login_cookie');
78
79 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
80 "\n\n" .
81 "<HTML>\n" .
82 "<HEAD>\n";
83
84 if ($theme_css != "")
85 echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">\n";
86
87 echo '<TITLE>';
88 echo $org_name . ' - ' . _("Login");
89 echo "</TITLE></HEAD>\n";
90 echo "<BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#0000CC VLINK=#0000CC ALINK=#0000CC onLoad='document.forms[0].elements[0].focus();'>\n";
91 echo "<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
92
93 $username_form_name = 'login_username';
94 $password_form_name = 'secretkey';
95 do_hook('login_top');
96
97 echo "<CENTER><IMG SRC=\"$org_logo\"></CENTER>\n";
98 echo "<CENTER><SMALL>";
99 printf (_("SquirrelMail version %s"), $version);
100 echo "<BR>\n";
101 echo _("By the SquirrelMail Development Team");
102 echo "<BR></SMALL><CENTER>\n";
103 echo "<TABLE COLS=1 WIDTH=350>\n";
104 echo " <TR>\n";
105 echo " <TD BGCOLOR=#DCDCDC>\n";
106 echo " <B><CENTER>";
107 printf (_("%s Login"), $org_name);
108 echo "</CENTER></B>\n";
109 echo " </TD>\n";
110 echo " </TR><TR>\n";
111 echo " <TD BGCOLOR=#FFFFFF>\n";
112 echo " <TABLE COLS=2 WIDTH=100%>\n";
113 echo " <TR>\n";
114 echo " <TD WIDTH=30% ALIGN=right>\n";
115 echo _("Name:");
116 echo " </TD><TD WIDTH=* ALIGN=left>\n";
117 echo " <INPUT TYPE=TEXT NAME=\"$username_form_name\"";
118 if (isset($loginname))
119 echo " value=\"" . htmlspecialchars($loginname) . "\"";
120 echo ">\n";
121 echo " </TD>\n";
122 echo " </TR><TR>\n";
123 echo " <TD WIDTH=30% ALIGN=right>\n";
124 echo _("Password:");
125 echo " </TD><TD WIDTH=* ALIGN=left>\n";
126 echo " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n";
127 echo " </TD>\n";
128 if ($rcptaddress != '') {
129 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
130 }
131 echo " </TR>\n";
132 echo " </TABLE>\n";
133 echo " </TD>\n";
134 echo " </TR><TR>\n";
135 echo " <TD>\n";
136 echo ' <CENTER><INPUT TYPE=SUBMIT VALUE="';
137 echo _("Login");
138 echo "\"></CENTER>\n";
139 echo " </TD>\n";
140 echo " </TR>\n";
141 echo "</TABLE>\n";
142 echo "<input type=hidden name=just_logged_in value=1>\n";
143 do_hook('login_form');
144 echo "</FORM>\n";
145 do_hook('login_bottom');
146 ?>
147 </BODY>
148 </HTML>
149