1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-27 17:00:52 +01:00
vichan/inc/user.php

32 lines
1.3 KiB
PHP
Raw Normal View History

2010-11-02 11:57:33 +01:00
<?php
2011-04-13 14:21:07 +02:00
if($_SERVER['SCRIPT_FILENAME'] == str_replace('\\', '/', __FILE__)) {
// You cannot request this file directly.
header('Location: ../', true, 302);
exit;
}
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();
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 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
?>