PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/phpgwapi/templates/default/login_default.php

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