- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
//старт сессии
function Sessions_Start () {
global $SecureKey, $SecureCookieName, $NumIPRanks, $AuthSalt;
$LifeTime = 0;
$Path = '/';
$Domain = '';
$Secure = FALSE;
$HttpOnly = TRUE;
session_set_cookie_params($LifeTime, $Path, $Domain, $Secure, $HttpOnly);
session_start ();
if (!isset ($_SESSION['UserData'])) {
$_SESSION['UserData'] = array ();
$_SESSION['UserData']['UserType'] = 'guest';
}
else{
$Type = $_SESSION['UserData']['UserType'];
$SessionValidator = 0;
if ($Type == 'member') {
if (!isset ($_SESSION['UserData']['UserID']) or !isset ($_SESSION['UserData']['UserName']) or!isset ($_SESSION['UserData']['GroupID']) or!isset ($_SESSION['UserData'][$SecureKey]) or!isset ($_SESSION['UserData'][$SecureCookieName])) {
$SessionValidator++;
}
if (!isset ($_COOKIE[$SecureCookieName])) {
$SessionValidator++;
}
//секретная строка
$IPArray = explode ('.', $_SERVER['REMOTE_ADDR']);
$IPRanks = array ();
for ($i=0; $i < $NumIPRanks; $i++) {
$IPRanks[] = $IPArray[$i];
}
$IPFinalString = sha1 (implode ('.', $IPRanks) . $AuthSalt);
$CurUserAgent = sha1 (substr ($_SERVER['HTTP_USER_AGENT'], 0, 50) . $AuthSalt);
$SecureString = sha1 ($IPFinalString . $CurUserAgent . $AuthSalt);
if ($_SESSION['UserData'][$SecureKey] <> $SecureString) {
$SessionValidator++;
}
if ($_SESSION['UserData'][$SecureCookieName] <> $_COOKIE[$SecureCookieName]) {
$SessionValidator++;
}
if ($SessionValidator > 0) {
session_regenerate_id ();
$_SESSION['UserData'] = array ();
$_SESSION['UserData']['UserType'] = 'guest';
}
}
}
return (session_id ());
}
Комментарии (0) RSS
Добавить комментарий