@@ -2,12 +2,12 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 4 | 4 | |
| 5 | -if($user['authlevel'] < AUTH_LEVEL_DEVELOPER) { |
|
| 5 | +if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) { |
|
| 6 | 6 | $error_message = SN::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : ( |
| 7 | 7 | !SN::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : '' |
| 8 | 8 | ); |
| 9 | 9 | |
| 10 | - if($error_message) { |
|
| 10 | + if ($error_message) { |
|
| 11 | 11 | messageBox($lang[$error_message], $lang['sys_error'], 'overview.php', 10); |
| 12 | 12 | die(); |
| 13 | 13 | } |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | $current_round = intval(SN::$config->db_loadItem('game_blitz_register_round')); |
| 18 | 18 | $current_price = intval(SN::$config->db_loadItem('game_blitz_register_price')); |
| 19 | 19 | |
| 20 | -if(SN::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
|
| 20 | +if (SN::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
|
| 21 | 21 | sn_db_transaction_start(); |
| 22 | 22 | $user = db_user_by_id($user['id'], true); |
| 23 | 23 | $is_registered = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `user_id` = {$user['id']} AND `round_number` = {$current_round} FOR UPDATE;", true); |
| 24 | - if(sys_get_param_str('register_me')) { |
|
| 25 | - if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
|
| 24 | + if (sys_get_param_str('register_me')) { |
|
| 25 | + if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
|
| 26 | 26 | doquery("INSERT IGNORE INTO {{blitz_registrations}} SET `user_id` = {$user['id']}, `round_number` = {$current_round};"); |
| 27 | 27 | //mm_points_change($user['id'], RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица"); |
| 28 | 28 | SN::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица"); |
@@ -43,17 +43,17 @@ discard block |
||
| 43 | 43 | $blitz_players = 0; |
| 44 | 44 | $blitz_prize_dark_matter = 0; |
| 45 | 45 | $blitz_prize_places = 0; |
| 46 | -if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
|
| 47 | - if(sys_get_param_str('generate')) { |
|
| 46 | +if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
|
| 47 | + if (sys_get_param_str('generate')) { |
|
| 48 | 48 | $next_id = 0; |
| 49 | 49 | $query = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY RAND();"); |
| 50 | - while($row = db_fetch($query)) { |
|
| 50 | + while ($row = db_fetch($query)) { |
|
| 51 | 51 | $next_id++; |
| 52 | 52 | $blitz_name = 'Игрок' . $next_id; |
| 53 | 53 | $blitz_password = sys_random_string(8); |
| 54 | 54 | doquery("UPDATE {{blitz_registrations}} SET blitz_name = '{$blitz_name}', blitz_password = '{$blitz_password}' WHERE `id` = {$row['id']} AND `round_number` = {$current_round};"); |
| 55 | 55 | } |
| 56 | - } elseif(sys_get_param_str('import_generated')) { |
|
| 56 | + } elseif (sys_get_param_str('import_generated')) { |
|
| 57 | 57 | // ЭТО НА БЛИЦЕ!!! |
| 58 | 58 | doquery("DELETE FROM {{users}} WHERE username like 'Игрок%';"); |
| 59 | 59 | doquery("DELETE FROM {{planets}} WHERE id_owner not in (SELECT `id` FROM {{users}});"); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $system = $system_step; |
| 76 | 76 | $planet = round(SN::$config->game_maxPlanet / 2); |
| 77 | 77 | |
| 78 | - foreach($imported_string as &$string_data) { |
|
| 78 | + foreach ($imported_string as &$string_data) { |
|
| 79 | 79 | $string_data = explode(',', $string_data); |
| 80 | 80 | $username_safe = $string_data[0]; |
| 81 | 81 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], Universe::MOON_MAX_SIZE, false); |
| 91 | 91 | |
| 92 | - if(($system += $system_step) >= SN::$config->game_maxSystem) { |
|
| 92 | + if (($system += $system_step) >= SN::$config->game_maxSystem) { |
|
| 93 | 93 | $galaxy++; |
| 94 | 94 | $system = $system_step; |
| 95 | 95 | } |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | SN::$config->db_saveItem('users_amount', SN::$config->users_amount + $new_players); |
| 100 | 100 | // generated_string |
| 101 | - } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
|
| 101 | + } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
|
| 102 | 102 | $blitz_result = explode(';', $blitz_result_string); |
| 103 | 103 | $blitz_last_update = $blitz_result[0]; // Пока не используется |
| 104 | 104 | unset($blitz_result[0]); |
| 105 | - foreach($blitz_result as $blitz_result_data) { |
|
| 105 | + foreach ($blitz_result as $blitz_result_data) { |
|
| 106 | 106 | $blitz_result_data = explode(',', $blitz_result_data); |
| 107 | - if(count($blitz_result_data) == 5) { |
|
| 107 | + if (count($blitz_result_data) == 5) { |
|
| 108 | 108 | $blitz_result_data[1] = db_escape($blitz_result_data[1]); |
| 109 | 109 | doquery( |
| 110 | 110 | "UPDATE `{{blitz_registrations}}` SET |
@@ -118,15 +118,15 @@ discard block |
||
| 118 | 118 | $blitz_result = array(); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if(SN::$config->game_mode == GAME_BLITZ) { |
|
| 121 | + if (SN::$config->game_mode == GAME_BLITZ) { |
|
| 122 | 122 | $blitz_result = array(SN::$config->db_loadItem('var_stat_update')); |
| 123 | 123 | $query = doquery("SELECT id, username, total_rank, total_points, onlinetime FROM {{users}} ORDER BY `id`;"); |
| 124 | - while($row = db_fetch($query)) { |
|
| 124 | + while ($row = db_fetch($query)) { |
|
| 125 | 125 | $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}"; |
| 126 | 126 | } |
| 127 | 127 | } else { |
| 128 | 128 | $query = doquery("SELECT blitz_name, blitz_password, blitz_online FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `id`;"); |
| 129 | - while($row = db_fetch($query)) { |
|
| 129 | + while ($row = db_fetch($query)) { |
|
| 130 | 130 | $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}"; |
| 131 | 131 | $row['blitz_online'] ? $blitz_prize_players_active++ : false; |
| 132 | 132 | $blitz_players++; |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | 'Игрок40' |
| 142 | 142 | */ |
| 143 | 143 | |
| 144 | - if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
|
| 144 | + if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
|
| 145 | 145 | // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'); |
| 146 | 146 | $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places'); |
| 147 | 147 | sn_db_transaction_start(); |
| 148 | 148 | $query = doquery("SELECT * FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `blitz_place` FOR UPDATE;"); |
| 149 | - while($row = db_fetch($query)) { |
|
| 150 | - if(!$row['blitz_place']) { |
|
| 149 | + while ($row = db_fetch($query)) { |
|
| 150 | + if (!$row['blitz_place']) { |
|
| 151 | 151 | continue; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | $blitz_prize_places_actual--; |
| 156 | 156 | |
| 157 | 157 | $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter']; |
| 158 | -pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}",$row['id']); |
|
| 159 | - if($reward) { |
|
| 158 | +pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']); |
|
| 159 | + if ($reward) { |
|
| 160 | 160 | rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf( |
| 161 | 161 | $lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name'] |
| 162 | 162 | )); |
| 163 | 163 | doquery("UPDATE {{blitz_registrations}} SET blitz_reward_dark_matter = blitz_reward_dark_matter + ($reward) WHERE id = {$row['id']} AND `round_number` = {$current_round};"); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
|
| 166 | + if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
|
| 167 | 167 | break; |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | JOIN {{users}} AS u ON u.id = br.user_id |
| 184 | 184 | WHERE br.`round_number` = {$current_round} |
| 185 | 185 | order by `blitz_place`, `timestamp`;"); |
| 186 | -while($row = db_fetch($query)) { |
|
| 186 | +while ($row = db_fetch($query)) { |
|
| 187 | 187 | $tpl_player_data = array( |
| 188 | 188 | 'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)), |
| 189 | 189 | ); |
| 190 | 190 | |
| 191 | - if(SN::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
|
| 191 | + if (SN::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
|
| 192 | 192 | // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда |
| 193 | 193 | $tpl_player_data = array_merge($tpl_player_data, array( |
| 194 | 194 | 'ID' => $row['id'], |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $template->assign_block_vars('registrations', $tpl_player_data); |
| 204 | - if($row['id'] == $user['id']) { |
|
| 204 | + if ($row['id'] == $user['id']) { |
|
| 205 | 205 | $player_registered = $row; |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | unset($player_options[PLAYER_OPTION_TUTORIAL_CURRENT]); |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - array_walk($player_options, function (&$value) { |
|
| 404 | + array_walk($player_options, function(&$value) { |
|
| 405 | 405 | // TODO - Когда будет больше параметров - сделать больше проверок |
| 406 | 406 | $value = intval($value); |
| 407 | 407 | }); |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | $user['id'], |
| 451 | 451 | RPG_NAME_CHANGE, |
| 452 | 452 | -$config->game_user_changename_cost, |
| 453 | - vsprintf('Пользователь ID %1$d сменил имя с "%2$s" на "%3$s"', [$user['id'], $user['username'], $username,]) |
|
| 453 | + vsprintf('Пользователь ID %1$d сменил имя с "%2$s" на "%3$s"', [$user['id'], $user['username'], $username, ]) |
|
| 454 | 454 | ); |
| 455 | 455 | |
| 456 | 456 | case SERVER_PLAYER_NAME_CHANGE_FREE: |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | protected static $autoloaderRegistered = false; |
| 25 | 25 | |
| 26 | 26 | protected static function _constructorStatic() { |
| 27 | - if(!static::$autoloaderRegistered) { |
|
| 27 | + if (!static::$autoloaderRegistered) { |
|
| 28 | 28 | spl_autoload_register(array(__CLASS__, 'autoloader')); |
| 29 | 29 | static::$autoloaderRegistered = true; |
| 30 | 30 | } |
@@ -36,17 +36,17 @@ discard block |
||
| 36 | 36 | public static function autoloader($class) { |
| 37 | 37 | static::_constructorStatic(); |
| 38 | 38 | |
| 39 | - foreach(static::$folders as $data) { |
|
| 39 | + foreach (static::$folders as $data) { |
|
| 40 | 40 | $theClassFile = $class; |
| 41 | 41 | |
| 42 | - if($data[static::P_PREFIX] && strrpos($class, $data[static::P_PREFIX]) !== false) { |
|
| 42 | + if ($data[static::P_PREFIX] && strrpos($class, $data[static::P_PREFIX]) !== false) { |
|
| 43 | 43 | $theClassFile = substr($class, strlen($data[static::P_PREFIX])); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $classFullFileName = str_replace('\\', '/', $data[static::P_FOLDER] . $theClassFile) . DOT_PHP_EX; |
| 47 | - if(file_exists($classFullFileName) && is_file($classFullFileName)) { |
|
| 47 | + if (file_exists($classFullFileName) && is_file($classFullFileName)) { |
|
| 48 | 48 | require_once($classFullFileName); |
| 49 | - if(method_exists($class, '_constructorStatic')) { |
|
| 49 | + if (method_exists($class, '_constructorStatic')) { |
|
| 50 | 50 | $class::_constructorStatic(); |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $absoluteClassRoot = str_replace('\\', '/', SN_ROOT_PHYSICAL . $absoluteClassRoot); |
| 64 | 64 | |
| 65 | - if(!($absoluteClassRoot = realpath($absoluteClassRoot))) { |
|
| 65 | + if (!($absoluteClassRoot = realpath($absoluteClassRoot))) { |
|
| 66 | 66 | // TODO - throw new \Exception("There is some error when installing autoloader for '{$absoluteClassRoot}' class prefix '{$classPrefix}'"); |
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | $absoluteClassRoot = str_replace('\\', '/', $absoluteClassRoot) . '/'; |
| 70 | 70 | |
| 71 | - if($classPrefix && strrpos($classPrefix, 1) != '\\') { |
|
| 71 | + if ($classPrefix && strrpos($classPrefix, 1) != '\\') { |
|
| 72 | 72 | $classPrefix .= '\\'; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null)); |
| 115 | -array_walk($payment_methods_available, function (&$value, $index) { |
|
| 115 | +array_walk($payment_methods_available, function(&$value, $index) { |
|
| 116 | 116 | $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value; |
| 117 | 117 | }); |
| 118 | 118 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | if ($request['metamatter'] && $payment_module_request) { |
| 224 | 224 | try { |
| 225 | 225 | $paymentModuleReal = SN::$gc->modules->getModule($payment_module_request); |
| 226 | - if(!is_object($paymentModuleReal)) { |
|
| 226 | + if (!is_object($paymentModuleReal)) { |
|
| 227 | 227 | throw new Exception('{ Менеджер модулей вернул null вместо платёжного модуля для }' . $payment_module_request, ERR_ERROR); |
| 228 | 228 | } |
| 229 | 229 | /** |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | 'PLAYER_CURRENCY' => $player_currency, |
| 313 | 313 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
| 314 | 314 | |
| 315 | - 'UNIT_AMOUNT' => (float)$request['metamatter'], |
|
| 315 | + 'UNIT_AMOUNT' => (float) $request['metamatter'], |
|
| 316 | 316 | 'UNIT_AMOUNT_TEXT' => HelperString::numberFloorAndFormat($request['metamatter']), |
| 317 | 317 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
| 318 | 318 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |
@@ -191,18 +191,18 @@ discard block |
||
| 191 | 191 | // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ |
| 192 | 192 | // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно |
| 193 | 193 | |
| 194 | - if(sys_get_param('login_player_register_logout')) { |
|
| 194 | + if (sys_get_param('login_player_register_logout')) { |
|
| 195 | 195 | $this->logout(); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | $original_suggest = ''; |
| 199 | 199 | // Смотрим - есть ли у нас данные от пользователя |
| 200 | - if(($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
| 200 | + if (($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
| 201 | 201 | // Попытка регистрации нового игрока из данных, введенных пользователем |
| 202 | 202 | $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name'); |
| 203 | 203 | } else { |
| 204 | - foreach($this->providers_authorised as $provider) { |
|
| 205 | - if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
| 204 | + foreach ($this->providers_authorised as $provider) { |
|
| 205 | + if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
| 206 | 206 | $original_suggest = $provider->player_name_suggest(); |
| 207 | 207 | break; |
| 208 | 208 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру |
| 213 | - if(!$this->player_suggested_name) { |
|
| 213 | + if (!$this->player_suggested_name) { |
|
| 214 | 214 | $max_user_id = db_player_get_max_id(); // 4.5 |
| 215 | 215 | // TODO - предлагать имя игрока по локали |
| 216 | 216 | |
@@ -219,15 +219,15 @@ discard block |
||
| 219 | 219 | sn_db_transaction_rollback(); |
| 220 | 220 | $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
| 221 | 221 | sn_db_transaction_start(); |
| 222 | - } while(db_player_name_exists($this->player_suggested_name)); |
|
| 222 | + } while (db_player_name_exists($this->player_suggested_name)); |
|
| 223 | 223 | |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if($player_name_submitted) { |
|
| 226 | + if ($player_name_submitted) { |
|
| 227 | 227 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
| 228 | - if($this->register_status == LOGIN_SUCCESS) { |
|
| 228 | + if ($this->register_status == LOGIN_SUCCESS) { |
|
| 229 | 229 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
| 230 | - } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
| 230 | + } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
| 231 | 231 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
| 232 | 232 | } |
| 233 | 233 | // if(self::$login_status != LOGIN_SUCCESS) { |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | : false |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 254 | + if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 255 | 255 | $prohibited_characters = array_map(function($value) { |
| 256 | 256 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
| 257 | 257 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -284,18 +284,18 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | // !self::$is_init ? self::init() : false; |
| 286 | 286 | |
| 287 | - if(!SN::$gc->modules->countModulesInGroup('auth')) { |
|
| 287 | + if (!SN::$gc->modules->countModulesInGroup('auth')) { |
|
| 288 | 288 | die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}'); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false; |
| 292 | 292 | !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false; |
| 293 | - !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false; |
|
| 293 | + !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false; |
|
| 294 | 294 | |
| 295 | 295 | $this->auth_reset(); // OK v4.5 |
| 296 | 296 | |
| 297 | 297 | $this->providers = array(); |
| 298 | - foreach(SN::$gc->modules->getModulesInGroup('auth', true) as $module_name => $module) { |
|
| 298 | + foreach (SN::$gc->modules->getModulesInGroup('auth', true) as $module_name => $module) { |
|
| 299 | 299 | /** |
| 300 | 300 | * @var auth_abstract $module |
| 301 | 301 | */ |
@@ -304,10 +304,10 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым! |
| 306 | 306 | //pdump($this->providers); |
| 307 | - foreach($this->providers as $provider_id => $provider) { |
|
| 307 | + foreach ($this->providers as $provider_id => $provider) { |
|
| 308 | 308 | $login_status = $provider->login(); // OK v4.5 |
| 309 | 309 | self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
| 310 | - if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
| 310 | + if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
| 311 | 311 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
| 312 | 312 | |
| 313 | 313 | $this->user_id_to_provider = array_replace_recursive( |
@@ -315,20 +315,20 @@ discard block |
||
| 315 | 315 | // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
| 316 | 316 | PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
| 317 | 317 | ); |
| 318 | - } elseif($login_status != LOGIN_UNDEFINED) { |
|
| 318 | + } elseif ($login_status != LOGIN_UNDEFINED) { |
|
| 319 | 319 | $this->provider_error_list[$provider_id] = $login_status; |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if(empty($this->providers_authorised)) { |
|
| 323 | + if (empty($this->providers_authorised)) { |
|
| 324 | 324 | // Ни один аккаунт не авторизирован |
| 325 | 325 | // Проверяем - есть ли у нас ошибки в аккаунтах? |
| 326 | - if(!empty($this->provider_error_list)) { |
|
| 326 | + if (!empty($this->provider_error_list)) { |
|
| 327 | 327 | // Если есть - выводим их |
| 328 | 328 | self::$login_status = reset($this->provider_error_list); |
| 329 | 329 | $providerError = $this->providers[key($this->provider_error_list)]->account_login_message; |
| 330 | 330 | |
| 331 | - if(!empty($providerError)) { |
|
| 331 | + if (!empty($providerError)) { |
|
| 332 | 332 | self::$login_message = $providerError; |
| 333 | 333 | } |
| 334 | 334 | } |
@@ -343,12 +343,12 @@ discard block |
||
| 343 | 343 | // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users` |
| 344 | 344 | |
| 345 | 345 | // Остались ли у нас в списке доступные игроки? |
| 346 | - if(empty($this->accessible_user_row_list)) { |
|
| 346 | + if (empty($this->accessible_user_row_list)) { |
|
| 347 | 347 | // Нет ни одного игрока ни на одном авторизированном аккаунте |
| 348 | 348 | // Надо регать нового игрока |
| 349 | 349 | |
| 350 | 350 | // Сейчас происходит процесс регистрации игрока? |
| 351 | - if(!$this->is_player_register) { |
|
| 351 | + if (!$this->is_player_register) { |
|
| 352 | 352 | // Нет - отправляем на процесс регистрации |
| 353 | 353 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
| 354 | 354 | sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | // Да, есть доступные игроки, которые так же прописаны в базе |
| 358 | 358 | $this->get_active_user(); // 4.5 |
| 359 | 359 | |
| 360 | - if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
| 360 | + if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
| 361 | 361 | $a_user = db_user_by_id($this->is_impersonating); |
| 362 | 362 | $this->impersonator_username = $a_user['username']; |
| 363 | 363 | } |
@@ -365,9 +365,9 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | //Прописываем текущего игрока на все авторизированные аккаунты |
| 367 | 367 | // TODO - ИЛИ ВСЕХ ИГРОКОВ?? |
| 368 | - if(empty($this->is_impersonating)) { |
|
| 369 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 370 | - if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
| 368 | + if (empty($this->is_impersonating)) { |
|
| 369 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 370 | + if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
| 371 | 371 | // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
| 372 | 372 | PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
| 373 | 373 | $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true; |
@@ -377,9 +377,9 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - if(empty(self::$user['id'])) { |
|
| 380 | + if (empty(self::$user['id'])) { |
|
| 381 | 381 | self::cookie_set(''); // OK 4.5 |
| 382 | - } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
| 382 | + } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
| 383 | 383 | self::cookie_set(self::$user['id']); // OK 4.5 |
| 384 | 384 | } |
| 385 | 385 | |
@@ -398,21 +398,21 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | // OK v4.7 |
| 400 | 400 | public function logout($redirect = true) { |
| 401 | - if(!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
| 401 | + if (!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
| 402 | 402 | self::cookie_set($_COOKIE[SN_COOKIE_U_I]); |
| 403 | 403 | self::cookie_set(0, true); |
| 404 | 404 | self::$main_provider->logout(); |
| 405 | 405 | } else { |
| 406 | - foreach($this->providers as $provider_name => $provider) { |
|
| 406 | + foreach ($this->providers as $provider_name => $provider) { |
|
| 407 | 407 | $provider->logout(); |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | self::cookie_set(0); |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if($redirect === true) { |
|
| 413 | + if ($redirect === true) { |
|
| 414 | 414 | sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
| 415 | - } elseif($redirect !== false) { |
|
| 415 | + } elseif ($redirect !== false) { |
|
| 416 | 416 | sys_redirect($redirect); |
| 417 | 417 | } |
| 418 | 418 | } |
@@ -423,15 +423,15 @@ discard block |
||
| 423 | 423 | * @param $user_selected |
| 424 | 424 | */ |
| 425 | 425 | public function impersonate($user_selected) { |
| 426 | - if($_COOKIE[SN_COOKIE_U_I]) { |
|
| 426 | + if ($_COOKIE[SN_COOKIE_U_I]) { |
|
| 427 | 427 | die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
| 430 | + if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
| 431 | 431 | die('You can\'t impersonate - too low level'); // TODO: Log it |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - if($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
| 434 | + if ($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
| 435 | 435 | die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it |
| 436 | 436 | } |
| 437 | 437 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]); |
| 440 | 440 | $account_to_impersonate = new Account(self::$main_provider->db); |
| 441 | 441 | $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']); |
| 442 | - if(!$account_to_impersonate->is_exists) { |
|
| 442 | + if (!$account_to_impersonate->is_exists) { |
|
| 443 | 443 | die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it |
| 444 | 444 | } |
| 445 | 445 | self::$main_provider->impersonate($account_to_impersonate); |
@@ -465,12 +465,12 @@ discard block |
||
| 465 | 465 | public function password_check($password_unsafe) { |
| 466 | 466 | $result = false; |
| 467 | 467 | |
| 468 | - if(empty($this->providers_authorised)) { |
|
| 468 | + if (empty($this->providers_authorised)) { |
|
| 469 | 469 | // TODO - такого быть не может! |
| 470 | 470 | self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
| 471 | 471 | } else { |
| 472 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 473 | - if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
| 472 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 473 | + if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
| 474 | 474 | $result = $result || $provider->password_check($password_unsafe); |
| 475 | 475 | } |
| 476 | 476 | } |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | public function password_change($old_password_unsafe, $new_password_unsafe) { |
| 492 | 492 | global $lang; |
| 493 | 493 | |
| 494 | - if(empty($this->providers_authorised)) { |
|
| 494 | + if (empty($this->providers_authorised)) { |
|
| 495 | 495 | // TODO - такого быть не может! |
| 496 | 496 | self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
| 497 | 497 | return false; |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | $salt_unsafe = self::password_salt_generate(); |
| 505 | 505 | |
| 506 | 506 | $providers_changed_password = array(); |
| 507 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 508 | - if( |
|
| 507 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 508 | + if ( |
|
| 509 | 509 | !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE) |
| 510 | 510 | || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe) |
| 511 | 511 | ) { |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id); |
| 518 | 518 | |
| 519 | 519 | // Рассылаем уведомления о смене пароля в ЛС |
| 520 | - foreach($account_translation as $user_id => $provider_info) { |
|
| 520 | + foreach ($account_translation as $user_id => $provider_info) { |
|
| 521 | 521 | // TODO - УКазывать тип аккаунта, на котором сменён пароль |
| 522 | 522 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, |
| 523 | 523 | $lang['sys_administration'], $lang['sys_login_register_message_title'], |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | sn_db_transaction_start(); |
| 565 | 565 | // Проверить наличие такого имени в истории имён |
| 566 | 566 | |
| 567 | - if(db_player_name_exists($player_name_unsafe)) { |
|
| 567 | + if (db_player_name_exists($player_name_unsafe)) { |
|
| 568 | 568 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR); |
| 569 | 569 | } |
| 570 | 570 | |
@@ -572,11 +572,11 @@ discard block |
||
| 572 | 572 | $player_language = ''; |
| 573 | 573 | $player_email = ''; |
| 574 | 574 | // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
| 575 | - foreach($this->providers_authorised as $provider) { |
|
| 576 | - if(!$player_language && $provider->account->account_language) { |
|
| 575 | + foreach ($this->providers_authorised as $provider) { |
|
| 576 | + if (!$player_language && $provider->account->account_language) { |
|
| 577 | 577 | $player_language = $provider->account->account_language; |
| 578 | 578 | } |
| 579 | - if(!$player_email && $provider->account->account_email) { |
|
| 579 | + if (!$player_email && $provider->account->account_email) { |
|
| 580 | 580 | $player_email = $provider->account->account_email; |
| 581 | 581 | } |
| 582 | 582 | } |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | )); |
| 593 | 593 | // Зарегестрировать на него аккаунты из self::$accounts_authorised |
| 594 | 594 | $a_user = self::$user; |
| 595 | - foreach($this->providers_authorised as $provider) { |
|
| 595 | + foreach ($this->providers_authorised as $provider) { |
|
| 596 | 596 | // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор |
| 597 | 597 | // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
| 598 | 598 | // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | sn_db_transaction_commit(); |
| 606 | 606 | $this->register_status = LOGIN_SUCCESS; |
| 607 | - } catch(Exception $e) { |
|
| 607 | + } catch (Exception $e) { |
|
| 608 | 608 | sn_db_transaction_rollback(); |
| 609 | 609 | |
| 610 | 610 | // Если старое имя занято |
@@ -623,10 +623,10 @@ discard block |
||
| 623 | 623 | // Пробиваем все ИД игроков по базе - есть ли вообще такие записи |
| 624 | 624 | // Вообще-то это не особо нужно - у нас по определению стоят констраинты |
| 625 | 625 | // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров |
| 626 | - foreach($this->user_id_to_provider as $user_id => $cork) { |
|
| 626 | + foreach ($this->user_id_to_provider as $user_id => $cork) { |
|
| 627 | 627 | $user = db_user_by_id($user_id); |
| 628 | 628 | // Если записи игрока в БД не существует? |
| 629 | - if(empty($user['id'])) { |
|
| 629 | + if (empty($user['id'])) { |
|
| 630 | 630 | // Удаляем этого и переходим к следующему |
| 631 | 631 | unset($this->user_id_to_provider[$user_id]); |
| 632 | 632 | // Де-регистрируем игрока из таблицы трансляции игроков |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | // OK v4.5 |
| 648 | 648 | protected function get_active_user() { |
| 649 | 649 | // Проверяем куку "текущего игрока" из браузера |
| 650 | - if( |
|
| 650 | + if ( |
|
| 651 | 651 | // Кука не пустая |
| 652 | 652 | ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U]) |
| 653 | 653 | // И в куке находится ID |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов |
| 675 | - if(empty(self::$user['id'])) { |
|
| 675 | + if (empty(self::$user['id'])) { |
|
| 676 | 676 | // Берем первого из доступных |
| 677 | 677 | // TODO - default_user |
| 678 | 678 | self::$user = reset($this->accessible_user_row_list); |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | $result = array(); |
| 698 | 698 | |
| 699 | - if($user_id && empty($this->is_impersonating)) { |
|
| 699 | + if ($user_id && empty($this->is_impersonating)) { |
|
| 700 | 700 | // self::db_counter_insert(); |
| 701 | 701 | self::$device->db_counter_insert($user_id); |
| 702 | 702 | |
@@ -704,12 +704,12 @@ discard block |
||
| 704 | 704 | |
| 705 | 705 | sys_user_options_unpack($user); |
| 706 | 706 | |
| 707 | - if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
| 707 | + if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
| 708 | 708 | $user['banaday'] = 0; |
| 709 | 709 | $user['vacation'] = SN_TIME_NOW; |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
| 712 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
| 713 | 713 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
| 714 | 714 | |
| 715 | 715 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -723,13 +723,13 @@ discard block |
||
| 723 | 723 | ); |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - if($extra = $config->security_ban_extra) { |
|
| 726 | + if ($extra = $config->security_ban_extra) { |
|
| 727 | 727 | $extra = explode(',', $extra); |
| 728 | - array_walk($extra,'trim'); |
|
| 728 | + array_walk($extra, 'trim'); |
|
| 729 | 729 | in_array(self::$device->device_id, $extra) and die(); |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - if(self::$login_message) { |
|
| 732 | + if (self::$login_message) { |
|
| 733 | 733 | $result[F_LOGIN_MESSAGE] = self::$login_message; |
| 734 | 734 | } |
| 735 | 735 | |
@@ -765,21 +765,21 @@ discard block |
||
| 765 | 765 | protected function register_player_name_validate($player_name_unsafe) { |
| 766 | 766 | // TODO - переделать под RAW-строки |
| 767 | 767 | // Если имя игрока пустое - NO GO! |
| 768 | - if(trim($player_name_unsafe) == '') { |
|
| 768 | + if (trim($player_name_unsafe) == '') { |
|
| 769 | 769 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR); |
| 770 | 770 | } |
| 771 | 771 | // Проверяем, что бы в начале и конце не было пустых символов |
| 772 | - if($player_name_unsafe != trim($player_name_unsafe)) { |
|
| 772 | + if ($player_name_unsafe != trim($player_name_unsafe)) { |
|
| 773 | 773 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR); |
| 774 | 774 | } |
| 775 | 775 | // Если логин имеет запрещенные символы - NO GO! |
| 776 | - if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 776 | + if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 777 | 777 | // TODO - выдавать в сообщение об ошибке список запрещенных символов |
| 778 | 778 | // TODO - заранее извещать игрока, какие символы являются запрещенными |
| 779 | 779 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
| 780 | 780 | } |
| 781 | 781 | // Если логин меньше минимальной длины - NO GO! |
| 782 | - if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 782 | + if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 783 | 783 | // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока |
| 784 | 784 | // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени |
| 785 | 785 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR); |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | protected static function flog($message, $die = false) { |
| 840 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 840 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 841 | 841 | return; |
| 842 | 842 | } |
| 843 | 843 | list($called, $caller) = debug_backtrace(false); |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
| 851 | 851 | |
| 852 | 852 | SN::log_file("$message - $caller_name"); |
| 853 | - if($die) { |
|
| 853 | + if ($die) { |
|
| 854 | 854 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
| 855 | 855 | } |
| 856 | 856 | } |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | public function __construct(GlobalContainer $services = null) { |
| 77 | 77 | parent::__construct($services); |
| 78 | 78 | |
| 79 | - if(empty(static::$shipInfo)) { |
|
| 80 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
| 79 | + if (empty(static::$shipInfo)) { |
|
| 80 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
| 81 | 81 | static::$shipInfo[$unit_id] = get_unit_param($unit_id); |
| 82 | 82 | static::$shipInfo[$unit_id][P_COST_METAL] = get_unit_cost_in(static::$shipInfo[$unit_id][P_COST]); |
| 83 | 83 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @inheritdoc |
| 104 | 104 | */ |
| 105 | 105 | public function update() { |
| 106 | - if($this->getShipCount() < 1) { |
|
| 106 | + if ($this->getShipCount() < 1) { |
|
| 107 | 107 | return $this->delete(); |
| 108 | 108 | } else { |
| 109 | 109 | return parent::update(); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function getCostInMetal() { |
| 129 | 129 | $result = 0; |
| 130 | - foreach($this->shipList as $shipId => $amount) { |
|
| 130 | + foreach ($this->shipList as $shipId => $amount) { |
|
| 131 | 131 | $result += $amount * $this->getShipCostInMetal($shipId); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function getCapacity() { |
| 150 | 150 | $result = 0; |
| 151 | - foreach($this->shipList as $shipId => $amount) { |
|
| 151 | + foreach ($this->shipList as $shipId => $amount) { |
|
| 152 | 152 | $result += $amount * $this->getShipCapacity($shipId); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | public function changeShipCount($shipSnId, $shipCount) { |
| 167 | 167 | !isset($this->shipList[$shipSnId]) ? $this->shipList[$shipSnId] = 0 : false; |
| 168 | - if($this->shipList[$shipSnId] + $shipCount < 0) { |
|
| 168 | + if ($this->shipList[$shipSnId] + $shipCount < 0) { |
|
| 169 | 169 | throw new \Exception("Trying to deduct more ships [{$shipSnId}] '{$shipCount}' then fleet has {$this->shipList[$shipSnId]}"); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $this->shipList[$shipSnId] += $shipCount; |
| 173 | - if($this->shipList[$shipSnId] <= 0) { |
|
| 173 | + if ($this->shipList[$shipSnId] <= 0) { |
|
| 174 | 174 | unset($this->shipList[$shipSnId]); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | * @throws \Exception |
| 186 | 186 | */ |
| 187 | 187 | public function changeResource($resourceId, $resourceCount) { |
| 188 | - if(!array_key_exists($resourceId, $this->resources) || empty($resourceCount)) { |
|
| 188 | + if (!array_key_exists($resourceId, $this->resources) || empty($resourceCount)) { |
|
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if($this->resources[$resourceId] + $resourceCount < 0) { |
|
| 192 | + if ($this->resources[$resourceId] + $resourceCount < 0) { |
|
| 193 | 193 | throw new \Exception("Trying to deduct more resources [{$resourceId}] '{$resourceCount}' then fleet has {$this->resources[$resourceId]}"); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | $this->secret_word = SN::$sn_secret_word; |
| 92 | 92 | |
| 93 | 93 | $snTableNames = $this->db->schema()->getSnTables(); |
| 94 | - foreach($this->table_check as $table_name) { |
|
| 95 | - if(empty($snTableNames[$table_name])) { |
|
| 94 | + foreach ($this->table_check as $table_name) { |
|
| 95 | + if (empty($snTableNames[$table_name])) { |
|
| 96 | 96 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
| 97 | 97 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
| 98 | 98 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | // OK v4.6 |
| 118 | 118 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
| 119 | - if(!$this->password_check($old_password_unsafe)) { |
|
| 119 | + if (!$this->password_check($old_password_unsafe)) { |
|
| 120 | 120 | return false; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | // OK v4.5 |
| 138 | 138 | public function assign_from_db_row($row) { |
| 139 | 139 | $this->reset(); |
| 140 | - if(empty($row) || !is_array($row)) { |
|
| 140 | + if (empty($row) || !is_array($row)) { |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | $this->account_id = $row['account_id']; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $this->reset(); |
| 203 | 203 | |
| 204 | 204 | $email_safe = $this->db->db_escape($email_unsafe); |
| 205 | - if($email_safe) { |
|
| 205 | + if ($email_safe) { |
|
| 206 | 206 | $account_row = $this->db->doquery("SELECT * FROM {{account}} WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true); |
| 207 | 207 | |
| 208 | 208 | return $this->assign_from_db_row($account_row); |
@@ -275,11 +275,11 @@ discard block |
||
| 275 | 275 | `account_email` = LOWER('{$email_safe}'), |
| 276 | 276 | `account_language` = '{$language_safe}'" |
| 277 | 277 | ); |
| 278 | - if(!$result) { |
|
| 278 | + if (!$result) { |
|
| 279 | 279 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if(!($account_id = $this->db->db_insert_id())) { |
|
| 282 | + if (!($account_id = $this->db->db_insert_id())) { |
|
| 283 | 283 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | WHERE `account_id` = '{$account_id_safe}'" |
| 310 | 310 | ) ? true : false; |
| 311 | 311 | |
| 312 | - if($result) { |
|
| 312 | + if ($result) { |
|
| 313 | 313 | $result = $this->db_get_by_id($this->account_id); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) { |
| 399 | 399 | global $debug, $mm_change_legit, $config; |
| 400 | 400 | |
| 401 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 401 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 402 | 402 | $debug->error('Ошибка при попытке манипуляции с ММ'); |
| 403 | 403 | return false; |
| 404 | 404 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | $mm_change_legit = true; |
| 409 | 409 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
| 410 | - if($already_changed) { |
|
| 410 | + if ($already_changed) { |
|
| 411 | 411 | $metamatter_total_delta = 0; |
| 412 | 412 | $result = -1; |
| 413 | 413 | } else { |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | ($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}'" : '') . |
| 421 | 421 | " WHERE `account_id` = {$account_id_safe}" |
| 422 | 422 | ); |
| 423 | - if(!$result) { |
|
| 423 | + if (!$result) { |
|
| 424 | 424 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 425 | 425 | } |
| 426 | 426 | $result = SN::$db->db_affected_rows(); |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | $this->awardImmortal($metamatter, $config); |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - if(empty(core_auth::$user['id'])) { |
|
| 431 | + if (empty(core_auth::$user['id'])) { |
|
| 432 | 432 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
| 433 | 433 | reset($user_list); |
| 434 | 434 | $user_id_unsafe = key($user_list); |
@@ -437,30 +437,30 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
| 439 | 439 | |
| 440 | - if(!$result) { |
|
| 440 | + if (!$result) { |
|
| 441 | 441 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if(!$already_changed) { |
|
| 444 | + if (!$already_changed) { |
|
| 445 | 445 | $this->account_metamatter += $metamatter; |
| 446 | 446 | $this->account_metamatter_total += $metamatter_total_delta; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - if(is_array($comment)) { |
|
| 449 | + if (is_array($comment)) { |
|
| 450 | 450 | $comment = call_user_func_array('sprintf', $comment); |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
| 454 | 454 | |
| 455 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
| 455 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
| 456 | 456 | $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true); |
| 457 | - if($old_referral['id']) { |
|
| 457 | + if ($old_referral['id']) { |
|
| 458 | 458 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
| 459 | 459 | doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;"); |
| 460 | 460 | $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1;", '', true); |
| 461 | 461 | |
| 462 | 462 | $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); |
| 463 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 463 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 464 | 464 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
| 465 | 465 | } |
| 466 | 466 | } |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | * @throws Exception |
| 477 | 477 | */ |
| 478 | 478 | public function cookieSet($rememberMe = false, $domain = null) { |
| 479 | - if(!$this->is_exists) { |
|
| 479 | + if (!$this->is_exists) { |
|
| 480 | 480 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
| 481 | 481 | } |
| 482 | 482 | |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | // OK v4.1 |
| 496 | 496 | public function cookieClear($domain = null) { |
| 497 | 497 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
| 498 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 498 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 499 | 499 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain); |
| 500 | 500 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain); |
| 501 | 501 | } else { |
@@ -505,14 +505,14 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | public function cookieLogin(&$rememberMe = false) { |
| 507 | 507 | // Пытаемся войти по куке |
| 508 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
| 509 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 508 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
| 509 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 510 | 510 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
| 511 | 511 | } else { |
| 512 | 512 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - if( |
|
| 515 | + if ( |
|
| 516 | 516 | $this->db_get_by_id($account_id_unsafe) |
| 517 | 517 | && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted) |
| 518 | 518 | ) { |
@@ -537,10 +537,10 @@ discard block |
||
| 537 | 537 | * @param classConfig $config |
| 538 | 538 | */ |
| 539 | 539 | protected function awardImmortal($metamatter, $config) { |
| 540 | - if(!is_object($awardModule = moduleAward())) { |
|
| 540 | + if (!is_object($awardModule = moduleAward())) { |
|
| 541 | 541 | return; |
| 542 | 542 | } |
| 543 | - if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal ) { |
|
| 543 | + if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal) { |
|
| 544 | 544 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list(ACCOUNT_PROVIDER_LOCAL, $this->account_id); |
| 545 | 545 | if (!empty($account_translation)) { |
| 546 | 546 | reset($account_translation); |
@@ -562,10 +562,10 @@ discard block |
||
| 562 | 562 | * @return bool|mysqli_result|null |
| 563 | 563 | */ |
| 564 | 564 | public function getMetamatterSum($where = '', $group = '') { |
| 565 | - if(is_array($where) && !empty($where)) { |
|
| 565 | + if (is_array($where) && !empty($where)) { |
|
| 566 | 566 | $where = implode(' AND ', $where); |
| 567 | 567 | } |
| 568 | - if(is_array($group) && !empty($group)) { |
|
| 568 | + if (is_array($group) && !empty($group)) { |
|
| 569 | 569 | $group = implode(',', $group); |
| 570 | 570 | } |
| 571 | 571 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 19 | 19 | |
| 20 | -if(!SN::$gc->modules->countModulesInGroup('payment')) { |
|
| 20 | +if (!SN::$gc->modules->countModulesInGroup('payment')) { |
|
| 21 | 21 | sys_redirect(SN_ROOT_VIRTUAL . 'admin/overview.php'); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | 'START_NAME' => $planetrow['name'], |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - if(!empty($TargetPlanet)) { |
|
| 30 | + if (!empty($TargetPlanet)) { |
|
| 31 | 31 | $template_route += array( |
| 32 | 32 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
| 33 | 33 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | $template->assign_block_vars('fleets', $template_route); |
| 39 | 39 | |
| 40 | 40 | $sn_groups_fleet = sn_get_groups('fleet'); |
| 41 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
| 42 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 41 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
| 42 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 43 | 43 | // $ship_base_data = get_ship_data($ship_id, $user); |
| 44 | 44 | $template->assign_block_vars('fleets.ships', array( |
| 45 | 45 | 'ID' => $ship_id, |
@@ -57,11 +57,10 @@ discard block |
||
| 57 | 57 | $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : |
|
| 61 | - (isset($missiontype[MT_HOLD]) ? 12 : 0); |
|
| 62 | - if($max_duration) { |
|
| 60 | + $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0); |
|
| 61 | + if ($max_duration) { |
|
| 63 | 62 | $config_game_speed_expedition = ($target_mission == MT_EXPLORE && $config->game_speed_expedition ? $config->game_speed_expedition : 1); |
| 64 | - for($i = 1; $i <= $max_duration; $i++) { |
|
| 63 | + for ($i = 1; $i <= $max_duration; $i++) { |
|
| 65 | 64 | $template->assign_block_vars('duration', array( |
| 66 | 65 | 'ID' => $i, |
| 67 | 66 | 'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)), |
@@ -80,7 +79,7 @@ discard block |
||
| 80 | 79 | // $TableTitle = uni_render_planet_full($planetrow) . ' => ' . uni_render_planet_full($temp); |
| 81 | 80 | |
| 82 | 81 | $sn_group_resources = sn_get_groups('resources'); |
| 83 | - for($i = 0; $i<3; $i++) { |
|
| 82 | + for ($i = 0; $i < 3; $i++) { |
|
| 84 | 83 | $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0); |
| 85 | 84 | $template->assign_block_vars('resources', array( |
| 86 | 85 | 'ID' => $i, |
@@ -90,7 +89,7 @@ discard block |
||
| 90 | 89 | )); |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | - if(is_object($captainModule = moduleCaptain()) && ($captain = $captainModule->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { |
|
| 92 | + if (is_object($captainModule = moduleCaptain()) && ($captain = $captainModule->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { |
|
| 94 | 93 | $template->assign_vars(array( |
| 95 | 94 | 'CAPTAIN_ID' => $captain['unit_id'], |
| 96 | 95 | 'CAPTAIN_LEVEL' => $captain['captain_level'], |
@@ -112,9 +111,9 @@ discard block |
||
| 112 | 111 | |
| 113 | 112 | |
| 114 | 113 | 'speedallsmin' => sys_get_param_float('speedallsmin'), |
| 115 | - 'speed' => sys_get_param_int('speed') , |
|
| 114 | + 'speed' => sys_get_param_int('speed'), |
|
| 116 | 115 | |
| 117 | - 'fleet_group' => sys_get_param_id('fleet_group') , |
|
| 116 | + 'fleet_group' => sys_get_param_id('fleet_group'), |
|
| 118 | 117 | 'acs_target_mr' => sys_get_param_str('acs_target_mr'), |
| 119 | 118 | |
| 120 | 119 | 'MAX_DURATION' => $max_duration, |