@@ -177,7 +177,7 @@ discard block  | 
                                                    ||
| 177 | 177 | const CD_SECOND_FACTOR_REQUIRED = 96;  | 
                                                        
| 178 | 178 | const CD_FORCE_PASSWORD_CHANGE = 97;  | 
                                                        
| 179 | 179 | const CD_ACCOUNT_EXPIRED = 98;  | 
                                                        
| 180 | - const CD_BLOCKED = 99; // to many failed attempts to loing  | 
                                                        |
| 180 | + const CD_BLOCKED = 99; // to many failed attempts to loing  | 
                                                        |
| 181 | 181 | |
| 182 | 182 | /**  | 
                                                        
| 183 | 183 | * Verbose reason why session creation failed  | 
                                                        
@@ -198,7 +198,7 @@ discard block  | 
                                                    ||
| 198 | 198 | *  | 
                                                        
| 199 | 199 | * @param array $domain_names =null domain-names used in this install  | 
                                                        
| 200 | 200 | */  | 
                                                        
| 201 | - function __construct(array $domain_names=null)  | 
                                                        |
| 201 | + function __construct(array $domain_names = null)  | 
                                                        |
| 202 | 202 |  	{ | 
                                                        
| 203 | 203 | $this->required_files = $_SESSION[self::EGW_REQUIRED_FILES];  | 
                                                        
| 204 | 204 | |
@@ -214,27 +214,27 @@ discard block  | 
                                                    ||
| 214 | 214 | $save_rep = false;  | 
                                                        
| 215 | 215 | if (!isset($GLOBALS['egw_info']['server']['max_access_log_age']))  | 
                                                        
| 216 | 216 |  			{ | 
                                                        
| 217 | - $GLOBALS['egw_info']['server']['max_access_log_age'] = 90; // default 90 days  | 
                                                        |
| 217 | + $GLOBALS['egw_info']['server']['max_access_log_age'] = 90; // default 90 days  | 
                                                        |
| 218 | 218 | $save_rep = true;  | 
                                                        
| 219 | 219 | }  | 
                                                        
| 220 | 220 | if (!isset($GLOBALS['egw_info']['server']['block_time']))  | 
                                                        
| 221 | 221 |  			{ | 
                                                        
| 222 | - $GLOBALS['egw_info']['server']['block_time'] = 1; // default 1min, its enough to slow down brute force attacks  | 
                                                        |
| 222 | + $GLOBALS['egw_info']['server']['block_time'] = 1; // default 1min, its enough to slow down brute force attacks  | 
                                                        |
| 223 | 223 | $save_rep = true;  | 
                                                        
| 224 | 224 | }  | 
                                                        
| 225 | 225 | if (!isset($GLOBALS['egw_info']['server']['num_unsuccessful_id']))  | 
                                                        
| 226 | 226 |  			{ | 
                                                        
| 227 | - $GLOBALS['egw_info']['server']['num_unsuccessful_id'] = 3; // default 3 trys per id  | 
                                                        |
| 227 | + $GLOBALS['egw_info']['server']['num_unsuccessful_id'] = 3; // default 3 trys per id  | 
                                                        |
| 228 | 228 | $save_rep = true;  | 
                                                        
| 229 | 229 | }  | 
                                                        
| 230 | 230 | if (!isset($GLOBALS['egw_info']['server']['num_unsuccessful_ip']))  | 
                                                        
| 231 | 231 |  			{ | 
                                                        
| 232 | - $GLOBALS['egw_info']['server']['num_unsuccessful_ip'] = $GLOBALS['egw_info']['server']['num_unsuccessful_id'] * 5; // default is 5 times as high as the id default; since accessing via proxy is quite common  | 
                                                        |
| 232 | + $GLOBALS['egw_info']['server']['num_unsuccessful_ip'] = $GLOBALS['egw_info']['server']['num_unsuccessful_id'] * 5; // default is 5 times as high as the id default; since accessing via proxy is quite common  | 
                                                        |
| 233 | 233 | $save_rep = true;  | 
                                                        
| 234 | 234 | }  | 
                                                        
| 235 | 235 | if (!isset($GLOBALS['egw_info']['server']['install_id']))  | 
                                                        
| 236 | 236 |  			{ | 
                                                        
| 237 | - $GLOBALS['egw_info']['server']['install_id'] = md5(Auth::randomstring(15));  | 
                                                        |
| 237 | + $GLOBALS['egw_info']['server']['install_id'] = md5(Auth::randomstring(15));  | 
                                                        |
| 238 | 238 | }  | 
                                                        
| 239 | 239 | if (!isset($GLOBALS['egw_info']['server']['max_history']))  | 
                                                        
| 240 | 240 |  			{ | 
                                                        
@@ -246,18 +246,18 @@ discard block  | 
                                                    ||
| 246 | 246 |  			{ | 
                                                        
| 247 | 247 |  				$config = new Config('phpgwapi'); | 
                                                        
| 248 | 248 | $config->read_repository();  | 
                                                        
| 249 | -				$config->value('max_access_log_age',$GLOBALS['egw_info']['server']['max_access_log_age']); | 
                                                        |
| 250 | -				$config->value('block_time',$GLOBALS['egw_info']['server']['block_time']); | 
                                                        |
| 251 | -				$config->value('num_unsuccessful_id',$GLOBALS['egw_info']['server']['num_unsuccessful_id']); | 
                                                        |
| 252 | -				$config->value('num_unsuccessful_ip',$GLOBALS['egw_info']['server']['num_unsuccessful_ip']); | 
                                                        |
| 253 | -				$config->value('install_id',$GLOBALS['egw_info']['server']['install_id']); | 
                                                        |
| 254 | -				$config->value('max_history',$GLOBALS['egw_info']['server']['max_history']); | 
                                                        |
| 249 | +				$config->value('max_access_log_age', $GLOBALS['egw_info']['server']['max_access_log_age']); | 
                                                        |
| 250 | +				$config->value('block_time', $GLOBALS['egw_info']['server']['block_time']); | 
                                                        |
| 251 | +				$config->value('num_unsuccessful_id', $GLOBALS['egw_info']['server']['num_unsuccessful_id']); | 
                                                        |
| 252 | +				$config->value('num_unsuccessful_ip', $GLOBALS['egw_info']['server']['num_unsuccessful_ip']); | 
                                                        |
| 253 | +				$config->value('install_id', $GLOBALS['egw_info']['server']['install_id']); | 
                                                        |
| 254 | +				$config->value('max_history', $GLOBALS['egw_info']['server']['max_history']); | 
                                                        |
| 255 | 255 | try  | 
                                                        
| 256 | 256 |  				{ | 
                                                        
| 257 | 257 | $config->save_repository();  | 
                                                        
| 258 | 258 | }  | 
                                                        
| 259 | 259 |  				catch (Db\Exception $e) { | 
                                                        
| 260 | - _egw_log_exception($e); // ignore exception, as it blocks session creation, if database is not writable  | 
                                                        |
| 260 | + _egw_log_exception($e); // ignore exception, as it blocks session creation, if database is not writable  | 
                                                        |
| 261 | 261 | }  | 
                                                        
| 262 | 262 | }  | 
                                                        
| 263 | 263 | }  | 
                                                        
@@ -266,7 +266,7 @@ discard block  | 
                                                    ||
| 266 | 266 | // set session_timeout from global php.ini and default to 14400=4h, if not set  | 
                                                        
| 267 | 267 |  		if (!($GLOBALS['egw_info']['server']['sessions_timeout'] = ini_get('session.gc_maxlifetime'))) | 
                                                        
| 268 | 268 |        	{ | 
                                                        
| 269 | -      		ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout']=14400); | 
                                                        |
| 269 | +      		ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout'] = 14400); | 
                                                        |
| 270 | 270 | }  | 
                                                        
| 271 | 271 | }  | 
                                                        
| 272 | 272 | |
@@ -335,15 +335,15 @@ discard block  | 
                                                    ||
| 335 | 335 | |
| 336 | 336 | if (!isset($_SESSION[self::EGW_SESSION_ENCRYPTED]) && self::init_crypt($kp3))  | 
                                                        
