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 | * |
4b5049de |
9 | * @copyright © 1999-2007 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 | |
ebd2391c |
15 | /** This is the login page */ |
16 | define('PAGE_NAME', 'login'); |
17 | |
30967a1e |
18 | /** |
202bcbcc |
19 | * Include the SquirrelMail initialization file. |
30967a1e |
20 | */ |
202bcbcc |
21 | require('../include/init.php'); |
22 | |
86725763 |
23 | /* SquirrelMail required files. */ |
ea348fd3 |
24 | require_once(SM_PATH . 'functions/imap_general.php'); |
a34d6890 |
25 | require_once(SM_PATH . 'functions/forms.php'); |
98f2ee76 |
26 | |
8f6f9ba5 |
27 | /** |
98f2ee76 |
28 | * $squirrelmail_language is set by a cookie when the user selects |
29 | * language and logs out |
30 | */ |
5e2b6751 |
31 | set_up_language($squirrelmail_language, TRUE, TRUE); |
d4e84069 |
32 | |
c6f28eb1 |
33 | /** |
98f2ee76 |
34 | * In case the last session was not terminated properly, make sure |
c6f28eb1 |
35 | * we get a new one, but make sure we preserve session_expired_* |
98f2ee76 |
36 | */ |
c6f28eb1 |
37 | if ( !empty($_SESSION['session_expired_post']) && !empty($_SESSION['session_expired_location']) ) { |
38 | $sep = $_SESSION['session_expired_post']; |
39 | $sel = $_SESSION['session_expired_location']; |
40 | |
41 | sqsession_destroy(); |
66c7cd3f |
42 | @sqsession_is_active(); |
c6f28eb1 |
43 | $_SESSION=array(); |
44 | sqsession_register($sep, 'session_expired_post'); |
45 | sqsession_register($sel, 'session_expired_location'); |
46 | } else { |
47 | sqsession_destroy(); |
48 | @sqsession_is_active(); |
49 | $_SESSION=array(); |
50 | } |
98f2ee76 |
51 | |
8f6f9ba5 |
52 | /** |
91e0dccc |
53 | * This detects if the IMAP server has logins disabled, and if so, |
8f6f9ba5 |
54 | * squelches the display of the login form and puts up a message |
55 | * explaining the situation. |
56 | */ |
6d611a76 |
57 | if($imap_auth_mech == 'login') { |
c0c5cf6a |
58 | /** |
f8a1ed5a |
59 | * detect disabled login, only when imapServerAddress contains |
c0c5cf6a |
60 | * server address and not mapping. See sqimap_get_user_server() |
61 | */ |
62 | if (substr($imapServerAddress, 0, 4) != "map:") { |
63 | $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls); |
64 | $logindisabled = sqimap_capability($imap,'LOGINDISABLED'); |
65 | sqimap_logout($imap); |
66 | if ($logindisabled) { |
67 | $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'. |
68 | _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />'; |
69 | if (!$use_imap_tls) { |
70 | $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />'; |
71 | } |
72 | $string .= _("Please contact your system administrator and report this error."); |
1b858d86 |
73 | error_box($string); |
74 | // display footer (closes html tags) and stop script execution |
75 | $oTemplate->display('footer.tpl'); |
c0c5cf6a |
76 | exit; |
6d611a76 |
77 | } |
ea348fd3 |
78 | } |
ea348fd3 |
79 | } |
80 | |
6e515418 |
81 | do_hook('login_cookie', $null); |
98f2ee76 |
82 | |
bca2d025 |
83 | $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : ''); |
84 | |
6e515418 |
85 | //FIXME: should be part of the template, not the core! |
98f2ee76 |
86 | /* Output the javascript onload function. */ |
2c92ea9d |
87 | $header = "<script type=\"text/javascript\">\n" . |
98f2ee76 |
88 | "<!--\n". |
89 | " function squirrelmail_loginpage_onload() {\n". |
03ccb49b |
90 | " var textElements = 0;\n". |
91 | " for (i = 0; i < document.forms[0].elements.length; i++) {\n". |
92 | " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n". |
93 | " textElements++;\n". |
94 | " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n". |
95 | " document.forms[0].elements[i].focus();\n". |
96 | " break;\n". |
97 | " }\n". |
98 | " }\n". |
99 | " }\n". |
98f2ee76 |
100 | " }\n". |
101 | "// -->\n". |
102 | "</script>\n"; |
dfb94cac |
103 | |
104 | if (@file_exists($theme[$theme_default]['PATH'])) |
105 | @include ($theme[$theme_default]['PATH']); |
106 | |
832dc1e2 |
107 | if (! isset($color) || ! is_array($color)) { |
108 | // Add default color theme, if theme loading fails |
109 | $color = array(); |
110 | $color[0] = '#dcdcdc'; /* light gray TitleBar */ |
111 | $color[1] = '#800000'; /* red */ |
112 | $color[2] = '#cc0000'; /* light red Warning/Error Messages */ |
113 | $color[4] = '#ffffff'; /* white Normal Background */ |
114 | $color[7] = '#0000cc'; /* blue Links */ |
115 | $color[8] = '#000000'; /* black Normal text */ |
116 | } |
117 | |
c5330196 |
118 | displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE ); |
98f2ee76 |
119 | |
98f2ee76 |
120 | |
6e515418 |
121 | |
78b2428e |
122 | /* If they don't have a logo, don't bother.. */ |
c5330196 |
123 | $logo_str = ''; |
78b2428e |
124 | if (isset($org_logo) && $org_logo) { |
b86f98e4 |
125 | |
78b2428e |
126 | if (isset($org_logo_width) && is_numeric($org_logo_width) && |
127 | $org_logo_width>0) { |
0173ad29 |
128 | $width = $org_logo_width; |
efb5bde8 |
129 | } else { |
0173ad29 |
130 | $width = ''; |
78b2428e |
131 | } |
132 | if (isset($org_logo_height) && is_numeric($org_logo_height) && |
133 | $org_logo_height>0) { |
0173ad29 |
134 | $height = $org_logo_height; |
efb5bde8 |
135 | } else { |
0173ad29 |
136 | $height = ''; |
78b2428e |
137 | } |
0173ad29 |
138 | |
b86f98e4 |
139 | $logo_str = create_image($org_logo, sprintf(_("%s Logo"), $org_name), |
0173ad29 |
140 | $width, $height, '', 'sqm_loginImage'); |
141 | |
c5330196 |
142 | } |
143 | |
144 | $sm_attribute_str = ''; |
beebd508 |
145 | if (isset($hide_sm_attributions) && !$hide_sm_attributions) { |
3e6b917e |
146 | $sm_attribute_str = _("SquirrelMail Webmail")."\n" . |
2e9a4e86 |
147 | _("By the SquirrelMail Project Team"); |
98f2ee76 |
148 | } |
3fde693b |
149 | |
7e2ff844 |
150 | if(sqgetGlobalVar('mailtodata', $mailtodata)) { |
151 | $mailtofield = addHidden('mailtodata', $mailtodata); |
c67e4479 |
152 | } else { |
7e2ff844 |
153 | $mailtofield = ''; |
c67e4479 |
154 | } |
c5330196 |
155 | |
84d10885 |
156 | $password_field = addPwField('secretkey'); |
2f04c558 |
157 | $login_extra = addHidden('js_autodetect_results', SMPREF_JS_OFF). |
7e2ff844 |
158 | $mailtofield . |
31633bef |
159 | addHidden('just_logged_in', '1'); |
c5330196 |
160 | |
202bcbcc |
161 | session_write_close(); |
162 | |
3f087701 |
163 | $oTemplate->assign('logo_str', $logo_str); |
84d10885 |
164 | $oTemplate->assign('logo_path', $org_logo); |
c5330196 |
165 | $oTemplate->assign('sm_attribute_str', $sm_attribute_str); |
6f4080b1 |
166 | // i18n: The %s represents the service provider's name |
c5330196 |
167 | $oTemplate->assign('org_name_str', sprintf (_("%s Login"), $org_name)); |
6f4080b1 |
168 | // i18n: The %s represents the service provider's name |
169 | $oTemplate->assign('org_logo_str', sprintf (_("The %s logo"), $org_name)); |
2f04c558 |
170 | $oTemplate->assign('login_field_value', $loginname_value); |
3f087701 |
171 | $oTemplate->assign('login_extra', $login_extra); |
2f04c558 |
172 | |
0173ad29 |
173 | //FIXME: need to remove *ALL* HTML from this file! |
3b4dece1 |
174 | echo '<body onload="squirrelmail_loginpage_onload()">'."\n"; |
175 | echo '<form action="redirect.php" method="post" onsubmit="document.forms[0].js_autodetect_results.value='. SMPREF_JS_ON .'">'."\n"; |
6e515418 |
176 | do_hook('login_top', $null); |
c5330196 |
177 | |
178 | $oTemplate->display('login.tpl'); |
f5dcd7f3 |
179 | |
0173ad29 |
180 | //FIXME: need to remove *ALL* HTML from this file! |
2f04c558 |
181 | echo "</form>\n"; |
6e515418 |
182 | do_hook('login_bottom', $null); |
2f04c558 |
183 | |
f5dcd7f3 |
184 | // Turn off delayed error handling to make sure all errors are dumped. |
84d10885 |
185 | $oErrorHandler->setDelayedErrors(false); |
f5dcd7f3 |
186 | |
f5dcd7f3 |
187 | $oTemplate->display('footer.tpl'); |