[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 | |
---|
[5141] | 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: |
---|
[5036] | 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>'; |
---|
[5036] | 40 | return '<font color="FF0000">' . lang('Bad login or password') . '</font>'; |
---|
[3448] | 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 | } |
---|
[5141] | 59 | function troca_espaco_por_mais($pem_data) |
---|
[5042] | 60 | { |
---|
[5141] | 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; |
---|
[5042] | 68 | } |
---|
[5164] | 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 | { |
---|
[5042] | 89 | /* Program starts here */ |
---|
[5141] | 90 | |
---|
[949] | 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 | } |
---|
[5141] | 136 | if(isset($_POST['certificado']) && $_POST['certificado']) |
---|
| 137 | { |
---|
[5042] | 138 | |
---|
[5141] | 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 | } |
---|
[5042] | 141 | if( isset( $_GET[ 'cd' ] ) && ( $_GET['cd']=='1' || $_GET['cd'] == 10 ) ) |
---|
[3437] | 142 | { |
---|
| 143 | $_SESSION['contador'] = 0; |
---|
| 144 | } |
---|
| 145 | |
---|
[949] | 146 | if(isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit) |
---|
| 147 | { |
---|
[3437] | 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 | { |
---|
[3448] | 156 | if(!$_GET['cd']) |
---|
| 157 | { |
---|
| 158 | $_GET['cd'] = '200'; |
---|
| 159 | } |
---|
[3437] | 160 | } |
---|
| 161 | unset($_SESSION['CAPTCHAString']); |
---|
| 162 | } |
---|
| 163 | } |
---|
[1713] | 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']; |
---|
[6528] | 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 | |
---|
[1247] | 222 | } |
---|
[949] | 223 | if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' && |
---|
| 224 | !isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN'])) |
---|
| 225 | { |
---|
[3448] | 226 | if(!$_GET['cd']) |
---|
| 227 | { |
---|
| 228 | $_GET['cd'] = '5'; |
---|
| 229 | } |
---|
[949] | 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 | } |
---|
[5036] | 246 | |
---|
| 247 | If(!$_GET['cd']) |
---|
| 248 | $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create(strtolower($login),$passwd,$passwd_type,'u'); |
---|
[949] | 249 | |
---|
| 250 | if(!isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid']) |
---|
| 251 | { |
---|
[5036] | 252 | If(!$_GET['cd']) $_GET['cd'] = $GLOBALS['phpgw']->session->cd_reason; |
---|
[949] | 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 | } |
---|
[3486] | 276 | if ($GLOBALS['phpgw_info']['server']['use_https'] != 2) |
---|
[949] | 277 | { |
---|
[3486] | 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>"; |
---|
[949] | 282 | } |
---|
[3486] | 283 | else |
---|
[949] | 284 | { |
---|
[3486] | 285 | $GLOBALS['phpgw']->redirect_link($forward,$extra_vars); |
---|
[949] | 286 | } |
---|
| 287 | } |
---|
| 288 | } |
---|
[3448] | 289 | //else // ================================================================================= |
---|
| 290 | //{ |
---|
[3437] | 291 | $valor_contador = $_SESSION['contador']; |
---|
| 292 | $valor_contador = $valor_contador + 1; |
---|
| 293 | $_SESSION['contador'] = $valor_contador; |
---|
[949] | 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 | } |
---|
[1933] | 307 | |
---|
| 308 | $_GET['lang'] = addslashes($_GET['lang']); |
---|
[949] | 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; |
---|
[5141] | 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 | } |
---|
[949] | 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 | } |
---|
[3448] | 346 | //} |
---|
[949] | 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']); |
---|
[7673] | 352 | |
---|
| 353 | $organizations_count = count($organizations); |
---|
| 354 | for ($i=0; $i<$organizations_count; ++$i) |
---|
[949] | 355 | { |
---|
| 356 | $tmp_array[strtolower($organizations[$i])] = $organizations[$i]; |
---|
| 357 | } |
---|
| 358 | |
---|
| 359 | $arrayOrganization = $tmp_array; |
---|
| 360 | ksort($arrayOrganization); |
---|
| 361 | |
---|
| 362 | foreach($arrayOrganization |
---|
| 363 | as $organization_name => $organization_vars) |
---|
| 364 | { |
---|
| 365 | $organization_select .= '<option value="' . $organization_name . '"'; |
---|
| 366 | |
---|
| 367 | if($organization_name == $_COOKIE['last_organization']) |
---|
| 368 | { |
---|
| 369 | $organization_select .= ' selected'; |
---|
| 370 | } |
---|
| 371 | $organization_select .= '>' . $organization_vars . "</option>\n"; |
---|
| 372 | } |
---|
[1713] | 373 | $organization_select = '<div class="login_label"><label>'.lang("organization") |
---|
| 374 | .'</label><br><select name="organization">' |
---|
| 375 | .$organization_select.'</select></div>'; |
---|
[949] | 376 | $tmpl->set_var('select_organization',$organization_select); |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | $domain_select = ' '; |
---|
| 380 | $last_loginid = $_COOKIE['last_loginid']; |
---|
| 381 | if($GLOBALS['phpgw_info']['server']['show_domain_selectbox']) |
---|
| 382 | { |
---|
| 383 | $domain_select = "<select name=\"logindomain\">\n"; |
---|
| 384 | foreach($GLOBALS['phpgw_domain'] as $domain_name => $domain_vars) |
---|
| 385 | { |
---|
| 386 | $domain_select .= '<option value="' . $domain_name . '"'; |
---|
| 387 | |
---|
| 388 | if($domain_name == $_COOKIE['last_domain']) |
---|
| 389 | { |
---|
| 390 | $domain_select .= ' selected'; |
---|
| 391 | } |
---|
| 392 | $domain_select .= '>' . $domain_name . "</option>\n"; |
---|
| 393 | } |
---|
| 394 | $domain_select .= "</select>\n"; |
---|
| 395 | } |
---|
| 396 | elseif($last_loginid !== '') |
---|
| 397 | { |
---|
| 398 | reset($GLOBALS['phpgw_domain']); |
---|
| 399 | list($default_domain) = each($GLOBALS['phpgw_domain']); |
---|
| 400 | |
---|
| 401 | if($_COOKIE['last_domain'] != $default_domain && !empty($_COOKIE['last_domain'])) |
---|
| 402 | { |
---|
| 403 | $last_loginid .= '@' . $_COOKIE['last_domain']; |
---|
| 404 | } |
---|
| 405 | } |
---|
| 406 | $tmpl->set_var('select_domain',$domain_select); |
---|
| 407 | |
---|
| 408 | foreach($_GET as $name => $value) |
---|
| 409 | { |
---|
[5281] | 410 | if(preg_match('/phpgw_/',$name)) |
---|
[949] | 411 | { |
---|
| 412 | $extra_vars .= '&' . $name . '=' . urlencode($value); |
---|
| 413 | } |
---|
| 414 | } |
---|
| 415 | |
---|
[1734] | 416 | if ( is_string( $extra_vars ) ) |
---|
[949] | 417 | { |
---|
| 418 | $extra_vars = '?' . substr($extra_vars,1); |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | /********************************************************\ |
---|
| 422 | * Check is the registration app is installed, activated * |
---|
| 423 | * And if the register link must be placed * |
---|
| 424 | \********************************************************/ |
---|
| 425 | |
---|
| 426 | $cnf_reg = createobject('phpgwapi.config','registration'); |
---|
| 427 | $cnf_reg->read_repository(); |
---|
| 428 | $config_reg = $cnf_reg->config_data; |
---|
| 429 | |
---|
[7681] | 430 | if($config_reg['enable_registration']=='True' && $config_reg['register_link']=='True') |
---|
[949] | 431 | { |
---|
| 432 | $reg_link=' <a href="registration/">'.lang('Not a user yet? Register now').'</a><br/>'; |
---|
| 433 | } |
---|
| 434 | |
---|
[3494] | 435 | $template = $GLOBALS['phpgw_info']['login_template_set']; |
---|
| 436 | $GLOBALS['phpgw_info']['server']['template_set'] = $template; |
---|
[949] | 437 | |
---|
| 438 | $tmpl->set_var('register_link',$reg_link); |
---|
| 439 | $tmpl->set_var('charset',$GLOBALS['phpgw']->translation->charset()); |
---|
| 440 | $tmpl->set_var('login_url', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php' . $extra_vars); |
---|
| 441 | $tmpl->set_var('registration_url',$GLOBALS['phpgw_info']['server']['webserver_url'] . '/registration/'); |
---|
| 442 | $tmpl->set_var('version',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']); |
---|
| 443 | $tmpl->set_var('cd',check_logoutcode($_GET['cd'])); |
---|
| 444 | $tmpl->set_var('cookie',$last_loginid); |
---|
| 445 | |
---|
| 446 | $tmpl->set_var('lang_username',lang('username')); |
---|
| 447 | $tmpl->set_var('lang_password',lang('password')); |
---|
| 448 | $tmpl->set_var('lang_login',lang('login')); |
---|
| 449 | |
---|
| 450 | $tmpl->set_var('website_title', $GLOBALS['phpgw_info']['server']['site_title']); |
---|
[3494] | 451 | $tmpl->set_var('template_set', $template); |
---|
[1860] | 452 | |
---|
[3500] | 453 | // loads the template's login.css |
---|
| 454 | // and then the theme's login.css (if any) |
---|
| 455 | $template_dir = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/' . $template; |
---|
| 456 | $login_dir = $template_dir . '/login.css'; |
---|
| 457 | $login_css = "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />"; |
---|
| 458 | $login_dir = $template_dir . '/themes/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '/login.css'; |
---|
| 459 | if(file_exists('./'.$login_dir)) |
---|
[3494] | 460 | { |
---|
[3500] | 461 | $login_css .= "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />"; |
---|
[3494] | 462 | } |
---|
| 463 | $tmpl->set_var('login_css',$login_css); |
---|
| 464 | |
---|
[3480] | 465 | $GLOBALS['phpgw']->translation->add_app('loginhelp',$_GET['lang']); |
---|
| 466 | |
---|
[1860] | 467 | if(lang('loginhelp_message') != 'loginhelp_message*' && trim(lang('loginhelp_message')) != ""){ |
---|
[7109] | 468 | $tmpl->set_var('lang_help',lang("Help")); |
---|
| 469 | $tmpl->set_var('lang','pt-br'); |
---|
[1860] | 470 | } |
---|
| 471 | else |
---|
| 472 | $tmpl->set_var('display_help','none'); |
---|
| 473 | |
---|
[949] | 474 | $tmpl->set_var('bg_color',($GLOBALS['phpgw_info']['server']['login_bg_color']?$GLOBALS['phpgw_info']['server']['login_bg_color']:'FFFFFF')); |
---|
| 475 | $tmpl->set_var('bg_color_title',($GLOBALS['phpgw_info']['server']['login_bg_color_title']?$GLOBALS['phpgw_info']['server']['login_bg_color_title']:'486591')); |
---|
| 476 | |
---|
| 477 | if($GLOBALS['phpgw_info']['server']['use_frontend_name']) |
---|
| 478 | $tmpl->set_var('frontend_name', " - ".$GLOBALS['phpgw_info']['server']['use_frontend_name']); |
---|
| 479 | |
---|
| 480 | if (substr($GLOBALS['phpgw_info']['server']['login_logo_file'],0,4) == 'http') |
---|
| 481 | { |
---|
| 482 | $var['logo_file'] = $GLOBALS['phpgw_info']['server']['login_logo_file']; |
---|
| 483 | } |
---|
| 484 | else |
---|
| 485 | { |
---|
| 486 | $var['logo_file'] = $GLOBALS['phpgw']->common->image('phpgwapi',$GLOBALS['phpgw_info']['server']['login_logo_file']?$GLOBALS['phpgw_info']['server']['login_logo_file']:'logo'); |
---|
| 487 | } |
---|
| 488 | $var['logo_url'] = $GLOBALS['phpgw_info']['server']['login_logo_url']?$GLOBALS['phpgw_info']['server']['login_logo_url']:'http://www.eGroupWare.org'; |
---|
| 489 | if (substr($var['logo_url'],0,4) != 'http') |
---|
| 490 | { |
---|
| 491 | $var['logo_url'] = 'http://'.$var['logo_url']; |
---|
| 492 | } |
---|
| 493 | $var['logo_title'] = $GLOBALS['phpgw_info']['server']['login_logo_title']?$GLOBALS['phpgw_info']['server']['login_logo_title']:'www.eGroupWare.org'; |
---|
| 494 | $tmpl->set_var($var); |
---|
| 495 | |
---|
[3191] | 496 | if (!@$GLOBALS['phpgw_info']['server']['login_virtual_keyboard']) |
---|
| 497 | $tmpl->set_var('show_kbd','none'); |
---|
| 498 | |
---|
[949] | 499 | if (@$GLOBALS['phpgw_info']['server']['login_show_language_selection']) |
---|
| 500 | { |
---|
| 501 | $select_lang = '<select name="lang" onchange="'."location.href=location.href+(location.search?'&':'?')+'lang='+this.value".'">'; |
---|
| 502 | $langs = $GLOBALS['phpgw']->translation->get_installed_langs(); |
---|
| 503 | uasort($langs,'strcasecmp'); |
---|
| 504 | foreach ($langs as $key => $name) // if we have a translation use it |
---|
| 505 | { |
---|
| 506 | $select_lang .= "\n\t".'<option value="'.$key.'"'.($key == $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] ? ' selected="1"' : '').'>'.$name.'</option>'; |
---|
| 507 | } |
---|
| 508 | $select_lang .= "\n</select>\n"; |
---|
| 509 | $tmpl->set_var(array( |
---|
| 510 | 'lang_language' => lang('Language'), |
---|
| 511 | 'select_language' => $select_lang, |
---|
| 512 | )); |
---|
| 513 | } |
---|
| 514 | else |
---|
| 515 | { |
---|
| 516 | $tmpl->set_block('login_form','language_select'); |
---|
| 517 | $tmpl->set_var('language_select',''); |
---|
| 518 | } |
---|
| 519 | |
---|
| 520 | $tmpl->set_var('autocomplete', ($GLOBALS['phpgw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : '')); |
---|
[3550] | 521 | |
---|
| 522 | // soh mostra o captcha se for login sem certificado.... |
---|
| 523 | if($GLOBALS['phpgw_info']['server']['captcha'] && $_GET['cd']!='300' ) |
---|
[1247] | 524 | { |
---|
[3550] | 525 | $aux_captcha = '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" >'; |
---|
| 526 | // setcookie(session_name(),base64_encode(session_convert($key_convert . session_id(),$key_convert)),0); |
---|
| 527 | if($valor_contador > $GLOBALS['phpgw_info']['server']['num_badlogin']) |
---|
| 528 | { |
---|
| 529 | $aux_captcha = '<div class="login_label" > |
---|
| 530 | <img id="id_captcha" src="./security/captcha.php?' . session_name() . '=' . session_id() . '" title="'.lang('Security code').'" alt="'.lang('Security code').'" style="position:static;"> |
---|
| 531 | <input class="input" type="text" maxlength="50" size="20" name="codigo" id="codigo" value="" > |
---|
| 532 | <input type="hidden" name="' . session_name() . '" value="' . session_id() . '" > |
---|
| 533 | </div>'; |
---|
| 534 | } |
---|
| 535 | } |
---|
| 536 | $tmpl->set_var('captcha',$aux_captcha); |
---|
| 537 | |
---|
| 538 | // Testa se deve incluir applet para login com certificado...... |
---|
| 539 | if ($_GET['cd']=='300' && $GLOBALS['phpgw_info']['server']['certificado']==1) |
---|
| 540 | { |
---|
[1247] | 541 | //Zera o Cookie contador, responsavel pelo captcha |
---|
[3624] | 542 | $_SESSION['contador'] = 0; |
---|
| 543 | $valor_contador = 0; |
---|
| 544 | $link_alterna_login = '<img src="phpgwapi/templates/default/images/warning.gif"/><a href="login.php">' . lang('Access without Digital Certificate') . '</a>'; |
---|
[1247] | 545 | $tmpl->set_var('show','none'); |
---|
| 546 | $tmpl->set_var('action','<div id="action"><img style="border:0px;margin:31px 0px 58px 0px;" src="phpgwapi/templates/default/images/acao.gif" /></div>'); |
---|
| 547 | // gera parametro com tokens suportados .... |
---|
| 548 | $var_tokens = ''; |
---|
[7655] | 549 | for($ii = 1; $ii < 11; ++$ii) |
---|
[3550] | 550 | { |
---|
| 551 | if($GLOBALS['phpgw_info']['server']['test_token' . $ii . '1']) |
---|
| 552 | $var_tokens .= $GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'] . ','; |
---|
| 553 | } |
---|
[1247] | 554 | |
---|
| 555 | if(!$var_tokens) |
---|
[3550] | 556 | { |
---|
| 557 | $var_tokens = 'ePass2000Lx;/usr/lib/libepsng_p11.so,ePass2000Win;c:/windows/system32/ngp11v211.dll'; |
---|
| 558 | } |
---|
| 559 | $param1 = " |
---|
| 560 | '<param name=\"token\" value=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\"> ' + |
---|
| 561 | "; |
---|
| 562 | $param2 = " |
---|
| 563 | 'token=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\" ' + |
---|
| 564 | "; |
---|
[1247] | 565 | |
---|
[3550] | 566 | $cod_applet = |
---|
| 567 | |
---|
[1247] | 568 | /* // com debug ativado |
---|
| 569 | '<script type="text/javascript"> |
---|
| 570 | if (navigator.userAgent.match(\'MSIE\')){ |
---|
| 571 | document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' + |
---|
| 572 | \'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' + |
---|
| 573 | \'<param name="type" value="application/x-java-applet;version=1.5"> \' + |
---|
| 574 | \'<param name="code" value="LoginApplet.class"> \' + |
---|
| 575 | \'<param name="locale" value="' . $lang . '"> \' + |
---|
| 576 | \'<param name="mayscript" value="true"> \' + ' |
---|
| 577 | . $param1 |
---|
| 578 | . ' \'<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"> \' + |
---|
| 579 | \'<param name="debug" value="true"> \' + |
---|
| 580 | \'</object>\'); |
---|
| 581 | } |
---|
| 582 | else { |
---|
| 583 | document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" code="LoginApplet.class" locale="' . $lang . '"\' + |
---|
| 584 | \'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" \' + ' |
---|
| 585 | . $param2 |
---|
| 586 | . ' \'type="application/x-java-applet;version=1.5" debug= "true" mayscript > \' + |
---|
| 587 | \'<noembed> \' + |
---|
| 588 | \'No Java Support. \' + |
---|
| 589 | \'</noembed> \' + |
---|
| 590 | \'</embed> \'); |
---|
| 591 | } |
---|
| 592 | </script>'; |
---|
| 593 | */ |
---|
| 594 | // sem debug ativado |
---|
| 595 | '<script type="text/javascript"> |
---|
| 596 | if (navigator.userAgent.match(\'MSIE\')){ |
---|
| 597 | document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' + |
---|
| 598 | \'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' + |
---|
| 599 | \'<param name="type" value="application/x-java-applet;version=1.5"> \' + |
---|
| 600 | \'<param name="codebase" value="/security/">\' + |
---|
| 601 | \'<param name="code" value="LoginApplet.class"> \' + |
---|
| 602 | \'<param name="locale" value="' . $lang . '"> \' + |
---|
| 603 | \'<param name="mayscript" value="true"> \' + ' |
---|
| 604 | . $param1 |
---|
| 605 | . ' \'<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"> \' + |
---|
| 606 | \'</object>\'); |
---|
| 607 | } |
---|
| 608 | else { |
---|
| 609 | document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" codebase="/security/" code="LoginApplet.class" locale="' . $lang . '"\' + |
---|
| 610 | \'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" \' + ' |
---|
| 611 | . $param2 |
---|
| 612 | . ' \'type="application/x-java-applet;version=1.5" mayscript > \' + |
---|
| 613 | \'<noembed> \' + |
---|
| 614 | \'No Java Support. \' + |
---|
| 615 | \'</noembed> \' + |
---|
| 616 | \'</embed> \'); |
---|
| 617 | } |
---|
| 618 | </script>'; |
---|
| 619 | |
---|
| 620 | |
---|
| 621 | } |
---|
| 622 | |
---|
[3550] | 623 | else |
---|
[1247] | 624 | { |
---|
| 625 | if($GLOBALS['phpgw_info']['server']['certificado']==1) |
---|
[3550] | 626 | { |
---|
| 627 | $tmpl->set_var('show','yes'); |
---|
[3624] | 628 | $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] | 629 | } |
---|
[3550] | 630 | $tmpl->set_var('lang_username',lang('username')); |
---|
| 631 | $tmpl->set_var('action',''); |
---|
| 632 | $cod_applet = ''; |
---|
[1247] | 633 | |
---|
[3550] | 634 | } |
---|
[1247] | 635 | |
---|
[3550] | 636 | $tmpl->set_var('applet',$cod_applet); |
---|
| 637 | $tmpl->set_var('link_alterna_login',$link_alterna_login); |
---|
| 638 | |
---|
| 639 | |
---|
| 640 | $tmpl->set_var('dir_root', 'http://' . nearest_to_me() . '/'); |
---|
| 641 | if(is_file(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php')) |
---|
| 642 | include_once(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php'); |
---|
| 643 | if(isset($ultima_revisao)) $tmpl->set_var('ultima_rev','<br>' . $ultima_revisao); |
---|
| 644 | |
---|
[6528] | 645 | // Adiciona cï¿œdigo personalizado de outro template |
---|
[3551] | 646 | // que esteja utilizando o login_default.php |
---|
| 647 | if(is_file('.'.$template_dir.'/login.inc.php')) { |
---|
| 648 | include_once('.'.$template_dir.'/login.inc.php'); |
---|
| 649 | } |
---|
| 650 | |
---|
[949] | 651 | $tmpl->pfp('loginout','login_form'); |
---|
[5164] | 652 | } |
---|
[3550] | 653 | |
---|
[1247] | 654 | ?> |
---|
| 655 | |
---|