59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * login.php -- simple login screen |
5 | * |
35586184 |
6 | * This a simple login screen. Some housekeeping is done to clean |
7 | * cookies and find language. |
8 | * |
47ccfad4 |
9 | * @copyright © 1999-2006 The SquirrelMail Project Team |
4b4abf93 |
10 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
11 | * @version $Id$ |
8f6f9ba5 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
8e2ed807 |
14 | |
30967a1e |
15 | /** |
16 | * Path for SquirrelMail required files. |
17 | * @ignore |
18 | */ |
86725763 |
19 | define('SM_PATH','../'); |
20 | |
21 | /* SquirrelMail required files. */ |
434d4114 |
22 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
23 | require_once(SM_PATH . 'functions/strings.php'); |
24 | require_once(SM_PATH . 'config/config.php'); |
25 | require_once(SM_PATH . 'functions/i18n.php'); |
26 | require_once(SM_PATH . 'functions/plugin.php'); |
27 | require_once(SM_PATH . 'functions/constants.php'); |
28 | require_once(SM_PATH . 'functions/page_header.php'); |
29 | require_once(SM_PATH . 'functions/html.php'); |
ea348fd3 |
30 | require_once(SM_PATH . 'functions/imap_general.php'); |
a34d6890 |
31 | require_once(SM_PATH . 'functions/forms.php'); |
98f2ee76 |
32 | |
8f6f9ba5 |
33 | /** |
98f2ee76 |
34 | * $squirrelmail_language is set by a cookie when the user selects |
35 | * language and logs out |
36 | */ |
5e2b6751 |
37 | set_up_language($squirrelmail_language, TRUE, TRUE); |
d4e84069 |
38 | |
85b454a0 |
39 | /** |
40 | * Find out the base URI to set cookies. |
41 | */ |
f3bc099d |
42 | $base_uri = sqm_baseuri(); |
8e2ed807 |
43 | |
98f2ee76 |
44 | /* |
45 | * In case the last session was not terminated properly, make sure |
46 | * we get a new one. |
47 | */ |
5250f7e7 |
48 | |
69146537 |
49 | sqsession_destroy(); |
07a52f9f |
50 | /** |
51 | * PHP bug. http://bugs.php.net/11643 (warning, spammed bug tracker) and |
52 | * http://bugs.php.net/13834 |
53 | * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other |
54 | * versions. Produces warning on login page. Bug should be fixed only in 4.3.0 |
55 | */ |
56 | @sqsession_start(); |
98f2ee76 |
57 | header('Pragma: no-cache'); |
58 | |
8f6f9ba5 |
59 | /** |
91e0dccc |
60 | * This detects if the IMAP server has logins disabled, and if so, |
8f6f9ba5 |
61 | * squelches the display of the login form and puts up a message |
62 | * explaining the situation. |
63 | */ |
6d611a76 |
64 | if($imap_auth_mech == 'login') { |
c0c5cf6a |
65 | /** |
f8a1ed5a |
66 | * detect disabled login, only when imapServerAddress contains |
c0c5cf6a |
67 | * server address and not mapping. See sqimap_get_user_server() |
68 | */ |
69 | if (substr($imapServerAddress, 0, 4) != "map:") { |
70 | $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls); |
71 | $logindisabled = sqimap_capability($imap,'LOGINDISABLED'); |
72 | sqimap_logout($imap); |
73 | if ($logindisabled) { |
74 | $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'. |
75 | _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />'; |
76 | if (!$use_imap_tls) { |
77 | $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />'; |
78 | } |
79 | $string .= _("Please contact your system administrator and report this error."); |
80 | error_box($string,$color); |
81 | exit; |
6d611a76 |
82 | } |
ea348fd3 |
83 | } |
ea348fd3 |
84 | } |
85 | |
c5330196 |
86 | /* |
87 | * Initialize the template object and custom error handler object |
88 | */ |
89 | include_once(SM_PATH . 'class/template/template.class.php'); |
90 | include_once(SM_PATH . 'class/error.class.php'); |
91 | |
92 | /* |
93 | * $sTplDir is not initialized when a user is not logged in, so we will use |
94 | * the config file defaults here. If the neccesary variables are net set, |
95 | * force a default value. |
96 | */ |
97 | $aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet ); |
98 | $templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default ); |
99 | $sTplDir = ( !isset($aTemplateSet[$templateset_default]['PATH']) ? |
100 | SM_PATH . 'templates/default/' : |
101 | $aTemplateSet[$templateset_default]['PATH'] ); |
102 | |
103 | $oTemplate = new Template($sTplDir); |
104 | $oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl'); |
105 | |
98f2ee76 |
106 | do_hook('login_cookie'); |
107 | |
bca2d025 |
108 | $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : ''); |
109 | |
98f2ee76 |
110 | /* Output the javascript onload function. */ |
2c92ea9d |
111 | $header = "<script type=\"text/javascript\">\n" . |
98f2ee76 |
112 | "<!--\n". |
113 | " function squirrelmail_loginpage_onload() {\n". |
03ccb49b |
114 | " var textElements = 0;\n". |
115 | " for (i = 0; i < document.forms[0].elements.length; i++) {\n". |
116 | " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n". |
117 | " textElements++;\n". |
118 | " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n". |
119 | " document.forms[0].elements[i].focus();\n". |
120 | " break;\n". |
121 | " }\n". |
122 | " }\n". |
123 | " }\n". |
98f2ee76 |
124 | " }\n". |
125 | "// -->\n". |
126 | "</script>\n"; |
dfb94cac |
127 | |
128 | if (@file_exists($theme[$theme_default]['PATH'])) |
129 | @include ($theme[$theme_default]['PATH']); |
130 | |
832dc1e2 |
131 | if (! isset($color) || ! is_array($color)) { |
132 | // Add default color theme, if theme loading fails |
133 | $color = array(); |
134 | $color[0] = '#dcdcdc'; /* light gray TitleBar */ |
135 | $color[1] = '#800000'; /* red */ |
136 | $color[2] = '#cc0000'; /* light red Warning/Error Messages */ |
137 | $color[4] = '#ffffff'; /* white Normal Background */ |
138 | $color[7] = '#0000cc'; /* blue Links */ |
139 | $color[8] = '#000000'; /* black Normal text */ |
140 | } |
141 | |
c5330196 |
142 | displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE ); |
98f2ee76 |
143 | |
98f2ee76 |
144 | |
78b2428e |
145 | /* If they don't have a logo, don't bother.. */ |
c5330196 |
146 | $logo_str = ''; |
78b2428e |
147 | if (isset($org_logo) && $org_logo) { |
148 | /* Display width and height like good little people */ |
149 | $width_and_height = ''; |
150 | if (isset($org_logo_width) && is_numeric($org_logo_width) && |
151 | $org_logo_width>0) { |
152 | $width_and_height = " width=\"$org_logo_width\""; |
153 | } |
154 | if (isset($org_logo_height) && is_numeric($org_logo_height) && |
155 | $org_logo_height>0) { |
156 | $width_and_height .= " height=\"$org_logo_height\""; |
157 | } |
c5330196 |
158 | |
159 | $logo_str = '<img src="'.$org_logo.'" ' . |
160 | 'alt="'. sprintf(_("%s Logo"), $org_name).'" ' . |
161 | $width_and_height . |
162 | 'class="sqm_loginImage" ' . |
163 | ' /><br />'."\n"; |
164 | } |
165 | |
166 | $sm_attribute_str = ''; |
beebd508 |
167 | if (isset($hide_sm_attributions) && !$hide_sm_attributions) { |
c5330196 |
168 | $sm_attribute_str = _("SquirrelMail Webmail Application")."<br />\n" . |
169 | _("By the SquirrelMail Project Team")."<br />\n"; |
98f2ee76 |
170 | } |
3fde693b |
171 | |
c5330196 |
172 | $username_form_name = 'login_username'; |
173 | $password_form_name = 'secretkey'; |
174 | |
c67e4479 |
175 | if(sqgetGlobalVar('mailto', $mailto)) { |
a34d6890 |
176 | $rcptaddress = addHidden('mailto', $mailto); |
c67e4479 |
177 | } else { |
178 | $rcptaddress = ''; |
179 | } |
c5330196 |
180 | |
181 | $password_field = addPwField($password_form_name). |
182 | addHidden('js_autodetect_results', SMPREF_JS_OFF). |
183 | $rcptaddress . |
184 | addHidden('just_logged_in', '1'); |
185 | |
186 | $oTemplate->assign('color', $color); |
187 | $oTemplate->assign('logo_str', $logo_str); |
188 | $oTemplate->assign('sm_attribute_str', $sm_attribute_str); |
189 | $oTemplate->assign('org_name_str', sprintf (_("%s Login"), $org_name)); |
190 | $oTemplate->assign('login_field', addInput($username_form_name, $loginname_value)); |
191 | $oTemplate->assign('password_field', $password_field); |
192 | $oTemplate->assign('submit_field', addSubmit(_("Login"))); |
193 | |
194 | $oTemplate->display('login.tpl'); |
195 | ?> |