| 337 | 337 |  		{ | 
                                                        
| 338 | - foreach(self::$egw_session_vars as $name)  | 
                                                        |
| 338 | + foreach (self::$egw_session_vars as $name)  | 
                                                        |
| 339 | 339 |  			{ | 
                                                        
| 340 | 340 | if (isset($_SESSION[$name]))  | 
                                                        
| 341 | 341 |  				{ | 
                                                        
| 342 | - $_SESSION[$name] = mcrypt_generic(self::$mcrypt,serialize($_SESSION[$name]));  | 
                                                        |
| 342 | + $_SESSION[$name] = mcrypt_generic(self::$mcrypt, serialize($_SESSION[$name]));  | 
                                                        |
| 343 | 343 | //error_log(__METHOD__."() 'encrypting' session var: $name, len=".strlen($_SESSION[$name]));  | 
                                                        
| 344 | 344 | }  | 
                                                        
| 345 | 345 | }  | 
                                                        
| 346 | - $_SESSION[self::EGW_SESSION_ENCRYPTED] = true; // flag session as encrypted  | 
                                                        |
| 346 | + $_SESSION[self::EGW_SESSION_ENCRYPTED] = true; // flag session as encrypted  | 
                                                        |
| 347 | 347 | |
| 348 | 348 | mcrypt_generic_deinit(self::$mcrypt);  | 
                                                        
| 349 | 349 | self::$mcrypt = null;  | 
                                                        
@@ -358,24 +358,24 @@ discard block  | 
                                                    ||
| 358 | 358 | * @param boolean $recursion =true if true call itself for every item > $limit  | 
                                                        
| 359 | 359 | * @param int $limit =1000 log only differences > $limit  | 
                                                        
| 360 | 360 | */  | 
                                                        
| 361 | - static function log_session_usage(&$arr,$label,$recursion=true,$limit=1000)  | 
                                                        |
| 361 | + static function log_session_usage(&$arr, $label, $recursion = true, $limit = 1000)  | 
                                                        |
| 362 | 362 |  	{ | 
                                                        
| 363 | 363 | if (!is_array($arr)) return;  | 
                                                        
| 364 | 364 | |
| 365 | 365 | $sizes = array();  | 
                                                        
| 366 | - foreach($arr as $key => &$data)  | 
                                                        |
| 366 | + foreach ($arr as $key => &$data)  | 
                                                        |
| 367 | 367 |  		{ | 
                                                        
| 368 | 368 | $sizes[$key] = strlen(serialize($data));  | 
                                                        
| 369 | 369 | }  | 
                                                        
| 370 | - arsort($sizes,SORT_NUMERIC);  | 
                                                        |
| 371 | - foreach($sizes as $key => $size)  | 
                                                        |
| 370 | + arsort($sizes, SORT_NUMERIC);  | 
                                                        |
| 371 | + foreach ($sizes as $key => $size)  | 
                                                        |
| 372 | 372 |  		{ | 
                                                        
| 373 | 373 | $diff = $size - (int)$_SESSION[$label.'-sizes'][$key];  | 
                                                        
| 374 | 374 | $_SESSION[$label.'-sizes'][$key] = $size;  | 
                                                        
| 375 | 375 | if ($diff > $limit)  | 
                                                        
| 376 | 376 |  			{ | 
                                                        
| 377 | 377 |  				error_log("strlen({$label}[$key])=".Vfs::hsize($size).", diff=".Vfs::hsize($diff)); | 
                                                        
| 378 | - if ($recursion) self::log_session_usage($arr[$key],$label.'['.$key.']',$recursion,$limit);  | 
                                                        |
| 378 | + if ($recursion) self::log_session_usage($arr[$key], $label.'['.$key.']', $recursion, $limit);  | 
                                                        |
| 379 | 379 | }  | 
                                                        
| 380 | 380 | }  | 
                                                        
| 381 | 381 | }  | 
                                                        
@@ -390,15 +390,15 @@ discard block  | 
                                                    ||
| 390 | 390 |  	{ | 
                                                        
| 391 | 391 |  		if ($_SESSION[self::EGW_SESSION_ENCRYPTED] && self::init_crypt(self::get_request('kp3'))) | 
                                                        
| 392 | 392 |  		{ | 
                                                        
| 393 | - foreach(self::$egw_session_vars as $name)  | 
                                                        |
| 393 | + foreach (self::$egw_session_vars as $name)  | 
                                                        |
| 394 | 394 |  			{ | 
                                                        
| 395 | 395 | if (isset($_SESSION[$name]))  | 
                                                        
| 396 | 396 |  				{ | 
                                                        
| 397 | - $_SESSION[$name] = unserialize(trim(mdecrypt_generic(self::$mcrypt,$_SESSION[$name])));  | 
                                                        |
| 397 | + $_SESSION[$name] = unserialize(trim(mdecrypt_generic(self::$mcrypt, $_SESSION[$name])));  | 
                                                        |
| 398 | 398 | //error_log(__METHOD__."() 'decrypting' session var $name: gettype($name) = ".gettype($_SESSION[$name]));  | 
                                                        
| 399 | 399 | }  | 
                                                        
| 400 | 400 | }  | 
                                                        
| 401 | - unset($_SESSION[self::EGW_SESSION_ENCRYPTED]); // delete encryption flag  | 
                                                        |
| 401 | + unset($_SESSION[self::EGW_SESSION_ENCRYPTED]); // delete encryption flag  | 
                                                        |
| 402 | 402 | }  | 
                                                        
| 403 | 403 | }  | 
                                                        
| 404 | 404 | |
@@ -413,13 +413,13 @@ discard block  | 
                                                    ||
| 413 | 413 | */  | 
                                                        
| 414 | 414 | static private function init_crypt($kp3)  | 
                                                        
| 415 | 415 |  	{ | 
                                                        
| 416 | - if(!$GLOBALS['egw_info']['server']['mcrypt_enabled'])  | 
                                                        |
| 416 | + if (!$GLOBALS['egw_info']['server']['mcrypt_enabled'])  | 
                                                        |
| 417 | 417 |  		{ | 
                                                        
| 418 | - return false; // session encryption is switched off  | 
                                                        |
| 418 | + return false; // session encryption is switched off  | 
                                                        |
| 419 | 419 | }  | 
                                                        
| 420 | 420 | if ($GLOBALS['egw_info']['currentapp'] == 'syncml' || !$kp3)  | 
                                                        
| 421 | 421 |  		{ | 
                                                        
| 422 | - $kp3 = 'staticsyncmlkp3'; // syncml has no kp3!  | 
                                                        |
| 422 | + $kp3 = 'staticsyncmlkp3'; // syncml has no kp3!  | 
                                                        |
| 423 | 423 | }  | 
                                                        
| 424 | 424 | if (is_null(self::$mcrypt))  | 
                                                        
| 425 | 425 |  		{ | 
                                                        
@@ -435,9 +435,9 @@ discard block  | 
                                                    ||
| 435 | 435 | }  | 
                                                        
| 436 | 436 | $iv_size = mcrypt_enc_get_iv_size(self::$mcrypt);  | 
                                                        
| 437 | 437 | $iv = !isset($GLOBALS['egw_info']['server']['mcrypt_iv']) || strlen($GLOBALS['egw_info']['server']['mcrypt_iv']) < $iv_size ?  | 
                                                        
| 438 | - mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size);  | 
                                                        |
| 438 | + mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'], 0, $iv_size);  | 
                                                        |
| 439 | 439 | |
| 440 | - if (mcrypt_generic_init(self::$mcrypt,$kp3, $iv) < 0)  | 
                                                        |
| 440 | + if (mcrypt_generic_init(self::$mcrypt, $kp3, $iv) < 0)  | 
                                                        |
| 441 | 441 |  			{ | 
                                                        
| 442 | 442 | error_log(__METHOD__."() could not initialise mcrypt, sessions get NOT encrypted!");  | 
                                                        
| 443 | 443 | return self::$mcrypt = false;  | 
                                                        
@@ -459,7 +459,7 @@ discard block  | 
                                                    ||
| 459 | 459 | * @param string $remember_me =null "True" for checkbox checked, or periode for user-choice select-box eg. "P1W" or "" for NOT remember  | 
                                                        
| 460 | 460 | * @return string|boolean session id or false if session was not created, $this->(cd_)reason contains cause  | 
                                                        
| 461 | 461 | */  | 
                                                        
| 462 | - function create($login,$passwd = '',$passwd_type = '',$no_session=false,$auth_check=true,$fail_on_forced_password_change=false,$check_2fa=false,$remember_me=null)  | 
                                                        |
| 462 | + function create($login, $passwd = '', $passwd_type = '', $no_session = false, $auth_check = true, $fail_on_forced_password_change = false, $check_2fa = false, $remember_me = null)  | 
                                                        |
| 463 | 463 |  	{ | 
                                                        
| 464 | 464 |  		try { | 
                                                        
| 465 | 465 | if (is_array($login))  | 
                                                        
@@ -477,9 +477,9 @@ discard block  | 
                                                    ||
| 477 | 477 | }  | 
                                                        
| 478 | 478 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) starting ...");  | 
                                                        
| 479 | 479 | |
| 480 | - self::split_login_domain($login,$this->account_lid,$this->account_domain);  | 
                                                        |
| 480 | + self::split_login_domain($login, $this->account_lid, $this->account_domain);  | 
                                                        |
| 481 | 481 | // add domain to the login, if not already there  | 
                                                        
| 482 | - if (substr($this->login,-strlen($this->account_domain)-1) != '@'.$this->account_domain)  | 
                                                        |
| 482 | + if (substr($this->login, -strlen($this->account_domain) - 1) != '@'.$this->account_domain)  | 
                                                        |
| 483 | 483 |  			{ | 
                                                        
| 484 | 484 | $this->login .= '@'.$this->account_domain;  | 
                                                        
| 485 | 485 | }  | 
                                                        
@@ -496,7 +496,7 @@ discard block  | 
                                                    ||
| 496 | 496 |  			{ | 
                                                        
| 497 | 497 | $this->account_domain = $GLOBALS['egw_info']['user']['domain'];  | 
                                                        
| 498 | 498 | }  | 
                                                        
| 499 | - elseif($this->account_domain != $GLOBALS['egw_info']['user']['domain'])  | 
                                                        |
| 499 | + elseif ($this->account_domain != $GLOBALS['egw_info']['user']['domain'])  | 
                                                        |
| 500 | 500 |  			{ | 
                                                        
| 501 | 501 |  				throw new Exception("Wrong domain! '$this->account_domain' != '{$GLOBALS['egw_info']['user']['domain']}'"); | 
                                                        
| 502 | 502 | }  | 
                                                        
@@ -504,7 +504,7 @@ discard block  | 
                                                    ||
| 504 | 504 | |
| 505 | 505 | $user_ip = self::getuser_ip();  | 
                                                        
| 506 | 506 | |
| 507 | - $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid,'account_lid','u');  | 
                                                        |
| 507 | + $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid, 'account_lid', 'u');  | 
                                                        |
| 508 | 508 | |
| 509 | 509 | // do we need to check 'remember me' token (to bypass authentication)  | 
                                                        
| 510 | 510 | if ($auth_check && !empty($_COOKIE[self::REMEMBER_ME_COOKIE]))  | 
                                                        
@@ -512,7 +512,7 @@ discard block  | 
                                                    ||
| 512 | 512 | $auth_check = !$this->skipPasswordAuth($_COOKIE[self::REMEMBER_ME_COOKIE], $this->account_id);  | 
                                                        
| 513 | 513 | }  | 
                                                        
| 514 | 514 | |
| 515 | - if (($blocked = $this->login_blocked($login,$user_ip)) || // too many unsuccessful attempts  | 
                                                        |
| 515 | + if (($blocked = $this->login_blocked($login, $user_ip)) || // too many unsuccessful attempts  | 
                                                        |
| 516 | 516 | $GLOBALS['egw_info']['server']['global_denied_users'][$this->account_lid] ||  | 
                                                        
| 517 | 517 | $auth_check && !$GLOBALS['egw']->auth->authenticate($this->account_lid, $this->passwd, $this->passwd_type) ||  | 
                                                        
| 518 | 518 | $this->account_id && $GLOBALS['egw']->accounts->get_type($this->account_id) == 'g')  | 
                                                        
@@ -521,9 +521,9 @@ discard block  | 
                                                    ||
| 521 | 521 | $this->cd_reason = $blocked ? self::CD_BLOCKED : self::CD_BAD_LOGIN_OR_PASSWORD;  | 
                                                        
| 522 | 522 | |
| 523 | 523 | // we dont log anon users as it would block the website  | 
                                                        
| 524 | - if (!$GLOBALS['egw']->acl->get_specific_rights_for_account($this->account_id,'anonymous','phpgwapi'))  | 
                                                        |
| 524 | + if (!$GLOBALS['egw']->acl->get_specific_rights_for_account($this->account_id, 'anonymous', 'phpgwapi'))  | 
                                                        |
| 525 | 525 |  				{ | 
                                                        
| 526 | - $this->log_access($this->reason,$login,$user_ip,0); // log unsuccessfull login  | 
                                                        |
| 526 | + $this->log_access($this->reason, $login, $user_ip, 0); // log unsuccessfull login  | 
                                                        |
| 527 | 527 | }  | 
                                                        
| 528 | 528 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)");  | 
                                                        
| 529 | 529 | return false;  | 
                                                        
@@ -541,7 +541,7 @@ discard block  | 
                                                    ||
| 541 | 541 | if ($this->account_lid != ($lid = $GLOBALS['egw']->accounts->id2name($this->account_id)))  | 
                                                        
| 542 | 542 |  			{ | 
                                                        
| 543 | 543 | $this->account_lid = $lid;  | 
                                                        
| 544 | - $this->login = $lid.substr($this->login,strlen($lid));  | 
                                                        |
| 544 | + $this->login = $lid.substr($this->login, strlen($lid));  | 
                                                        |
| 545 | 545 | }  | 
                                                        
| 546 | 546 | |
| 547 | 547 | $GLOBALS['egw_info']['user']['account_id'] = $this->account_id;  | 
                                                        
@@ -563,7 +563,7 @@ discard block  | 
                                                    ||
| 563 | 563 | }  | 
                                                        
| 564 | 564 | $this->sessionid = session_id();  | 
                                                        
| 565 | 565 | }  | 
                                                        
| 566 | - $this->kp3 = Auth::randomstring(24);  | 
                                                        |
| 566 | + $this->kp3 = Auth::randomstring(24);  | 
                                                        |
| 567 | 567 | |
| 568 | 568 | $GLOBALS['egw_info']['user'] = $this->read_repositories();  | 
                                                        
| 569 | 569 | if ($GLOBALS['egw']->accounts->is_expired($GLOBALS['egw_info']['user']))  | 
                                                        
@@ -583,10 +583,10 @@ discard block  | 
                                                    ||
| 583 | 583 |  				try { | 
                                                        
| 584 | 584 | $this->checkMultifactorAuth($check_2fa, $_COOKIE[self::REMEMBER_ME_COOKIE]);  | 
                                                        
| 585 | 585 | }  | 
                                                        
| 586 | -				catch(\Exception $e) { | 
                                                        |
| 586 | +				catch (\Exception $e) { | 
                                                        |
| 587 | 587 | $this->cd_reason = $e->getCode();  | 
                                                        
| 588 | 588 | $this->reason = $e->getMessage();  | 
                                                        
| 589 | - $this->log_access($this->reason, $login, $user_ip, 0); // log unsuccessfull login  | 
                                                        |
| 589 | + $this->log_access($this->reason, $login, $user_ip, 0); // log unsuccessfull login  | 
                                                        |
| 590 | 590 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check,$fail_on_forced_password_change,'$check_2fa') UNSUCCESSFULL ($this->reason)");  | 
                                                        
| 591 | 591 | return false;  | 
                                                        
| 592 | 592 | }  | 
                                                        
@@ -598,7 +598,7 @@ discard block  | 
                                                    ||
| 598 | 598 | return false;  | 
                                                        
| 599 | 599 | }  | 
                                                        
| 600 | 600 | |
| 601 | -			if ($GLOBALS['egw']->acl->check('anonymous',1,'phpgwapi')) | 
                                                        |
| 601 | +			if ($GLOBALS['egw']->acl->check('anonymous', 1, 'phpgwapi')) | 
                                                        |
| 602 | 602 |  			{ | 
                                                        
| 603 | 603 | $this->session_flags = 'A';  | 
                                                        
| 604 | 604 | }  | 
                                                        
@@ -616,41 +616,41 @@ discard block  | 
                                                    ||
| 616 | 616 | 'passwd' => $this->passwd,  | 
                                                        
| 617 | 617 | 'account_domain' => $this->account_domain,  | 
                                                        
| 618 | 618 | 'user_ip' => $user_ip,  | 
                                                        
| 619 | - ),'',true))) // true = run hooks from all apps, not just the ones the current user has perms to run  | 
                                                        |
