2010-11-02 11:57:33 +01:00
|
|
|
<?php
|
2010-12-10 11:03:20 +01:00
|
|
|
// 'false' means that the user is not logged in as a moderator
|
|
|
|
$mod = false;
|
2010-11-02 11:57:33 +01:00
|
|
|
|
2010-12-01 06:42:48 +01:00
|
|
|
// Set the session name.
|
2011-02-12 07:25:15 +01:00
|
|
|
session_name($config['cookies']['session']);
|
2010-11-02 11:57:33 +01:00
|
|
|
|
2010-12-01 06:42:48 +01:00
|
|
|
// Set session parameters
|
2011-02-12 07:25:15 +01:00
|
|
|
session_set_cookie_params(0, $config['cookies']['jail']?$config['root']:'/');
|
2010-12-01 06:42:48 +01:00
|
|
|
|
|
|
|
// Start the session
|
2010-12-01 06:43:36 +01:00
|
|
|
session_start();
|
2010-12-01 06:42:48 +01:00
|
|
|
|
|
|
|
// Session creation time
|
2010-11-02 11:57:33 +01:00
|
|
|
if(!isset($_SESSION['created'])) $_SESSION['created'] = time();
|
|
|
|
|
2011-02-12 07:25:15 +01:00
|
|
|
if(!isset($_COOKIE[$config['cookies']['hash']]) || !isset($_COOKIE[$config['cookies']['time']]) || $_COOKIE[$config['cookies']['hash']] != md5($_COOKIE[$config['cookies']['time']] . $config['cookies']['salt'])) {
|
2010-11-02 11:57:33 +01:00
|
|
|
$time = time();
|
2011-02-12 07:25:15 +01:00
|
|
|
setcookie($config['cookies']['time'], $time, time()+$config['cookies']['expire'], $config['cookies']['jail']?$config['root']:'/', null, false, true);
|
|
|
|
setcookie($config['cookies']['hash'], md5($time . $config['cookies']['salt']), $time+$config['cookies']['expire'], $config['cookies']['jail']?$config['root']:'/', null, false, true);
|
2010-11-02 11:57:33 +01:00
|
|
|
$user = Array('valid' => false, 'appeared' => $time);
|
|
|
|
} else {
|
2011-02-12 07:25:15 +01:00
|
|
|
$user = Array('valid' => true, 'appeared' => $_COOKIE[$config['cookies']['time']]);
|
2010-11-02 11:57:33 +01:00
|
|
|
}
|
2010-12-01 11:24:14 +01:00
|
|
|
|
2010-11-02 11:57:33 +01:00
|
|
|
?>
|