@@ -829,10 +829,17 @@ |
||
| 829 | 829 | |
| 830 | 830 | // OK v4.5 |
| 831 | 831 | // TODO - REMEMBER_ME |
| 832 | + |
|
| 833 | + /** |
|
| 834 | + * @param integer $period |
|
| 835 | + */ |
|
| 832 | 836 | protected static function cookie_set($value, $impersonate = false, $period = null) { |
| 833 | 837 | sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE); |
| 834 | 838 | } |
| 835 | 839 | |
| 840 | + /** |
|
| 841 | + * @param string $message |
|
| 842 | + */ |
|
| 836 | 843 | protected static function flog($message, $die = false) { |
| 837 | 844 | if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
| 838 | 845 | return; |
@@ -205,18 +205,18 @@ discard block |
||
| 205 | 205 | // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ |
| 206 | 206 | // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно |
| 207 | 207 | |
| 208 | - if(sys_get_param('login_player_register_logout')) { |
|
| 208 | + if (sys_get_param('login_player_register_logout')) { |
|
| 209 | 209 | $this->logout(); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | $original_suggest = ''; |
| 213 | 213 | // Смотрим - есть ли у нас данные от пользователя |
| 214 | - if(($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
| 214 | + if (($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
| 215 | 215 | // Попытка регистрации нового игрока из данных, введенных пользователем |
| 216 | 216 | $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name'); |
| 217 | 217 | } else { |
| 218 | - foreach($this->providers_authorised as $provider) { |
|
| 219 | - if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
| 218 | + foreach ($this->providers_authorised as $provider) { |
|
| 219 | + if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
| 220 | 220 | $original_suggest = $provider->player_name_suggest(); |
| 221 | 221 | break; |
| 222 | 222 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру |
| 227 | - if(!$this->player_suggested_name) { |
|
| 227 | + if (!$this->player_suggested_name) { |
|
| 228 | 228 | $max_user_id = db_player_get_max_id(); // 4.5 |
| 229 | 229 | // TODO - предлагать имя игрока по локали |
| 230 | 230 | |
@@ -233,15 +233,15 @@ discard block |
||
| 233 | 233 | sn_db_transaction_rollback(); |
| 234 | 234 | $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
| 235 | 235 | sn_db_transaction_start(); |
| 236 | - } while(db_player_name_exists($this->player_suggested_name)); |
|
| 236 | + } while (db_player_name_exists($this->player_suggested_name)); |
|
| 237 | 237 | |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if($player_name_submitted) { |
|
| 240 | + if ($player_name_submitted) { |
|
| 241 | 241 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
| 242 | - if($this->register_status == LOGIN_SUCCESS) { |
|
| 242 | + if ($this->register_status == LOGIN_SUCCESS) { |
|
| 243 | 243 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
| 244 | - } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
| 244 | + } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
| 245 | 245 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
| 246 | 246 | } |
| 247 | 247 | // if(self::$login_status != LOGIN_SUCCESS) { |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | : false |
| 266 | 266 | ); |
| 267 | 267 | |
| 268 | - if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 268 | + if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 269 | 269 | $prohibited_characters = array_map(function($value) { |
| 270 | 270 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
| 271 | 271 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -297,27 +297,27 @@ discard block |
||
| 297 | 297 | global $sn_module_list, $lang; |
| 298 | 298 | |
| 299 | 299 | // !self::$is_init ? self::init() : false; |
| 300 | - if(empty($sn_module_list['auth'])) { |
|
| 300 | + if (empty($sn_module_list['auth'])) { |
|
| 301 | 301 | die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}'); |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false; |
| 305 | 305 | !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false; |
| 306 | - !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false; |
|
| 306 | + !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false; |
|
| 307 | 307 | |
| 308 | 308 | $this->auth_reset(); // OK v4.5 |
| 309 | 309 | |
| 310 | 310 | $this->providers = array(); |
| 311 | - foreach($sn_module_list['auth'] as $module_name => $module) { |
|
| 311 | + foreach ($sn_module_list['auth'] as $module_name => $module) { |
|
| 312 | 312 | $this->providers[$module->provider_id] = $module; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым! |
| 316 | 316 | //pdump($this->providers); |
| 317 | - foreach($this->providers as $provider_id => $provider) { |
|
| 317 | + foreach ($this->providers as $provider_id => $provider) { |
|
| 318 | 318 | $login_status = $provider->login(); // OK v4.5 |
| 319 | 319 | self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
| 320 | - if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
| 320 | + if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
| 321 | 321 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
| 322 | 322 | |
| 323 | 323 | $this->user_id_to_provider = array_replace_recursive( |
@@ -325,20 +325,20 @@ discard block |
||
| 325 | 325 | // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
| 326 | 326 | PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
| 327 | 327 | ); |
| 328 | - } elseif($login_status != LOGIN_UNDEFINED) { |
|
| 328 | + } elseif ($login_status != LOGIN_UNDEFINED) { |
|
| 329 | 329 | $this->provider_error_list[$provider_id] = $login_status; |
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if(empty($this->providers_authorised)) { |
|
| 333 | + if (empty($this->providers_authorised)) { |
|
| 334 | 334 | // Ни один аккаунт не авторизирован |
| 335 | 335 | // Проверяем - есть ли у нас ошибки в аккаунтах? |
| 336 | - if(!empty($this->provider_error_list)) { |
|
| 336 | + if (!empty($this->provider_error_list)) { |
|
| 337 | 337 | // Если есть - выводим их |
| 338 | 338 | self::$login_status = reset($this->provider_error_list); |
| 339 | 339 | $providerError = $this->providers[key($this->provider_error_list)]->account_login_message; |
| 340 | 340 | |
| 341 | - if(!empty($providerError)) { |
|
| 341 | + if (!empty($providerError)) { |
|
| 342 | 342 | self::$login_message = $providerError; |
| 343 | 343 | } |
| 344 | 344 | } |
@@ -353,12 +353,12 @@ discard block |
||
| 353 | 353 | // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users` |
| 354 | 354 | |
| 355 | 355 | // Остались ли у нас в списке доступные игроки? |
| 356 | - if(empty($this->accessible_user_row_list)) { |
|
| 356 | + if (empty($this->accessible_user_row_list)) { |
|
| 357 | 357 | // Нет ни одного игрока ни на одном авторизированном аккаунте |
| 358 | 358 | // Надо регать нового игрока |
| 359 | 359 | |
| 360 | 360 | // Сейчас происходит процесс регистрации игрока? |
| 361 | - if(!$this->is_player_register) { |
|
| 361 | + if (!$this->is_player_register) { |
|
| 362 | 362 | // Нет - отправляем на процесс регистрации |
| 363 | 363 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
| 364 | 364 | sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | // Да, есть доступные игроки, которые так же прописаны в базе |
| 368 | 368 | $this->get_active_user(); // 4.5 |
| 369 | 369 | |
| 370 | - if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
| 370 | + if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
| 371 | 371 | $a_user = db_user_by_id($this->is_impersonating); |
| 372 | 372 | $this->impersonator_username = $a_user['username']; |
| 373 | 373 | } |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | //Прописываем текущего игрока на все авторизированные аккаунты |
| 377 | 377 | // TODO - ИЛИ ВСЕХ ИГРОКОВ?? |
| 378 | - if(empty($this->is_impersonating)) { |
|
| 379 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 380 | - if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
| 378 | + if (empty($this->is_impersonating)) { |
|
| 379 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 380 | + if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
| 381 | 381 | // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
| 382 | 382 | PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
| 383 | 383 | $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true; |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if(empty(self::$user['id'])) { |
|
| 390 | + if (empty(self::$user['id'])) { |
|
| 391 | 391 | self::cookie_set(''); // OK 4.5 |
| 392 | - } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
| 392 | + } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
| 393 | 393 | self::cookie_set(self::$user['id']); // OK 4.5 |
| 394 | 394 | } |
| 395 | 395 | |
@@ -408,21 +408,21 @@ discard block |
||
| 408 | 408 | */ |
| 409 | 409 | // OK v4.7 |
| 410 | 410 | public function logout($redirect = true) { |
| 411 | - if(!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
| 411 | + if (!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
| 412 | 412 | self::cookie_set($_COOKIE[SN_COOKIE_U_I]); |
| 413 | 413 | self::cookie_set(0, true); |
| 414 | 414 | self::$main_provider->logout(); |
| 415 | 415 | } else { |
| 416 | - foreach($this->providers as $provider_name => $provider) { |
|
| 416 | + foreach ($this->providers as $provider_name => $provider) { |
|
| 417 | 417 | $provider->logout(); |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | self::cookie_set(0); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if($redirect === true) { |
|
| 423 | + if ($redirect === true) { |
|
| 424 | 424 | sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
| 425 | - } elseif($redirect !== false) { |
|
| 425 | + } elseif ($redirect !== false) { |
|
| 426 | 426 | sys_redirect($redirect); |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -433,15 +433,15 @@ discard block |
||
| 433 | 433 | * @param $user_selected |
| 434 | 434 | */ |
| 435 | 435 | public function impersonate($user_selected) { |
| 436 | - if($_COOKIE[SN_COOKIE_U_I]) { |
|
| 436 | + if ($_COOKIE[SN_COOKIE_U_I]) { |
|
| 437 | 437 | die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
| 440 | + if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
| 441 | 441 | die('You can\'t impersonate - too low level'); // TODO: Log it |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
| 444 | + if ($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
| 445 | 445 | die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it |
| 446 | 446 | } |
| 447 | 447 | |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]); |
| 450 | 450 | $account_to_impersonate = new Account(self::$main_provider->db); |
| 451 | 451 | $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']); |
| 452 | - if(!$account_to_impersonate->is_exists) { |
|
| 452 | + if (!$account_to_impersonate->is_exists) { |
|
| 453 | 453 | die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it |
| 454 | 454 | } |
| 455 | 455 | self::$main_provider->impersonate($account_to_impersonate); |
@@ -475,12 +475,12 @@ discard block |
||
| 475 | 475 | public function password_check($password_unsafe) { |
| 476 | 476 | $result = false; |
| 477 | 477 | |
| 478 | - if(empty($this->providers_authorised)) { |
|
| 478 | + if (empty($this->providers_authorised)) { |
|
| 479 | 479 | // TODO - такого быть не может! |
| 480 | 480 | self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
| 481 | 481 | } else { |
| 482 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 483 | - if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
| 482 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 483 | + if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
| 484 | 484 | $result = $result || $provider->password_check($password_unsafe); |
| 485 | 485 | } |
| 486 | 486 | } |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | public function password_change($old_password_unsafe, $new_password_unsafe) { |
| 502 | 502 | global $lang; |
| 503 | 503 | |
| 504 | - if(empty($this->providers_authorised)) { |
|
| 504 | + if (empty($this->providers_authorised)) { |
|
| 505 | 505 | // TODO - такого быть не может! |
| 506 | 506 | self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
| 507 | 507 | return false; |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | $salt_unsafe = self::password_salt_generate(); |
| 515 | 515 | |
| 516 | 516 | $providers_changed_password = array(); |
| 517 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 518 | - if( |
|
| 517 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 518 | + if ( |
|
| 519 | 519 | !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE) |
| 520 | 520 | || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe) |
| 521 | 521 | ) { |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id); |
| 528 | 528 | |
| 529 | 529 | // Рассылаем уведомления о смене пароля в ЛС |
| 530 | - foreach($account_translation as $user_id => $provider_info) { |
|
| 530 | + foreach ($account_translation as $user_id => $provider_info) { |
|
| 531 | 531 | // TODO - УКазывать тип аккаунта, на котором сменён пароль |
| 532 | 532 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, |
| 533 | 533 | $lang['sys_administration'], $lang['sys_login_register_message_title'], |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | sn_db_transaction_start(); |
| 575 | 575 | // Проверить наличие такого имени в истории имён |
| 576 | 576 | |
| 577 | - if(db_player_name_exists($player_name_unsafe)) { |
|
| 577 | + if (db_player_name_exists($player_name_unsafe)) { |
|
| 578 | 578 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR); |
| 579 | 579 | } |
| 580 | 580 | |
@@ -582,11 +582,11 @@ discard block |
||
| 582 | 582 | $player_language = ''; |
| 583 | 583 | $player_email = ''; |
| 584 | 584 | // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
| 585 | - foreach($this->providers_authorised as $provider) { |
|
| 586 | - if(!$player_language && $provider->account->account_language) { |
|
| 585 | + foreach ($this->providers_authorised as $provider) { |
|
| 586 | + if (!$player_language && $provider->account->account_language) { |
|
| 587 | 587 | $player_language = $provider->account->account_language; |
| 588 | 588 | } |
| 589 | - if(!$player_email && $provider->account->account_email) { |
|
| 589 | + if (!$player_email && $provider->account->account_email) { |
|
| 590 | 590 | $player_email = $provider->account->account_email; |
| 591 | 591 | } |
| 592 | 592 | } |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | )); |
| 603 | 603 | // Зарегестрировать на него аккаунты из self::$accounts_authorised |
| 604 | 604 | $a_user = self::$user; |
| 605 | - foreach($this->providers_authorised as $provider) { |
|
| 605 | + foreach ($this->providers_authorised as $provider) { |
|
| 606 | 606 | // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор |
| 607 | 607 | // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
| 608 | 608 | // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']); |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | |
| 615 | 615 | sn_db_transaction_commit(); |
| 616 | 616 | $this->register_status = LOGIN_SUCCESS; |
| 617 | - } catch(Exception $e) { |
|
| 617 | + } catch (Exception $e) { |
|
| 618 | 618 | sn_db_transaction_rollback(); |
| 619 | 619 | |
| 620 | 620 | // Если старое имя занято |
@@ -633,10 +633,10 @@ discard block |
||
| 633 | 633 | // Пробиваем все ИД игроков по базе - есть ли вообще такие записи |
| 634 | 634 | // Вообще-то это не особо нужно - у нас по определению стоят констраинты |
| 635 | 635 | // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров |
| 636 | - foreach($this->user_id_to_provider as $user_id => $cork) { |
|
| 636 | + foreach ($this->user_id_to_provider as $user_id => $cork) { |
|
| 637 | 637 | $user = db_user_by_id($user_id); |
| 638 | 638 | // Если записи игрока в БД не существует? |
| 639 | - if(empty($user['id'])) { |
|
| 639 | + if (empty($user['id'])) { |
|
| 640 | 640 | // Удаляем этого и переходим к следующему |
| 641 | 641 | unset($this->user_id_to_provider[$user_id]); |
| 642 | 642 | // Де-регистрируем игрока из таблицы трансляции игроков |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | // OK v4.5 |
| 658 | 658 | protected function get_active_user() { |
| 659 | 659 | // Проверяем куку "текущего игрока" из браузера |
| 660 | - if( |
|
| 660 | + if ( |
|
| 661 | 661 | // Кука не пустая |
| 662 | 662 | ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U]) |
| 663 | 663 | // И в куке находится ID |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов |
| 685 | - if(empty(self::$user['id'])) { |
|
| 685 | + if (empty(self::$user['id'])) { |
|
| 686 | 686 | // Берем первого из доступных |
| 687 | 687 | // TODO - default_user |
| 688 | 688 | self::$user = reset($this->accessible_user_row_list); |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | |
| 707 | 707 | $result = array(); |
| 708 | 708 | |
| 709 | - if($user_id && empty($this->is_impersonating)) { |
|
| 709 | + if ($user_id && empty($this->is_impersonating)) { |
|
| 710 | 710 | // self::db_counter_insert(); |
| 711 | 711 | self::$device->db_counter_insert($user_id); |
| 712 | 712 | |
@@ -714,12 +714,12 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | sys_user_options_unpack($user); |
| 716 | 716 | |
| 717 | - if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
| 717 | + if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
| 718 | 718 | $user['banaday'] = 0; |
| 719 | 719 | $user['vacation'] = SN_TIME_NOW; |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
| 722 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
| 723 | 723 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
| 724 | 724 | |
| 725 | 725 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -733,13 +733,13 @@ discard block |
||
| 733 | 733 | ); |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | - if($extra = $config->security_ban_extra) { |
|
| 736 | + if ($extra = $config->security_ban_extra) { |
|
| 737 | 737 | $extra = explode(',', $extra); |
| 738 | - array_walk($extra,'trim'); |
|
| 738 | + array_walk($extra, 'trim'); |
|
| 739 | 739 | in_array(self::$device->device_id, $extra) and die(); |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - if(self::$login_message) { |
|
| 742 | + if (self::$login_message) { |
|
| 743 | 743 | $result[F_LOGIN_MESSAGE] = self::$login_message; |
| 744 | 744 | } |
| 745 | 745 | |
@@ -775,21 +775,21 @@ discard block |
||
| 775 | 775 | protected function register_player_name_validate($player_name_unsafe) { |
| 776 | 776 | // TODO - переделать под RAW-строки |
| 777 | 777 | // Если имя игрока пустое - NO GO! |
| 778 | - if(trim($player_name_unsafe) == '') { |
|
| 778 | + if (trim($player_name_unsafe) == '') { |
|
| 779 | 779 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR); |
| 780 | 780 | } |
| 781 | 781 | // Проверяем, что бы в начале и конце не было пустых символов |
| 782 | - if($player_name_unsafe != trim($player_name_unsafe)) { |
|
| 782 | + if ($player_name_unsafe != trim($player_name_unsafe)) { |
|
| 783 | 783 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR); |
| 784 | 784 | } |
| 785 | 785 | // Если логин имеет запрещенные символы - NO GO! |
| 786 | - if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 786 | + if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 787 | 787 | // TODO - выдавать в сообщение об ошибке список запрещенных символов |
| 788 | 788 | // TODO - заранее извещать игрока, какие символы являются запрещенными |
| 789 | 789 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
| 790 | 790 | } |
| 791 | 791 | // Если логин меньше минимальной длины - NO GO! |
| 792 | - if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 792 | + if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 793 | 793 | // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока |
| 794 | 794 | // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени |
| 795 | 795 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR); |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | protected static function flog($message, $die = false) { |
| 850 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 850 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 851 | 851 | return; |
| 852 | 852 | } |
| 853 | 853 | list($called, $caller) = debug_backtrace(false); |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
| 861 | 861 | |
| 862 | 862 | classSupernova::log_file("$message - $caller_name"); |
| 863 | - if($die) { |
|
| 863 | + if ($die) { |
|
| 864 | 864 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
| 865 | 865 | } |
| 866 | 866 | } |
@@ -180,6 +180,9 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| 183 | + /** |
|
| 184 | + * @param string $query |
|
| 185 | + */ |
|
| 183 | 186 | function security_watch_user_queries($query) { |
| 184 | 187 | // TODO Заменить это на новый логгер |
| 185 | 188 | global $config, $is_watching, $user, $debug; |
@@ -202,6 +205,9 @@ discard block |
||
| 202 | 205 | } |
| 203 | 206 | |
| 204 | 207 | |
| 208 | + /** |
|
| 209 | + * @param string $query |
|
| 210 | + */ |
|
| 205 | 211 | function security_query_check_bad_words($query) { |
| 206 | 212 | global $user, $dm_change_legit, $mm_change_legit; |
| 207 | 213 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function schema() { |
| 67 | - if(!isset(self::$schema)) { |
|
| 67 | + if (!isset(self::$schema)) { |
|
| 68 | 68 | self::$schema = new \DBAL\Schema($this); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -82,23 +82,23 @@ discard block |
||
| 82 | 82 | function sn_db_connect($external_db_settings = null) { |
| 83 | 83 | $this->db_disconnect(); |
| 84 | 84 | |
| 85 | - if(!empty($external_db_settings) && is_array($external_db_settings)) { |
|
| 85 | + if (!empty($external_db_settings) && is_array($external_db_settings)) { |
|
| 86 | 86 | $this->dbsettings = $external_db_settings; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if(empty($this->dbsettings)) { |
|
| 89 | + if (empty($this->dbsettings)) { |
|
| 90 | 90 | $this->load_db_settings(); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
| 94 | - if(!empty($this->dbsettings)) { |
|
| 94 | + if (!empty($this->dbsettings)) { |
|
| 95 | 95 | $driver_name = empty($this->dbsettings['sn_driver']) ? 'db_mysql_v5' : $this->dbsettings['sn_driver']; |
| 96 | 96 | $this->driver = new $driver_name(); |
| 97 | 97 | $this->db_prefix = $this->dbsettings['prefix']; |
| 98 | 98 | |
| 99 | 99 | $this->connected = $this->connected || $this->driver_connect(); |
| 100 | 100 | |
| 101 | - if($this->connected && empty($this->schema()->getSnTables())) { |
|
| 101 | + if ($this->connected && empty($this->schema()->getSnTables())) { |
|
| 102 | 102 | die('DB error - cannot find any table. Halting...'); |
| 103 | 103 | } |
| 104 | 104 | } else { |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | function driver_connect() { |
| 112 | 112 | global $debug; |
| 113 | 113 | |
| 114 | - if(!is_object($this->driver)) { |
|
| 114 | + if (!is_object($this->driver)) { |
|
| 115 | 115 | $debug->error_fatal('DB Error - No driver for MySQL found!'); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if(!method_exists($this->driver, 'mysql_connect')) { |
|
| 118 | + if (!method_exists($this->driver, 'mysql_connect')) { |
|
| 119 | 119 | $debug->error_fatal('DB Error - WRONG MySQL driver!'); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | function db_disconnect() { |
| 126 | - if($this->connected) { |
|
| 126 | + if ($this->connected) { |
|
| 127 | 127 | $this->connected = !$this->driver_disconnect(); |
| 128 | 128 | $this->connected = false; |
| 129 | 129 | } |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | function doquery($query, $table = '', $fetch = false, $skip_query_check = false) { |
| 135 | 135 | global $numqueries, $debug, $sn_cache, $config; |
| 136 | 136 | |
| 137 | - if(!is_string($table)) { |
|
| 137 | + if (!is_string($table)) { |
|
| 138 | 138 | $fetch = $table; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if(!$this->connected) { |
|
| 141 | + if (!$this->connected) { |
|
| 142 | 142 | $this->sn_db_connect(); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -147,30 +147,30 @@ discard block |
||
| 147 | 147 | $skip_query_check or $this->security_query_check_bad_words($query); |
| 148 | 148 | |
| 149 | 149 | $sql = $query; |
| 150 | - if(strpos($sql, '{{') !== false) { |
|
| 151 | - foreach($this->schema()->getSnTables() as $tableName) { |
|
| 150 | + if (strpos($sql, '{{') !== false) { |
|
| 151 | + foreach ($this->schema()->getSnTables() as $tableName) { |
|
| 152 | 152 | $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if($config->debug) { |
|
| 156 | + if ($config->debug) { |
|
| 157 | 157 | $numqueries++; |
| 158 | 158 | $arr = debug_backtrace(); |
| 159 | - $file = end(explode('/',$arr[0]['file'])); |
|
| 159 | + $file = end(explode('/', $arr[0]['file'])); |
|
| 160 | 160 | $line = $arr[0]['line']; |
| 161 | 161 | $debug->add("<tr><th>Query $numqueries: </th><th>$query</th><th>$file($line)</th><th>$table</th><th>$fetch</th></tr>"); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if(defined('DEBUG_SQL_COMMENT')) { |
|
| 164 | + if (defined('DEBUG_SQL_COMMENT')) { |
|
| 165 | 165 | $backtrace = debug_backtrace(); |
| 166 | 166 | $sql_comment = $debug->compact_backtrace($backtrace, defined('DEBUG_SQL_COMMENT_LONG')); |
| 167 | 167 | |
| 168 | 168 | $sql_commented = '/* ' . implode("<br />", $sql_comment) . '<br /> */ ' . preg_replace("/\s+/", ' ', $sql); |
| 169 | - if(defined('DEBUG_SQL_ONLINE')) { |
|
| 169 | + if (defined('DEBUG_SQL_ONLINE')) { |
|
| 170 | 170 | $debug->warning($sql_commented, 'SQL Debug', LOG_DEBUG_SQL); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - if(defined('DEBUG_SQL_ERROR')) { |
|
| 173 | + if (defined('DEBUG_SQL_ERROR')) { |
|
| 174 | 174 | array_unshift($sql_comment, preg_replace("/\s+/", ' ', $sql)); |
| 175 | 175 | $debug->add_to_array($sql_comment); |
| 176 | 176 | // $debug->add_to_array($sql_comment . preg_replace("/\s+/", ' ', $sql)); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $sql = $sql_commented; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $sqlquery = $this->db_sql_query($sql) or $debug->error(db_error()."<br />$sql<br />",'SQL Error'); |
|
| 181 | + $sqlquery = $this->db_sql_query($sql) or $debug->error(db_error() . "<br />$sql<br />", 'SQL Error'); |
|
| 182 | 182 | |
| 183 | 183 | return $fetch ? $this->db_fetch($sqlquery) : $sqlquery; |
| 184 | 184 | } |
@@ -197,16 +197,16 @@ discard block |
||
| 197 | 197 | // TODO Заменить это на новый логгер |
| 198 | 198 | global $config, $is_watching, $user, $debug; |
| 199 | 199 | |
| 200 | - if(!$is_watching && $config->game_watchlist_array && in_array($user['id'], $config->game_watchlist_array)) |
|
| 200 | + if (!$is_watching && $config->game_watchlist_array && in_array($user['id'], $config->game_watchlist_array)) |
|
| 201 | 201 | { |
| 202 | - if(!preg_match('/^(select|commit|rollback|start transaction)/i', $query)) { |
|
| 202 | + if (!preg_match('/^(select|commit|rollback|start transaction)/i', $query)) { |
|
| 203 | 203 | $is_watching = true; |
| 204 | 204 | $msg = "\$query = \"{$query}\"\n\r"; |
| 205 | - if(!empty($_POST)) { |
|
| 206 | - $msg .= "\n\r" . dump($_POST,'$_POST'); |
|
| 205 | + if (!empty($_POST)) { |
|
| 206 | + $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
| 207 | 207 | } |
| 208 | - if(!empty($_GET)) { |
|
| 209 | - $msg .= "\n\r" . dump($_GET,'$_GET'); |
|
| 208 | + if (!empty($_GET)) { |
|
| 209 | + $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
| 210 | 210 | } |
| 211 | 211 | $debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
| 212 | 212 | $is_watching = false; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | function security_query_check_bad_words($query) { |
| 219 | 219 | global $user, $dm_change_legit, $mm_change_legit; |
| 220 | 220 | |
| 221 | - switch(true) { |
|
| 221 | + switch (true) { |
|
| 222 | 222 | case stripos($query, 'RUNCATE TABL') != false: |
| 223 | 223 | case stripos($query, 'ROP TABL') != false: |
| 224 | 224 | case stripos($query, 'ENAME TABL') != false: |
@@ -229,33 +229,33 @@ discard block |
||
| 229 | 229 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
| 230 | 230 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
| 231 | 231 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
| 232 | - $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
| 232 | + $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
| 233 | 233 | $report .= ">Database Inforamation\n"; |
| 234 | - $report .= "\tID - ".$user['id']."\n"; |
|
| 235 | - $report .= "\tUser - ".$user['username']."\n"; |
|
| 236 | - $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
| 237 | - $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
| 238 | - $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
| 239 | - $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
| 240 | - $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
| 241 | - $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
| 242 | - $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
| 243 | - $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
| 234 | + $report .= "\tID - " . $user['id'] . "\n"; |
|
| 235 | + $report .= "\tUser - " . $user['username'] . "\n"; |
|
| 236 | + $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
| 237 | + $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
| 238 | + $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
| 239 | + $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
| 240 | + $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
| 241 | + $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
| 242 | + $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
| 243 | + $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
| 244 | 244 | $report .= "\n"; |
| 245 | 245 | |
| 246 | 246 | $report .= ">Query Information\n"; |
| 247 | - $report .= "\tQuery - ".$query."\n"; |
|
| 247 | + $report .= "\tQuery - " . $query . "\n"; |
|
| 248 | 248 | $report .= "\n"; |
| 249 | 249 | |
| 250 | 250 | $report .= ">\$_SERVER Information\n"; |
| 251 | - $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
| 252 | - $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
| 253 | - $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
| 254 | - $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
| 255 | - $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
| 256 | - $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
| 257 | - $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
| 258 | - $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
| 251 | + $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
| 252 | + $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
| 253 | + $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
| 254 | + $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
| 255 | + $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
| 256 | + $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
| 257 | + $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
| 258 | + $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
| 259 | 259 | |
| 260 | 260 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
| 261 | 261 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | $prefixedTableName_safe = $this->db_escape($this->db_prefix . $tableName_unsafe); |
| 288 | 288 | $q1 = $this->db_sql_query("SHOW FULL COLUMNS FROM `{$prefixedTableName_safe}`;"); |
| 289 | - while($r1 = db_fetch($q1)) { |
|
| 289 | + while ($r1 = db_fetch($q1)) { |
|
| 290 | 290 | $result[$r1['Field']] = $r1; |
| 291 | 291 | } |
| 292 | 292 | return $result; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $prefixedTableName_safe = $this->db_escape($this->db_prefix . $tableName_unsafe); |
| 304 | 304 | $q1 = $this->db_sql_query("SHOW INDEX FROM {$prefixedTableName_safe};"); |
| 305 | - while($r1 = db_fetch($q1)) { |
|
| 305 | + while ($r1 = db_fetch($q1)) { |
|
| 306 | 306 | $indexName = $r1['Key_name']; |
| 307 | 307 | |
| 308 | 308 | $result[$indexName]['name'] = $r1['Key_name']; |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | $prefixedTableName_safe = $this->db_escape($this->db_prefix . $tableName_unsafe); |
| 329 | 329 | |
| 330 | - $q1 = $this->db_sql_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name). "' AND `TABLE_NAME` = '{$prefixedTableName_safe}' AND `REFERENCED_TABLE_NAME` IS NOT NULL;"); |
|
| 331 | - while($r1 = db_fetch($q1)) { |
|
| 330 | + $q1 = $this->db_sql_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND `TABLE_NAME` = '{$prefixedTableName_safe}' AND `REFERENCED_TABLE_NAME` IS NOT NULL;"); |
|
| 331 | + while ($r1 = db_fetch($q1)) { |
|
| 332 | 332 | $indexName = $r1['CONSTRAINT_NAME']; |
| 333 | 333 | |
| 334 | 334 | $table_referenced = str_replace($this->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
@@ -55,6 +55,9 @@ |
||
| 55 | 55 | return true; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + /** |
|
| 59 | + * @param string $query_string |
|
| 60 | + */ |
|
| 58 | 61 | function mysql_query($query_string) { |
| 59 | 62 | return mysql_query($query_string, $this->link); |
| 60 | 63 | } |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | static $need_keys = array('server', 'user', 'pass', 'name', 'prefix'); |
| 32 | 32 | |
| 33 | - if($this->connected) { |
|
| 33 | + if ($this->connected) { |
|
| 34 | 34 | return true; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
| 37 | + if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
| 38 | 38 | $debug->error_fatal('There is missconfiguration in your config.php. Check it again', $this->mysql_error()); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // TODO !!!!!! DEBUG -> error!!!! |
| 42 | 42 | @$this->link = mysql_connect($settings['server'], $settings['user'], $settings['pass']); |
| 43 | - if(!is_resource($this->link)) { |
|
| 43 | + if (!is_resource($this->link)) { |
|
| 44 | 44 | $debug->error_fatal('DB Error - cannot connect to server', $this->mysql_error()); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return mysql_real_escape_string($unescaped_string, $this->link); |
| 69 | 69 | } |
| 70 | 70 | function mysql_close_link() { |
| 71 | - if($this->connected) { |
|
| 71 | + if ($this->connected) { |
|
| 72 | 72 | $this->connected = false; |
| 73 | 73 | mysql_close($this->link); |
| 74 | 74 | unset($this->link); |
@@ -56,6 +56,9 @@ discard block |
||
| 56 | 56 | WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | + /** |
|
| 60 | + * @param string $set |
|
| 61 | + */ |
|
| 59 | 62 | public static function db_unit_set_by_id($unit_id, $set) { |
| 60 | 63 | return classSupernova::db_upd_record_by_id(LOC_UNIT, $unit_id, $set); |
| 61 | 64 | } |
@@ -69,6 +72,9 @@ discard block |
||
| 69 | 72 | return classSupernova::db_ins_record(LOC_UNIT, $set); |
| 70 | 73 | } |
| 71 | 74 | |
| 75 | + /** |
|
| 76 | + * @param integer $unit_location_type |
|
| 77 | + */ |
|
| 72 | 78 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) { |
| 73 | 79 | return classSupernova::db_del_record_list(LOC_UNIT, |
| 74 | 80 | "`unit_location_type` = {$unit_location_type}" . |
@@ -70,8 +70,8 @@ |
||
| 70 | 70 | /** |
| 71 | 71 | * Vector constructor. |
| 72 | 72 | * |
| 73 | - * @param int|string $galaxy |
|
| 74 | - * @param int|Vector|array $system |
|
| 73 | + * @param integer $galaxy |
|
| 74 | + * @param integer $system |
|
| 75 | 75 | * @param int $planet |
| 76 | 76 | * @param int $type |
| 77 | 77 | */ |
@@ -141,6 +141,7 @@ discard block |
||
| 141 | 141 | * LIST - Get fleet list by condition |
| 142 | 142 | * |
| 143 | 143 | * @param string $where_safe |
| 144 | + * @param boolean $for_update |
|
| 144 | 145 | * |
| 145 | 146 | * @return array |
| 146 | 147 | */ |
@@ -432,6 +433,7 @@ discard block |
||
| 432 | 433 | * LIST - Get missile attack list by condition |
| 433 | 434 | * |
| 434 | 435 | * @param string $where |
| 436 | + * @param boolean $for_update |
|
| 435 | 437 | * |
| 436 | 438 | * @return array |
| 437 | 439 | */ |
@@ -80,11 +80,12 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $planet_precache_query = DBStaticPlanet::db_planet_list_in_system($uni_galaxy, $uni_system); |
| 82 | 82 | // while($planet_row = db_fetch($planet_precache_query)) |
| 83 | -if(!empty($planet_precache_query)) |
|
| 84 | -foreach($planet_precache_query as $planet_row) |
|
| 83 | +if(!empty($planet_precache_query)) { |
|
| 84 | + foreach($planet_precache_query as $planet_row) |
|
| 85 | 85 | { |
| 86 | 86 | $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row; |
| 87 | 87 | } |
| 88 | +} |
|
| 88 | 89 | |
| 89 | 90 | |
| 90 | 91 | //$fleet_precache_query = doquery( |
@@ -139,14 +140,12 @@ discard block |
||
| 139 | 140 | if ($uni_galaxyRowPlanet['destruyed']) |
| 140 | 141 | { |
| 141 | 142 | CheckAbandonPlanetState ($uni_galaxyRowPlanet); |
| 142 | - } |
|
| 143 | - elseif($uni_galaxyRowPlanet['id']) |
|
| 143 | + } elseif($uni_galaxyRowPlanet['id']) |
|
| 144 | 144 | { |
| 145 | 145 | if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) |
| 146 | 146 | { |
| 147 | 147 | $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']]; |
| 148 | - } |
|
| 149 | - else |
|
| 148 | + } else |
|
| 150 | 149 | { |
| 151 | 150 | $uni_galaxyRowUser = db_user_by_id($uni_galaxyRowPlanet['id_owner']); |
| 152 | 151 | $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser; |
@@ -168,8 +167,7 @@ discard block |
||
| 168 | 167 | if($cached['allies'][$uni_galaxyRowUser['ally_id']]) |
| 169 | 168 | { |
| 170 | 169 | $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']]; |
| 171 | - } |
|
| 172 | - else |
|
| 170 | + } else |
|
| 173 | 171 | { |
| 174 | 172 | $allyquery = doquery("SELECT * FROM `{{alliance}}` WHERE `id` = '{$uni_galaxyRowUser['ally_id']}';", '', true); |
| 175 | 173 | $cached['allies'][$uni_galaxyRowUser['ally_id']] = $allyquery; |
@@ -188,8 +186,7 @@ discard block |
||
| 188 | 186 | if ($uni_galaxyRowMoon['destruyed']) |
| 189 | 187 | { |
| 190 | 188 | CheckAbandonPlanetState($uni_galaxyRowMoon); |
| 191 | - } |
|
| 192 | - else |
|
| 189 | + } else |
|
| 193 | 190 | { |
| 194 | 191 | $moon_fleet_id = 0; |
| 195 | 192 | $fleets_to_planet = flt_get_fleets_to_planet(false, $fleet_list[$Planet][PT_MOON]); |
@@ -238,53 +238,53 @@ discard block |
||
| 238 | 238 | $birthday_array = $uni_galaxyRowUser['user_birthday'] ? date_parse($uni_galaxyRowUser['user_birthday']) : array(); |
| 239 | 239 | $user_activity = floor((SN_TIME_NOW - $uni_galaxyRowUser['onlinetime'])/(60*60*24)); |
| 240 | 240 | $template->assign_block_vars('galaxyrow', array( |
| 241 | - 'PLANET_ID' => $uni_galaxyRowPlanet['id'], |
|
| 242 | - 'PLANET_NUM' => $Planet, |
|
| 243 | - 'PLANET_NAME' => $uni_galaxyRowPlanet['name'], |
|
| 244 | - 'PLANET_NAME_JS' => js_safe_string($uni_galaxyRowPlanet['name']), |
|
| 245 | - 'PLANET_DESTROYED' => $uni_galaxyRowPlanet["destruyed"], |
|
| 246 | - 'PLANET_TYPE' => $uni_galaxyRowPlanet["planet_type"], |
|
| 247 | - 'PLANET_ACTIVITY' => floor((SN_TIME_NOW - $uni_galaxyRowPlanet['last_update'])/60), |
|
| 248 | - 'PLANET_IMAGE' => $uni_galaxyRowPlanet['image'], |
|
| 249 | - 'PLANET_FLEET_ID' => $planet_fleet_id, |
|
| 250 | - 'PLANET_DIAMETER' => number_format($uni_galaxyRowPlanet['diameter'], 0, '', '.'), |
|
| 251 | - |
|
| 252 | - 'MOON_NAME_JS' => js_safe_string($uni_galaxyRowMoon['name']), |
|
| 253 | - 'MOON_IMAGE' => $uni_galaxyRowMoon['image'], |
|
| 254 | - 'MOON_DIAMETER' => number_format($uni_galaxyRowMoon['diameter'], 0, '', '.'), |
|
| 255 | - 'MOON_TEMP' => number_format($uni_galaxyRowMoon['temp_min'], 0, '', '.'), |
|
| 256 | - 'MOON_FLEET_ID' => $moon_fleet_id, |
|
| 257 | - |
|
| 258 | - 'DEBRIS' => $uni_galaxyRowPlanet['debris'], |
|
| 259 | - 'DEBRIS_METAL' => $uni_galaxyRowPlanet['debris_metal'], |
|
| 260 | - 'DEBRIS_CRYSTAL' => $uni_galaxyRowPlanet['debris_crystal'], |
|
| 261 | - 'DEBRIS_REST_PERCENT' => $uni_galaxyRowPlanet["debris_rest_percent"], |
|
| 262 | - |
|
| 263 | - 'DEBRIS_RESERVED' => $uni_galaxyRowPlanet['debris_reserved'], |
|
| 264 | - 'DEBRIS_RESERVED_PERCENT' => $uni_galaxyRowPlanet['debris_reserved_percent'], |
|
| 265 | - 'DEBRIS_WILL_GATHER' => $uni_galaxyRowPlanet['debris_will_gather'], |
|
| 266 | - 'DEBRIS_WILL_GATHER_PERCENT' => $uni_galaxyRowPlanet['debris_will_gather_percent'], |
|
| 267 | - 'DEBRIS_GATHER_TOTAL' => $uni_galaxyRowPlanet['debris_gather_total'], |
|
| 268 | - 'DEBRIS_GATHER_TOTAL_PERCENT' => $uni_galaxyRowPlanet['debris_gather_total_percent'], |
|
| 269 | - |
|
| 270 | - 'USER_ID' => $uni_galaxyRowUser['id'], |
|
| 271 | - 'USER_NAME' => player_nick_render_to_html($uni_galaxyRowUser), |
|
| 272 | - 'USER_NAME_JS' => js_safe_string(player_nick_render_to_html($uni_galaxyRowUser)), |
|
| 273 | - 'USER_RANK' => in_array($uni_galaxyRowUser['id'], $user_skip_list) ? '-' : $uni_galaxyRowUser['total_rank'], |
|
| 274 | - 'USER_BANNED' => $uni_galaxyRowUser['banaday'], |
|
| 275 | - 'USER_VACATION' => $uni_galaxyRowUser['vacation'], |
|
| 276 | - 'USER_ACTIVITY' => $user_activity, |
|
| 277 | - 'USER_ATTACKABLE' => $user_activity >= 7, |
|
| 278 | - 'USER_INACTIVE' => $user_activity >= 28, |
|
| 279 | - 'USER_PROTECTED'=> $RowUserPoints <= classSupernova::$config->game_noob_points, |
|
| 280 | - 'USER_NOOB' => $RowUserPoints * classSupernova::$config->game_noob_factor < $CurrentPoints && classSupernova::$config->game_noob_factor, |
|
| 281 | - 'USER_STRONG' => $CurrentPoints * classSupernova::$config->game_noob_factor < $RowUserPoints && classSupernova::$config->game_noob_factor, |
|
| 282 | - 'USER_AUTH' => $uni_galaxyRowUser['authlevel'], |
|
| 283 | - 'USER_ADMIN' => $lang['user_level_shortcut'][$uni_galaxyRowUser['authlevel']], |
|
| 284 | - 'USER_BIRTHDAY' => $birthday_array['month'] == $time_now_parsed['mon'] && $birthday_array['day'] == $time_now_parsed['mday'] ? date(FMT_DATE, SN_TIME_NOW) : 0, |
|
| 285 | - |
|
| 286 | - 'ALLY_ID' => $uni_galaxyRowUser['ally_id'], |
|
| 287 | - 'ALLY_TAG' => $uni_galaxyRowUser['ally_tag'], |
|
| 241 | + 'PLANET_ID' => $uni_galaxyRowPlanet['id'], |
|
| 242 | + 'PLANET_NUM' => $Planet, |
|
| 243 | + 'PLANET_NAME' => $uni_galaxyRowPlanet['name'], |
|
| 244 | + 'PLANET_NAME_JS' => js_safe_string($uni_galaxyRowPlanet['name']), |
|
| 245 | + 'PLANET_DESTROYED' => $uni_galaxyRowPlanet["destruyed"], |
|
| 246 | + 'PLANET_TYPE' => $uni_galaxyRowPlanet["planet_type"], |
|
| 247 | + 'PLANET_ACTIVITY' => floor((SN_TIME_NOW - $uni_galaxyRowPlanet['last_update'])/60), |
|
| 248 | + 'PLANET_IMAGE' => $uni_galaxyRowPlanet['image'], |
|
| 249 | + 'PLANET_FLEET_ID' => $planet_fleet_id, |
|
| 250 | + 'PLANET_DIAMETER' => number_format($uni_galaxyRowPlanet['diameter'], 0, '', '.'), |
|
| 251 | + |
|
| 252 | + 'MOON_NAME_JS' => js_safe_string($uni_galaxyRowMoon['name']), |
|
| 253 | + 'MOON_IMAGE' => $uni_galaxyRowMoon['image'], |
|
| 254 | + 'MOON_DIAMETER' => number_format($uni_galaxyRowMoon['diameter'], 0, '', '.'), |
|
| 255 | + 'MOON_TEMP' => number_format($uni_galaxyRowMoon['temp_min'], 0, '', '.'), |
|
| 256 | + 'MOON_FLEET_ID' => $moon_fleet_id, |
|
| 257 | + |
|
| 258 | + 'DEBRIS' => $uni_galaxyRowPlanet['debris'], |
|
| 259 | + 'DEBRIS_METAL' => $uni_galaxyRowPlanet['debris_metal'], |
|
| 260 | + 'DEBRIS_CRYSTAL' => $uni_galaxyRowPlanet['debris_crystal'], |
|
| 261 | + 'DEBRIS_REST_PERCENT' => $uni_galaxyRowPlanet["debris_rest_percent"], |
|
| 262 | + |
|
| 263 | + 'DEBRIS_RESERVED' => $uni_galaxyRowPlanet['debris_reserved'], |
|
| 264 | + 'DEBRIS_RESERVED_PERCENT' => $uni_galaxyRowPlanet['debris_reserved_percent'], |
|
| 265 | + 'DEBRIS_WILL_GATHER' => $uni_galaxyRowPlanet['debris_will_gather'], |
|
| 266 | + 'DEBRIS_WILL_GATHER_PERCENT' => $uni_galaxyRowPlanet['debris_will_gather_percent'], |
|
| 267 | + 'DEBRIS_GATHER_TOTAL' => $uni_galaxyRowPlanet['debris_gather_total'], |
|
| 268 | + 'DEBRIS_GATHER_TOTAL_PERCENT' => $uni_galaxyRowPlanet['debris_gather_total_percent'], |
|
| 269 | + |
|
| 270 | + 'USER_ID' => $uni_galaxyRowUser['id'], |
|
| 271 | + 'USER_NAME' => player_nick_render_to_html($uni_galaxyRowUser), |
|
| 272 | + 'USER_NAME_JS' => js_safe_string(player_nick_render_to_html($uni_galaxyRowUser)), |
|
| 273 | + 'USER_RANK' => in_array($uni_galaxyRowUser['id'], $user_skip_list) ? '-' : $uni_galaxyRowUser['total_rank'], |
|
| 274 | + 'USER_BANNED' => $uni_galaxyRowUser['banaday'], |
|
| 275 | + 'USER_VACATION' => $uni_galaxyRowUser['vacation'], |
|
| 276 | + 'USER_ACTIVITY' => $user_activity, |
|
| 277 | + 'USER_ATTACKABLE' => $user_activity >= 7, |
|
| 278 | + 'USER_INACTIVE' => $user_activity >= 28, |
|
| 279 | + 'USER_PROTECTED'=> $RowUserPoints <= classSupernova::$config->game_noob_points, |
|
| 280 | + 'USER_NOOB' => $RowUserPoints * classSupernova::$config->game_noob_factor < $CurrentPoints && classSupernova::$config->game_noob_factor, |
|
| 281 | + 'USER_STRONG' => $CurrentPoints * classSupernova::$config->game_noob_factor < $RowUserPoints && classSupernova::$config->game_noob_factor, |
|
| 282 | + 'USER_AUTH' => $uni_galaxyRowUser['authlevel'], |
|
| 283 | + 'USER_ADMIN' => $lang['user_level_shortcut'][$uni_galaxyRowUser['authlevel']], |
|
| 284 | + 'USER_BIRTHDAY' => $birthday_array['month'] == $time_now_parsed['mon'] && $birthday_array['day'] == $time_now_parsed['mday'] ? date(FMT_DATE, SN_TIME_NOW) : 0, |
|
| 285 | + |
|
| 286 | + 'ALLY_ID' => $uni_galaxyRowUser['ally_id'], |
|
| 287 | + 'ALLY_TAG' => $uni_galaxyRowUser['ally_tag'], |
|
| 288 | 288 | )); |
| 289 | 289 | } |
| 290 | 290 | |
@@ -350,53 +350,53 @@ discard block |
||
| 350 | 350 | $system_name = doquery("select `universe_name` from `{{universe}}` where `universe_galaxy` = {$uni_galaxy} and `universe_system` = {$uni_system} limit 1;", true); |
| 351 | 351 | |
| 352 | 352 | $template->assign_vars(array( |
| 353 | - 'rows' => $Result, |
|
| 354 | - 'userCount' => classSupernova::$config->users_amount, |
|
| 355 | - 'ALLY_COUNT' => $ally_count['ally_count'], |
|
| 356 | - 'PLANET_EXPEDITION' => classSupernova::$config->game_maxPlanet + 1, |
|
| 357 | - 'curPlanetID' => $planetrow['id'], |
|
| 358 | - 'curPlanetG' => $planetrow['galaxy'], |
|
| 359 | - 'curPlanetS' => $planetrow['system'], |
|
| 360 | - 'curPlanetP' => $planetrow['planet'], |
|
| 361 | - 'curPlanetPT' => $planetrow['planet_type'], |
|
| 362 | - 'deathStars' => mrc_get_level($user, $planetrow, SHIP_HUGE_DEATH_STAR, false, true), |
|
| 363 | - 'galaxy' => $uni_galaxy, |
|
| 364 | - 'system' => $uni_system, |
|
| 365 | - 'planet' => $planet, |
|
| 366 | - 'MIPs' => round($CurrentMIP), |
|
| 367 | - 'MODE' => $mode, |
|
| 368 | - 'planets' => $planetcount, |
|
| 369 | - 'SPs' => pretty_number(mrc_get_level($user, $planetrow, SHIP_SPY, false, true)), |
|
| 370 | - 'SHOW_ADMIN' => SHOW_ADMIN, |
|
| 371 | - 'fleet_count' => $flying_fleet_count, |
|
| 372 | - 'fleet_max' => $fleetmax, |
|
| 373 | - 'ALLY_ID' => $user['ally_id'], |
|
| 374 | - 'USER_ID' => $user['id'], |
|
| 375 | - 'ACT_SPIO' => classSupernova::$user_options[PLAYER_OPTION_FLEET_SPY_DEFAULT], |
|
| 376 | - 'ACT_SPY' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_SPYING], |
|
| 377 | - 'ACT_WRITE' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_PM], |
|
| 378 | - 'ACT_STATISTICS' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_STATS], |
|
| 379 | - 'ACT_INFO' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_PROFILE], |
|
| 380 | - 'ACT_FRIEND' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_BUDDY], |
|
| 381 | - 'opt_uni_tooltip_time'=> classSupernova::$user_options[PLAYER_OPTION_TOOLTIP_DELAY], |
|
| 382 | - 'opt_uni_avatar_user' => $user['opt_uni_avatar_user'], |
|
| 383 | - 'opt_uni_avatar_ally' => $user['opt_uni_avatar_ally'], |
|
| 384 | - 'ACT_MISSILE' => $is_missile, |
|
| 385 | - 'PLANET_PHALANX' => $HavePhalanx && $uni_galaxy == $CurrentGalaxy && $uni_system >= $CurrentSystem - $PhalanxRange && $uni_system <= $CurrentSystem + $PhalanxRange, |
|
| 386 | - 'PAGE_HINT' => $lang['gal_sys_hint'], |
|
| 387 | - 'PLANET_RECYCLERS' => $planet_recyclers_orbiting, |
|
| 388 | - 'PLANET_RECYCLERS_TEXT' => pretty_number($planet_recyclers_orbiting), |
|
| 389 | - 'GALAXY_NAME' => $galaxy_name['universe_name'], |
|
| 390 | - 'SYSTEM_NAME' => $system_name['universe_name'], |
|
| 391 | - 'COL_SPAN' => $colspan + 9, |
|
| 392 | - 'COL_SPAN_PLUS' => $colspan + 3, |
|
| 393 | - |
|
| 394 | - 'COL_SPAN_NEW' => $colspan + 4, |
|
| 395 | - 'COL_SPAN_NEW_COLONIZE' => $colspan - 2, |
|
| 396 | - |
|
| 397 | - 'PLAYER_OPTION_UNIVERSE_OLD' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_OLD], |
|
| 398 | - 'PLAYER_OPTION_UNIVERSE_DISABLE_COLONIZE' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_DISABLE_COLONIZE], |
|
| 399 | - ) |
|
| 353 | + 'rows' => $Result, |
|
| 354 | + 'userCount' => classSupernova::$config->users_amount, |
|
| 355 | + 'ALLY_COUNT' => $ally_count['ally_count'], |
|
| 356 | + 'PLANET_EXPEDITION' => classSupernova::$config->game_maxPlanet + 1, |
|
| 357 | + 'curPlanetID' => $planetrow['id'], |
|
| 358 | + 'curPlanetG' => $planetrow['galaxy'], |
|
| 359 | + 'curPlanetS' => $planetrow['system'], |
|
| 360 | + 'curPlanetP' => $planetrow['planet'], |
|
| 361 | + 'curPlanetPT' => $planetrow['planet_type'], |
|
| 362 | + 'deathStars' => mrc_get_level($user, $planetrow, SHIP_HUGE_DEATH_STAR, false, true), |
|
| 363 | + 'galaxy' => $uni_galaxy, |
|
| 364 | + 'system' => $uni_system, |
|
| 365 | + 'planet' => $planet, |
|
| 366 | + 'MIPs' => round($CurrentMIP), |
|
| 367 | + 'MODE' => $mode, |
|
| 368 | + 'planets' => $planetcount, |
|
| 369 | + 'SPs' => pretty_number(mrc_get_level($user, $planetrow, SHIP_SPY, false, true)), |
|
| 370 | + 'SHOW_ADMIN' => SHOW_ADMIN, |
|
| 371 | + 'fleet_count' => $flying_fleet_count, |
|
| 372 | + 'fleet_max' => $fleetmax, |
|
| 373 | + 'ALLY_ID' => $user['ally_id'], |
|
| 374 | + 'USER_ID' => $user['id'], |
|
| 375 | + 'ACT_SPIO' => classSupernova::$user_options[PLAYER_OPTION_FLEET_SPY_DEFAULT], |
|
| 376 | + 'ACT_SPY' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_SPYING], |
|
| 377 | + 'ACT_WRITE' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_PM], |
|
| 378 | + 'ACT_STATISTICS' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_STATS], |
|
| 379 | + 'ACT_INFO' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_PROFILE], |
|
| 380 | + 'ACT_FRIEND' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_ICON_BUDDY], |
|
| 381 | + 'opt_uni_tooltip_time'=> classSupernova::$user_options[PLAYER_OPTION_TOOLTIP_DELAY], |
|
| 382 | + 'opt_uni_avatar_user' => $user['opt_uni_avatar_user'], |
|
| 383 | + 'opt_uni_avatar_ally' => $user['opt_uni_avatar_ally'], |
|
| 384 | + 'ACT_MISSILE' => $is_missile, |
|
| 385 | + 'PLANET_PHALANX' => $HavePhalanx && $uni_galaxy == $CurrentGalaxy && $uni_system >= $CurrentSystem - $PhalanxRange && $uni_system <= $CurrentSystem + $PhalanxRange, |
|
| 386 | + 'PAGE_HINT' => $lang['gal_sys_hint'], |
|
| 387 | + 'PLANET_RECYCLERS' => $planet_recyclers_orbiting, |
|
| 388 | + 'PLANET_RECYCLERS_TEXT' => pretty_number($planet_recyclers_orbiting), |
|
| 389 | + 'GALAXY_NAME' => $galaxy_name['universe_name'], |
|
| 390 | + 'SYSTEM_NAME' => $system_name['universe_name'], |
|
| 391 | + 'COL_SPAN' => $colspan + 9, |
|
| 392 | + 'COL_SPAN_PLUS' => $colspan + 3, |
|
| 393 | + |
|
| 394 | + 'COL_SPAN_NEW' => $colspan + 4, |
|
| 395 | + 'COL_SPAN_NEW_COLONIZE' => $colspan - 2, |
|
| 396 | + |
|
| 397 | + 'PLAYER_OPTION_UNIVERSE_OLD' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_OLD], |
|
| 398 | + 'PLAYER_OPTION_UNIVERSE_DISABLE_COLONIZE' => classSupernova::$user_options[PLAYER_OPTION_UNIVERSE_DISABLE_COLONIZE], |
|
| 399 | + ) |
|
| 400 | 400 | ); |
| 401 | 401 | |
| 402 | 402 | if($scan) { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $uni_system = sys_get_param_int('system', $planetrow['system']); |
| 31 | 31 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
| 32 | 32 | |
| 33 | -if($mode == 'name') { |
|
| 33 | +if ($mode == 'name') { |
|
| 34 | 34 | require_once('includes/includes/uni_rename.php'); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $planet_precache_query = DBStaticPlanet::db_planet_list_in_system($uni_galaxy, $uni_system); |
| 83 | 83 | // while($planet_row = db_fetch($planet_precache_query)) |
| 84 | -if(!empty($planet_precache_query)) |
|
| 85 | -foreach($planet_precache_query as $planet_row) |
|
| 84 | +if (!empty($planet_precache_query)) |
|
| 85 | +foreach ($planet_precache_query as $planet_row) |
|
| 86 | 86 | { |
| 87 | 87 | $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row; |
| 88 | 88 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | // $fleet_list[$fleet_planet][$fleet_type][] = $fleet_row; |
| 102 | 102 | //} |
| 103 | 103 | $system_fleet_list = fleet_list_by_planet_coords($uni_galaxy, $uni_system); |
| 104 | -foreach($system_fleet_list as $fleet_row) { |
|
| 104 | +foreach ($system_fleet_list as $fleet_row) { |
|
| 105 | 105 | $fleet_planet = $fleet_row['fleet_mess'] == 0 ? $fleet_row['fleet_end_planet'] : $fleet_row['fleet_start_planet']; |
| 106 | 106 | $fleet_type = $fleet_row['fleet_mess'] == 0 ? $fleet_row['fleet_end_type'] : $fleet_row['fleet_start_type']; |
| 107 | 107 | $fleet_list[$fleet_planet][$fleet_type][] = $fleet_row; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $recycler_info = array(); |
| 113 | 113 | $planet_recyclers_orbiting = 0; |
| 114 | 114 | $recyclers_fleet = array(); |
| 115 | -foreach(sn_get_groups('flt_recyclers') as $recycler_id) |
|
| 115 | +foreach (sn_get_groups('flt_recyclers') as $recycler_id) |
|
| 116 | 116 | { |
| 117 | 117 | $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user); |
| 118 | 118 | $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id); |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | $planet_fleet_id = 0; |
| 140 | 140 | if ($uni_galaxyRowPlanet['destruyed']) |
| 141 | 141 | { |
| 142 | - CheckAbandonPlanetState ($uni_galaxyRowPlanet); |
|
| 142 | + CheckAbandonPlanetState($uni_galaxyRowPlanet); |
|
| 143 | 143 | } |
| 144 | - elseif($uni_galaxyRowPlanet['id']) |
|
| 144 | + elseif ($uni_galaxyRowPlanet['id']) |
|
| 145 | 145 | { |
| 146 | - if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) |
|
| 146 | + if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) |
|
| 147 | 147 | { |
| 148 | 148 | $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']]; |
| 149 | 149 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if(!$uni_galaxyRowUser['id']) |
|
| 156 | + if (!$uni_galaxyRowUser['id']) |
|
| 157 | 157 | { |
| 158 | 158 | $debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503); |
| 159 | 159 | $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24; |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | DBStaticPlanet::db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}"); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if($uni_galaxyRowUser['id']) |
|
| 164 | + if ($uni_galaxyRowUser['id']) |
|
| 165 | 165 | { |
| 166 | 166 | $planetcount++; |
| 167 | - if($uni_galaxyRowUser['ally_id']) |
|
| 167 | + if ($uni_galaxyRowUser['ally_id']) |
|
| 168 | 168 | { |
| 169 | - if($cached['allies'][$uni_galaxyRowUser['ally_id']]) |
|
| 169 | + if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) |
|
| 170 | 170 | { |
| 171 | 171 | $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']]; |
| 172 | 172 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $fleets_to_planet = flt_get_fleets_to_planet(false, $fleet_list[$Planet][PT_PLANET]); |
| 181 | - if($fleets_to_planet['own']['count']) |
|
| 181 | + if ($fleets_to_planet['own']['count']) |
|
| 182 | 182 | { |
| 183 | 183 | $planet_fleet_id = $fleet_id; |
| 184 | 184 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | $moon_fleet_id = 0; |
| 196 | 196 | $fleets_to_planet = flt_get_fleets_to_planet(false, $fleet_list[$Planet][PT_MOON]); |
| 197 | - if($fleets_to_planet['own']['count']) |
|
| 197 | + if ($fleets_to_planet['own']['count']) |
|
| 198 | 198 | { |
| 199 | 199 | $moon_fleet_id = $fleet_id; |
| 200 | 200 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | // $recyclers_incoming = 0; |
| 208 | 208 | $recyclers_incoming_capacity = 0; |
| 209 | 209 | $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal']; |
| 210 | - if($uni_galaxyRowPlanet['debris']) { |
|
| 211 | - if($fleet_list[$Planet][PT_DEBRIS]) { |
|
| 212 | - foreach($fleet_list[$Planet][PT_DEBRIS] as $fleet_row) { |
|
| 213 | - if($fleet_row['fleet_owner'] == $user['id']) { |
|
| 210 | + if ($uni_galaxyRowPlanet['debris']) { |
|
| 211 | + if ($fleet_list[$Planet][PT_DEBRIS]) { |
|
| 212 | + foreach ($fleet_list[$Planet][PT_DEBRIS] as $fleet_row) { |
|
| 213 | + if ($fleet_row['fleet_owner'] == $user['id']) { |
|
| 214 | 214 | $fleet_data = sys_unit_str2arr($fleet_row['fleet_array']); |
| 215 | - foreach($recycler_info as $recycler_id => $recycler_data) { |
|
| 215 | + foreach ($recycler_info as $recycler_id => $recycler_data) { |
|
| 216 | 216 | $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity']; |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $RowUserPoints = $uni_galaxyRowUser['total_points']; |
| 238 | 238 | $birthday_array = $uni_galaxyRowUser['user_birthday'] ? date_parse($uni_galaxyRowUser['user_birthday']) : array(); |
| 239 | - $user_activity = floor((SN_TIME_NOW - $uni_galaxyRowUser['onlinetime'])/(60*60*24)); |
|
| 239 | + $user_activity = floor((SN_TIME_NOW - $uni_galaxyRowUser['onlinetime']) / (60 * 60 * 24)); |
|
| 240 | 240 | $template->assign_block_vars('galaxyrow', array( |
| 241 | 241 | 'PLANET_ID' => $uni_galaxyRowPlanet['id'], |
| 242 | 242 | 'PLANET_NUM' => $Planet, |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | 'PLANET_NAME_JS' => js_safe_string($uni_galaxyRowPlanet['name']), |
| 245 | 245 | 'PLANET_DESTROYED' => $uni_galaxyRowPlanet["destruyed"], |
| 246 | 246 | 'PLANET_TYPE' => $uni_galaxyRowPlanet["planet_type"], |
| 247 | - 'PLANET_ACTIVITY' => floor((SN_TIME_NOW - $uni_galaxyRowPlanet['last_update'])/60), |
|
| 247 | + 'PLANET_ACTIVITY' => floor((SN_TIME_NOW - $uni_galaxyRowPlanet['last_update']) / 60), |
|
| 248 | 248 | 'PLANET_IMAGE' => $uni_galaxyRowPlanet['image'], |
| 249 | 249 | 'PLANET_FLEET_ID' => $planet_fleet_id, |
| 250 | 250 | 'PLANET_DIAMETER' => number_format($uni_galaxyRowPlanet['diameter'], 0, '', '.'), |
@@ -290,21 +290,21 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | tpl_assign_fleet($template, $fleets); |
| 292 | 292 | |
| 293 | -foreach(sn_get_groups('defense_active') as $unit_id) { |
|
| 293 | +foreach (sn_get_groups('defense_active') as $unit_id) { |
|
| 294 | 294 | $template->assign_block_vars('defense_active', array( |
| 295 | 295 | 'ID' => $unit_id, |
| 296 | 296 | 'NAME' => $lang['tech'][$unit_id], |
| 297 | 297 | )); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | -foreach($cached['users'] as $PlanetUser) { |
|
| 301 | - if(!$PlanetUser) { |
|
| 300 | +foreach ($cached['users'] as $PlanetUser) { |
|
| 301 | + if (!$PlanetUser) { |
|
| 302 | 302 | continue; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $user_ally = $cached['allies'][$PlanetUser['ally_id']]; |
| 306 | - if(isset($user_ally)) { |
|
| 307 | - if($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
| 306 | + if (isset($user_ally)) { |
|
| 307 | + if ($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
| 308 | 308 | $user_rank_title = $user_ally['ally_owner_range']; |
| 309 | 309 | } else { |
| 310 | 310 | $ally_ranks = explode(';', $user_ally['ranklist']); |
@@ -327,9 +327,9 @@ discard block |
||
| 327 | 327 | )); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | -foreach($cached['allies'] as $PlanetAlly) |
|
| 330 | +foreach ($cached['allies'] as $PlanetAlly) |
|
| 331 | 331 | { |
| 332 | - if($PlanetAlly) |
|
| 332 | + if ($PlanetAlly) |
|
| 333 | 333 | { |
| 334 | 334 | $template->assign_block_vars('alliances', array( |
| 335 | 335 | 'ID' => $PlanetAlly['id'], |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | ) |
| 400 | 400 | ); |
| 401 | 401 | |
| 402 | -if($scan) { |
|
| 402 | +if ($scan) { |
|
| 403 | 403 | $template_result = array_merge($template_result, array( |
| 404 | 404 | 'GLOBAL_DISPLAY_MENU' => false, |
| 405 | 405 | 'GLOBAL_DISPLAY_NAVBAR' => false, |
@@ -26,7 +26,9 @@ |
||
| 26 | 26 | * DO NOT CHANGE |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!defined('INSIDE')) die(); |
|
| 29 | +if (!defined('INSIDE')) { |
|
| 30 | + die(); |
|
| 31 | +} |
|
| 30 | 32 | |
| 31 | 33 | |
| 32 | 34 | $a_lang_array = (array( |
@@ -26,7 +26,9 @@ |
||
| 26 | 26 | * DO NOT CHANGE |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!defined('INSIDE')) die(); |
|
| 29 | +if (!defined('INSIDE')) { |
|
| 30 | + die(); |
|
| 31 | +} |
|
| 30 | 32 | |
| 31 | 33 | |
| 32 | 34 | $a_lang_array = (array( |