|
@@ -1,7 +1,7 @@ discard block |
|
|
block discarded – undo |
|
1
|
1
|
<?php |
|
2
|
2
|
|
|
3
|
3
|
// Защита от двойного инита |
|
4
|
|
-if(defined('INIT')) { |
|
|
4
|
+if (defined('INIT')) { |
|
5
|
5
|
return; |
|
6
|
6
|
} |
|
7
|
7
|
|
|
@@ -20,22 +20,22 @@ discard block |
|
|
block discarded – undo |
|
20
|
20
|
version_compare(PHP_VERSION, '5.3.2') < 0 ? die('FATAL ERROR: SuperNova REQUIRE PHP version > 5.3.2') : false; |
|
21
|
21
|
|
|
22
|
22
|
// Бенчмарк |
|
23
|
|
-register_shutdown_function(function () { |
|
24
|
|
- if(defined('IN_AJAX')) { |
|
|
23
|
+register_shutdown_function(function() { |
|
|
24
|
+ if (defined('IN_AJAX')) { |
|
25
|
25
|
return; |
|
26
|
26
|
} |
|
27
|
27
|
|
|
28
|
28
|
global $user, $locale_cache_statistic; |
|
29
|
29
|
|
|
30
|
|
- print('<hr><div class="benchmark">Benchmark ' . (microtime(true) - SN_TIME_MICRO) . 's, memory: ' . number_format(memory_get_usage() - SN_MEM_START) . |
|
31
|
|
- (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') . |
|
32
|
|
- (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') . |
|
|
30
|
+ print('<hr><div class="benchmark">Benchmark '.(microtime(true) - SN_TIME_MICRO).'s, memory: '.number_format(memory_get_usage() - SN_MEM_START). |
|
|
31
|
+ (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : ''). |
|
|
32
|
+ (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: '.classSupernova::$db->time_mysql_total.'ms' : ''). |
|
33
|
33
|
'</div>'); |
|
34
|
|
- if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
|
34
|
+ if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL.'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL.'badqrys.txt') > 0) { |
|
35
|
35
|
echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>'; |
|
36
|
36
|
} |
|
37
|
37
|
|
|
38
|
|
- if(!empty($locale_cache_statistic['misses'])) { |
|
|
38
|
+ if (!empty($locale_cache_statistic['misses'])) { |
|
39
|
39
|
print('<!--'); |
|
40
|
40
|
pdump($locale_cache_statistic); |
|
41
|
41
|
print('-->'); |
|
@@ -55,7 +55,7 @@ discard block |
|
|
block discarded – undo |
|
55
|
55
|
|
|
56
|
56
|
define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW)); |
|
57
|
57
|
|
|
58
|
|
-if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
|
58
|
+if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
59
|
59
|
define('SN_GOOGLE', true); |
|
60
|
60
|
} |
|
61
|
61
|
|
|
@@ -74,12 +74,12 @@ discard block |
|
|
block discarded – undo |
|
74
|
74
|
$sn_root_relative = str_replace($sn_root_relative, '', $_SERVER['SCRIPT_NAME']); |
|
75
|
75
|
define('SN_ROOT_RELATIVE', $sn_root_relative); |
|
76
|
76
|
|
|
77
|
|
-define('SN_ROOT_VIRTUAL', 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . SN_ROOT_RELATIVE); |
|
|
77
|
+define('SN_ROOT_VIRTUAL', 'http'.(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '').'://'.$_SERVER['HTTP_HOST'].SN_ROOT_RELATIVE); |
|
78
|
78
|
define('SN_ROOT_VIRTUAL_PARENT', str_replace('//google.', '//', SN_ROOT_VIRTUAL)); |
|
79
|
79
|
|
|
80
|
80
|
$phpEx = strpos($phpEx = substr(strrchr(__FILE__, '.'), 1), '/') === false ? $phpEx : ''; |
|
81
|
81
|
define('PHP_EX', $phpEx); // PHP extension on this server |
|
82
|
|
-define('DOT_PHP_EX', '.' . PHP_EX); // PHP extension on this server |
|
|
82
|
+define('DOT_PHP_EX', '.'.PHP_EX); // PHP extension on this server |
|
83
|
83
|
|
|
84
|
84
|
|
|
85
|
85
|
require_once('constants.php'); |
|
@@ -100,16 +100,16 @@ discard block |
|
|
block discarded – undo |
|
100
|
100
|
|
|
101
|
101
|
// required for db.php |
|
102
|
102
|
// Initializing global 'debug' object |
|
103
|
|
-require_once(SN_ROOT_PHYSICAL . "includes/debug.class" . DOT_PHP_EX); |
|
|
103
|
+require_once(SN_ROOT_PHYSICAL."includes/debug.class".DOT_PHP_EX); |
|
104
|
104
|
classSupernova::$debug = new debug(); |
|
105
|
105
|
|
|
106
|
|
-empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL . 'includes/classes/' : false; |
|
107
|
|
-spl_autoload_register(function ($class) use ($classRoot) { |
|
|
106
|
+empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL.'includes/classes/' : false; |
|
|
107
|
+spl_autoload_register(function($class) use ($classRoot) { |
|
108
|
108
|
$class = str_replace('\\', '/', $class); |
|
109
|
|
- if (file_exists($classRoot . $class . '.php')) { |
|
110
|
|
- require_once $classRoot . $class . '.php'; |
|
111
|
|
- } elseif (file_exists($classRoot . 'UBE/' . $class . '.php')) { |
|
112
|
|
- require_once $classRoot . 'UBE/' . $class . '.php'; |
|
|
109
|
+ if (file_exists($classRoot.$class.'.php')) { |
|
|
110
|
+ require_once $classRoot.$class.'.php'; |
|
|
111
|
+ } elseif (file_exists($classRoot.'UBE/'.$class.'.php')) { |
|
|
112
|
+ require_once $classRoot.'UBE/'.$class.'.php'; |
|
113
|
113
|
} |
|
114
|
114
|
}); |
|
115
|
115
|
|
|
@@ -124,7 +124,7 @@ discard block |
|
|
block discarded – undo |
|
124
|
124
|
//}); |
|
125
|
125
|
|
|
126
|
126
|
|
|
127
|
|
-require_once(SN_ROOT_PHYSICAL . "includes/db" . DOT_PHP_EX); |
|
|
127
|
+require_once(SN_ROOT_PHYSICAL."includes/db".DOT_PHP_EX); |
|
128
|
128
|
require_once('classes/db_mysql_v4.php'); |
|
129
|
129
|
require_once('classes/db_mysql_v5.php'); |
|
130
|
130
|
require_once('classes/db_mysql.php'); |
|
@@ -137,7 +137,7 @@ discard block |
|
|
block discarded – undo |
|
137
|
137
|
require_once('classes/module.php'); |
|
138
|
138
|
|
|
139
|
139
|
require_once('classes/user_options.php'); |
|
140
|
|
-require_once(SN_ROOT_PHYSICAL . "includes/init/init_functions" . DOT_PHP_EX); |
|
|
140
|
+require_once(SN_ROOT_PHYSICAL."includes/init/init_functions".DOT_PHP_EX); |
|
141
|
141
|
|
|
142
|
142
|
/** |
|
143
|
143
|
* @var classConfig $config |
|
@@ -150,8 +150,8 @@ discard block |
|
|
block discarded – undo |
|
150
|
150
|
// define('BE_DEBUG', true); // Отладка боевого движка |
|
151
|
151
|
classSupernova::init_debug_state(); |
|
152
|
152
|
|
|
153
|
|
-require_once(SN_ROOT_PHYSICAL . "includes/vars/vars" . DOT_PHP_EX); |
|
154
|
|
-require_once(SN_ROOT_PHYSICAL . "includes/general" . DOT_PHP_EX); |
|
|
153
|
+require_once(SN_ROOT_PHYSICAL."includes/vars/vars".DOT_PHP_EX); |
|
|
154
|
+require_once(SN_ROOT_PHYSICAL."includes/general".DOT_PHP_EX); |
|
155
|
155
|
|
|
156
|
156
|
init_update(); |
|
157
|
157
|
|
|
@@ -160,28 +160,28 @@ discard block |
|
|
block discarded – undo |
|
160
|
160
|
? trim(strip_tags($_GET['page'])) |
|
161
|
161
|
: str_replace(DOT_PHP_EX, '', str_replace(SN_ROOT_RELATIVE, '', str_replace('\\', '/', $_SERVER['SCRIPT_NAME']))); |
|
162
|
162
|
define('INITIAL_PAGE', $sn_page_name_original); |
|
163
|
|
-define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova') . (defined('SN_GOOGLE') ? '_G' : '')); |
|
164
|
|
-define('SN_COOKIE_I', SN_COOKIE . AUTH_COOKIE_IMPERSONATE_SUFFIX); |
|
165
|
|
-define('SN_COOKIE_D', SN_COOKIE . '_D'); |
|
166
|
|
-define('SN_COOKIE_T', SN_COOKIE . '_T'); // Time measure cookie |
|
167
|
|
-define('SN_COOKIE_F', SN_COOKIE . '_F'); // Font size cookie |
|
168
|
|
-define('SN_COOKIE_U', SN_COOKIE . '_U'); // Current user cookie aka user ID |
|
169
|
|
-define('SN_COOKIE_U_I', SN_COOKIE_U . AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID |
|
|
163
|
+define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova').(defined('SN_GOOGLE') ? '_G' : '')); |
|
|
164
|
+define('SN_COOKIE_I', SN_COOKIE.AUTH_COOKIE_IMPERSONATE_SUFFIX); |
|
|
165
|
+define('SN_COOKIE_D', SN_COOKIE.'_D'); |
|
|
166
|
+define('SN_COOKIE_T', SN_COOKIE.'_T'); // Time measure cookie |
|
|
167
|
+define('SN_COOKIE_F', SN_COOKIE.'_F'); // Font size cookie |
|
|
168
|
+define('SN_COOKIE_U', SN_COOKIE.'_U'); // Current user cookie aka user ID |
|
|
169
|
+define('SN_COOKIE_U_I', SN_COOKIE_U.AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID |
|
170
|
170
|
define('TEMPLATE_NAME', classSupernova::$config->game_default_template ? classSupernova::$config->game_default_template : 'OpenGame'); |
|
171
|
|
-define('TEMPLATE_PATH', 'design/templates/' . TEMPLATE_NAME); |
|
172
|
|
-define('TEMPLATE_DIR', SN_ROOT_PHYSICAL . TEMPLATE_PATH); |
|
|
171
|
+define('TEMPLATE_PATH', 'design/templates/'.TEMPLATE_NAME); |
|
|
172
|
+define('TEMPLATE_DIR', SN_ROOT_PHYSICAL.TEMPLATE_PATH); |
|
173
|
173
|
define('DEFAULT_SKINPATH', classSupernova::$config->game_default_skin ? classSupernova::$config->game_default_skin : 'skins/EpicBlue/'); |
|
174
|
174
|
define('DEFAULT_LANG', classSupernova::$config->game_default_language ? classSupernova::$config->game_default_language : 'ru'); |
|
175
|
175
|
define('FMT_DATE', classSupernova::$config->int_format_date ? classSupernova::$config->int_format_date : 'd.m.Y'); |
|
176
|
176
|
define('FMT_TIME', classSupernova::$config->int_format_time ? classSupernova::$config->int_format_time : 'H:i:s'); |
|
177
|
|
-define('FMT_DATE_TIME', FMT_DATE . ' ' . FMT_TIME); |
|
|
177
|
+define('FMT_DATE_TIME', FMT_DATE.' '.FMT_TIME); |
|
178
|
178
|
|
|
179
|
179
|
$HTTP_ACCEPT_LANGUAGE = DEFAULT_LANG; |
|
180
|
180
|
|
|
181
|
|
-require_once(SN_ROOT_PHYSICAL . "includes/template" . DOT_PHP_EX); |
|
|
181
|
+require_once(SN_ROOT_PHYSICAL."includes/template".DOT_PHP_EX); |
|
182
|
182
|
$template_result = array('.' => array('result' => array())); |
|
183
|
183
|
|
|
184
|
|
-sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX); |
|
|
184
|
+sn_sys_load_php_files(SN_ROOT_PHYSICAL."includes/functions/", PHP_EX); |
|
185
|
185
|
|
|
186
|
186
|
|
|
187
|
187
|
|
|
@@ -192,7 +192,7 @@ discard block |
|
|
block discarded – undo |
|
192
|
192
|
// Конфиг - часть манифеста? |
|
193
|
193
|
classSupernova::$auth = new core_auth(); |
|
194
|
194
|
|
|
195
|
|
-sn_sys_load_php_files(SN_ROOT_PHYSICAL . "modules/", PHP_EX, true); |
|
|
195
|
+sn_sys_load_php_files(SN_ROOT_PHYSICAL."modules/", PHP_EX, true); |
|
196
|
196
|
// Здесь - потому что core_auth модуль лежит в другом каталоге и его нужно инициализировать отдельно |
|
197
|
197
|
|
|
198
|
198
|
// Подключаем дефолтную страницу |
|
@@ -200,10 +200,10 @@ discard block |
|
|
block discarded – undo |
|
200
|
200
|
// Сейчас мы делаем это здесь только для того, что бы содержание дефолтной страницы оказалось вверху. Что не факт, что нужно всегда |
|
201
|
201
|
// Но нужно, пока у нас есть не MVC-страницы |
|
202
|
202
|
$sn_page_data = $sn_data['pages'][$sn_page_name]; |
|
203
|
|
-$sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
|
204
|
|
-if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
|
203
|
+$sn_page_name_file = 'includes/pages/'.$sn_page_data['filename'].DOT_PHP_EX; |
|
|
204
|
+if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
205
|
205
|
require_once($sn_page_name_file); |
|
206
|
|
- if(is_array($sn_page_data['options'])) { |
|
|
206
|
+ if (is_array($sn_page_data['options'])) { |
|
207
|
207
|
classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']); |
|
208
|
208
|
} |
|
209
|
209
|
} |
|
@@ -218,10 +218,10 @@ discard block |
|
|
block discarded – undo |
|
218
|
218
|
$load_order = array(); |
|
219
|
219
|
$sn_req = array(); |
|
220
|
220
|
|
|
221
|
|
-foreach(sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
|
221
|
+foreach (sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
222
|
222
|
$load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000; |
|
223
|
|
- if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
224
|
|
- foreach($module_data->manifest['require'] as $require_name) { |
|
|
223
|
+ if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
|
224
|
+ foreach ($module_data->manifest['require'] as $require_name) { |
|
225
|
225
|
$sn_req[$loaded_module_name][$require_name] = 0; |
|
226
|
226
|
} |
|
227
|
227
|
} |
|
@@ -234,10 +234,10 @@ discard block |
|
|
block discarded – undo |
|
234
|
234
|
do { |
|
235
|
235
|
$prev_order = $load_order; |
|
236
|
236
|
|
|
237
|
|
- foreach($sn_req as $loaded_module_name => &$req_data) { |
|
|
237
|
+ foreach ($sn_req as $loaded_module_name => &$req_data) { |
|
238
|
238
|
$level = 1; |
|
239
|
|
- foreach($req_data as $req_name => &$req_level) { |
|
240
|
|
- if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
|
239
|
+ foreach ($req_data as $req_name => &$req_level) { |
|
|
240
|
+ if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
241
|
241
|
$level = $req_level = -1; |
|
242
|
242
|
break; |
|
243
|
243
|
} else { |
|
@@ -245,20 +245,20 @@ discard block |
|
|
block discarded – undo |
|
245
|
245
|
} |
|
246
|
246
|
$req_level = $load_order[$req_name]; |
|
247
|
247
|
} |
|
248
|
|
- if($level > $load_order[$loaded_module_name] || $level == -1) { |
|
|
248
|
+ if ($level > $load_order[$loaded_module_name] || $level == -1) { |
|
249
|
249
|
$load_order[$loaded_module_name] = $level; |
|
250
|
250
|
} |
|
251
|
251
|
} |
|
252
|
|
-} while($prev_order != $load_order); |
|
|
252
|
+} while ($prev_order != $load_order); |
|
253
|
253
|
|
|
254
|
254
|
asort($load_order); |
|
255
|
255
|
|
|
256
|
256
|
// Инициализируем модули |
|
257
|
257
|
// По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти |
|
258
|
|
-foreach($load_order as $loaded_module_name => $load_order_order) { |
|
259
|
|
- if($load_order_order >= 0) { |
|
|
258
|
+foreach ($load_order as $loaded_module_name => $load_order_order) { |
|
|
259
|
+ if ($load_order_order >= 0) { |
|
260
|
260
|
sn_module::$sn_module[$loaded_module_name]->check_status(); |
|
261
|
|
- if(!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
|
261
|
+ if (!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
262
|
262
|
unset(sn_module::$sn_module[$loaded_module_name]); |
|
263
|
263
|
continue; |
|
264
|
264
|
} |
|
@@ -275,7 +275,7 @@ discard block |
|
|
block discarded – undo |
|
275
|
275
|
unset($sn_req); |
|
276
|
276
|
|
|
277
|
277
|
// А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
|
278
|
|
-if(!isset($sn_data['pages'][$sn_page_name])) { |
|
|
278
|
+if (!isset($sn_data['pages'][$sn_page_name])) { |
|
279
|
279
|
$sn_page_name = ''; |
|
280
|
280
|
} |
|
281
|
281
|
|
|
@@ -283,6 +283,6 @@ discard block |
|
|
block discarded – undo |
|
283
|
283
|
classLocale::$lang = $lang = new classLocale(classSupernova::$config->server_locale_log_usage); |
|
284
|
284
|
classLocale::$lang->lng_switch(sys_get_param_str('lang')); |
|
285
|
285
|
|
|
286
|
|
-if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
|
286
|
+if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
287
|
287
|
require_once "init_secondary.php"; |
|
288
|
288
|
} |