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