@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | $uni_galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']); |
12 | 12 | $uni_system = sys_get_param_int('system'); |
13 | 13 | |
14 | - if($uni_galaxy < 1 || $uni_galaxy > Vector::$knownGalaxies) |
|
14 | + if ($uni_galaxy < 1 || $uni_galaxy > Vector::$knownGalaxies) |
|
15 | 15 | { |
16 | 16 | throw new exception(classLocale::$lang['uni_msg_error_wrong_galaxy'], ERR_ERROR); |
17 | 17 | } |
18 | 18 | |
19 | - if($uni_system < 0 || $uni_system > Vector::$knownSystems) |
|
19 | + if ($uni_system < 0 || $uni_system > Vector::$knownSystems) |
|
20 | 20 | { |
21 | 21 | throw new exception(classLocale::$lang['uni_msg_error_wrong_system'], ERR_ERROR); |
22 | 22 | } |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | $uni_row['universe_price'] += $uni_system ? classSupernova::$config->uni_price_system : classSupernova::$config->uni_price_galaxy; |
26 | 26 | $uni_row['universe_name'] = strip_tags($uni_row['universe_name'] ? $uni_row['universe_name'] : ($uni_system ? "{$classLocale['sys_system']} [{$uni_galaxy}:{$uni_system}]" : "{$classLocale['sys_galaxy']} {$uni_galaxy}")); |
27 | 27 | |
28 | - if(sys_get_param_str('uni_name_submit')) |
|
28 | + if (sys_get_param_str('uni_name_submit')) |
|
29 | 29 | { |
30 | 30 | $uni_row['universe_name'] = strip_tags(sys_get_param_str('uni_name')); |
31 | 31 | |
32 | 32 | $uni_price = sys_get_param_float('uni_price'); |
33 | - if($uni_price < $uni_row['universe_price']) |
|
33 | + if ($uni_price < $uni_row['universe_price']) |
|
34 | 34 | { |
35 | 35 | throw new exception(classLocale::$lang['uni_msg_error_low_price'], ERR_ERROR); |
36 | 36 | } |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | sn_db_transaction_start(); |
40 | 40 | $user = db_user_by_id($user['id'], true); |
41 | 41 | // if($user[get_unit_param(RES_DARK_MATTER, P_NAME)] < $uni_price) |
42 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) |
|
42 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) |
|
43 | 43 | { |
44 | 44 | throw new exception(classLocale::$lang['uni_msg_error_no_dm'], ERR_ERROR); |
45 | 45 | } |
46 | 46 | |
47 | - if(!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name'))) |
|
47 | + if (!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to ".sys_get_param_str_unsafe('uni_name'))) |
|
48 | 48 | { |
49 | 49 | throw new exception(classLocale::$lang['sys_msg_err_update_dm'], ERR_ERROR); |
50 | 50 | } |
@@ -74,4 +74,4 @@ discard block |
||
74 | 74 | 'PAGE_HINT' => classLocale::$lang['uni_name_page_hint'], |
75 | 75 | )); |
76 | 76 | |
77 | - display($template, classLocale::$lang['sys_universe'] . ' - ' . classLocale::$lang['uni_naming'], true, '', false); |
|
77 | + display($template, classLocale::$lang['sys_universe'].' - '.classLocale::$lang['uni_naming'], true, '', false); |
@@ -4,13 +4,13 @@ discard block |
||
4 | 4 | |
5 | 5 | function mrc_officer_accessible(&$user, $mercenary_id) { |
6 | 6 | $mercenary_info = get_unit_param($mercenary_id); |
7 | - if(classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) { |
|
7 | + if (classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) { |
|
8 | 8 | return true; |
9 | 9 | } |
10 | 10 | |
11 | - if(isset($mercenary_info[P_REQUIRE])) { |
|
12 | - foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) { |
|
13 | - if(mrc_get_level($user, null, $unit_id) < $unit_level) { |
|
11 | + if (isset($mercenary_info[P_REQUIRE])) { |
|
12 | + foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) { |
|
13 | + if (mrc_get_level($user, null, $unit_id) < $unit_level) { |
|
14 | 14 | return false; |
15 | 15 | } |
16 | 16 | } |
@@ -26,35 +26,35 @@ discard block |
||
26 | 26 | $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary; |
27 | 27 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1); |
28 | 28 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
29 | - if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
29 | + if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
30 | 30 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR); |
31 | 31 | } |
32 | 32 | |
33 | - if(!mrc_officer_accessible($user, $mercenary_id)) { |
|
33 | + if (!mrc_officer_accessible($user, $mercenary_id)) { |
|
34 | 34 | throw new Exception(classLocale::$lang['mrc_msg_error_requirements'], ERR_ERROR); |
35 | 35 | } |
36 | 36 | |
37 | 37 | $mercenary_level = sys_get_param_int('mercenary_level'); |
38 | - if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
38 | + if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
39 | 39 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_level'], ERR_ERROR); |
40 | 40 | } |
41 | 41 | |
42 | - if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
42 | + if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
43 | 43 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_period'], ERR_ERROR); |
44 | 44 | } |
45 | 45 | |
46 | 46 | sn_db_transaction_start(); |
47 | 47 | |
48 | 48 | $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true); |
49 | - if(classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
49 | + if (classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
50 | 50 | throw new Exception(classLocale::$lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first |
51 | - } elseif(classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
51 | + } elseif (classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
52 | 52 | throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error |
53 | 53 | } |
54 | 54 | |
55 | - if($mercenary_level) { |
|
55 | + if ($mercenary_level) { |
|
56 | 56 | $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level); |
57 | - if(!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
57 | + if (!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
58 | 58 | $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
59 | 59 | $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
60 | 60 | } |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | } |
65 | 65 | $darkmater_cost *= $cost_alliance_multiplyer; |
66 | 66 | |
67 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
67 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
68 | 68 | throw new Exception(classLocale::$lang['mrc_msg_error_no_resource'], ERR_ERROR); |
69 | 69 | } |
70 | 70 | |
71 | - if(($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
71 | + if (($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
72 | 72 | $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id); |
73 | - if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
73 | + if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
74 | 74 | $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']); |
75 | 75 | $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER]; |
76 | 76 | |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id); |
84 | 84 | } |
85 | 85 | |
86 | - if($darkmater_cost && $mercenary_level) { |
|
86 | + if ($darkmater_cost && $mercenary_level) { |
|
87 | 87 | db_unit_set_insert( |
88 | 88 | "unit_player_id = {$user['id']}, |
89 | - unit_location_type = " . LOC_USER . ", |
|
89 | + unit_location_type = ".LOC_USER.", |
|
90 | 90 | unit_location_id = {$user['id']}, |
91 | 91 | unit_type = {$mode}, |
92 | 92 | unit_snid = {$mercenary_id}, |
93 | 93 | unit_level = {$mercenary_level}, |
94 | - unit_time_start = " . (!$is_permanent ? 'FROM_UNIXTIME(' . SN_TIME_NOW . ')' : 'null') . ", |
|
95 | - unit_time_finish = " . (!$is_permanent ? 'FROM_UNIXTIME(' . (SN_TIME_NOW + $mercenary_period) . ')' : 'null') |
|
94 | + unit_time_start = ".(!$is_permanent ? 'FROM_UNIXTIME('.SN_TIME_NOW.')' : 'null').", |
|
95 | + unit_time_finish = " . (!$is_permanent ? 'FROM_UNIXTIME('.(SN_TIME_NOW + $mercenary_period).')' : 'null') |
|
96 | 96 | ); |
97 | 97 | |
98 | 98 | rpg_points_change($user['id'], $mode == UNIT_PLANS ? RPG_PLANS : RPG_MERCENARY, -($darkmater_cost), |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | } |
101 | 101 | sn_db_transaction_commit(); |
102 | 102 | sys_redirect($_SERVER['REQUEST_URI']); |
103 | - } catch(Exception $e) { |
|
103 | + } catch (Exception $e) { |
|
104 | 104 | sn_db_transaction_rollback(); |
105 | 105 | $operation_result = array( |
106 | 106 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES; |
119 | 119 | $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary; |
120 | 120 | |
121 | - if($mercenary_id = sys_get_param_int('mercenary_id')) { |
|
121 | + if ($mercenary_id = sys_get_param_int('mercenary_id')) { |
|
122 | 122 | $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id); |
123 | 123 | } |
124 | 124 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | $template = gettemplate('mrc_mercenary_hire', true); |
128 | 128 | |
129 | - if(!empty($operation_result)) { |
|
129 | + if (!empty($operation_result)) { |
|
130 | 130 | $template->assign_block_vars('result', $operation_result); |
131 | 131 | } |
132 | 132 | |
133 | - foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) { |
|
133 | + foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) { |
|
134 | 134 | $template->assign_block_vars('period', array( |
135 | 135 | 'LENGTH' => $hire_period, |
136 | 136 | 'TEXT' => classLocale::$lang['mrc_period_list'][$hire_period], |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
143 | 143 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1); |
144 | 144 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
145 | - foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) { |
|
145 | + foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) { |
|
146 | 146 | { |
147 | 147 | $mercenary = get_unit_param($mercenary_id); |
148 | 148 | $mercenary_bonus = $mercenary['bonus']; |
149 | 149 | $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}"; |
150 | - switch($mercenary['bonus_type']) { |
|
150 | + switch ($mercenary['bonus_type']) { |
|
151 | 151 | case BONUS_PERCENT: |
152 | 152 | $mercenary_bonus = "{$mercenary_bonus}% "; |
153 | 153 | break; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true); |
165 | 165 | $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level); |
166 | 166 | $total_cost_old = 0; |
167 | - if($is_permanent) { |
|
167 | + if ($is_permanent) { |
|
168 | 168 | $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level); |
169 | 169 | $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer; |
170 | 170 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | )); |
194 | 194 | |
195 | 195 | $upgrade_cost = 1; |
196 | - for($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) { |
|
196 | + for ($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) { |
|
197 | 197 | $total_cost = eco_get_total_cost($mercenary_id, $i); |
198 | 198 | $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer; |
199 | 199 | $upgrade_cost = $total_cost[BUILD_CREATE][RES_DARK_MATTER] - $total_cost_old; |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | |
40 | 40 | $sta_update_msg = db_escape($sta_update_msg); |
41 | 41 | |
42 | - if($next_step) { |
|
42 | + if ($next_step) { |
|
43 | 43 | $sta_update_step++; |
44 | 44 | } |
45 | 45 | $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}."; |
46 | 46 | |
47 | 47 | classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg); |
48 | - if($next_step) { |
|
48 | + if ($next_step) { |
|
49 | 49 | classSupernova::$debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | 53 | function sys_stat_calculate_flush(&$data, $force = false) { |
54 | - if(count($data) < 25 && !$force) { |
|
54 | + if (count($data) < 25 && !$force) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - if(!empty($data)) { |
|
58 | + if (!empty($data)) { |
|
59 | 59 | doquery('REPLACE INTO {{statpoints}} |
60 | 60 | (`id_owner`, `id_ally`, `stat_type`, `stat_code`, `tech_points`, `tech_count`, `build_points`, `build_count`, |
61 | 61 | `defs_points`, `defs_count`, `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`, |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | $user_list = db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id'); |
96 | 96 | $row_num = count($user_list); |
97 | 97 | // while($player = db_fetch($query)) |
98 | - foreach($user_list as $player) { |
|
99 | - if($i++ % 100 == 0) { |
|
98 | + foreach ($user_list as $player) { |
|
99 | + if ($i++ % 100 == 0) { |
|
100 | 100 | sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false); |
101 | 101 | } |
102 | - if(array_key_exists($user_id = $player['id'], $user_skip_list)) { |
|
102 | + if (array_key_exists($user_id = $player['id'], $user_skip_list)) { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | // $points[$user_id][UNIT_RESOURCES] += $resources; |
110 | 110 | |
111 | 111 | // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что |
112 | - if(!isset($user_skip_list[$user_id])) { |
|
112 | + if (!isset($user_skip_list[$user_id])) { |
|
113 | 113 | $user_allies[$user_id] = $player['ally_id']; |
114 | 114 | } |
115 | 115 | } |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | $i = 0; |
124 | 124 | $query = db_planet_list_resources_by_owner(); |
125 | 125 | $row_num = db_num_rows($query); |
126 | - while($planet = db_fetch($query)) { |
|
127 | - if($i++ % 100 == 0) { |
|
126 | + while ($planet = db_fetch($query)) { |
|
127 | + if ($i++ % 100 == 0) { |
|
128 | 128 | sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false); |
129 | 129 | } |
130 | - if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
|
130 | + if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | $i = 0; |
143 | 143 | $query = FleetList::dbQueryAllId(); |
144 | 144 | $row_num = db_num_rows($query); |
145 | - while($fleet_row = db_fetch($query)) { |
|
146 | - if($i++ % 100 == 0) { |
|
145 | + while ($fleet_row = db_fetch($query)) { |
|
146 | + if ($i++ % 100 == 0) { |
|
147 | 147 | sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false); |
148 | 148 | } |
149 | 149 | $objFleet = new Fleet(); |
@@ -151,15 +151,15 @@ discard block |
||
151 | 151 | // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными |
152 | 152 | // $objFleet->_reset(); |
153 | 153 | $objFleet->dbRowParse($fleet_row); |
154 | - if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) { |
|
154 | + if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) { |
|
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $fleet = $objFleet->shipsGetArray(); |
159 | - foreach($fleet as $unit_id => $unit_amount) { |
|
159 | + foreach ($fleet as $unit_id => $unit_amount) { |
|
160 | 160 | $counts[$user_id][UNIT_SHIPS] += $unit_amount; |
161 | 161 | |
162 | - if(!isset($unit_cost_cache[$unit_id][0])) { |
|
162 | + if (!isset($unit_cost_cache[$unit_id][0])) { |
|
163 | 163 | $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST); |
164 | 164 | } |
165 | 165 | $unit_cost_data = &$unit_cost_cache[$unit_id][0]; |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | $i = 0; |
180 | 180 | $query = db_unit_list_stat_calculate(); |
181 | 181 | $row_num = db_num_rows($query); |
182 | - while($unit = db_fetch($query)) { |
|
183 | - if($i++ % 100 == 0) { |
|
182 | + while ($unit = db_fetch($query)) { |
|
183 | + if ($i++ % 100 == 0) { |
|
184 | 184 | sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false); |
185 | 185 | } |
186 | - if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
|
186 | + if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
|
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | $i = 0; |
198 | 198 | $query = db_que_list_stat(); |
199 | 199 | $row_num = db_num_rows($query); |
200 | - while($que_item = db_fetch($query)) { |
|
201 | - if($i++ % 100 == 0) { |
|
200 | + while ($que_item = db_fetch($query)) { |
|
201 | + if ($i++ % 100 == 0) { |
|
202 | 202 | sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false); |
203 | 203 | } |
204 | - if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
|
204 | + if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
|
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | $que_unit_amount = $que_item['que_unit_amount']; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | sta_set_time_limit('posting new user stats to DB'); |
222 | 222 | $data = array(); |
223 | - foreach($user_allies as $user_id => $ally_id) { |
|
223 | + foreach ($user_allies as $user_id => $ally_id) { |
|
224 | 224 | // $counts[UNIT_RESOURCES] дублирует $points[UNIT_RESOURCES], поэтому $points не заполняем, а берем $counts и делим на 1000 |
225 | 225 | $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000; |
226 | 226 | $points[$user_id] = array_map('floor', $points[$user_id]); |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | $user_points = array_sum($points[$user_id]); |
233 | 233 | $user_counts = array_sum($counts[$user_id]); |
234 | 234 | |
235 | - $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}'," . |
|
236 | - "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}'," . |
|
237 | - "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}'," . |
|
238 | - "{$user_points},{$user_counts}," . SN_TIME_NOW . ")"; |
|
235 | + $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}',". |
|
236 | + "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}',". |
|
237 | + "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}',". |
|
238 | + "{$user_points},{$user_counts},".SN_TIME_NOW.")"; |
|
239 | 239 | |
240 | 240 | sys_stat_calculate_flush($data); |
241 | 241 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | SUM(u.`tech_points`)+aus.`tech_points`, SUM(u.`tech_count`)+aus.`tech_count`, SUM(u.`build_points`)+aus.`build_points`, SUM(u.`build_count`)+aus.`build_count`, |
256 | 256 | SUM(u.`defs_points`)+aus.`defs_points`, SUM(u.`defs_count`)+aus.`defs_count`, SUM(u.`fleet_points`)+aus.`fleet_points`, SUM(u.`fleet_count`)+aus.`fleet_count`, |
257 | 257 | SUM(u.`res_points`)+aus.`res_points`, SUM(u.`res_count`)+aus.`res_count`, SUM(u.`total_points`)+aus.`total_points`, SUM(u.`total_count`)+aus.`total_count`, |
258 | - " . SN_TIME_NOW . ", NULL, u.`id_ally`, 2, 1, |
|
258 | + " . SN_TIME_NOW.", NULL, u.`id_ally`, 2, 1, |
|
259 | 259 | a.tech_rank, a.build_rank, a.defs_rank, a.fleet_rank, a.res_rank, a.total_rank |
260 | 260 | FROM {{statpoints}} AS u |
261 | 261 | JOIN {{alliance}} AS al ON al.id = u.id_ally |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | // Updating player's ranks |
278 | 278 | sta_set_time_limit("updating ranks for players"); |
279 | - foreach($rankNames as $rankName) { |
|
279 | + foreach ($rankNames as $rankName) { |
|
280 | 280 | sta_set_time_limit("updating player rank '{$rankName}'", false); |
281 | 281 | doquery($qryResetRowNum); |
282 | 282 | doquery(sprintf($qryFormat, $rankName, 1)); |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | sta_set_time_limit("updating ranks for Alliances"); |
286 | 286 | // --- Updating Allie's ranks |
287 | - foreach($rankNames as $rankName) { |
|
287 | + foreach ($rankNames as $rankName) { |
|
288 | 288 | sta_set_time_limit("updating Alliances rank '{$rankName}'", false); |
289 | 289 | doquery($qryResetRowNum); |
290 | 290 | doquery(sprintf($qryFormat, $rankName, 2)); |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
5 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | -$page_title .= ' - ' . classLocale::$lang["eco_mrk_{$submode}"]; |
|
9 | +$page_title .= ' - '.classLocale::$lang["eco_mrk_{$submode}"]; |
|
10 | 10 | |
11 | 11 | $template = gettemplate('market_fleet', true); |
12 | 12 | $template->assign_vars(array( |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | 'rpg_cost' => $rpg_cost, |
15 | 15 | )); |
16 | 16 | |
17 | -if(is_array($shipList)) { |
|
18 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
17 | +if (is_array($shipList)) { |
|
18 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
19 | 19 | $intError = MARKET_NO_DM; |
20 | 20 | } |
21 | 21 | |
@@ -28,34 +28,34 @@ discard block |
||
28 | 28 | // Блокируем запись о запасах кораблей у трейдера |
29 | 29 | db_config_get_stockman_fleet(); |
30 | 30 | |
31 | - $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>'; |
|
31 | + $message .= classLocale::$lang["eco_mrk_{$submode}_ships"].'<ul>'; |
|
32 | 32 | $qry = array(); |
33 | 33 | $total = array(); |
34 | 34 | $db_changeset = array(); |
35 | - foreach($shipList as $shipID => &$shipCount) { |
|
35 | + foreach ($shipList as $shipID => &$shipCount) { |
|
36 | 36 | $shipCount = ceil(floatval($shipCount)); |
37 | - if(!$shipCount) { |
|
37 | + if (!$shipCount) { |
|
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | - if($shipCount < 0) { |
|
41 | + if ($shipCount < 0) { |
|
42 | 42 | classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
43 | 43 | $intError = MARKET_NEGATIVE_SHIPS; |
44 | 44 | break; |
45 | 45 | } |
46 | 46 | |
47 | - if($mode == MARKET_SCRAPPER) { |
|
47 | + if ($mode == MARKET_SCRAPPER) { |
|
48 | 48 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
49 | - } elseif($mode == MARKET_STOCKMAN) { |
|
49 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
50 | 50 | $amount = $stock[$shipID]; |
51 | 51 | } |
52 | 52 | |
53 | - if($amount < $shipCount) { |
|
53 | + if ($amount < $shipCount) { |
|
54 | 54 | $intError = $error_no_stock; |
55 | 55 | break; |
56 | 56 | } |
57 | 57 | |
58 | - if(!in_array($shipID, sn_get_groups('fleet'))) { |
|
58 | + if (!in_array($shipID, sn_get_groups('fleet'))) { |
|
59 | 59 | classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
60 | 60 | $intError = MARKET_NOT_A_SHIP; |
61 | 61 | break; |
@@ -71,16 +71,16 @@ discard block |
||
71 | 71 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
72 | 72 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
73 | 73 | |
74 | - foreach($resTemp as $resID => $resCount) { |
|
74 | + foreach ($resTemp as $resID => $resCount) { |
|
75 | 75 | $total[$resID] += $resCount; |
76 | 76 | } |
77 | 77 | |
78 | - $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount); |
|
78 | + $message .= "<li>{$classLocale['tech'][$shipID]}: ".pretty_number($shipCount); |
|
79 | 79 | } |
80 | 80 | |
81 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
82 | - foreach($total as $resID => $resCount) { |
|
83 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
81 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
82 | + foreach ($total as $resID => $resCount) { |
|
83 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
84 | 84 | $intError = MARKET_NO_RESOURCES; |
85 | 85 | classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
86 | 86 | break; |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | |
91 | 91 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
92 | 92 | |
93 | - if($intError == MARKET_DEAL) { |
|
94 | - $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>'; |
|
95 | - foreach($total as $resID => $resCount) { |
|
96 | - if(!$resCount) { |
|
93 | + if ($intError == MARKET_DEAL) { |
|
94 | + $message .= '</ul>'.classLocale::$lang["eco_mrk_{$submode}_res"].'<ul>'; |
|
95 | + foreach ($total as $resID => $resCount) { |
|
96 | + if (!$resCount) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // $newrow[$resID] = $planetrow[$resID] + $resCount * (-$multiplier); |
102 | 102 | $qry[] = "`{$resource_name}` = `{$resource_name}` + ({$resCount})"; |
103 | 103 | |
104 | - $message .= "<li>" . classLocale::$lang['sys_' . $resource_name] . ": " . pretty_number(abs($resCount)); |
|
104 | + $message .= "<li>".classLocale::$lang['sys_'.$resource_name].": ".pretty_number(abs($resCount)); |
|
105 | 105 | } |
106 | 106 | $message .= "</ul>"; |
107 | 107 | |
@@ -127,38 +127,38 @@ discard block |
||
127 | 127 | 'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError], |
128 | 128 | )); |
129 | 129 | |
130 | - foreach($shipList as $shipID => $shipCount) { |
|
130 | + foreach ($shipList as $shipID => $shipCount) { |
|
131 | 131 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | $message = ''; |
136 | 136 | |
137 | -if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
138 | - classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet')))); |
|
137 | +if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
138 | + classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet')))); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | tpl_set_resource_info($template, $planetrow, array()); |
142 | 142 | |
143 | -if(!$array) { |
|
143 | +if (!$array) { |
|
144 | 144 | $array = array(); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $group_fleet = sn_get_groups('fleet'); |
148 | -foreach($array as $key => $value) { |
|
149 | - if($mode == MARKET_SCRAPPER) { |
|
148 | +foreach ($array as $key => $value) { |
|
149 | + if ($mode == MARKET_SCRAPPER) { |
|
150 | 150 | $shipID = $value; |
151 | 151 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
152 | - } elseif($mode == MARKET_STOCKMAN) { |
|
152 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
153 | 153 | $shipID = $key; |
154 | 154 | $amount = $value; |
155 | 155 | } |
156 | 156 | |
157 | - if(!in_array($shipID, $group_fleet)) { |
|
157 | + if (!in_array($shipID, $group_fleet)) { |
|
158 | 158 | continue; |
159 | 159 | } |
160 | 160 | |
161 | - if($amount > 0) { |
|
161 | + if ($amount > 0) { |
|
162 | 162 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
163 | 163 | $template->assign_block_vars('ships', array( |
164 | 164 | 'ID' => $shipID, |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | $destination_planet = &$mission_data->dst_planet; |
16 | 16 | |
17 | - if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
17 | + if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
18 | 18 | $objFleet->markReturnedAndSave(); |
19 | 19 | |
20 | 20 | return CACHE_FLEET; |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | $fleet_resources[RES_METAL], classLocale::$lang['Metal'], |
28 | 28 | $fleet_resources[RES_CRYSTAL], classLocale::$lang['Crystal'], |
29 | 29 | $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium'] |
30 | - ) . '<br />' . classLocale::$lang['sys_relocate_mess_user']; |
|
30 | + ).'<br />'.classLocale::$lang['sys_relocate_mess_user']; |
|
31 | 31 | $fleet_real_array = $objFleet->shipsGetArray(); |
32 | - foreach($fleet_real_array as $ship_id => $ship_count) { |
|
33 | - $Message .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; |
|
32 | + foreach ($fleet_real_array as $ship_id => $ship_count) { |
|
33 | + $Message .= classLocale::$lang['tech'][$ship_id].' - '.$ship_count.'<br />'; |
|
34 | 34 | } |
35 | 35 | msg_send_simple_message( |
36 | 36 | $objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, |
@@ -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,17 +8,17 @@ 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) { |
|
18 | - $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
|
16 | + if (!(strpos($query, '{{') === false)) { |
|
17 | + foreach ($update_tables as $tableName => $cork) { |
|
18 | + $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix.$tableName, $query); |
|
19 | 19 | } |
20 | 20 | } |
21 | - !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for ' . $query . ': ' . db_error()) : false; |
|
21 | + !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for '.$query.': '.db_error()) : false; |
|
22 | 22 | |
23 | 23 | return $result; |
24 | 24 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | global $sys_log_disabled; |
28 | 28 | |
29 | 29 | classSupernova::$config->db_loadItem($key); |
30 | - if($condition || !isset(classSupernova::$config->$key)) { |
|
30 | + if ($condition || !isset(classSupernova::$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 | classSupernova::$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; |
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 | } |
@@ -85,23 +85,23 @@ discard block |
||
85 | 85 | global $update_tables, $update_indexes, $update_indexes_full, $update_foreigns; |
86 | 86 | |
87 | 87 | $tableName = $prefixed ? str_replace(classSupernova::$config->db_prefix, '', $prefix_table_name) : $prefix_table_name; |
88 | - $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix . $prefix_table_name; |
|
88 | + $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix.$prefix_table_name; |
|
89 | 89 | |
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 | - $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)) { |
|
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)) { |
|
105 | 105 | $table_referenced = str_replace(classSupernova::$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']};"; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @return bool|mysqli_result|void |
117 | 117 | */ |
118 | 118 | function upd_alter_table($table, $alters, $condition = true) { |
119 | - if(!$condition) { |
|
119 | + if (!$condition) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $alters_print = is_array($alters) ? dump($alters) : $alters; |
125 | 125 | upd_log_message("Altering table '{$table}' with alterations {$alters_print}"); |
126 | 126 | |
127 | - if(!is_array($alters)) { |
|
127 | + if (!is_array($alters)) { |
|
128 | 128 | $alters = array($alters); |
129 | 129 | } |
130 | 130 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $result = upd_do_query($qry); |
135 | 135 | $error = db_error(); |
136 | - if($error) { |
|
136 | + if ($error) { |
|
137 | 137 | die("Altering error for table `{$table}`: {$error}<br />{$alters_print}"); |
138 | 138 | } |
139 | 139 | |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | function upd_create_table($table_name, $declaration) { |
153 | 153 | global $update_tables; |
154 | 154 | |
155 | - if(!$update_tables[$table_name]) { |
|
155 | + if (!$update_tables[$table_name]) { |
|
156 | 156 | upd_do_query('set foreign_key_checks = 0;', true); |
157 | 157 | $db_prefix = classSupernova::$config->db_prefix; |
158 | 158 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
159 | 159 | $error = db_error(); |
160 | - if($error) { |
|
161 | - die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
|
160 | + if ($error) { |
|
161 | + die("Creating error for table `{$table_name}`: {$error}<br />".dump($declaration)); |
|
162 | 162 | } |
163 | 163 | upd_do_query('set foreign_key_checks = 1;', true); |
164 | 164 | upd_load_table_info($table_name, false); |
@@ -173,24 +173,24 @@ discard block |
||
173 | 173 | "SELECT {$fields} |
174 | 174 | FROM {{unit}} |
175 | 175 | WHERE |
176 | - `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND " . db_unit_time_restrictions() . |
|
177 | - ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
178 | - ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '') . |
|
179 | - " LIMIT 1" . |
|
176 | + `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND ".db_unit_time_restrictions(). |
|
177 | + ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
178 | + ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : ''). |
|
179 | + " LIMIT 1". |
|
180 | 180 | ($for_update ? ' FOR UPDATE' : '') |
181 | 181 | )); |
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | 185 | function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) { |
186 | - if(!is_array($user)) { |
|
186 | + if (!is_array($user)) { |
|
187 | 187 | // TODO - remove later |
188 | 188 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>'); |
189 | 189 | pdump(debug_backtrace()); |
190 | 190 | die('USER is not ARRAY'); |
191 | 191 | } |
192 | 192 | |
193 | - if(!isset($user['id']) || !$user['id']) { |
|
193 | + if (!isset($user['id']) || !$user['id']) { |
|
194 | 194 | // TODO - remove later |
195 | 195 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>'); |
196 | 196 | pdump($user); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $db_changeset = array(); |
207 | 207 | $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
208 | - if($temp['unit_id']) { |
|
208 | + if ($temp['unit_id']) { |
|
209 | 209 | // update |
210 | 210 | $db_changeset = array( |
211 | 211 | 'action' => SQL_OP_UPDATE, |
@@ -250,41 +250,41 @@ discard block |
||
250 | 250 | |
251 | 251 | |
252 | 252 | function upd_db_changeset_apply($db_changeset) { |
253 | - if(!is_array($db_changeset) || empty($db_changeset)) { |
|
253 | + if (!is_array($db_changeset) || empty($db_changeset)) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | - foreach($db_changeset as $table_name => $table_data) { |
|
258 | - foreach($table_data as $record_id => $conditions) { |
|
257 | + foreach ($db_changeset as $table_name => $table_data) { |
|
258 | + foreach ($table_data as $record_id => $conditions) { |
|
259 | 259 | $where = ''; |
260 | - if(!empty($conditions['where'])) { |
|
261 | - $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
|
260 | + if (!empty($conditions['where'])) { |
|
261 | + $where = 'WHERE '.implode(' AND ', $conditions['where']); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | $fields = array(); |
265 | - if($conditions['fields']) { |
|
266 | - foreach($conditions['fields'] as $field_name => $field_data) { |
|
265 | + if ($conditions['fields']) { |
|
266 | + foreach ($conditions['fields'] as $field_name => $field_data) { |
|
267 | 267 | $condition = "`{$field_name}` = "; |
268 | 268 | $value = ''; |
269 | - if($field_data['delta']) { |
|
270 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
271 | - } elseif($field_data['set']) { |
|
269 | + if ($field_data['delta']) { |
|
270 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
271 | + } elseif ($field_data['set']) { |
|
272 | 272 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
273 | 273 | } |
274 | - if($value) { |
|
275 | - $fields[] = $condition . $value; |
|
274 | + if ($value) { |
|
275 | + $fields[] = $condition.$value; |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | 279 | $fields = implode(',', $fields); |
280 | 280 | |
281 | - switch($conditions['action']) { |
|
281 | + switch ($conditions['action']) { |
|
282 | 282 | case SQL_OP_DELETE: |
283 | 283 | upd_do_query("DELETE FROM {{{$table_name}}} {$where}"); |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case SQL_OP_UPDATE: |
287 | - if($fields) { |
|
287 | + if ($fields) { |
|
288 | 288 | /*if($table_name == 'unit') |
289 | 289 | { |
290 | 290 | pdump("UPDATE {{{$table_name}}} SET {$fields} {$where}"); |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | break; |
296 | 296 | |
297 | 297 | case SQL_OP_INSERT: |
298 | - if($fields) { |
|
298 | + if ($fields) { |
|
299 | 299 | upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}"); |
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case SQL_OP_REPLACE: |
304 | - if($fields) { |
|
304 | + if ($fields) { |
|
305 | 305 | upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}"); |
306 | 306 | } |
307 | 307 | break; |
@@ -2,32 +2,32 @@ discard block |
||
2 | 2 | |
3 | 3 | function sys_avatar_upload($subject_id, &$avatar_field, $prefix = 'avatar') { |
4 | 4 | try { |
5 | - $avatar_filename = $fullsize_filename = SN_ROOT_PHYSICAL . 'images/avatar/' . $prefix . '_' . $subject_id; |
|
5 | + $avatar_filename = $fullsize_filename = SN_ROOT_PHYSICAL.'images/avatar/'.$prefix.'_'.$subject_id; |
|
6 | 6 | $avatar_filename .= '.png'; |
7 | 7 | $fullsize_filename .= '_full.png'; |
8 | - if(sys_get_param_int('avatar_remove')) { |
|
9 | - if(file_exists($avatar_filename) && !unlink($avatar_filename)) { |
|
8 | + if (sys_get_param_int('avatar_remove')) { |
|
9 | + if (file_exists($avatar_filename) && !unlink($avatar_filename)) { |
|
10 | 10 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR); |
11 | 11 | } |
12 | 12 | $avatar_field = 0; |
13 | 13 | throw new Exception(classLocale::$lang['opt_msg_avatar_removed'], ERR_NONE); |
14 | - } elseif($_FILES['avatar']['size']) { |
|
15 | - if(!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) { |
|
14 | + } elseif ($_FILES['avatar']['size']) { |
|
15 | + if (!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) { |
|
16 | 16 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING); |
17 | 17 | } |
18 | 18 | |
19 | - if($_FILES['avatar']['error']) { |
|
19 | + if ($_FILES['avatar']['error']) { |
|
20 | 20 | throw new Exception(sprintf(classLocale::$lang['opt_msg_avatar_error_upload'], $_FILES['avatar']['error']), ERR_ERROR); |
21 | 21 | } |
22 | 22 | |
23 | - if(!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) { |
|
23 | + if (!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) { |
|
24 | 24 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING); |
25 | 25 | } |
26 | 26 | |
27 | 27 | $avatar_size = getimagesize($_FILES['avatar']['tmp_name']); |
28 | 28 | $avatar_max_width = classSupernova::$config->avatar_max_width; |
29 | 29 | $avatar_max_height = classSupernova::$config->avatar_max_height; |
30 | - if($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) { |
|
30 | + if ($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) { |
|
31 | 31 | $aspect_ratio = min($avatar_max_width / $avatar_size[0], $avatar_max_height / $avatar_size[1]); |
32 | 32 | $avatar_image_new = imagecreatetruecolor($avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio); |
33 | 33 | $result = imagecopyresized($avatar_image_new, $avatar_image, 0, 0, 0, 0, $avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio, $avatar_size[0], $avatar_size[1]); |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | $avatar_image = $avatar_image_new; |
36 | 36 | } |
37 | 37 | |
38 | - if(file_exists($avatar_filename) && !unlink($avatar_filename)) { |
|
38 | + if (file_exists($avatar_filename) && !unlink($avatar_filename)) { |
|
39 | 39 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR); |
40 | 40 | } |
41 | 41 | |
42 | - if(!imagepng($avatar_image, $avatar_filename, 9)) { |
|
42 | + if (!imagepng($avatar_image, $avatar_filename, 9)) { |
|
43 | 43 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_writing'], ERR_ERROR); |
44 | 44 | } |
45 | 45 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | imagedestroy($avatar_image); |
48 | 48 | throw new Exception(classLocale::$lang['opt_msg_avatar_uploaded'], ERR_NONE); |
49 | 49 | } |
50 | - } catch(Exception $e) { |
|
50 | + } catch (Exception $e) { |
|
51 | 51 | return array( |
52 | 52 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
53 | 53 | 'MESSAGE' => $e->getMessage() |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | global $who; |
12 | 12 | |
13 | 13 | // $sn_group_stat_common = sn_get_groups('STAT_COMMON'); |
14 | - foreach($array as $key => $value) { |
|
15 | - if($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { |
|
14 | + foreach ($array as $key => $value) { |
|
15 | + if ($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { |
|
16 | 16 | continue; |
17 | 17 | } |
18 | 18 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | $allow_anonymous = true; |
30 | 30 | |
31 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
31 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
32 | 32 | |
33 | 33 | lng_include('stat'); |
34 | 34 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $subject_list = array( |
45 | 45 | 1 => array('header' => classLocale::$lang['stat_player']), |
46 | 46 | ); |
47 | -if(!$source) { |
|
47 | +if (!$source) { |
|
48 | 48 | $subject_list[2] = array('header' => classLocale::$lang['stat_allys']); |
49 | 49 | } |
50 | 50 | stat_tpl_assign($template, $who, 'subject', $subject_list, $sn_group_stat_common); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | $page_count = floor($record_count / 100); |
115 | 115 | $pages = array(); |
116 | -for($i = 0; $i <= $page_count; $i++) { |
|
116 | +for ($i = 0; $i <= $page_count; $i++) { |
|
117 | 117 | $first_element = $i * 100 + 1; |
118 | 118 | $last_element = $first_element + 99; |
119 | 119 | $pages[$first_element] = array( |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ); |
134 | 134 | //pdump($row); |
135 | 135 | |
136 | - if($who == 1) { |
|
136 | + if ($who == 1) { |
|
137 | 137 | $row_stat['ALLY_NAME'] = $row['ally_name']; |
138 | 138 | $row_stat['ALLY_ID'] = $row['ally_id']; |
139 | 139 | empty($row['username']) ? $row['username'] = $row['name'] : false; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * Galaxy view |
7 | 7 | */ |
8 | 8 | |
9 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
9 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
10 | 10 | |
11 | 11 | lng_include('universe'); |
12 | 12 | lng_include('stat'); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $uni_system = sys_get_param_int('system', $planetrow['system']); |
17 | 17 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
18 | 18 | |
19 | -if($mode == 'name') { |
|
19 | +if ($mode == 'name') { |
|
20 | 20 | require_once('includes/includes/uni_rename.php'); |
21 | 21 | } |
22 | 22 | |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | |
38 | 38 | $flying_fleet_count = FleetList::fleet_count_flying($user['id']); |
39 | 39 | |
40 | -if($mode == 1) { |
|
41 | -} elseif($mode == 2 || $mode == 3) { |
|
40 | +if ($mode == 1) { |
|
41 | +} elseif ($mode == 2 || $mode == 3) { |
|
42 | 42 | $planet = $planetrow['planet']; |
43 | 43 | } else { |
44 | 44 | $uni_galaxy = $planetrow['galaxy']; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $planet = $planetrow['planet']; |
47 | 47 | } |
48 | 48 | |
49 | -$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies? Vector::$knownGalaxies: $uni_galaxy); |
|
49 | +$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies ? Vector::$knownGalaxies : $uni_galaxy); |
|
50 | 50 | $uni_system = $uni_system < 1 ? 1 : ($uni_system > Vector::$knownSystems ? Vector::$knownSystems : $uni_system); |
51 | 51 | $planet = $planet < 1 ? 1 : ($planet > Vector::$knownPlanets + 1 ? Vector::$knownPlanets + 1 : $planet); |
52 | 52 | |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $PhalanxRange = GetPhalanxRange($HavePhalanx); |
65 | 65 | |
66 | 66 | $planet_precache_query = db_planet_list_in_system($uni_galaxy, $uni_system); |
67 | -if(!empty($planet_precache_query)) { |
|
68 | - foreach($planet_precache_query as $planet_row) { |
|
67 | +if (!empty($planet_precache_query)) { |
|
68 | + foreach ($planet_precache_query as $planet_row) { |
|
69 | 69 | $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row; |
70 | 70 | } |
71 | 71 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * @var Fleet[][][] $fleet_list |
84 | 84 | */ |
85 | 85 | $fleet_list = array(); |
86 | -foreach($system_fleet_list->_container as $objFleetSystem) { |
|
87 | - if(!$objFleetSystem->isReturning()) { |
|
86 | +foreach ($system_fleet_list->_container as $objFleetSystem) { |
|
87 | + if (!$objFleetSystem->isReturning()) { |
|
88 | 88 | $fleet_planet = $objFleetSystem->fleet_end_planet; |
89 | 89 | $fleet_type = $objFleetSystem->fleet_end_type; |
90 | 90 | } else { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $recycler_info = array(); |
100 | 100 | $planet_recyclers_orbiting = 0; |
101 | 101 | $recyclers_fleet = array(); |
102 | -foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
102 | +foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
|
103 | 103 | $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user); |
104 | 104 | $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id); |
105 | 105 | $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id]; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $fleet_id = 1; |
110 | 110 | $fleets = array(); |
111 | 111 | $config_game_max_planet = Vector::$knownPlanets + 1; |
112 | -for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) { |
|
112 | +for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) { |
|
113 | 113 | unset($uni_galaxyRowPlanet); |
114 | 114 | unset($uni_galaxyRowMoon); |
115 | 115 | unset($uni_galaxyRowUser); |
@@ -119,27 +119,27 @@ discard block |
||
119 | 119 | $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET]; |
120 | 120 | |
121 | 121 | $planet_fleet_id = 0; |
122 | - if($uni_galaxyRowPlanet['destruyed']) { |
|
122 | + if ($uni_galaxyRowPlanet['destruyed']) { |
|
123 | 123 | CheckAbandonPlanetState($uni_galaxyRowPlanet); |
124 | - } elseif($uni_galaxyRowPlanet['id']) { |
|
125 | - if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) { |
|
124 | + } elseif ($uni_galaxyRowPlanet['id']) { |
|
125 | + if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) { |
|
126 | 126 | $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']]; |
127 | 127 | } else { |
128 | 128 | $uni_galaxyRowUser = db_user_by_id($uni_galaxyRowPlanet['id_owner']); |
129 | 129 | $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser; |
130 | 130 | } |
131 | 131 | |
132 | - if(!$uni_galaxyRowUser['id']) { |
|
132 | + if (!$uni_galaxyRowUser['id']) { |
|
133 | 133 | classSupernova::$debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503); |
134 | 134 | $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24; |
135 | 135 | $uni_galaxyRowPlanet['id_owner'] = 0; |
136 | 136 | db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}"); |
137 | 137 | } |
138 | 138 | |
139 | - if($uni_galaxyRowUser['id']) { |
|
139 | + if ($uni_galaxyRowUser['id']) { |
|
140 | 140 | $planetcount++; |
141 | - if($uni_galaxyRowUser['ally_id']) { |
|
142 | - if($cached['allies'][$uni_galaxyRowUser['ally_id']]) { |
|
141 | + if ($uni_galaxyRowUser['ally_id']) { |
|
142 | + if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) { |
|
143 | 143 | $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']]; |
144 | 144 | } else { |
145 | 145 | $allyquery = db_ally_get_by_id($uni_galaxyRowUser['ally_id']); |
@@ -148,19 +148,19 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]); |
151 | - if(!empty($fleets_to_planet['own']['count'])) { |
|
151 | + if (!empty($fleets_to_planet['own']['count'])) { |
|
152 | 152 | $planet_fleet_id = $fleet_id; |
153 | 153 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
154 | 154 | $fleet_id++; |
155 | 155 | } |
156 | 156 | |
157 | 157 | $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON]; |
158 | - if($uni_galaxyRowMoon['destruyed']) { |
|
158 | + if ($uni_galaxyRowMoon['destruyed']) { |
|
159 | 159 | CheckAbandonPlanetState($uni_galaxyRowMoon); |
160 | 160 | } else { |
161 | 161 | $moon_fleet_id = 0; |
162 | 162 | $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]); |
163 | - if(!empty($fleets_to_planet['own']['count'])) { |
|
163 | + if (!empty($fleets_to_planet['own']['count'])) { |
|
164 | 164 | $moon_fleet_id = $fleet_id; |
165 | 165 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
166 | 166 | $fleet_id++; |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | |
172 | 172 | $recyclers_incoming_capacity = 0; |
173 | 173 | $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal']; |
174 | - if($uni_galaxyRowPlanet['debris']) { |
|
175 | - if(!empty($fleet_list[$Planet][PT_DEBRIS])) { |
|
176 | - foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) { |
|
177 | - if($objFleetToDebris->playerOwnerId == $user['id']) { |
|
174 | + if ($uni_galaxyRowPlanet['debris']) { |
|
175 | + if (!empty($fleet_list[$Planet][PT_DEBRIS])) { |
|
176 | + foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) { |
|
177 | + if ($objFleetToDebris->playerOwnerId == $user['id']) { |
|
178 | 178 | $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info); |
179 | 179 | } |
180 | 180 | } |
@@ -251,21 +251,21 @@ discard block |
||
251 | 251 | |
252 | 252 | tpl_assign_fleet($template, $fleets); |
253 | 253 | |
254 | -foreach(sn_get_groups('defense_active') as $unit_id) { |
|
254 | +foreach (sn_get_groups('defense_active') as $unit_id) { |
|
255 | 255 | $template->assign_block_vars('defense_active', array( |
256 | 256 | 'ID' => $unit_id, |
257 | 257 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
258 | 258 | )); |
259 | 259 | } |
260 | 260 | |
261 | -foreach($cached['users'] as $PlanetUser) { |
|
262 | - if(!$PlanetUser) { |
|
261 | +foreach ($cached['users'] as $PlanetUser) { |
|
262 | + if (!$PlanetUser) { |
|
263 | 263 | continue; |
264 | 264 | } |
265 | 265 | |
266 | 266 | $user_ally = $cached['allies'][$PlanetUser['ally_id']]; |
267 | - if(isset($user_ally)) { |
|
268 | - if($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
267 | + if (isset($user_ally)) { |
|
268 | + if ($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
269 | 269 | $user_rank_title = $user_ally['ally_owner_range']; |
270 | 270 | } else { |
271 | 271 | $ally_ranks = explode(';', $user_ally['ranklist']); |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | )); |
289 | 289 | } |
290 | 290 | |
291 | -foreach($cached['allies'] as $PlanetAlly) { |
|
292 | - if($PlanetAlly) { |
|
291 | +foreach ($cached['allies'] as $PlanetAlly) { |
|
292 | + if ($PlanetAlly) { |
|
293 | 293 | $template->assign_block_vars('alliances', array( |
294 | 294 | 'ID' => $PlanetAlly['id'], |
295 | 295 | 'NAME_JS' => js_safe_string($PlanetAlly['ally_name']), |