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 | |
202bcbcc |
15 | // reduces the files included in init.php |
16 | $sInitLocation = 'login'; |
17 | |
30967a1e |
18 | /** |
202bcbcc |
19 | * Include the SquirrelMail initialization file. |
30967a1e |
20 | */ |
202bcbcc |
21 | require('../include/init.php'); |
22 | |
86725763 |
23 | |
24 | /* SquirrelMail required files. */ |
ea348fd3 |
25 | require_once(SM_PATH . 'functions/imap_general.php'); |
a34d6890 |
26 | require_once(SM_PATH . 'functions/forms.php'); |
98f2ee76 |
27 | |
8f6f9ba5 |
28 | /** |
98f2ee76 |
29 | * $squirrelmail_language is set by a cookie when the user selects |
30 | * language and logs out |
31 | */ |
5e2b6751 |
32 | set_up_language($squirrelmail_language, TRUE, TRUE); |
d4e84069 |
33 | |
98f2ee76 |
34 | /* |
35 | * In case the last session was not terminated properly, make sure |
36 | * we get a new one. |
37 | */ |
69146537 |
38 | sqsession_destroy(); |
202bcbcc |
39 | sqsession_is_active(); |
40 | $_SESSION=array(); |
41 | |
42 | |
07a52f9f |
43 | /** |
44 | * PHP bug. http://bugs.php.net/11643 (warning, spammed bug tracker) and |
45 | * http://bugs.php.net/13834 |
202bcbcc |
46 | * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other |
07a52f9f |
47 | * versions. Produces warning on login page. Bug should be fixed only in 4.3.0 |
48 | */ |
98f2ee76 |
49 | |
8f6f9ba5 |
50 | /** |
91e0dccc |
51 | * This detects if the IMAP server has logins disabled, and if so, |
8f6f9ba5 |
52 | * squelches the display of the login form and puts up a message |
53 | * explaining the situation. |
54 | */ |
6d611a76 |
55 | if($imap_auth_mech == 'login') { |
c0c5cf6a |
56 | /** |
f8a1ed5a |
57 | * detect disabled login, only when imapServerAddress contains |
c0c5cf6a |
58 | * server address and not mapping. See sqimap_get_user_server() |
59 | */ |
60 | if (substr($imapServerAddress, 0, 4) != "map:") { |
61 | $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls); |
62 | $logindisabled = sqimap_capability($imap,'LOGINDISABLED'); |
63 | sqimap_logout($imap); |
64 | if ($logindisabled) { |
65 | $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'. |
66 | _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />'; |
67 | if (!$use_imap_tls) { |
68 | $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />'; |
69 | } |
70 | $string .= _("Please contact your system administrator and report this error."); |
71 | error_box($string,$color); |
72 | exit; |
6d611a76 |
73 | } |
ea348fd3 |
74 | } |
ea348fd3 |
75 | } |
76 | |
98f2ee76 |
77 | do_hook('login_cookie'); |
78 | |
bca2d025 |
79 | $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : ''); |
80 | |
98f2ee76 |
81 | /* Output the javascript onload function. */ |
2c92ea9d |
82 | $header = "<script type=\"text/javascript\">\n" . |
98f2ee76 |
83 | "<!--\n". |
84 | " function squirrelmail_loginpage_onload() {\n". |
03ccb49b |
85 | " var textElements = 0;\n". |
86 | " for (i = 0; i < document.forms[0].elements.length; i++) {\n". |
87 | " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n". |
88 | " textElements++;\n". |
89 | " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n". |
90 | " document.forms[0].elements[i].focus();\n". |
91 | " break;\n". |
92 | " }\n". |
93 | " }\n". |
94 | " }\n". |
98f2ee76 |
95 | " }\n". |
96 | "// -->\n". |
97 | "</script>\n"; |
dfb94cac |
98 | |
99 | if (@file_exists($theme[$theme_default]['PATH'])) |
100 | @include ($theme[$theme_default]['PATH']); |
101 | |
832dc1e2 |
102 | if (! isset($color) || ! is_array($color)) { |
103 | // Add default color theme, if theme loading fails |
104 | $color = array(); |
105 | $color[0] = '#dcdcdc'; /* light gray TitleBar */ |
106 | $color[1] = '#800000'; /* red */ |
107 | $color[2] = '#cc0000'; /* light red Warning/Error Messages */ |
108 | $color[4] = '#ffffff'; /* white Normal Background */ |
109 | $color[7] = '#0000cc'; /* blue Links */ |
110 | $color[8] = '#000000'; /* black Normal text */ |
111 | } |
1d537493 |
112 | /** |
113 | * send out all the cookies |
114 | */ |
115 | sqsetcookieflush(); |
832dc1e2 |
116 | |
c5330196 |
117 | displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE ); |
98f2ee76 |
118 | |
98f2ee76 |
119 | |
78b2428e |
120 | /* If they don't have a logo, don't bother.. */ |
c5330196 |
121 | $logo_str = ''; |
78b2428e |
122 | if (isset($org_logo) && $org_logo) { |
123 | /* Display width and height like good little people */ |
124 | $width_and_height = ''; |
125 | if (isset($org_logo_width) && is_numeric($org_logo_width) && |
126 | $org_logo_width>0) { |
127 | $width_and_height = " width=\"$org_logo_width\""; |
128 | } |
129 | if (isset($org_logo_height) && is_numeric($org_logo_height) && |
130 | $org_logo_height>0) { |
131 | $width_and_height .= " height=\"$org_logo_height\""; |
132 | } |
f5dcd7f3 |
133 | |
c5330196 |
134 | $logo_str = '<img src="'.$org_logo.'" ' . |
135 | 'alt="'. sprintf(_("%s Logo"), $org_name).'" ' . |
136 | $width_and_height . |
137 | 'class="sqm_loginImage" ' . |
138 | ' /><br />'."\n"; |
139 | } |
140 | |
141 | $sm_attribute_str = ''; |
beebd508 |
142 | if (isset($hide_sm_attributions) && !$hide_sm_attributions) { |
c5330196 |
143 | $sm_attribute_str = _("SquirrelMail Webmail Application")."<br />\n" . |
144 | _("By the SquirrelMail Project Team")."<br />\n"; |
98f2ee76 |
145 | } |
3fde693b |
146 | |
c5330196 |
147 | $username_form_name = 'login_username'; |
148 | $password_form_name = 'secretkey'; |
149 | |
c67e4479 |
150 | if(sqgetGlobalVar('mailto', $mailto)) { |
a34d6890 |
151 | $rcptaddress = addHidden('mailto', $mailto); |
c67e4479 |
152 | } else { |
153 | $rcptaddress = ''; |
154 | } |
c5330196 |
155 | |
156 | $password_field = addPwField($password_form_name). |
157 | addHidden('js_autodetect_results', SMPREF_JS_OFF). |
158 | $rcptaddress . |
159 | addHidden('just_logged_in', '1'); |
160 | |
202bcbcc |
161 | session_write_close(); |
162 | |
c5330196 |
163 | $oTemplate->assign('logo_str', $logo_str); |
164 | $oTemplate->assign('sm_attribute_str', $sm_attribute_str); |
165 | $oTemplate->assign('org_name_str', sprintf (_("%s Login"), $org_name)); |
166 | $oTemplate->assign('login_field', addInput($username_form_name, $loginname_value)); |
167 | $oTemplate->assign('password_field', $password_field); |
168 | $oTemplate->assign('submit_field', addSubmit(_("Login"))); |
169 | |
170 | $oTemplate->display('login.tpl'); |
f5dcd7f3 |
171 | |
172 | // Turn off delayed error handling to make sure all errors are dumped. |
97f53001 |
173 | #$oErrorHandler->delayedErrors(false); |
f5dcd7f3 |
174 | |
97f53001 |
175 | #trigger_error('login'); |
f5dcd7f3 |
176 | $oTemplate->display('footer.tpl'); |
c5330196 |
177 | ?> |