forked from sbromle/RefBase-Fork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_logout.php
More file actions
113 lines (88 loc) · 5.12 KB
/
user_logout.php
File metadata and controls
113 lines (88 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./user_logout.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 16-Apr-02, 10:54
// Modified: $Date$
// $Author$
// $Revision$
// This script logs a user out and redirects
// to the calling page. If the script is called
// unexpectedly, an error message is generated.
// Incorporate some include files:
include 'includes/include.inc.php'; // include common functions
// --------------------------------------------------------------------
// START A SESSION:
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
start_session(true);
// --------------------------------------------------------------------
// Is the user logged in?
if (isset($_SESSION['loginEmail']))
{
// Delete the 'loginEmail' session variable & other session variables we've registered on login:
// (function 'deleteSessionVariable()' is defined in 'include.inc.php')
deleteSessionVariable("loginEmail"); // remove the user's email address (as a result the user will be logged out)
deleteSessionVariable("loginUserID"); // clear the user's user ID
deleteSessionVariable("loginFirstName"); // clear the user's first name
deleteSessionVariable("loginLastName"); // clear the user's last name
deleteSessionVariable("abbrevInstitution"); // clear the user's abbreviated institution name
deleteSessionVariable("userLanguage"); // clear the user's preferred language
deleteSessionVariable("userDefaultView"); // clear the user's default view setting
deleteSessionVariable("userRecordsPerPage"); // clear the user's preferred number of records per page
deleteSessionVariable("userAutoCompletions"); // clear the user's preference for displaying auto-completions
deleteSessionVariable("userMainFields"); // clear the user's preferred list of "main fields"
deleteSessionVariable("lastLogin"); // clear the user's last login date & time
if (isset($_SESSION['userGroups']))
deleteSessionVariable("userGroups"); // clear the user's user groups (if any)
if (isset($_SESSION['adminUserGroups']))
deleteSessionVariable("adminUserGroups"); // clear the admin's user groups (if any)
if (isset($_SESSION['userQueries']))
deleteSessionVariable("userQueries"); // clear the user's saved queries (if any)
if (isset($_SESSION['user_export_formats']))
deleteSessionVariable("user_export_formats"); // clear the user's export formats (if any)
if (isset($_SESSION['user_cite_formats']))
deleteSessionVariable("user_cite_formats"); // clear the user's cite formats (if any)
if (isset($_SESSION['user_styles']))
deleteSessionVariable("user_styles"); // clear the user's styles (if any)
if (isset($_SESSION['user_types']))
deleteSessionVariable("user_types"); // clear the user's types (if any)
if (isset($_SESSION['user_permissions']))
deleteSessionVariable("user_permissions"); // clear any user-specific permissions
if (isset($_SESSION['HeaderString']))
deleteSessionVariable("HeaderString"); // clear any previous messages
if (isset($_SESSION['cqlQuery']))
deleteSessionVariable("cqlQuery"); // clear any stored OpenSearch/CQL query
if (isset($_SESSION['oldQuery']))
deleteSessionVariable("oldQuery"); // clear any query URL pointing to the formerly displayed results page
if (isset($_SESSION['oldMultiRecordQuery']))
deleteSessionVariable("oldMultiRecordQuery"); // clear any query URL pointing to the last multi-record query
if (isset($_SESSION['lastListViewQuery']))
deleteSessionVariable("lastListViewQuery"); // clear any SQL query generated for the last List view
if (isset($_SESSION['lastDetailsViewQuery']))
deleteSessionVariable("lastDetailsViewQuery"); // clear any SQL query generated for the last Details view
// if (isset($_SESSION['lastCitationViewQuery']))
// deleteSessionVariable("lastCitationViewQuery"); // clear any SQL query generated for the last Citation view
if (isset($_SESSION['queryHistory']))
deleteSessionVariable("queryHistory"); // clear any links to previous search results
}
else
{
// save an error message:
$HeaderString = "<b><span class=\"warning\">You cannot logout since you are not logged in anymore!</span></b>";
// Write back session variables:
saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
}
if (!preg_match("/.*user(_details|_options|_receipt|s)\.php.*|.*(error|install|query_manager|query_history)\.php.*/", $referer)) // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
header("Location: " . $referer); // redirect the user to the calling page
else
header("Location: index.php"); // back to main page
?>