root/tags/5.1RC3/index.php

Revision 213, 3.5 kB (checked in by hannes, 3 years ago)

adding support for PostgreSQL databases (ticket #46)

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