-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlogout.php
313 lines (244 loc) · 7.07 KB
/
logout.php
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php
if (session_id() == "") session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include_once "includes/framework/ewcfg9.php" ?>
<?php include_once "includes/framework/ewmysql9.php" ?>
<?php include_once "phpfn9.php" ?>
<?php include_once "userfn9.php" ?>
<?php
//
// Page class
//
$logout = NULL; // Initialize page object first
class clogout {
// Page ID
var $PageID = 'logout';
// Project ID
var $ProjectID = "{94C0E450-F9A8-47EE-A905-551040DB9277}";
// Page object name
var $PageObjName = 'logout';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
return $PageUrl;
}
// Message
function getMessage() {
return @$_SESSION[EW_SESSION_MESSAGE];
}
function setMessage($v) {
ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
}
function getFailureMessage() {
return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
}
function setFailureMessage($v) {
ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
}
function getSuccessMessage() {
return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
}
function setSuccessMessage($v) {
ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
}
function getWarningMessage() {
return @$_SESSION[EW_SESSION_WARNING_MESSAGE];
}
function setWarningMessage($v) {
ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v);
}
// Show message
function ShowMessage() {
$hidden = FALSE;
$html = "";
// Message
$sMessage = $this->getMessage();
$this->Message_Showing($sMessage, "");
if ($sMessage <> "") { // Message in Session, display
$html .= "<p class=\"ewMessage\">" . $sMessage . "</p>";
$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
}
// Warning message
$sWarningMessage = $this->getWarningMessage();
$this->Message_Showing($sWarningMessage, "warning");
if ($sWarningMessage <> "") { // Message in Session, display
$html .= "<table class=\"ewMessageTable\"><tr><td class=\"ewWarningIcon\"></td><td class=\"ewWarningMessage\">" . $sWarningMessage . "</td></tr></table>";
$_SESSION[EW_SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
}
// Success message
$sSuccessMessage = $this->getSuccessMessage();
$this->Message_Showing($sSuccessMessage, "success");
if ($sSuccessMessage <> "") { // Message in Session, display
$html .= "<table class=\"ewMessageTable\"><tr><td class=\"ewSuccessIcon\"></td><td class=\"ewSuccessMessage\">" . $sSuccessMessage . "</td></tr></table>";
$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
}
// Failure message
$sErrorMessage = $this->getFailureMessage();
$this->Message_Showing($sErrorMessage, "failure");
if ($sErrorMessage <> "") { // Message in Session, display
$html .= "<table class=\"ewMessageTable\"><tr><td class=\"ewErrorIcon\"></td><td class=\"ewErrorMessage\">" . $sErrorMessage . "</td></tr></table>";
$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
}
echo "<div class=\"ewMessageDialog\"" . (($hidden) ? " style=\"display: none;\"" : "") . ">" . $html . "</div>";
}
var $PageHeader;
var $PageFooter;
// Show Page Header
function ShowPageHeader() {
$sHeader = $this->PageHeader;
$this->Page_DataRendering($sHeader);
if ($sHeader <> "") { // Header exists, display
echo "<p class=\"phpmaker\">" . $sHeader . "</p>";
}
}
// Show Page Footer
function ShowPageFooter() {
$sFooter = $this->PageFooter;
$this->Page_DataRendered($sFooter);
if ($sFooter <> "") { // Fotoer exists, display
echo "<p class=\"phpmaker\">" . $sFooter . "</p>";
}
}
// Validate page request
function IsPageRequest() {
return TRUE;
}
//
// Page class constructor
//
function __construct() {
global $conn, $Language, $UserAgent;
// User agent
$UserAgent = ew_UserAgent();
$GLOBALS["Page"] = &$this;
// Language object
if (!isset($Language)) $Language = new cLanguage();
// Page ID
if (!defined("EW_PAGE_ID"))
define("EW_PAGE_ID", 'logout', TRUE);
// Start timer
if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();
// Open connection
if (!isset($conn)) $conn = ew_Connect();
}
//
// Page_Init
//
function Page_Init() {
global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
// Security
$Security = new cAdvancedSecurity();
// Global Page Loading event (in userfn*.php)
Page_Loading();
// Page Load event
$this->Page_Load();
}
//
// Page_Terminate
//
function Page_Terminate($url = "") {
global $conn;
// Page Unload event
$this->Page_Unload();
// Global Page Unloaded event (in userfn*.php)
Page_Unloaded();
$this->Page_Redirecting($url);
// Close connection
$conn->Close();
// Go to URL if specified
if ($url <> "") {
if (!EW_DEBUG_ENABLED && ob_get_length())
ob_end_clean();
header("Location: " . $url);
}
exit();
}
//
// Page main
//
function Page_Main() {
global $Security, $Language, $UserProfile;
$bValidate = TRUE;
$sUsername = $Security->CurrentUserName();
// Call User LoggingOut event
$bValidate = $this->User_LoggingOut($sUsername);
if (!$bValidate) {
$sLastUrl = $Security->LastUrl();
if ($sLastUrl == "")
$sLastUrl = "index.php";
$this->Page_Terminate($sLastUrl); // Go to last accessed URL
} else {
if (@$_COOKIE[EW_PROJECT_NAME]['AutoLogin'] == "") // Not autologin
setcookie(EW_PROJECT_NAME . '[Username]', ""); // clear user name cookie
setcookie(EW_PROJECT_NAME . '[Password]', ""); // clear password cookie
setcookie(EW_PROJECT_NAME . '[LastUrl]', ""); // clear last URL
// Call User LoggedOut event
$this->User_LoggedOut($sUsername);
// Unset all of the Session variables
$_SESSION = array();
// Delete the Session cookie and kill the Session
if (isset($_COOKIE[session_name()]))
setcookie(session_name(), '', time()-42000, '/');
// Finally, destroy the Session
@session_destroy();
$this->Page_Terminate("login.php"); // Go to login page
}
}
// Page Load event
function Page_Load() {
//echo "Page Load";
}
// Page Unload event
function Page_Unload() {
//echo "Page Unload";
}
// Page Redirecting event
function Page_Redirecting(&$url) {
// Example:
//$url = "your URL";
}
// Message Showing event
// $type = ''|'success'|'failure'
function Message_Showing(&$msg, $type) {
// Example:
//if ($type == 'success') $msg = "your success message";
}
// Page Data Rendering event
function Page_DataRendering(&$header) {
// Example:
//$header = "your header";
}
// Page Data Rendered event
function Page_DataRendered(&$footer) {
// Example:
//$footer = "your footer";
}
// User Logging Out event
function User_LoggingOut($usr) {
// Enter your code here
// To cancel, set return value to FALSE;
return TRUE;
}
// User Logged Out event
function User_LoggedOut($usr) {
//echo "User Logged Out";
}
}
?>
<?php ew_Header(FALSE) ?>
<?php
// Create page object
if (!isset($logout)) $logout = new clogout();
// Page init
$logout->Page_Init();
// Page main
$logout->Page_Main();
?>
<?php
$logout->Page_Terminate();
?>