leftypol/inc/user.php

32 lines
1.3 KiB
PHP
Raw Normal View History

2010-11-02 10:57:33 +00:00
<?php
2011-04-13 12:21:07 +00:00
if($_SERVER['SCRIPT_FILENAME'] == str_replace('\\', '/', __FILE__)) {
// You cannot request this file directly.
header('Location: ../', true, 302);
exit;
}
2010-12-10 10:03:20 +00:00
// 'false' means that the user is not logged in as a moderator
$mod = false;
2010-11-02 10:57:33 +00:00
2010-12-01 05:42:48 +00:00
// Set the session name.
2011-02-12 06:25:15 +00:00
session_name($config['cookies']['session']);
2010-11-02 10:57:33 +00:00
2010-12-01 05:42:48 +00:00
// Set session parameters
2011-02-12 06:25:15 +00:00
session_set_cookie_params(0, $config['cookies']['jail']?$config['root']:'/');
2010-12-01 05:42:48 +00:00
// Start the session
2010-12-01 05:43:36 +00:00
session_start();
2010-12-01 05:42:48 +00:00
// Session creation time
2010-11-02 10:57:33 +00:00
if(!isset($_SESSION['created'])) $_SESSION['created'] = time();
2011-02-12 06:25:15 +00: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 10:57:33 +00:00
$time = time();
setcookie($config['cookies']['time'], $time, time()+$config['cookies']['expire'], $config['cookies']['jail']?$config['cookies']['path']:'/', null, false, true);
setcookie($config['cookies']['hash'], md5($time . $config['cookies']['salt']), $time+$config['cookies']['expire'], $config['cookies']['jail']?$config['cookies']['path']:'/', null, false, true);
2010-11-02 10:57:33 +00:00
$user = Array('valid' => false, 'appeared' => $time);
} else {
2011-02-12 06:25:15 +00:00
$user = Array('valid' => true, 'appeared' => $_COOKIE[$config['cookies']['time']]);
2010-11-02 10:57:33 +00:00
}
2010-12-01 10:24:14 +00:00
2010-11-02 10:57:33 +00:00
?>