@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | $this->secret_word = SN::$sn_secret_word; |
| 93 | 93 | |
| 94 | 94 | $snTableNames = $this->db->schema()->getSnTables(); |
| 95 | - foreach($this->table_check as $table_name) { |
|
| 96 | - if(empty($snTableNames[$table_name])) { |
|
| 95 | + foreach ($this->table_check as $table_name) { |
|
| 96 | + if (empty($snTableNames[$table_name])) { |
|
| 97 | 97 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
| 98 | 98 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
| 99 | 99 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | // OK v4.6 |
| 119 | 119 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
| 120 | - if(!$this->password_check($old_password_unsafe)) { |
|
| 120 | + if (!$this->password_check($old_password_unsafe)) { |
|
| 121 | 121 | return false; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | // OK v4.5 |
| 139 | 139 | public function assign_from_db_row($row) { |
| 140 | 140 | $this->reset(); |
| 141 | - if(empty($row) || !is_array($row)) { |
|
| 141 | + if (empty($row) || !is_array($row)) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | $this->account_id = $row['account_id']; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $this->reset(); |
| 204 | 204 | |
| 205 | 205 | $email_safe = $this->db->db_escape($email_unsafe); |
| 206 | - if($email_safe) { |
|
| 206 | + if ($email_safe) { |
|
| 207 | 207 | $account_row = $this->db->doQueryAndFetch("SELECT * FROM `{{account}}` WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;"); |
| 208 | 208 | |
| 209 | 209 | return $this->assign_from_db_row($account_row); |
@@ -283,11 +283,11 @@ discard block |
||
| 283 | 283 | `account_email` = LOWER('{$email_safe}'), |
| 284 | 284 | `account_language` = '{$language_safe}'" |
| 285 | 285 | ); |
| 286 | - if(!$result) { |
|
| 286 | + if (!$result) { |
|
| 287 | 287 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if(!($account_id = $this->db->db_insert_id())) { |
|
| 290 | + if (!($account_id = $this->db->db_insert_id())) { |
|
| 291 | 291 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 292 | 292 | } |
| 293 | 293 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | WHERE `account_id` = '{$account_id_safe}'" |
| 318 | 318 | ) ? true : false; |
| 319 | 319 | |
| 320 | - if($result) { |
|
| 320 | + if ($result) { |
|
| 321 | 321 | $result = $this->db_get_by_id($this->account_id); |
| 322 | 322 | } |
| 323 | 323 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) { |
| 410 | 410 | global $debug, $mm_change_legit, $config; |
| 411 | 411 | |
| 412 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 412 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 413 | 413 | $debug->error('Ошибка при попытке манипуляции с ММ'); |
| 414 | 414 | return false; |
| 415 | 415 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | $mm_change_legit = true; |
| 420 | 420 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
| 421 | - if($already_changed) { |
|
| 421 | + if ($already_changed) { |
|
| 422 | 422 | $metamatter_total_delta = 0; |
| 423 | 423 | $result = -1; |
| 424 | 424 | } else { |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal} AND `account_immortal` IS NULL, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') . |
| 432 | 432 | " WHERE `account_id` = {$account_id_safe}" |
| 433 | 433 | ); |
| 434 | - if(!$result) { |
|
| 434 | + if (!$result) { |
|
| 435 | 435 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 436 | 436 | } |
| 437 | 437 | $result = SN::$db->db_affected_rows(); |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | $this->awardImmortal($metamatter, $config); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if(empty(core_auth::$user['id'])) { |
|
| 442 | + if (empty(core_auth::$user['id'])) { |
|
| 443 | 443 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
| 444 | 444 | reset($user_list); |
| 445 | 445 | $user_id_unsafe = key($user_list); |
@@ -448,30 +448,30 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
| 450 | 450 | |
| 451 | - if(!$result) { |
|
| 451 | + if (!$result) { |
|
| 452 | 452 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if(!$already_changed) { |
|
| 455 | + if (!$already_changed) { |
|
| 456 | 456 | $this->account_metamatter += $metamatter; |
| 457 | 457 | $this->account_metamatter_total += $metamatter_total_delta; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if(is_array($comment)) { |
|
| 460 | + if (is_array($comment)) { |
|
| 461 | 461 | $comment = call_user_func_array('sprintf', $comment); |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
| 465 | 465 | |
| 466 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
| 466 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
| 467 | 467 | $old_referral = doquery("SELECT * FROM `{{referrals}}` WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true); |
| 468 | - if($old_referral['id']) { |
|
| 468 | + if ($old_referral['id']) { |
|
| 469 | 469 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
| 470 | 470 | doquery("UPDATE `{{referrals}}` SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;"); |
| 471 | 471 | $new_referral = doquery("SELECT * FROM `{{referrals}}` WHERE `id` = {$user_id_safe} LIMIT 1;", '', true); |
| 472 | 472 | |
| 473 | 473 | $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0); |
| 474 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 474 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 475 | 475 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
| 476 | 476 | } |
| 477 | 477 | } |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | * @throws Exception |
| 488 | 488 | */ |
| 489 | 489 | public function cookieSet($rememberMe = false, $domain = null) { |
| 490 | - if(!$this->is_exists) { |
|
| 490 | + if (!$this->is_exists) { |
|
| 491 | 491 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
| 492 | 492 | } |
| 493 | 493 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | // OK v4.1 |
| 507 | 507 | public function cookieClear($domain = null) { |
| 508 | 508 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
| 509 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 509 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 510 | 510 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain); |
| 511 | 511 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain); |
| 512 | 512 | } else { |
@@ -516,14 +516,14 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | public function cookieLogin(&$rememberMe = false) { |
| 518 | 518 | // Пытаемся войти по куке |
| 519 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
| 520 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 519 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
| 520 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 521 | 521 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
| 522 | 522 | } else { |
| 523 | 523 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - if( |
|
| 526 | + if ( |
|
| 527 | 527 | $this->db_get_by_id($account_id_unsafe) |
| 528 | 528 | && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted) |
| 529 | 529 | ) { |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | * @param classConfig $config |
| 549 | 549 | */ |
| 550 | 550 | protected function awardImmortal($metamatter, $config) { |
| 551 | - if(!is_object($awardModule = moduleAward())) { |
|
| 551 | + if (!is_object($awardModule = moduleAward())) { |
|
| 552 | 552 | return; |
| 553 | 553 | } |
| 554 | - if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal ) { |
|
| 554 | + if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal) { |
|
| 555 | 555 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list(ACCOUNT_PROVIDER_LOCAL, $this->account_id); |
| 556 | 556 | if (!empty($account_translation)) { |
| 557 | 557 | reset($account_translation); |
@@ -573,10 +573,10 @@ discard block |
||
| 573 | 573 | * @return bool|mysqli_result|null |
| 574 | 574 | */ |
| 575 | 575 | public function getMetamatterSum($where = '', $group = '') { |
| 576 | - if(is_array($where) && !empty($where)) { |
|
| 576 | + if (is_array($where) && !empty($where)) { |
|
| 577 | 577 | $where = implode(' AND ', $where); |
| 578 | 578 | } |
| 579 | - if(is_array($group) && !empty($group)) { |
|
| 579 | + if (is_array($group) && !empty($group)) { |
|
| 580 | 580 | $group = implode(',', $group); |
| 581 | 581 | } |
| 582 | 582 | |
@@ -167,7 +167,7 @@ |
||
| 167 | 167 | // $logRecord->browserId . '_' . |
| 168 | 168 | // $logRecord->ip . '_' . |
| 169 | 169 | // $logRecord->proxies; |
| 170 | - return $logRecord->userId . '_' . $logRecord->playerEntryId; |
|
| 170 | + return $logRecord->userId . '_' . $logRecord->playerEntryId; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | protected static $is_init = false; |
| 22 | 22 | |
| 23 | 23 | protected static function init() { |
| 24 | - if(!empty(static::$db)) { |
|
| 24 | + if (!empty(static::$db)) { |
|
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | static::$db = SN::$db; |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | $provider_id_safe = intval($provider_id_unsafe); |
| 69 | 69 | !is_array($account_list) ? $account_list = array($account_list) : false; |
| 70 | 70 | |
| 71 | - foreach($account_list as $provider_account_id_unsafe) { |
|
| 71 | + foreach ($account_list as $provider_account_id_unsafe) { |
|
| 72 | 72 | $provider_account_id_safe = intval($provider_account_id_unsafe); |
| 73 | 73 | |
| 74 | 74 | // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером |
| 75 | 75 | $query = static::$db->doquery( |
| 76 | 76 | "SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE" |
| 77 | 77 | ); |
| 78 | - while($row = static::$db->db_fetch($query)) { |
|
| 78 | + while ($row = static::$db->db_fetch($query)) { |
|
| 79 | 79 | $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') . |
| 103 | 103 | "ORDER BY `timestamp` FOR UPDATE" |
| 104 | 104 | ); |
| 105 | - while($row = static::$db->db_fetch($query)) { |
|
| 105 | + while ($row = static::$db->db_fetch($query)) { |
|
| 106 | 106 | $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | $query = $this->db->doQueryAndFetch( |
| 54 | 54 | "SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE" |
| 55 | 55 | ); |
| 56 | - } while($query); |
|
| 56 | + } while ($query); |
|
| 57 | 57 | |
| 58 | 58 | $this->db->doquery( |
| 59 | 59 | "REPLACE INTO {{confirmations}} |
@@ -113,10 +113,10 @@ |
||
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | - * Mark next set operation as delta increment |
|
| 117 | - * |
|
| 118 | - * @return $this |
|
| 119 | - */ |
|
| 116 | + * Mark next set operation as delta increment |
|
| 117 | + * |
|
| 118 | + * @return $this |
|
| 119 | + */ |
|
| 120 | 120 | public function inc() { |
| 121 | 121 | $this->_currentOperation = self::ACCESS_DELTA_INC; |
| 122 | 122 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
| 44 | - $query = doquery( |
|
| 44 | + $query = doquery( |
|
| 45 | 45 | "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
| 46 | 46 | ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
| 47 | 47 | ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } elseif (in_array($unitSnId, sn_get_groups(UNIT_ARTIFACTS_STR))) { |
| 167 | 167 | // Add artifacts to player |
| 168 | 168 | $result = self::dbAdd($playerId, 0, $unitSnId, $amount); |
| 169 | - } elseif (!empty($planetId) && in_array($unitSnId, sn_get_groups([UNIT_SHIPS_STR, UNIT_DEFENCE_STR,]))) { |
|
| 169 | + } elseif (!empty($planetId) && in_array($unitSnId, sn_get_groups([UNIT_SHIPS_STR, UNIT_DEFENCE_STR, ]))) { |
|
| 170 | 170 | // Add fleet or defense to user's capital |
| 171 | 171 | $result = self::dbAdd($playerId, $planetId, $unitSnId, $amount); |
| 172 | 172 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @return bool |
| 191 | 191 | */ |
| 192 | 192 | protected static function dbAdd($playerId, $planetId, $unitSnId, $amount) { |
| 193 | - if (!in_array($unitSnId, sn_get_groups([UNIT_SHIPS_STR, UNIT_DEFENCE_STR, UNIT_ARTIFACTS_STR,]))) { |
|
| 193 | + if (!in_array($unitSnId, sn_get_groups([UNIT_SHIPS_STR, UNIT_DEFENCE_STR, UNIT_ARTIFACTS_STR, ]))) { |
|
| 194 | 194 | return false; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | // 'unit_level' => $level, |
| 224 | 224 | // ]); |
| 225 | 225 | |
| 226 | - $fields += [ |
|
| 226 | + $fields += [ |
|
| 227 | 227 | 'unit_type' => get_unit_param($unitSnId, P_UNIT_TYPE), |
| 228 | 228 | 'unit_level' => $amount, |
| 229 | 229 | ]; |
@@ -93,103 +93,103 @@ |
||
| 93 | 93 | |
| 94 | 94 | // Services -------------------------------------------------------------------------------------------------------- |
| 95 | 95 | // Default db |
| 96 | - $gc->db = function (GlobalContainer $c) { |
|
| 96 | + $gc->db = function(GlobalContainer $c) { |
|
| 97 | 97 | SN::$db = new \DBAL\db_mysql($c); |
| 98 | 98 | |
| 99 | 99 | return SN::$db; |
| 100 | 100 | }; |
| 101 | 101 | |
| 102 | - $gc->debug = function (/** @noinspection PhpUnusedParameterInspection */ |
|
| 102 | + $gc->debug = function(/** @noinspection PhpUnusedParameterInspection */ |
|
| 103 | 103 | GlobalContainer $c) { |
| 104 | 104 | return new \debug(); |
| 105 | 105 | }; |
| 106 | 106 | |
| 107 | - $gc->cache = function (GlobalContainer $gc) { |
|
| 107 | + $gc->cache = function(GlobalContainer $gc) { |
|
| 108 | 108 | return new \classCache($gc->cachePrefix); |
| 109 | 109 | }; |
| 110 | 110 | |
| 111 | - $gc->config = function (GlobalContainer $gc) { |
|
| 111 | + $gc->config = function(GlobalContainer $gc) { |
|
| 112 | 112 | return new \classConfig($gc->cachePrefix); |
| 113 | 113 | }; |
| 114 | 114 | |
| 115 | 115 | |
| 116 | - $gc->repository = function (GlobalContainer $gc) { |
|
| 116 | + $gc->repository = function(GlobalContainer $gc) { |
|
| 117 | 117 | return new Repository($gc); |
| 118 | 118 | }; |
| 119 | 119 | |
| 120 | - $gc->storage = function (GlobalContainer $gc) { |
|
| 120 | + $gc->storage = function(GlobalContainer $gc) { |
|
| 121 | 121 | return new \Storage($gc); |
| 122 | 122 | }; |
| 123 | 123 | |
| 124 | - $gc->repoV2 = function (GlobalContainer $gc) { |
|
| 124 | + $gc->repoV2 = function(GlobalContainer $gc) { |
|
| 125 | 125 | return new RepoV2($gc); |
| 126 | 126 | }; |
| 127 | 127 | |
| 128 | - $gc->storageV2 = function (GlobalContainer $gc) { |
|
| 128 | + $gc->storageV2 = function(GlobalContainer $gc) { |
|
| 129 | 129 | return new StorageV2($gc); |
| 130 | 130 | }; |
| 131 | 131 | |
| 132 | - $gc->storageSqlV2 = function (GlobalContainer $gc) { |
|
| 132 | + $gc->storageSqlV2 = function(GlobalContainer $gc) { |
|
| 133 | 133 | return new StorageSqlV2($gc); |
| 134 | 134 | }; |
| 135 | 135 | |
| 136 | - $gc->design = function (GlobalContainer $gc) { |
|
| 136 | + $gc->design = function(GlobalContainer $gc) { |
|
| 137 | 137 | return new \Design($gc); |
| 138 | 138 | }; |
| 139 | 139 | |
| 140 | - $gc->bbCodeParser = function (GlobalContainer $gc) { |
|
| 140 | + $gc->bbCodeParser = function(GlobalContainer $gc) { |
|
| 141 | 141 | return new \BBCodeParser($gc); |
| 142 | 142 | }; |
| 143 | 143 | |
| 144 | - $gc->fleetDispatcher = function (GlobalContainer $gc) { |
|
| 144 | + $gc->fleetDispatcher = function(GlobalContainer $gc) { |
|
| 145 | 145 | return new \Fleet\FleetDispatcher($gc); |
| 146 | 146 | }; |
| 147 | 147 | |
| 148 | - $gc->watchdog = function (GlobalContainer $gc) { |
|
| 148 | + $gc->watchdog = function(GlobalContainer $gc) { |
|
| 149 | 149 | return new Watchdog($gc); |
| 150 | 150 | }; |
| 151 | 151 | |
| 152 | - $gc->valueStorage = function (GlobalContainer $gc) { |
|
| 152 | + $gc->valueStorage = function(GlobalContainer $gc) { |
|
| 153 | 153 | return new ValueStorage([]); |
| 154 | 154 | }; |
| 155 | 155 | |
| 156 | - $gc->bonusCatalog = function (GlobalContainer $gc) { |
|
| 156 | + $gc->bonusCatalog = function(GlobalContainer $gc) { |
|
| 157 | 157 | return new BonusCatalog($gc); |
| 158 | 158 | }; |
| 159 | 159 | |
| 160 | - $gc->general = function (GlobalContainer $gc) { |
|
| 160 | + $gc->general = function(GlobalContainer $gc) { |
|
| 161 | 161 | return new General($gc); |
| 162 | 162 | }; |
| 163 | 163 | |
| 164 | - $gc->economicHelper = function (GlobalContainer $gc) { |
|
| 164 | + $gc->economicHelper = function(GlobalContainer $gc) { |
|
| 165 | 165 | return new EconomicHelper($gc); |
| 166 | 166 | }; |
| 167 | 167 | |
| 168 | - $gc->playerLevelHelper = function (GlobalContainer $gc) { |
|
| 168 | + $gc->playerLevelHelper = function(GlobalContainer $gc) { |
|
| 169 | 169 | return new PlayerLevelHelper($gc); |
| 170 | 170 | }; |
| 171 | 171 | |
| 172 | - $gc->pimp = function (GlobalContainer $gc) { |
|
| 172 | + $gc->pimp = function(GlobalContainer $gc) { |
|
| 173 | 173 | return new SnPimp($gc); |
| 174 | 174 | }; |
| 175 | 175 | |
| 176 | - $gc->modules = function (GlobalContainer $gc) { |
|
| 176 | + $gc->modules = function(GlobalContainer $gc) { |
|
| 177 | 177 | return new ModulesManager($gc); |
| 178 | 178 | }; |
| 179 | 179 | |
| 180 | 180 | // Dummy objects --------------------------------------------------------------------------------------------------- |
| 181 | - $gc->theUser = function (GlobalContainer $gc) { |
|
| 181 | + $gc->theUser = function(GlobalContainer $gc) { |
|
| 182 | 182 | return new \TheUser($gc); |
| 183 | 183 | }; |
| 184 | 184 | |
| 185 | 185 | |
| 186 | 186 | // Models ---------------------------------------------------------------------------------------------------------- |
| 187 | 187 | $gc->skinEntityClass = \SkinV2::class; |
| 188 | - $gc->skinModel = function (GlobalContainer $gc) { |
|
| 188 | + $gc->skinModel = function(GlobalContainer $gc) { |
|
| 189 | 189 | return new \SkinModel($gc); |
| 190 | 190 | }; |
| 191 | 191 | |
| 192 | - $gc->textModel = function (GlobalContainer $gc) { |
|
| 192 | + $gc->textModel = function(GlobalContainer $gc) { |
|
| 193 | 193 | return new \TextModel($gc); |
| 194 | 194 | }; |
| 195 | 195 | |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | $invitedUserRecord = db_user_by_id($inv); |
| 659 | - if(!empty($invitedUserRecord)) { |
|
| 659 | + if (!empty($invitedUserRecord)) { |
|
| 660 | 660 | $acsPoints += $invitedUserRecord['total_points']; |
| 661 | 661 | } |
| 662 | 662 | } |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | |
| 674 | - if(self::acsIsAcsFull($aks['id'])) { |
|
| 674 | + if (self::acsIsAcsFull($aks['id'])) { |
|
| 675 | 675 | throw new Exception(SN::$lang['fl_aks_too_power']); |
| 676 | 676 | } |
| 677 | 677 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $this->sql_index_field = "{$table_name}_name"; |
| 41 | 41 | $this->sql_value_field = "{$table_name}_value"; |
| 42 | 42 | |
| 43 | - if(!$this->_DB_LOADED) { |
|
| 43 | + if (!$this->_DB_LOADED) { |
|
| 44 | 44 | $this->db_loadAll(); |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function db_loadItem($index) { |
| 62 | 62 | $result = null; |
| 63 | - if($index) { |
|
| 63 | + if ($index) { |
|
| 64 | 64 | $index_safe = db_escape($index); |
| 65 | 65 | $queryResult = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
| 66 | - if(is_array($queryResult) && !empty($queryResult)) { |
|
| 66 | + if (is_array($queryResult) && !empty($queryResult)) { |
|
| 67 | 67 | $this->$index = $result = $queryResult[$this->sql_value_field]; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $this->loadDefaults(); |
| 76 | 76 | |
| 77 | 77 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
| 78 | - while($row = db_fetch($query)) { |
|
| 78 | + while ($row = db_fetch($query)) { |
|
| 79 | 79 | $this[$row[$this->sql_index_field]] = $row[$this->sql_value_field]; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | public function loadDefaults() { |
| 86 | - foreach($this->defaults as $defName => $defValue) { |
|
| 86 | + foreach ($this->defaults as $defName => $defValue) { |
|
| 87 | 87 | $this->$defName = $defValue; |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | public function db_saveItem($item_list, $value = NULL) { |
| 96 | - if(empty($item_list)) { |
|
| 96 | + if (empty($item_list)) { |
|
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | // Сначала записываем данные в базу - что бы поймать все блокировки |
| 103 | 103 | $qry = array(); |
| 104 | - foreach($item_list as $item_name => $item_value) { |
|
| 105 | - if($item_name) { |
|
| 104 | + foreach ($item_list as $item_name => $item_value) { |
|
| 105 | + if ($item_name) { |
|
| 106 | 106 | $item_value = db_escape($item_value === NULL ? $this->$item_name : $item_value); |
| 107 | 107 | $item_name = db_escape($item_name); |
| 108 | 108 | $qry[] = "('{$item_name}', '{$item_value}')"; |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
| 112 | 112 | |
| 113 | 113 | // И только после взятия блокировок - меняем значения в кэше |
| 114 | - foreach($item_list as $item_name => $item_value) { |
|
| 115 | - if($item_name && $item_value !== null) { |
|
| 114 | + foreach ($item_list as $item_name => $item_value) { |
|
| 115 | + if ($item_name && $item_value !== null) { |
|
| 116 | 116 | $this->__set($item_name, $item_value); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -140,14 +140,14 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public function __get($name) { |
| 143 | - if($this->force) { |
|
| 143 | + if ($this->force) { |
|
| 144 | 144 | $this->force = false; |
| 145 | 145 | $value = $this->db_loadItem($name); |
| 146 | 146 | } else { |
| 147 | 147 | $value = parent::__get($name); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if(isset($this->notEmptyFields[$name]) && empty($value) && isset($this->defaults[$name])) { |
|
| 150 | + if (isset($this->notEmptyFields[$name]) && empty($value) && isset($this->defaults[$name])) { |
|
| 151 | 151 | $value = $this->defaults[$name]; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public function __set($name, $value) { |
| 158 | - if($this->force) { |
|
| 158 | + if ($this->force) { |
|
| 159 | 159 | $this->force = false; |
| 160 | 160 | $this->db_saveItem($name, $value); |
| 161 | 161 | } |