@@ -27,19 +27,19 @@ |
||
27 | 27 | */ |
28 | 28 | function db_set_make_safe_string($set, $delta = false) { |
29 | 29 | $set_safe = array(); |
30 | - foreach($set as $field => $value) { |
|
31 | - if(empty($field)) { |
|
30 | + foreach ($set as $field => $value) { |
|
31 | + if (empty($field)) { |
|
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $field = '`' . db_escape($field) . '`'; |
36 | 36 | $new_value = $value; |
37 | - if($value === null) { |
|
37 | + if ($value === null) { |
|
38 | 38 | $new_value = 'NULL'; |
39 | - } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) { |
|
39 | + } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) { |
|
40 | 40 | // non-float |
41 | 41 | $new_value = '"' . db_escape($value) . '"'; |
42 | - } elseif($delta) { |
|
42 | + } elseif ($delta) { |
|
43 | 43 | // float and DELTA-set |
44 | 44 | $new_value = "{$field} + ({$new_value})"; |
45 | 45 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) { |
87 | 87 | // pdump($source); |
88 | - if(!$source) { |
|
88 | + if (!$source) { |
|
89 | 89 | $source = array( |
90 | 90 | 'statpoints' => 'statpoints', |
91 | 91 | 'users' => 'users', |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | ); |
107 | 107 | } |
108 | 108 | // pdump($source); |
109 | - if($who == 1) { |
|
110 | - if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
109 | + if ($who == 1) { |
|
110 | + if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
111 | 111 | $query_str = |
112 | 112 | "SELECT |
113 | 113 | @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.* |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
192 | 192 | $current_value_safe = db_escape($current_value_unsafe); |
193 | 193 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
194 | - if(!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
194 | + if (!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
195 | 195 | doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');"); |
196 | 196 | $variable_id = db_insert_id(); |
197 | 197 | } else { |
@@ -161,7 +161,7 @@ |
||
161 | 161 | !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false; |
162 | 162 | |
163 | 163 | $user_list = array(); |
164 | - foreach($user_id_list as $user_id_unsafe) { |
|
164 | + foreach ($user_id_list as $user_id_unsafe) { |
|
165 | 165 | $user = db_user_by_id($user_id_unsafe); |
166 | 166 | !empty($user) ? $user_list[$user_id_unsafe] = $user : false; |
167 | 167 | } |
@@ -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 | } |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | |
42 | 42 | //$config->db_loadItem('db_version'); |
43 | -if($config->db_version == DB_VERSION) { |
|
44 | -} elseif($config->db_version > DB_VERSION) { |
|
43 | +if ($config->db_version == DB_VERSION) { |
|
44 | +} elseif ($config->db_version > DB_VERSION) { |
|
45 | 45 | $config->db_saveItem('var_db_update_end', SN_TIME_NOW); |
46 | 46 | die( |
47 | 47 | 'Internal error! Auotupdater detects DB version greater then can be handled!<br /> |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | -if($config->db_version < 26) { |
|
53 | +if ($config->db_version < 26) { |
|
54 | 54 | $sys_log_disabled = true; |
55 | 55 | } |
56 | 56 | |
@@ -69,25 +69,25 @@ discard block |
||
69 | 69 | $update_tables = array(); |
70 | 70 | $update_indexes = array(); |
71 | 71 | $query = upd_do_query('SHOW TABLES;', true); |
72 | -while($row = db_fetch_row($query)) { |
|
72 | +while ($row = db_fetch_row($query)) { |
|
73 | 73 | upd_load_table_info($row[0]); |
74 | 74 | } |
75 | 75 | upd_log_message('Table info loaded. Now looking DB for upgrades...'); |
76 | 76 | |
77 | 77 | upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true); |
78 | 78 | |
79 | -if($new_version < 37) { |
|
79 | +if ($new_version < 37) { |
|
80 | 80 | require_once('update_old.php'); |
81 | 81 | } |
82 | 82 | |
83 | 83 | ini_set('memory_limit', '1024M'); |
84 | 84 | |
85 | -switch($new_version) { |
|
85 | +switch ($new_version) { |
|
86 | 86 | case 37: |
87 | 87 | upd_log_version_update(); |
88 | 88 | |
89 | 89 | upd_check_key('player_vacation_timeout', PERIOD_WEEK, $config->player_vacation_timeout != PERIOD_WEEK); |
90 | - upd_check_key('player_vacation_time', PERIOD_WEEK , $config->player_vacation_time != PERIOD_WEEK); |
|
90 | + upd_check_key('player_vacation_time', PERIOD_WEEK, $config->player_vacation_time != PERIOD_WEEK); |
|
91 | 91 | |
92 | 92 | upd_alter_table('users', "ADD `vacation_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next datetime when player can go on vacation'", !$update_tables['users']['vacation_next']); |
93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | upd_check_key('payment_currency_exchange_mm_', 2500, !$config->payment_currency_exchange_mm_); |
99 | 99 | |
100 | - if(!$update_tables['log_metamatter']) |
|
100 | + if (!$update_tables['log_metamatter']) |
|
101 | 101 | { |
102 | 102 | upd_create_table('log_metamatter', |
103 | 103 | "( |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
124 | 124 | ), !$update_tables['payment']['payment_test']); |
125 | 125 | |
126 | - if($update_tables['payment']['payment_test']['Default'] == 1) |
|
126 | + if ($update_tables['payment']['payment_test']['Default'] == 1) |
|
127 | 127 | { |
128 | 128 | upd_alter_table('payment', array( |
129 | 129 | "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | ), $update_tables['users']['metamatter']['Type'] == 'int(20)'); |
142 | 142 | |
143 | 143 | $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id in (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE"); |
144 | - while($row = db_fetch($query)) |
|
144 | + while ($row = db_fetch($query)) |
|
145 | 145 | { |
146 | 146 | $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']); |
147 | 147 | upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE"); |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | LEFT JOIN {{planets}} AS p ON p.id = u.id_planet |
161 | 161 | WHERE unit_snid in (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") |
162 | 162 | FOR UPDATE"); |
163 | - while($row = db_fetch($query)) |
|
163 | + while ($row = db_fetch($query)) |
|
164 | 164 | { |
165 | - if(!$row['id_planet']) |
|
165 | + if (!$row['id_planet']) |
|
166 | 166 | { |
167 | 167 | continue; |
168 | 168 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $unit_level = $row['unit_level']; |
172 | 172 | $price = get_unit_param($unit_id, P_COST); |
173 | 173 | $factor = $price['factor']; |
174 | - foreach($price as $resource_id => &$resource_amount) |
|
174 | + foreach ($price as $resource_id => &$resource_amount) |
|
175 | 175 | { |
176 | 176 | $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1); |
177 | 177 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | // Вернуть ресы за уже исследованную Экспедиционную технологию |
192 | 192 | upd_check_key('player_max_colonies', -1, $config->player_max_colonies >= 0); |
193 | 193 | |
194 | - if(!isset($update_tables['users']['player_rpg_explore_xp'])) |
|
194 | + if (!isset($update_tables['users']['player_rpg_explore_xp'])) |
|
195 | 195 | { |
196 | 196 | upd_alter_table('users', array( |
197 | 197 | "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | ), !isset($update_tables['users']['player_rpg_explore_xp'])); |
200 | 200 | } |
201 | 201 | |
202 | - if(!$update_tables['log_users_online']) |
|
202 | + if (!$update_tables['log_users_online']) |
|
203 | 203 | { |
204 | - upd_create_table('log_users_online',"( |
|
204 | + upd_create_table('log_users_online', "( |
|
205 | 205 | `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time', |
206 | 206 | `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online', |
207 | 207 | |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`", |
216 | 216 | ), !$update_tables['users']['user_time_measured']); |
217 | 217 | |
218 | - if($update_tables['rw']) |
|
218 | + if ($update_tables['rw']) |
|
219 | 219 | { |
220 | 220 | upd_do_query("DROP TABLE IF EXISTS {{rw}};"); |
221 | 221 | } |
222 | 222 | |
223 | - if(!$update_tables['player_award']) |
|
223 | + if (!$update_tables['player_award']) |
|
224 | 224 | { |
225 | 225 | upd_create_table('player_award', "( |
226 | 226 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | upd_log_version_update(); |
264 | 264 | |
265 | 265 | |
266 | - if(!isset($update_tables['planets']['que_processed'])) { |
|
266 | + if (!isset($update_tables['planets']['que_processed'])) { |
|
267 | 267 | upd_alter_table('planets', array( |
268 | 268 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`", |
269 | 269 | ), true); |
270 | 270 | upd_do_query("UPDATE {{planets}} SET que_processed = last_update;"); |
271 | 271 | } |
272 | 272 | |
273 | - if(!isset($update_tables['users']['que_processed'])) { |
|
273 | + if (!isset($update_tables['users']['que_processed'])) { |
|
274 | 274 | upd_alter_table('users', array( |
275 | 275 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`", |
276 | 276 | ), true); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | |
283 | 283 | |
284 | - if(isset($update_tables['planets']['que'])) { |
|
284 | + if (isset($update_tables['planets']['que'])) { |
|
285 | 285 | $sn_data_aux = array( |
286 | 286 | SHIP_SMALL_FIGHTER_WRATH => array( |
287 | 287 | 'name' => 'ship_fighter_wrath', |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | $unit_data = array(); |
367 | 367 | $planets = array(); |
368 | 368 | |
369 | - foreach($planet_unit_list as $unit_id) { |
|
370 | - if(!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
369 | + foreach ($planet_unit_list as $unit_id) { |
|
370 | + if (!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
371 | 371 | $unit_name = $sn_data_aux[$unit_id][P_NAME]; |
372 | 372 | } |
373 | - if(isset($update_tables['planets'][$unit_name])) { |
|
373 | + if (isset($update_tables['planets'][$unit_name])) { |
|
374 | 374 | $drop[] = "DROP COLUMN `{$unit_name}`"; |
375 | 375 | |
376 | - if(isset($aux_group[$unit_id])) { |
|
376 | + if (isset($aux_group[$unit_id])) { |
|
377 | 377 | $units_info[$unit_id] = $sn_data_aux[$unit_id]; |
378 | 378 | $units_info[$unit_id]['que'] = QUE_HANGAR; |
379 | 379 | } else { |
380 | 380 | $units_info[$unit_id] = get_unit_param($unit_id); |
381 | - foreach($ques_info as $que_id => $que_data1) { |
|
382 | - if(in_array($unit_id, $que_data1['unit_list'])) { |
|
381 | + foreach ($ques_info as $que_id => $que_data1) { |
|
382 | + if (in_array($unit_id, $que_data1['unit_list'])) { |
|
383 | 383 | $units_info[$unit_id]['que'] = $que_id; |
384 | 384 | break; |
385 | 385 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | } |
390 | 390 | |
391 | 391 | $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE"); |
392 | - while($row = db_fetch($query)) { |
|
392 | + while ($row = db_fetch($query)) { |
|
393 | 393 | $user_id = $row['id_owner']; |
394 | 394 | $planet_id = $row['id']; |
395 | 395 | |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | |
398 | 398 | // Конвертируем юниты |
399 | 399 | $units_levels = array(); |
400 | - foreach($planet_unit_list as $unit_id) { |
|
400 | + foreach ($planet_unit_list as $unit_id) { |
|
401 | 401 | $unit_name = &$units_info[$unit_id][P_NAME]; |
402 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) continue; |
|
402 | + if (!isset($row[$unit_name]) || !$row[$unit_name]) continue; |
|
403 | 403 | $units_levels[$unit_id] = $row[$unit_name]; |
404 | 404 | $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
405 | - if(count($unit_data) > 30) { |
|
405 | + if (count($unit_data) > 30) { |
|
406 | 406 | $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max; |
407 | 407 | 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) . ';'); |
408 | 408 | $unit_data = array(); |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | } |
411 | 411 | |
412 | 412 | // Конвертируем очередь построек |
413 | - if($row['que']) { |
|
413 | + if ($row['que']) { |
|
414 | 414 | $que = explode(';', $row['que']); |
415 | - foreach($que as $que_item) { |
|
416 | - if(!$que_item) continue; |
|
415 | + foreach ($que as $que_item) { |
|
416 | + if (!$que_item) continue; |
|
417 | 417 | |
418 | 418 | $que_item = explode(',', $que_item); |
419 | 419 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1; |
427 | 427 | $price_increase = pow($unit_factor, $unit_level); |
428 | 428 | // $unit_time = 0; |
429 | - foreach($unit_cost as $resource_id => &$resource_amount) { |
|
430 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
429 | + foreach ($unit_cost as $resource_id => &$resource_amount) { |
|
430 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
431 | 431 | unset($unit_cost[$resource_id]); |
432 | 432 | continue; |
433 | 433 | } |
@@ -441,33 +441,33 @@ discard block |
||
441 | 441 | } |
442 | 442 | |
443 | 443 | // Конвертируем очередь верфи |
444 | - if($row['b_hangar_id']) { |
|
445 | - $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0, ); |
|
444 | + if ($row['b_hangar_id']) { |
|
445 | + $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,); |
|
446 | 446 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
447 | - foreach($hangar_units as $unit_id => $unit_count) { |
|
448 | - if($unit_count <= 0) continue; |
|
449 | - foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
450 | - if(!in_array($resource_id, $group_resource_loot)) continue; |
|
447 | + foreach ($hangar_units as $unit_id => $unit_count) { |
|
448 | + if ($unit_count <= 0) continue; |
|
449 | + foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
450 | + if (!in_array($resource_id, $group_resource_loot)) continue; |
|
451 | 451 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
452 | 452 | } |
453 | 453 | } |
454 | - if(array_sum($return_resources) > 0) { |
|
454 | + if (array_sum($return_resources) > 0) { |
|
455 | 455 | 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"); |
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | 459 | |
460 | - if(count($que_data) > 10) { |
|
460 | + if (count($que_data) > 10) { |
|
461 | 461 | $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max; |
462 | 462 | 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) . ';'); |
463 | 463 | $que_data = array(); |
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if(!empty($unit_data)) |
|
467 | + if (!empty($unit_data)) |
|
468 | 468 | 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) . ';'); |
469 | 469 | |
470 | - if(!empty($que_data)) |
|
470 | + if (!empty($que_data)) |
|
471 | 471 | 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) . ';'); |
472 | 472 | |
473 | 473 | upd_alter_table('planets', $drop, true); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = '' |
478 | 478 | SET u.`username` = CONCAT('[', a.`ally_tag`, ']');"); |
479 | 479 | |
480 | - if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
480 | + if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
481 | 481 | upd_do_query("SET FOREIGN_KEY_CHECKS=0;"); |
482 | 482 | upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']); |
483 | 483 | upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']); |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{$config->db_prefix}security_browser` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE", |
574 | 574 | ), !isset($update_tables['users']['user_last_proxy'])); |
575 | 575 | |
576 | - if(!isset($update_tables['notes']['planet_type'])) { |
|
576 | + if (!isset($update_tables['notes']['planet_type'])) { |
|
577 | 577 | upd_alter_table('notes', array( |
578 | 578 | // "ADD COLUMN `planet_name` VARCHAR(64) NOT NULL DEFAULT '' AFTER `title`", |
579 | 579 | "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`", |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot'])); |
593 | 593 | upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']); |
594 | 594 | |
595 | - if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
595 | + if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
596 | 596 | upd_alter_table('users', array( |
597 | 597 | "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'", |
598 | 598 | ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint'); |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;"); |
601 | 601 | } |
602 | 602 | |
603 | - if(!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
603 | + if (!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
604 | 604 | 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'])); |
605 | 605 | upd_alter_table('log_users_online', array( |
606 | 606 | "DROP PRIMARY KEY", |
@@ -608,13 +608,13 @@ discard block |
||
608 | 608 | ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,'); |
609 | 609 | } |
610 | 610 | |
611 | - if(!isset($update_tables['users']['gender'])) { |
|
611 | + if (!isset($update_tables['users']['gender'])) { |
|
612 | 612 | upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
613 | - upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE. ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
613 | + upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
614 | 614 | } |
615 | 615 | upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex'])); |
616 | 616 | |
617 | - if(!$update_tables['users']['dark_matter_total']) { |
|
617 | + if (!$update_tables['users']['dark_matter_total']) { |
|
618 | 618 | 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']); |
619 | 619 | upd_do_query( |
620 | 620 | "UPDATE `{{users}}` AS u |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | upd_check_key('player_metamatter_immortal', 100000, !isset($config->player_metamatter_immortal)); |
630 | - if(!$update_tables['users']['metamatter_total']) { |
|
630 | + if (!$update_tables['users']['metamatter_total']) { |
|
631 | 631 | upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']); |
632 | 632 | |
633 | 633 | upd_do_query( |
@@ -639,11 +639,11 @@ discard block |
||
639 | 639 | (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0) |
640 | 640 | );"); |
641 | 641 | } |
642 | - if(!isset($update_tables['users']['immortal'])) { |
|
642 | + if (!isset($update_tables['users']['immortal'])) { |
|
643 | 643 | upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal'])); |
644 | 644 | upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;"); |
645 | 645 | } |
646 | - if(isset($update_tables['player_award'])) { |
|
646 | + if (isset($update_tables['player_award'])) { |
|
647 | 647 | upd_do_query( |
648 | 648 | "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id |
649 | 649 | SET metamatter_total = 1, immortal = NOW() |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
671 | 671 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); |
672 | 672 | |
673 | - if(empty($update_tables['blitz_statpoints'])) { |
|
673 | + if (empty($update_tables['blitz_statpoints'])) { |
|
674 | 674 | upd_create_table('blitz_statpoints', " ( |
675 | 675 | `stat_date` int(11) NOT NULL DEFAULT '0', |
676 | 676 | `id_owner` bigint(20) unsigned DEFAULT NULL, |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE |
739 | 739 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
740 | 740 | |
741 | - if(empty($update_tables['security_url'])) { |
|
741 | + if (empty($update_tables['security_url'])) { |
|
742 | 742 | upd_create_table('security_url', " ( |
743 | 743 | `url_id` int unsigned NOT NULL AUTO_INCREMENT, |
744 | 744 | `url_string` VARCHAR(250) NOT NULL DEFAULT '', |
@@ -751,9 +751,9 @@ discard block |
||
751 | 751 | |
752 | 752 | $strings = array(); |
753 | 753 | $query = doquery($query); |
754 | - while($row = db_fetch($query)) { |
|
754 | + while ($row = db_fetch($query)) { |
|
755 | 755 | $strings[] = '("' . db_escape($row['url']) . '")'; |
756 | - if(count($strings) > 100) { |
|
756 | + if (count($strings) > 100) { |
|
757 | 757 | doquery($query_string . implode(',', $strings)); |
758 | 758 | $strings = array(); |
759 | 759 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
762 | 762 | } |
763 | 763 | |
764 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
764 | + if (isset($update_tables['counter']['page'])) // TODO REMOVE |
|
765 | 765 | { |
766 | 766 | update_security_url("SELECT DISTINCT `page` as url FROM {{counter}}"); |
767 | 767 | update_security_url("SELECT DISTINCT `url` as url FROM {{counter}}"); |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
787 | 787 | "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
788 | 788 | ), !isset($update_tables['counter']['device_id'])); |
789 | - if(isset($update_tables['counter']['ip'])) { |
|
789 | + if (isset($update_tables['counter']['ip'])) { |
|
790 | 790 | // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)'); |
791 | 791 | upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)'); |
792 | 792 | 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'); |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | |
838 | 838 | upd_check_key('stats_history_days', 14, !$config->stats_history_days); |
839 | 839 | |
840 | - if($config->payment_currency_default != 'USD') { |
|
841 | - upd_check_key('payment_currency_default', 'USD', true); |
|
840 | + if ($config->payment_currency_default != 'USD') { |
|
841 | + upd_check_key('payment_currency_default', 'USD', true); |
|
842 | 842 | upd_check_key('payment_currency_exchange_dm_', 20000, true); |
843 | 843 | upd_check_key('payment_currency_exchange_mm_', 20000, true); |
844 | 844 | upd_check_key('payment_currency_exchange_usd', 1, true); |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | function propagade_player_options($old_option_name, $new_option_id) { |
921 | 921 | global $update_tables; |
922 | 922 | |
923 | - if(!empty($update_tables['users'][$old_option_name])) { |
|
923 | + if (!empty($update_tables['users'][$old_option_name])) { |
|
924 | 924 | upd_do_query( |
925 | 925 | "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) |
926 | 926 | SELECT `id`, {$new_option_id}, `{$old_option_name}` |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | |
955 | 955 | // 2015-08-03 15:05:26 40a6.0 |
956 | 956 | |
957 | - if(empty($update_tables['planets']['position_original'])) { |
|
957 | + if (empty($update_tables['planets']['position_original'])) { |
|
958 | 958 | upd_alter_table('planets', array( |
959 | 959 | "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0", |
960 | 960 | "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0", |
@@ -982,12 +982,12 @@ discard block |
||
982 | 982 | // 2015-08-27 19:14:05 40a10.0 |
983 | 983 | |
984 | 984 | // Старая версия таблицы |
985 | - if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
985 | + if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
986 | 986 | upd_drop_table('account'); |
987 | 987 | upd_drop_table('account_translate'); |
988 | 988 | } |
989 | 989 | |
990 | - if(empty($update_tables['account'])) { |
|
990 | + if (empty($update_tables['account'])) { |
|
991 | 991 | upd_create_table('account', " ( |
992 | 992 | `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
993 | 993 | `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | upd_alter_table('security_url', "MODIFY COLUMN `url_string` VARCHAR(250) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''", empty($update_tables['security_url']['ube_report_capture_result'])); |
1046 | 1046 | |
1047 | 1047 | // 2015-09-24 11:39:37 40a10.25 |
1048 | - if(empty($update_tables['log_metamatter']['provider_id'])) { |
|
1048 | + if (empty($update_tables['log_metamatter']['provider_id'])) { |
|
1049 | 1049 | upd_alter_table('log_metamatter', array( |
1050 | 1050 | "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'", |
1051 | 1051 | "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0", |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | upd_check_key('event_halloween_2015_code', '', !isset($config->event_halloween_2015_code)); |
1096 | 1096 | upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset($config->event_halloween_2015_timestamp)); |
1097 | 1097 | upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset($config->event_halloween_2015_units_used)); |
1098 | - if(empty($update_tables['log_halloween_2015'])) { |
|
1098 | + if (empty($update_tables['log_halloween_2015'])) { |
|
1099 | 1099 | upd_create_table('log_halloween_2015', " ( |
1100 | 1100 | `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1101 | 1101 | `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | // 2015-11-28 06:30:27 40a19.21 |
1112 | - if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1112 | + if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1113 | 1113 | upd_alter_table('ube_report', array( |
1114 | 1114 | "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", |
1115 | 1115 | // "ADD KEY `I_ube_report_debris_id` (`ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | // 2015-12-06 15:10:58 40b1.0 |
1127 | - if(!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1127 | + if (!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1128 | 1128 | upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']); |
1129 | 1129 | upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']); |
1130 | 1130 | 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, |
@@ -1275,18 +1275,18 @@ discard block |
||
1275 | 1275 | $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin' |
1276 | 1276 | ); |
1277 | 1277 | |
1278 | - if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1278 | + if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1279 | 1279 | // pdump($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type']); |
1280 | 1280 | upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true); |
1281 | 1281 | upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true); |
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | // #ctv№ |
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 | 1292 | ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, " . get_unit_param($unit_id, P_UNIT_TYPE) . ", {$unit_id}, {$unit_count});", |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | |
1322 | 1322 | classSupernova::$cache->unset_by_prefix('lng_'); |
1323 | 1323 | |
1324 | -if($new_version) { |
|
1324 | +if ($new_version) { |
|
1325 | 1325 | $config->db_saveItem('db_version', $new_version); |
1326 | 1326 | upd_log_message("<font color=green>DB version is now {$new_version}</font>"); |
1327 | 1327 | } else { |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * @copyright 2008 by Gorlum for Project "SuperNova.WS" |
11 | 11 | */ |
12 | 12 | function flt_mission_hold($mission_data) { |
13 | - if($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) { |
|
13 | + if ($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) { |
|
14 | 14 | $mission_data->fleet->mark_fleet_as_returned_and_save(); |
15 | 15 | |
16 | 16 | return CACHE_FLEET; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('IN_UPDATE')) { |
|
3 | +if (!defined('IN_UPDATE')) { |
|
4 | 4 | die('Trying to call update helpers externally!'); |
5 | 5 | } |
6 | 6 | |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | global $update_tables; |
9 | 9 | |
10 | 10 | upd_add_more_time(); |
11 | - if(!$no_log) { |
|
11 | + if (!$no_log) { |
|
12 | 12 | upd_log_message("Performing query '{$query}'"); |
13 | 13 | } |
14 | 14 | |
15 | 15 | // classSupernova::$db->sn_db_connect(); |
16 | - if(!(strpos($query, '{{') === false)) { |
|
17 | - foreach($update_tables as $tableName => $cork) { |
|
16 | + if (!(strpos($query, '{{') === false)) { |
|
17 | + foreach ($update_tables as $tableName => $cork) { |
|
18 | 18 | $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
19 | 19 | } |
20 | 20 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | global $config, $sys_log_disabled; |
28 | 28 | |
29 | 29 | $config->db_loadItem($key); |
30 | - if($condition || !isset($config->$key)) { |
|
30 | + if ($condition || !isset($config->$key)) { |
|
31 | 31 | upd_add_more_time(); |
32 | - if(!$sys_log_disabled) { |
|
32 | + if (!$sys_log_disabled) { |
|
33 | 33 | upd_log_message("Updating config key '{$key}' with value '{$default_value}'"); |
34 | 34 | } |
35 | 35 | $config->db_saveItem($key, $default_value); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function upd_log_message($message) { |
58 | 58 | global $sys_log_disabled, $upd_log, $debug; |
59 | 59 | |
60 | - if($sys_log_disabled) { |
|
60 | + if ($sys_log_disabled) { |
|
61 | 61 | // print("{$message}<br />"); |
62 | 62 | } else { |
63 | 63 | $upd_log .= "{$message}\r\n"; |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | function upd_unset_table_info($table_name) { |
69 | 69 | global $update_tables, $update_indexes, $update_foreigns; |
70 | 70 | |
71 | - if(isset($update_tables[$table_name])) { |
|
71 | + if (isset($update_tables[$table_name])) { |
|
72 | 72 | unset($update_tables[$table_name]); |
73 | 73 | } |
74 | 74 | |
75 | - if(isset($update_indexes[$table_name])) { |
|
75 | + if (isset($update_indexes[$table_name])) { |
|
76 | 76 | unset($update_indexes[$table_name]); |
77 | 77 | } |
78 | 78 | |
79 | - if(isset($update_foreigns[$table_name])) { |
|
79 | + if (isset($update_foreigns[$table_name])) { |
|
80 | 80 | unset($update_foreigns[$table_name]); |
81 | 81 | } |
82 | 82 | } |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | upd_unset_table_info($tableName); |
91 | 91 | |
92 | 92 | $q1 = upd_do_query("SHOW FULL COLUMNS FROM {$prefix_table_name};", true); |
93 | - while($r1 = db_fetch($q1)) { |
|
93 | + while ($r1 = db_fetch($q1)) { |
|
94 | 94 | $update_tables[$tableName][$r1['Field']] = $r1; |
95 | 95 | } |
96 | 96 | |
97 | 97 | $q1 = upd_do_query("SHOW INDEX FROM {$prefix_table_name};", true); |
98 | - while($r1 = db_fetch($q1)) { |
|
98 | + while ($r1 = db_fetch($q1)) { |
|
99 | 99 | $update_indexes[$tableName][$r1['Key_name']] .= "{$r1['Column_name']},"; |
100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
104 | - while($r1 = db_fetch($q1)) { |
|
104 | + while ($r1 = db_fetch($q1)) { |
|
105 | 105 | $table_referenced = str_replace($config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
106 | 106 | |
107 | 107 | $update_foreigns[$tableName][$r1['CONSTRAINT_NAME']] .= "{$r1['COLUMN_NAME']},{$table_referenced},{$r1['REFERENCED_COLUMN_NAME']};"; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | function upd_alter_table($table, $alters, $condition = true) { |
119 | 119 | global $config; |
120 | 120 | |
121 | - if(!$condition) { |
|
121 | + if (!$condition) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $alters_print = is_array($alters) ? dump($alters) : $alters; |
127 | 127 | upd_log_message("Altering table '{$table}' with alterations {$alters_print}"); |
128 | 128 | |
129 | - if(!is_array($alters)) { |
|
129 | + if (!is_array($alters)) { |
|
130 | 130 | $alters = array($alters); |
131 | 131 | } |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | //$result = db_query($qry); |
138 | 138 | $result = upd_do_query($qry); |
139 | 139 | $error = db_error(); |
140 | - if($error) { |
|
140 | + if ($error) { |
|
141 | 141 | die("Altering error for table `{$table}`: {$error}<br />{$alters_print}"); |
142 | 142 | } |
143 | 143 | |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | function upd_create_table($table_name, $declaration) { |
161 | 161 | global $config, $update_tables; |
162 | 162 | |
163 | - if(!$update_tables[$table_name]) { |
|
163 | + if (!$update_tables[$table_name]) { |
|
164 | 164 | upd_do_query('set foreign_key_checks = 0;', true); |
165 | 165 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$config->db_prefix}{$table_name}` {$declaration}"); |
166 | 166 | $error = db_error(); |
167 | - if($error) { |
|
167 | + if ($error) { |
|
168 | 168 | die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
169 | 169 | } |
170 | 170 | upd_do_query('set foreign_key_checks = 1;', true); |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | |
191 | 191 | |
192 | 192 | function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) { |
193 | - if(!is_array($user)) { |
|
193 | + if (!is_array($user)) { |
|
194 | 194 | // TODO - remove later |
195 | 195 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>'); |
196 | 196 | pdump(debug_backtrace()); |
197 | 197 | die('USER is not ARRAY'); |
198 | 198 | } |
199 | 199 | |
200 | - if(!isset($user['id']) || !$user['id']) { |
|
200 | + if (!isset($user['id']) || !$user['id']) { |
|
201 | 201 | // TODO - remove later |
202 | 202 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>'); |
203 | 203 | pdump($user); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | $db_changeset = array(); |
214 | 214 | $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
215 | - if($temp['unit_id']) { |
|
215 | + if ($temp['unit_id']) { |
|
216 | 216 | // update |
217 | 217 | $db_changeset = array( |
218 | 218 | 'action' => SQL_OP_UPDATE, |
@@ -257,41 +257,41 @@ discard block |
||
257 | 257 | |
258 | 258 | |
259 | 259 | function upd_db_changeset_apply($db_changeset) { |
260 | - if(!is_array($db_changeset) || empty($db_changeset)) { |
|
260 | + if (!is_array($db_changeset) || empty($db_changeset)) { |
|
261 | 261 | return; |
262 | 262 | } |
263 | 263 | |
264 | - foreach($db_changeset as $table_name => $table_data) { |
|
265 | - foreach($table_data as $record_id => $conditions) { |
|
264 | + foreach ($db_changeset as $table_name => $table_data) { |
|
265 | + foreach ($table_data as $record_id => $conditions) { |
|
266 | 266 | $where = ''; |
267 | - if(!empty($conditions['where'])) { |
|
267 | + if (!empty($conditions['where'])) { |
|
268 | 268 | $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
269 | 269 | } |
270 | 270 | |
271 | 271 | $fields = array(); |
272 | - if($conditions['fields']) { |
|
273 | - foreach($conditions['fields'] as $field_name => $field_data) { |
|
272 | + if ($conditions['fields']) { |
|
273 | + foreach ($conditions['fields'] as $field_name => $field_data) { |
|
274 | 274 | $condition = "`{$field_name}` = "; |
275 | 275 | $value = ''; |
276 | - if($field_data['delta']) { |
|
276 | + if ($field_data['delta']) { |
|
277 | 277 | $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
278 | - } elseif($field_data['set']) { |
|
278 | + } elseif ($field_data['set']) { |
|
279 | 279 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
280 | 280 | } |
281 | - if($value) { |
|
281 | + if ($value) { |
|
282 | 282 | $fields[] = $condition . $value; |
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
286 | 286 | $fields = implode(',', $fields); |
287 | 287 | |
288 | - switch($conditions['action']) { |
|
288 | + switch ($conditions['action']) { |
|
289 | 289 | case SQL_OP_DELETE: |
290 | 290 | upd_do_query("DELETE FROM {{{$table_name}}} {$where}"); |
291 | 291 | break; |
292 | 292 | |
293 | 293 | case SQL_OP_UPDATE: |
294 | - if($fields) { |
|
294 | + if ($fields) { |
|
295 | 295 | /*if($table_name == 'unit') |
296 | 296 | { |
297 | 297 | pdump("UPDATE {{{$table_name}}} SET {$fields} {$where}"); |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | break; |
303 | 303 | |
304 | 304 | case SQL_OP_INSERT: |
305 | - if($fields) { |
|
305 | + if ($fields) { |
|
306 | 306 | upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}"); |
307 | 307 | } |
308 | 308 | break; |
309 | 309 | |
310 | 310 | case SQL_OP_REPLACE: |
311 | - if($fields) { |
|
311 | + if ($fields) { |
|
312 | 312 | upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}"); |
313 | 313 | } |
314 | 314 | break; |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | { |
5 | 5 | $strPacked = "{$type}!"; |
6 | 6 | |
7 | - foreach($combat as $fleetID => $fleetCompress) |
|
7 | + foreach ($combat as $fleetID => $fleetCompress) |
|
8 | 8 | { |
9 | - foreach($fleetCompress as $key => $value) |
|
9 | + foreach ($fleetCompress as $key => $value) |
|
10 | 10 | { |
11 | 11 | $value = intval($value); |
12 | 12 | $strPacked .= "{$key},{$value};"; |
@@ -22,29 +22,29 @@ discard block |
||
22 | 22 | $fleet_id = 0; |
23 | 23 | |
24 | 24 | $arr_data_unpacked = explode('!', $str_data); |
25 | - foreach($arr_data_unpacked as $data_piece) |
|
25 | + foreach ($arr_data_unpacked as $data_piece) |
|
26 | 26 | { |
27 | - if(!$data_piece) |
|
27 | + if (!$data_piece) |
|
28 | 28 | { |
29 | 29 | continue; |
30 | 30 | } |
31 | 31 | |
32 | - if($data_piece == 'A' || $data_piece == 'D') |
|
32 | + if ($data_piece == 'A' || $data_piece == 'D') |
|
33 | 33 | { |
34 | 34 | $fleet_type = $data_piece; |
35 | 35 | continue; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $arr_unit_strings = explode(';', $data_piece); |
39 | - foreach($arr_unit_strings as $str_unit_string) |
|
39 | + foreach ($arr_unit_strings as $str_unit_string) |
|
40 | 40 | { |
41 | - if(!$str_unit_string) |
|
41 | + if (!$str_unit_string) |
|
42 | 42 | { |
43 | 43 | continue; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $arr_unit_data = explode(',', $str_unit_string); |
47 | - if($arr_unit_data[1]) |
|
47 | + if ($arr_unit_data[1]) |
|
48 | 48 | { |
49 | 49 | $unpacked[$fleet_type][$fleet_id][$arr_unit_data[0]] = intval($arr_unit_data[1]); |
50 | 50 | } |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | */ |
12 | 12 | // ---------------------------------------------------------------------------------------------------------------- |
13 | 13 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
14 | - foreach($unit_group as $unit_id) { |
|
15 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
14 | + foreach ($unit_group as $unit_id) { |
|
15 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
16 | 16 | $compress_data[$unit_id] = $unit_count; |
17 | 17 | } |
18 | 18 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | global $lang; |
23 | 23 | |
24 | 24 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
25 | - foreach(sn_get_groups($group_name) as $unit_id) { |
|
26 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
25 | + foreach (sn_get_groups($group_name) as $unit_id) { |
|
26 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
27 | 27 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$lang['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
28 | 28 | } |
29 | 29 | |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | |
55 | 55 | $objFleet = $mission_data->fleet; |
56 | 56 | |
57 | - if(empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
57 | + if (empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
58 | 58 | $objFleet->mark_fleet_as_returned_and_save(); |
59 | 59 | |
60 | 60 | return $result; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $spy_probes = $objFleet->shipCountById(SHIP_SPY); |
64 | - if($spy_probes > 0) { |
|
64 | + if ($spy_probes > 0) { |
|
65 | 65 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
66 | 66 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
67 | 67 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
86 | 86 | $spy_message .= "<td width=220>{$lang['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
87 | 87 | $spy_message .= "</tr>"; |
88 | - if($spy_diff >= 2) { |
|
88 | + if ($spy_diff >= 2) { |
|
89 | 89 | $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', $lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>"; |
90 | 90 | coe_compress_add_units(sn_get_groups('fleet'), $target_planet_row, $combat_pack[0]); |
91 | 91 | } |
92 | - if($spy_diff >= 3) { |
|
92 | + if ($spy_diff >= 3) { |
|
93 | 93 | $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', $lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>"; |
94 | 94 | coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]); |
95 | 95 | } |
96 | - if($spy_diff >= 5) { |
|
96 | + if ($spy_diff >= 5) { |
|
97 | 97 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', $lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
98 | 98 | } |
99 | 99 | |
100 | - if($spy_diff_empire >= 0) { |
|
100 | + if ($spy_diff_empire >= 0) { |
|
101 | 101 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', $lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
102 | 102 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
103 | 103 | } |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
107 | 107 | |
108 | 108 | $target_unit_list = 0; |
109 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
109 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
110 | 110 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
114 | 114 | |
115 | - if(mt_rand(0, 99) > $spy_detected) { |
|
115 | + if (mt_rand(0, 99) > $spy_detected) { |
|
116 | 116 | $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected); |
117 | 117 | $spy_detected = false; |
118 | 118 | } else { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $target_message = "{$lang['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3); |
133 | 133 | $target_message .= " {$lang['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row); |
134 | 134 | |
135 | - if($spy_detected) { |
|
135 | + if ($spy_detected) { |
|
136 | 136 | $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet']; |
137 | 137 | |
138 | 138 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_mess_spy_control'], $lang['sys_mess_spy_activity'], $target_message); |
150 | 150 | } |
151 | 151 | |
152 | - if($spy_detected) { |
|
152 | + if ($spy_detected) { |
|
153 | 153 | $objFleet->db_delete_this_fleet(); |
154 | 154 | } else { |
155 | 155 | $objFleet->mark_fleet_as_returned_and_save(); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | $destination_planet = &$mission_data->dst_planet; |
18 | 18 | |
19 | - if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
19 | + if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
20 | 20 | $objFleet->mark_fleet_as_returned_and_save(); |
21 | 21 | |
22 | 22 | return CACHE_FLEET; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $fleet_resources[RES_DEUTERIUM], $lang['Deuterium'] |
32 | 32 | ) . '<br />' . $lang['sys_relocate_mess_user']; |
33 | 33 | $fleet_real_array = $objFleet->get_unit_list(); |
34 | - foreach($fleet_real_array as $ship_id => $ship_count) { |
|
34 | + foreach ($fleet_real_array as $ship_id => $ship_count) { |
|
35 | 35 | $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; |
36 | 36 | } |
37 | 37 | msg_send_simple_message( |