| 619 | + ), '', true))) // true = run hooks from all apps, not just the ones the current user has perms to run  | 
                                                        |
| 620 | 620 |  			{ | 
                                                        
| 621 | - foreach($hook_result as $reason)  | 
                                                        |
| 621 | + foreach ($hook_result as $reason)  | 
                                                        |
| 622 | 622 |  				{ | 
                                                        
| 623 | 623 | if ($reason) // called hook requests to deny the session  | 
                                                        
| 624 | 624 |  					{ | 
                                                        
| 625 | 625 | $this->reason = $this->cd_reason = $reason;  | 
                                                        
| 626 | - $this->log_access($this->reason,$login,$user_ip,0); // log unsuccessfull login  | 
                                                        |
| 626 | + $this->log_access($this->reason, $login, $user_ip, 0); // log unsuccessfull login  | 
                                                        |
| 627 | 627 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)");  | 
                                                        
| 628 | 628 | return false;  | 
                                                        
| 629 | 629 | }  | 
                                                        
| 630 | 630 | }  | 
                                                        
| 631 | 631 | }  | 
                                                        
| 632 | 632 | $GLOBALS['egw']->db->transaction_begin();  | 
                                                        
| 633 | - $this->register_session($this->login,$user_ip,$now,$this->session_flags);  | 
                                                        |
| 633 | + $this->register_session($this->login, $user_ip, $now, $this->session_flags);  | 
                                                        |
| 634 | 634 | if ($this->session_flags != 'A') // dont log anonymous sessions  | 
                                                        
| 635 | 635 |  			{ | 
                                                        
| 636 | - $this->sessionid_access_log = $this->log_access($this->sessionid,$login,$user_ip,$this->account_id);  | 
                                                        |
| 636 | + $this->sessionid_access_log = $this->log_access($this->sessionid, $login, $user_ip, $this->account_id);  | 
                                                        |
| 637 | 637 | // We do NOT log anonymous sessions to not block website and also to cope with  | 
                                                        
| 638 | 638 | // high rate anon endpoints might be called creating a bottleneck in the egw_accounts table.  | 
                                                        
| 639 | 639 |  				Cache::setSession('phpgwapi', 'account_previous_login', $GLOBALS['egw']->auth->previous_login); | 
                                                        
| 640 | - $GLOBALS['egw']->accounts->update_lastlogin($this->account_id,$user_ip);  | 
                                                        |
| 640 | + $GLOBALS['egw']->accounts->update_lastlogin($this->account_id, $user_ip);  | 
                                                        |
| 641 | 641 | }  | 
                                                        
| 642 | 642 | $GLOBALS['egw']->db->transaction_commit();  | 
                                                        
| 643 | 643 | |
| 644 | 644 | if ($GLOBALS['egw_info']['server']['usecookies'] && !$no_session)  | 
                                                        
| 645 | 645 |  			{ | 
                                                        
| 646 | - self::egw_setcookie(self::EGW_SESSION_NAME,$this->sessionid);  | 
                                                        |
| 647 | -				self::egw_setcookie('kp3',$this->kp3); | 
                                                        |
| 648 | -				self::egw_setcookie('domain',$this->account_domain); | 
                                                        |
| 646 | + self::egw_setcookie(self::EGW_SESSION_NAME, $this->sessionid);  | 
                                                        |
| 647 | +				self::egw_setcookie('kp3', $this->kp3); | 
                                                        |
| 648 | +				self::egw_setcookie('domain', $this->account_domain); | 
                                                        |
| 649 | 649 | }  | 
                                                        
| 650 | 650 | if ($GLOBALS['egw_info']['server']['usecookies'] && !$no_session || isset($_COOKIE['last_loginid']))  | 
                                                        
| 651 | 651 |  			{ | 
                                                        
| 652 | -				self::egw_setcookie('last_loginid', $this->account_lid ,$now+1209600); /* For 2 weeks */ | 
                                                        |
| 653 | -				self::egw_setcookie('last_domain',$this->account_domain,$now+1209600); | 
                                                        |
| 652 | +				self::egw_setcookie('last_loginid', $this->account_lid, $now + 1209600); /* For 2 weeks */ | 
                                                        |
| 653 | +				self::egw_setcookie('last_domain', $this->account_domain, $now + 1209600); | 
                                                        |
| 654 | 654 | }  | 
                                                        
| 655 | 655 | |
| 656 | 656 | // set new remember me token/cookie, if requested and necessary  | 
                                                        
@@ -674,13 +674,13 @@ discard block  | 
                                                    ||
| 674 | 674 | 'user_ip' => $user_ip,  | 
                                                        
| 675 | 675 | 'session_type' => Session\Type::get($_SERVER['REQUEST_URI'],  | 
                                                        
| 676 | 676 | $GLOBALS['egw_info']['flags']['current_app'],  | 
                                                        
| 677 | - true), // true return WebGUI instead of login, as we are logged in now  | 
                                                        |
| 678 | - ),'',true);  | 
                                                        |
| 677 | + true), // true return WebGUI instead of login, as we are logged in now  | 
                                                        |
| 678 | + ), '', true);  | 
                                                        |
| 679 | 679 | |
| 680 | 680 | return $this->sessionid;  | 
                                                        
| 681 | 681 | }  | 
                                                        
| 682 | 682 | // catch all exceptions, as their (allways logged) trace (eg. on a database error) would contain the user password  | 
                                                        
| 683 | -		catch(Exception $e) { | 
                                                        |
| 683 | +		catch (Exception $e) { | 
                                                        |
| 684 | 684 | $this->reason = $this->cd_reason = is_a($e, Db\Exception::class) ?  | 
                                                        
| 685 | 685 | // do not output specific database error, eg. invalid SQL statement  | 
                                                        
| 686 | 686 |  				lang('Database Error!') : $e->getMessage(); | 
                                                        
@@ -704,7 +704,7 @@ discard block  | 
                                                    ||
| 704 | 704 | * @param int& $account_id =null account_id of token-owner to limit check on that user, on return account_id of token owner  | 
                                                        
| 705 | 705 | * @return boolean false: if further auth check is required, true: if token is sufficient for authentication  | 
                                                        
| 706 | 706 | */  | 
                                                        
| 707 | - public function skipPasswordAuth($token, &$account_id=null)  | 
                                                        |
| 707 | + public function skipPasswordAuth($token, &$account_id = null)  | 
                                                        |
| 708 | 708 |  	{ | 
                                                        
| 709 | 709 | // if token is empty or disabled --> password authentication required  | 
                                                        
| 710 | 710 | if (empty($token) || $GLOBALS['egw_info']['server']['remember_me_token'] !== 'always' ||  | 
                                                        
@@ -746,7 +746,7 @@ discard block  | 
                                                    ||
| 746 | 746 | |
| 747 | 747 | if ($GLOBALS['egw_info']['server']['2fa_required'] === 'disabled')  | 
                                                        
| 748 | 748 |  		{ | 
                                                        
| 749 | - return; // nothing to check  | 
                                                        |
| 749 | + return; // nothing to check  | 
                                                        |
| 750 | 750 | }  | 
                                                        
| 751 | 751 | |
| 752 | 752 | // check if token exists and is (still) valid  | 
                                                        
@@ -831,7 +831,7 @@ discard block  | 
                                                    ||
| 831 | 831 | $tokenRepo = new OpenID\Repositories\AccessTokenRepository();  | 
                                                        
| 832 | 832 | if ($tokenRepo->findToken($client, $this->account_id, 'PT1S', $token))  | 
                                                        
| 833 | 833 |  				{ | 
                                                        
| 834 | - return null; // token still valid, no need to set it again  | 
                                                        |
| 834 | + return null; // token still valid, no need to set it again  | 
                                                        |
| 835 | 835 | }  | 
                                                        
| 836 | 836 | }  | 
                                                        
| 837 | 837 | $lifetime = $this->rememberMeTokenLifetime(is_string($remember_me) ? $remember_me : null);  | 
                                                        
@@ -882,17 +882,17 @@ discard block  | 
                                                    ||
| 882 | 882 | |
| 883 | 883 | $clients = new OpenID\Repositories\ClientRepository();  | 
                                                        
| 884 | 884 |  		try { | 
                                                        
| 885 | - $client = $clients->getClientEntity(self::OPENID_REMEMBER_ME_CLIENT_ID, null, null, false); // false = do NOT check client-secret  | 
                                                        |
| 885 | + $client = $clients->getClientEntity(self::OPENID_REMEMBER_ME_CLIENT_ID, null, null, false); // false = do NOT check client-secret  | 
                                                        |
| 886 | 886 | }  | 
                                                        
| 887 | 887 | catch (OAuthServerException $e)  | 
                                                        
| 888 | 888 |  		{ | 
                                                        
| 889 | 889 | unset($e);  | 
                                                        
| 890 | 890 | $client = new OpenID\Entities\ClientEntity();  | 
                                                        
| 891 | 891 | $client->setIdentifier(self::OPENID_REMEMBER_ME_CLIENT_ID);  | 
                                                        
| 892 | - $client->setSecret(Auth::randomstring(24)); // must not be unset  | 
                                                        |
| 892 | + $client->setSecret(Auth::randomstring(24)); // must not be unset  | 
                                                        |
| 893 | 893 |  			$client->setName(lang('Remember me token')); | 
                                                        
| 894 | 894 | $client->setAccessTokenTTL($this->rememberMeTokenLifetime());  | 
                                                        
| 895 | -			$client->setRefreshTokenTTL('P0S');	// no refresh token | 
                                                        |
| 895 | +			$client->setRefreshTokenTTL('P0S'); // no refresh token | 
                                                        |
| 896 | 896 | $client->setRedirectUri($GLOBALS['egw_info']['server']['webserver_url'].'/');  | 
                                                        
| 897 | 897 | $clients->persistNewClient($client);  | 
                                                        
| 898 | 898 | }  | 
                                                        
@@ -906,7 +906,7 @@ discard block  | 
                                                    ||
| 906 | 906 | * @param boolean $ts =false false: return periode string, true: return integer timestamp  | 
                                                        
| 907 | 907 | * @return string periode spec eg. 'P1M'  | 
                                                        
| 908 | 908 | */  | 
                                                        
| 909 | - protected function rememberMeTokenLifetime($user=null, $ts=false)  | 
                                                        |
| 909 | + protected function rememberMeTokenLifetime($user = null, $ts = false)  | 
                                                        |
| 910 | 910 |  	{ | 
                                                        
| 911 | 911 | switch ((string)$GLOBALS['egw_info']['server']['remember_me_lifetime'])  | 
                                                        
| 912 | 912 |  		{ | 
                                                        
@@ -941,13 +941,12 @@ discard block  | 
                                                    ||
| 941 | 941 | * @param int $now  | 
                                                        
| 942 | 942 | * @param string $session_flags  | 
                                                        
| 943 | 943 | */  | 
                                                        
| 944 | - private function register_session($login,$user_ip,$now,$session_flags)  | 
                                                        |
| 944 | + private function register_session($login, $user_ip, $now, $session_flags)  | 
                                                        |
| 945 | 945 |  	{ | 
                                                        
| 946 | 946 | // restore session vars set before session was started  | 
                                                        
| 947 | 947 | if (is_array($this->required_files))  | 
                                                        
| 948 | 948 |  		{ | 
                                                        
| 949 | - $_SESSION[self::EGW_REQUIRED_FILES] = !is_array($_SESSION[self::EGW_REQUIRED_FILES]) ? $this->required_files :  | 
                                                        |
| 950 | - array_unique(array_merge($_SESSION[self::EGW_REQUIRED_FILES],$this->required_files));  | 
                                                        |
| 949 | + $_SESSION[self::EGW_REQUIRED_FILES] = !is_array($_SESSION[self::EGW_REQUIRED_FILES]) ? $this->required_files : array_unique(array_merge($_SESSION[self::EGW_REQUIRED_FILES], $this->required_files));  | 
                                                        |
| 951 | 950 | unset($this->required_files);  | 
                                                        
| 952 | 951 | }  | 
                                                        
| 953 | 952 | $_SESSION[self::EGW_SESSION_VAR] = array(  | 
                                                        
@@ -986,7 +985,7 @@ discard block  | 
                                                    ||
| 986 | 985 | * @param int $account_id =0 numerical account_id  | 
                                                        
| 987 | 986 | * @return int $sessionid primary key of egw_access_log for login, null otherwise  | 
                                                        
| 988 | 987 | */  | 
                                                        
| 989 | - private function log_access($sessionid,$login='',$user_ip='',$account_id=0)  | 
                                                        |
| 988 | + private function log_access($sessionid, $login = '', $user_ip = '', $account_id = 0)  | 
                                                        |
| 990 | 989 |  	{ | 
                                                        
| 991 | 990 | // do not log anything for anonymous sessions  | 
                                                        
| 992 | 991 | if ($this->session_flags === 'A')  | 
                                                        
@@ -1004,7 +1003,7 @@ discard block  | 
                                                    ||
| 1004 | 1003 | |
| 1005 | 1004 | if ($login)  | 
                                                        
| 1006 | 1005 |  		{ | 
                                                        
| 1007 | - $GLOBALS['egw']->db->insert(self::ACCESS_LOG_TABLE,array(  | 
                                                        |
| 1006 | + $GLOBALS['egw']->db->insert(self::ACCESS_LOG_TABLE, array(  | 
                                                        |
| 1008 | 1007 | 'session_php' => $sessionid,  | 
                                                        
| 1009 | 1008 | 'loginid' => $login,  | 
                                                        
| 1010 | 1009 | 'ip' => $user_ip,  | 
                                                        
@@ -1012,22 +1011,22 @@ discard block  | 
                                                    ||
| 1012 | 1011 | 'account_id'=> $account_id,  | 
                                                        
| 1013 | 1012 | 'user_agent'=> $_SERVER['HTTP_USER_AGENT'],  | 
                                                        
| 1014 | 1013 | 'session_dla' => $now,  | 
                                                        
| 1015 | - 'session_action' => $this->update_dla(false), // dont update egw_access_log  | 
                                                        |
| 1016 | - ),false,__LINE__,__FILE__);  | 
                                                        |
| 1014 | + 'session_action' => $this->update_dla(false), // dont update egw_access_log  | 
                                                        |
| 1015 | + ), false, __LINE__, __FILE__);  | 
                                                        |
| 1017 | 1016 | |
| 1018 | 1017 | $_SESSION[self::EGW_SESSION_VAR]['session_logged_dla'] = $now;  | 
                                                        
| 1019 | 1018 | |
| 1020 | - $ret = $GLOBALS['egw']->db->get_last_insert_id(self::ACCESS_LOG_TABLE,'sessionid');  | 
                                                        |
| 1019 | + $ret = $GLOBALS['egw']->db->get_last_insert_id(self::ACCESS_LOG_TABLE, 'sessionid');  | 
                                                        |
| 1021 | 1020 | |
| 1022 | 1021 | // if we can not store failed login attempts in database, store it in cache  | 
                                                        
| 1023 | 1022 | if (!$ret && !$account_id)  | 
                                                        
| 1024 | 1023 |  			{ | 
                                                        
| 1025 | 1024 | Cache::setInstance(__CLASS__, self::FALSE_IP_CACHE_PREFIX.$user_ip,  | 
                                                        
| 1026 | - 1+Cache::getInstance(__CLASS__, self::FALSE_IP_CACHE_PREFIX.$user_ip),  | 
                                                        |
| 1025 | + 1 + Cache::getInstance(__CLASS__, self::FALSE_IP_CACHE_PREFIX.$user_ip),  | 
                                                        |
| 1027 | 1026 | $GLOBALS['egw_info']['server']['block_time'] * 60);  | 
                                                        
| 1028 | 1027 | |
| 1029 | 1028 | Cache::setInstance(__CLASS__, self::FALSE_ID_CACHE_PREFIX.$login,  | 
                                                        
| 1030 | - 1+Cache::getInstance(__CLASS__, self::FALSE_ID_CACHE_PREFIX.$login),  | 
                                                        |
| 1029 | + 1 + Cache::getInstance(__CLASS__, self::FALSE_ID_CACHE_PREFIX.$login),  | 
                                                        |
| 1031 | 1030 | $GLOBALS['egw_info']['server']['block_time'] * 60);  | 
                                                        
| 1032 | 1031 | }  | 
                                                        
| 1033 | 1032 | }  | 
                                                        
@@ -1037,20 +1036,20 @@ discard block  | 
                                                    ||
| 1037 | 1036 |  			{ | 
                                                        
| 1038 | 1037 | $sessionid = $this->sessionid_access_log;  | 
                                                        
| 1039 | 1038 | }  | 
                                                        
| 1040 | - $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE,array(  | 
                                                        |
| 1039 | + $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE, array(  | 
                                                        |
| 1041 | 1040 | 'lo' => $now  | 
                                                        
| 1042 | - ),is_numeric($sessionid) ? array(  | 
                                                        |
| 1041 | + ), is_numeric($sessionid) ? array(  | 
                                                        |
| 1043 | 1042 | 'sessionid' => $sessionid,  | 
                                                        
| 1044 | 1043 | ) : array(  | 
                                                        
| 1045 | 1044 | 'session_php' => $sessionid,  | 
                                                        
| 1046 | - ),__LINE__,__FILE__);  | 
                                                        |
| 1045 | + ), __LINE__, __FILE__);  | 
                                                        |
| 1047 | 1046 | |
| 1048 | 1047 | // run maintenance only on logout, to not delay login  | 
                                                        
| 1049 | 1048 | if ($GLOBALS['egw_info']['server']['max_access_log_age'])  | 
                                                        
| 1050 | 1049 |  			{ | 
                                                        
| 1051 | 1050 | $max_age = $now - $GLOBALS['egw_info']['server']['max_access_log_age'] * 24 * 60 * 60;  | 
                                                        
| 1052 | 1051 | |
| 1053 | - $GLOBALS['egw']->db->delete(self::ACCESS_LOG_TABLE,"li < $max_age",__LINE__,__FILE__);  | 
                                                        |
| 1052 | + $GLOBALS['egw']->db->delete(self::ACCESS_LOG_TABLE, "li < $max_age", __LINE__, __FILE__);  | 
                                                        |
| 1054 | 1053 | }  | 
                                                        
| 1055 | 1054 | }  | 
                                                        
| 1056 | 1055 |  		//error_log(__METHOD__."('$sessionid', '$login', '$user_ip', $account_id) returning ".array2string($ret)); | 
                                                        
@@ -1064,12 +1063,12 @@ discard block  | 
                                                    ||
| 1064 | 1063 | * @param string $ip ip of the user  | 
                                                        
| 1065 | 1064 | * @returns bool login blocked?  | 
                                                        
| 1066 | 1065 | */  | 
                                                        
| 1067 | - private function login_blocked($login,$ip)  | 
                                                        |
| 1066 | + private function login_blocked($login, $ip)  | 
                                                        |
| 1068 | 1067 |  	{ | 
                                                        
| 1069 | 1068 | $block_time = time() - $GLOBALS['egw_info']['server']['block_time'] * 60;  | 
                                                        
| 1070 | 1069 | |
| 1071 | 1070 | $false_id = $false_ip = 0;  | 
                                                        
| 1072 | - foreach($GLOBALS['egw']->db->union(array(  | 
                                                        |
| 1071 | + foreach ($GLOBALS['egw']->db->union(array(  | 
                                                        |
| 1073 | 1072 | array(  | 
                                                        
| 1074 | 1073 | 'table' => self::ACCESS_LOG_TABLE,  | 
                                                        
| 1075 | 1074 | 'cols' => "'false_ip' AS name,COUNT(*) AS num",  | 
                                                        
@@ -1112,7 +1111,7 @@ discard block  | 
                                                    ||
| 1112 | 1111 | if (!empty($GLOBALS['egw_info']['server']['unsuccessful_ip_whitelist']) &&  | 
                                                        
| 1113 | 1112 |  			preg_match_all('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d+)?/', | 
                                                        
| 1114 | 1113 | $GLOBALS['egw_info']['server']['unsuccessful_ip_whitelist'], $matches) &&  | 
                                                        
| 1115 | - ($key=array_search($ip, $matches[1])) !== false)  | 
                                                        |
| 1114 | + ($key = array_search($ip, $matches[1])) !== false)  | 
                                                        |
| 1116 | 1115 |  		{ | 
                                                        
| 1117 | 1116 | $blocked = !empty($matches[3][$key]) && $false_ip > $matches[3][$key];  | 
                                                        
| 1118 | 1117 | }  | 
                                                        
@@ -1127,28 +1126,28 @@ discard block  | 
                                                    ||
| 1127 | 1126 |  		//error_log(__METHOD__."('$login', '$ip') false_ip=$false_ip, false_id=$false_id --> blocked=".array2string($blocked)); | 
                                                        
| 1128 | 1127 | |
| 1129 | 1128 | if ($blocked && $GLOBALS['egw_info']['server']['admin_mails'] &&  | 
                                                        
| 1130 | - $GLOBALS['egw_info']['server']['login_blocked_mail_time'] < time()-5*60) // max. one mail every 5mins  | 
                                                        |
| 1129 | + $GLOBALS['egw_info']['server']['login_blocked_mail_time'] < time() - 5 * 60) // max. one mail every 5mins  | 
                                                        |
| 1131 | 1130 |  		{ | 
                                                        
| 1132 | 1131 |  			try { | 
                                                        
| 1133 | 1132 | $mailer = new Mailer();  | 
                                                        
| 1134 | 1133 | // notify admin(s) via email  | 
                                                        
| 1135 | 1134 |  				$mailer->setFrom('eGroupWare@'.$GLOBALS['egw_info']['server']['mail_suffix']); | 
                                                        
| 1136 | -				$mailer->addHeader('Subject', lang("eGroupWare: login blocked for user '%1', IP %2",$login,$ip)); | 
                                                        |
| 1137 | -				$mailer->setBody(lang("Too many unsucessful attempts to login: %1 for the user '%2', %3 for the IP %4",$false_id,$login,$false_ip,$ip)); | 
                                                        |
| 1138 | -				foreach(preg_split('/,\s*/',$GLOBALS['egw_info']['server']['admin_mails']) as $mail) | 
                                                        |
| 1135 | +				$mailer->addHeader('Subject', lang("eGroupWare: login blocked for user '%1', IP %2", $login, $ip)); | 
                                                        |
| 1136 | +				$mailer->setBody(lang("Too many unsucessful attempts to login: %1 for the user '%2', %3 for the IP %4", $false_id, $login, $false_ip, $ip)); | 
                                                        |
| 1137 | +				foreach (preg_split('/,\s*/', $GLOBALS['egw_info']['server']['admin_mails']) as $mail) | 
                                                        |
| 1139 | 1138 |  				{ | 
                                                        
| 1140 | 1139 | $mailer->addAddress($mail);  | 
                                                        
| 1141 | 1140 | }  | 
                                                        
| 1142 | 1141 | $mailer->send();  | 
                                                        
| 1143 | 1142 | }  | 
                                                        
| 1144 | -			catch(\Exception $e) { | 
                                                        |
| 1143 | +			catch (\Exception $e) { | 
                                                        |
| 1145 | 1144 | // ignore exception, but log it, to block the account and give a correct error-message to user  | 
                                                        
| 1146 | 1145 |  				error_log(__METHOD__."('$login', '$ip') ".$e->getMessage()); | 
                                                        
| 1147 | 1146 | }  | 
                                                        
| 1148 | 1147 | // save time of mail, to not send to many mails  | 
                                                        
| 1149 | 1148 |  			$config = new Config('phpgwapi'); | 
                                                        
| 1150 | 1149 | $config->read_repository();  | 
                                                        
| 1151 | -			$config->value('login_blocked_mail_time',time()); | 
                                                        |
| 1150 | +			$config->value('login_blocked_mail_time', time()); | 
                                                        |
| 1152 | 1151 | $config->save_repository();  | 
                                                        
| 1153 | 1152 | }  | 
                                                        
| 1154 | 1153 | return $blocked;  | 
                                                        
@@ -1169,7 +1168,7 @@ discard block  | 
                                                    ||
| 1169 | 1168 | * @param boolean $only_basic_auth =false return only a basic auth pseudo sessionid, default no  | 
                                                        
| 1170 | 1169 | * @return string|null (pseudo-)session-id use or NULL if no Cookie or Basic-Auth credentials  | 
                                                        
| 1171 | 1170 | */  | 
                                                        
| 1172 | - static function get_sessionid($only_basic_auth=false)  | 
                                                        |
| 1171 | + static function get_sessionid($only_basic_auth = false)  | 
                                                        |
| 1173 | 1172 |  	{ | 
                                                        
| 1174 | 1173 | // for WebDAV and GroupDAV we use a pseudo sessionid created from md5(user:passwd)  | 
                                                        
| 1175 | 1174 | // --> allows this stateless protocolls which use basic auth to use sessions!  | 
                                                        
@@ -1196,11 +1195,11 @@ discard block  | 
                                                    ||
| 1196 | 1195 | EGW_SERVER_ROOT.':'.self::getuser_ip().':'.filemtime(EGW_SERVER_ROOT.'/api/setup/setup.inc.php').  | 
                                                        
| 1197 | 1196 | ':'.$_SERVER['HTTP_USER_AGENT']);  | 
                                                        
| 1198 | 1197 | }  | 
                                                        
| 1199 | - elseif(!$only_basic_auth && isset($_REQUEST[self::EGW_SESSION_NAME]))  | 
                                                        |
| 1198 | + elseif (!$only_basic_auth && isset($_REQUEST[self::EGW_SESSION_NAME]))  | 
                                                        |
| 1200 | 1199 |  		{ | 
                                                        
| 1201 | 1200 | $sessionid = $_REQUEST[self::EGW_SESSION_NAME];  | 
                                                        
| 1202 | 1201 | }  | 
                                                        
| 1203 | - elseif(!$only_basic_auth && isset($_COOKIE[self::EGW_SESSION_NAME]))  | 
                                                        |
| 1202 | + elseif (!$only_basic_auth && isset($_COOKIE[self::EGW_SESSION_NAME]))  | 
                                                        |
| 1204 | 1203 |  		{ | 
                                                        
| 1205 | 1204 | $sessionid = $_COOKIE[self::EGW_SESSION_NAME];  | 
                                                        
| 1206 | 1205 | }  | 
                                                        
@@ -1208,7 +1207,7 @@ discard block  | 
                                                    ||
| 1208 | 1207 |  		{ | 
                                                        
| 1209 | 1208 | $sessionid = null;  | 
                                                        
| 1210 | 1209 | }  | 
                                                        
| 1211 | - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid,true));  | 
                                                        |
| 1210 | + if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid, true));  | 
                                                        |
| 1212 | 1211 | return $sessionid;  | 
                                                        
| 1213 | 1212 | }  | 
                                                        
| 1214 | 1213 | |
@@ -1224,9 +1223,7 @@ discard block  | 
                                                    ||
| 1224 | 1223 | */  | 
                                                        
| 1225 | 1224 | static function get_request($name)  | 
                                                        
| 1226 | 1225 |  	{ | 
                                                        
| 1227 | - return isset($_REQUEST[$name]) ? $_REQUEST[$name] :  | 
                                                        |
| 1228 | - (isset($_COOKIE[$name]) ? $_COOKIE[$name] :  | 
                                                        |
| 1229 | - (isset($_COOKIE[$name=ucfirst($name)]) ? $_COOKIE[$name] : null));  | 
                                                        |
| 1226 | + return isset($_REQUEST[$name]) ? $_REQUEST[$name] : (isset($_COOKIE[$name]) ? $_COOKIE[$name] : (isset($_COOKIE[$name = ucfirst($name)]) ? $_COOKIE[$name] : null));  | 
                                                        |
| 1230 | 1227 | }  | 
                                                        
| 1231 | 1228 | |
| 1232 | 1229 | /**  | 
                                                        
@@ -1236,13 +1233,13 @@ discard block  | 
                                                    ||
| 1236 | 1233 | * @param string $kp3 ?? to be verified  | 
                                                        
| 1237 | 1234 | * @return bool is the session valid?  | 
                                                        
| 1238 | 1235 | */  | 
                                                        
| 1239 | - function verify($sessionid=null,$kp3=null)  | 
                                                        |
| 1236 | + function verify($sessionid = null, $kp3 = null)  | 
                                                        |
| 1240 | 1237 |  	{ | 
                                                        
| 1241 | 1238 |  		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid','$kp3') ".function_backtrace()); | 
                                                        
| 1242 | 1239 | |
| 1243 | 1240 | $fill_egw_info_and_repositories = !$GLOBALS['egw_info']['flags']['restored_from_session'];  | 
                                                        
| 1244 | 1241 | |
| 1245 | - if(!$sessionid)  | 
                                                        |
| 1242 | + if (!$sessionid)  | 
                                                        |
| 1246 | 1243 |  		{ | 
                                                        
| 1247 | 1244 | $sessionid = self::get_sessionid();  | 
                                                        
| 1248 | 1245 |  			$kp3       = self::get_request('kp3'); | 
                                                        
@@ -1278,23 +1275,23 @@ discard block  | 
                                                    ||
| 1278 | 1275 |  			if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') session does NOT exist!"); | 
                                                        
| 1279 | 1276 | return false;  | 
                                                        
| 1280 | 1277 | }  | 
                                                        
| 1281 | - $session =& $_SESSION[self::EGW_SESSION_VAR];  | 
                                                        |
| 1278 | + $session = & $_SESSION[self::EGW_SESSION_VAR];  | 
                                                        |
| 1282 | 1279 | |
| 1283 | 1280 | if ($session['session_dla'] <= time() - $GLOBALS['egw_info']['server']['sessions_timeout'])  | 
                                                        
| 1284 | 1281 |  		{ | 
                                                        
| 1285 | 1282 |  			if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') session timed out!"); | 
                                                        
| 1286 | - $this->destroy($sessionid,$kp3);  | 
                                                        |
| 1283 | + $this->destroy($sessionid, $kp3);  | 
                                                        |
| 1287 | 1284 | return false;  | 
                                                        
| 1288 | 1285 | }  | 
                                                        
| 1289 | 1286 | |
| 1290 | 1287 | $this->session_flags = $session['session_flags'];  | 
                                                        
| 1291 | 1288 | |
| 1292 | - $this->split_login_domain($session['session_lid'],$this->account_lid,$this->account_domain);  | 
                                                        |
| 1289 | + $this->split_login_domain($session['session_lid'], $this->account_lid, $this->account_domain);  | 
                                                        |
| 1293 | 1290 | |
| 1294 | 1291 | // This is to ensure that we authenticate to the correct domain (might not be default)  | 
                                                        
| 1295 | - if($GLOBALS['egw_info']['user']['domain'] && $this->account_domain != $GLOBALS['egw_info']['user']['domain'])  | 
                                                        |
| 1292 | + if ($GLOBALS['egw_info']['user']['domain'] && $this->account_domain != $GLOBALS['egw_info']['user']['domain'])  | 
                                                        |
| 1296 | 1293 |  		{ | 
                                                        
| 1297 | - return false; // session not verified, domain changed  | 
                                                        |
| 1294 | + return false; // session not verified, domain changed  | 
                                                        |
| 1298 | 1295 | }  | 
                                                        
| 1299 | 1296 | $GLOBALS['egw_info']['user']['kp3'] = $this->kp3;  | 
                                                        
| 1300 | 1297 | |
@@ -1307,7 +1304,7 @@ discard block  | 
                                                    ||
| 1307 | 1304 |  		{ | 
                                                        
| 1308 | 1305 | $this->update_notification_heartbeat();  | 
                                                        
| 1309 | 1306 | }  | 
                                                        
| 1310 | - $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid,'account_lid','u');  | 
                                                        |
| 1307 | + $this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid, 'account_lid', 'u');  | 
                                                        |
| 1311 | 1308 | if (!$this->account_id)  | 
                                                        
| 1312 | 1309 |  		{ | 
                                                        
| 1313 | 1310 |  			if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) !accounts::name2id('$this->account_lid')"); | 
                                                        
@@ -1354,7 +1351,7 @@ discard block  | 
                                                    ||
| 1354 | 1351 | |
| 1355 | 1352 | if ($GLOBALS['egw_info']['server']['sessions_checkip'])  | 
                                                        
| 1356 | 1353 |  		{ | 
                                                        
| 1357 | - if (strtoupper(substr(PHP_OS,0,3)) != 'WIN' && (!$GLOBALS['egw_info']['user']['session_ip'] ||  | 
                                                        |
| 1354 | + if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN' && (!$GLOBALS['egw_info']['user']['session_ip'] ||  | 
                                                        |
| 1358 | 1355 | $GLOBALS['egw_info']['user']['session_ip'] != $this->getuser_ip()))  | 
                                                        
| 1359 | 1356 |  			{ | 
                                                        
| 1360 | 1357 |  				if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) wrong IP"); | 
                                                        
@@ -1377,9 +1374,9 @@ discard block  | 
                                                    ||
| 1377 | 1374 | // query accesslog-id, if not set in session (session is made persistent after login!)  | 
                                                        
| 1378 | 1375 | if (!$this->sessionid_access_log && $this->session_flags != 'A')  | 
                                                        
| 1379 | 1376 |  		{ | 
                                                        
| 1380 | - $this->sessionid_access_log = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE,'sessionid',array(  | 
                                                        |
| 1377 | + $this->sessionid_access_log = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE, 'sessionid', array(  | 
                                                        |
| 1381 | 1378 | 'session_php' => $this->sessionid,  | 
                                                        
| 1382 | - ),__LINE__,__FILE__)->fetchColumn();  | 
                                                        |
| 1379 | + ), __LINE__, __FILE__)->fetchColumn();  | 
                                                        |
| 1383 | 1380 | //error_log(__METHOD__."() sessionid=$this->sessionid --> sessionid_access_log=$this->sessionid_access_log");  | 
                                                        
| 1384 | 1381 | }  | 
                                                        
| 1385 | 1382 | |
@@ -1390,9 +1387,9 @@ discard block  | 
                                                    ||
| 1390 | 1387 | (!isset($_COOKIE[self::EGW_SESSION_NAME]) || $_COOKIE[self::EGW_SESSION_NAME] !== $_REQUEST[self::EGW_SESSION_NAME]))  | 
                                                        
| 1391 | 1388 |  		{ | 
                                                        
| 1392 | 1389 |  			if (self::ERROR_LOG_DEBUG) error_log("--> Session::verify($sessionid) SUCCESS, but NO required cookies set --> setting them now"); | 
                                                        
| 1393 | - self::egw_setcookie(self::EGW_SESSION_NAME,$this->sessionid);  | 
                                                        |
| 1394 | -			self::egw_setcookie('kp3',$this->kp3); | 
                                                        |
| 1395 | -			self::egw_setcookie('domain',$this->account_domain); | 
                                                        |
| 1390 | + self::egw_setcookie(self::EGW_SESSION_NAME, $this->sessionid);  | 
                                                        |
| 1391 | +			self::egw_setcookie('kp3', $this->kp3); | 
                                                        |
| 1392 | +			self::egw_setcookie('domain', $this->account_domain); | 
                                                        |
| 1396 | 1393 | }  | 
                                                        
| 1397 | 1394 | |
| 1398 | 1395 |  		if (self::ERROR_LOG_DEBUG) error_log("--> Session::verify($sessionid) SUCCESS"); | 
                                                        
@@ -1407,27 +1404,27 @@ discard block  | 
                                                    ||
| 1407 | 1404 | * @param string $kp3  | 
                                                        
| 1408 | 1405 | * @return boolean true on success, false on error  | 
                                                        
| 1409 | 1406 | */  | 
                                                        
| 1410 | - function destroy($sessionid, $kp3='')  | 
                                                        |
| 1407 | + function destroy($sessionid, $kp3 = '')  | 
                                                        |
| 1411 | 1408 |  	{ | 
                                                        
| 1412 | 1409 | if (!$sessionid && $kp3)  | 
                                                        
| 1413 | 1410 |  		{ | 
                                                        
| 1414 | 1411 | return false;  | 
                                                        
| 1415 | 1412 | }  | 
                                                        
| 1416 | - $this->log_access($sessionid); // log logout-time  | 
                                                        |
| 1413 | + $this->log_access($sessionid); // log logout-time  | 
                                                        |
| 1417 | 1414 | |
| 1418 | 1415 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($sessionid,$kp3)");  | 
                                                        
| 1419 | 1416 | |
| 1420 | 1417 | if (is_numeric($sessionid)) // do we have a access-log-id --> get PHP session id  | 
                                                        
| 1421 | 1418 |  		{ | 
                                                        
| 1422 | - $sessionid = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE,'session_php',array(  | 
                                                        |
| 1419 | + $sessionid = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE, 'session_php', array(  | 
                                                        |
| 1423 | 1420 | 'sessionid' => $sessionid,  | 
                                                        
| 1424 | - ),__LINE__,__FILE__)->fetchColumn();  | 
                                                        |
| 1421 | + ), __LINE__, __FILE__)->fetchColumn();  | 
                                                        |
| 1425 | 1422 | }  | 
                                                        
| 1426 | 1423 | |
| 1427 | 1424 | Hooks::process(array(  | 
                                                        
| 1428 | 1425 | 'location' => 'session_destroyed',  | 
                                                        
| 1429 | 1426 | 'sessionid' => $sessionid,  | 
                                                        
| 1430 | - ),'',true); // true = run hooks from all apps, not just the ones the current user has perms to run  | 
                                                        |
| 1427 | + ), '', true); // true = run hooks from all apps, not just the ones the current user has perms to run  | 
                                                        |
| 1431 | 1428 | |
| 1432 | 1429 | // Only do the following, if where working with the current user  | 
                                                        
| 1433 | 1430 | if (!$GLOBALS['egw_info']['user']['sessionid'] || $sessionid == $GLOBALS['egw_info']['user']['sessionid'])  | 
                                                        
@@ -1448,7 +1445,7 @@ discard block  | 
                                                    ||
| 1448 | 1445 | }  | 
                                                        
| 1449 | 1446 | else  | 
                                                        
| 1450 | 1447 |  		{ | 
                                                        
| 1451 | - $this->commit_session(); // close our own session  | 
                                                        |
| 1448 | + $this->commit_session(); // close our own session  | 
                                                        |
| 1452 | 1449 | |
| 1453 | 1450 | session_id($sessionid);  | 
                                                        
| 1454 | 1451 | if (session_start())  | 
                                                        
@@ -1488,25 +1485,25 @@ discard block  | 
                                                    ||
| 1488 | 1485 | // as $webserver_url may be part of $url (as /egw is part of phpgwapi/js/egw_instant_load.html)  | 
                                                        
| 1489 | 1486 | if (($url[0] != '/' || $webserver_url != '/') && (!$webserver_url || strpos($url, $webserver_url.'/') === false))  | 
                                                        
| 1490 | 1487 |  		{ | 
                                                        
| 1491 | - if($url[0] != '/' && substr($webserver_url,-1) != '/')  | 
                                                        |
| 1488 | + if ($url[0] != '/' && substr($webserver_url, -1) != '/')  | 
                                                        |
| 1492 | 1489 |  			{ | 
                                                        
| 1493 | - $url = $webserver_url .'/'. $url;  | 
                                                        |
| 1490 | + $url = $webserver_url.'/'.$url;  | 
                                                        |
| 1494 | 1491 | }  | 
                                                        
| 1495 | 1492 | else  | 
                                                        
| 1496 | 1493 |  			{ | 
                                                        
| 1497 | - $url = $webserver_url . $url;  | 
                                                        |
| 1494 | + $url = $webserver_url.$url;  | 
                                                        |
| 1498 | 1495 | }  | 
                                                        
| 1499 | 1496 | }  | 
                                                        
| 1500 | 1497 | |
| 1501 | - if(isset($GLOBALS['egw_info']['server']['enforce_ssl']) && $GLOBALS['egw_info']['server']['enforce_ssl'])  | 
                                                        |
| 1498 | + if (isset($GLOBALS['egw_info']['server']['enforce_ssl']) && $GLOBALS['egw_info']['server']['enforce_ssl'])  | 
                                                        |
| 1502 | 1499 |  		{ | 
                                                        
| 1503 | - if(substr($url ,0,4) != 'http')  | 
                                                        |
| 1500 | + if (substr($url, 0, 4) != 'http')  | 
                                                        |
| 1504 | 1501 |  			{ | 
                                                        
| 1505 | 1502 | $url = 'https://'.$_SERVER['HTTP_HOST'].$url;  | 
                                                        
| 1506 | 1503 | }  | 
                                                        
| 1507 | 1504 | else  | 
                                                        
| 1508 | 1505 |  			{ | 
                                                        
| 1509 | - $url = str_replace ( 'http:', 'https:', $url);  | 
                                                        |
| 1506 | +				$url = str_replace('http:', 'https:', $url); | 
                                                        |
| 1510 | 1507 | }  | 
                                                        
| 1511 | 1508 | }  | 
                                                        
| 1512 | 1509 | $vars = array();  | 
                                                        
@@ -1519,7 +1516,7 @@ discard block  | 
                                                    ||
| 1519 | 1516 | }  | 
                                                        
