1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-01-10 13:31:43 +01:00
vichan/inc/user.php

32 lines
1.3 KiB
PHP
Raw Normal View History

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