<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
require(root."/___simple_config.php");
session_start();
require(root."/".adminFolder."/_common.php");
require(root."/".adminFolder."/_lib/db.php");
require(root."/".adminFolder."/_lib/main.php");

#$_SESSION["user"]["last_click"] = time();
$session_id = $_SESSION["user"]["session_id"];
/*
$kdcua = getID("_user_activities", "kd");
$kduser = $_SESSION["user"]["kduser"];
$username = $_SESSION["user"]["username"];
$inisial = $_SESSION["user"]["inisial"];
$login_time = $_SESSION["user"]["login_time"];
$last_click = $_SESSION["user"]["last_click"];
$logout_time = time();
$qua = "INSERT INTO _user_activities (kd, kduser, username, inisial, login_time, last_click, session_id, logout_time) 
	VALUES ('$kdcua', '$kduser', '$username', '$inisial', '$login_time', '$last_click', '$session_id', '$logout_time')";
execRS($qua);
*/
$kdcua = getIDL("_user_activities", "kd");
$kduser = $_SESSION["user"]["kduser"];
$username = $_SESSION["user"]["username"];
$inisial = $_SESSION["user"]["inisial"];
$login_time = $_SESSION["user"]["login_time"];
$last_click = $_SESSION["user"]["last_click"];
$logout_time = time();
$qua = "INSERT INTO _user_activities (kd, kduser, username, inisial, login_time, last_click, session_id, logout_time, ket) 
	VALUES ('$kdcua', '$kduser', '$username', '$inisial', '$login_time', '$last_click', '$session_id', '$logout_time', 'Log Out')";
execRSL($qua);


session_destroy();
session_start();
if (isset($_SESSION["user"])) {
	unset($_SESSION["user"]);
}
header("Location: /".adminFolder."/login/");
?>