supernova-ws /
SuperNova
| 1 | <?php |
||||
| 2 | |||||
| 3 | use DBAL\db_mysql; |
||||
| 4 | use Universe\Universe; |
||||
|
0 ignored issues
–
show
|
|||||
| 5 | |||||
| 6 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||||
| 7 | |||||
| 8 | if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) { |
||||
| 9 | $error_message = SN::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : ( |
||||
| 10 | !SN::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : '' |
||||
|
0 ignored issues
–
show
The property
game_blitz_register does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||
| 11 | ); |
||||
| 12 | |||||
| 13 | if ($error_message) { |
||||
| 14 | SnTemplate::messageBox($lang[$error_message], $lang['sys_error'], 'overview.php', 10); |
||||
| 15 | die(); |
||||
| 16 | } |
||||
| 17 | |||||
| 18 | } |
||||
| 19 | |||||
| 20 | $current_round = intval(SN::$config->db_loadItem('game_blitz_register_round')); |
||||
| 21 | $current_price = intval(SN::$config->db_loadItem('game_blitz_register_price')); |
||||
| 22 | |||||
| 23 | if (SN::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
||||
| 24 | db_mysql::db_transaction_start(); |
||||
| 25 | $user = db_user_by_id($user['id'], true); |
||||
|
0 ignored issues
–
show
The function
db_user_by_id() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 26 | $is_registered = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `user_id` = {$user['id']} AND `round_number` = {$current_round} FOR UPDATE;", true); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 27 | if (sys_get_param_str('register_me')) { |
||||
| 28 | if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
||||
| 29 | doquery("INSERT IGNORE INTO {{blitz_registrations}} SET `user_id` = {$user['id']}, `round_number` = {$current_round};"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 30 | //mm_points_change($user['id'], RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица"); |
||||
| 31 | SN::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица"); |
||||
| 32 | } |
||||
| 33 | } elseif (sys_get_param_str('register_me_not') && !empty($is_registered)) { |
||||
| 34 | doquery("DELETE FROM {{blitz_registrations}} WHERE `user_id` = {$user['id']} AND `round_number` = {$current_round};"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 35 | // mm_points_change($user['id'], RPG_BLITZ_REGISTRATION_CANCEL, $current_price, "Отмена регистрации в раунде {$current_round} Блица"); |
||||
| 36 | SN::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION_CANCEL, $current_price, "Отмена регистрации в раунде {$current_round} Блица"); |
||||
| 37 | } |
||||
| 38 | $registered_count = doquery("SELECT count(`id`) AS `count` FROM {{blitz_registrations}} WHERE `round_number` = {$current_round};", true); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 39 | SN::$config->db_saveItem('game_blitz_register_users', $registered_count['count']); |
||||
| 40 | db_mysql::db_transaction_commit(); |
||||
| 41 | } |
||||
| 42 | |||||
| 43 | $blitz_generated = array(); |
||||
| 44 | $blitz_result = array(); |
||||
| 45 | $blitz_prize_players_active = 0; |
||||
| 46 | $blitz_players = 0; |
||||
| 47 | $blitz_prize_dark_matter = 0; |
||||
| 48 | $blitz_prize_places = 0; |
||||
| 49 | if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
||||
| 50 | if (sys_get_param_str('generate')) { |
||||
| 51 | $next_id = 0; |
||||
| 52 | $query = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY RAND();"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 53 | while ($row = db_fetch($query)) { |
||||
|
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 54 | $next_id++; |
||||
| 55 | $blitz_name = 'Игрок' . $next_id; |
||||
| 56 | $blitz_password = sys_random_string(8); |
||||
| 57 | doquery("UPDATE {{blitz_registrations}} SET blitz_name = '{$blitz_name}', blitz_password = '{$blitz_password}' WHERE `id` = {$row['id']} AND `round_number` = {$current_round};"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 58 | } |
||||
| 59 | } elseif (sys_get_param_str('import_generated')) { |
||||
| 60 | // ЭТО НА БЛИЦЕ!!! |
||||
| 61 | doquery("DELETE FROM {{users}} WHERE username like 'Игрок%';"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 62 | doquery("DELETE FROM {{planets}} WHERE id_owner not in (SELECT `id` FROM {{users}});"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 63 | |||||
| 64 | $imported_string = explode(';', sys_get_param_str('generated_string')); |
||||
| 65 | shuffle($imported_string); |
||||
| 66 | |||||
| 67 | $new_players = count($imported_string); |
||||
| 68 | $system_count = ceil($new_players / SN::$config->game_maxGalaxy); |
||||
| 69 | $system_step = floor(SN::$config->game_maxSystem / $system_count); |
||||
| 70 | |||||
| 71 | pdump($system_count, '$system_count'); |
||||
| 72 | pdump($system_step, '$system_step'); |
||||
| 73 | |||||
| 74 | $skin = DEFAULT_SKINPATH; |
||||
| 75 | $language = DEFAULT_LANG; |
||||
| 76 | |||||
| 77 | $galaxy = 1; |
||||
| 78 | $system = $system_step; |
||||
| 79 | $planet = round(SN::$config->game_maxPlanet / 2); |
||||
| 80 | |||||
| 81 | foreach ($imported_string as &$string_data) { |
||||
| 82 | $string_data = explode(',', $string_data); |
||||
| 83 | $username_safe = $string_data[0]; |
||||
| 84 | |||||
| 85 | $user_new = player_create($username_safe, sys_random_string(), array( |
||||
| 86 | 'password_encoded_unsafe' => core_auth::password_encode($string_data[1], ''), |
||||
| 87 | |||||
| 88 | 'galaxy' => $galaxy, |
||||
| 89 | 'system' => $system, |
||||
| 90 | 'planet' => $planet, |
||||
| 91 | )); |
||||
| 92 | |||||
| 93 | $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], Universe::MOON_MAX_SIZE, false); |
||||
| 94 | |||||
| 95 | if (($system += $system_step) >= SN::$config->game_maxSystem) { |
||||
| 96 | $galaxy++; |
||||
| 97 | $system = $system_step; |
||||
| 98 | } |
||||
| 99 | } |
||||
| 100 | doquery('UPDATE {{users}} SET dark_matter = 50000, dark_matter_total = 50000;'); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 101 | |||||
| 102 | SN::$config->db_saveItem('users_amount', SN::$config->users_amount + $new_players); |
||||
| 103 | // generated_string |
||||
| 104 | } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
||||
| 105 | $blitz_result = explode(';', $blitz_result_string); |
||||
| 106 | $blitz_last_update = $blitz_result[0]; // Пока не используется |
||||
| 107 | unset($blitz_result[0]); |
||||
| 108 | foreach ($blitz_result as $blitz_result_data) { |
||||
| 109 | $blitz_result_data = explode(',', $blitz_result_data); |
||||
| 110 | if (count($blitz_result_data) == 5) { |
||||
| 111 | $blitz_result_data[1] = SN::$db->db_escape($blitz_result_data[1]); |
||||
| 112 | doquery( |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 113 | "UPDATE `{{blitz_registrations}}` SET |
||||
| 114 | `blitz_player_id` = '{$blitz_result_data[0]}', |
||||
| 115 | `blitz_online` = '{$blitz_result_data[2]}', |
||||
| 116 | `blitz_place` = '{$blitz_result_data[3]}', |
||||
| 117 | `blitz_points` = '{$blitz_result_data[4]}' |
||||
| 118 | WHERE `blitz_name` = '{$blitz_result_data[1]}' AND `round_number` = {$current_round};"); |
||||
| 119 | } |
||||
| 120 | } |
||||
| 121 | $blitz_result = array(); |
||||
| 122 | } |
||||
| 123 | |||||
| 124 | if (SN::$config->game_mode == GAME_BLITZ) { |
||||
| 125 | $blitz_result = array(SN::$config->db_loadItem('var_stat_update')); |
||||
| 126 | $query = doquery("SELECT id, username, total_rank, total_points, onlinetime FROM {{users}} ORDER BY `id`;"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 127 | while ($row = db_fetch($query)) { |
||||
|
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 128 | $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}"; |
||||
| 129 | } |
||||
| 130 | } else { |
||||
| 131 | $query = doquery("SELECT blitz_name, blitz_password, blitz_online FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `id`;"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 132 | while ($row = db_fetch($query)) { |
||||
|
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 133 | $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}"; |
||||
| 134 | $row['blitz_online'] ? $blitz_prize_players_active++ : false; |
||||
| 135 | $blitz_players++; |
||||
| 136 | } |
||||
| 137 | $blitz_prize_dark_matter = $blitz_prize_players_active * 20000; |
||||
| 138 | $blitz_prize_places = ceil($blitz_prize_players_active / 5); |
||||
| 139 | /* |
||||
| 140 | 'Игрок10' |
||||
| 141 | 'Игрок14' |
||||
| 142 | 'Игрок23' |
||||
| 143 | 'Игрок32' |
||||
| 144 | 'Игрок40' |
||||
| 145 | */ |
||||
| 146 | |||||
| 147 | if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
||||
| 148 | // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'); |
||||
| 149 | $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places'); |
||||
| 150 | db_mysql::db_transaction_start(); |
||||
| 151 | $query = doquery("SELECT * FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `blitz_place` FOR UPDATE;"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 152 | while ($row = db_fetch($query)) { |
||||
|
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 153 | if (!$row['blitz_place']) { |
||||
| 154 | continue; |
||||
| 155 | } |
||||
| 156 | |||||
| 157 | $blitz_prize_dark_matter_actual = round($blitz_prize_dark_matter_actual / 2); |
||||
| 158 | $blitz_prize_places_actual--; |
||||
| 159 | |||||
| 160 | $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter']; |
||||
| 161 | pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']); |
||||
| 162 | if ($reward) { |
||||
| 163 | rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf( |
||||
| 164 | $lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name'] |
||||
| 165 | )); |
||||
| 166 | doquery("UPDATE {{blitz_registrations}} SET blitz_reward_dark_matter = blitz_reward_dark_matter + ($reward) WHERE id = {$row['id']} AND `round_number` = {$current_round};"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 167 | } |
||||
| 168 | |||||
| 169 | if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
||||
| 170 | break; |
||||
| 171 | } |
||||
| 172 | } |
||||
| 173 | db_mysql::db_transaction_commit(); |
||||
| 174 | } |
||||
| 175 | |||||
| 176 | } |
||||
| 177 | } |
||||
| 178 | |||||
| 179 | |||||
| 180 | $template = SnTemplate::gettemplate('blitz_register', true); |
||||
|
0 ignored issues
–
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 181 | |||||
| 182 | $player_registered = false; |
||||
| 183 | $query = doquery( |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 184 | "SELECT u.*, br.blitz_name, br.blitz_password, br.blitz_place, br.blitz_status, br.blitz_points, br.blitz_reward_dark_matter |
||||
| 185 | FROM {{blitz_registrations}} AS br |
||||
| 186 | JOIN {{users}} AS u ON u.id = br.user_id |
||||
| 187 | WHERE br.`round_number` = {$current_round} |
||||
| 188 | order by `blitz_place`, `timestamp`;"); |
||||
| 189 | while ($row = db_fetch($query)) { |
||||
|
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 190 | $tpl_player_data = array( |
||||
| 191 | 'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)), |
||||
| 192 | ); |
||||
| 193 | |||||
| 194 | if (SN::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
||||
| 195 | // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда |
||||
| 196 | $tpl_player_data = array_merge($tpl_player_data, array( |
||||
| 197 | 'ID' => $row['id'], |
||||
| 198 | 'BLITZ_NAME' => $row['blitz_name'], |
||||
| 199 | // 'BLITZ_STATUS' => $row['blitz_status'], |
||||
| 200 | 'BLITZ_PLACE' => $row['blitz_place'], |
||||
| 201 | 'BLITZ_POINTS' => $row['blitz_points'], |
||||
| 202 | 'BLITZ_REWARD_DARK_MATTER' => $row['blitz_reward_dark_matter'], |
||||
| 203 | )); |
||||
| 204 | } |
||||
| 205 | |||||
| 206 | $template->assign_block_vars('registrations', $tpl_player_data); |
||||
| 207 | if ($row['id'] == $user['id']) { |
||||
| 208 | $player_registered = $row; |
||||
| 209 | } |
||||
| 210 | } |
||||
| 211 | |||||
| 212 | $template->assign_vars(array( |
||||
| 213 | 'GAME_BLITZ' => SN::$config->game_mode == GAME_BLITZ, |
||||
| 214 | |||||
| 215 | 'REGISTRATION_OPEN' => SN::$config->game_blitz_register == BLITZ_REGISTER_OPEN, |
||||
| 216 | 'REGISTRATION_CLOSED' => SN::$config->game_blitz_register == BLITZ_REGISTER_CLOSED, |
||||
| 217 | 'REGISTRATION_SHOW_LOGIN' => SN::$config->game_blitz_register == BLITZ_REGISTER_SHOW_LOGIN, |
||||
| 218 | 'REGISTRATION_DISCLOSURE_NAMES' => SN::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES, |
||||
| 219 | |||||
| 220 | 'PLAYER_REGISTERED' => !empty($player_registered), |
||||
| 221 | 'BLITZ_NAME' => $player_registered['blitz_name'], |
||||
| 222 | 'BLITZ_PASSWORD' => $player_registered['blitz_password'], |
||||
| 223 | |||||
| 224 | 'BLITZ_GENERATED' => implode(';', $blitz_generated), |
||||
| 225 | 'BLITZ_RESULT' => implode(';', $blitz_result), |
||||
| 226 | 'BLITZ_PRIZE_PLAYERS_ACTIVE' => $blitz_prize_players_active, |
||||
| 227 | 'BLITZ_PRIZE_DARK_MATTER' => $blitz_prize_dark_matter, |
||||
| 228 | 'BLITZ_PRIZE_PLACES' => $blitz_prize_places, |
||||
| 229 | )); |
||||
| 230 | |||||
| 231 | SnTemplate::display($template, $lang['sys_blitz_global_button']); |
||||
| 232 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: