<?php
// $Id: logout.php,v 1.5 2004/02/05 18:03:54 saka_car Exp $
/**
* Administrator logout function
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License: http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.5 $
**/
$currentDate = date("Y-m-d\TH:i:s");

if (isset($_SESSION['session_user_id']) && $_SESSION['session_user_id']!="") {
	$database->setQuery( "UPDATE #__users SET lastvisitDate='$currentDate' WHERE id='" . $_SESSION['session_user_id'] . "'");

	if (!$database->query()) {
        echo $database->stderr();
	}
}

if (isset($_SESSION['session_id']) && $_SESSION['session_id']!="") {
	$database->setQuery( "DELETE FROM #__session WHERE session_id='" . $_SESSION['session_id'] . "'");

	if (!$database->query()) {
		echo $database->stderr();
	}
}

$name = "";
$fullname = "";
$id = "";
$session_id = "";

session_unregister( "session_id" );
session_unregister( "session_user_id" );
session_unregister( "session_username" );
session_unregister( "session_usertype" );
session_unregister( "session_logintime" );

if (session_is_registered( "session_id" )) {
	session_destroy();
}
if (session_is_registered( "session_user_id" )) {
	session_destroy();
}
if (session_is_registered( "session_username" )) {
	session_destroy();
}
if (session_is_registered( "session_usertype" )) {
	session_destroy();
}
if (session_is_registered( "session_logintime" )) {
	session_destroy();
}
mosRedirect( "../index.php" );
?>