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