1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 09:20:58 +01:00
vichan/inc/user.php

26 lines
856 B
PHP
Raw Normal View History

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.
2010-11-02 11:57:33 +01:00
session_name(SESS_COOKIE);
2010-12-01 06:42:48 +01:00
// Set session parameters
session_set_cookie_params(0, JAIL_COOKIES?ROOT:'/');
// 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();
if(!isset($_COOKIE[HASH_COOKIE]) || !isset($_COOKIE[TIME_COOKIE]) || $_COOKIE[HASH_COOKIE] != md5($_COOKIE[TIME_COOKIE].SALT)) {
$time = time();
2010-12-01 06:42:48 +01:00
setcookie(TIME_COOKIE, $time, time()+COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true);
2010-12-01 11:24:14 +01:00
setcookie(HASH_COOKIE, md5($time.SALT), $time+COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true);
2010-11-02 11:57:33 +01:00
$user = Array('valid' => false, 'appeared' => $time);
} else {
$user = Array('valid' => true, 'appeared' => $_COOKIE[TIME_COOKIE]);
}
2010-12-01 11:24:14 +01:00
2010-11-02 11:57:33 +01:00
?>