@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | use EGroupware\Api\Framework; |
| 16 | 16 | use EGroupware\Api\Egw; |
| 17 | 17 | |
| 18 | -$submit = False; // set to some initial value |
|
| 18 | +$submit = False; // set to some initial value |
|
| 19 | 19 | |
| 20 | 20 | $GLOBALS['egw_info'] = array('flags' => array( |
| 21 | 21 | 'disable_Template_class' => True, |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | 'currentapp' => 'login', |
| 24 | 24 | )); |
| 25 | 25 | |
| 26 | -if(file_exists('./header.inc.php')) |
|
| 26 | +if (file_exists('./header.inc.php')) |
|
| 27 | 27 | { |
| 28 | 28 | include('./header.inc.php'); |
| 29 | - if(!function_exists('CreateObject')) |
|
| 29 | + if (!function_exists('CreateObject')) |
|
| 30 | 30 | { |
| 31 | 31 | Header('Location: setup/index.php'); |
| 32 | 32 | exit; |
@@ -42,17 +42,17 @@ discard block |
||
| 42 | 42 | * Destroy any existing anonymous session. |
| 43 | 43 | * Copied from logout.php. Maybe make it a common function? |
| 44 | 44 | */ |
| 45 | -if(isset($GLOBALS['sitemgr_info']) && $GLOBALS['egw_info']['user']['userid'] == $GLOBALS['sitemgr_info']['anonymous_user']) |
|
| 45 | +if (isset($GLOBALS['sitemgr_info']) && $GLOBALS['egw_info']['user']['userid'] == $GLOBALS['sitemgr_info']['anonymous_user']) |
|
| 46 | 46 | { |
| 47 | - if($GLOBALS['egw']->session->verify()) |
|
| 47 | + if ($GLOBALS['egw']->session->verify()) |
|
| 48 | 48 | { |
| 49 | 49 | Api\Hooks::process('logout'); |
| 50 | - $GLOBALS['egw']->session->destroy($GLOBALS['sessionid'],$GLOBALS['kp3']); |
|
| 50 | + $GLOBALS['egw']->session->destroy($GLOBALS['sessionid'], $GLOBALS['kp3']); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // CAS : |
| 55 | -if($GLOBALS['egw_info']['server']['auth_type'] == 'cas') |
|
| 55 | +if ($GLOBALS['egw_info']['server']['auth_type'] == 'cas') |
|
| 56 | 56 | { |
| 57 | 57 | ob_end_clean(); |
| 58 | 58 | |
@@ -60,32 +60,32 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | //phpCAS::setDebug('/var/log/log_phpcas.php'); |
| 62 | 62 | |
| 63 | - if($GLOBALS['egw_info']['server']['cas_authentication_mode'] == 'Proxy') |
|
| 63 | + if ($GLOBALS['egw_info']['server']['cas_authentication_mode'] == 'Proxy') |
|
| 64 | 64 | { |
| 65 | 65 | phpCAS::proxy(CAS_VERSION_2_0, |
| 66 | 66 | $GLOBALS['egw_info']['server']['cas_server_host_name'], |
| 67 | - (int) $GLOBALS['egw_info']['server']['cas_server_port'], |
|
| 68 | - $GLOBALS['egw_info']['server']['cas_server_uri'] ); |
|
| 67 | + (int)$GLOBALS['egw_info']['server']['cas_server_port'], |
|
| 68 | + $GLOBALS['egw_info']['server']['cas_server_uri']); |
|
| 69 | 69 | } |
| 70 | 70 | else |
| 71 | 71 | { |
| 72 | 72 | phpCAS::client(CAS_VERSION_2_0, |
| 73 | 73 | $GLOBALS['egw_info']['server']['cas_server_host_name'], |
| 74 | - (int) $GLOBALS['egw_info']['server']['cas_server_port'], |
|
| 75 | - $GLOBALS['egw_info']['server']['cas_server_uri'] ); |
|
| 74 | + (int)$GLOBALS['egw_info']['server']['cas_server_port'], |
|
| 75 | + $GLOBALS['egw_info']['server']['cas_server_uri']); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'PEMCertificate') |
|
| 78 | + if ($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'PEMCertificate') |
|
| 79 | 79 | { |
| 80 | 80 | // Set the certificate of the CAS server (PEM Certificate) |
| 81 | 81 | phpCAS::setCasServerCert($GLOBALS['egw_info']['server']['cas_cert']); |
| 82 | 82 | } |
| 83 | - elseif($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'CACertificate') |
|
| 83 | + elseif ($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'CACertificate') |
|
| 84 | 84 | { |
| 85 | 85 | // Set the CA certificate of the CAS server |
| 86 | 86 | phpCAS::setCasServerCACert($GLOBALS['egw_info']['server']['cas_cert']); |
| 87 | 87 | } |
| 88 | - elseif($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'No') |
|
| 88 | + elseif ($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'No') |
|
| 89 | 89 | { |
| 90 | 90 | // no SSL validation for the CAS server |
| 91 | 91 | phpCAS::setNoCasServerValidation(); |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | ob_start(); |
| 97 | 97 | |
| 98 | 98 | $login = phpCAS::getUser(); |
| 99 | - $password = phpCAS::retrievePT("imap://".$GLOBALS['egw_info']['server']['mail_server'],$err_code,$output); |
|
| 100 | - $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login,$password,'text'); |
|
| 99 | + $password = phpCAS::retrievePT("imap://".$GLOBALS['egw_info']['server']['mail_server'], $err_code, $output); |
|
| 100 | + $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login, $password, 'text'); |
|
| 101 | 101 | |
| 102 | 102 | /* set auth_cookie */ |
| 103 | - $GLOBALS['egw']->redirect_link($forward,$extra_vars); |
|
| 103 | + $GLOBALS['egw']->redirect_link($forward, $extra_vars); |
|
| 104 | 104 | } |
| 105 | 105 | else |
| 106 | 106 | { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $GLOBALS['egw']->framework = Framework::factory(); |
| 126 | 126 | |
| 127 | 127 | // This is used for system downtime, to prevent new logins. |
| 128 | - if($GLOBALS['egw_info']['server']['deny_all_logins']) |
|
| 128 | + if ($GLOBALS['egw_info']['server']['deny_all_logins']) |
|
| 129 | 129 | { |
| 130 | 130 | echo $GLOBALS['egw']->framework->denylogin_screen(); |
| 131 | 131 | exit; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER']; |
| 140 | 140 | } |
| 141 | - if($GLOBALS['egw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER'])) |
|
| 141 | + if ($GLOBALS['egw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER'])) |
|
| 142 | 142 | { |
| 143 | 143 | $submit = True; |
| 144 | 144 | $login = $_SERVER['PHP_AUTH_USER']; |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | $passwd = get_magic_quotes_gpc() ? stripslashes($_POST['passwd']) : $_POST['passwd']; |
| 151 | 151 | $passwd_type = $_POST['passwd_type']; |
| 152 | 152 | |
| 153 | - if($GLOBALS['egw_info']['server']['allow_cookie_auth']) |
|
| 153 | + if ($GLOBALS['egw_info']['server']['allow_cookie_auth']) |
|
| 154 | 154 | { |
| 155 | - $eGW_remember = explode('::::',get_magic_quotes_gpc() ? stripslashes($_COOKIE['eGW_remember']) : $_COOKIE['eGW_remember']); |
|
| 155 | + $eGW_remember = explode('::::', get_magic_quotes_gpc() ? stripslashes($_COOKIE['eGW_remember']) : $_COOKIE['eGW_remember']); |
|
| 156 | 156 | |
| 157 | - if($eGW_remember[0] && $eGW_remember[1] && $eGW_remember[2]) |
|
| 157 | + if ($eGW_remember[0] && $eGW_remember[1] && $eGW_remember[2]) |
|
| 158 | 158 | { |
| 159 | 159 | $_SERVER['PHP_AUTH_USER'] = $login = $eGW_remember[0]; |
| 160 | 160 | $_SERVER['PHP_AUTH_PW'] = $passwd = $eGW_remember[1]; |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | $submit = True; |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | - if(!$passwd && ($GLOBALS['egw_info']['server']['auto_anon_login']) && !$_GET['cd']) |
|
| 165 | + if (!$passwd && ($GLOBALS['egw_info']['server']['auto_anon_login']) && !$_GET['cd']) |
|
| 166 | 166 | { |
| 167 | 167 | $_SERVER['PHP_AUTH_USER'] = $login = 'anonymous'; |
| 168 | - $_SERVER['PHP_AUTH_PW'] = $passwd = 'anonymous'; |
|
| 168 | + $_SERVER['PHP_AUTH_PW'] = $passwd = 'anonymous'; |
|
| 169 | 169 | $passwd_type = 'text'; |
| 170 | 170 | $submit = True; |
| 171 | 171 | } |
@@ -173,26 +173,26 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | # Apache + mod_ssl style SSL certificate authentication |
| 175 | 175 | # Certificate (chain) verification occurs inside mod_ssl |
| 176 | - if($GLOBALS['egw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd'])) |
|
| 176 | + if ($GLOBALS['egw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd'])) |
|
| 177 | 177 | { |
| 178 | 178 | // an X.509 subject looks like: |
| 179 | 179 | // CN=john.doe/OU=Department/O=Company/C=xx/[email protected]/L=City/ |
| 180 | 180 | // the username is deliberately lowercase, to ease LDAP integration |
| 181 | - $sslattribs = explode('/',$_SERVER['SSL_CLIENT_S_DN']); |
|
| 181 | + $sslattribs = explode('/', $_SERVER['SSL_CLIENT_S_DN']); |
|
| 182 | 182 | # skip the part in front of the first '/' (nothing) |
| 183 | - while(($sslattrib = next($sslattribs))) |
|
| 183 | + while (($sslattrib = next($sslattribs))) |
|
| 184 | 184 | { |
| 185 | - list($key,$val) = explode('=',$sslattrib); |
|
| 185 | + list($key, $val) = explode('=', $sslattrib); |
|
| 186 | 186 | $sslattributes[$key] = $val; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if(isset($sslattributes['Email'])) |
|
| 189 | + if (isset($sslattributes['Email'])) |
|
| 190 | 190 | { |
| 191 | 191 | $submit = True; |
| 192 | 192 | |
| 193 | 193 | # login will be set here if the user logged out and uses a different username with |
| 194 | 194 | # the same SSL-certificate. |
| 195 | - if(!isset($_POST['login'])&&isset($sslattributes['Email'])) |
|
| 195 | + if (!isset($_POST['login']) && isset($sslattributes['Email'])) |
|
| 196 | 196 | { |
| 197 | 197 | $login = $sslattributes['Email']; |
| 198 | 198 | # not checked against the database, but delivered to authentication module |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | unset($sslattributes); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if(isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit) |
|
| 207 | + if (isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit) |
|
| 208 | 208 | { |
| 209 | - if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' && |
|
| 209 | + if (getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' && |
|
| 210 | 210 | !isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN'])) |
| 211 | 211 | { |
| 212 | - $GLOBALS['egw']->session->egw_setcookie('eGW_remember','',0,'/'); |
|
| 213 | - Egw::redirect_link('/login.php','cd=5'); |
|
| 212 | + $GLOBALS['egw']->session->egw_setcookie('eGW_remember', '', 0, '/'); |
|
| 213 | + Egw::redirect_link('/login.php', 'cd=5'); |
|
| 214 | 214 | } |
| 215 | 215 | /* cookie enabled check comment out, as it seems to cause a redirect loop under certain conditions and browsers :-( |
| 216 | 216 | if ($_COOKIE['eGW_cookie_test'] !== 'enabled') |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | }*/ |
| 220 | 220 | |
| 221 | 221 | // don't get login data again when $submit is true |
| 222 | - if($submit == false) |
|
| 222 | + if ($submit == false) |
|
| 223 | 223 | { |
| 224 | 224 | $login = $_POST['login']; |
| 225 | 225 | } |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | //conference - for strings like [email protected]@default , allows |
| 228 | 228 | //that user have a login that is his e-mail. (viniciuscb) |
| 229 | 229 | // remove blanks |
| 230 | - $login_parts = array_map('trim',explode('@',$login)); |
|
| 231 | - $login = implode('@',$login_parts); |
|
| 230 | + $login_parts = array_map('trim', explode('@', $login)); |
|
| 231 | + $login = implode('@', $login_parts); |
|
| 232 | 232 | |
| 233 | 233 | $got_login = false; |
| 234 | 234 | if (count($login_parts) > 1) |
| 235 | 235 | { |
| 236 | 236 | //Last part of login string, when separated by @, is a domain name |
| 237 | - if (array_key_exists(array_pop($login_parts),$GLOBALS['egw_domain'])) |
|
| 237 | + if (array_key_exists(array_pop($login_parts), $GLOBALS['egw_domain'])) |
|
| 238 | 238 | { |
| 239 | 239 | $got_login = true; |
| 240 | 240 | } |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | if (!$got_login) |
| 244 | 244 | { |
| 245 | - if(isset($_POST['logindomain'])) |
|
| 245 | + if (isset($_POST['logindomain'])) |
|
| 246 | 246 | { |
| 247 | - $login .= '@' . $_POST['logindomain']; |
|
| 247 | + $login .= '@'.$_POST['logindomain']; |
|
| 248 | 248 | } |
| 249 | - elseif(!isset($GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']])) |
|
| 249 | + elseif (!isset($GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']])) |
|
| 250 | 250 | { |
| 251 | 251 | $login .= '@'.$GLOBALS['egw_info']['server']['default_domain']; |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login, $passwd, |
| 255 | - $passwd_type, false, true, true); // true = let session fail on forced password change |
|
| 255 | + $passwd_type, false, true, true); // true = let session fail on forced password change |
|
| 256 | 256 | |
| 257 | 257 | if (!$GLOBALS['sessionid'] && $GLOBALS['egw']->session->cd_reason == Api\Session::CD_FORCE_PASSWORD_CHANGE) |
| 258 | 258 | { |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | } |
| 265 | 265 | else |
| 266 | 266 | { |
| 267 | - $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login,$_POST['new_passwd'],$passwd_type); |
|
| 267 | + $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login, $_POST['new_passwd'], $passwd_type); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | else |
@@ -276,29 +276,29 @@ discard block |
||
| 276 | 276 | { |
| 277 | 277 | // will show new login-screen incl. new password field below |
| 278 | 278 | } |
| 279 | - elseif (!isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid']) |
|
| 279 | + elseif (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) |
|
| 280 | 280 | { |
| 281 | - Api\Session::egw_setcookie('eGW_remember','',0,'/'); |
|
| 282 | - Egw::redirect_link('/login.php?cd=' . $GLOBALS['egw']->session->cd_reason); |
|
| 281 | + Api\Session::egw_setcookie('eGW_remember', '', 0, '/'); |
|
| 282 | + Egw::redirect_link('/login.php?cd='.$GLOBALS['egw']->session->cd_reason); |
|
| 283 | 283 | } |
| 284 | 284 | else |
| 285 | 285 | { |
| 286 | 286 | /* set auth_cookie */ |
| 287 | - if($GLOBALS['egw_info']['server']['allow_cookie_auth'] && $_POST['remember_me'] && $_POST['passwd']) |
|
| 287 | + if ($GLOBALS['egw_info']['server']['allow_cookie_auth'] && $_POST['remember_me'] && $_POST['passwd']) |
|
| 288 | 288 | { |
| 289 | 289 | switch ($_POST['remember_me']) |
| 290 | 290 | { |
| 291 | 291 | case '1hour' : |
| 292 | - $remember_time = time()+60*60; |
|
| 292 | + $remember_time = time() + 60 * 60; |
|
| 293 | 293 | break; |
| 294 | 294 | case '1day' : |
| 295 | - $remember_time = time()+60*60*24; |
|
| 295 | + $remember_time = time() + 60 * 60 * 24; |
|
| 296 | 296 | break; |
| 297 | 297 | case '1week' : |
| 298 | - $remember_time = time()+60*60*24*7; |
|
| 298 | + $remember_time = time() + 60 * 60 * 24 * 7; |
|
| 299 | 299 | break; |
| 300 | 300 | case '1month' : |
| 301 | - $remember_time = time()+60*60*24*30; |
|
| 301 | + $remember_time = time() + 60 * 60 * 24 * 30; |
|
| 302 | 302 | break; |
| 303 | 303 | case 'forever' : |
| 304 | 304 | default: |
@@ -310,17 +310,17 @@ discard block |
||
| 310 | 310 | // It is served unencrypted and saved as a cookie, which is not recommended |
| 311 | 311 | // !!!!! Never Never save credentials into cookies !!!!! |
| 312 | 312 | // Implement only sessions instead |
| 313 | - $GLOBALS['egw']->session->egw_setcookie('eGW_remember',implode('::::',array( |
|
| 313 | + $GLOBALS['egw']->session->egw_setcookie('eGW_remember', implode('::::', array( |
|
| 314 | 314 | 'login' => $login, |
| 315 | 315 | 'passwd' => $passwd, |
| 316 | 316 | 'passwd_type' => $passwd_type)), |
| 317 | - $remember_time,'/'); // make the cookie valid for the whole site (incl. sitemgr) and not only the eGW install-dir |
|
| 317 | + $remember_time, '/'); // make the cookie valid for the whole site (incl. sitemgr) and not only the eGW install-dir |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_POST['lang']) && |
|
| 320 | + if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_POST['lang']) && |
|
| 321 | 321 | $_POST['lang'] != $GLOBALS['egw_info']['user']['preferences']['common']['lang']) |
| 322 | 322 | { |
| 323 | - $GLOBALS['egw']->preferences->add('common','lang',$_POST['lang'],'session'); |
|
| 323 | + $GLOBALS['egw']->preferences->add('common', 'lang', $_POST['lang'], 'session'); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | // check if new translations are available |
@@ -334,27 +334,27 @@ discard block |
||
| 334 | 334 | } |
| 335 | 335 | else |
| 336 | 336 | { |
| 337 | - list($forward,$extra_vars) = explode('?',$forward,2); |
|
| 337 | + list($forward, $extra_vars) = explode('?', $forward, 2); |
|
| 338 | 338 | $extra_vars .= ($extra_vars ? '&' : '').'cd=yes'; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if(strpos($_SERVER['HTTP_REFERER'], $_SERVER['REQUEST_URI']) === false) { |
|
| 341 | + if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['REQUEST_URI']) === false) { |
|
| 342 | 342 | // login requuest does not come from login.php |
| 343 | 343 | // redirect to referer on logout |
| 344 | 344 | Api\Cache::setSession('login', 'referer', $_SERVER['HTTP_REFERER']); |
| 345 | 345 | } |
| 346 | - $strength = ($GLOBALS['egw_info']['server']['force_pwd_strength']?$GLOBALS['egw_info']['server']['force_pwd_strength']:false); |
|
| 347 | - if ($strength && $strength>5) $strength =5; |
|
| 348 | - if ($strength && $strength<0) $strength = false; |
|
| 346 | + $strength = ($GLOBALS['egw_info']['server']['force_pwd_strength'] ? $GLOBALS['egw_info']['server']['force_pwd_strength'] : false); |
|
| 347 | + if ($strength && $strength > 5) $strength = 5; |
|
| 348 | + if ($strength && $strength < 0) $strength = false; |
|
| 349 | 349 | // Check for save passwd |
| 350 | - if($strength && $GLOBALS['egw_info']['server']['check_save_passwd'] && !$GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences') && |
|
| 350 | + if ($strength && $GLOBALS['egw_info']['server']['check_save_passwd'] && !$GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences') && |
|
| 351 | 351 | ($unsave_msg = $GLOBALS['egw']->auth->crackcheck($passwd, $strength))) |
| 352 | 352 | { |
| 353 | - error_log('login::'.__LINE__.' User '. $login. ' authenticated with an unsave password'.' '.$unsave_msg); |
|
| 353 | + error_log('login::'.__LINE__.' User '.$login.' authenticated with an unsave password'.' '.$unsave_msg); |
|
| 354 | 354 | $message = lang('eGroupWare checked your password for safetyness. You have to change your password for the following reason:')."\n"; |
| 355 | 355 | Egw::redirect_link('/index.php', array( |
| 356 | 356 | 'menuaction' => 'preferences.uipassword.change', |
| 357 | - 'message' => $message . $unsave_msg, |
|
| 357 | + 'message' => $message.$unsave_msg, |
|
| 358 | 358 | 'cd' => 'yes', |
| 359 | 359 | )); |
| 360 | 360 | } |
@@ -362,66 +362,66 @@ discard block |
||
| 362 | 362 | { |
| 363 | 363 | // commiting the session, before redirecting might fix racecondition in session creation |
| 364 | 364 | $GLOBALS['egw']->session->commit_session(); |
| 365 | - Egw::redirect_link($forward,$extra_vars); |
|
| 365 | + Egw::redirect_link($forward, $extra_vars); |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | // show login screen |
| 370 | - if(isset($_COOKIE['last_loginid'])) |
|
| 370 | + if (isset($_COOKIE['last_loginid'])) |
|
| 371 | 371 | { |
| 372 | 372 | $prefs = new Api\Preferences($GLOBALS['egw']->accounts->name2id($_COOKIE['last_loginid'])); |
| 373 | 373 | |
| 374 | - if($prefs->account_id) |
|
| 374 | + if ($prefs->account_id) |
|
| 375 | 375 | { |
| 376 | 376 | $GLOBALS['egw_info']['user']['preferences'] = $prefs->read_repository(); |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | - if ($_GET['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_GET['lang'])) |
|
| 379 | + if ($_GET['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_GET['lang'])) |
|
| 380 | 380 | { |
| 381 | 381 | $GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $_GET['lang']; |
| 382 | 382 | } |
| 383 | - elseif(!isset($_COOKIE['last_loginid']) || !$prefs->account_id) |
|
| 383 | + elseif (!isset($_COOKIE['last_loginid']) || !$prefs->account_id) |
|
| 384 | 384 | { |
| 385 | 385 | // If the lastloginid cookies isn't set, we will default to the first language, |
| 386 | 386 | // the users browser accepts. |
| 387 | - list($lang) = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); |
|
| 388 | - if(strlen($lang) > 2) |
|
| 387 | + list($lang) = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); |
|
| 388 | + if (strlen($lang) > 2) |
|
| 389 | 389 | { |
| 390 | - $lang = substr($lang,0,2); |
|
| 390 | + $lang = substr($lang, 0, 2); |
|
| 391 | 391 | } |
| 392 | 392 | $GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $lang; |
| 393 | 393 | } |
| 394 | 394 | if ($_COOKIE['eGW_cookie_test'] !== 'enabled') |
| 395 | 395 | { |
| 396 | - Api\Session::egw_setcookie('eGW_cookie_test','enabled',0); |
|
| 396 | + Api\Session::egw_setcookie('eGW_cookie_test', 'enabled', 0); |
|
| 397 | 397 | } |
| 398 | 398 | #print 'LANG:' . $GLOBALS['egw_info']['user']['preferences']['common']['lang'] . '<br>'; |
| 399 | - Api\Translation::init(); // this will set the language according to the (new) set prefs |
|
| 399 | + Api\Translation::init(); // this will set the language according to the (new) set prefs |
|
| 400 | 400 | Api\Translation::add_app('login'); |
| 401 | 401 | Api\Translation::add_app('loginscreen'); |
| 402 | - $GLOBALS['loginscreenmessage'] = Api\Translation::translate('loginscreen_message',false,''); |
|
| 403 | - if($GLOBALS['loginscreenmessage'] == 'loginscreen_message' || empty($GLOBALS['loginscreenmessage'])) |
|
| 402 | + $GLOBALS['loginscreenmessage'] = Api\Translation::translate('loginscreen_message', false, ''); |
|
| 403 | + if ($GLOBALS['loginscreenmessage'] == 'loginscreen_message' || empty($GLOBALS['loginscreenmessage'])) |
|
| 404 | 404 | { |
| 405 | - Api\Translation::add_app('loginscreen','en'); // trying the en one |
|
| 406 | - $GLOBALS['loginscreenmessage'] = Api\Translation::translate('loginscreen_message',false,''); |
|
| 405 | + Api\Translation::add_app('loginscreen', 'en'); // trying the en one |
|
| 406 | + $GLOBALS['loginscreenmessage'] = Api\Translation::translate('loginscreen_message', false, ''); |
|
| 407 | 407 | } |
| 408 | - if($GLOBALS['loginscreenmessage'] == 'loginscreen_message' || empty($GLOBALS['loginscreenmessage'])) |
|
| 408 | + if ($GLOBALS['loginscreenmessage'] == 'loginscreen_message' || empty($GLOBALS['loginscreenmessage'])) |
|
| 409 | 409 | { |
| 410 | 410 | // remove the global var since the lang loginscreen message and its fallback (en) is empty or not set |
| 411 | 411 | unset($GLOBALS['loginscreenmessage']); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - foreach($_GET as $name => $value) |
|
| 414 | + foreach ($_GET as $name => $value) |
|
| 415 | 415 | { |
| 416 | - if(strpos($name,'phpgw_') !== false) |
|
| 416 | + if (strpos($name, 'phpgw_') !== false) |
|
| 417 | 417 | { |
| 418 | - $extra_vars .= '&' . $name . '=' . urlencode($value); |
|
| 418 | + $extra_vars .= '&'.$name.'='.urlencode($value); |
|
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - if($extra_vars) |
|
| 422 | + if ($extra_vars) |
|
| 423 | 423 | { |
| 424 | - $extra_vars = '?' . substr($extra_vars,1); |
|
| 424 | + $extra_vars = '?'.substr($extra_vars, 1); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | $GLOBALS['egw']->framework->login_screen($extra_vars, $force_password_change); |