root/tags/5.2RC2/index.php

Revision 307, 3.6 kB (checked in by hannes, 3 years ago)

untested attempt at replacing member status with group based functionality

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 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
28 // if install script is present, redirect there
29 if (is_file('install.php')) {
30     header('Location: install.php');
31 }
32
33 // initialize global warnings array
34 $WARNINGS = Array();
35
36 // global settings file
37 require_once('includes/config/settings.php');
38
39 // load classes on demand; in spite of being spread over two directories, class names obviously have to be unique
40 function __autoload($class) {
41     global $SETTINGS;
42     if (is_file($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php')) {
43         require_once($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php');
44     } elseif (is_file($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php')) {
45         require_once($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php');
46     } else { die('Class ' . $class . ' not found.'); }
47 }
48
49 // list of time zones
50 require_once($SETTINGS['fspath'] . 'includes/config/timezones.php');
51
52 // import version number
53 require_once($SETTINGS['fspath'] . 'includes/config/version.php');
54
55 // bots definition
56 require_once($SETTINGS['fspath'] . 'includes/config/bots.php');
57
58 // get memberstages
59 require_once($SETTINGS['fspath'] . 'includes/config/memberstages.php');
60
61 // default usergroups
62 require_once($SETTINGS['fspath'] . 'includes/config/defaultgroups.php');
63
64 // cryptography module
65 require_once($SETTINGS['fspath'] . 'includes/config/crypt.php');
66
67 // load formatting functions
68 $F = new Format();
69
70 // language file
71 require($SETTINGS['fspath'] . 'includes/lang/' . $SETTINGS['language'] . '.php');
72
73 // input validation
74 require_once($SETTINGS['fspath'] . 'includes/input.php');
75
76 // open SQL connection
77 $C = new Connection();
78
79 // initialize session
80 Member::session();
81
82 // check if too many failed login attempts
83 if (Page::checkLogins()) {
84
85     // override global language setting with user preference if present
86     if ($_SESSION['lang'] != '') {
87         include($SETTINGS['fspath'] . 'includes/lang/' . $_SESSION['lang'] . '.php');
88         $LANGUAGE = $_SESSION['lang'];
89     } else {
90         $LANGUAGE = $SETTINGS['language'];
91     }
92
93     // construct requested page
94     $inc = ucfirst($INPUT['show']);
95     if (is_file($SETTINGS['fspath'] . 'classes/pages/' . $inc . '.php') && is_readable($SETTINGS['fspath'] . 'classes/pages/' . $inc . '.php')) {
96         if (isset($INPUT['id']) && $INPUT['id'] > 0) {
97             $page = new $inc($INPUT['id']);
98         } else {
99             $page = new $inc();
100         }
101     } else {
102         // 404
103         die($LANG['error_page_not_found']);
104     }
105
106     /* send output to browser;
107      * 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'. */
108     $page->out();
109
110     // close database connection
111     $C = NULL;
112
113     // destroy global formatting object
114     unset($F);
115
116     // everything done - page object no longer needed
117     unset($page);
118
119 }
120
121 ?>
Note: See TracBrowser for help on using the browser.