| 1520 | 1517 | |
| 1521 | 1518 | // check if the url already contains a query and ensure that vars is an array and all strings are in extravars  | 
                                                        
| 1522 | -		list($ret_url,$othervars) = explode('?', $url, 2); | 
                                                        |
| 1519 | +		list($ret_url, $othervars) = explode('?', $url, 2); | 
                                                        |
| 1523 | 1520 | if ($extravars && is_array($extravars))  | 
                                                        
| 1524 | 1521 |  		{ | 
                                                        
| 1525 | 1522 | $vars += $extravars;  | 
                                                        
@@ -1527,19 +1524,19 @@ discard block  | 
                                                    ||
| 1527 | 1524 | }  | 
                                                        
| 1528 | 1525 | else  | 
                                                        
| 1529 | 1526 |  		{ | 
                                                        
| 1530 | - if ($othervars) $extravars .= ($extravars?'&':'').$othervars;  | 
                                                        |
| 1527 | + if ($othervars) $extravars .= ($extravars ? '&' : '').$othervars;  | 
                                                        |
| 1531 | 1528 | }  | 
                                                        
| 1532 | 1529 | |
| 1533 | 1530 | // parse extravars string into the vars array  | 
                                                        
| 1534 | 1531 | if ($extravars)  | 
                                                        
| 1535 | 1532 |  		{ | 
                                                        
| 1536 | -			foreach(explode('&',$extravars) as $expr) | 
                                                        |
| 1533 | +			foreach (explode('&', $extravars) as $expr) | 
                                                        |
| 1537 | 1534 |  			{ | 
                                                        
| 1538 | -				list($var,$val) = explode('=', $expr,2); | 
                                                        |
| 1539 | -				if (strpos($val,'%26') != false) $val = str_replace('%26','&',$val);	// make sure to not double encode & | 
                                                        |
| 1540 | - if (substr($var,-2) == '[]')  | 
                                                        |
| 1535 | +				list($var, $val) = explode('=', $expr, 2); | 
                                                        |
| 1536 | +				if (strpos($val, '%26') != false) $val = str_replace('%26', '&', $val); // make sure to not double encode & | 
                                                        |
| 1537 | + if (substr($var, -2) == '[]')  | 
                                                        |
| 1541 | 1538 |  				{ | 
                                                        
| 1542 | - $vars[substr($var,0,-2)][] = $val;  | 
                                                        |
| 1539 | + $vars[substr($var, 0, -2)][] = $val;  | 
                                                        |
| 1543 | 1540 | }  | 
                                                        
| 1544 | 1541 | else  | 
                                                        
| 1545 | 1542 |  				{ | 
                                                        
@@ -1552,11 +1549,11 @@ discard block  | 
                                                    ||
| 1552 | 1549 | if (count($vars))  | 
                                                        
| 1553 | 1550 |  		{ | 
                                                        
| 1554 | 1551 | $query = array();  | 
                                                        
| 1555 | - foreach($vars as $key => $value)  | 
                                                        |
| 1552 | + foreach ($vars as $key => $value)  | 
                                                        |
| 1556 | 1553 |  			{ | 
                                                        
| 1557 | 1554 | if (is_array($value))  | 
                                                        
| 1558 | 1555 |  				{ | 
                                                        
| 1559 | - foreach($value as $val)  | 
                                                        |
| 1556 | + foreach ($value as $val)  | 
                                                        |
| 1560 | 1557 |  					{ | 
                                                        
| 1561 | 1558 | $query[] = $key.'[]='.urlencode($val);  | 
                                                        
| 1562 | 1559 | }  | 
                                                        
@@ -1566,7 +1563,7 @@ discard block  | 
                                                    ||
| 1566 | 1563 | $query[] = $key.'='.urlencode($value);  | 
                                                        
| 1567 | 1564 | }  | 
                                                        
| 1568 | 1565 | }  | 
                                                        
| 1569 | -			$ret_url .= '?' . implode('&',$query); | 
                                                        |
| 1566 | +			$ret_url .= '?'.implode('&', $query); | 
                                                        |
| 1570 | 1567 | }  | 
                                                        
| 1571 | 1568 | return $ret_url;  | 
                                                        
| 1572 | 1569 | }  | 
                                                        
@@ -1627,7 +1624,7 @@ discard block  | 
                                                    ||
| 1627 | 1624 | * @param int $cookietime =0 when cookie should expire, 0 for session only (optional)  | 
                                                        
| 1628 | 1625 | * @param string $cookiepath =null optional path (eg. '/') if the eGW install-dir should not be used  | 
                                                        
| 1629 | 1626 | */  | 
                                                        
| 1630 | - public static function egw_setcookie($cookiename,$cookievalue='',$cookietime=0,$cookiepath=null)  | 
                                                        |
| 1627 | + public static function egw_setcookie($cookiename, $cookievalue = '', $cookietime = 0, $cookiepath = null)  | 
                                                        |
| 1631 | 1628 |  	{ | 
                                                        
| 1632 | 1629 | if (empty(self::$cookie_domain) || empty(self::$cookie_path))  | 
                                                        
| 1633 | 1630 |  		{ | 
                                                        
@@ -1640,11 +1637,11 @@ discard block  | 
                                                    ||
| 1640 | 1637 | static $is_iOS = null;  | 
                                                        
| 1641 | 1638 |  		if (!$cookietime && !isset($is_iOS)) $is_iOS = (bool)preg_match('/^(iPhone|iPad|iPod)/i', Header\UserAgent::mobile()); | 
                                                        
| 1642 | 1639 | |
| 1643 | - if(!headers_sent()) // gives only a warning, but can not send the cookie anyway  | 
                                                        |
| 1640 | + if (!headers_sent()) // gives only a warning, but can not send the cookie anyway  | 
                                                        |
| 1644 | 1641 |  		{ | 
                                                        
| 1645 | 1642 | setcookie($cookiename, $cookievalue,  | 
                                                        
| 1646 | - !$cookietime && $is_iOS ? time()+self::IOS_SESSION_COOKIE_LIFETIME : $cookietime,  | 
                                                        |
| 1647 | - is_null($cookiepath) ? self::$cookie_path : $cookiepath,self::$cookie_domain,  | 
                                                        |
| 1643 | + !$cookietime && $is_iOS ? time() + self::IOS_SESSION_COOKIE_LIFETIME : $cookietime,  | 
                                                        |
| 1644 | + is_null($cookiepath) ? self::$cookie_path : $cookiepath, self::$cookie_domain,  | 
                                                        |
| 1648 | 1645 | // if called via HTTPS, only send cookie for https and only allow cookie access via HTTP (true)  | 
                                                        
| 1649 | 1646 | empty($GLOBALS['egw_info']['server']['insecure_cookies']) && Header\Http::schema() === 'https', true);  | 
                                                        
| 1650 | 1647 | }  | 
                                                        
@@ -1667,17 +1664,17 @@ discard block  | 
                                                    ||
| 1667 | 1664 | }  | 
                                                        
| 1668 | 1665 | // remove port from HTTP_HOST  | 
                                                        
| 1669 | 1666 | $arr = null;  | 
                                                        
| 1670 | -		if (preg_match("/^(.*):(.*)$/",self::$cookie_domain,$arr)) | 
                                                        |
| 1667 | +		if (preg_match("/^(.*):(.*)$/", self::$cookie_domain, $arr)) | 
                                                        |
| 1671 | 1668 |  		{ | 
                                                        
| 1672 | 1669 | self::$cookie_domain = $arr[1];  | 
                                                        
| 1673 | 1670 | }  | 
                                                        
| 1674 | -		if (count(explode('.',self::$cookie_domain)) <= 1) | 
                                                        |
| 1671 | +		if (count(explode('.', self::$cookie_domain)) <= 1) | 
                                                        |
| 1675 | 1672 |  		{ | 
                                                        
| 1676 | 1673 | // setcookie dont likes domains without dots, leaving it empty, gets setcookie to fill the domain in  | 
                                                        
| 1677 | 1674 | self::$cookie_domain = '';  | 
                                                        
| 1678 | 1675 | }  | 
                                                        
| 1679 | 1676 | if (!$GLOBALS['egw_info']['server']['cookiepath'] ||  | 
                                                        
| 1680 | - !(self::$cookie_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH)))  | 
                                                        |
| 1677 | + !(self::$cookie_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH)))  | 
                                                        |
| 1681 | 1678 |  		{ | 
                                                        
| 1682 | 1679 | self::$cookie_path = '/';  | 
                                                        
| 1683 | 1680 | }  | 
                                                        
