@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use Player\playerTimeDiff; |
| 10 | 10 | |
| 11 | 11 | // Защита от двойного инита |
| 12 | -if(defined('INIT')) { |
|
| 12 | +if (defined('INIT')) { |
|
| 13 | 13 | return; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | !defined('INSTALL') && define('INSTALL', false); |
| 25 | 25 | !defined('IN_PHPBB') && define('IN_PHPBB', true); |
| 26 | 26 | |
| 27 | -call_user_func(function () { |
|
| 27 | +call_user_func(function() { |
|
| 28 | 28 | if (file_exists($fileName = realpath(__DIR__ . '/../.env.ini'))) { |
| 29 | 29 | define('SN_ENV_PROD', 'production'); |
| 30 | 30 | define('SN_ENV_DEV', 'development'); |
| 31 | 31 | |
| 32 | 32 | if (($ini = @parse_ini_file($fileName)) !== false) { |
| 33 | - if (!empty($ini['SN_ENV']) && in_array($envName = $ini['SN_ENV'], [SN_ENV_DEV, SN_ENV_PROD,])) { |
|
| 33 | + if (!empty($ini['SN_ENV']) && in_array($envName = $ini['SN_ENV'], [SN_ENV_DEV, SN_ENV_PROD, ])) { |
|
| 34 | 34 | define('SN_ENV', $envName); |
| 35 | 35 | } else { |
| 36 | 36 | define('SN_ENV', SN_ENV_PROD); |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | // Detecting if we are under Google's eye - domain is prefixed with `google.` |
| 64 | 64 | $_server_server_name = |
| 65 | - isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : |
|
| 66 | - (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''); |
|
| 65 | + isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''); |
|
| 67 | 66 | if (substr(strtolower($_server_server_name), 0, 7) === 'google.') { |
| 68 | 67 | define('SN_GOOGLE', true); |
| 69 | 68 | } else { |
@@ -73,7 +72,7 @@ discard block |
||
| 73 | 72 | // Instancing |
| 74 | 73 | // If server name contains port - replacing : with _ - servers on different ports are different instances |
| 75 | 74 | $instanceName = str_replace(':', '_', $_server_server_name); |
| 76 | -if(SN_GOOGLE) { |
|
| 75 | +if (SN_GOOGLE) { |
|
| 77 | 76 | $instanceName = substr($instanceName, 7); |
| 78 | 77 | } |
| 79 | 78 | $instancePath = 'servers/' . $instanceName . '/'; |
@@ -207,40 +206,40 @@ discard block |
||
| 207 | 206 | // Но нужно, пока у нас есть не MVC-страницы |
| 208 | 207 | $sn_page_data = $sn_mvc['pages'][$sn_page_name]; |
| 209 | 208 | $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
| 210 | -if($sn_page_name) { |
|
| 209 | +if ($sn_page_name) { |
|
| 211 | 210 | // Merging page options to global option pull |
| 212 | - if(is_array($sn_page_data['options'])) { |
|
| 211 | + if (is_array($sn_page_data['options'])) { |
|
| 213 | 212 | SN::$options = array_merge(SN::$options, $sn_page_data['options']); |
| 214 | 213 | } |
| 215 | 214 | |
| 216 | - if(isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
| 215 | + if (isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
| 217 | 216 | require_once($sn_page_name_file); |
| 218 | 217 | } |
| 219 | 218 | } |
| 220 | 219 | |
| 221 | -if((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true) || (!empty(SN::$options[PAGE_OPTION_ADMIN]))) { |
|
| 220 | +if ((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true) || (!empty(SN::$options[PAGE_OPTION_ADMIN]))) { |
|
| 222 | 221 | SN::$options[PAGE_OPTION_FLEET_UPDATE_SKIP] = true; |
| 223 | 222 | } |
| 224 | 223 | |
| 225 | 224 | |
| 226 | 225 | // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
| 227 | 226 | // TODO - костыль, что бы работали старые модули. Убрать! |
| 228 | -if(is_array($sn_data['pages'])) { |
|
| 227 | +if (is_array($sn_data['pages'])) { |
|
| 229 | 228 | $sn_mvc['pages'] = array_merge($sn_mvc['pages'], $sn_data['pages']); |
| 230 | 229 | } |
| 231 | -if(!isset($sn_mvc['pages'][$sn_page_name])) { |
|
| 230 | +if (!isset($sn_mvc['pages'][$sn_page_name])) { |
|
| 232 | 231 | $sn_page_name = ''; |
| 233 | 232 | } |
| 234 | 233 | |
| 235 | 234 | $lang->lng_switch(sys_get_param_str('lang')); |
| 236 | 235 | |
| 237 | 236 | |
| 238 | -if(SN::$config->server_updater_check_auto && SN::$config->server_updater_check_last + SN::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
| 237 | +if (SN::$config->server_updater_check_auto && SN::$config->server_updater_check_last + SN::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
| 239 | 238 | VersionCheckerDeprecated::performCheckVersion(); |
| 240 | 239 | } |
| 241 | 240 | |
| 242 | 241 | SN::$gc->watchdog->register(new TaskDispatchFleets(), TaskDispatchFleets::class); |
| 243 | -SN::$gc->worker->registerWorker('dispatchFleets', function () { |
|
| 242 | +SN::$gc->worker->registerWorker('dispatchFleets', function() { |
|
| 244 | 243 | \Core\Worker::detachIncomingRequest(); |
| 245 | 244 | |
| 246 | 245 | $result = SN::$gc->fleetDispatcher->flt_flying_fleet_handler(); |
@@ -263,16 +262,16 @@ discard block |
||
| 263 | 262 | die(json_encode($result)); |
| 264 | 263 | } |
| 265 | 264 | |
| 266 | -if(SN::$config->user_birthday_gift && SN_TIME_NOW - SN::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
| 265 | +if (SN::$config->user_birthday_gift && SN_TIME_NOW - SN::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
| 267 | 266 | require_once(SN_ROOT_PHYSICAL . 'includes/includes/user_birthday_celebrate.php'); |
| 268 | 267 | sn_user_birthday_celebrate(); |
| 269 | 268 | } |
| 270 | 269 | |
| 271 | -if(!SN::$config->var_online_user_count || SN::$config->var_online_user_time + SN::$config->game_users_update_online < SN_TIME_NOW) { |
|
| 270 | +if (!SN::$config->var_online_user_count || SN::$config->var_online_user_time + SN::$config->game_users_update_online < SN_TIME_NOW) { |
|
| 272 | 271 | dbUpdateUsersCount(db_user_count()); |
| 273 | 272 | dbUpdateUsersOnline(db_user_count(true)); |
| 274 | 273 | SN::$config->pass()->var_online_user_time = SN_TIME_NOW; |
| 275 | - if(SN::$config->server_log_online) { |
|
| 274 | + if (SN::$config->server_log_online) { |
|
| 276 | 275 | /** @noinspection SqlResolve */ |
| 277 | 276 | doquery("INSERT IGNORE INTO `{{log_users_online}}` SET online_count = " . SN::$config->var_online_user_count . ";"); |
| 278 | 277 | } |
@@ -296,7 +295,7 @@ discard block |
||
| 296 | 295 | |
| 297 | 296 | $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id']; |
| 298 | 297 | |
| 299 | -if(!empty($user['id'])) { |
|
| 298 | +if (!empty($user['id'])) { |
|
| 300 | 299 | SN::$user_options->user_change($user['id']); |
| 301 | 300 | } |
| 302 | 301 | |
@@ -309,7 +308,7 @@ discard block |
||
| 309 | 308 | : false |
| 310 | 309 | ); |
| 311 | 310 | |
| 312 | -if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 311 | +if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 313 | 312 | $prohibited_characters = array_map(function($value) { |
| 314 | 313 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
| 315 | 314 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -317,7 +316,7 @@ discard block |
||
| 317 | 316 | } |
| 318 | 317 | |
| 319 | 318 | |
| 320 | -if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
| 319 | +if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
| 321 | 320 | pdump('Отключи отладку перед продакшном!'); |
| 322 | 321 | } |
| 323 | 322 | |
@@ -332,7 +331,7 @@ discard block |
||
| 332 | 331 | // TODO - to scheduler |
| 333 | 332 | StatUpdateLauncher::unlock(); |
| 334 | 333 | |
| 335 | -if($template_result[F_GAME_DISABLE] = SN::$config->game_disable) { |
|
| 334 | +if ($template_result[F_GAME_DISABLE] = SN::$config->game_disable) { |
|
| 336 | 335 | $template_result[F_GAME_DISABLE_REASON] = HelperString::nl2br( |
| 337 | 336 | SN::$config->game_disable == GAME_DISABLE_REASON |
| 338 | 337 | ? SN::$config->game_disable_reason |
@@ -341,33 +340,33 @@ discard block |
||
| 341 | 340 | |
| 342 | 341 | // For API - just skipping all checks |
| 343 | 342 | // TODO: That is ideologically wrong and should be redone |
| 344 | - if(defined('IN_API')) { |
|
| 343 | + if (defined('IN_API')) { |
|
| 345 | 344 | return; |
| 346 | 345 | } |
| 347 | 346 | |
| 348 | 347 | // Actions for install mode |
| 349 | - if(defined('INSTALL_MODE') && INSTALL_MODE) { |
|
| 348 | + if (defined('INSTALL_MODE') && INSTALL_MODE) { |
|
| 350 | 349 | // Handling log out - should work even in install mode |
| 351 | - if(strtolower(INITIAL_PAGE) === 'logout') { |
|
| 350 | + if (strtolower(INITIAL_PAGE) === 'logout') { |
|
| 352 | 351 | SN::$auth->logout(true); |
| 353 | 352 | die(); |
| 354 | 353 | } |
| 355 | 354 | |
| 356 | 355 | // If user not logged in AND we are not on login page - redirect user there |
| 357 | - if(!$sys_user_logged_in && !defined('LOGIN_LOGOUT')) { |
|
| 356 | + if (!$sys_user_logged_in && !defined('LOGIN_LOGOUT')) { |
|
| 358 | 357 | header('Location: login.php'); |
| 359 | 358 | die(); |
| 360 | 359 | } |
| 361 | 360 | |
| 362 | 361 | // If user is type of admin AND in user pages - redirecting him to admin interface |
| 363 | 362 | // You really shouldn't mess in user interface until game not configured! |
| 364 | - if($user['authlevel'] >= 1 && !defined('IN_ADMIN')) { |
|
| 363 | + if ($user['authlevel'] >= 1 && !defined('IN_ADMIN')) { |
|
| 365 | 364 | header('Location: ' . SN_ROOT_VIRTUAL_PARENT . 'admin/overview.php'); |
| 366 | 365 | die(); |
| 367 | 366 | } |
| 368 | 367 | } |
| 369 | 368 | |
| 370 | - if( |
|
| 369 | + if ( |
|
| 371 | 370 | ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN)) |
| 372 | 371 | && |
| 373 | 372 | !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT')) |
@@ -383,8 +382,8 @@ discard block |
||
| 383 | 382 | // TODO ban |
| 384 | 383 | // TODO $skip_ban_check |
| 385 | 384 | global $skip_ban_check; |
| 386 | -if($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
| 387 | - if(defined('IN_API')) { |
|
| 385 | +if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
| 386 | + if (defined('IN_API')) { |
|
| 388 | 387 | return; |
| 389 | 388 | } |
| 390 | 389 | |
@@ -398,10 +397,10 @@ discard block |
||
| 398 | 397 | $allow_anonymous = $allow_anonymous || (isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous']); |
| 399 | 398 | |
| 400 | 399 | |
| 401 | -if($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
| 400 | +if ($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
| 402 | 401 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
| 403 | -} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
| 404 | -} elseif(!$allow_anonymous && !$sys_user_logged_in) { |
|
| 402 | +} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
| 403 | +} elseif (!$allow_anonymous && !$sys_user_logged_in) { |
|
| 405 | 404 | sys_redirect(SN_ROOT_VIRTUAL . 'login.php'); |
| 406 | 405 | } |
| 407 | 406 | |