0
|
1 |
<?php
|
|
2 |
/***********************************************************************
|
|
3 |
|
|
4 |
Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
|
|
5 |
|
|
6 |
This file is part of PunBB.
|
|
7 |
|
|
8 |
PunBB is free software; you can redistribute it and/or modify it
|
|
9 |
under the terms of the GNU General Public License as published
|
|
10 |
by the Free Software Foundation; either version 2 of the License,
|
|
11 |
or (at your option) any later version.
|
|
12 |
|
|
13 |
PunBB is distributed in the hope that it will be useful, but
|
|
14 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
GNU General Public License for more details.
|
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License
|
|
19 |
along with this program; if not, write to the Free Software
|
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
21 |
MA 02111-1307 USA
|
|
22 |
|
|
23 |
************************************************************************/
|
|
24 |
|
|
25 |
// Enable DEBUG mode by removing // from the following line
|
|
26 |
//define('PUN_DEBUG', 1);
|
|
27 |
|
|
28 |
// This displays all executed queries in the page footer.
|
|
29 |
// DO NOT enable this in a production environment!
|
|
30 |
//define('PUN_SHOW_QUERIES', 1);
|
|
31 |
|
|
32 |
if (!defined('PUN_ROOT'))
|
|
33 |
exit('The constant PUN_ROOT must be defined and point to a valid PunBB installation root directory.');
|
|
34 |
|
|
35 |
|
|
36 |
// Load the functions script
|
|
37 |
require PUN_ROOT.'include/functions.php';
|
|
38 |
|
|
39 |
// Reverse the effect of register_globals
|
|
40 |
unregister_globals();
|
|
41 |
|
|
42 |
|
|
43 |
@include PUN_ROOT.'config.php';
|
|
44 |
|
|
45 |
// If PUN isn't defined, config.php is missing or corrupt
|
|
46 |
if (!defined('PUN'))
|
|
47 |
exit('The file \'config.php\' doesn\'t exist or is corrupt. Please run <a href="install.php">install.php</a> to install PunBB first.');
|
|
48 |
|
|
49 |
|
|
50 |
// Record the start time (will be used to calculate the generation time for the page)
|
|
51 |
list($usec, $sec) = explode(' ', microtime());
|
|
52 |
$pun_start = ((float)$usec + (float)$sec);
|
|
53 |
|
|
54 |
// Make sure PHP reports all errors except E_NOTICE. PunBB supports E_ALL, but a lot of scripts it may interact with, do not.
|
|
55 |
error_reporting(E_ALL ^ E_NOTICE);
|
|
56 |
|
|
57 |
// Turn off magic_quotes_runtime
|
|
58 |
set_magic_quotes_runtime(0);
|
|
59 |
|
|
60 |
// Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
|
|
61 |
if (get_magic_quotes_gpc())
|
|
62 |
{
|
|
63 |
function stripslashes_array($array)
|
|
64 |
{
|
|
65 |
return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
|
|
66 |
}
|
|
67 |
|
|
68 |
$_GET = stripslashes_array($_GET);
|
|
69 |
$_POST = stripslashes_array($_POST);
|
|
70 |
$_COOKIE = stripslashes_array($_COOKIE);
|
|
71 |
}
|
|
72 |
|
|
73 |
// Seed the random number generator
|
|
74 |
mt_srand((double)microtime()*1000000);
|
|
75 |
|
|
76 |
// If a cookie name is not specified in config.php, we use the default (punbb_cookie)
|
|
77 |
if (empty($cookie_name))
|
|
78 |
$cookie_name = 'punbb_cookie';
|
|
79 |
|
|
80 |
// Define a few commonly used constants
|
|
81 |
define('PUN_UNVERIFIED', 32000);
|
|
82 |
define('PUN_ADMIN', 1);
|
|
83 |
define('PUN_MOD', 2);
|
|
84 |
define('PUN_GUEST', 3);
|
|
85 |
define('PUN_MEMBER', 4);
|
|
86 |
|
|
87 |
|
|
88 |
// Load DB abstraction layer and connect
|
|
89 |
require PUN_ROOT.'include/dblayer/common_db.php';
|
|
90 |
|
|
91 |
// Start a transaction
|
|
92 |
$db->start_transaction();
|
|
93 |
|
|
94 |
// Load cached config
|
|
95 |
@include PUN_ROOT.'cache/cache_config.php';
|
|
96 |
if (!defined('PUN_CONFIG_LOADED'))
|
|
97 |
{
|
|
98 |
require PUN_ROOT.'include/cache.php';
|
|
99 |
generate_config_cache();
|
|
100 |
require PUN_ROOT.'cache/cache_config.php';
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
// Enable output buffering
|
|
105 |
if (!defined('PUN_DISABLE_BUFFERING'))
|
|
106 |
{
|
|
107 |
// For some very odd reason, "Norton Internet Security" unsets this
|
|
108 |
$_SERVER['HTTP_ACCEPT_ENCODING'] = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : '';
|
|
109 |
|
|
110 |
// Should we use gzip output compression?
|
|
111 |
if ($pun_config['o_gzip'] && extension_loaded('zlib') && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false || strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== false))
|
|
112 |
ob_start('ob_gzhandler');
|
|
113 |
else
|
|
114 |
ob_start();
|
|
115 |
}
|
|
116 |
|
|
117 |
|
|
118 |
// Check/update/set cookie and fetch user info
|
|
119 |
$pun_user = array();
|
|
120 |
check_cookie($pun_user);
|
|
121 |
|
|
122 |
// Attempt to load the common language file
|
|
123 |
@include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
|
|
124 |
if (!isset($lang_common))
|
|
125 |
exit('There is no valid language pack \''.pun_htmlspecialchars($pun_user['language']).'\' installed. Please reinstall a language of that name.');
|
|
126 |
|
|
127 |
// Check if we are to display a maintenance message
|
|
128 |
if ($pun_config['o_maintenance'] && $pun_user['g_id'] > PUN_ADMIN && !defined('PUN_TURN_OFF_MAINT'))
|
|
129 |
maintenance_message();
|
|
130 |
|
|
131 |
|
|
132 |
// Load cached bans
|
|
133 |
@include PUN_ROOT.'cache/cache_bans.php';
|
|
134 |
if (!defined('PUN_BANS_LOADED'))
|
|
135 |
{
|
|
136 |
require_once PUN_ROOT.'include/cache.php';
|
|
137 |
generate_bans_cache();
|
|
138 |
require PUN_ROOT.'cache/cache_bans.php';
|
|
139 |
}
|
|
140 |
|
|
141 |
// Check if current user is banned
|
|
142 |
check_bans();
|
|
143 |
|
|
144 |
|
|
145 |
// Update online list
|
|
146 |
update_users_online();
|
|
147 |
|