1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare login * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Originaly written by Dan Kuykendall <seek3r@phpgroupware.org> * |
---|
6 | * Joseph Engo <jengo@phpgroupware.org> * |
---|
7 | * Updated by Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br> * |
---|
8 | * This program is free software; you can redistribute it and/or modify it * |
---|
9 | * under the terms of the GNU General Public License as published by the * |
---|
10 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
11 | * option) any later version. * |
---|
12 | \**************************************************************************/ |
---|
13 | |
---|
14 | function check_logoutcode($code) |
---|
15 | { |
---|
16 | switch($code) |
---|
17 | { |
---|
18 | case 1: |
---|
19 | return lang('You have been successfully logged out'); |
---|
20 | |
---|
21 | case 2: |
---|
22 | return lang('Sorry, your login has expired'); |
---|
23 | |
---|
24 | case 4: |
---|
25 | return lang('Cookies are required to login to this site.'); |
---|
26 | |
---|
27 | case 5: |
---|
28 | return '<font color="FF0000">' . lang('Bad login or password') . '</font>'; |
---|
29 | |
---|
30 | case 6: |
---|
31 | return '<font color="FF0000">' . lang('Your password has expired, and you do not have access to change it') . '</font>'; |
---|
32 | |
---|
33 | case 97: |
---|
34 | return '<font color="FF0000">' . $GLOBALS['usrworkleaveobs']?$GLOBALS['usrworkleaveobs']:lang('Account blocked, please contact the system administrator.') . '</font>'; |
---|
35 | case 98: |
---|
36 | return '<font color="FF0000">' . lang('Account is expired') . '</font>'; |
---|
37 | |
---|
38 | case 99: |
---|
39 | return '<font color="FF0000">' . lang('Blocked, too many attempts(%1)! Retry in %2 minute(s)',$GLOBALS['phpgw_info']['server']['num_unsuccessful_id'],$GLOBALS['phpgw_info']['server']['block_time']) . '</font>'; |
---|
40 | case 200: |
---|
41 | //return '<font color="FF0000">' . lang('Invalid code') . '</font>'; |
---|
42 | return '<font color="FF0000">' . lang('Bad login or password') . '</font>'; |
---|
43 | break; |
---|
44 | case 10: |
---|
45 | $GLOBALS['phpgw']->session->phpgw_setcookie('sessionid'); |
---|
46 | $GLOBALS['phpgw']->session->phpgw_setcookie('kp3'); |
---|
47 | $GLOBALS['phpgw']->session->phpgw_setcookie('domain'); |
---|
48 | |
---|
49 | //fix for bug php4 expired sessions bug |
---|
50 | if($GLOBALS['phpgw_info']['server']['sessions_type'] == 'php4') |
---|
51 | { |
---|
52 | $GLOBALS['phpgw']->session->phpgw_setcookie(PHPGW_PHPSESSID); |
---|
53 | } |
---|
54 | |
---|
55 | return '<font color="#FF0000">' . lang('Your session could not be verified.') . '</font>'; |
---|
56 | |
---|
57 | default: |
---|
58 | return ''; |
---|
59 | } |
---|
60 | } |
---|
61 | function troca_espaco_por_mais($pem_data) |
---|
62 | { |
---|
63 | $begin = "CERTIFICATE-----"; |
---|
64 | $end = "-----END"; |
---|
65 | $aux = substr($pem_data, strpos($pem_data, $begin)+strlen($begin)); |
---|
66 | $aux = substr($aux, 0, strpos($aux, $end)); |
---|
67 | $aux = strtr($aux,' ','+'); |
---|
68 | $aux = '-----BEGIN CERTIFICATE-----'.$aux.'-----END CERTIFICATE-----'; |
---|
69 | $aux = str_replace(chr(0x0A).chr(0x0A),chr(0x0A),str_replace(chr(0x0D).chr(0x0A),chr(0x0A), $aux)); |
---|
70 | return $aux; |
---|
71 | } |
---|
72 | /* Program starts here */ |
---|
73 | |
---|
74 | if($GLOBALS['phpgw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER'])) |
---|
75 | { |
---|
76 | $submit = True; |
---|
77 | $login = $_SERVER['PHP_AUTH_USER']; |
---|
78 | $passwd = $_SERVER['PHP_AUTH_PW']; |
---|
79 | $passwd_type = 'text'; |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | $passwd = $_POST['passwd']; |
---|
84 | $passwd_type = $_POST['passwd_type']; |
---|
85 | } |
---|
86 | |
---|
87 | # Apache + mod_ssl style SSL certificate authentication |
---|
88 | # Certificate (chain) verification occurs inside mod_ssl |
---|
89 | if($GLOBALS['phpgw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd'])) |
---|
90 | { |
---|
91 | # an X.509 subject looks like: |
---|
92 | # /CN=john.doe/OU=Department/O=Company/C=xx/Email=john@comapy.tld/L=City/ |
---|
93 | # the username is deliberately lowercase, to ease LDAP integration |
---|
94 | $sslattribs = explode('/',$_SERVER['SSL_CLIENT_S_DN']); |
---|
95 | # skip the part in front of the first '/' (nothing) |
---|
96 | while($sslattrib = next($sslattribs)) |
---|
97 | { |
---|
98 | list($key,$val) = explode('=',$sslattrib); |
---|
99 | $sslattributes[$key] = $val; |
---|
100 | } |
---|
101 | |
---|
102 | if(isset($sslattributes['Email'])) |
---|
103 | { |
---|
104 | $submit = True; |
---|
105 | |
---|
106 | # login will be set here if the user logged out and uses a different username with |
---|
107 | # the same SSL-certificate. |
---|
108 | if(!isset($_POST['login'])&&isset($sslattributes['Email'])) |
---|
109 | { |
---|
110 | $login = $sslattributes['Email']; |
---|
111 | # not checked against the database, but delivered to authentication module |
---|
112 | $passwd = $_SERVER['SSL_CLIENT_S_DN']; |
---|
113 | } |
---|
114 | } |
---|
115 | unset($key); |
---|
116 | unset($val); |
---|
117 | unset($sslattributes); |
---|
118 | } |
---|
119 | if(isset($_POST['certificado']) && $_POST['certificado'] && $GLOBALS['phpgw_info']['server']['certificado']==1) |
---|
120 | { |
---|
121 | $_SESSION['login_certificate'] = troca_espaco_por_mais($_POST['certificado']); |
---|
122 | } |
---|
123 | if( isset( $_GET[ 'cd' ] ) && ( $_GET['cd']=='1' || $_GET['cd'] == 10 ) ) |
---|
124 | { |
---|
125 | $_SESSION['contador'] = 0; |
---|
126 | } |
---|
127 | |
---|
128 | if(isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit) |
---|
129 | { |
---|
130 | |
---|
131 | // Primeiro testa o captcha....se houver...... |
---|
132 | if($GLOBALS['phpgw_info']['server']['captcha']==1) |
---|
133 | { |
---|
134 | if($_SESSION['contador'] > $GLOBALS['phpgw_info']['server']['num_badlogin']) |
---|
135 | { |
---|
136 | if ($_SESSION['CAPTCHAString'] != trim(strtoupper($_POST['codigo']))) |
---|
137 | { |
---|
138 | if(!$_GET['cd']) |
---|
139 | { |
---|
140 | $_GET['cd'] = '200'; |
---|
141 | } |
---|
142 | } |
---|
143 | unset($_SESSION['CAPTCHAString']); |
---|
144 | } |
---|
145 | } |
---|
146 | if($_POST['user']) { |
---|
147 | if($GLOBALS['phpgw_info']['server']['use_prefix_organization']) { |
---|
148 | $common = CreateObject('phpgwapi.common'); |
---|
149 | $ldap_conn = $common->ldapConnect(); |
---|
150 | $justthese = array("uid"); |
---|
151 | $filter="(&(phpgwAccountType=u)(uid=".$_POST['user']."))"; |
---|
152 | $ldap_search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); |
---|
153 | $ldap_info = ldap_get_entries($ldap_conn, $ldap_search); |
---|
154 | ldap_close($ldap_conn); |
---|
155 | if ($ldap_info['count'] != 0) { |
---|
156 | $_POST['login'] = $_POST['user']; |
---|
157 | } |
---|
158 | } |
---|
159 | else |
---|
160 | $_POST['login'] = $_POST['user']; |
---|
161 | } |
---|
162 | if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' && |
---|
163 | !isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN'])) |
---|
164 | { |
---|
165 | if(!$_GET['cd']) |
---|
166 | { |
---|
167 | $_GET['cd'] = '5'; |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | // don't get login data again when $submit is true |
---|
172 | if($submit == false) |
---|
173 | { |
---|
174 | $login = $_POST['login']; |
---|
175 | } |
---|
176 | |
---|
177 | if(strstr($login,'@') === False && isset($_POST['logindomain'])) |
---|
178 | { |
---|
179 | $login .= '@' . $_POST['logindomain']; |
---|
180 | } |
---|
181 | elseif(!isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']])) |
---|
182 | { |
---|
183 | $login .= '@'.$GLOBALS['phpgw_info']['server']['default_domain']; |
---|
184 | } |
---|
185 | If(!$_GET['cd']) |
---|
186 | $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create(strtolower($login),$passwd,$passwd_type,'u'); |
---|
187 | |
---|
188 | if(!isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid']) |
---|
189 | { |
---|
190 | |
---|
191 | If(!$_GET['cd']) $_GET['cd'] = $GLOBALS['phpgw']->session->cd_reason; |
---|
192 | } |
---|
193 | else |
---|
194 | { |
---|
195 | if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2}){0,1}$/',$_POST['lang']) && |
---|
196 | $_POST['lang'] != $GLOBALS['phpgw_info']['user']['preferences']['common']['lang']) |
---|
197 | { |
---|
198 | $GLOBALS['phpgw']->preferences->add('common','lang',$_POST['lang'],'session'); |
---|
199 | } |
---|
200 | |
---|
201 | if(!$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) |
---|
202 | { |
---|
203 | $GLOBALS['phpgw']->translation->autoload_changed_langfiles(); |
---|
204 | } |
---|
205 | $forward = isset($_GET['phpgw_forward']) ? urldecode($_GET['phpgw_forward']) : @$_POST['phpgw_forward']; |
---|
206 | if (!$forward) |
---|
207 | { |
---|
208 | $extra_vars['cd'] = 'yes'; |
---|
209 | $forward = '/home.php'; |
---|
210 | } |
---|
211 | else |
---|
212 | { |
---|
213 | list($forward,$extra_vars) = explode('?',$forward,2); |
---|
214 | } |
---|
215 | |
---|
216 | if ($GLOBALS['phpgw_info']['server']['use_https'] != 2) |
---|
217 | { |
---|
218 | //Modificacao feita para que o Expresso redirecione para o primeiro proxy caso haja um encadeamento de mais de um proxy. |
---|
219 | //$forward = 'http://'.$_SERVER['HTTP_HOST'].($GLOBALS['phpgw']->link($forward.'?cd=yes')); |
---|
220 | $forward = 'http://' . nearest_to_me() . $GLOBALS['phpgw']->link($forward.'?cd=yes'); |
---|
221 | echo "<script language='Javascript1.3'>location.href='".$forward."'</script>"; |
---|
222 | } |
---|
223 | else |
---|
224 | { |
---|
225 | $GLOBALS['phpgw']->redirect_link($forward,$extra_vars); |
---|
226 | } |
---|
227 | } |
---|
228 | } |
---|
229 | //else // ================================================================================= |
---|
230 | //{ |
---|
231 | $valor_contador = $_SESSION['contador']; |
---|
232 | $valor_contador = $valor_contador + 1; |
---|
233 | $_SESSION['contador'] = $valor_contador; |
---|
234 | // !!! DONT CHANGE THESE LINES !!! |
---|
235 | // If there is something wrong with this code TELL ME! |
---|
236 | // Commenting out the code will not fix it. (jengo) |
---|
237 | if(isset($_COOKIE['last_loginid'])) |
---|
238 | { |
---|
239 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
240 | $prefs = CreateObject('phpgwapi.preferences', $accounts->name2id($_COOKIE['last_loginid'])); |
---|
241 | |
---|
242 | if($prefs->account_id) |
---|
243 | { |
---|
244 | $GLOBALS['phpgw_info']['user']['preferences'] = $prefs->read_repository(); |
---|
245 | } |
---|
246 | } |
---|
247 | |
---|
248 | $_GET['lang'] = addslashes($_GET['lang']); |
---|
249 | if ($_GET['lang']) |
---|
250 | { |
---|
251 | $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $_GET['lang']; |
---|
252 | } |
---|
253 | elseif(!isset($_COOKIE['last_loginid']) || !$prefs->account_id) |
---|
254 | { |
---|
255 | // If the lastloginid cookies isn't set, we will default to the first language, |
---|
256 | // the users browser accepts. |
---|
257 | list($lang) = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); |
---|
258 | /* |
---|
259 | if(strlen($lang) > 2) |
---|
260 | { |
---|
261 | $lang = substr($lang,0,2); |
---|
262 | } |
---|
263 | */ |
---|
264 | $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $lang; |
---|
265 | |
---|
266 | if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme'])) |
---|
267 | { |
---|
268 | $prefs2 = CreateObject('phpgwapi.preferences'); |
---|
269 | $temp_pref = $prefs2->read_repository(); |
---|
270 | $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $temp_pref['common']['theme']; |
---|
271 | } |
---|
272 | } |
---|
273 | #print 'LANG:' . $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] . '<br>'; |
---|
274 | |
---|
275 | $GLOBALS['phpgw']->translation->init(); // this will set the language according to the (new) set prefs |
---|
276 | $GLOBALS['phpgw']->translation->add_app('login'); |
---|
277 | $GLOBALS['phpgw']->translation->add_app('loginscreen'); |
---|
278 | if(lang('loginscreen_message') == 'loginscreen_message*') |
---|
279 | { |
---|
280 | $GLOBALS['phpgw']->translation->add_app('loginscreen','en'); // trying the en one |
---|
281 | } |
---|
282 | if(lang('loginscreen_message') != 'loginscreen_message*') |
---|
283 | { |
---|
284 | $tmpl->set_var('lang_message',stripslashes(lang('loginscreen_message'))); |
---|
285 | } |
---|
286 | //} |
---|
287 | |
---|
288 | if($GLOBALS['phpgw_info']['server']['use_prefix_organization']) |
---|
289 | { |
---|
290 | $obj_organization = CreateObject('phpgwapi.sector_search_ldap'); |
---|
291 | $organizations = $obj_organization->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']); |
---|
292 | |
---|
293 | for ($i=0; $i<count($organizations); $i++) |
---|
294 | { |
---|
295 | $tmp_array[strtolower($organizations[$i])] = $organizations[$i]; |
---|
296 | } |
---|
297 | |
---|
298 | $arrayOrganization = $tmp_array; |
---|
299 | ksort($arrayOrganization); |
---|
300 | |
---|
301 | foreach($arrayOrganization |
---|
302 | as $organization_name => $organization_vars) |
---|
303 | { |
---|
304 | $organization_select .= '<option value="' . $organization_name . '"'; |
---|
305 | |
---|
306 | if($organization_name == $_COOKIE['last_organization']) |
---|
307 | { |
---|
308 | $organization_select .= ' selected'; |
---|
309 | } |
---|
310 | $organization_select .= '>' . $organization_vars . "</option>\n"; |
---|
311 | } |
---|
312 | $organization_select = '<div class="login_label"><label>'.lang("organization") |
---|
313 | .'</label><br><select name="organization">' |
---|
314 | .$organization_select.'</select></div>'; |
---|
315 | $tmpl->set_var('select_organization',$organization_select); |
---|
316 | } |
---|
317 | |
---|
318 | $domain_select = ' '; |
---|
319 | $last_loginid = $_COOKIE['last_loginid']; |
---|
320 | if($GLOBALS['phpgw_info']['server']['show_domain_selectbox']) |
---|
321 | { |
---|
322 | $domain_select = "<select name=\"logindomain\">\n"; |
---|
323 | foreach($GLOBALS['phpgw_domain'] as $domain_name => $domain_vars) |
---|
324 | { |
---|
325 | $domain_select .= '<option value="' . $domain_name . '"'; |
---|
326 | |
---|
327 | if($domain_name == $_COOKIE['last_domain']) |
---|
328 | { |
---|
329 | $domain_select .= ' selected'; |
---|
330 | } |
---|
331 | $domain_select .= '>' . $domain_name . "</option>\n"; |
---|
332 | } |
---|
333 | $domain_select .= "</select>\n"; |
---|
334 | } |
---|
335 | elseif($last_loginid !== '') |
---|
336 | { |
---|
337 | reset($GLOBALS['phpgw_domain']); |
---|
338 | list($default_domain) = each($GLOBALS['phpgw_domain']); |
---|
339 | |
---|
340 | if($_COOKIE['last_domain'] != $default_domain && !empty($_COOKIE['last_domain'])) |
---|
341 | { |
---|
342 | $last_loginid .= '@' . $_COOKIE['last_domain']; |
---|
343 | } |
---|
344 | } |
---|
345 | $tmpl->set_var('select_domain',$domain_select); |
---|
346 | |
---|
347 | foreach($_GET as $name => $value) |
---|
348 | { |
---|
349 | if(ereg('phpgw_',$name)) |
---|
350 | { |
---|
351 | $extra_vars .= '&' . $name . '=' . urlencode($value); |
---|
352 | } |
---|
353 | } |
---|
354 | |
---|
355 | if ( is_string( $extra_vars ) ) |
---|
356 | { |
---|
357 | $extra_vars = '?' . substr($extra_vars,1); |
---|
358 | } |
---|
359 | |
---|
360 | /********************************************************\ |
---|
361 | * Check is the registration app is installed, activated * |
---|
362 | * And if the register link must be placed * |
---|
363 | \********************************************************/ |
---|
364 | |
---|
365 | $cnf_reg = createobject('phpgwapi.config','registration'); |
---|
366 | $cnf_reg->read_repository(); |
---|
367 | $config_reg = $cnf_reg->config_data; |
---|
368 | |
---|
369 | if($config_reg[enable_registration]=='True' && $config_reg[register_link]=='True') |
---|
370 | { |
---|
371 | $reg_link=' <a href="registration/">'.lang('Not a user yet? Register now').'</a><br/>'; |
---|
372 | } |
---|
373 | |
---|
374 | $template = $GLOBALS['phpgw_info']['login_template_set']; |
---|
375 | $GLOBALS['phpgw_info']['server']['template_set'] = $template; |
---|
376 | |
---|
377 | $tmpl->set_var('register_link',$reg_link); |
---|
378 | $tmpl->set_var('charset',$GLOBALS['phpgw']->translation->charset()); |
---|
379 | $tmpl->set_var('login_url', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php' . $extra_vars); |
---|
380 | $tmpl->set_var('registration_url',$GLOBALS['phpgw_info']['server']['webserver_url'] . '/registration/'); |
---|
381 | $tmpl->set_var('version',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']); |
---|
382 | $tmpl->set_var('cd',check_logoutcode($_GET['cd'])); |
---|
383 | $tmpl->set_var('cookie',$last_loginid); |
---|
384 | |
---|
385 | $tmpl->set_var('lang_username',lang('username')); |
---|
386 | $tmpl->set_var('lang_password',lang('password')); |
---|
387 | $tmpl->set_var('lang_login',lang('login')); |
---|
388 | |
---|
389 | $tmpl->set_var('website_title', $GLOBALS['phpgw_info']['server']['site_title']); |
---|
390 | $tmpl->set_var('template_set', $template); |
---|
391 | $tmpl->set_var('compatIE8',lang("The compatibility mode for internet explorer 8 is active. Turn it of if you want to use the local mail functionality.")); |
---|
392 | |
---|
393 | // loads the template's login.css |
---|
394 | // and then the theme's login.css (if any) |
---|
395 | $template_dir = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/' . $template; |
---|
396 | $login_dir = $template_dir . '/login.css'; |
---|
397 | $login_css = "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />"; |
---|
398 | $login_dir = $template_dir . '/themes/' . get_theme() . '/login.css'; |
---|
399 | if(file_exists('./'.$login_dir)) |
---|
400 | { |
---|
401 | $login_css .= "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />"; |
---|
402 | } |
---|
403 | $tmpl->set_var('login_css',$login_css); |
---|
404 | |
---|
405 | $GLOBALS['phpgw']->translation->add_app('loginhelp',$_GET['lang']); |
---|
406 | |
---|
407 | if(lang('loginhelp_message') != 'loginhelp_message*' && trim(lang('loginhelp_message')) != ""){ |
---|
408 | $tmpl->set_var('lang_help',lang("Help")); |
---|
409 | } |
---|
410 | else |
---|
411 | $tmpl->set_var('display_help','none'); |
---|
412 | |
---|
413 | $tmpl->set_var('bg_color',($GLOBALS['phpgw_info']['server']['login_bg_color']?$GLOBALS['phpgw_info']['server']['login_bg_color']:'FFFFFF')); |
---|
414 | $tmpl->set_var('bg_color_title',($GLOBALS['phpgw_info']['server']['login_bg_color_title']?$GLOBALS['phpgw_info']['server']['login_bg_color_title']:'486591')); |
---|
415 | |
---|
416 | if($GLOBALS['phpgw_info']['server']['use_frontend_name']) |
---|
417 | $tmpl->set_var('frontend_name', " - ".$GLOBALS['phpgw_info']['server']['use_frontend_name']); |
---|
418 | |
---|
419 | if (substr($GLOBALS['phpgw_info']['server']['login_logo_file'],0,4) == 'http') |
---|
420 | { |
---|
421 | $var['logo_file'] = $GLOBALS['phpgw_info']['server']['login_logo_file']; |
---|
422 | } |
---|
423 | else |
---|
424 | { |
---|
425 | $var['logo_file'] = $GLOBALS['phpgw']->common->image('phpgwapi',$GLOBALS['phpgw_info']['server']['login_logo_file']?$GLOBALS['phpgw_info']['server']['login_logo_file']:'logo'); |
---|
426 | } |
---|
427 | $var['logo_url'] = $GLOBALS['phpgw_info']['server']['login_logo_url']?$GLOBALS['phpgw_info']['server']['login_logo_url']:'http://www.eGroupWare.org'; |
---|
428 | if (substr($var['logo_url'],0,4) != 'http') |
---|
429 | { |
---|
430 | $var['logo_url'] = 'http://'.$var['logo_url']; |
---|
431 | } |
---|
432 | $var['logo_title'] = $GLOBALS['phpgw_info']['server']['login_logo_title']?$GLOBALS['phpgw_info']['server']['login_logo_title']:'www.eGroupWare.org'; |
---|
433 | $tmpl->set_var($var); |
---|
434 | |
---|
435 | if (!@$GLOBALS['phpgw_info']['server']['login_virtual_keyboard']) |
---|
436 | $tmpl->set_var('show_kbd','none'); |
---|
437 | |
---|
438 | if (@$GLOBALS['phpgw_info']['server']['login_show_language_selection']) |
---|
439 | { |
---|
440 | $select_lang = '<select name="lang" onchange="'."location.href=location.href+(location.search?'&':'?')+'lang='+this.value".'">'; |
---|
441 | $langs = $GLOBALS['phpgw']->translation->get_installed_langs(); |
---|
442 | uasort($langs,'strcasecmp'); |
---|
443 | foreach ($langs as $key => $name) // if we have a translation use it |
---|
444 | { |
---|
445 | $select_lang .= "\n\t".'<option value="'.$key.'"'.($key == $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] ? ' selected="1"' : '').'>'.$name.'</option>'; |
---|
446 | } |
---|
447 | $select_lang .= "\n</select>\n"; |
---|
448 | $tmpl->set_var(array( |
---|
449 | 'lang_language' => lang('Language'), |
---|
450 | 'select_language' => $select_lang, |
---|
451 | )); |
---|
452 | } |
---|
453 | else |
---|
454 | { |
---|
455 | $tmpl->set_block('login_form','language_select'); |
---|
456 | $tmpl->set_var('language_select',''); |
---|
457 | } |
---|
458 | |
---|
459 | $tmpl->set_var('autocomplete', ($GLOBALS['phpgw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : '')); |
---|
460 | |
---|
461 | // soh mostra o captcha se for login sem certificado.... |
---|
462 | if($GLOBALS['phpgw_info']['server']['captcha'] && $_GET['cd']!='300' ) |
---|
463 | { |
---|
464 | $aux_captcha = '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" >'; |
---|
465 | // setcookie(session_name(),base64_encode(session_convert($key_convert . session_id(),$key_convert)),0); |
---|
466 | if($valor_contador > $GLOBALS['phpgw_info']['server']['num_badlogin']) |
---|
467 | { |
---|
468 | $aux_captcha = '<div class="login_label" > |
---|
469 | <img id="id_captcha" src="./security/captcha.php?' . session_name() . '=' . session_id() . '" title="'.lang('Security code').'" alt="'.lang('Security code').'" style="position:static;"> |
---|
470 | <input class="input" type="text" maxlength="50" size="20" name="codigo" id="codigo" value="" > |
---|
471 | <input type="hidden" name="' . session_name() . '" value="' . session_id() . '" > |
---|
472 | </div>'; |
---|
473 | } |
---|
474 | } |
---|
475 | $tmpl->set_var('captcha',$aux_captcha); |
---|
476 | |
---|
477 | // Testa se deve incluir applet para login com certificado...... |
---|
478 | if ($_GET['cd']=='300' && $GLOBALS['phpgw_info']['server']['certificado']==1) |
---|
479 | { |
---|
480 | //Zera o Cookie contador, responsavel pelo captcha |
---|
481 | $_SESSION['contador'] = 0; |
---|
482 | $valor_contador = 0; |
---|
483 | $link_alterna_login = '<img src="phpgwapi/templates/default/images/warning.gif"/><a href="login.php">' . lang('Access without Digital Certificate') . '</a>'; |
---|
484 | $tmpl->set_var('show','none'); |
---|
485 | $tmpl->set_var('action','<div id="action"><img style="border:0px;margin:31px 0px 58px 0px;" src="phpgwapi/templates/default/images/acao.gif" /></div>'); |
---|
486 | // gera parametro com tokens suportados .... |
---|
487 | $var_tokens = ''; |
---|
488 | for($ii = 1; $ii < 11; $ii++) |
---|
489 | { |
---|
490 | if($GLOBALS['phpgw_info']['server']['test_token' . $ii . '1']) |
---|
491 | $var_tokens .= $GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'] . ','; |
---|
492 | } |
---|
493 | |
---|
494 | if(!$var_tokens) |
---|
495 | { |
---|
496 | $var_tokens = 'ePass2000Lx;/usr/lib/libepsng_p11.so,ePass2000Win;c:/windows/system32/ngp11v211.dll'; |
---|
497 | } |
---|
498 | $param1 = " |
---|
499 | '<param name=\"token\" value=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\"> ' + |
---|
500 | "; |
---|
501 | $param2 = " |
---|
502 | 'token=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\" ' + |
---|
503 | "; |
---|
504 | |
---|
505 | $cod_applet = |
---|
506 | |
---|
507 | // com debug ativado |
---|
508 | /* '<script type="text/javascript"> |
---|
509 | if (navigator.userAgent.match(\'MSIE\')){ |
---|
510 | document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' + |
---|
511 | \'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' + |
---|
512 | \'<param name="type" value="application/x-java-applet;version=1.5"> \' + |
---|
513 | \'<param name="codebase" value="/security/">\' + |
---|
514 | \'<param name="code" value="LoginApplet.class"> \' + |
---|
515 | \'<param name="locale" value="' . $GLOBALS['phpgw']->translation->userlang . '"> \' + |
---|
516 | \'<param name="mayscript" value="true"> \' + ' |
---|
517 | . $param1 |
---|
518 | . ' \'<param name="archive" value="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar"> \' + |
---|
519 | \'<param name="debug" value="true"> \' + |
---|
520 | \'</object>\'); |
---|
521 | } |
---|
522 | else { |
---|
523 | document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" codebase="/security/" code="LoginApplet.class" locale="' . $GLOBALS['phpgw']->translation->userlang . '"\' + |
---|
524 | \'archive="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar" \' + ' |
---|
525 | . $param2 |
---|
526 | . ' \'type="application/x-java-applet;version=1.5" debug= "true" mayscript > \' + |
---|
527 | \'<noembed> \' + |
---|
528 | \'No Java Support. \' + |
---|
529 | \'</noembed> \' + |
---|
530 | \'</embed> \'); |
---|
531 | } |
---|
532 | </script>'; |
---|
533 | */ |
---|
534 | // sem debug ativado |
---|
535 | '<script type="text/javascript"> |
---|
536 | if (navigator.userAgent.match(\'MSIE\')){ |
---|
537 | document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' + |
---|
538 | \'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' + |
---|
539 | \'<param name="type" value="application/x-java-applet;version=1.5"> \' + |
---|
540 | \'<param name="codebase" value="/security/">\' + |
---|
541 | \'<param name="code" value="LoginApplet.class"> \' + |
---|
542 | \'<param name="locale" value="' . $GLOBALS['phpgw']->translation->userlang . '"> \' + |
---|
543 | \'<param name="mayscript" value="true"> \' + ' |
---|
544 | . $param1 |
---|
545 | . ' \'<param name="archive" value="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar"> \' + |
---|
546 | \'</object>\'); |
---|
547 | } |
---|
548 | else { |
---|
549 | document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" codebase="/security/" code="LoginApplet.class" locale="' . $GLOBALS['phpgw']->translation->userlang . '"\' + |
---|
550 | \'archive="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar" \' + ' |
---|
551 | . $param2 |
---|
552 | . ' \'type="application/x-java-applet;version=1.5" mayscript > \' + |
---|
553 | \'<noembed> \' + |
---|
554 | \'No Java Support. \' + |
---|
555 | \'</noembed> \' + |
---|
556 | \'</embed> \'); |
---|
557 | } |
---|
558 | </script>'; |
---|
559 | |
---|
560 | |
---|
561 | } |
---|
562 | |
---|
563 | else |
---|
564 | { |
---|
565 | if($GLOBALS['phpgw_info']['server']['certificado']==1) |
---|
566 | { |
---|
567 | $tmpl->set_var('show','yes'); |
---|
568 | $link_alterna_login = '<img src="phpgwapi/templates/default/images/lock1_icon.gif"/><a title="' . lang('Link to use digital certificate') . '" href="login.php?cd=300">' . lang('Logon with my digital certificate') . '</a>'; |
---|
569 | } |
---|
570 | $tmpl->set_var('lang_username',lang('username')); |
---|
571 | $tmpl->set_var('action',''); |
---|
572 | $cod_applet = ''; |
---|
573 | |
---|
574 | } |
---|
575 | |
---|
576 | $tmpl->set_var('applet',$cod_applet); |
---|
577 | $tmpl->set_var('link_alterna_login',$link_alterna_login); |
---|
578 | |
---|
579 | |
---|
580 | $tmpl->set_var('dir_root', 'http://' . nearest_to_me() . '/'); |
---|
581 | if(is_file(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php')) |
---|
582 | include_once(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php'); |
---|
583 | if(isset($ultima_revisao)) $tmpl->set_var('ultima_rev','<br>' . $ultima_revisao); |
---|
584 | |
---|
585 | // Adiciona código personalizado de outro template |
---|
586 | // que esteja utilizando o login_default.php |
---|
587 | if(is_file('.'.$template_dir.'/login.inc.php')) { |
---|
588 | include_once('.'.$template_dir.'/login.inc.php'); |
---|
589 | } |
---|
590 | |
---|
591 | $tmpl->pfp('loginout','login_form'); |
---|
592 | |
---|
593 | ?> |
---|
594 | |
---|