<?php
/*
* Created on 26 août 2005
* @author Matthias Cullmann
*/
require_once('config.inc.php');
require_once (ACCESS_MANAGER.'.php');
function loginPage(){
return defined('falseLogin') ||
( isset($_POST['loginout']) && $_POST['loginout']=='login');
}
function logoutPage(){
return isset($_POST['loginout']) && $_POST['loginout']=='logout';
}
function isLogged(){
return isset($_COOKIE["weXpID"]);
}
function getUser(){
if(isset($_COOKIE["weXpID"])){
$sIDarr = split(":",$_COOKIE["weXpID"]);
return $sIDarr[0];
}
return "anonymous";
}
$cookiedomain = '.'.$_SERVER["HTTP_HOST"];
function login($user,$pass){
global $cookiedomain;
$weXpID = $_POST['login'].":".rand(100000000,999999999);
if (validLogin($user,$pass)){
setcookie ( 'weXpID', $weXpID, time()+600, '/',$cookiedomain,false);
$_COOKIE["weXpID"] = $weXpID;
if(is_file("$user.prefs"))
$prefs = unserialize(file_get_contents("$user.prefs"));
else
$prefs = array();
if(isset($prefs['weXpLastLogin'])){
setcookie ( 'weXpBeforeLastLogin', $prefs['weXpLastLogin'], mktime(2050), '/',$cookiedomain, false);
}
setcookie ( 'weXpLastLogin', time(), mktime(2050), '/',$cookiedomain, false);
$prefs['weXpLastLogin'] = time();
@file_put_contents("$user.prefs",serialize($prefs));
return true;
} else {
return false;
}
}
function logout(){
global $cookiedomain;
if(isset($_COOKIE["weXpID"]))
setcookie ( 'weXpID', $_COOKIE["weXpID"], time() - 3600, '/',$cookiedomain, false);
unset($_COOKIE["weXpID"]);
}
function lastLogin(){
if(isset($_COOKIE['weXpBeforeLastLogin'])){
return $_COOKIE['weXpBeforeLastLogin'];
}
return false;
}
if(isLogged())
setcookie ( 'weXpID', $_COOKIE["weXpID"], time()+600, '/',$cookiedomain, false);
?>