@@ -1697,7 +1694,7 @@ discard block  | 
                                                    ||
| 1697 | 1694 | * @param array $domains =null defaults to $GLOBALS['egw_domain'] from the header  | 
                                                        
| 1698 | 1695 | * @return string $GLOBALS['egw_info']['user']['domain'] set with the domain/instance to use  | 
                                                        
| 1699 | 1696 | */  | 
                                                        
| 1700 | - public static function search_instance($login,$domain_requested,&$default_domain,$server_names,array $domains=null)  | 
                                                        |
| 1697 | + public static function search_instance($login, $domain_requested, &$default_domain, $server_names, array $domains = null)  | 
                                                        |
| 1701 | 1698 |  	{ | 
                                                        
| 1702 | 1699 |  		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$login','$domain_requested',".array2string($default_domain).".".array2string($server_names).".".array2string($domains).")"); | 
                                                        
| 1703 | 1700 | |
@@ -1705,10 +1702,10 @@ discard block  | 
                                                    ||
| 1705 | 1702 | |
| 1706 | 1703 | if (!isset($default_domain) || !isset($domains[$default_domain])) // allow to overwrite the default domain  | 
                                                        
| 1707 | 1704 |  		{ | 
                                                        
| 1708 | - foreach((array)$server_names as $server_name)  | 
                                                        |
| 1705 | + foreach ((array)$server_names as $server_name)  | 
                                                        |
| 1709 | 1706 |  			{ | 
                                                        
| 1710 | -				list($server_name) = explode(':', $server_name);	// remove port from HTTP_HOST | 
                                                        |
| 1711 | - if(isset($domains[$server_name]))  | 
                                                        |
| 1707 | +				list($server_name) = explode(':', $server_name); // remove port from HTTP_HOST | 
                                                        |
| 1708 | + if (isset($domains[$server_name]))  | 
                                                        |
| 1712 | 1709 |  				{ | 
                                                        
| 1713 | 1710 | $default_domain = $server_name;  | 
                                                        
| 1714 | 1711 | break;  | 
                                                        
@@ -1718,7 +1715,7 @@ discard block  | 
                                                    ||
| 1718 | 1715 |  					$parts = explode('.', $server_name); | 
                                                        
| 1719 | 1716 | array_shift($parts);  | 
                                                        
| 1720 | 1717 |  					$domain_part = implode('.', $parts); | 
                                                        
| 1721 | - if(isset($domains[$domain_part]))  | 
                                                        |
| 1718 | + if (isset($domains[$domain_part]))  | 
                                                        |
| 1722 | 1719 |  					{ | 
                                                        
| 1723 | 1720 | $default_domain = $domain_part;  | 
                                                        
| 1724 | 1721 | break;  | 
                                                        
@@ -1734,11 +1731,11 @@ discard block  | 
                                                    ||
| 1734 | 1731 | }  | 
                                                        
| 1735 | 1732 | if (isset($login)) // on login  | 
                                                        
| 1736 | 1733 |  		{ | 
                                                        
| 1737 | - if (strpos($login,'@') === false || count($domains) == 1)  | 
                                                        |
| 1734 | + if (strpos($login, '@') === false || count($domains) == 1)  | 
                                                        |
| 1738 | 1735 |  			{ | 
                                                        
| 1739 | - $login .= '@' . (isset($_POST['logindomain']) ? $_POST['logindomain'] : $default_domain);  | 
                                                        |
| 1736 | + $login .= '@'.(isset($_POST['logindomain']) ? $_POST['logindomain'] : $default_domain);  | 
                                                        |
| 1740 | 1737 | }  | 
                                                        
| 1741 | -			$parts = explode('@',$login); | 
                                                        |
| 1738 | +			$parts = explode('@', $login); | 
                                                        |
| 1742 | 1739 | $domain = array_pop($parts);  | 
                                                        
| 1743 | 1740 | $GLOBALS['login'] = $login;  | 
                                                        
| 1744 | 1741 | }  | 
                                                        
@@ -1782,7 +1779,7 @@ discard block  | 
                                                    ||
| 1782 | 1779 | * @param boolean $update_access_log =false false: dont update egw_access_log table, but set $this->action  | 
                                                        
| 1783 | 1780 | * @return string action as written to egw_access_log.session_action  | 
                                                        
| 1784 | 1781 | */  | 
                                                        
| 1785 | - private function update_dla($update_access_log=false)  | 
                                                        |
| 1782 | + private function update_dla($update_access_log = false)  | 
                                                        |
| 1786 | 1783 |  	{ | 
                                                        
| 1787 | 1784 | // This way XML-RPC users aren't always listed as xmlrpc.php  | 
                                                        
| 1788 | 1785 | if (isset($_GET['menuaction']))  | 
                                                        
@@ -1796,14 +1793,14 @@ discard block  | 
                                                    ||
| 1796 | 1793 | $action = $_SERVER['PHP_SELF'];  | 
                                                        
| 1797 | 1794 | // remove EGroupware path, if not installed in webroot  | 
                                                        
| 1798 | 1795 | $egw_path = $GLOBALS['egw_info']['server']['webserver_url'];  | 
                                                        
| 1799 | - if ($egw_path[0] != '/') $egw_path = parse_url($egw_path,PHP_URL_PATH);  | 
                                                        |
| 1796 | + if ($egw_path[0] != '/') $egw_path = parse_url($egw_path, PHP_URL_PATH);  | 
                                                        |
| 1800 | 1797 | if ($action == '/Microsoft-Server-ActiveSync')  | 
                                                        
| 1801 | 1798 |  			{ | 
                                                        
| 1802 | 1799 | $action .= '?Cmd='.$_GET['Cmd'].'&DeviceId='.$_GET['DeviceId'];  | 
                                                        
| 1803 | 1800 | }  | 
                                                        
| 1804 | 1801 | elseif ($egw_path)  | 
                                                        
| 1805 | 1802 |  			{ | 
                                                        
| 1806 | - list(,$action) = explode($egw_path,$action,2);  | 
                                                        |
| 1803 | + list(,$action) = explode($egw_path, $action, 2);  | 
                                                        |
| 1807 | 1804 | }  | 
                                                        
| 1808 | 1805 | }  | 
                                                        
| 1809 | 1806 | $this->set_action($action);  | 
                                                        
@@ -1817,14 +1814,14 @@ discard block  | 
                                                    ||
| 1817 | 1814 |  		{ | 
                                                        
| 1818 | 1815 | $_SESSION[self::EGW_SESSION_VAR]['session_logged_dla'] = time();  | 
                                                        
| 1819 | 1816 | |
| 1820 | - $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE,array(  | 
                                                        |
| 1817 | + $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE, array(  | 
                                                        |
| 1821 | 1818 | 'session_dla' => time(),  | 
                                                        
| 1822 | 1819 | 'session_action' => $this->action,  | 
                                                        
| 1823 | 1820 | ) + ($this->action === '/logout.php' ? array() : array(  | 
                                                        
| 1824 | - 'lo' => null, // just in case it was (automatic) timed out before  | 
                                                        |
| 1825 | - )),array(  | 
                                                        |
| 1821 | + 'lo' => null, // just in case it was (automatic) timed out before  | 
                                                        |
| 1822 | + )), array(  | 
                                                        |
| 1826 | 1823 | 'sessionid' => $this->sessionid_access_log,  | 
                                                        
| 1827 | - ),__LINE__,__FILE__);  | 
                                                        |
| 1824 | + ), __LINE__, __FILE__);  | 
                                                        |
| 1828 | 1825 | }  | 
                                                        
| 1829 | 1826 | |
| 1830 | 1827 | $_SESSION[self::EGW_SESSION_VAR]['session_dla'] = time();  | 
                                                        
@@ -1842,12 +1839,12 @@ discard block  | 
                                                    ||
| 1842 | 1839 | // update dla in access-log table, if we have an access-log row (non-anonymous session)  | 
                                                        
| 1843 | 1840 | if ($this->sessionid_access_log)  | 
                                                        
| 1844 | 1841 |  		{ | 
                                                        
| 1845 | - $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE,array(  | 
                                                        |
| 1842 | + $GLOBALS['egw']->db->update(self::ACCESS_LOG_TABLE, array(  | 
                                                        |
| 1846 | 1843 | 'notification_heartbeat' => time(),  | 
                                                        
| 1847 | - ),array(  | 
                                                        |
| 1844 | + ), array(  | 
                                                        |
| 1848 | 1845 | 'sessionid' => $this->sessionid_access_log,  | 
                                                        
| 1849 | 1846 | 'lo IS NULL',  | 
                                                        
| 1850 | - ),__LINE__,__FILE__);  | 
                                                        |
| 1847 | + ), __LINE__, __FILE__);  | 
                                                        |
| 1851 | 1848 | }  | 
                                                        
| 1852 | 1849 | }  | 
                                                        
| 1853 | 1850 | |
@@ -1868,7 +1865,7 @@ discard block  | 
                                                    ||
