1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
/**
* @access public
* indique si l'utilisateur est connecte
* @return bool
*/
public function _isConnected(){
if( !isset($_SESSION['ip']) or $_SESSION['ip']!=sha1($_SERVER['REMOTE_ADDR'])
or !isset($_SESSION['userAgent']) or $_SESSION['userAgent']!=sha1($_SERVER['HTTP_USER_AGENT']) ){
return false;
}else if(
(int)_root::getConfigVar('auth.session.timeout.enabled')==1
and (!isset($_SESSION['timeout']) or ((int)$_SESSION['timeout']-time() ) < 0)){
//on regenere un nouvel id de session
session_regenerate_id(true);
//redirection ves pages lock
_root::redirect('auth::sessionLock');
return false;
}else if(
_root::getConfigVar('security.xsrf.checkReferer.enabled') ==1
and isset($_SERVER['HTTP_REFERER'])){
if(isset($_SERVER['HTTPS']) ){
$sPattern='https://'.$_SERVER['SERVER_NAME'];
}else{
$sPattern='http://'.$_SERVER['SERVER_NAME'];
}
$urllen=strlen($sPattern);
if( substr($_SERVER['HTTP_REFERER'],0,$urllen)!=$sPattern ){
return false;
}
}
if((int)_root::getConfigVar('auth.session.timeout.enabled')==1){
$_SESSION['timeout']=(time()+(int)_root::getConfigVar('auth.session.timeout.lifetime') );
}
return true;
} |
Partager