Basic mailto: support.
[squirrelmail.git] / src / login.php
1 <?php
2
3 /**
4 * login.php -- simple login screen
5 *
6 * Copyright (c) 1999-2003 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 /* Path for SquirrelMail required files. */
16 define('SM_PATH','../');
17
18 /* SquirrelMail required files. */
19 require_once(SM_PATH . 'functions/strings.php');
20 require_once(SM_PATH . 'config/config.php');
21 require_once(SM_PATH . 'functions/i18n.php');
22 require_once(SM_PATH . 'functions/plugin.php');
23 require_once(SM_PATH . 'functions/constants.php');
24 require_once(SM_PATH . 'functions/page_header.php');
25 require_once(SM_PATH . 'functions/html.php');
26 require_once(SM_PATH . 'functions/global.php');
27
28 /*
29 * $squirrelmail_language is set by a cookie when the user selects
30 * language and logs out
31 */
32 set_up_language($squirrelmail_language, TRUE);
33
34 /**
35 * Find out the base URI to set cookies.
36 */
37 if (!function_exists('sqm_baseuri')){
38 require_once(SM_PATH . 'functions/display_messages.php');
39 }
40 $base_uri = sqm_baseuri();
41
42 /*
43 * In case the last session was not terminated properly, make sure
44 * we get a new one.
45 */
46
47 sqsession_destroy();
48
49 header('Pragma: no-cache');
50
51 do_hook('login_cookie');
52
53 /* Output the javascript onload function. */
54
55 $header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
56 "<!--\n".
57 " function squirrelmail_loginpage_onload() {\n".
58 " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
59 " var textElements = 0;\n".
60 " for (i = 0; i < document.forms[0].elements.length; i++) {\n".
61 " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
62 " textElements++;\n".
63 " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
64 " document.forms[0].elements[i].focus();\n".
65 " break;\n".
66 " }\n".
67 " }\n".
68 " }\n".
69 " }\n".
70 "// -->\n".
71 "</script>\n";
72 $custom_css = 'none';
73 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
74
75 echo '<body text="#000000" bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="squirrelmail_loginpage_onload();">' .
76 "\n" . '<form action="redirect.php" method="post">' . "\n";
77
78 $username_form_name = 'login_username';
79 $password_form_name = 'secretkey';
80 do_hook('login_top');
81
82 $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
83
84 /* If they don't have a logo, don't bother.. */
85 if (isset($org_logo) && $org_logo) {
86 /* Display width and height like good little people */
87 $width_and_height = '';
88 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
89 $org_logo_width>0) {
90 $width_and_height = " width=\"$org_logo_width\"";
91 }
92 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
93 $org_logo_height>0) {
94 $width_and_height .= " height=\"$org_logo_height\"";
95 }
96 }
97
98 if(sqgetGlobalVar('mailto', $mailto)) {
99 $rcptaddress = '<input type="hidden" name="mailto" value="' . urlencode($mailto) . '" />' . "\n";
100 } else {
101 $rcptaddress = '';
102 }
103 echo html_tag( 'table',
104 html_tag( 'tr',
105 html_tag( 'td',
106 '<center>'.
107 ( isset($org_logo) && $org_logo
108 ? '<img src="' . $org_logo . '" alt="' .
109 sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
110 ' /><br />' . "\n"
111 : '' ).
112 ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
113 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
114 ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) .
115 html_tag( 'table',
116 html_tag( 'tr',
117 html_tag( 'td',
118 '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
119 'center', '#DCDCDC' )
120 ) .
121 html_tag( 'tr',
122 html_tag( 'td', "\n" .
123 html_tag( 'table',
124 html_tag( 'tr',
125 html_tag( 'td',
126 _("Name:") ,
127 'right', '', 'width="30%"' ) .
128 html_tag( 'td',
129 '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'" />' ,
130 'left', '', 'width="*"' )
131 ) . "\n" .
132 html_tag( 'tr',
133 html_tag( 'td',
134 _("Password:") ,
135 'right', '', 'width="30%"' ) .
136 html_tag( 'td',
137 '<input type="password" name="' . $password_form_name . '" />' . "\n" .
138 '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF" />' . "\n" .
139 $rcptaddress .
140 '<input type="hidden" name="just_logged_in" value="1" />' . "\n",
141 'left', '', 'width="*"' )
142 ) ,
143 'center', '#ffffff', 'border="0" width="100%"' ) ,
144 'left', '#FFFFFF' )
145 ) .
146 html_tag( 'tr',
147 html_tag( 'td',
148 '<center><input type="submit" value="' . _("Login") . '" /></center>',
149 'left' )
150 ),
151 '', '#ffffff', 'border="0" width="350"' ) . '</center>',
152 'center' )
153 ) ,
154 '', '#ffffff', 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
155 do_hook('login_form');
156 echo '</form>' . "\n";
157
158 do_hook('login_bottom');
159 echo "</body>\n".
160 "</html>\n";
161 ?>