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 2098 darkviper
    $oDb = WbDatabase::getInstance();
24
	$sql = 'UPDATE `'.$oDb->TablePrefix.'users` '
25
         . 'SET `remember_key`=\'\' '
26
         . 'WHERE `user_id`='.(int)$_SESSION['USER_ID'];
27
	$oDb->doQuery($sql);
28 4 ryan
}
29
30 932 doc
// delete remember key cookie if set
31
if (isset($_COOKIE['REMEMBER_KEY'])) {
32
	setcookie('REMEMBER_KEY', '', time() - 3600, '/');
33
}
34
35
// delete most critical session variables manually
36 4 ryan
$_SESSION['USER_ID'] = null;
37
$_SESSION['GROUP_ID'] = null;
38 546 doc
$_SESSION['GROUPS_ID'] = null;
39 4 ryan
$_SESSION['USERNAME'] = null;
40
$_SESSION['PAGE_PERMISSIONS'] = null;
41
$_SESSION['SYSTEM_PERMISSIONS'] = null;
42 932 doc
43
// overwrite session array
44 4 ryan
$_SESSION = array();
45 932 doc
46
// delete session cookie if set
47
if (isset($_COOKIE[session_name()])) {
48
    setcookie(session_name(), '', time() - 42000, '/');
49
}
50
51
// delete the session itself
52 4 ryan
session_destroy();
53
54 932 doc
// redirect to admin login
55
die(header('Location: ' . ADMIN_URL . '/login/index.php'));
56 4 ryan
57
?>