root/trunk/redirectors/markasread.php

Revision 291, 2.8 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/markasread.php
6  * Description: mark all posts as read by setting 'lastvisit' information
7  *              to the current time; only does something for registered users
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('Markasread', 'w')) {
58     // permission granted
59     // close databast connection
60     $C = NULL;
61     // get current time in UTC
62     $_ts = new DateTime('now', new DateTimeZone('UTC'));
63     // update session
64     $_SESSION['lastvisit'] = $_ts->format('Y-m-d H:i:s');
65     session_write_close();
66     // refresh session
67     session_start();
68     // handle refering page
69     if (strpos($_SESSION['page_ref'], '?') === FALSE) {
70         $ref = $_SESSION['page_ref'] . '?';
71     } else {
72         $ref = $_SESSION['page_ref'];
73     }
74     // forward to last page
75     header('Location: ' . $SETTINGS['webpath'] . $ref . '&' . strip_tags(SID));
76     // just in case something went wrong with redirecting, print something
77     print($LANG['markasread_success']);
78 } else {
79     print($LANG['error_permission_denied']);
80 }
81
82 ?>
Note: See TracBrowser for help on using the browser.