root/trunk/index.php

Revision 407, 3.7 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: index.php
6  * Description: wrapper file calling all the others directly or indirectly
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'] . 'classes/pages/' . $class . '.php')) {
47         require_once($SETTINGS['fspath'] . '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 // list of time zones
54 require_once($SETTINGS['fspath'] . 'includes/config/timezones.php');
55
56 // import version number
57 require_once($SETTINGS['fspath'] . 'includes/config/version.php');
58
59 // bots definition
60 require_once($SETTINGS['fspath'] . 'includes/config/bots.php');
61
62 // get memberstages
63 require_once($SETTINGS['fspath'] . 'includes/config/memberstages.php');
64
65 // default usergroups
66 require_once($SETTINGS['fspath'] . 'includes/config/defaultgroups.php');
67
68 // cryptography module
69 require_once($SETTINGS['fspath'] . 'includes/config/crypt.php');
70
71 // load formatting functions
72 $F = new Format();
73
74 // language file
75 require($SETTINGS['fspath'] . 'includes/lang/' . $SETTINGS['language'] . '.php');
76
77 // input validation
78 require_once($SETTINGS['fspath'] . 'includes/input.php');
79
80 // open SQL connection
81 $C = new Connection();
82
83 // initialize session
84 Member::session();
85
86 // check if too many failed login attempts
87 if (Page::checkLogins()) {
88
89     // override global language setting with user preference if present
90     if ($_SESSION['lang'] != '') {
91         include($SETTINGS['fspath'] . 'includes/lang/' . $_SESSION['lang'] . '.php');
92         $LANGUAGE = $_SESSION['lang'];
93     } else {
94         $LANGUAGE = $SETTINGS['language'];
95     }
96
97     // construct requested page
98     $inc = ucfirst($INPUT['show']);
99     if (is_file($SETTINGS['fspath'] . 'classes/pages/' . $inc . '.php') && is_readable($SETTINGS['fspath'] . 'classes/pages/' . $inc . '.php')) {
100         if (isset($INPUT['id']) && $INPUT['id'] > 0) {
101             $page = new $inc($INPUT['id']);
102         } else {
103             $page = new $inc();
104         }
105     } else {
106         // 404
107         die($LANG['error_page_not_found']);
108     }
109
110     /* send output to browser;
111      * 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'. */
112     $page->out();
113
114     // close database connection
115     $C = NULL;
116
117     // destroy global formatting object
118     unset($F);
119
120     // everything done - page object no longer needed
121     unset($page);
122
123 }
124
125 ?>
Note: See TracBrowser for help on using the browser.