| 1868 | 1865 |  		{ | 
                                                        
| 1869 | 1866 | // authentication happens in login.php, which does NOT yet create egw-object in session  | 
                                                        
| 1870 | 1867 | // --> need to store homedirectory in session  | 
                                                        
| 1871 | - if(isset($GLOBALS['auto_create_acct']['homedirectory']))  | 
                                                        |
| 1868 | + if (isset($GLOBALS['auto_create_acct']['homedirectory']))  | 
                                                        |
| 1872 | 1869 |  			{ | 
                                                        
| 1873 | 1870 | Cache::setSession(__CLASS__, 'homedirectory',  | 
                                                        
| 1874 | 1871 | $user['homedirectory'] = $GLOBALS['auto_create_acct']['homedirectory']);  | 
                                                        
@@ -1881,7 +1878,7 @@ discard block  | 
                                                    ||
| 1881 | 1878 | $user['preferences'] = $GLOBALS['egw']->preferences->read_repository();  | 
                                                        
| 1882 | 1879 | if (is_object($GLOBALS['egw']->datetime))  | 
                                                        
| 1883 | 1880 |  		{ | 
                                                        
| 1884 | - $GLOBALS['egw']->datetime->__construct(); // to set tz_offset from the now read prefs  | 
                                                        |
| 1881 | + $GLOBALS['egw']->datetime->__construct(); // to set tz_offset from the now read prefs  | 
                                                        |
| 1885 | 1882 | }  | 
                                                        
| 1886 | 1883 | $user['apps'] = $GLOBALS['egw']->applications->read_repository();  | 
                                                        
| 1887 | 1884 | $user['domain'] = $this->account_domain;  | 
                                                        
@@ -1904,9 +1901,9 @@ discard block  | 
                                                    ||
| 1904 | 1901 | * @param string &$account_lid returned account_lid (ie. user)  | 
                                                        
| 1905 | 1902 | * @param string &$domain returned domain (ie. domain)  | 
                                                        
| 1906 | 1903 | */  | 
                                                        
| 1907 | - private function split_login_domain($login,&$account_lid,&$domain)  | 
                                                        |
| 1904 | + private function split_login_domain($login, &$account_lid, &$domain)  | 
                                                        |
| 1908 | 1905 |  	{ | 
                                                        
| 1909 | -		$parts = explode('@',$login); | 
                                                        |
| 1906 | +		$parts = explode('@', $login); | 
                                                        |
| 1910 | 1907 | |
| 1911 | 1908 | //conference - for strings like [email protected]@default ,  | 
                                                        
| 1912 | 1909 | //allows that user have a login that is his e-mail. (viniciuscb)  | 
                                                        
@@ -1914,11 +1911,11 @@ discard block  | 
                                                    ||
| 1914 | 1911 |  		{ | 
                                                        
| 1915 | 1912 | $probable_domain = array_pop($parts);  | 
                                                        
| 1916 | 1913 | //Last part of login string, when separated by @, is a domain name  | 
                                                        
| 1917 | - if (in_array($probable_domain,$this->egw_domains))  | 
                                                        |
| 1914 | + if (in_array($probable_domain, $this->egw_domains))  | 
                                                        |
| 1918 | 1915 |  			{ | 
                                                        
| 1919 | 1916 | $got_login = true;  | 
                                                        
| 1920 | 1917 | $domain = $probable_domain;  | 
                                                        
| 1921 | -				$account_lid = implode('@',$parts); | 
                                                        |
| 1918 | +				$account_lid = implode('@', $parts); | 
                                                        |
| 1922 | 1919 | }  | 
                                                        
| 1923 | 1920 | }  | 
                                                        
| 1924 | 1921 | |
@@ -1941,9 +1938,9 @@ discard block  | 
                                                    ||
| 1941 | 1938 | * @param boolean $allow_password_md5 =false can password alread be an md5 hash  | 
                                                        
| 1942 | 1939 | * @return string  | 
                                                        
| 1943 | 1940 | */  | 
                                                        
| 1944 | - static function user_pw_hash($user,$password,$allow_password_md5=false)  | 
                                                        |
| 1941 | + static function user_pw_hash($user, $password, $allow_password_md5 = false)  | 
                                                        |
| 1945 | 1942 |  	{ | 
                                                        
| 1946 | -		$password_md5 = $allow_password_md5 && preg_match('/^[a-f0-9]{32}$/',$password) ? $password : md5($password); | 
                                                        |
| 1943 | +		$password_md5 = $allow_password_md5 && preg_match('/^[a-f0-9]{32}$/', $password) ? $password : md5($password); | 
                                                        |
| 1947 | 1944 | |
| 1948 | 1945 | $hash = sha1(strtolower($user).$password_md5);  | 
                                                        
| 1949 | 1946 | |
@@ -1958,12 +1955,12 @@ discard block  | 
                                                    ||
| 1958 | 1955 | */  | 
                                                        
| 1959 | 1956 | public static function init_handler()  | 
                                                        
| 1960 | 1957 |  	{ | 
                                                        
| 1961 | - switch(session_status())  | 
                                                        |
| 1958 | + switch (session_status())  | 
                                                        |
| 1962 | 1959 |  		{ | 
                                                        
| 1963 | 1960 | case PHP_SESSION_DISABLED:  | 
                                                        
| 1964 | 1961 |  				throw new \ErrorException('EGroupware requires PHP session extension!'); | 
                                                        
| 1965 | 1962 | case PHP_SESSION_NONE:  | 
                                                        
| 1966 | -				ini_set('session.use_cookies',0);	// disable the automatic use of cookies, as it uses the path / by default | 
                                                        |
| 1963 | +				ini_set('session.use_cookies', 0); // disable the automatic use of cookies, as it uses the path / by default | 
                                                        |
| 1967 | 1964 | session_name(self::EGW_SESSION_NAME);  | 
                                                        
| 1968 | 1965 | if (($sessionid = self::get_sessionid()))  | 
                                                        
| 1969 | 1966 |  				{ | 
                                                        
@@ -1976,7 +1973,7 @@ discard block  | 
                                                    ||
| 1976 | 1973 | }  | 
                                                        
| 1977 | 1974 | break;  | 
                                                        
| 1978 | 1975 | case PHP_SESSION_ACTIVE:  | 
                                                        
| 1979 | - return true; // session created by MServer  | 
                                                        |
| 1976 | + return true; // session created by MServer  | 
                                                        |
| 1980 | 1977 | }  | 
                                                        
| 1981 | 1978 | if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() no active session!");  | 
                                                        
| 1982 | 1979 | |
@@ -1994,7 +1991,7 @@ discard block  | 
                                                    ||
| 1994 | 1991 | * @param int $expire =null expiration time in seconds, default $GLOBALS['egw_info']['flags']['nocachecontrol'] or php.ini session.cache_expire  | 
                                                        
| 1995 | 1992 | * @param int $private =null allows to set private caching with given expiration time, by setting it to true  | 
                                                        
| 1996 | 1993 | */  | 
                                                        
| 1997 | - public static function cache_control($expire=null, $private=null)  | 
                                                        |
| 1994 | + public static function cache_control($expire = null, $private = null)  | 
                                                        |
| 1998 | 1995 |  	{ | 
                                                        
| 1999 | 1996 | if (is_null($expire) && isset($GLOBALS['egw_info']['flags']['nocachecontrol']) && is_int($GLOBALS['egw_info']['flags']['nocachecontrol']))  | 
                                                        
| 2000 | 1997 |  		{ | 
                                                        
@@ -2004,7 +2001,7 @@ discard block  | 
                                                    ||
| 2004 | 2001 | if (!isset($_SESSION))  | 
                                                        
| 2005 | 2002 |  		{ | 
                                                        
| 2006 | 2003 | // controling caching and expires header  | 
                                                        
| 2007 | - if(!isset($expire) && (!isset($GLOBALS['egw_info']['flags']['nocachecontrol']) ||  | 
                                                        |
| 2004 | + if (!isset($expire) && (!isset($GLOBALS['egw_info']['flags']['nocachecontrol']) ||  | 
                                                        |
| 2008 | 2005 | !$GLOBALS['egw_info']['flags']['nocachecontrol']))  | 
                                                        
| 2009 | 2006 |  			{ | 
                                                        
| 2010 | 2007 |  				session_cache_limiter('nocache'); | 
                                                        
@@ -2014,7 +2011,7 @@ discard block  | 
                                                    ||
| 2014 | 2011 | // allow public caching: proxys, cdns, ...  | 
                                                        
| 2015 | 2012 | if (isset($expire))  | 
                                                        
| 2016 | 2013 |  				{ | 
                                                        
| 2017 | - session_cache_expire((int)ceil($expire/60)); // in minutes  | 
                                                        |
| 2014 | + session_cache_expire((int)ceil($expire / 60)); // in minutes  | 
                                                        |
| 2018 | 2015 | }  | 
                                                        
| 2019 | 2016 | session_cache_limiter($private ? 'private' : 'public');  | 
                                                        
| 2020 | 2017 | }  | 
                                                        
@@ -2027,8 +2024,8 @@ discard block  | 
                                                    ||
| 2027 | 2024 | // session already started  | 
                                                        
| 2028 | 2025 | if (isset($_SESSION))  | 
                                                        
| 2029 | 2026 |  		{ | 
                                                        
| 2030 | - if ($expire && (session_cache_limiter() !== ($expire===true?'private_no_expire':'public') ||  | 
                                                        |
| 2031 | - is_int($expire) && $expire/60 !== session_cache_expire()))  | 
                                                        |
| 2027 | + if ($expire && (session_cache_limiter() !== ($expire === true ? 'private_no_expire' : 'public') ||  | 
                                                        |
| 2028 | + is_int($expire) && $expire / 60 !== session_cache_expire()))  | 
                                                        |
| 2032 | 2029 |  			{ | 
                                                        
| 2033 | 2030 | $file = $line = null;  | 
                                                        
| 2034 | 2031 | if (headers_sent($file, $line))  | 
                                                        
@@ -2036,20 +2033,20 @@ discard block  | 
                                                    ||
| 2036 | 2033 | error_log(__METHOD__."($expire) called, but header already sent in $file: $line");  | 
                                                        
| 2037 | 2034 | return;  | 
                                                        
| 2038 | 2035 | }  | 
                                                        
| 2039 | -				if($expire === true)	// same behavior as session_cache_limiter('private_no_expire') | 
                                                        |
| 2036 | +				if ($expire === true)	// same behavior as session_cache_limiter('private_no_expire') | 
                                                        |
| 2040 | 2037 |  				{ | 
                                                        
| 2041 | -					header('Cache-Control: private, max-age='.(60*session_cache_expire())); | 
                                                        |
| 2038 | +					header('Cache-Control: private, max-age='.(60 * session_cache_expire())); | 
                                                        |
| 2042 | 2039 |  					header_remove('Expires'); | 
                                                        
| 2043 | 2040 | }  | 
                                                        
| 2044 | 2041 | elseif ($private)  | 
                                                        
| 2045 | 2042 |  				{ | 
                                                        
| 2046 | 2043 |  					header('Cache-Control: private, max-age='.$expire); | 
                                                        
| 2047 | -					header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expire) . ' GMT'); | 
                                                        |
| 2044 | +					header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expire).' GMT'); | 
                                                        |
| 2048 | 2045 | }  | 
                                                        
| 2049 | 2046 | else  | 
                                                        
| 2050 | 2047 |  				{ | 
                                                        
| 2051 | 2048 |  					header('Cache-Control: public, max-age='.$expire); | 
                                                        
| 2052 | -					header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expire) . ' GMT'); | 
                                                        |
| 2049 | +					header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expire).' GMT'); | 
                                                        |
| 2053 | 2050 | }  | 
                                                        
| 2054 | 2051 | // remove Pragma header, might be set by old header  | 
                                                        
| 2055 | 2052 |  				if (function_exists('header_remove'))	// PHP 5.3+ | 
                                                        
@@ -2074,10 +2071,10 @@ discard block  | 
                                                    ||
| 2074 | 2071 | * @param array $filter =array() extra filter for sessions  | 
                                                        
| 2075 | 2072 | * @return array with sessions (values for keys as in $sort)  | 
                                                        
| 2076 | 2073 | */  | 
                                                        
| 2077 | - public static function session_list($start,$sort='DESC',$order='session_dla',$all_no_sort=False,array $filter=array())  | 
                                                        |
| 2074 | + public static function session_list($start, $sort = 'DESC', $order = 'session_dla', $all_no_sort = False, array $filter = array())  | 
                                                        |
| 2078 | 2075 |  	{ | 
                                                        
| 2079 | 2076 | $sessions = array();  | 
                                                        
| 2080 | -		if (!preg_match('/^[a-z0-9_ ,]+$/i',$order_by=$order.' '.$sort) || $order_by == ' ') | 
                                                        |
| 2077 | +		if (!preg_match('/^[a-z0-9_ ,]+$/i', $order_by = $order.' '.$sort) || $order_by == ' ') | 
                                                        |
| 2081 | 2078 |  		{ | 
                                                        
| 2082 | 2079 | $order_by = 'session_dla DESC';  | 
                                                        
| 2083 | 2080 | }  | 
                                                        
@@ -2085,7 +2082,7 @@ discard block  | 
                                                    ||
| 2085 | 2082 | $filter[] = 'account_id>0';  | 
                                                        
| 2086 | 2083 | $filter[] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']);  | 
                                                        
| 2087 | 2084 | $filter[] = '(notification_heartbeat IS NULL OR notification_heartbeat > '.self::heartbeat_limit().')';  | 
                                                        
| 2088 | - foreach($GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE, '*', $filter, __LINE__, __FILE__,  | 
                                                        |
| 2085 | + foreach ($GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE, '*', $filter, __LINE__, __FILE__,  | 
                                                        |
| 2089 | 2086 | $all_no_sort ? false : $start, 'ORDER BY '.$order_by) as $row)  | 
                                                        
| 2090 | 2087 |  		{ | 
                                                        
| 2091 | 2088 | $sessions[$row['sessionid']] = $row;  | 
                                                        
@@ -2099,7 +2096,7 @@ discard block  | 
                                                    ||
| 2099 | 2096 | * @param array $filter =array() extra filter for sessions  | 
                                                        
| 2100 | 2097 | * @return int number of active sessions  | 
                                                        
| 2101 | 2098 | */  | 
                                                        
| 2102 | - public static function session_count(array $filter=array())  | 
                                                        |
| 2099 | + public static function session_count(array $filter = array())  | 
                                                        |
| 2103 | 2100 |  	{ | 
                                                        
| 2104 | 2101 | $filter['lo'] = null;  | 
                                                        
| 2105 | 2102 | $filter[] = 'account_id>0';  | 
                                                        
@@ -2115,16 +2112,16 @@ discard block  | 
                                                    ||
| 2115 | 2112 | */  | 
                                                        
| 2116 | 2113 | public static function heartbeat_limit()  | 
                                                        
| 2117 | 2114 |  	{ | 
                                                        
| 2118 | - static $limit=null;  | 
                                                        |
| 2115 | + static $limit = null;  | 
                                                        |
| 2119 | 2116 | |
| 2120 | 2117 | if (is_null($limit))  | 
                                                        
| 2121 | 2118 |  		{ | 
                                                        
| 2122 | 2119 |  			$config = Config::read('notifications'); | 
                                                        
| 2123 | - if (!($popup_poll_interval = $config['popup_poll_interval']))  | 
                                                        |
| 2120 | + if (!($popup_poll_interval = $config['popup_poll_interval']))  | 
                                                        |
| 2124 | 2121 |  			{ | 
                                                        
| 2125 | 2122 | $popup_poll_interval = 60;  | 
                                                        
| 2126 | 2123 | }  | 
                                                        
| 2127 | - $limit = (int)(time() - $popup_poll_interval-10); // 10s grace periode  | 
                                                        |
| 2124 | + $limit = (int)(time() - $popup_poll_interval - 10); // 10s grace periode  | 
                                                        |
| 2128 | 2125 | }  | 
                                                        
| 2129 | 2126 | return $limit;  | 
                                                        
| 2130 | 2127 | }  |