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 | * |
1977ab55 |
9 | * @copyright 1999-2010 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 | |
8f6f9ba5 |
33 | /** |
91e0dccc |
34 | * This detects if the IMAP server has logins disabled, and if so, |
8f6f9ba5 |
35 | * squelches the display of the login form and puts up a message |
36 | * explaining the situation. |
37 | */ |
6d611a76 |
38 | if($imap_auth_mech == 'login') { |
c0c5cf6a |
39 | /** |
f8a1ed5a |
40 | * detect disabled login, only when imapServerAddress contains |
c0c5cf6a |
41 | * server address and not mapping. See sqimap_get_user_server() |
42 | */ |
43 | if (substr($imapServerAddress, 0, 4) != "map:") { |
44 | $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls); |
45 | $logindisabled = sqimap_capability($imap,'LOGINDISABLED'); |
46 | sqimap_logout($imap); |
47 | if ($logindisabled) { |
48 | $string = _("The IMAP server is reporting that plain text logins are disabled.").'<br />'. |
49 | _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />'; |
50 | if (!$use_imap_tls) { |
51 | $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />'; |
52 | } |
53 | $string .= _("Please contact your system administrator and report this error."); |
1b858d86 |
54 | error_box($string); |
55 | // display footer (closes html tags) and stop script execution |
56 | $oTemplate->display('footer.tpl'); |
c0c5cf6a |
57 | exit; |
6d611a76 |
58 | } |
ea348fd3 |
59 | } |
ea348fd3 |
60 | } |
61 | |
8e8072b3 |
62 | $username_form_name = 'login_username'; |
63 | $password_form_name = 'secretkey'; |
6e515418 |
64 | do_hook('login_cookie', $null); |
98f2ee76 |
65 | |
bca2d025 |
66 | $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : ''); |
67 | |
6e515418 |
68 | //FIXME: should be part of the template, not the core! |
98f2ee76 |
69 | /* Output the javascript onload function. */ |
2c92ea9d |
70 | $header = "<script type=\"text/javascript\">\n" . |
98f2ee76 |
71 | "<!--\n". |
0bdd0f3e |
72 | " var alreadyFocused = false;\n". |
98f2ee76 |
73 | " function squirrelmail_loginpage_onload() {\n". |
0bdd0f3e |
74 | " if (alreadyFocused) return;\n". |
684f1a88 |
75 | " var textElements = 0; var i = 0;\n". |
e208b883 |
76 | " for (i = 0; i < document.login_form.elements.length; i++) {\n". |
77 | " if (document.login_form.elements[i].type == \"text\" || document.login_form.elements[i].type == \"password\") {\n". |
03ccb49b |
78 | " textElements++;\n". |
79 | " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n". |
e208b883 |
80 | " document.login_form.elements[i].focus();\n". |
03ccb49b |
81 | " break;\n". |
82 | " }\n". |
83 | " }\n". |
84 | " }\n". |
98f2ee76 |
85 | " }\n". |
86 | "// -->\n". |
87 | "</script>\n"; |
dfb94cac |
88 | |
89 | if (@file_exists($theme[$theme_default]['PATH'])) |
90 | @include ($theme[$theme_default]['PATH']); |
91 | |
832dc1e2 |
92 | if (! isset($color) || ! is_array($color)) { |
93 | // Add default color theme, if theme loading fails |
94 | $color = array(); |
95 | $color[0] = '#dcdcdc'; /* light gray TitleBar */ |
96 | $color[1] = '#800000'; /* red */ |
97 | $color[2] = '#cc0000'; /* light red Warning/Error Messages */ |
98 | $color[4] = '#ffffff'; /* white Normal Background */ |
99 | $color[7] = '#0000cc'; /* blue Links */ |
100 | $color[8] = '#000000'; /* black Normal text */ |
101 | } |
102 | |
c5330196 |
103 | displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE ); |
98f2ee76 |
104 | |
98f2ee76 |
105 | |
6e515418 |
106 | |
78b2428e |
107 | /* If they don't have a logo, don't bother.. */ |
c5330196 |
108 | $logo_str = ''; |
78b2428e |
109 | if (isset($org_logo) && $org_logo) { |
b86f98e4 |
110 | |
78b2428e |
111 | if (isset($org_logo_width) && is_numeric($org_logo_width) && |
112 | $org_logo_width>0) { |
0173ad29 |
113 | $width = $org_logo_width; |
efb5bde8 |
114 | } else { |
0173ad29 |
115 | $width = ''; |
78b2428e |
116 | } |
117 | if (isset($org_logo_height) && is_numeric($org_logo_height) && |
118 | $org_logo_height>0) { |
0173ad29 |
119 | $height = $org_logo_height; |
efb5bde8 |
120 | } else { |
0173ad29 |
121 | $height = ''; |
78b2428e |
122 | } |
0173ad29 |
123 | |
b86f98e4 |
124 | $logo_str = create_image($org_logo, sprintf(_("%s Logo"), $org_name), |
0173ad29 |
125 | $width, $height, '', 'sqm_loginImage'); |
126 | |
c5330196 |
127 | } |
128 | |
129 | $sm_attribute_str = ''; |
beebd508 |
130 | if (isset($hide_sm_attributions) && !$hide_sm_attributions) { |
3e6b917e |
131 | $sm_attribute_str = _("SquirrelMail Webmail")."\n" . |
2e9a4e86 |
132 | _("By the SquirrelMail Project Team"); |
98f2ee76 |
133 | } |
3fde693b |
134 | |
7e2ff844 |
135 | if(sqgetGlobalVar('mailtodata', $mailtodata)) { |
136 | $mailtofield = addHidden('mailtodata', $mailtodata); |
c67e4479 |
137 | } else { |
7e2ff844 |
138 | $mailtofield = ''; |
c67e4479 |
139 | } |
c5330196 |
140 | |
84d10885 |
141 | $password_field = addPwField('secretkey'); |
2f04c558 |
142 | $login_extra = addHidden('js_autodetect_results', SMPREF_JS_OFF). |
7e2ff844 |
143 | $mailtofield . |
31633bef |
144 | addHidden('just_logged_in', '1'); |
c5330196 |
145 | |
202bcbcc |
146 | session_write_close(); |
147 | |
5cf27342 |
148 | $oTemplate->assign('logo_str', $logo_str, FALSE); |
84d10885 |
149 | $oTemplate->assign('logo_path', $org_logo); |
c5330196 |
150 | $oTemplate->assign('sm_attribute_str', $sm_attribute_str); |
6f4080b1 |
151 | // i18n: The %s represents the service provider's name |
c5330196 |
152 | $oTemplate->assign('org_name_str', sprintf (_("%s Login"), $org_name)); |
6f4080b1 |
153 | // i18n: The %s represents the service provider's name |
154 | $oTemplate->assign('org_logo_str', sprintf (_("The %s logo"), $org_name)); |
2f04c558 |
155 | $oTemplate->assign('login_field_value', $loginname_value); |
5cf27342 |
156 | $oTemplate->assign('login_extra', $login_extra, FALSE); |
2f04c558 |
157 | |
c5330196 |
158 | $oTemplate->display('login.tpl'); |
f5dcd7f3 |
159 | |
6e515418 |
160 | do_hook('login_bottom', $null); |
2f04c558 |
161 | |
f5dcd7f3 |
162 | // Turn off delayed error handling to make sure all errors are dumped. |
84d10885 |
163 | $oErrorHandler->setDelayedErrors(false); |
f5dcd7f3 |
164 | |
f5dcd7f3 |
165 | $oTemplate->display('footer.tpl'); |