Project

General

Profile

1 4 ryan
<?php
2 1386 Luisehahne
/**
3
 *
4
 * @category        admin
5
 * @package         logout
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id$
14
 * @filesource		$HeadURL: http://svn.websitebaker2.org/branches/2.8.x/wb/admin/users/save.php $
15
 * @lastmodified    $Date: 2011-01-10 13:21:47 +0100 (Mo, 10. Jan 2011) $
16
 *
17
 */
18 4 ryan
19 932 doc
require('../../config.php');
20 4 ryan
21 932 doc
// delete remember key of current user from database
22
if (isset($_SESSION['USER_ID']) && isset($database)) {
23
	$table = TABLE_PREFIX . 'users';
24
	$sql = "UPDATE `$table` SET `remember_key` = '' WHERE `user_id` = '" . (int) $_SESSION['USER_ID'] . "'";
25
	$database->query($sql);
26 4 ryan
}
27
28 932 doc
// delete remember key cookie if set
29
if (isset($_COOKIE['REMEMBER_KEY'])) {
30
	setcookie('REMEMBER_KEY', '', time() - 3600, '/');
31
}
32
33
// delete most critical session variables manually
34 4 ryan
$_SESSION['USER_ID'] = null;
35
$_SESSION['GROUP_ID'] = null;
36 546 doc
$_SESSION['GROUPS_ID'] = null;
37 4 ryan
$_SESSION['USERNAME'] = null;
38
$_SESSION['PAGE_PERMISSIONS'] = null;
39
$_SESSION['SYSTEM_PERMISSIONS'] = null;
40 932 doc
41
// overwrite session array
42 4 ryan
$_SESSION = array();
43 932 doc
44
// delete session cookie if set
45
if (isset($_COOKIE[session_name()])) {
46
    setcookie(session_name(), '', time() - 42000, '/');
47
}
48
49
// delete the session itself
50 4 ryan
session_destroy();
51
52 932 doc
// redirect to admin login
53
die(header('Location: ' . ADMIN_URL . '/login/index.php'));
54 4 ryan
55
?>