forked from b2evolution/b2evolution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_config.php
More file actions
189 lines (165 loc) · 6.72 KB
/
_config.php
File metadata and controls
189 lines (165 loc) · 6.72 KB
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
<?php
/**
* This is b2evolution's main config file, which just includes all the other
* config files.
*
* This file should not be edited. You should edit the sub files instead.
*
* See {@link _basic_config.php} for the basic settings.
*
* @package conf
*/
if( defined('EVO_CONFIG_LOADED') )
{
return;
}
// HARD MAINTENANCE !
if( file_exists(dirname(__FILE__).'/maintenance.html') )
{ // Stop execution as soon as possible. This is useful while uploading new app files via FTP.
header('HTTP/1.0 503 Service Unavailable');
readfile(dirname(__FILE__).'/maintenance.html');
die();
}
elseif( file_exists(dirname(__FILE__).'/umaintenance.html') )
{ // Maintenance mode with a file - "umaintenance.html" with an "u" prevents access to the site but NOT to upgrade
$get_ctrl = isset( $_GET['ctrl'] ) ? $_GET['ctrl'] : ( isset( $_POST['ctrl'] ) ? $_POST['ctrl'] : '' );
// Check if the request is to the upgrade controller or it is an upgrade action request from the upgrade ctrl
$is_upgrade = ( ( $get_ctrl == 'upgrade' ) || ( ( substr( $_SERVER['PHP_SELF'], -17 ) == 'install/index.php' )
&& isset( $_GET['action'] ) && ( $_GET['action'] == 'auto_upgrade' ) ) ); // The request action is 'auto_upgrade'
if( ! $is_upgrade )
{ // NOT an upgrade
header('HTTP/1.0 503 Service Unavailable');
readfile(dirname(__FILE__).'/umaintenance.html');
die();
}
}
/**
* This makes sure the config does not get loaded twice in Windows
* (when the /conf file is in a path containing uppercase letters as in /Blog/conf).
*/
define( 'EVO_CONFIG_LOADED', true );
// basic settings
if( file_exists(dirname(__FILE__).'/_basic_config.php') )
{ // Use configured base config:
require_once dirname(__FILE__).'/_basic_config.php';
}
else
{ // Use default template:
require_once dirname(__FILE__).'/_basic_config.template.php';
}
// DEPRECATED -- You can now have a _basic_config.php file that will not be overwritten by new releases
if( file_exists(dirname(__FILE__).'/_config_TEST.php') )
{ // Put testing conf in there (For testing, you can also set $install_password here):
include_once dirname(__FILE__).'/_config_TEST.php'; // FOR TESTING / DEVELOPMENT OVERRIDES
}
if( empty($assets_baseurl) )
{ // We need to set this var before we continue:
$assets_baseurl = $baseurl;
}
require_once dirname(__FILE__).'/_advanced.php'; // advanced settings
require_once dirname(__FILE__).'/_locales.php'; // locale settings
require_once dirname(__FILE__).'/_formatting.php'; // formatting settings
require_once dirname(__FILE__).'/_stats.php'; // stats/hitlogging settings
require_once dirname(__FILE__).'/_application.php'; // application settings
global $app_pro;
if( isset( $app_pro ) && $app_pro === true )
{ // Load social settings only for PRO version:
require_once dirname(__FILE__).'/_social.php'; // social settings
}
if( file_exists(dirname(__FILE__).'/_local.php') )
{ // Override for local config in there:
include_once dirname(__FILE__).'/_local.php'; // Will not be overridden on upgrade.
}
elseif( file_exists(dirname(__FILE__).'/_overrides_TEST.php') )
{ // Legacy file (not recommended):
include_once dirname(__FILE__).'/_overrides_TEST.php'; // Will not be overridden on upgrade.
}
// Load to use evo_setcookie() for proper working with cookies on different domains from $baseurl:
require_once $inc_path.'sessions/model/_cookie.funcs.php';
// Handle debug cookie:
if( $debug == 'pwd' )
{ // Debug *can* be enabled/disabled by cookie:
// Disabled until we find a reason to enable:
$debug = 0;
if( !empty( $debug_pwd ) )
{ // We have configured a password that could enable debug mode:
if( isset( $_GET['debug'] ) )
{ // We have submitted a ?debug=password
if( $_GET['debug'] == $debug_pwd )
{ // Password matches
$debug = 1;
evo_setcookie( 'debug', $debug_pwd, 0, $cookie_path, $cookie_domain, false, true );
}
else
{ // Password doesn't match: turn off debug mode:
evo_setcookie( 'debug', '', $cookie_expired, $cookie_path, $cookie_domain, false, true );
}
}
elseif( !empty( $_COOKIE['debug'] ) && $_COOKIE['debug'] == $debug_pwd )
{ // We have a cookie with the correct debug password:
$debug = 1;
}
}
}
// Handle debug jslog cookie:
if( $debug_jslog == 'pwd' )
{ // Debug *can* be enabled/disabled by cookie:
// Disabled until we find a reason to enable:
$debug_jslog = 0;
if( !empty( $debug_pwd ) )
{ // We have configured a password that could enable debug mode:
if( isset( $_GET['jslog'] ) )
{ // We have submitted a ?jslog=password
if( $_GET['jslog'] == $debug_pwd )
{ // Password matches
$debug_jslog = 1;
evo_setcookie( 'jslog', $debug_pwd, 0, '/' );
}
else
{ // Password doesn't match: turn off debug mode:
evo_setcookie( 'jslog', '', $cookie_expired, '/' );
if( !empty( $_COOKIE['jslog_style'] ) )
{ // Change the saved styles to hide jslog
$_COOKIE['jslog_style'] = str_replace( 'display: block', 'display: none', $_COOKIE['jslog_style'] );
evo_setcookie( 'jslog_style', $_COOKIE['jslog_style'], 0, '/' );
}
}
}
elseif( !empty( $_COOKIE['jslog'] ) && $_COOKIE['jslog'] == $debug_pwd )
{ // We have a cookie with the correct debug password:
$debug_jslog = 1;
if( !empty( $_COOKIE['jslog_style'] ) )
{ // Change the saved styles to show jslog
$_COOKIE['jslog_style'] = str_replace( 'display: none', 'display: block', $_COOKIE['jslog_style'] );
evo_setcookie( 'jslog_style', $_COOKIE['jslog_style'], 0, '/' );
}
}
}
}
// To help debugging severe errors, you'll probably want PHP to display the errors on screen.
if( $debug > 0 || $display_errors_on_production )
{ // We are debugging or we want to display errors on screen production anyways:
@ini_set( 'display_errors', 'On' );
}
else
{ // Do not display errors on screen:
@ini_set( 'display_errors', 'Off' );
}
// Check compatibility. Server PHP version can't be lower than the application's required PHP version.
$php_version = phpversion();
if( version_compare( $php_version, $required_php_version[ 'application' ], '<' ) )
{
$compat = sprintf( 'You cannot use %1$s %2$s on this server because it requires PHP version %3$s or higher. You are running version %4$s.',
$app_name, $app_version, $required_php_version[ 'application' ], $php_version );
die('<h1>Insufficient Requirements</h1><p>'.$compat.'</p>');
}
// Check timezone setting:
$date_timezone = ini_get( "date.timezone" );
if( ( !empty( $date_default_timezone ) || empty( $date_timezone ) ) )
{ // Set default timezone if $date_default_timezone is set or php.ini 'date.timezone' setting was not set
date_default_timezone_set( empty( $date_default_timezone ) ? 'Europe/Paris' : $date_default_timezone );
}
// STUFF THAT SHOULD BE INITIALIZED (to avoid param injection on badly configured PHP)
$use_db = true;
$use_session = true;
?>