23 |
23 |
|
24 |
24 |
*/
|
25 |
25 |
|
26 |
|
require("../../config.php");
|
|
26 |
require('../../config.php');
|
27 |
27 |
|
28 |
|
if(isset($_COOKIE['REMEMBER_KEY'])) {
|
29 |
|
setcookie('REMEMBER_KEY', '', time()-3600, '/');
|
|
28 |
// delete remember key of current user from database
|
|
29 |
if (isset($_SESSION['USER_ID']) && isset($database)) {
|
|
30 |
$table = TABLE_PREFIX . 'users';
|
|
31 |
$sql = "UPDATE `$table` SET `remember_key` = '' WHERE `user_id` = '" . (int) $_SESSION['USER_ID'] . "'";
|
|
32 |
$database->query($sql);
|
30 |
33 |
}
|
31 |
34 |
|
|
35 |
// delete remember key cookie if set
|
|
36 |
if (isset($_COOKIE['REMEMBER_KEY'])) {
|
|
37 |
setcookie('REMEMBER_KEY', '', time() - 3600, '/');
|
|
38 |
}
|
|
39 |
|
|
40 |
// delete most critical session variables manually
|
32 |
41 |
$_SESSION['USER_ID'] = null;
|
33 |
42 |
$_SESSION['GROUP_ID'] = null;
|
34 |
43 |
$_SESSION['GROUPS_ID'] = null;
|
35 |
44 |
$_SESSION['USERNAME'] = null;
|
36 |
45 |
$_SESSION['PAGE_PERMISSIONS'] = null;
|
37 |
46 |
$_SESSION['SYSTEM_PERMISSIONS'] = null;
|
|
47 |
|
|
48 |
// overwrite session array
|
38 |
49 |
$_SESSION = array();
|
39 |
|
session_unset();
|
40 |
|
unset($_COOKIE[session_name()]);
|
|
50 |
|
|
51 |
// delete session cookie if set
|
|
52 |
if (isset($_COOKIE[session_name()])) {
|
|
53 |
setcookie(session_name(), '', time() - 42000, '/');
|
|
54 |
}
|
|
55 |
|
|
56 |
// delete the session itself
|
41 |
57 |
session_destroy();
|
42 |
58 |
|
43 |
|
header("Location: ".ADMIN_URL."/login/index.php");
|
|
59 |
// redirect to admin login
|
|
60 |
die(header('Location: ' . ADMIN_URL . '/login/index.php'));
|
44 |
61 |
|
45 |
62 |
?>
|
reworked logout to reset possible remember key in database when logging out