Project

General

Profile

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