@@ -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->doquery("SELECT * FROM `{{account}}` WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true); |
| 208 | 208 | |
| 209 | 209 | return $this->assign_from_db_row($account_row); |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | `account_email` = LOWER('{$email_safe}'), |
| 277 | 277 | `account_language` = '{$language_safe}'" |
| 278 | 278 | ); |
| 279 | - if(!$result) { |
|
| 279 | + if (!$result) { |
|
| 280 | 280 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if(!($account_id = $this->db->db_insert_id())) { |
|
| 283 | + if (!($account_id = $this->db->db_insert_id())) { |
|
| 284 | 284 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 285 | 285 | } |
| 286 | 286 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | WHERE `account_id` = '{$account_id_safe}'" |
| 311 | 311 | ) ? true : false; |
| 312 | 312 | |
| 313 | - if($result) { |
|
| 313 | + if ($result) { |
|
| 314 | 314 | $result = $this->db_get_by_id($this->account_id); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) { |
| 400 | 400 | global $debug, $mm_change_legit, $config; |
| 401 | 401 | |
| 402 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 402 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 403 | 403 | $debug->error('Ошибка при попытке манипуляции с ММ'); |
| 404 | 404 | return false; |
| 405 | 405 | } |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | $mm_change_legit = true; |
| 410 | 410 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
| 411 | - if($already_changed) { |
|
| 411 | + if ($already_changed) { |
|
| 412 | 412 | $metamatter_total_delta = 0; |
| 413 | 413 | $result = -1; |
| 414 | 414 | } else { |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | ($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}'" : '') . |
| 422 | 422 | " WHERE `account_id` = {$account_id_safe}" |
| 423 | 423 | ); |
| 424 | - if(!$result) { |
|
| 424 | + if (!$result) { |
|
| 425 | 425 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 426 | 426 | } |
| 427 | 427 | $result = SN::$db->db_affected_rows(); |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $this->awardImmortal($metamatter, $config); |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - if(empty(core_auth::$user['id'])) { |
|
| 432 | + if (empty(core_auth::$user['id'])) { |
|
| 433 | 433 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
| 434 | 434 | reset($user_list); |
| 435 | 435 | $user_id_unsafe = key($user_list); |
@@ -438,30 +438,30 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
| 440 | 440 | |
| 441 | - if(!$result) { |
|
| 441 | + if (!$result) { |
|
| 442 | 442 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if(!$already_changed) { |
|
| 445 | + if (!$already_changed) { |
|
| 446 | 446 | $this->account_metamatter += $metamatter; |
| 447 | 447 | $this->account_metamatter_total += $metamatter_total_delta; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - if(is_array($comment)) { |
|
| 450 | + if (is_array($comment)) { |
|
| 451 | 451 | $comment = call_user_func_array('sprintf', $comment); |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
| 455 | 455 | |
| 456 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
| 456 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
| 457 | 457 | $old_referral = doquery("SELECT * FROM `{{referrals}}` WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true); |
| 458 | - if($old_referral['id']) { |
|
| 458 | + if ($old_referral['id']) { |
|
| 459 | 459 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
| 460 | 460 | doquery("UPDATE `{{referrals}}` SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;"); |
| 461 | 461 | $new_referral = doquery("SELECT * FROM `{{referrals}}` WHERE `id` = {$user_id_safe} LIMIT 1;", '', true); |
| 462 | 462 | |
| 463 | 463 | $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); |
| 464 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 464 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 465 | 465 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
| 466 | 466 | } |
| 467 | 467 | } |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @throws Exception |
| 478 | 478 | */ |
| 479 | 479 | public function cookieSet($rememberMe = false, $domain = null) { |
| 480 | - if(!$this->is_exists) { |
|
| 480 | + if (!$this->is_exists) { |
|
| 481 | 481 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
| 482 | 482 | } |
| 483 | 483 | |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | // OK v4.1 |
| 497 | 497 | public function cookieClear($domain = null) { |
| 498 | 498 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
| 499 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 499 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 500 | 500 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain); |
| 501 | 501 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain); |
| 502 | 502 | } else { |
@@ -506,14 +506,14 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | public function cookieLogin(&$rememberMe = false) { |
| 508 | 508 | // Пытаемся войти по куке |
| 509 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
| 510 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 509 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
| 510 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 511 | 511 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
| 512 | 512 | } else { |
| 513 | 513 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - if( |
|
| 516 | + if ( |
|
| 517 | 517 | $this->db_get_by_id($account_id_unsafe) |
| 518 | 518 | && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted) |
| 519 | 519 | ) { |
@@ -538,10 +538,10 @@ discard block |
||
| 538 | 538 | * @param classConfig $config |
| 539 | 539 | */ |
| 540 | 540 | protected function awardImmortal($metamatter, $config) { |
| 541 | - if(!is_object($awardModule = moduleAward())) { |
|
| 541 | + if (!is_object($awardModule = moduleAward())) { |
|
| 542 | 542 | return; |
| 543 | 543 | } |
| 544 | - if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal ) { |
|
| 544 | + if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal) { |
|
| 545 | 545 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list(ACCOUNT_PROVIDER_LOCAL, $this->account_id); |
| 546 | 546 | if (!empty($account_translation)) { |
| 547 | 547 | reset($account_translation); |
@@ -563,10 +563,10 @@ discard block |
||
| 563 | 563 | * @return bool|mysqli_result|null |
| 564 | 564 | */ |
| 565 | 565 | public function getMetamatterSum($where = '', $group = '') { |
| 566 | - if(is_array($where) && !empty($where)) { |
|
| 566 | + if (is_array($where) && !empty($where)) { |
|
| 567 | 567 | $where = implode(' AND ', $where); |
| 568 | 568 | } |
| 569 | - if(is_array($group) && !empty($group)) { |
|
| 569 | + if (is_array($group) && !empty($group)) { |
|
| 570 | 570 | $group = implode(',', $group); |
| 571 | 571 | } |
| 572 | 572 | |