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