author | Dan |
Sun, 02 Sep 2007 11:00:57 -0400 | |
changeset 5 | e3d7322305bf |
parent 4 | eb9ed4c366d0 |
permissions | -rw-r--r-- |
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 |
|
5 | 26 |
//define('PUN_DEBUG', 1); |
0 | 27 |
|
28 |
// This displays all executed queries in the page footer. |
|
29 |
// DO NOT enable this in a production environment! |
|
5 | 30 |
//define('PUN_SHOW_QUERIES', 1); |
0 | 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 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
38 |
// Load the compatibility layer between Pun's DBAL and Enano's DBAL |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
39 |
require PUN_ROOT.'include/enano_dbal.php'; |
0 | 40 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
41 |
// Reverse the effect of register_globals |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
42 |
// unregister_globals(); // DISABLED for Enano |
0 | 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 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
48 |
// Record the start time (will be used to calculate the generation time for the page) |
0 | 49 |
|
5 | 50 |
function get_microtime() |
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
51 |
{ |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
52 |
list($usec, $sec) = explode(' ', microtime()); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
53 |
return ((float)$usec + (float)$sec); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
54 |
} |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
55 |
|
5 | 56 |
$pun_start = get_microtime(); |
0 | 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. |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
59 |
error_reporting(E_ALL); |
0 | 60 |
|
61 |
// Turn off magic_quotes_runtime |
|
62 |
set_magic_quotes_runtime(0); |
|
63 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
64 |
/* |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
65 |
Disabled for Enano - this is already done by Enano's API |
0 | 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 |
} |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
78 |
*/ |
0 | 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); |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
89 |
define('PUN_ADMIN', USER_LEVEL_ADMIN); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
90 |
define('PUN_MOD', USER_LEVEL_MOD); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
91 |
define('PUN_GUEST', USER_LEVEL_GUEST); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
92 |
define('PUN_MEMBER', USER_LEVEL_MEMBER); |
0 | 93 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
94 |
/* |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
95 |
Skip this - Enano's API will handle it |
0 | 96 |
// Load DB abstraction layer and connect |
97 |
require PUN_ROOT.'include/dblayer/common_db.php'; |
|
98 |
||
99 |
// Start a transaction |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
100 |
$pun_db->start_transaction(); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
101 |
*/ |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
102 |
|
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
103 |
$GLOBALS['pun_db'] = new PunBB_DBAL_Enano(); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
104 |
$GLOBALS['pun_config'] = array(); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
105 |
|
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
106 |
$pun_config =& $GLOBALS['pun_config']; |
0 | 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 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
131 |
$GLOBALS['pun_user'] = array(); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
132 |
$pun_user =& $GLOBALS['pun_user']; |
0 | 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 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
141 |
if ($pun_config['o_maintenance'] && $pun_user['g_id'] < PUN_ADMIN && !defined('PUN_TURN_OFF_MAINT')) |
0 | 142 |
maintenance_message(); |
143 |
||
144 |
||
145 |
// Load cached bans |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
146 |
/* |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
147 |
// // DISABLED IN ENANO // // |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
148 |
// Enano has its own ban list // |
0 | 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(); |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
159 |
*/ |
0 | 160 |
|
161 |
// Update online list |
|
162 |
update_users_online(); |
|
163 |