@@ -116,7 +116,7 @@ |
||
116 | 116 | 'log_lost_send_mail' => 'Send confirmation code', |
117 | 117 | 'log_lost_description2' => 'If you have a confirmation code, please enter it below and click "Reset password". An e-mail will be sent an email with a new password<br /><br /> |
118 | 118 | If you already asking for confirmation code but can not find email from us in your main folder - check your SPAM folder. Some mail servers can mark our letters as "SPAM"<br /><br /> |
119 | - If you absolutly sure that did not receive email from us - just write a email to Administration address <span class="ok">' . classSupernova::$config->server_email . '</span>', |
|
119 | + If you absolutly sure that did not receive email from us - just write a email to Administration address <span class="ok">' . classSupernova::$config->server_email.'</span>', |
|
120 | 120 | 'log_lost_reset_pass' => 'Reset password', |
121 | 121 | 'log_lost_sent_code' => 'Email sent to this email with further instructions on resetting your password', |
122 | 122 | 'log_lost_sent_pass' => 'Just sent to your email message with the new password', |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | global $skip_fleet_update; |
6 | 6 | $skip_fleet_update = true; |
7 | 7 | |
8 | -require_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
8 | +require_once('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
9 | 9 | |
10 | 10 | /* |
11 | 11 | $time_local = $time_server + $time_diff |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | $time_server = $time_local - $time_diff |
14 | 14 | */ |
15 | 15 | |
16 | -if($font_size = sys_get_param_str('font_size')) { |
|
17 | - if(strpos($font_size, '%') !== false) { |
|
16 | +if ($font_size = sys_get_param_str('font_size')) { |
|
17 | + if (strpos($font_size, '%') !== false) { |
|
18 | 18 | // Размер шрифта в процентах |
19 | - $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%'; |
|
20 | - } elseif(strpos($font_size, 'px') !== false) { |
|
19 | + $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX).'%'; |
|
20 | + } elseif (strpos($font_size, 'px') !== false) { |
|
21 | 21 | // Размер шрифта в пикселях |
22 | - $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px'; |
|
22 | + $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX).'px'; |
|
23 | 23 | } else { |
24 | 24 | // Не мышонка, не лягушка... |
25 | 25 | $font_size = FONT_SIZE_PERCENT_DEFAULT_STRING; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE] = $font_size; |
30 | 30 | } else { |
31 | 31 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
32 | - if($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
32 | + if ($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
33 | 33 | $time_diff = intval($user_time_diff[PLAYER_OPTION_TIME_DIFF]); |
34 | 34 | } else { |
35 | 35 | $user_time_diff = playerTimeDiff::user_time_diff_probe(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | $language_new = sys_get_param_str('langer', $user['lang']); |
14 | 14 | |
15 | - if($language_new != $user['lang']) { |
|
15 | + if ($language_new != $user['lang']) { |
|
16 | 16 | classLocale::$lang->lng_switch($language_new); |
17 | 17 | } |
18 | 18 | |
@@ -21,41 +21,41 @@ discard block |
||
21 | 21 | |
22 | 22 | $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE); |
23 | 23 | |
24 | - if(sys_get_param_str('mode') == 'change') { |
|
25 | - if($user['authlevel'] > 0) { |
|
24 | + if (sys_get_param_str('mode') == 'change') { |
|
25 | + if ($user['authlevel'] > 0) { |
|
26 | 26 | $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0; |
27 | 27 | db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'"); |
28 | 28 | db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'"); |
29 | 29 | $user['admin_protection'] = $planet_protection; |
30 | 30 | } |
31 | 31 | |
32 | - if(sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) { |
|
32 | + if (sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) { |
|
33 | 33 | sn_db_transaction_start(); |
34 | - if($user['authlevel'] < 3) { |
|
35 | - if($user['vacation_next'] > SN_TIME_NOW) { |
|
34 | + if ($user['authlevel'] < 3) { |
|
35 | + if ($user['vacation_next'] > SN_TIME_NOW) { |
|
36 | 36 | message(classLocale::$lang['opt_vacation_err_timeout'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
37 | 37 | die(); |
38 | 38 | } |
39 | 39 | |
40 | - if(FleetList::fleet_count_flying($user['id'])) { |
|
40 | + if (FleetList::fleet_count_flying($user['id'])) { |
|
41 | 41 | message(classLocale::$lang['opt_vacation_err_your_fleet'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
42 | 42 | die(); |
43 | 43 | } |
44 | 44 | |
45 | 45 | $que = que_get($user['id'], false); |
46 | - if(!empty($que)) { |
|
46 | + if (!empty($que)) { |
|
47 | 47 | message(classLocale::$lang['opt_vacation_err_que'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
48 | 48 | die(); |
49 | 49 | } |
50 | 50 | |
51 | 51 | $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}"); |
52 | - foreach($query as $planet) { |
|
52 | + foreach ($query as $planet) { |
|
53 | 53 | // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW); |
54 | 54 | // $planet = $planet['planet']; |
55 | 55 | |
56 | 56 | $classConfig = classSupernova::$config; |
57 | 57 | db_planet_set_by_id($planet['id'], |
58 | - "last_update = " . SN_TIME_NOW . ", energy_used = '0', energy_max = '0', |
|
58 | + "last_update = ".SN_TIME_NOW.", energy_used = '0', energy_max = '0', |
|
59 | 59 | metal_perhour = '{$classConfig->metal_basic_income}', crystal_perhour = '{$classConfig->crystal_basic_income}', deuterium_perhour = '{$classConfig->deuterium_basic_income}', |
60 | 60 | metal_mine_porcent = '0', crystal_mine_porcent = '0', deuterium_sintetizer_porcent = '0', solar_plant_porcent = '0', |
61 | 61 | fusion_plant_porcent = '0', solar_satelit_porcent = '0', ship_sattelite_sloth_porcent = 0" |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | sn_db_transaction_commit(); |
69 | 69 | } |
70 | 70 | |
71 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
72 | - foreach($option_group as $option_name => $option_value) { |
|
73 | - if($user[$option_name] !== null) { |
|
71 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
72 | + foreach ($option_group as $option_name => $option_value) { |
|
73 | + if ($user[$option_name] !== null) { |
|
74 | 74 | $user[$option_name] = sys_get_param_str($option_name); |
75 | 75 | } else { |
76 | 76 | $user[$option_name] = $option_value; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | $player_options = sys_get_param('options'); |
84 | - if(!empty($player_options)) { |
|
85 | - array_walk($player_options, function (&$value) { |
|
84 | + if (!empty($player_options)) { |
|
85 | + array_walk($player_options, function(&$value) { |
|
86 | 86 | // TODO - Когда будет больше параметров - сделать больше проверок |
87 | 87 | $value = intval($value); |
88 | 88 | }); |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | |
94 | 94 | $username = substr(sys_get_param_str_unsafe('username'), 0, 32); |
95 | 95 | $username_safe = db_escape($username); |
96 | - if($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
96 | + if ($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
97 | 97 | // проверка на корректность |
98 | 98 | sn_db_transaction_start(); |
99 | 99 | $name_check = db_player_name_history_get_name_by_name($username_safe); |
100 | - if(!$name_check || $name_check['player_id'] == $user['id']) { |
|
100 | + if (!$name_check || $name_check['player_id'] == $user['id']) { |
|
101 | 101 | $user = db_user_by_id($user['id'], true); |
102 | - switch(classSupernova::$config->game_user_changename) { |
|
102 | + switch (classSupernova::$config->game_user_changename) { |
|
103 | 103 | case SERVER_PLAYER_NAME_CHANGE_PAY: |
104 | - if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) { |
|
104 | + if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) { |
|
105 | 105 | $template_result['.']['result'][] = array( |
106 | 106 | 'STATUS' => ERR_ERROR, |
107 | 107 | 'MESSAGE' => classLocale::$lang['opt_msg_name_change_err_no_dm'], |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | sn_db_transaction_commit(); |
132 | 132 | } |
133 | 133 | |
134 | - if($new_password = sys_get_param('newpass1')) { |
|
134 | + if ($new_password = sys_get_param('newpass1')) { |
|
135 | 135 | try { |
136 | - if($new_password != sys_get_param('newpass2')) { |
|
136 | + if ($new_password != sys_get_param('newpass2')) { |
|
137 | 137 | throw new Exception(classLocale::$lang['opt_err_pass_unmatched'], ERR_WARNING); |
138 | 138 | } |
139 | 139 | |
140 | - if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
140 | + if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
141 | 141 | throw new Exception(classLocale::$lang['opt_err_pass_wrong'], ERR_WARNING); |
142 | 142 | } |
143 | 143 | |
144 | 144 | throw new Exception(classLocale::$lang['opt_msg_pass_changed'], ERR_NONE); |
145 | - } catch(Exception $e) { |
|
145 | + } catch (Exception $e) { |
|
146 | 146 | $template_result['.']['result'][] = array( |
147 | 147 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
148 | 148 | 'MESSAGE' => $e->getMessage() |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender']; |
165 | 165 | |
166 | 166 | try { |
167 | - if($user['birthday']) { |
|
167 | + if ($user['birthday']) { |
|
168 | 168 | throw new exception(); |
169 | 169 | } |
170 | 170 | |
171 | 171 | $user_birthday = sys_get_param_str_unsafe('user_birthday'); |
172 | - if(!$user_birthday || $user_birthday == $FMT_DATE) { |
|
172 | + if (!$user_birthday || $user_birthday == $FMT_DATE) { |
|
173 | 173 | throw new exception(); |
174 | 174 | } |
175 | 175 | |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | $pos['Y'] = strpos(FMT_DATE, 'Y'); |
180 | 180 | asort($pos); |
181 | 181 | $i = 0; |
182 | - foreach($pos as &$position) { |
|
182 | + foreach ($pos as &$position) { |
|
183 | 183 | $position = ++$i; |
184 | 184 | } |
185 | 185 | |
186 | - $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/"; |
|
187 | - if(!preg_match($regexp, $user_birthday, $match)) { |
|
186 | + $regexp = "/".preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE)."/"; |
|
187 | + if (!preg_match($regexp, $user_birthday, $match)) { |
|
188 | 188 | throw new exception(); |
189 | 189 | } |
190 | 190 | |
191 | - if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
191 | + if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
192 | 192 | throw new exception(); |
193 | 193 | } |
194 | 194 | |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format |
197 | 197 | |
198 | 198 | $year = date('Y', SN_TIME_NOW); |
199 | - if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
199 | + if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
200 | 200 | $year--; |
201 | 201 | } |
202 | 202 | $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}"); |
203 | 203 | |
204 | 204 | $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'"; |
205 | - } catch(exception $e) { |
|
205 | + } catch (exception $e) { |
|
206 | 206 | $user_birthday = ''; |
207 | 207 | } |
208 | 208 | |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | $template_result['.']['result'][] = $avatar_upload_result; |
213 | 213 | |
214 | 214 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
215 | - if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
215 | + if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
216 | 216 | playerTimeDiff::user_time_diff_set(array( |
217 | 217 | PLAYER_OPTION_TIME_DIFF => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'), |
218 | 218 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
219 | 219 | PLAYER_OPTION_TIME_DIFF_FORCED => 1, |
220 | 220 | PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL, |
221 | 221 | )); |
222 | - } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
222 | + } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
223 | 223 | playerTimeDiff::user_time_diff_set(array( |
224 | 224 | PLAYER_OPTION_TIME_DIFF => '', |
225 | 225 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | 'STATUS' => ERR_NONE, |
240 | 240 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
241 | 241 | ); |
242 | - } elseif(sys_get_param_str('result') == 'ok') { |
|
242 | + } elseif (sys_get_param_str('result') == 'ok') { |
|
243 | 243 | $template_result['.']['result'][] = array( |
244 | 244 | 'STATUS' => ERR_NONE, |
245 | 245 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | |
263 | 263 | $template = gettemplate('options', $template); |
264 | 264 | |
265 | - $dir = dir(SN_ROOT_PHYSICAL . 'skins'); |
|
266 | - while(($entry = $dir->read()) !== false) { |
|
267 | - if(is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
265 | + $dir = dir(SN_ROOT_PHYSICAL.'skins'); |
|
266 | + while (($entry = $dir->read()) !== false) { |
|
267 | + if (is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
268 | 268 | $template_result['.']['skin_list'][] = array( |
269 | 269 | 'VALUE' => $entry, |
270 | 270 | 'NAME' => $entry, |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | $dir->close(); |
276 | 276 | |
277 | - foreach(classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
277 | + foreach (classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
278 | 278 | $template_result['.']['planet_sort_options'][] = array( |
279 | 279 | 'VALUE' => $key, |
280 | 280 | 'NAME' => $value, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | ); |
283 | 283 | } |
284 | 284 | |
285 | - foreach(classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
285 | + foreach (classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
286 | 286 | $template_result['.']['gender_list'][] = array( |
287 | 287 | 'VALUE' => $key, |
288 | 288 | 'NAME' => $value, |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | $lang_list = lng_get_list(); |
294 | - foreach($lang_list as $lang_id => $lang_data) { |
|
294 | + foreach ($lang_list as $lang_id => $lang_data) { |
|
295 | 295 | $template_result['.']['languages'][] = array( |
296 | 296 | 'VALUE' => $lang_id, |
297 | 297 | 'NAME' => $lang_data['LANG_NAME_NATIVE'], |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | |
303 | - if(isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
304 | - foreach(classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
303 | + if (isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
304 | + foreach (classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
305 | 305 | $template->assign_block_vars('menu_customize_show_hide_button_state', array( |
306 | 306 | 'ID' => $key, |
307 | 307 | 'NAME' => $value, |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | 'PAGE_HEADER' => classLocale::$lang['opt_header'], |
409 | 409 | )); |
410 | 410 | |
411 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
412 | - if($option_group_id == OPT_MESSAGE) { |
|
413 | - foreach($sn_message_class_list as $message_class_id => $message_class_data) { |
|
414 | - if($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) { |
|
411 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
412 | + if ($option_group_id == OPT_MESSAGE) { |
|
413 | + foreach ($sn_message_class_list as $message_class_id => $message_class_data) { |
|
414 | + if ($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) { |
|
415 | 415 | $option_name = $message_class_data['name']; |
416 | 416 | |
417 | 417 | $template->assign_block_vars("options_{$option_group_id}", array( |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | } |
424 | 424 | } |
425 | 425 | } else { |
426 | - foreach($option_group as $option_name => $option_value) { |
|
427 | - if(array_key_exists($option_name, $user_option_types)) { |
|
426 | + foreach ($option_group as $option_name => $option_value) { |
|
427 | + if (array_key_exists($option_name, $user_option_types)) { |
|
428 | 428 | $option_type = $user_option_types[$option_name]; |
429 | 429 | } else { |
430 | 430 | $option_type = 'switch'; |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | $sn_group_factories = sn_get_groups('factories'); |
23 | 23 | $planet_density = sn_get_groups('planet_density'); |
24 | 24 | |
25 | - if(sys_get_param('save_production')) { |
|
25 | + if (sys_get_param('save_production')) { |
|
26 | 26 | $production = sys_get_param('percent'); |
27 | - if(is_array($production) && !empty($production)) { |
|
27 | + if (is_array($production) && !empty($production)) { |
|
28 | 28 | // sn_db_transaction_start(); |
29 | 29 | $query = array(); |
30 | 30 | $planet_row_list = db_planet_list_sorted($user, false, '*'); |
31 | 31 | // while($planet = db_fetch($planet_row_list)) |
32 | - foreach($planet_row_list as $planet) { |
|
33 | - foreach($sn_group_factories as $factory_unit_id) { |
|
32 | + foreach ($planet_row_list as $planet) { |
|
33 | + foreach ($sn_group_factories as $factory_unit_id) { |
|
34 | 34 | $unit_db_name_porcent = pname_factory_production_field_name($factory_unit_id); |
35 | - if( |
|
35 | + if ( |
|
36 | 36 | get_unit_param($factory_unit_id, P_MINING_IS_MANAGED) |
37 | 37 | && isset($production[$factory_unit_id][$planet['id']]) |
38 | 38 | && ($actual_porcent = intval($production[$factory_unit_id][$planet['id']] / 10)) >= 0 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | - foreach($query as $planet_id => $query_data) { |
|
46 | + foreach ($query as $planet_id => $query_data) { |
|
47 | 47 | db_planet_set_by_id($planet_id, implode(',', $query_data)); |
48 | 48 | } |
49 | 49 | // sn_db_transaction_commit(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | $planet_row_list = db_planet_list_sorted($user); |
54 | 54 | // while ($planet = db_fetch($planet_row_list)) |
55 | - foreach($planet_row_list as $planet) { |
|
55 | + foreach ($planet_row_list as $planet) { |
|
56 | 56 | sn_db_transaction_start(); |
57 | 57 | $global_data = sys_o_get_updated($user, $planet['id'], SN_TIME_NOW, false, true); |
58 | 58 | $planets[$planet['id']] = $global_data['planet']; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $template = gettemplate('imperium', $template); |
65 | 65 | $template->assign_var('amount', count($planets) + 2); |
66 | 66 | |
67 | - for($i = 100; $i >= 0; $i -= 10) { |
|
67 | + for ($i = 100; $i >= 0; $i -= 10) { |
|
68 | 68 | $template->assign_block_vars('percent', array('PERCENT' => $i)); |
69 | 69 | } |
70 | 70 | |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | $total['temp_min'] = 1000; |
75 | 75 | $total['temp_max'] = -999; |
76 | 76 | |
77 | - foreach($planets as $planet_index => &$planet) { |
|
77 | + foreach ($planets as $planet_index => &$planet) { |
|
78 | 78 | $list_planet_que = $ques[$planet_index]; |
79 | 79 | $planet_template = tpl_parse_planet($planet); |
80 | 80 | |
81 | 81 | $planet_fleet_id = 0; |
82 | - $fleet_list = $planet_template['fleet_list'];//flt_get_fleets_to_planet($planet); |
|
83 | - if($fleet_list['own']['count']) { |
|
82 | + $fleet_list = $planet_template['fleet_list']; //flt_get_fleets_to_planet($planet); |
|
83 | + if ($fleet_list['own']['count']) { |
|
84 | 84 | $planet_fleet_id = "p{$fleet_id}"; |
85 | 85 | $fleets[] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id); |
86 | 86 | $fleet_id++; |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | UNIT_DEFENCE => 'defense', |
142 | 142 | ); |
143 | 143 | |
144 | - foreach($show_groups as $unit_group_id => $mode) { |
|
144 | + foreach ($show_groups as $unit_group_id => $mode) { |
|
145 | 145 | $template->assign_block_vars('prods', array( |
146 | 146 | 'NAME' => classLocale::$lang['tech'][$unit_group_id], |
147 | 147 | )); |
148 | 148 | $unit_group = get_unit_param('techtree', $unit_group_id); |
149 | - foreach($unit_group as $unit_id) { |
|
149 | + foreach ($unit_group as $unit_id) { |
|
150 | 150 | $unit_count = $unit_count_abs = 0; |
151 | 151 | $block_vars = array(); |
152 | 152 | $unit_is_factory = in_array($unit_id, $sn_group_factories) && get_unit_param($unit_id, P_MINING_IS_MANAGED); |
153 | 153 | // $unit_db_name = pname_resource_name($unit_id); |
154 | - foreach($planets as $planet) { |
|
154 | + foreach ($planets as $planet) { |
|
155 | 155 | $unit_level_plain = mrc_get_level($user, $planet, $unit_id, false, true); |
156 | 156 | |
157 | 157 | $level_plus['FACTORY'] = $unit_is_factory; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $level_plus['LEVEL_PLUS_GREEN'] = 0; |
160 | 160 | |
161 | 161 | $level_plus['PERCENT'] = $unit_is_factory ? ($unit_level_plain ? $planet[pname_factory_production_field_name($unit_id)] * 10 : -1) : -1; |
162 | - switch($mode) { |
|
162 | + switch ($mode) { |
|
163 | 163 | /* |
164 | 164 | case 'structures': |
165 | 165 | $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id]; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | case 'structures': |
180 | 180 | case 'defense': |
181 | 181 | $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id]; |
182 | - if($level_plus_build) { |
|
182 | + if ($level_plus_build) { |
|
183 | 183 | $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build < 0 ? $level_plus_build : "+{$level_plus_build}"; |
184 | 184 | // $level_plus['LEVEL_PLUS_GREEN'] = "+{$level_plus_build}"; |
185 | 185 | $total['units'][$unit_id]['LEVEL_PLUS_GREEN'] += $level_plus['LEVEL_PLUS_GREEN']; |
@@ -199,15 +199,15 @@ discard block |
||
199 | 199 | $unit_count_abs += $unit_level_plain + abs($level_plus['LEVEL_PLUS_YELLOW']) + abs($level_plus['LEVEL_PLUS_GREEN']); |
200 | 200 | } |
201 | 201 | |
202 | - if($unit_count_abs) { |
|
202 | + if ($unit_count_abs) { |
|
203 | 203 | $template->assign_block_vars('prods', array( |
204 | 204 | 'ID' => $unit_id, |
205 | - 'FIELD' => 'unit_' . $unit_id, // pname_resource_name($unit_id), // TODO Делать это прямо в темплейте |
|
205 | + 'FIELD' => 'unit_'.$unit_id, // pname_resource_name($unit_id), // TODO Делать это прямо в темплейте |
|
206 | 206 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
207 | 207 | 'MODE' => $mode, |
208 | 208 | )); |
209 | 209 | |
210 | - foreach($block_vars as $block_var) { |
|
210 | + foreach ($block_vars as $block_var) { |
|
211 | 211 | $template->assign_block_vars('prods.planet', $block_var); |
212 | 212 | } |
213 | 213 | $unit_green = $total['units'][$unit_id]['LEVEL_PLUS_GREEN']; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | [!] DB code updates |
22 | 22 | */ |
23 | 23 | |
24 | -if(!defined('INIT')) { |
|
24 | +if (!defined('INIT')) { |
|
25 | 25 | // include_once('init.php'); |
26 | 26 | die('Unauthorized access'); |
27 | 27 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | classSupernova::$config->debug = 0; |
40 | 40 | |
41 | 41 | |
42 | -if(classSupernova::$config->db_version == DB_VERSION) { |
|
43 | -} elseif(classSupernova::$config->db_version > DB_VERSION) { |
|
42 | +if (classSupernova::$config->db_version == DB_VERSION) { |
|
43 | +} elseif (classSupernova::$config->db_version > DB_VERSION) { |
|
44 | 44 | classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW); |
45 | 45 | die( |
46 | 46 | 'Internal error! Auotupdater detects DB version greater then can be handled!<br /> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | -if(classSupernova::$config->db_version < 26) { |
|
52 | +if (classSupernova::$config->db_version < 26) { |
|
53 | 53 | $sys_log_disabled = true; |
54 | 54 | } |
55 | 55 | |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | $update_tables = array(); |
69 | 69 | $update_indexes = array(); |
70 | 70 | $query = upd_do_query('SHOW TABLES;', true); |
71 | -while($row = db_fetch_row($query)) { |
|
71 | +while ($row = db_fetch_row($query)) { |
|
72 | 72 | upd_load_table_info($row[0]); |
73 | 73 | } |
74 | 74 | upd_log_message('Table info loaded. Now looking DB for upgrades...'); |
75 | 75 | |
76 | 76 | upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true); |
77 | 77 | |
78 | -if($new_version < 37) { |
|
78 | +if ($new_version < 37) { |
|
79 | 79 | require_once('update_old.php'); |
80 | 80 | } |
81 | 81 | |
82 | 82 | ini_set('memory_limit', '1024M'); |
83 | 83 | |
84 | -switch($new_version) { |
|
84 | +switch ($new_version) { |
|
85 | 85 | case 37: |
86 | 86 | upd_log_version_update(); |
87 | 87 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_); |
98 | 98 | |
99 | - if(!$update_tables['log_metamatter']) { |
|
99 | + if (!$update_tables['log_metamatter']) { |
|
100 | 100 | upd_create_table('log_metamatter', |
101 | 101 | "( |
102 | 102 | `id` SERIAL, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
122 | 122 | ), !$update_tables['payment']['payment_test']); |
123 | 123 | |
124 | - if($update_tables['payment']['payment_test']['Default'] == 1) { |
|
124 | + if ($update_tables['payment']['payment_test']['Default'] == 1) { |
|
125 | 125 | upd_alter_table('payment', array( |
126 | 126 | "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
127 | 127 | )); |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | "MODIFY COLUMN `metamatter` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Metamatter amount'", |
138 | 138 | ), $update_tables['users']['metamatter']['Type'] == 'int(20)'); |
139 | 139 | |
140 | - $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE"); |
|
141 | - while($row = db_fetch($query)) { |
|
140 | + $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = ".QUE_RESEARCH." AND que_unit_id IN (".TECH_EXPEDITION.",".TECH_COLONIZATION.") FOR UPDATE"); |
|
141 | + while ($row = db_fetch($query)) { |
|
142 | 142 | $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']); |
143 | 143 | upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE"); |
144 | 144 | $price = sys_unit_str2arr($row['que_unit_price']); |
145 | - upd_do_query("UPDATE {{planets}} SET " . |
|
146 | - "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," . |
|
147 | - "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," . |
|
148 | - "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) . |
|
145 | + upd_do_query("UPDATE {{planets}} SET ". |
|
146 | + "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",". |
|
147 | + "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",". |
|
148 | + "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0). |
|
149 | 149 | " WHERE id = {$planet_id}" |
150 | 150 | ); |
151 | 151 | upd_do_query("DELETE FROM {{que}} WHERE que_id = {$row['que_id']}"); |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | $query = upd_do_query("SELECT unit_id, unit_snid, unit_level, id_planet FROM {{unit}} AS un |
155 | 155 | LEFT JOIN {{users}} AS u ON u.id = un.unit_player_id |
156 | 156 | LEFT JOIN {{planets}} AS p ON p.id = u.id_planet |
157 | - WHERE unit_snid IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") |
|
157 | + WHERE unit_snid IN (" . TECH_EXPEDITION.",".TECH_COLONIZATION.") |
|
158 | 158 | FOR UPDATE"); |
159 | - while($row = db_fetch($query)) { |
|
160 | - if(!$row['id_planet']) { |
|
159 | + while ($row = db_fetch($query)) { |
|
160 | + if (!$row['id_planet']) { |
|
161 | 161 | continue; |
162 | 162 | } |
163 | 163 | |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | $unit_level = $row['unit_level']; |
166 | 166 | $price = get_unit_param($unit_id, P_COST); |
167 | 167 | $factor = $price['factor']; |
168 | - foreach($price as $resource_id => &$resource_amount) { |
|
168 | + foreach ($price as $resource_id => &$resource_amount) { |
|
169 | 169 | $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1); |
170 | 170 | } |
171 | 171 | // upd_do_query |
172 | - upd_do_query($q = "UPDATE {{planets}} SET " . |
|
173 | - "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," . |
|
174 | - "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," . |
|
175 | - "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) . |
|
172 | + upd_do_query($q = "UPDATE {{planets}} SET ". |
|
173 | + "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",". |
|
174 | + "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",". |
|
175 | + "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0). |
|
176 | 176 | " WHERE id = {$row['id_planet']}" |
177 | 177 | ); |
178 | 178 | upd_do_query("DELETE FROM {{unit}} WHERE unit_id = {$row['unit_id']}"); |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | // Вернуть ресы за уже исследованную Экспедиционную технологию |
185 | 185 | upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0); |
186 | 186 | |
187 | - if(!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
187 | + if (!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
188 | 188 | upd_alter_table('users', array( |
189 | 189 | "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
190 | 190 | "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
191 | 191 | ), !isset($update_tables['users']['player_rpg_explore_xp'])); |
192 | 192 | } |
193 | 193 | |
194 | - if(!$update_tables['log_users_online']) { |
|
194 | + if (!$update_tables['log_users_online']) { |
|
195 | 195 | upd_create_table('log_users_online', "( |
196 | 196 | `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time', |
197 | 197 | `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online', |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`", |
207 | 207 | ), !$update_tables['users']['user_time_measured']); |
208 | 208 | |
209 | - if($update_tables['rw']) { |
|
209 | + if ($update_tables['rw']) { |
|
210 | 210 | upd_do_query("DROP TABLE IF EXISTS {{rw}};"); |
211 | 211 | } |
212 | 212 | |
213 | - if(!$update_tables['player_award']) { |
|
213 | + if (!$update_tables['player_award']) { |
|
214 | 214 | upd_create_table('player_award', "( |
215 | 215 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
216 | 216 | `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc', |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | upd_log_version_update(); |
253 | 253 | |
254 | 254 | |
255 | - if(!isset($update_tables['planets']['que_processed'])) { |
|
255 | + if (!isset($update_tables['planets']['que_processed'])) { |
|
256 | 256 | upd_alter_table('planets', array( |
257 | 257 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`", |
258 | 258 | ), true); |
259 | 259 | upd_do_query("UPDATE {{planets}} SET que_processed = last_update;"); |
260 | 260 | } |
261 | 261 | |
262 | - if(!isset($update_tables['users']['que_processed'])) { |
|
262 | + if (!isset($update_tables['users']['que_processed'])) { |
|
263 | 263 | upd_alter_table('users', array( |
264 | 264 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`", |
265 | 265 | ), true); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | |
270 | - if(isset($update_tables['planets']['que'])) { |
|
270 | + if (isset($update_tables['planets']['que'])) { |
|
271 | 271 | $sn_data_aux = array( |
272 | 272 | SHIP_SMALL_FIGHTER_WRATH => array( |
273 | 273 | 'name' => 'ship_fighter_wrath', |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | $unit_data = array(); |
353 | 353 | $planets = array(); |
354 | 354 | |
355 | - foreach($planet_unit_list as $unit_id) { |
|
356 | - if(!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
355 | + foreach ($planet_unit_list as $unit_id) { |
|
356 | + if (!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
357 | 357 | $unit_name = $sn_data_aux[$unit_id][P_NAME]; |
358 | 358 | } |
359 | - if(isset($update_tables['planets'][$unit_name])) { |
|
359 | + if (isset($update_tables['planets'][$unit_name])) { |
|
360 | 360 | $drop[] = "DROP COLUMN `{$unit_name}`"; |
361 | 361 | |
362 | - if(isset($aux_group[$unit_id])) { |
|
362 | + if (isset($aux_group[$unit_id])) { |
|
363 | 363 | $units_info[$unit_id] = $sn_data_aux[$unit_id]; |
364 | 364 | $units_info[$unit_id]['que'] = QUE_HANGAR; |
365 | 365 | } else { |
366 | 366 | $units_info[$unit_id] = get_unit_param($unit_id); |
367 | - foreach($ques_info as $que_id => $que_data1) { |
|
368 | - if(in_array($unit_id, $que_data1['unit_list'])) { |
|
367 | + foreach ($ques_info as $que_id => $que_data1) { |
|
368 | + if (in_array($unit_id, $que_data1['unit_list'])) { |
|
369 | 369 | $units_info[$unit_id]['que'] = $que_id; |
370 | 370 | break; |
371 | 371 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE"); |
378 | - while($row = db_fetch($query)) { |
|
378 | + while ($row = db_fetch($query)) { |
|
379 | 379 | $user_id = $row['id_owner']; |
380 | 380 | $planet_id = $row['id']; |
381 | 381 | |
@@ -383,25 +383,25 @@ discard block |
||
383 | 383 | |
384 | 384 | // Конвертируем юниты |
385 | 385 | $units_levels = array(); |
386 | - foreach($planet_unit_list as $unit_id) { |
|
386 | + foreach ($planet_unit_list as $unit_id) { |
|
387 | 387 | $unit_name = &$units_info[$unit_id][P_NAME]; |
388 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
388 | + if (!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
389 | 389 | continue; |
390 | 390 | } |
391 | 391 | $units_levels[$unit_id] = $row[$unit_name]; |
392 | - $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
|
393 | - if(count($unit_data) > 30) { |
|
392 | + $unit_data[] = "({$user_id},".LOC_PLANET.",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
|
393 | + if (count($unit_data) > 30) { |
|
394 | 394 | $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max; |
395 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
395 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES '.implode(',', $unit_data).';'); |
|
396 | 396 | $unit_data = array(); |
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
400 | 400 | // Конвертируем очередь построек |
401 | - if($row['que']) { |
|
401 | + if ($row['que']) { |
|
402 | 402 | $que = explode(';', $row['que']); |
403 | - foreach($que as $que_item) { |
|
404 | - if(!$que_item) { |
|
403 | + foreach ($que as $que_item) { |
|
404 | + if (!$que_item) { |
|
405 | 405 | continue; |
406 | 406 | } |
407 | 407 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1; |
417 | 417 | $price_increase = pow($unit_factor, $unit_level); |
418 | 418 | // $unit_time = 0; |
419 | - foreach($unit_cost as $resource_id => &$resource_amount) { |
|
420 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
419 | + foreach ($unit_cost as $resource_id => &$resource_amount) { |
|
420 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
421 | 421 | unset($unit_cost[$resource_id]); |
422 | 422 | continue; |
423 | 423 | } |
@@ -431,39 +431,39 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | // Конвертируем очередь верфи |
434 | - if($row['b_hangar_id']) { |
|
434 | + if ($row['b_hangar_id']) { |
|
435 | 435 | $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,); |
436 | 436 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
437 | - foreach($hangar_units as $unit_id => $unit_count) { |
|
438 | - if($unit_count <= 0) { |
|
437 | + foreach ($hangar_units as $unit_id => $unit_count) { |
|
438 | + if ($unit_count <= 0) { |
|
439 | 439 | continue; |
440 | 440 | } |
441 | - foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
442 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
441 | + foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
442 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
443 | 443 | continue; |
444 | 444 | } |
445 | 445 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
446 | 446 | } |
447 | 447 | } |
448 | - if(array_sum($return_resources) > 0) { |
|
448 | + if (array_sum($return_resources) > 0) { |
|
449 | 449 | upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1"); |
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
453 | 453 | |
454 | - if(count($que_data) > 10) { |
|
454 | + if (count($que_data) > 10) { |
|
455 | 455 | $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max; |
456 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
456 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES '.implode(',', $que_data).';'); |
|
457 | 457 | $que_data = array(); |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | - if(!empty($unit_data)) { |
|
462 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
461 | + if (!empty($unit_data)) { |
|
462 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES '.implode(',', $unit_data).';'); |
|
463 | 463 | } |
464 | 464 | |
465 | - if(!empty($que_data)) { |
|
466 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
465 | + if (!empty($que_data)) { |
|
466 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES '.implode(',', $que_data).';'); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | upd_alter_table('planets', $drop, true); |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = '' |
474 | 474 | SET u.`username` = CONCAT('[', a.`ally_tag`, ']');"); |
475 | 475 | |
476 | - if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
476 | + if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
477 | 477 | upd_do_query("SET FOREIGN_KEY_CHECKS=0;"); |
478 | 478 | upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']); |
479 | 479 | upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{security_browser}}` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE", |
570 | 570 | ), !isset($update_tables['users']['user_last_proxy'])); |
571 | 571 | |
572 | - if(!isset($update_tables['notes']['planet_type'])) { |
|
572 | + if (!isset($update_tables['notes']['planet_type'])) { |
|
573 | 573 | upd_alter_table('notes', array( |
574 | 574 | "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`", |
575 | 575 | "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`", |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot'])); |
588 | 588 | upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']); |
589 | 589 | |
590 | - if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
590 | + if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
591 | 591 | upd_alter_table('users', array( |
592 | 592 | "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'", |
593 | 593 | ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint'); |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;"); |
596 | 596 | } |
597 | 597 | |
598 | - if(!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
598 | + if (!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
599 | 599 | upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated'])); |
600 | 600 | upd_alter_table('log_users_online', array( |
601 | 601 | "DROP PRIMARY KEY", |
@@ -603,13 +603,13 @@ discard block |
||
603 | 603 | ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,'); |
604 | 604 | } |
605 | 605 | |
606 | - if(!isset($update_tables['users']['gender'])) { |
|
607 | - upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
|
608 | - upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
606 | + if (!isset($update_tables['users']['gender'])) { |
|
607 | + upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT ".GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
|
608 | + upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', ".GENDER_FEMALE.", IF(UPPER(`sex`) = 'M', ".GENDER_MALE.", ".GENDER_UNKNOWN."));"); |
|
609 | 609 | } |
610 | 610 | upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex'])); |
611 | 611 | |
612 | - if(!$update_tables['users']['dark_matter_total']) { |
|
612 | + if (!$update_tables['users']['dark_matter_total']) { |
|
613 | 613 | upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']); |
614 | 614 | upd_do_query( |
615 | 615 | "UPDATE `{{users}}` AS u |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | } |
623 | 623 | |
624 | 624 | upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal)); |
625 | - if(!$update_tables['users']['metamatter_total']) { |
|
625 | + if (!$update_tables['users']['metamatter_total']) { |
|
626 | 626 | upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']); |
627 | 627 | |
628 | 628 | upd_do_query( |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0) |
635 | 635 | );"); |
636 | 636 | } |
637 | - if(!isset($update_tables['users']['immortal'])) { |
|
637 | + if (!isset($update_tables['users']['immortal'])) { |
|
638 | 638 | upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal'])); |
639 | 639 | upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;"); |
640 | 640 | } |
641 | - if(isset($update_tables['player_award'])) { |
|
641 | + if (isset($update_tables['player_award'])) { |
|
642 | 642 | upd_do_query( |
643 | 643 | "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id |
644 | 644 | SET metamatter_total = 1, immortal = NOW() |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
666 | 666 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); |
667 | 667 | |
668 | - if(empty($update_tables['blitz_statpoints'])) { |
|
668 | + if (empty($update_tables['blitz_statpoints'])) { |
|
669 | 669 | upd_create_table('blitz_statpoints', " ( |
670 | 670 | `stat_date` int(11) NOT NULL DEFAULT '0', |
671 | 671 | `id_owner` bigint(20) unsigned DEFAULT NULL, |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE |
734 | 734 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
735 | 735 | |
736 | - if(empty($update_tables['security_url'])) { |
|
736 | + if (empty($update_tables['security_url'])) { |
|
737 | 737 | upd_create_table('security_url', " ( |
738 | 738 | `url_id` int unsigned NOT NULL AUTO_INCREMENT, |
739 | 739 | `url_string` VARCHAR(250) NOT NULL DEFAULT '', |
@@ -746,17 +746,17 @@ discard block |
||
746 | 746 | |
747 | 747 | $strings = array(); |
748 | 748 | $query = doquery($query); |
749 | - while($row = db_fetch($query)) { |
|
750 | - $strings[] = '("' . db_escape($row['url']) . '")'; |
|
751 | - if(count($strings) > 100) { |
|
752 | - doquery($query_string . implode(',', $strings)); |
|
749 | + while ($row = db_fetch($query)) { |
|
750 | + $strings[] = '("'.db_escape($row['url']).'")'; |
|
751 | + if (count($strings) > 100) { |
|
752 | + doquery($query_string.implode(',', $strings)); |
|
753 | 753 | $strings = array(); |
754 | 754 | } |
755 | 755 | } |
756 | - !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
|
756 | + !empty($strings) ? doquery($query_string.implode(',', $strings)) : false; |
|
757 | 757 | } |
758 | 758 | |
759 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
759 | + if (isset($update_tables['counter']['page'])) // TODO REMOVE |
|
760 | 760 | { |
761 | 761 | update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}"); |
762 | 762 | update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}"); |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
782 | 782 | "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
783 | 783 | ), !isset($update_tables['counter']['device_id'])); |
784 | - if(isset($update_tables['counter']['ip'])) { |
|
784 | + if (isset($update_tables['counter']['ip'])) { |
|
785 | 785 | // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)'); |
786 | 786 | upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)'); |
787 | 787 | upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id'); |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | |
833 | 833 | upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days); |
834 | 834 | |
835 | - if(classSupernova::$config->payment_currency_default != 'USD') { |
|
835 | + if (classSupernova::$config->payment_currency_default != 'USD') { |
|
836 | 836 | upd_check_key('payment_currency_default', 'USD', true); |
837 | 837 | upd_check_key('payment_currency_exchange_dm_', 20000, true); |
838 | 838 | upd_check_key('payment_currency_exchange_mm_', 20000, true); |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | |
890 | 890 | $virtual_exploded = explode('/', SN_ROOT_VIRTUAL_PARENT); |
891 | 891 | // TODO - переделать всё на db_loadItem... НАВЕРНОЕ |
892 | - upd_check_key('server_email', 'root@' . $virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email')); |
|
892 | + upd_check_key('server_email', 'root@'.$virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email')); |
|
893 | 893 | |
894 | 894 | upd_alter_table('survey_votes', array( |
895 | 895 | "DROP FOREIGN KEY `FK_survey_votes_user`", |
@@ -915,12 +915,12 @@ discard block |
||
915 | 915 | function propagade_player_options($old_option_name, $new_option_id) { |
916 | 916 | global $update_tables; |
917 | 917 | |
918 | - if(!empty($update_tables['users'][$old_option_name])) { |
|
918 | + if (!empty($update_tables['users'][$old_option_name])) { |
|
919 | 919 | upd_do_query( |
920 | 920 | "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) |
921 | 921 | SELECT `id`, {$new_option_id}, `{$old_option_name}` |
922 | 922 | FROM {{users}} |
923 | - WHERE `user_as_ally` is null and `user_bot` = " . USER_BOT_PLAYER); |
|
923 | + WHERE `user_as_ally` is null and `user_bot` = ".USER_BOT_PLAYER); |
|
924 | 924 | // TODO - UNCOMMENT !!! |
925 | 925 | upd_alter_table('users', array("DROP COLUMN `{$old_option_name}`",)); |
926 | 926 | } |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | |
950 | 950 | |
951 | 951 | // 2015-08-03 15:05:26 40a6.0 |
952 | - if(empty($update_tables['planets']['position_original'])) { |
|
952 | + if (empty($update_tables['planets']['position_original'])) { |
|
953 | 953 | upd_alter_table('planets', array( |
954 | 954 | "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0", |
955 | 955 | "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0", |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | upd_do_query('UPDATE {{planets}} SET `position_original` = `planet`, `field_max_original` = `field_max`, `temp_min_original` = `temp_min`, `temp_max_original` = `temp_max`;'); |
965 | 965 | |
966 | 966 | // Миграция тяжмета в оливин |
967 | - upd_do_query('UPDATE {{planets}} SET `density_index` = ' . PLANET_DENSITY_METAL_PERIDOT . ' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7); |
|
967 | + upd_do_query('UPDATE {{planets}} SET `density_index` = '.PLANET_DENSITY_METAL_PERIDOT.' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7); |
|
968 | 968 | |
969 | 969 | // Добавляем планету-странника |
970 | 970 | upd_check_key('game_maxPlanet', 16, Vector::$knownPlanets == 15); |
@@ -977,12 +977,12 @@ discard block |
||
977 | 977 | |
978 | 978 | // 2015-08-27 19:14:05 40a10.0 |
979 | 979 | // Старая версия таблицы |
980 | - if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
980 | + if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
981 | 981 | upd_drop_table('account'); |
982 | 982 | upd_drop_table('account_translate'); |
983 | 983 | } |
984 | 984 | |
985 | - if(empty($update_tables['account'])) { |
|
985 | + if (empty($update_tables['account'])) { |
|
986 | 986 | upd_create_table('account', " ( |
987 | 987 | `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
988 | 988 | `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
1002 | 1002 | |
1003 | 1003 | upd_create_table('account_translate', " ( |
1004 | - `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider', |
|
1004 | + `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider', |
|
1005 | 1005 | `provider_account_id` bigint(20) unsigned NOT NULL COMMENT 'Account ID on provider', |
1006 | 1006 | `user_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
1007 | 1007 | `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, |
@@ -1016,12 +1016,12 @@ discard block |
||
1016 | 1016 | (`account_id`, `account_name`, `account_password`, `account_salt`, `account_email`, `account_register_time`, `account_language`, `account_metamatter`, `account_metamatter_total`, `account_immortal`) |
1017 | 1017 | SELECT |
1018 | 1018 | `id`, `username`, `password`, `salt`, `email_2`, FROM_UNIXTIME(register_time), `lang`, `metamatter`, `metamatter_total`, `immortal` |
1019 | - FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER . ";" |
|
1019 | + FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER.";" |
|
1020 | 1020 | ); |
1021 | 1021 | |
1022 | 1022 | upd_do_query( |
1023 | 1023 | "REPLACE INTO {{account_translate}} (`provider_id`, `provider_account_id`, `user_id`, `timestamp`) |
1024 | - SELECT " . ACCOUNT_PROVIDER_LOCAL . ", a.account_id, u.id, a.`account_register_time` |
|
1024 | + SELECT " . ACCOUNT_PROVIDER_LOCAL.", a.account_id, u.id, a.`account_register_time` |
|
1025 | 1025 | FROM {{users}} AS u |
1026 | 1026 | JOIN {{account}} AS a ON |
1027 | 1027 | a.account_name = u.username |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | |
1038 | 1038 | // 2015-09-05 17:07:15 40a10.17 |
1039 | - upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT " . UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result'])); |
|
1039 | + upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT ".UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result'])); |
|
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | // 2015-09-07 21:11:48 40a10.19 |
@@ -1044,18 +1044,18 @@ discard block |
||
1044 | 1044 | |
1045 | 1045 | |
1046 | 1046 | // 2015-09-24 11:39:37 40a10.25 |
1047 | - if(empty($update_tables['log_metamatter']['provider_id'])) { |
|
1047 | + if (empty($update_tables['log_metamatter']['provider_id'])) { |
|
1048 | 1048 | upd_alter_table('log_metamatter', array( |
1049 | - "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'", |
|
1049 | + "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider'", |
|
1050 | 1050 | "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0", |
1051 | 1051 | "ADD COLUMN `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''", |
1052 | - "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '" . SN_ROOT_VIRTUAL . "'", |
|
1052 | + "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '".SN_ROOT_VIRTUAL."'", |
|
1053 | 1053 | ), empty($update_tables['log_metamatter']['provider_id'])); |
1054 | 1054 | |
1055 | 1055 | upd_do_query("UPDATE {{log_metamatter}} SET `account_id` = `user_id`, `account_name` = `username`"); |
1056 | 1056 | |
1057 | 1057 | upd_alter_table('payment', array( |
1058 | - "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Payment account provider'", |
|
1058 | + "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Payment account provider'", |
|
1059 | 1059 | "ADD COLUMN `payment_account_id` bigint(20) unsigned NOT NULL", |
1060 | 1060 | "ADD COLUMN `payment_account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''", |
1061 | 1061 | ), !$update_tables['payment']['payment_account_id']); |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code)); |
1097 | 1097 | upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp)); |
1098 | 1098 | upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used)); |
1099 | - if(empty($update_tables['log_halloween_2015'])) { |
|
1099 | + if (empty($update_tables['log_halloween_2015'])) { |
|
1100 | 1100 | upd_create_table('log_halloween_2015', " ( |
1101 | 1101 | `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1102 | 1102 | `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | |
1113 | 1113 | // 2015-11-28 06:30:27 40a19.21 |
1114 | - if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1114 | + if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1115 | 1115 | upd_alter_table('ube_report', array( |
1116 | 1116 | "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", |
1117 | 1117 | "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | |
1128 | 1128 | // 2015-12-06 15:10:58 40b1.0 |
1129 | - if(!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1129 | + if (!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1130 | 1130 | upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']); |
1131 | 1131 | upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']); |
1132 | 1132 | upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']); |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | case 40: |
1190 | 1190 | upd_log_version_update(); |
1191 | 1191 | |
1192 | - if(empty($update_tables['festival'])) { |
|
1192 | + if (empty($update_tables['festival'])) { |
|
1193 | 1193 | upd_create_table('festival', " ( |
1194 | 1194 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
1195 | 1195 | `start` datetime NOT NULL COMMENT 'Festival start datetime', |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | ); |
1231 | 1231 | } |
1232 | 1232 | |
1233 | - if(empty($update_tables['festival_unit'])) { |
|
1233 | + if (empty($update_tables['festival_unit'])) { |
|
1234 | 1234 | upd_create_table('festival_unit', " ( |
1235 | 1235 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1236 | 1236 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | // 2015-12-21 06:06:09 41a0.12 |
1250 | - if(empty($update_tables['festival_unit_log'])) { |
|
1250 | + if (empty($update_tables['festival_unit_log'])) { |
|
1251 | 1251 | upd_create_table('festival_unit_log', " ( |
1252 | 1252 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1253 | 1253 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1277,19 +1277,19 @@ discard block |
||
1277 | 1277 | $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin' |
1278 | 1278 | ); |
1279 | 1279 | |
1280 | - if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1280 | + if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1281 | 1281 | upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true); |
1282 | 1282 | upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true); |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - if(!empty($update_tables['fleets']['fleet_array'])) { |
|
1285 | + if (!empty($update_tables['fleets']['fleet_array'])) { |
|
1286 | 1286 | $query = upd_do_query("SELECT * FROM {{fleets}}"); |
1287 | - while($row = db_fetch($query)) { |
|
1287 | + while ($row = db_fetch($query)) { |
|
1288 | 1288 | $unit_list = sys_unit_str2arr($row['fleet_array']); |
1289 | - foreach($unit_list as $unit_id => $unit_count) { |
|
1289 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
1290 | 1290 | upd_do_query( |
1291 | 1291 | "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES |
1292 | - ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, " . get_unit_param($unit_id, P_UNIT_TYPE) . ", {$unit_id}, {$unit_count});", |
|
1292 | + ({$row['fleet_owner']}, ".LOC_FLEET.", {$row['fleet_id']}, ".get_unit_param($unit_id, P_UNIT_TYPE).", {$unit_id}, {$unit_count});", |
|
1293 | 1293 | true |
1294 | 1294 | ); |
1295 | 1295 | } |
@@ -1322,11 +1322,11 @@ discard block |
||
1322 | 1322 | |
1323 | 1323 | classSupernova::$cache->unset_by_prefix('lng_'); |
1324 | 1324 | |
1325 | -if($new_version) { |
|
1325 | +if ($new_version) { |
|
1326 | 1326 | classSupernova::$config->db_saveItem('db_version', $new_version); |
1327 | 1327 | upd_log_message("<font color=green>DB version is now {$new_version}</font>"); |
1328 | 1328 | } else { |
1329 | - upd_log_message("DB version didn't changed from " . classSupernova::$config->db_version); |
|
1329 | + upd_log_message("DB version didn't changed from ".classSupernova::$config->db_version); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | classSupernova::$config->db_loadAll(); |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | |
31 | 31 | defined('INSIDE') || die(); |
32 | 32 | |
33 | -if(php_sapi_name() == "cli") { |
|
33 | +if (php_sapi_name() == "cli") { |
|
34 | 34 | // In cli-mode |
35 | 35 | define('__DEBUG_CRLF', "\r\n"); |
36 | - define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF); |
|
36 | + define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF); |
|
37 | 37 | } else { |
38 | 38 | // Not in cli-mode |
39 | 39 | define('__DEBUG_CRLF', '<br />'); |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | function log_file($message, $ident_change = 0) { |
51 | 51 | static $ident = 0; |
52 | 52 | |
53 | - if(!defined('SN_DEBUG_LOG')) { |
|
53 | + if (!defined('SN_DEBUG_LOG')) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if($this->log_file_handler === null) { |
|
58 | - $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
|
57 | + if ($this->log_file_handler === null) { |
|
58 | + $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+'); |
|
59 | 59 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
60 | 60 | } |
61 | 61 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
62 | - if($this->log_file_handler) { |
|
63 | - @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
|
62 | + if ($this->log_file_handler) { |
|
63 | + @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n"); |
|
64 | 64 | } |
65 | 65 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
66 | 66 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | function echo_log() { |
83 | - echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
83 | + echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
84 | 84 | die(); |
85 | 85 | } |
86 | 86 | |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | $result = array(); |
91 | 91 | $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++; |
92 | 92 | $result[] = "tID {$transaction_id}"; |
93 | - foreach($backtrace as $a_trace) { |
|
94 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
93 | + foreach ($backtrace as $a_trace) { |
|
94 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | $function = |
98 | 98 | ($a_trace['type'] |
99 | 99 | ? ($a_trace['type'] == '->' |
100 | - ? "({$a_trace['class']})" . get_class($a_trace['object']) |
|
100 | + ? "({$a_trace['class']})".get_class($a_trace['object']) |
|
101 | 101 | : $a_trace['class'] |
102 | - ) . $a_trace['type'] |
|
102 | + ).$a_trace['type'] |
|
103 | 103 | : '' |
104 | - ) . $a_trace['function'] . '()'; |
|
104 | + ).$a_trace['function'].'()'; |
|
105 | 105 | |
106 | 106 | $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file'])); |
107 | 107 | |
108 | 108 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
109 | 109 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
110 | 110 | |
111 | - if(!$long_comment) { |
|
111 | + if (!$long_comment) { |
|
112 | 112 | break; |
113 | 113 | } |
114 | 114 | } |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | function dump($dump = false, $force_base = false, $deadlock = false) { |
123 | 123 | global $user, $planetrow; |
124 | 124 | |
125 | - if($dump === false) { |
|
125 | + if ($dump === false) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $error_backtrace = array(); |
130 | 130 | $base_dump = false; |
131 | 131 | |
132 | - if($force_base === true) { |
|
132 | + if ($force_base === true) { |
|
133 | 133 | $base_dump = true; |
134 | 134 | } |
135 | 135 | |
136 | - if($dump === true) { |
|
136 | + if ($dump === true) { |
|
137 | 137 | $base_dump = true; |
138 | 138 | } else { |
139 | - if(!is_array($dump)) { |
|
139 | + if (!is_array($dump)) { |
|
140 | 140 | $dump = array('var' => $dump); |
141 | 141 | } |
142 | 142 | |
143 | - foreach($dump as $dump_var_name => $dump_var) { |
|
144 | - if($dump_var_name == 'base_dump') { |
|
143 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
144 | + if ($dump_var_name == 'base_dump') { |
|
145 | 145 | $base_dump = $dump_var; |
146 | 146 | } else { |
147 | 147 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -149,22 +149,21 @@ discard block |
||
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
152 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
153 | 153 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
154 | 154 | $error_backtrace['locks'] = classSupernova::$locks; |
155 | 155 | $error_backtrace['cSN_data'] = classSupernova::$data; |
156 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
157 | - foreach($location as $location_id => &$location_data) { |
|
158 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
159 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
156 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
157 | + foreach ($location as $location_id => &$location_data) { |
|
158 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
160 | 159 | } |
161 | 160 | } |
162 | 161 | $error_backtrace['cSN_queries'] = classSupernova::$queries; |
163 | 162 | } |
164 | 163 | |
165 | - if($base_dump) { |
|
166 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
167 | - foreach($this->log_array as $log) { |
|
164 | + if ($base_dump) { |
|
165 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
166 | + foreach ($this->log_array as $log) { |
|
168 | 167 | $error_backtrace['queries'][] = $log; |
169 | 168 | } |
170 | 169 | } |
@@ -193,14 +192,14 @@ discard block |
||
193 | 192 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
194 | 193 | global $sys_stop_log_hit, $sys_log_disabled, $user; |
195 | 194 | |
196 | - if(empty(classSupernova::$db->connected)) { |
|
195 | + if (empty(classSupernova::$db->connected)) { |
|
197 | 196 | // TODO - писать ошибку в файл |
198 | 197 | die('SQL server currently unavailable. Please contact Administration...'); |
199 | 198 | } |
200 | 199 | |
201 | 200 | sn_db_transaction_rollback(); |
202 | 201 | |
203 | - if(classSupernova::$config->debug == 1) { |
|
202 | + if (classSupernova::$config->debug == 1) { |
|
204 | 203 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
205 | 204 | echo "<table>{$this->log}</table>"; |
206 | 205 | } |
@@ -210,15 +209,15 @@ discard block |
||
210 | 209 | $error_text = db_escape($message); |
211 | 210 | $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false); |
212 | 211 | |
213 | - if(!$sys_log_disabled) { |
|
212 | + if (!$sys_log_disabled) { |
|
214 | 213 | $query = "INSERT INTO `{{logs}}` SET |
215 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($user['id']) . "', |
|
216 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
217 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
218 | - ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";"; |
|
219 | - doquery($query, '', false, true) or die($fatal_error . db_error()); |
|
214 | + `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($user['id'])."', |
|
215 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
216 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
217 | + ($error_backtrace ? ", `log_dump` = '".db_escape(serialize($error_backtrace))."'" : '').";"; |
|
218 | + doquery($query, '', false, true) or die($fatal_error.db_error()); |
|
220 | 219 | |
221 | - $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . db_insert_id() . "</b>"; |
|
220 | + $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".db_insert_id()."</b>"; |
|
222 | 221 | |
223 | 222 | $sys_stop_log_hit = true; |
224 | 223 | $sys_log_disabled = true; |
@@ -228,7 +227,7 @@ discard block |
||
228 | 227 | ob_start(); |
229 | 228 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
230 | 229 | |
231 | - foreach($error_backtrace as $name => $value) { |
|
230 | + foreach ($error_backtrace as $name => $value) { |
|
232 | 231 | print(__DEBUG_LINE); |
233 | 232 | pdump($value, $name); |
234 | 233 | } |
@@ -240,19 +239,19 @@ discard block |
||
240 | 239 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
241 | 240 | global $user, $sys_log_disabled; |
242 | 241 | |
243 | - if(empty(classSupernova::$db->connected)) { |
|
242 | + if (empty(classSupernova::$db->connected)) { |
|
244 | 243 | // TODO - писать ошибку в файл |
245 | 244 | die('SQL server currently unavailable. Please contact Administration...'); |
246 | 245 | } |
247 | 246 | |
248 | 247 | $error_backtrace = $this->dump($dump, false); |
249 | 248 | |
250 | - if(!$sys_log_disabled) { |
|
249 | + if (!$sys_log_disabled) { |
|
251 | 250 | $query = "INSERT INTO `{{logs}}` SET |
252 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($user['id']) . "', |
|
253 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
254 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
255 | - ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";"; |
|
251 | + `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($user['id'])."', |
|
252 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
253 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
254 | + ($error_backtrace ? ", `log_dump` = '".db_escape(serialize($error_backtrace))."'" : '').";"; |
|
256 | 255 | doquery($query, '', false, true); |
257 | 256 | } else { |
258 | 257 | // // TODO Здесь надо писать в файло |
@@ -265,11 +264,11 @@ discard block |
||
265 | 264 | // Dump variables nicer then var_dump() |
266 | 265 | |
267 | 266 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
268 | - if(isset($varname)) { |
|
267 | + if (isset($varname)) { |
|
269 | 268 | $varname .= " = "; |
270 | 269 | } |
271 | 270 | |
272 | - if($level == -1) { |
|
271 | + if ($level == -1) { |
|
273 | 272 | $trans[' '] = '∴'; |
274 | 273 | $trans["\t"] = '⇒'; |
275 | 274 | $trans["\n"] = '¶;'; |
@@ -278,31 +277,31 @@ discard block |
||
278 | 277 | |
279 | 278 | return strtr(htmlspecialchars($value), $trans); |
280 | 279 | } |
281 | - if($level == 0) { |
|
280 | + if ($level == 0) { |
|
282 | 281 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
283 | - $dumper = mt_rand(10, 99) . '|' . $varname; |
|
282 | + $dumper = mt_rand(10, 99).'|'.$varname; |
|
284 | 283 | } |
285 | 284 | |
286 | 285 | $type = gettype($value); |
287 | 286 | $dumper .= $type; |
288 | 287 | |
289 | - if($type == 'string') { |
|
290 | - $dumper .= '(' . strlen($value) . ')'; |
|
288 | + if ($type == 'string') { |
|
289 | + $dumper .= '('.strlen($value).')'; |
|
291 | 290 | $value = dump($value, '', -1); |
292 | - } elseif($type == 'boolean') { |
|
291 | + } elseif ($type == 'boolean') { |
|
293 | 292 | $value = ($value ? 'true' : 'false'); |
294 | - } elseif($type == 'object') { |
|
293 | + } elseif ($type == 'object') { |
|
295 | 294 | $props = get_class_vars(get_class($value)); |
296 | - $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
297 | - foreach($props as $key => $val) { |
|
298 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
295 | + $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
296 | + foreach ($props as $key => $val) { |
|
297 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
299 | 298 | $dumper .= dump($value->$key, '', $level + 1); |
300 | 299 | } |
301 | 300 | $value = ''; |
302 | - } elseif($type == 'array') { |
|
303 | - $dumper .= '(' . count($value) . ')'; |
|
304 | - foreach($value as $key => $val) { |
|
305 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
|
301 | + } elseif ($type == 'array') { |
|
302 | + $dumper .= '('.count($value).')'; |
|
303 | + foreach ($value as $key => $val) { |
|
304 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => '; |
|
306 | 305 | $dumper .= dump($val, '', $level + 1); |
307 | 306 | } |
308 | 307 | $value = ''; |
@@ -321,24 +320,24 @@ discard block |
||
321 | 320 | // $backtrace = $backtrace[1]; |
322 | 321 | |
323 | 322 | $caller = ''; |
324 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
325 | - $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
|
326 | - (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
|
327 | - $backtrace[1]['function'] . |
|
323 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
324 | + $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : ''). |
|
325 | + (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : ''). |
|
326 | + $backtrace[1]['function']. |
|
328 | 327 | (!empty($backtrace[0]['file']) |
329 | 328 | ? ( |
330 | - ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) . |
|
331 | - (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') . |
|
329 | + ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN). |
|
330 | + (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : ''). |
|
332 | 331 | ')' |
333 | 332 | ) |
334 | 333 | : '' |
335 | 334 | ); |
336 | - $caller = "\r\n" . $caller; |
|
335 | + $caller = "\r\n".$caller; |
|
337 | 336 | } |
338 | 337 | |
339 | - print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' . |
|
340 | - dump($value, $varname) . |
|
341 | - $caller . |
|
338 | + print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'. |
|
339 | + dump($value, $varname). |
|
340 | + $caller. |
|
342 | 341 | '</pre>' |
343 | 342 | ); |
344 | 343 | } |
@@ -348,24 +347,24 @@ discard block |
||
348 | 347 | } |
349 | 348 | |
350 | 349 | function pr($prePrint = false) { |
351 | - if($prePrint) { |
|
350 | + if ($prePrint) { |
|
352 | 351 | print(__DEBUG_CRLF); |
353 | 352 | } |
354 | - print(mt_rand() . __DEBUG_CRLF); |
|
353 | + print(mt_rand().__DEBUG_CRLF); |
|
355 | 354 | } |
356 | 355 | |
357 | 356 | function pc($prePrint = false) { |
358 | 357 | global $_PRINT_COUNT_VALUE; |
359 | 358 | $_PRINT_COUNT_VALUE++; |
360 | 359 | |
361 | - if($prePrint) { |
|
360 | + if ($prePrint) { |
|
362 | 361 | print(__DEBUG_CRLF); |
363 | 362 | } |
364 | - print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
|
363 | + print($_PRINT_COUNT_VALUE.__DEBUG_CRLF); |
|
365 | 364 | } |
366 | 365 | |
367 | 366 | function prep($message) { |
368 | - print('<pre>' . $message . '</pre>'); |
|
367 | + print('<pre>'.$message.'</pre>'); |
|
369 | 368 | } |
370 | 369 | |
371 | 370 | function backtrace_no_arg() { |
@@ -388,5 +387,5 @@ discard block |
||
388 | 387 | */ |
389 | 388 | function pdie($message = '') { |
390 | 389 | $backtrace = debug_backtrace(); |
391 | - die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']); |
|
390 | + die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']); |
|
392 | 391 | } |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | |
15 | 15 | $no_data = array('user' => false, 'planet' => false, 'que' => false); |
16 | 16 | |
17 | - if(!$planet) { |
|
17 | + if (!$planet) { |
|
18 | 18 | return $no_data; |
19 | 19 | } |
20 | 20 | |
21 | - if(!$no_user_update) { |
|
21 | + if (!$no_user_update) { |
|
22 | 22 | $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user); |
23 | - if(!$user) { |
|
23 | + if (!$user) { |
|
24 | 24 | // TODO - Убрать позже |
25 | 25 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>'); |
26 | 26 | $backtrace = debug_backtrace(); |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | $user = db_user_by_id($user, !$simulation, '*', true); |
33 | 33 | } |
34 | 34 | |
35 | - if(empty($user['id'])) { |
|
35 | + if (empty($user['id'])) { |
|
36 | 36 | return $no_data; |
37 | 37 | } |
38 | 38 | |
39 | - if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
39 | + if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
40 | 40 | $planet = db_planet_by_vector($planet, '', !$simulation); |
41 | 41 | } else { |
42 | 42 | $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet); |
43 | 43 | $planet = db_planet_by_id($planet, !$simulation); |
44 | 44 | } |
45 | - if(!is_array($planet) || !isset($planet['id'])) { |
|
45 | + if (!is_array($planet) || !isset($planet['id'])) { |
|
46 | 46 | return $no_data; |
47 | 47 | } |
48 | 48 | |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | RES_DEUTERIUM => 0, |
66 | 66 | ); |
67 | 67 | |
68 | - switch($planet['planet_type']) { |
|
68 | + switch ($planet['planet_type']) { |
|
69 | 69 | case PT_PLANET: |
70 | - foreach($resources_increase as $resource_id => &$increment) { |
|
70 | + foreach ($resources_increase as $resource_id => &$increment) { |
|
71 | 71 | $resource_name = pname_resource_name($resource_id); |
72 | 72 | $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600; |
73 | 73 | $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name]; |
74 | 74 | $increment = min($increment, max(0, $store_free)); |
75 | 75 | |
76 | - if($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
76 | + if ($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
77 | 77 | classSupernova::$debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501); |
78 | 78 | } |
79 | 79 | $planet[$resource_name] += $increment; |
80 | - $planet[$resource_name . '_perhour'] = $caps_real['total'][$resource_id]; |
|
80 | + $planet[$resource_name.'_perhour'] = $caps_real['total'][$resource_id]; |
|
81 | 81 | } |
82 | 82 | break; |
83 | 83 | |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора |
95 | 95 | $planet['field_current'] = 0; |
96 | 96 | $sn_group_build_allow = sn_get_groups('build_allow'); |
97 | - if(is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
98 | - foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
97 | + if (is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
98 | + foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
99 | 99 | $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true); |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - if($simulation) { |
|
103 | + if ($simulation) { |
|
104 | 104 | return array('user' => $user, 'planet' => $planet, 'que' => $que); |
105 | 105 | } |
106 | 106 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | function sys_user_vacation($user) { |
10 | - if(sys_get_param_str('vacation') == 'leave') { |
|
10 | + if (sys_get_param_str('vacation') == 'leave') { |
|
11 | 11 | if ($user['vacation'] < SN_TIME_NOW) { |
12 | 12 | $user['vacation'] = 0; |
13 | 13 | $user['vacation_next'] = SN_TIME_NOW + classSupernova::$config->player_vacation_timeout; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | } |
16 | 16 | } |
17 | 17 | |
18 | - if($user['vacation']) { |
|
18 | + if ($user['vacation']) { |
|
19 | 19 | // sn_sys_logout(false, true); |
20 | 20 | // core_auth::logout(false, true); |
21 | 21 | |
@@ -45,33 +45,33 @@ discard block |
||
45 | 45 | // TODO: Full rewrite |
46 | 46 | sn_db_transaction_start(); |
47 | 47 | $TheUser = db_user_by_id($UserID); |
48 | - if ( $TheUser['ally_id'] != 0 ) { |
|
49 | - $TheAlly = doquery ( "SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true ); |
|
48 | + if ($TheUser['ally_id'] != 0) { |
|
49 | + $TheAlly = doquery("SELECT * FROM `{{alliance}}` WHERE `id` = '".$TheUser['ally_id']."';", '', true); |
|
50 | 50 | $TheAlly['ally_members'] -= 1; |
51 | - if ( $TheAlly['ally_members'] > 0 ) { |
|
52 | - doquery ( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
51 | + if ($TheAlly['ally_members'] > 0) { |
|
52 | + doquery("UPDATE `{{alliance}}` SET `ally_members` = '".$TheAlly['ally_members']."' WHERE `id` = '".$TheAlly['id']."';"); |
|
53 | 53 | } else { |
54 | - doquery ( "DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
55 | - doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); |
|
54 | + doquery("DELETE FROM `{{alliance}}` WHERE `id` = '".$TheAlly['id']."';"); |
|
55 | + doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '".$TheAlly['id']."';"); |
|
56 | 56 | } |
57 | 57 | } |
58 | - doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); |
|
58 | + doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '".$UserID."';"); |
|
59 | 59 | |
60 | 60 | db_planet_list_delete_by_owner($UserID); |
61 | 61 | |
62 | - doquery ( "DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); |
|
63 | - doquery ( "DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); |
|
64 | - doquery ( "DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); |
|
62 | + doquery("DELETE FROM `{{messages}}` WHERE `message_sender` = '".$UserID."';"); |
|
63 | + doquery("DELETE FROM `{{messages}}` WHERE `message_owner` = '".$UserID."';"); |
|
64 | + doquery("DELETE FROM `{{notes}}` WHERE `owner` = '".$UserID."';"); |
|
65 | 65 | FleetList::db_fleet_list_delete_by_owner($UserID); |
66 | 66 | // doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner1` = '" . $UserID . "';"); |
67 | 67 | // doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner2` = '" . $UserID . "';"); |
68 | - doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); |
|
69 | - doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); |
|
70 | - doquery ( "DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';"); |
|
68 | + doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '".$UserID."';"); |
|
69 | + doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '".$UserID."';"); |
|
70 | + doquery("DELETE FROM `{{annonce}}` WHERE `user` = '".$UserID."';"); |
|
71 | 71 | |
72 | 72 | |
73 | 73 | classSupernova::db_del_record_by_id(LOC_USER, $UserID); |
74 | - doquery ( "DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); |
|
74 | + doquery("DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); |
|
75 | 75 | classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->db_loadItem('users_amount') - 1); |
76 | 76 | sn_db_transaction_commit(); |
77 | 77 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $ban_current = db_user_by_id($banned['id'], false, 'banaday'); |
88 | 88 | $ban_until = ($ban_current['banaday'] ? $ban_current['banaday'] : SN_TIME_NOW) + $term; |
89 | 89 | |
90 | - db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} " . ($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
90 | + db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} ".($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
91 | 91 | |
92 | 92 | $banned['username'] = db_escape($banned['username']); |
93 | 93 | $banner['username'] = db_escape($banner['username']); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string $reason |
106 | 106 | */ |
107 | 107 | function sys_admin_player_ban_unset($banner, $banned, $reason = '') { |
108 | - db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = " . SN_TIME_NOW . ""); |
|
108 | + db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = ".SN_TIME_NOW.""); |
|
109 | 109 | |
110 | 110 | $banned['username'] = db_escape($banned['username']); |
111 | 111 | $banner['username'] = db_escape($banner['username']); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | 'total_points' => $options['total_points'] = empty($options['total_points']) ? 0 : $options['total_points'], |
136 | 136 | |
137 | - 'options' => (empty($options['options']) ? $player_options_string : $options['options']) . (empty($options['options_extra']) ? '' : $options['options_extra']), |
|
137 | + 'options' => (empty($options['options']) ? $player_options_string : $options['options']).(empty($options['options_extra']) ? '' : $options['options_extra']), |
|
138 | 138 | |
139 | 139 | 'galaxy' => $options['galaxy'] = intval($options['galaxy'] ? $options['galaxy'] : 0), |
140 | 140 | 'system' => $options['system'] = intval($options['system'] ? $options['system'] : 0), |
@@ -145,28 +145,28 @@ discard block |
||
145 | 145 | !empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false; |
146 | 146 | |
147 | 147 | $user_new = classSupernova::db_ins_field_set(LOC_USER, $field_set); |
148 | - if(!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
148 | + if (!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
149 | 149 | $options['galaxy'] = classSupernova::$config->LastSettedGalaxyPos; |
150 | 150 | $options['system'] = classSupernova::$config->LastSettedSystemPos; |
151 | - $segment_size = floor(Vector::$knownPlanets/ 3); |
|
151 | + $segment_size = floor(Vector::$knownPlanets / 3); |
|
152 | 152 | $segment = floor(classSupernova::$config->LastSettedPlanetPos / $segment_size); |
153 | 153 | $segment++; |
154 | 154 | $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); |
155 | 155 | |
156 | 156 | // $new_planet_id = 0; |
157 | - while(true) { |
|
158 | - if($options['planet'] > Vector::$knownPlanets) { |
|
157 | + while (true) { |
|
158 | + if ($options['planet'] > Vector::$knownPlanets) { |
|
159 | 159 | $options['planet'] = mt_rand(0, $segment_size - 1) + 1; |
160 | 160 | $options['system']++; |
161 | 161 | } |
162 | - if($options['system'] > Vector::$knownSystems) { |
|
162 | + if ($options['system'] > Vector::$knownSystems) { |
|
163 | 163 | $options['system'] = 1; |
164 | 164 | $options['galaxy']++; |
165 | 165 | } |
166 | - $options['galaxy'] > Vector::$knownGalaxies? $options['galaxy'] = 1 : false; |
|
166 | + $options['galaxy'] > Vector::$knownGalaxies ? $options['galaxy'] = 1 : false; |
|
167 | 167 | |
168 | 168 | $galaxy_row = db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); |
169 | - if(!$galaxy_row['id']) { |
|
169 | + if (!$galaxy_row['id']) { |
|
170 | 170 | classSupernova::$config->db_saveItem(array( |
171 | 171 | 'LastSettedGalaxyPos' => $options['galaxy'], |
172 | 172 | 'LastSettedSystemPos' => $options['system'], |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $username_safe = db_escape($username_unsafe); |
190 | 190 | db_player_name_history_replace($user_new, $username_safe); |
191 | 191 | |
192 | - if(!empty($options['partner_id']) && ($referral_row = db_user_by_id($options['partner_id'], true))) { |
|
192 | + if (!empty($options['partner_id']) && ($referral_row = db_user_by_id($options['partner_id'], true))) { |
|
193 | 193 | db_referral_insert($options, $user_new); |
194 | 194 | } |
195 | 195 |
@@ -3,10 +3,10 @@ discard block |
||
3 | 3 | function ali_rank_list_save($ranks) { |
4 | 4 | global $user; |
5 | 5 | |
6 | - if(!empty($ranks)) { |
|
7 | - foreach($ranks as $rank => $rights) { |
|
6 | + if (!empty($ranks)) { |
|
7 | + foreach ($ranks as $rank => $rights) { |
|
8 | 8 | $rights = implode(',', $rights); |
9 | - $ranklist .= $rights . ';'; |
|
9 | + $ranklist .= $rights.';'; |
|
10 | 10 | } |
11 | 11 | } |
12 | 12 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $temp_array = array(); |
23 | 23 | $query = db_ally_diplomacy_get_relations($ally_from, $ally_to); |
24 | 24 | |
25 | - while($record = db_fetch($query)) { |
|
25 | + while ($record = db_fetch($query)) { |
|
26 | 26 | $temp_array[$record['alliance_diplomacy_contr_ally_id']] = $record; |
27 | 27 | } |
28 | 28 |