This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
gp-settings.php
371 lines (296 loc) · 11.7 KB
/
gp-settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<?php
/**
* Loads needed libraries and does the preliminary work. You should not have to
* edit this file. Everything should be configurable from the outside. Starts the
* routing logic in the end.
*/
if ( defined( 'GP_DEBUG' ) && GP_DEBUG ) {
error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
} else {
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
}
require_once( GP_PATH . GP_INC . '/system.php' );
gp_unregister_GLOBALS();
if ( !defined( 'BACKPRESS_PATH' ) ) {
define( 'BACKPRESS_PATH', GP_PATH . GP_INC . 'backpress/' );
}
if ( !defined( 'GP_POMO_PATH' ) ) {
define( 'GP_POMO_PATH', GP_PATH . 'pomo/' );
}
if ( !defined( 'GP_LOCALES_PATH' ) ) {
define( 'GP_LOCALES_PATH', GP_PATH . 'locales/' );
}
if ( !defined( 'GP_LANG_PATH' ) ) {
define( 'GP_LANG_PATH', GP_PATH . 'languages/' );
}
if ( !defined( 'GP_PLUGINS_PATH' ) ) {
define( 'GP_PLUGINS_PATH', GP_PATH . 'plugins/' );
}
if ( !defined( 'DATE_MYSQL' ) ) {
define( 'DATE_MYSQL', 'Y-m-d H:i:s' );
}
if ( !defined( 'GP_TESTS_PATH' ) ) {
define( 'GP_TESTS_PATH', GP_PATH . 't/' );
}
require_once( GP_PATH . GP_INC . 'gp.php');
/*
* In most cases the default internal encoding is latin1, which is of no use,
* since we want to use the mb_ functions for UTF-8 strings
*/
if (function_exists('mb_internal_encoding')) {
mb_internal_encoding('UTF-8');
}
require_once( BACKPRESS_PATH . 'class.bp-log.php' );
$gp_log = new BP_Log();
if ( defined( 'GP_LOG_LEVEL' ) ) {
$gp_log->set_level( GP_LOG_LEVEL );
}
if ( defined( 'GP_LOG_TYPE' ) ) {
$gp_log->set_type( GP_LOG_TYPE );
}
if ( defined( 'GP_LOG_FILENAME' ) ) {
$gp_log->set_filename( GP_LOG_FILENAME );
}
$gp_log->notice('Logging started');
// Load core BackPress functions
require_once( BACKPRESS_PATH . 'functions.core.php' );
require_once( BACKPRESS_PATH . 'functions.compat.php' );
require_once( BACKPRESS_PATH . 'functions.formatting.php' );
// alleviate the magic_quotes_gpc effects
if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes_deep( $_GET );
$_POST = stripslashes_deep( $_POST );
$_COOKIE = stripslashes_deep( $_COOKIE );
}
$_GET = gp_urldecode_deep( $_GET );
require_once( BACKPRESS_PATH . 'class.wp-error.php' );
if ( !defined( 'GP_DATABASE_CLASS_INCLUDE' ) ) {
define( 'GP_DATABASE_CLASS_INCLUDE', BACKPRESS_PATH . 'class.bpdb-multi.php' );
}
if ( GP_DATABASE_CLASS_INCLUDE ) {
require_once( GP_DATABASE_CLASS_INCLUDE );
}
if ( !defined( 'GP_DATABASE_CLASS' ) ) {
define( 'GP_DATABASE_CLASS', 'BPDB_Multi' );
}
if ( in_array( GP_DATABASE_CLASS, array( 'BPDB', 'BPDB_Multi' ) ) ) {
/**
* Define BackPress Database errors if not already done - no localisation at this stage
*/
if ( !defined( 'BPDB__CONNECT_ERROR_MESSAGE' ) ) {
define( 'BPDB__CONNECT_ERROR_MESSAGE', 'ERROR: Could not establish a database connection' );
}
if ( !defined( 'BPDB__CONNECT_ERROR_MESSAGE' ) ) {
define( 'BPDB__SELECT_ERROR_MESSAGE', 'ERROR: Can\'t select database.' );
}
if ( !defined( 'BPDB__ERROR_STRING' ) ) {
define( 'BPDB__ERROR_STRING', 'ERROR: GlotPress database error - "%s" for query "%s" via caller "%s"' );
}
if ( !defined( 'BPDB__ERROR_HTML' ) ) {
define( 'BPDB__ERROR_HTML', '<div id="error"><p class="bpdberror"><strong>Database error:</strong> [%s]<br /><code>%s</code><br />Caller: %s</p></div>' );
}
if ( !defined( 'BPDB__DB_VERSION_ERROR' ) ) {
define( 'BPDB__DB_VERSION_ERROR', 'ERROR: GlotPress requires MySQL 4.0.0 or higher' );
}
if ( !defined( 'BPDB__PHP_EXTENSION_MISSING' ) ) {
define( 'BPDB__PHP_EXTENSION_MISSING', 'ERROR: GlotPress requires The MySQL PHP extension' );
}
}
// Die if there is no database table prefix
if ( !$gp_table_prefix ) {
die( 'You must specify a table prefix in your <code>gp-config.php</code> file.' );
}
// Setup the global database connection
$gpdb_class = GP_DATABASE_CLASS;
$gpdb = new $gpdb_class( array(
'name' => GPDB_NAME,
'user' => GPDB_USER,
'password' => GPDB_PASSWORD,
'host' => GPDB_HOST,
'charset' => defined( 'GPDB_CHARSET' ) ? GPDB_CHARSET : false,
'collate' => defined( 'GPDB_COLLATE' ) ? GPDB_COLLATE : false
) );
unset( $gpdb_class );
$gpdb->table_names = array('translations', 'translation_sets', 'glossaries', 'glossary_entries', 'originals', 'projects', 'users', 'usermeta', 'meta', 'permissions', 'api_keys', );
foreach( $gpdb->table_names as $table ) {
$gpdb->tables[$table] = false;
}
unset( $table );
// Set the prefix on the tables
if ( is_wp_error( $gpdb->set_prefix( $gp_table_prefix ) ) ) {
die( 'Your table prefix may only contain letters, numbers and underscores.' );
}
if ( defined( 'CUSTOM_USER_TABLE' ) )
$gpdb->users = CUSTOM_USER_TABLE;
if ( defined( 'CUSTOM_USER_META_TABLE' ) )
$gpdb->usermeta = CUSTOM_USER_META_TABLE;
if ( defined( 'CUSTOM_PERMISSIONS_TABLE' ) )
$gpdb->permissions = CUSTOM_PERMISSIONS_TABLE;
if ( !function_exists( 'add_filter' ) ) {
require_once( BACKPRESS_PATH . 'functions.plugin-api.php' );
}
if ( !defined( 'GP_TMPL_PATH' ) )
define( 'GP_TMPL_PATH', GP_PATH . 'gp-templates/' );
// Functions that aren't used anymore.
require_once( GP_PATH . GP_INC . 'deprecated.php');
require_once( GP_PATH . GP_INC . 'meta.php' );
require_once( GP_PATH . GP_INC . 'misc.php' );
require_once( GP_PATH . GP_INC . 'url.php' );
require_once( GP_PATH . GP_INC . 'strings.php' );
require_once( GP_PATH . GP_INC . 'template.php' );
require_once( GP_PATH . GP_INC . 'template-links.php' );
require_once( GP_PATH . GP_INC . 'cli.php' );
/**
* Define the full path to the object cache functions include
*/
if ( !defined( 'GP_OBJECT_CACHE_FUNCTIONS_INCLUDE' ) ) {
define( 'GP_OBJECT_CACHE_FUNCTIONS_INCLUDE', BACKPRESS_PATH . 'loader.wp-object-cache.php' );
}
// Load the database class
if ( GP_OBJECT_CACHE_FUNCTIONS_INCLUDE && !function_exists( 'wp_cache_init' ) ) {
require_once( GP_OBJECT_CACHE_FUNCTIONS_INCLUDE );
}
// Instantiate the $wp_object_cache object using wp_cache_init()
if ( !isset( $wp_object_cache ) && function_exists( 'wp_cache_init' ) ) {
wp_cache_init();
if ( function_exists( 'wp_cache_add_global_groups' ) ) {
wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'usermail', 'usernicename' ) );
}
}
require_once( GP_PATH . GP_INC . 'class.bp-options.php' );
require_once( BACKPRESS_PATH . 'functions.bp-options.php' );
require_once( BACKPRESS_PATH . 'class.wp-http.php' );
require_once( BACKPRESS_PATH . 'class.wp-dependencies.php' );
require_once( BACKPRESS_PATH . 'class.wp-styles.php' );
require_once( BACKPRESS_PATH . 'functions.wp-styles.php' );
require_once( BACKPRESS_PATH . 'class.wp-scripts.php' );
require_once( BACKPRESS_PATH . 'functions.wp-scripts.php' );
require_once( GP_PATH . GP_INC . 'assets-loader.php' );
require_once( GP_PATH . GP_INC . 'default-filters.php' );
require_once( BACKPRESS_PATH . 'functions.kses.php' );
require_once( GP_POMO_PATH . 'mo.php' );
require_once( GP_POMO_PATH . 'po.php' );
require_once( GP_PATH . GP_INC . 'l10n.php' );
require_once( GP_LOCALES_PATH . 'locales.php' );
if ( defined('GP_LANG') )
load_default_textdomain();
// Users and authentication
if ( !class_exists( 'WP_Users' ) ) {
require_once( BACKPRESS_PATH . 'class.wp-users.php' );
$wp_users_object = new WP_Users( $gpdb );
}
if ( !defined( 'WP_AUTH_COOKIE_VERSION' ) ) {
define( 'WP_AUTH_COOKIE_VERSION', 2 );
}
// WP_Pass
if ( !class_exists( 'WP_Pass' ) ) {
require_once( BACKPRESS_PATH . 'class.wp-pass.php' );
}
// We assume all variables set in this file will be global.
// If the file is inovked inside a function, we will lose them all.
// So, make all local variables, global
gp_set_globals( get_defined_vars() );
/**
* It is possible to define this in wp-config.php and it will be used as the domain for all cookies.
* Set it carefully for sharing cookies amonst subdomains
*
* @link http://curl.haxx.se/rfc/cookie_spec.html
*/
if ( !defined('GP_COOKIE_DOMAIN') )
define('GP_COOKIE_DOMAIN', false);
if ( !class_exists( 'WP_Auth' ) ) {
require_once( BACKPRESS_PATH . 'class.wp-auth.php' );
$cookies = array();
$cookies['auth'][] = array(
'domain' => GP_COOKIE_DOMAIN,
'path' => gp_url_path(),
'name' => gp_const_get( 'GP_AUTH_COOKIE', 'glotpress_auth' ),
);
$cookies['secure_auth'][] = array(
'domain' => GP_COOKIE_DOMAIN,
'path' => gp_url_path(),
'name' => gp_const_get( 'GP_SECURE_AUTH_COOKIE', 'glotpress_sec_auth' ),
'secure' => 'true',
);
$cookies['logged_in'][] = array(
'domain' => GP_COOKIE_DOMAIN,
'path' => gp_url_path(),
'name' => gp_const_get( 'GP_LOGGED_IN_COOKIE', 'glotpress_logged_in' ),
);
$wp_auth_object = new WP_Auth( $gpdb, $wp_users_object, $cookies );
unset( $cookies );
}
require_once( GP_PATH . GP_INC . 'warnings.php' );
require_once( GP_PATH . GP_INC . 'validation.php' );
require_once( GP_PATH . GP_INC . 'advanced-permissions.php' );
require_once GP_PATH . GP_INC . 'thing.php';
require_once GP_PATH . GP_INC . 'things/original.php';
require_once GP_PATH . GP_INC . 'things/permission.php';
require_once GP_PATH . GP_INC . 'things/project.php';
require_once GP_PATH . GP_INC . 'things/translation-set.php';
require_once GP_PATH . GP_INC . 'things/translation.php';
require_once GP_PATH . GP_INC . 'things/user.php';
require_once GP_PATH . GP_INC . 'things/validator-permission.php';
require_once GP_PATH . GP_INC . 'things/glossary.php';
require_once GP_PATH . GP_INC . 'things/glossary-entry.php';
require_once( GP_PATH . GP_INC . 'route.php' );
require_once( GP_PATH . GP_INC . 'router.php' );
require_once GP_PATH . GP_INC . 'routes/_main.php';
require_once GP_PATH . GP_INC . 'routes/index.php';
require_once GP_PATH . GP_INC . 'routes/login.php';
require_once GP_PATH . GP_INC . 'routes/original.php';
require_once GP_PATH . GP_INC . 'routes/profile.php';
require_once GP_PATH . GP_INC . 'routes/project.php';
require_once GP_PATH . GP_INC . 'routes/translation-set.php';
require_once GP_PATH . GP_INC . 'routes/translation.php';
require_once GP_PATH . GP_INC . 'routes/glossary.php';
require_once GP_PATH . GP_INC . 'routes/glossary-entry.php';
require_once GP_PATH . GP_INC . 'routes/locale.php';
GP::$translation_warnings = new GP_Translation_Warnings();
GP::$builtin_translation_warnings = new GP_Builtin_Translation_Warnings();
GP::$builtin_translation_warnings->add_all( GP::$translation_warnings );
GP::$router = new GP_Router();
GP::$formats = array();
require_once GP_PATH . GP_INC . 'format.php';
require_once GP_PATH . GP_INC . 'formats/format_android.php';
require_once GP_PATH . GP_INC . 'formats/format_pomo.php';
require_once GP_PATH . GP_INC . 'formats/format_resx.php';
require_once GP_PATH . GP_INC . 'formats/format_strings.php';
// Let's do it again, there are more variables added since last time we called it
gp_set_globals( get_defined_vars() );
require_once( GP_PATH . GP_INC . 'plugin.php' );
$plugins = scandir( GP_PLUGINS_PATH );
foreach ( $plugins as $plugin ) {
if ( is_dir( GP_PLUGINS_PATH . '/' . $plugin ) ) {
if ( is_readable( GP_PLUGINS_PATH . "/$plugin/$plugin.php" ) )
require_once GP_PLUGINS_PATH . "/$plugin/$plugin.php";
} else if ( substr( $plugin, -4 ) == '.php' ) {
require_once GP_PLUGINS_PATH . $plugin;
}
}
unset( $plugins, $plugin );
GP::$router->set_default_routes();
do_action( 'plugins_loaded' );
if ( defined( 'GP_INSTALLING' ) && GP_INSTALLING )
return;
else
define( 'GP_INSTALLING', false );
if ( !defined( 'GP_ROUTING') ) {
define( 'GP_ROUTING', false );
}
if ( ( !defined( 'GP_INSTALLING' ) || !GP_INSTALLING ) && !gp_is_installed() ) {
if ( GP_ROUTING ) {
$install_uri = preg_replace( '|/[^/]+?$|', '/', $_SERVER['PHP_SELF'] ) . 'install.php';
header( 'Location: ' . $install_uri );
}
return;
}
gp_populate_notices();
function gp_shutdown_action_hook() {
do_action( 'shutdown' );
}
register_shutdown_function( 'gp_shutdown_action_hook' );
do_action( 'init' );
if ( GP_ROUTING ) {
GP::$router->route();
}