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