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 // Load the functions script |
|
36 require PUN_ROOT.'include/functions.php'; |
|
37 |
|
38 // Load the compatibility layer between Pun's DBAL and Enano's DBAL |
|
39 require PUN_ROOT.'include/enano_dbal.php'; |
|
40 |
|
41 // Reverse the effect of register_globals |
|
42 // unregister_globals(); // DISABLED for Enano |
|
43 |
|
44 // If PUN isn't defined, config.php is missing or corrupt |
|
45 if (!defined('PUN')) |
|
46 exit('The file \'config.php\' doesn\'t exist or is corrupt. Please run <a href="install.php">install.php</a> to install PunBB first.'); |
|
47 |
|
48 // Record the start time (will be used to calculate the generation time for the page) |
|
49 |
|
50 function get_microtime() |
|
51 { |
|
52 list($usec, $sec) = explode(' ', microtime()); |
|
53 return ((float)$usec + (float)$sec); |
|
54 } |
|
55 |
|
56 $pun_start = get_microtime(); |
|
57 |
|
58 // Make sure PHP reports all errors except E_NOTICE. PunBB supports E_ALL, but a lot of scripts it may interact with, do not. |
|
59 error_reporting(E_ALL); |
|
60 |
|
61 // Turn off magic_quotes_runtime |
|
62 set_magic_quotes_runtime(0); |
|
63 |
|
64 /* |
|
65 Disabled for Enano - this is already done by Enano's API |
|
66 // Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled) |
|
67 if (get_magic_quotes_gpc()) |
|
68 { |
|
69 function stripslashes_array($array) |
|
70 { |
|
71 return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array); |
|
72 } |
|
73 |
|
74 $_GET = stripslashes_array($_GET); |
|
75 $_POST = stripslashes_array($_POST); |
|
76 $_COOKIE = stripslashes_array($_COOKIE); |
|
77 } |
|
78 */ |
|
79 |
|
80 // Seed the random number generator |
|
81 mt_srand((double)microtime()*1000000); |
|
82 |
|
83 // If a cookie name is not specified in config.php, we use the default (punbb_cookie) |
|
84 if (empty($cookie_name)) |
|
85 $cookie_name = 'punbb_cookie'; |
|
86 |
|
87 // Define a few commonly used constants |
|
88 define('PUN_UNVERIFIED', 32000); |
|
89 define('PUN_ADMIN', USER_LEVEL_ADMIN); |
|
90 define('PUN_MOD', USER_LEVEL_MOD); |
|
91 define('PUN_GUEST', USER_LEVEL_GUEST); |
|
92 define('PUN_MEMBER', USER_LEVEL_MEMBER); |
|
93 |
|
94 /* |
|
95 Skip this - Enano's API will handle it |
|
96 // Load DB abstraction layer and connect |
|
97 require PUN_ROOT.'include/dblayer/common_db.php'; |
|
98 |
|
99 // Start a transaction |
|
100 $pun_db->start_transaction(); |
|
101 */ |
|
102 |
|
103 $GLOBALS['pun_db'] = new PunBB_DBAL_Enano(); |
|
104 $GLOBALS['pun_config'] = array(); |
|
105 |
|
106 $pun_config =& $GLOBALS['pun_config']; |
|
107 |
|
108 // Load cached config |
|
109 @include PUN_ROOT.'cache/cache_config.php'; |
|
110 if (!defined('PUN_CONFIG_LOADED')) |
|
111 { |
|
112 require PUN_ROOT.'include/cache.php'; |
|
113 generate_config_cache(); |
|
114 require PUN_ROOT.'cache/cache_config.php'; |
|
115 } |
|
116 |
|
117 // Enable output buffering |
|
118 if (!defined('PUN_DISABLE_BUFFERING')) |
|
119 { |
|
120 // For some very odd reason, "Norton Internet Security" unsets this |
|
121 $_SERVER['HTTP_ACCEPT_ENCODING'] = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : ''; |
|
122 |
|
123 // Should we use gzip output compression? |
|
124 if ($pun_config['o_gzip'] && extension_loaded('zlib') && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false || strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== false)) |
|
125 ob_start('ob_gzhandler'); |
|
126 else |
|
127 ob_start(); |
|
128 } |
|
129 |
|
130 // Check/update/set cookie and fetch user info |
|
131 $GLOBALS['pun_user'] = array(); |
|
132 $pun_user =& $GLOBALS['pun_user']; |
|
133 check_cookie($pun_user); |
|
134 |
|
135 // Attempt to load the common language file |
|
136 @include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php'; |
|
137 if (!isset($lang_common)) |
|
138 exit('There is no valid language pack \''.pun_htmlspecialchars($pun_user['language']).'\' installed. Please reinstall a language of that name.'); |
|
139 |
|
140 // Check if we are to display a maintenance message |
|
141 if ($pun_config['o_maintenance'] && $pun_user['g_id'] < PUN_ADMIN && !defined('PUN_TURN_OFF_MAINT')) |
|
142 maintenance_message(); |
|
143 |
|
144 |
|
145 // Load cached bans |
|
146 /* |
|
147 // // DISABLED IN ENANO // // |
|
148 // Enano has its own ban list // |
|
149 @include PUN_ROOT.'cache/cache_bans.php'; |
|
150 if (!defined('PUN_BANS_LOADED')) |
|
151 { |
|
152 require_once PUN_ROOT.'include/cache.php'; |
|
153 generate_bans_cache(); |
|
154 require PUN_ROOT.'cache/cache_bans.php'; |
|
155 } |
|
156 |
|
157 // Check if current user is banned |
|
158 check_bans(); |
|
159 */ |
|
160 |
|
161 // Update online list |
|
162 update_users_online(); |
|
163 |
|