@@ -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 = classSupernova::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : ( |
7 | 7 | !classSupernova::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : '' |
8 | 8 | ); |
9 | 9 | |
10 | - if($error_message) { |
|
10 | + if ($error_message) { |
|
11 | 11 | message(classLocale::$lang[$error_message], classLocale::$lang['sys_error'], 'overview.php', 10); |
12 | 12 | die(); |
13 | 13 | } |
@@ -16,16 +16,16 @@ discard block |
||
16 | 16 | $current_round = intval(classSupernova::$config->db_loadItem('game_blitz_register_round')); |
17 | 17 | $current_price = intval(classSupernova::$config->db_loadItem('game_blitz_register_price')); |
18 | 18 | |
19 | -if(classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
|
19 | +if (classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
|
20 | 20 | sn_db_transaction_start(); |
21 | 21 | $user = db_user_by_id($user['id'], true); |
22 | 22 | $is_registered = db_blitz_reg_get_id_by_player_and_round($user, $current_round); |
23 | - if(sys_get_param_str('register_me')) { |
|
24 | - if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
|
23 | + if (sys_get_param_str('register_me')) { |
|
24 | + if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
|
25 | 25 | db_blitz_reg_insert($user, $current_round); |
26 | 26 | classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица"); |
27 | 27 | } |
28 | - } elseif(sys_get_param_str('register_me_not') && !empty($is_registered)) { |
|
28 | + } elseif (sys_get_param_str('register_me_not') && !empty($is_registered)) { |
|
29 | 29 | db_blitz_reg_delete($user, $current_round); |
30 | 30 | classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION_CANCEL, $current_price, "Отмена регистрации в раунде {$current_round} Блица"); |
31 | 31 | } |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | $blitz_players = 0; |
41 | 41 | $blitz_prize_dark_matter = 0; |
42 | 42 | $blitz_prize_places = 0; |
43 | -if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
|
44 | - if(sys_get_param_str('generate')) { |
|
43 | +if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
|
44 | + if (sys_get_param_str('generate')) { |
|
45 | 45 | $next_id = 0; |
46 | 46 | $query = db_blitz_reg_get_random_id($current_round); |
47 | - while($row = db_fetch($query)) { |
|
47 | + while ($row = db_fetch($query)) { |
|
48 | 48 | $next_id++; |
49 | 49 | $blitz_name = 'Игрок' . $next_id; |
50 | 50 | $blitz_password = sys_random_string(8); |
51 | 51 | db_blitz_reg_update_with_name_and_password($blitz_name, $blitz_password, $row, $current_round); |
52 | 52 | } |
53 | - } elseif(sys_get_param_str('import_generated')) { |
|
53 | + } elseif (sys_get_param_str('import_generated')) { |
|
54 | 54 | // ЭТО НА БЛИЦЕ!!! |
55 | 55 | db_player_list_blitz_delete_players(); |
56 | 56 | db_planets_purge(); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $system = $system_step; |
73 | 73 | $planet = round(classSupernova::$config->game_maxPlanet / 2); |
74 | 74 | |
75 | - foreach($imported_string as &$string_data) { |
|
75 | + foreach ($imported_string as &$string_data) { |
|
76 | 76 | $string_data = explode(',', $string_data); |
77 | 77 | $username_safe = $string_data[0]; |
78 | 78 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], 30, '', false); |
94 | 94 | |
95 | - if(($system += $system_step) >= classSupernova::$config->game_maxSystem) { |
|
95 | + if (($system += $system_step) >= classSupernova::$config->game_maxSystem) { |
|
96 | 96 | $galaxy++; |
97 | 97 | $system = $system_step; |
98 | 98 | } |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->users_amount + $new_players); |
103 | 103 | // pdump($imported_string); |
104 | 104 | // generated_string |
105 | - } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
|
105 | + } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
|
106 | 106 | $blitz_result = explode(';', $blitz_result_string); |
107 | 107 | $blitz_last_update = $blitz_result[0]; // Пока не используется |
108 | 108 | unset($blitz_result[0]); |
109 | - foreach($blitz_result as $blitz_result_data) { |
|
109 | + foreach ($blitz_result as $blitz_result_data) { |
|
110 | 110 | $blitz_result_data = explode(',', $blitz_result_data); |
111 | - if(count($blitz_result_data) == 5) { |
|
111 | + if (count($blitz_result_data) == 5) { |
|
112 | 112 | $blitz_result_data[1] = db_escape($blitz_result_data[1]); |
113 | 113 | db_blitz_reg_update_results($blitz_result_data, $current_round); |
114 | 114 | } |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | $blitz_result = array(); |
117 | 117 | } |
118 | 118 | |
119 | - if(classSupernova::$config->game_mode == GAME_BLITZ) { |
|
119 | + if (classSupernova::$config->game_mode == GAME_BLITZ) { |
|
120 | 120 | $blitz_result = array(classSupernova::$config->db_loadItem('var_stat_update')); |
121 | 121 | $query = db_player_list_export_blitz_info(); |
122 | - while($row = db_fetch($query)) { |
|
122 | + while ($row = db_fetch($query)) { |
|
123 | 123 | $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}"; |
124 | 124 | } |
125 | 125 | } else { |
126 | 126 | $query = db_blitz_reg_get_player_list($current_round); |
127 | - while($row = db_fetch($query)) { |
|
127 | + while ($row = db_fetch($query)) { |
|
128 | 128 | $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}"; |
129 | 129 | $row['blitz_online'] ? $blitz_prize_players_active++ : false; |
130 | 130 | $blitz_players++; |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $blitz_prize_dark_matter = $blitz_prize_players_active * 20000; |
133 | 133 | $blitz_prize_places = ceil($blitz_prize_players_active / 5); |
134 | 134 | |
135 | - if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
|
135 | + if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
|
136 | 136 | // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'); |
137 | 137 | $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places'); |
138 | 138 | sn_db_transaction_start(); |
139 | 139 | $query = db_blitz_reg_get_player_list_order_by_place($current_round); |
140 | - while($row = db_fetch($query)) { |
|
141 | - if(!$row['blitz_place']) { |
|
140 | + while ($row = db_fetch($query)) { |
|
141 | + if (!$row['blitz_place']) { |
|
142 | 142 | continue; |
143 | 143 | } |
144 | 144 | |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | |
148 | 148 | $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter']; |
149 | 149 | pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']); |
150 | - if($reward) { |
|
150 | + if ($reward) { |
|
151 | 151 | rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf( |
152 | 152 | classLocale::$lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name'] |
153 | 153 | )); |
154 | 154 | db_blitz_reg_update_apply_results($reward, $row, $current_round); |
155 | 155 | } |
156 | 156 | |
157 | - if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
|
157 | + if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
|
158 | 158 | break; |
159 | 159 | } |
160 | 160 | } |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | |
170 | 170 | $player_registered = false; |
171 | 171 | $query = db_blitz_reg_get_player_list_and_users($current_round); |
172 | -while($row = db_fetch($query)) { |
|
172 | +while ($row = db_fetch($query)) { |
|
173 | 173 | $tpl_player_data = array( |
174 | 174 | 'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)), |
175 | 175 | ); |
176 | 176 | |
177 | - if(classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
|
177 | + if (classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
|
178 | 178 | // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда |
179 | 179 | $tpl_player_data = array_merge($tpl_player_data, array( |
180 | 180 | 'ID' => $row['id'], |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | $template->assign_block_vars('registrations', $tpl_player_data); |
190 | - if($row['id'] == $user['id']) { |
|
190 | + if ($row['id'] == $user['id']) { |
|
191 | 191 | $player_registered = $row; |
192 | 192 | } |
193 | 193 | } |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | * @copyright 2008 by ??????? for XNova |
9 | 9 | */ |
10 | 10 | |
11 | -define('INSIDE' , true); |
|
12 | -define('INSTALL' , false); |
|
11 | +define('INSIDE', true); |
|
12 | +define('INSTALL', false); |
|
13 | 13 | define('IN_ADMIN', true); |
14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
15 | 15 | |
16 | -if($user['authlevel'] < 3) { |
|
16 | +if ($user['authlevel'] < 3) { |
|
17 | 17 | AdminMessage(classLocale::$lang['adm_err_denied']); |
18 | 18 | } |
19 | 19 | |
20 | 20 | $template = gettemplate('admin/settings', true); |
21 | 21 | |
22 | -if(sys_get_param('save')) { |
|
22 | +if (sys_get_param('save')) { |
|
23 | 23 | classSupernova::$config->game_name = sys_get_param_str_unsafe('game_name'); |
24 | 24 | classSupernova::$config->game_mode = sys_get_param_int('game_mode'); |
25 | 25 | classSupernova::$config->game_speed = sys_get_param_float('game_speed', 1); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | classSupernova::$config->url_faq = sys_get_param_str_unsafe('url_faq'); |
30 | 30 | classSupernova::$config->url_forum = sys_get_param_str_unsafe('url_forum'); |
31 | 31 | classSupernova::$config->url_rules = sys_get_param_str_unsafe('url_rules'); |
32 | - classSupernova::$config->url_purchase_metamatter = sys_get_param_str_unsafe('url_purchase_metamatter'); |
|
32 | + classSupernova::$config->url_purchase_metamatter = sys_get_param_str_unsafe('url_purchase_metamatter'); |
|
33 | 33 | classSupernova::$config->game_disable = sys_get_param_int('game_disable'); |
34 | 34 | classSupernova::$config->game_disable_reason = sys_get_param_str_unsafe('game_disable_reason'); |
35 | 35 | classSupernova::$config->server_updater_check_auto = sys_get_param_int('server_updater_check_auto'); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | classSupernova::$config->stats_schedule = sys_get_param_str('stats_schedule'); |
97 | 97 | |
98 | 98 | classSupernova::$config->empire_mercenary_base_period = sys_get_param_int('empire_mercenary_base_period'); |
99 | - if(classSupernova::$config->empire_mercenary_temporary != sys_get_param_int('empire_mercenary_temporary')) { |
|
100 | - if(classSupernova::$config->empire_mercenary_temporary) { |
|
99 | + if (classSupernova::$config->empire_mercenary_temporary != sys_get_param_int('empire_mercenary_temporary')) { |
|
100 | + if (classSupernova::$config->empire_mercenary_temporary) { |
|
101 | 101 | db_unit_list_admin_delete_mercenaries_finished(); |
102 | 102 | } else { |
103 | 103 | db_unit_list_admin_set_mercenaries_expire_time(classSupernova::$config->empire_mercenary_base_period); |
@@ -138,21 +138,21 @@ discard block |
||
138 | 138 | 'STATS_HIDE_PM_LINK' => classSupernova::$config->stats_hide_pm_link, |
139 | 139 | )); |
140 | 140 | |
141 | -foreach(classLocale::$lang['sys_game_disable_reason'] as $id => $name) { |
|
141 | +foreach (classLocale::$lang['sys_game_disable_reason'] as $id => $name) { |
|
142 | 142 | $template->assign_block_vars('sys_game_disable_reason', array( |
143 | 143 | 'ID' => $id, |
144 | 144 | 'NAME' => $name, |
145 | 145 | )); |
146 | 146 | } |
147 | 147 | |
148 | -foreach(classLocale::$lang['sys_game_mode'] as $mode_id => $mode_name) { |
|
148 | +foreach (classLocale::$lang['sys_game_mode'] as $mode_id => $mode_name) { |
|
149 | 149 | $template->assign_block_vars('game_modes', array( |
150 | 150 | 'ID' => $mode_id, |
151 | 151 | 'NAME' => $mode_name, |
152 | 152 | )); |
153 | 153 | } |
154 | 154 | |
155 | -foreach(classLocale::$lang['adm_opt_ver_response'] as $ver_id => $ver_response) { |
|
155 | +foreach (classLocale::$lang['adm_opt_ver_response'] as $ver_id => $ver_response) { |
|
156 | 156 | $template->assign_block_vars('ver_response', array( |
157 | 157 | 'ID' => $ver_id, |
158 | 158 | 'NAME' => js_safe_string($ver_response), |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | $lang_list = lng_get_list(); |
163 | -foreach($lang_list as $lang_id => $lang_data) { |
|
163 | +foreach ($lang_list as $lang_id => $lang_data) { |
|
164 | 164 | $template->assign_block_vars('game_languages', array( |
165 | 165 | 'ID' => $lang_id, |
166 | 166 | 'NAME' => "{$lang_data['LANG_NAME_NATIVE']} ({$lang_data['LANG_NAME_ENGLISH']})", |
@@ -13,15 +13,15 @@ |
||
13 | 13 | . '&id=' . urlencode(classSupernova::$config->server_updater_id); |
14 | 14 | |
15 | 15 | switch($mode) { |
16 | - case SNC_MODE_REGISTER: |
|
17 | - if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | - if($ajax) { |
|
19 | - print(SNC_VER_REGISTER_ERROR_REGISTERED); |
|
16 | + case SNC_MODE_REGISTER: |
|
17 | + if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | + if($ajax) { |
|
19 | + print(SNC_VER_REGISTER_ERROR_REGISTERED); |
|
20 | + } |
|
21 | + die(); |
|
20 | 22 | } |
21 | - die(); |
|
22 | - } |
|
23 | - $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); |
|
24 | - break; |
|
23 | + $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); |
|
24 | + break; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $check_result = sn_get_url_contents($url); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | . '&key=' . urlencode(classSupernova::$config->server_updater_key) |
13 | 13 | . '&id=' . urlencode(classSupernova::$config->server_updater_id); |
14 | 14 | |
15 | -switch($mode) { |
|
15 | +switch ($mode) { |
|
16 | 16 | case SNC_MODE_REGISTER: |
17 | - if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | - if($ajax) { |
|
17 | + if (classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | + if ($ajax) { |
|
19 | 19 | print(SNC_VER_REGISTER_ERROR_REGISTERED); |
20 | 20 | } |
21 | 21 | die(); |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | $check_result = sn_get_url_contents($url); |
28 | -if(!$check_result) { |
|
28 | +if (!$check_result) { |
|
29 | 29 | $version_check = SNC_VER_ERROR_CONNECT; |
30 | -} elseif(($version_check = intval($check_result)) && $version_check == $check_result) { |
|
30 | +} elseif (($version_check = intval($check_result)) && $version_check == $check_result) { |
|
31 | 31 | $version_check = $check_result; |
32 | 32 | } else { |
33 | 33 | // JSON decode if string |
34 | 34 | $check_result = json_decode($check_result, true); |
35 | 35 | $version_check = $check_result === null ? SNC_VER_UNKNOWN_RESPONSE : $check_result['version_check']; |
36 | 36 | |
37 | - switch($mode) { |
|
37 | + switch ($mode) { |
|
38 | 38 | case SNC_MODE_REGISTER: |
39 | - if($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) { |
|
39 | + if ($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) { |
|
40 | 40 | classSupernova::$config->db_saveItem('server_updater_key', $check_result['site']['site_key']); |
41 | 41 | classSupernova::$config->db_saveItem('server_updater_id', $check_result['site']['site_id']); |
42 | 42 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | classSupernova::$config->db_saveItem('server_updater_check_last', SN_TIME_NOW); |
50 | 50 | classSupernova::$config->db_saveItem('server_updater_check_result', $version_check); |
51 | 51 | |
52 | -if($ajax) { |
|
52 | +if ($ajax) { |
|
53 | 53 | define('IN_AJAX', true); |
54 | 54 | print($version_check); |
55 | 55 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * @param $query |
|
127 | + * @param string $query |
|
128 | 128 | * |
129 | 129 | * @return mixed |
130 | 130 | */ |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | - * @param $query |
|
144 | - * @param $fetch |
|
143 | + * @param string $query |
|
144 | + * @param boolean $fetch |
|
145 | 145 | */ |
146 | 146 | public function logQuery($query, $fetch) { |
147 | 147 | if(!classSupernova::$config->debug) { |
@@ -204,6 +204,10 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | // TODO Заменить это на новый логгер |
207 | + |
|
208 | + /** |
|
209 | + * @param string $query |
|
210 | + */ |
|
207 | 211 | function security_watch_user_queries($query) { |
208 | 212 | global $user; |
209 | 213 | |
@@ -227,6 +231,9 @@ discard block |
||
227 | 231 | } |
228 | 232 | |
229 | 233 | |
234 | + /** |
|
235 | + * @param string $query |
|
236 | + */ |
|
230 | 237 | function security_query_check_bad_words($query) { |
231 | 238 | global $user, $dm_change_legit, $mm_change_legit; |
232 | 239 |
@@ -73,23 +73,23 @@ discard block |
||
73 | 73 | public function sn_db_connect($external_db_settings = null) { |
74 | 74 | $this->db_disconnect(); |
75 | 75 | |
76 | - if(!empty($external_db_settings) && is_array($external_db_settings)) { |
|
76 | + if (!empty($external_db_settings) && is_array($external_db_settings)) { |
|
77 | 77 | $this->dbsettings = $external_db_settings; |
78 | 78 | } |
79 | 79 | |
80 | - if(empty($this->dbsettings)) { |
|
80 | + if (empty($this->dbsettings)) { |
|
81 | 81 | $this->load_db_settings(); |
82 | 82 | } |
83 | 83 | |
84 | 84 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
85 | - if(!empty($this->dbsettings)) { |
|
85 | + if (!empty($this->dbsettings)) { |
|
86 | 86 | $driver_name = empty($this->dbsettings['sn_driver']) ? 'db_mysql_v5' : $this->dbsettings['sn_driver']; |
87 | 87 | $this->driver = new $driver_name(); |
88 | 88 | $this->db_prefix = $this->dbsettings['prefix']; |
89 | 89 | |
90 | 90 | $this->connected = $this->connected || $this->driver_connect(); |
91 | 91 | |
92 | - if($this->connected) { |
|
92 | + if ($this->connected) { |
|
93 | 93 | $this->table_list = $this->db_get_table_list(); |
94 | 94 | // TODO Проверка на пустоту |
95 | 95 | } |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | protected function driver_connect() { |
104 | 104 | global $debug; |
105 | 105 | |
106 | - if(!is_object($this->driver)) { |
|
106 | + if (!is_object($this->driver)) { |
|
107 | 107 | $debug->error_fatal('DB Error - No driver for MySQL found!'); |
108 | 108 | } |
109 | 109 | |
110 | - if(!method_exists($this->driver, 'mysql_connect')) { |
|
110 | + if (!method_exists($this->driver, 'mysql_connect')) { |
|
111 | 111 | $debug->error_fatal('DB Error - WRONG MySQL driver!'); |
112 | 112 | } |
113 | 113 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | public function db_disconnect() { |
118 | - if($this->connected) { |
|
118 | + if ($this->connected) { |
|
119 | 119 | $this->connected = !$this->driver_disconnect(); |
120 | 120 | $this->connected = false; |
121 | 121 | } |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function replaceTablePlaceholders($query) { |
132 | 132 | $sql = $query; |
133 | - if(strpos($sql, '{{') !== false) { |
|
134 | - foreach($this->table_list as $tableName) { |
|
133 | + if (strpos($sql, '{{') !== false) { |
|
134 | + foreach ($this->table_list as $tableName) { |
|
135 | 135 | $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
136 | 136 | } |
137 | 137 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param $fetch |
145 | 145 | */ |
146 | 146 | protected function logQuery($query, $fetch) { |
147 | - if(!classSupernova::$config->debug) { |
|
147 | + if (!classSupernova::$config->debug) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | * @return void |
163 | 163 | */ |
164 | 164 | protected function commentQuery(&$sql) { |
165 | - if(!defined('DEBUG_SQL_COMMENT')) { |
|
165 | + if (!defined('DEBUG_SQL_COMMENT')) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | $backtrace = debug_backtrace(); |
169 | 169 | $sql_comment = classSupernova::$debug->compact_backtrace($backtrace, defined('DEBUG_SQL_COMMENT_LONG')); |
170 | 170 | |
171 | 171 | $sql_commented = '/* ' . implode("<br />", $sql_comment) . '<br /> */ ' . preg_replace("/\s+/", ' ', $sql); |
172 | - if(defined('DEBUG_SQL_ONLINE')) { |
|
172 | + if (defined('DEBUG_SQL_ONLINE')) { |
|
173 | 173 | classSupernova::$debug->warning($sql_commented, 'SQL Debug', LOG_DEBUG_SQL); |
174 | 174 | } |
175 | 175 | |
176 | - if(defined('DEBUG_SQL_ERROR')) { |
|
176 | + if (defined('DEBUG_SQL_ERROR')) { |
|
177 | 177 | array_unshift($sql_comment, preg_replace("/\s+/", ' ', $sql)); |
178 | 178 | classSupernova::$debug->add_to_array($sql_comment); |
179 | 179 | } |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | public function doquery($query, $table = '', $fetch = false, $skip_query_check = false) { |
185 | - if(!is_string($table)) { |
|
185 | + if (!is_string($table)) { |
|
186 | 186 | $fetch = $table; |
187 | 187 | } |
188 | 188 | |
189 | - if(!$this->connected) { |
|
189 | + if (!$this->connected) { |
|
190 | 190 | $this->sn_db_connect(); |
191 | 191 | } |
192 | 192 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | protected function security_watch_user_queries($query) { |
208 | 208 | global $user; |
209 | 209 | |
210 | - if( |
|
210 | + if ( |
|
211 | 211 | !$this->isWatching // Not already watching |
212 | 212 | && !empty(classSupernova::$config->game_watchlist_array) // There is some players in watchlist |
213 | 213 | && in_array($user['id'], classSupernova::$config->game_watchlist_array) // Current player is in watchlist |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | ) { |
216 | 216 | $this->isWatching = true; |
217 | 217 | $msg = "\$query = \"{$query}\"\n\r"; |
218 | - if(!empty($_POST)) { |
|
218 | + if (!empty($_POST)) { |
|
219 | 219 | $msg .= "\n\r" . dump($_POST, '$_POST'); |
220 | 220 | } |
221 | - if(!empty($_GET)) { |
|
221 | + if (!empty($_GET)) { |
|
222 | 222 | $msg .= "\n\r" . dump($_GET, '$_GET'); |
223 | 223 | } |
224 | 224 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public function security_query_check_bad_words($query) { |
231 | 231 | global $user, $dm_change_legit, $mm_change_legit; |
232 | 232 | |
233 | - switch(true) { |
|
233 | + switch (true) { |
|
234 | 234 | case stripos($query, 'RUNCATE TABL') != false: |
235 | 235 | case stripos($query, 'ROP TABL') != false: |
236 | 236 | case stripos($query, 'ENAME TABL') != false: |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | $prefix_length = strlen($this->db_prefix); |
293 | 293 | |
294 | 294 | $tl = array(); |
295 | - while($row = $this->db_fetch($query)) { |
|
296 | - foreach($row as $table_name) { |
|
297 | - if(strpos($table_name, $this->db_prefix) === 0) { |
|
295 | + while ($row = $this->db_fetch($query)) { |
|
296 | + foreach ($row as $table_name) { |
|
297 | + if (strpos($table_name, $this->db_prefix) === 0) { |
|
298 | 298 | $table_name = substr($table_name, $prefix_length); |
299 | - } elseif($prefixed_only) { |
|
299 | + } elseif ($prefixed_only) { |
|
300 | 300 | continue; |
301 | 301 | } |
302 | 302 | // $table_name = str_replace($db_prefix, '', $table_name); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $result = array(); |
392 | 392 | |
393 | 393 | $status = explode(' ', $this->driver->mysql_stat()); |
394 | - foreach($status as $value) { |
|
394 | + foreach ($status as $value) { |
|
395 | 395 | $row = explode(': ', $value); |
396 | 396 | $result[$row[0]] = $row[1]; |
397 | 397 | } |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | $result = array(); |
408 | 408 | |
409 | 409 | $query = $this->db_sql_query('SHOW STATUS;'); |
410 | - if(is_bool($query)) { |
|
410 | + if (is_bool($query)) { |
|
411 | 411 | throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?'); |
412 | 412 | } |
413 | - while($row = db_fetch($query)) { |
|
413 | + while ($row = db_fetch($query)) { |
|
414 | 414 | $result[$row['Variable_name']] = $row['Value']; |
415 | 415 | } |
416 | 416 |
@@ -2,19 +2,19 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
5 | +if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
6 | 6 | include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX); |
7 | 7 | } |
8 | 8 | |
9 | -if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
9 | +if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
10 | 10 | require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX); |
11 | 11 | sn_user_birthday_celebrate(); |
12 | 12 | } |
13 | 13 | |
14 | -if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
14 | +if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
15 | 15 | classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true)); |
16 | 16 | classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW); |
17 | - if(classSupernova::$config->server_log_online) { |
|
17 | + if (classSupernova::$config->server_log_online) { |
|
18 | 18 | db_log_online_insert(); |
19 | 19 | } |
20 | 20 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id']; |
42 | 42 | //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die(); |
43 | 43 | |
44 | -if(!empty($user['id'])) { |
|
44 | +if (!empty($user['id'])) { |
|
45 | 45 | classSupernova::$user_options->user_change($user['id']); |
46 | 46 | } |
47 | 47 | |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | : false |
55 | 55 | ); |
56 | 56 | |
57 | -if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
58 | - $prohibited_characters = array_map(function ($value) { |
|
57 | +if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
58 | + $prohibited_characters = array_map(function($value) { |
|
59 | 59 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
60 | 60 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
61 | 61 | $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters); |
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | -if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
65 | +if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
66 | 66 | pdump("Отключи отладку перед продакшном!"); |
67 | 67 | } |
68 | 68 | |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | ? define('INSTALL_MODE', GAME_DISABLE_INSTALL) |
77 | 77 | : false; |
78 | 78 | |
79 | -if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
79 | +if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
80 | 80 | $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse( |
81 | 81 | classSupernova::$config->game_disable == GAME_DISABLE_REASON |
82 | 82 | ? classSupernova::$config->game_disable_reason |
83 | 83 | : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable] |
84 | 84 | ); |
85 | - if(defined('IN_API')) { |
|
85 | + if (defined('IN_API')) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | |
89 | - if( |
|
89 | + if ( |
|
90 | 90 | ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN)) |
91 | 91 | && |
92 | 92 | !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT')) |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | |
101 | 101 | // TODO ban |
102 | 102 | // TODO $skip_ban_check |
103 | -if($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
104 | - if(defined('IN_API')) { |
|
103 | +if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
104 | + if (defined('IN_API')) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | // pdump($allow_anonymous, '$allow_anonymous'); |
120 | 120 | // pdump($sys_user_logged_in, '$sys_user_logged_in'); |
121 | 121 | |
122 | -if($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
122 | +if ($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
123 | 123 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
124 | -} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
124 | +} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
125 | 125 | // pdump($sn_page_name); |
126 | 126 | // pdump(INITIAL_PAGE); |
127 | 127 | // die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}'); |
128 | -} elseif(!$allow_anonymous && !$sys_user_logged_in) { |
|
128 | +} elseif (!$allow_anonymous && !$sys_user_logged_in) { |
|
129 | 129 | // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
130 | 130 | sys_redirect(SN_ROOT_VIRTUAL . 'login.php'); |
131 | 131 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | global $skip_fleet_update; |
148 | 148 | $skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN'); |
149 | -if( |
|
149 | +if ( |
|
150 | 150 | !$skip_fleet_update |
151 | 151 | && !(defined('IN_AJAX') && IN_AJAX === true) |
152 | 152 | && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | flt_flying_fleet_handler($skip_fleet_update); |
156 | 156 | } |
157 | 157 | |
158 | -if(!defined('IN_AJAX')) { |
|
158 | +if (!defined('IN_AJAX')) { |
|
159 | 159 | print("Scheduled processes is disabled<br />"); |
160 | 160 | } |
161 | 161 | // scheduler_process(); |
@@ -34,69 +34,69 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | switch($mode) { |
37 | - case ADM_TOOL_CONFIG_RELOAD: |
|
38 | - classSupernova::$config->db_loadAll(); |
|
39 | - sys_refresh_tablelist(); |
|
40 | - |
|
41 | - classSupernova::$config->db_loadItem('game_watchlist'); |
|
42 | - if(classSupernova::$config->game_watchlist) { |
|
43 | - classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist); |
|
44 | - } else { |
|
45 | - unset(classSupernova::$config->game_watchlist_array); |
|
46 | - } |
|
47 | - break; |
|
48 | - |
|
49 | - case ADM_TOOL_MD5: |
|
50 | - $template = gettemplate("admin/md5enc", true); |
|
51 | - $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED); |
|
52 | - $password_length = sys_get_param_int('length', 16); |
|
53 | - $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed); |
|
54 | - |
|
55 | - $template->assign_vars(array( |
|
56 | - 'SEED' => $password_seed, |
|
57 | - 'LENGTH' => $password_length, |
|
58 | - 'STRING' => htmlentities($string), |
|
59 | - 'MD5' => md5($string), |
|
60 | - )); |
|
61 | - display($template, classLocale::$lang['adm_tools_md5_header'], false, '', true); |
|
62 | - break; |
|
63 | - |
|
64 | - case ADM_TOOL_FORCE_ALL: |
|
65 | - classSupernova::$config->db_saveItem('db_version', 0); |
|
66 | - require_once('../includes/update.php'); |
|
67 | - break; |
|
68 | - |
|
69 | - case ADM_TOOL_FORCE_LAST: |
|
70 | - classSupernova::$config->db_saveItem('db_version', floor(classSupernova::$config->db_version - 1)); |
|
71 | - require_once('../includes/update.php'); |
|
72 | - break; |
|
73 | - |
|
74 | - case ADM_TOOL_INFO_PHP: |
|
75 | - phpinfo(); |
|
76 | - break; |
|
77 | - |
|
78 | - case ADM_TOOL_INFO_SQL: |
|
79 | - $template = gettemplate("simple_table", true); |
|
80 | - |
|
81 | - $status = array( |
|
82 | - classLocale::$lang['adm_tool_sql_server_version'] => classSupernova::$db->db_get_server_info(), |
|
83 | - classLocale::$lang['adm_tool_sql_client_version'] => classSupernova::$db->db_get_client_info(), |
|
84 | - classLocale::$lang['adm_tool_sql_host_info'] => classSupernova::$db->db_get_host_info(), |
|
85 | - ); |
|
86 | - templateAssignTable($template, 'server', $status); |
|
87 | - |
|
88 | - templateAssignTable($template, 'status', classSupernova::$db->db_get_server_stat()); |
|
89 | - templateAssignTable($template, 'params', classSupernova::$db->db_core_show_status()); |
|
90 | - |
|
91 | - $template->assign_vars(array( |
|
92 | - 'PAGE_HEADER' => classLocale::$lang['adm_tool_sql_page_header'], |
|
93 | - 'COLUMN_NAME_1' => classLocale::$lang['adm_tool_sql_param_name'], |
|
94 | - 'COLUMN_NAME_2' => classLocale::$lang['adm_tool_sql_param_value'], |
|
95 | - 'TABLE_FOOTER' => 'test', |
|
96 | - )); |
|
97 | - |
|
98 | - display($template, classLocale::$lang['adm_bn_ttle'], false, '', true); |
|
99 | - break; |
|
37 | + case ADM_TOOL_CONFIG_RELOAD: |
|
38 | + classSupernova::$config->db_loadAll(); |
|
39 | + sys_refresh_tablelist(); |
|
40 | + |
|
41 | + classSupernova::$config->db_loadItem('game_watchlist'); |
|
42 | + if(classSupernova::$config->game_watchlist) { |
|
43 | + classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist); |
|
44 | + } else { |
|
45 | + unset(classSupernova::$config->game_watchlist_array); |
|
46 | + } |
|
47 | + break; |
|
48 | + |
|
49 | + case ADM_TOOL_MD5: |
|
50 | + $template = gettemplate("admin/md5enc", true); |
|
51 | + $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED); |
|
52 | + $password_length = sys_get_param_int('length', 16); |
|
53 | + $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed); |
|
54 | + |
|
55 | + $template->assign_vars(array( |
|
56 | + 'SEED' => $password_seed, |
|
57 | + 'LENGTH' => $password_length, |
|
58 | + 'STRING' => htmlentities($string), |
|
59 | + 'MD5' => md5($string), |
|
60 | + )); |
|
61 | + display($template, classLocale::$lang['adm_tools_md5_header'], false, '', true); |
|
62 | + break; |
|
63 | + |
|
64 | + case ADM_TOOL_FORCE_ALL: |
|
65 | + classSupernova::$config->db_saveItem('db_version', 0); |
|
66 | + require_once('../includes/update.php'); |
|
67 | + break; |
|
68 | + |
|
69 | + case ADM_TOOL_FORCE_LAST: |
|
70 | + classSupernova::$config->db_saveItem('db_version', floor(classSupernova::$config->db_version - 1)); |
|
71 | + require_once('../includes/update.php'); |
|
72 | + break; |
|
73 | + |
|
74 | + case ADM_TOOL_INFO_PHP: |
|
75 | + phpinfo(); |
|
76 | + break; |
|
77 | + |
|
78 | + case ADM_TOOL_INFO_SQL: |
|
79 | + $template = gettemplate("simple_table", true); |
|
80 | + |
|
81 | + $status = array( |
|
82 | + classLocale::$lang['adm_tool_sql_server_version'] => classSupernova::$db->db_get_server_info(), |
|
83 | + classLocale::$lang['adm_tool_sql_client_version'] => classSupernova::$db->db_get_client_info(), |
|
84 | + classLocale::$lang['adm_tool_sql_host_info'] => classSupernova::$db->db_get_host_info(), |
|
85 | + ); |
|
86 | + templateAssignTable($template, 'server', $status); |
|
87 | + |
|
88 | + templateAssignTable($template, 'status', classSupernova::$db->db_get_server_stat()); |
|
89 | + templateAssignTable($template, 'params', classSupernova::$db->db_core_show_status()); |
|
90 | + |
|
91 | + $template->assign_vars(array( |
|
92 | + 'PAGE_HEADER' => classLocale::$lang['adm_tool_sql_page_header'], |
|
93 | + 'COLUMN_NAME_1' => classLocale::$lang['adm_tool_sql_param_name'], |
|
94 | + 'COLUMN_NAME_2' => classLocale::$lang['adm_tool_sql_param_value'], |
|
95 | + 'TABLE_FOOTER' => 'test', |
|
96 | + )); |
|
97 | + |
|
98 | + display($template, classLocale::$lang['adm_bn_ttle'], false, '', true); |
|
99 | + break; |
|
100 | 100 | |
101 | 101 | } |
102 | 102 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
13 | 13 | |
14 | 14 | // if($user['authlevel'] < 1) |
15 | -if($user['authlevel'] < 3) { |
|
15 | +if ($user['authlevel'] < 3) { |
|
16 | 16 | AdminMessage(classLocale::$lang['adm_err_denied']); |
17 | 17 | } |
18 | 18 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function templateAssignTable($template, $str, $status) { |
27 | 27 | $template->assign_block_vars('table', classLocale::$lang['adm_tool_sql_table'][$str]); |
28 | - foreach($status as $key => $value) { |
|
28 | + foreach ($status as $key => $value) { |
|
29 | 29 | $template->assign_block_vars('table.row', array( |
30 | 30 | 'VALUE_1' => $key, |
31 | 31 | 'VALUE_2' => $value, |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
36 | -switch($mode) { |
|
36 | +switch ($mode) { |
|
37 | 37 | case ADM_TOOL_CONFIG_RELOAD: |
38 | 38 | classSupernova::$config->db_loadAll(); |
39 | 39 | sys_refresh_tablelist(); |
40 | 40 | |
41 | 41 | classSupernova::$config->db_loadItem('game_watchlist'); |
42 | - if(classSupernova::$config->game_watchlist) { |
|
42 | + if (classSupernova::$config->game_watchlist) { |
|
43 | 43 | classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist); |
44 | 44 | } else { |
45 | 45 | unset(classSupernova::$config->game_watchlist_array); |