root/trunk/admin/index.php

Revision 407, 3.8 kB (checked in by hannes, 1 year ago)

fixes for PHP strict mode

Line 
1 <?php
2
3 /**
4  * Package: Spam Board 5
5  * File: admin/index.php
6  * Description: wrapper file calling all administrative functions
7  *
8  * Copyright (C) 2007, 2008, 2009, 2011 Hannes Schueller
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as
12  * published by the Free Software Foundation, version 3 of the
13  * License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program (see LICENCE). If not,
22  * see <http://www.gnu.org/licenses/>.
23  **/
24
25 // disable output of error messages and warnings
26 ini_set('display_errors', 'Off');
27 error_reporting(E_ALL | E_STRICT);
28
29 // explicitely set default timezone
30 date_default_timezone_set('UTC');
31
32 // if install script is present, redirect there
33 if (is_file('../install.php')) {
34     header('Location: ../install.php');
35 }
36
37 // initialize global warnings array
38 $WARNINGS = Array();
39
40 // global settings file
41 require_once('../includes/config/settings.php');
42
43 // load classes on demand; in spite of being spread over two directories, class names obviously have to be unique
44 function __autoload($class) {
45     global $SETTINGS;
46     if (is_file($SETTINGS['fspath'] . 'admin/classes/pages/' . $class . '.php')) {
47         require_once($SETTINGS['fspath'] . 'admin/classes/pages/' . $class . '.php');
48     } elseif (is_file($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php')) {
49         require_once($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php');
50     } else { die('Class ' . $class . ' not found.'); }
51 }
52
53 // import the abstract page class
54 require_once($SETTINGS['fspath'] . 'classes/pages/Page.php');
55
56 // time zones
57 require_once($SETTINGS['fspath'] . 'includes/config/timezones.php');
58
59 // import version number
60 require_once($SETTINGS['fspath'] . 'includes/config/version.php');
61
62 // bots definition
63 require_once($SETTINGS['fspath'] . 'includes/config/bots.php');
64
65 // get memberstages
66 require_once($SETTINGS['fspath'] . 'includes/config/memberstages.php');
67
68 // default usergroups
69 require_once($SETTINGS['fspath'] . 'includes/config/defaultgroups.php');
70
71 // cryptography module
72 require_once($SETTINGS['fspath'] . 'includes/config/crypt.php');
73
74 // load formatting functions
75 $F = new Format();
76
77 // language file
78 require($SETTINGS['fspath'] . 'includes/lang/' . $SETTINGS['language'] . '.php');
79
80 // input validation
81 require_once($SETTINGS['fspath'] . 'includes/input.php');
82
83 // open SQL connection
84 $C = new Connection();
85
86 // initialize session
87 Member::session();
88
89 // check if too many failed login attempts
90 if (Page::checkLogins()) {
91
92     // override global language setting with user preference if present
93     if ($_SESSION['lang'] != '') {
94         include($SETTINGS['fspath'] . 'includes/lang/' . $_SESSION['lang'] . '.php');
95         $LANGUAGE = $_SESSION['lang'];
96     } else {
97         $LANGUAGE = $SETTINGS['language'];
98     }
99
100     // construct requested page
101     $inc = ucfirst($INPUT['show']);
102     if (is_file($SETTINGS['fspath'] . 'admin/classes/pages/' . $inc . '.php') && is_readable($SETTINGS['fspath'] . 'admin/classes/pages/' . $inc . '.php')) {
103         if (isset($INPUT['id']) && $INPUT['id'] > 0) {
104             $page = new $inc($INPUT['id']);
105         } else {
106             $page = new $inc();
107         }
108     } else {
109         // 404
110         die($LANG['error_page_not_found']);
111     }
112
113     /* send output to browser;
114      * NOTHING is sent before apart from header data. The complete XML tree is only constructed in memory before to ensure it will be well-formed. Obviously, such a guarantee can't be given if it's sent 'on the fly'. */
115     $page->out(TRUE);
116
117     // close database connection
118     $C = NULL;
119
120     // destroy global formatting object
121     unset($F);
122
123     // everything done - page object no longer needed
124     unset($page);
125
126 }
127
128 ?>
Note: See TracBrowser for help on using the browser.