root/trunk/redirectors/logout.php

Revision 291, 3.1 kB (checked in by hannes, 3 years ago)

establishing a global warnings array to store and display (choke) warnings

Line 
1 <?php
2
3 /**
4  * Package: Spam Board 5
5  * File: redirectors/logout.php
6  * Description: called on user-requested logout; needs to be a 'redirector',
7  *              because this causes headers to be sent before any output
8  *
9  * Copyright (C) 2007, 2009 Hannes Schueller
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Affero General Public License as
13  * published by the Free Software Foundation, version 3 of the
14  * License.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Affero General Public License for more details.
20  *
21  * You should have received a copy of the GNU Affero General Public License
22  * along with this program (see LICENCE). If not,
23  * see <http://www.gnu.org/licenses/>.
24  **/
25
26 // called independently from index
27 require_once('../includes/config/settings.php');
28
29 // load classes on demand
30 function __autoload($class) {
31     global $SETTINGS;
32     if (is_file($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php')) {
33         require_once($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php');
34     } elseif (is_file($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php')) {
35         require_once($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php');
36     } else { die('Class ' . $class . ' not found.'); }
37 }
38
39 // initialize global warnings array
40 $WARNINGS = Array();
41
42 // import version number
43 require_once($SETTINGS['fspath'] . 'includes/config/version.php');
44 // bots definition
45 require_once($SETTINGS['fspath'] . 'includes/config/bots.php');
46 // formatting object
47 $F = new Format();
48 require($SETTINGS['fspath'] . 'includes/lang/' . $SETTINGS['language'] . '.php');
49 // open database connection
50 $C = new Connection();
51 Member::session();
52 if (isset($_SESSION['lang']) && $_SESSION['lang'] != '') {
53     include($SETTINGS['fspath'] . 'includes/lang/' . $_SESSION['lang'] . '.php');
54 }
55
56 // check if user has permission; required: write; independent from id
57 if (Member::checkRights('Login', 'w')) {
58     // permission granted
59     // update session
60     $_SESSION['memberid'] = 0;
61     $_SESSION['membername'] = '';
62     $_SESSION['lastvisit'] = -1;
63     if (isset($_SESSION['auth_admin'])) {
64         unset($_SESSION['auth_admin']);
65     }
66     // if cookie to remember user credentials has previously been set, remove them
67     if ($_SESSION['remember'] === 1) {
68         // delete cookie
69         @setcookie('sb_user', '', -1, $SETTINGS['cookiepath']);
70     }
71     $_SESSION['remember'] = 0;
72     session_write_close();
73     // refresh session
74     session_start();
75     // update in database
76     $q = $C->prepare('UPDATE ' . $SETTINGS['dbtableprefix'] . 'online SET onlinememberid = :zero WHERE onlinesession=:session');
77     $q->bindValue(':zero', 0, PDO::PARAM_INT);
78     $q->bindParam(':session', session_id(), PDO::PARAM_STR, 40);
79     $q->execute();
80     $q = NULL;
81     // close database connection
82     $C = NULL;
83     // forward to index
84     header('Location: ' . $SETTINGS['webpath'] . 'index.php?' . strip_tags(SID));
85     // just in case something went wrong with redirecting, print something
86     print($LANG['logout_success']);
87 } else {
88     print($LANG['error_permission_denied']);
89 }
90
91 ?>
Note: See TracBrowser for help on using the browser.