Add check of configuration file.
[squirrelmail.git] / src / login.php
1 <?php
2
3 /**
4 ** login.php -- simple login screen
5 **
6 ** Copyright (c) 1999-2001 The Squirrelmail Development 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 $rcptaddress = '';
16 if (isset($emailaddress)) {
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;
31 $$naame = $val;
32 }
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') {
42 $rcptaddress .= '&send_to_cc=' . $value;
43 } else if ($key == 'bcc') {
44 $rcptaddress .= '&send_to_bcc=' . $value;
45 } else if ($key == 'subject') {
46 $rcptaddress .= '&subject=' . $value;
47 } else if ($key == 'body') {
48 $rcptaddress .= '&body=' . $value;
49 }
50 }
51
52 /* Double-encode in this fashion to get past redirect.php properly. */
53 $rcptaddress = urlencode($rcptaddress);
54 }
55
56 /* Check if system has been configured */
57 if ( !file_exists( '../config/config.php' ) ) {
58 echo "<html>\n".
59 "<head>\n".
60 '<title>' . _("Configuration Error") . "</title>\n".
61 "</head>\n".
62 "<body>\n" .
63 '<center><h1>' .
64 _("This system has not been configured yet.") .
65 '<br>' .
66 _("Please contact system administrator.") .
67 '</h1></center>'.
68 "</body></html>\n";
69 exit;
70 }
71
72 require_once('../functions/strings.php');
73 require_once('../config/config.php');
74 require_once('../functions/i18n.php');
75 require_once('../functions/plugin.php');
76 require_once('../functions/constants.php');
77 require_once('../functions/page_header.php');
78
79 /*
80 * $squirrelmail_language is set by a cookie when the user selects
81 * language and logs out
82 */
83 set_up_language($squirrelmail_language, true);
84
85 /* Need the base URI to set the cookies. (Same code as in webmail.php). */
86 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
87 $base_uri = $regs[1];
88 @session_destroy();
89
90 /*
91 * In case the last session was not terminated properly, make sure
92 * we get a new one.
93 */
94 $cookie_params = session_get_cookie_params();
95 setcookie(session_name(),'',0,$cookie_params['path'].$cookie_params['domain']);
96 setcookie('username', '', 0, $base_uri);
97 setcookie('key', '', 0, $base_uri);
98 header ('Pragma: no-cache');
99
100 do_hook('login_cookie');
101
102 /* Output the javascript onload function. */
103 displayHtmlHeader( "$org_name - " . _("Login"),
104 "<SCRIPT LANGUAGE=\"JavaScript\">\n" .
105 "<!--\n".
106 " function squirrelmail_loginpage_onload() {\n".
107 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
108 " document.forms[0].elements[0].focus();\n".
109 " }\n".
110 "// -->\n".
111 "</script>\n", FALSE );
112
113 /* Set the title of this page. */
114 echo "<BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#0000CC VLINK=#0000CC ALINK=#0000CC onLoad='squirrelmail_loginpage_onload();'>\n".
115 "<FORM ACTION=\"redirect.php\" METHOD=\"POST\" NAME=f>\n";
116
117 $username_form_name = 'login_username';
118 $password_form_name = 'secretkey';
119 do_hook('login_top');
120
121 $loginname_value = (isset($loginname) ? htmlspecialchars($loginname) : '');
122
123 echo "<CENTER>".
124 " <IMG SRC=\"$org_logo\"><BR>\n".
125 ( $hide_sm_attributions ? '' :
126 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
127 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
128 "</CENTER>\n".
129
130 "<CENTER>\n".
131 "<TABLE COLS=1 WIDTH=350>\n".
132 " <TR><TD BGCOLOR=#DCDCDC>\n".
133 ' <B><CENTER>' . sprintf (_("%s Login"), $org_name) . "</CENTER></B>\n".
134 " </TD></TR>".
135 " <TR><TD BGCOLOR=\"#FFFFFF\"><TABLE COLS=2 WIDTH=\"100%\">\n".
136 " <TR>\n".
137 ' <TD WIDTH=30% ALIGN=right>' . _("Name:") . "</TD>\n".
138 " <TD WIDTH=* ALIGN=left>\n".
139 " <INPUT TYPE=TEXT NAME=\"$username_form_name\" VALUE=\"$loginname_value\">\n".
140 " </TD>\n".
141 " </TR>\n".
142 " <TR>\n".
143 ' <TD WIDTH="30%" ALIGN=right>' . _("Password:") . "</TD>\n".
144 " <TD WIDTH=* ALIGN=left>\n".
145 " <INPUT TYPE=PASSWORD NAME=\"$password_form_name\">\n".
146 " <INPUT TYPE=HIDDEN NAME=\"js_autodetect_results\" VALUE=\"" . SMPREF_JS_OFF . "\">\n".
147 " <INPUT TYPE=HIDDEN NAME=\"just_logged_in\" value=1>\n";
148 if ($rcptaddress != '') {
149 echo " <INPUT TYPE=HIDDEN NAME=\"rcptemail\" VALUE=\"".htmlspecialchars($rcptaddress)."\">\n";
150 }
151 echo " </TD>\n".
152 " </TR>\n".
153 " </TABLE></TD></TR>\n".
154 " <TR><TD>\n".
155 ' <CENTER><INPUT TYPE=SUBMIT VALUE="' . _("Login") . "\"></CENTER>\n".
156 " </TD></TR>\n".
157 "</TABLE>\n".
158 "</CENTER>\n";
159
160 do_hook('login_form');
161 echo "</FORM>\n";
162
163 do_hook('login_bottom');
164 echo "</BODY>\n".
165 "</HTML>\n";
166 ?>