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

#$_SESSION["member"]["last_click"] = time();
$session_id = $_SESSION["member"]["session_id"];
/*
$kdcua = getID("_user_activities", "kd");
$kdmember = $_SESSION["member"]["kdmember"];
$username = $_SESSION["member"]["username"];
$inisial = $_SESSION["member"]["inisial"];
$login_time = $_SESSION["member"]["login_time"];
$last_click = $_SESSION["member"]["last_click"];
$logout_time = time();
$qua = "INSERT INTO _user_activities (kd, kdmember, username, inisial, login_time, last_click, session_id, logout_time) 
	VALUES ('$kdcua', '$kdmember', '$username', '$inisial', '$login_time', '$last_click', '$session_id', '$logout_time')";
execRS($qua);
*/
$kdcua = getIDL("_member_activities", "kd");
$kdmember = $_SESSION["member"]["kdmember"];
$login_time = $_SESSION["member"]["login_time"];
$last_click = $_SESSION["member"]["last_click"];
$logout_time = time();
$rsc=array(); $qc="SELECT * FROM members WHERE kdmember='$kdmember'";
callRS($rsc, $qc);
$email = $rsc[0]["email"];
$telp = $rsc[0]["telp"];
$qua = "INSERT INTO _member_activities (kd, kdmember, email, telp, login_time, last_click, session_id, logout_time, ket) 
	VALUES ('$kdcua', '$kdmember', '$email', '$telp', '$login_time', '$last_click', '$session_id', '$logout_time', 'Log Out')";
execRSL($qua);


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