@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
3 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
4 | 4 | $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | 'rpg_cost' => $rpg_cost, |
13 | 13 | )); |
14 | 14 | |
15 | -if(is_array($shipList)) { |
|
16 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
15 | +if (is_array($shipList)) { |
|
16 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
17 | 17 | $intError = MARKET_NO_DM; |
18 | 18 | } |
19 | 19 | |
@@ -30,30 +30,30 @@ discard block |
||
30 | 30 | $qry = array(); |
31 | 31 | $total = array(); |
32 | 32 | $db_changeset = array(); |
33 | - foreach($shipList as $shipID => &$shipCount) { |
|
33 | + foreach ($shipList as $shipID => &$shipCount) { |
|
34 | 34 | $shipCount = ceil(floatval($shipCount)); |
35 | - if(!$shipCount) { |
|
35 | + if (!$shipCount) { |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
39 | - if($shipCount < 0) { |
|
39 | + if ($shipCount < 0) { |
|
40 | 40 | $debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
41 | 41 | $intError = MARKET_NEGATIVE_SHIPS; |
42 | 42 | break; |
43 | 43 | } |
44 | 44 | |
45 | - if($mode == MARKET_SCRAPPER) { |
|
45 | + if ($mode == MARKET_SCRAPPER) { |
|
46 | 46 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
47 | - } elseif($mode == MARKET_STOCKMAN) { |
|
47 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
48 | 48 | $amount = $stock[$shipID]; |
49 | 49 | } |
50 | 50 | |
51 | - if($amount < $shipCount) { |
|
51 | + if ($amount < $shipCount) { |
|
52 | 52 | $intError = $error_no_stock; |
53 | 53 | break; |
54 | 54 | } |
55 | 55 | |
56 | - if(!in_array($shipID, sn_get_groups('fleet'))) { |
|
56 | + if (!in_array($shipID, sn_get_groups('fleet'))) { |
|
57 | 57 | $debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
58 | 58 | $intError = MARKET_NOT_A_SHIP; |
59 | 59 | break; |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
70 | 70 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
71 | 71 | |
72 | - foreach($resTemp as $resID => $resCount) { |
|
72 | + foreach ($resTemp as $resID => $resCount) { |
|
73 | 73 | $total[$resID] += $resCount; |
74 | 74 | } |
75 | 75 | |
76 | 76 | $message .= "<li>{$lang['tech'][$shipID]}: " . pretty_number($shipCount); |
77 | 77 | } |
78 | 78 | |
79 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
80 | - foreach($total as $resID => $resCount) { |
|
81 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
79 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
80 | + foreach ($total as $resID => $resCount) { |
|
81 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
82 | 82 | $intError = MARKET_NO_RESOURCES; |
83 | 83 | $debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
84 | 84 | break; |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | |
89 | 89 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
90 | 90 | |
91 | - if($intError == MARKET_DEAL) { |
|
91 | + if ($intError == MARKET_DEAL) { |
|
92 | 92 | $message .= '</ul>' . $lang["eco_mrk_{$submode}_res"] . '<ul>'; |
93 | - foreach($total as $resID => $resCount) { |
|
94 | - if(!$resCount) { |
|
93 | + foreach ($total as $resID => $resCount) { |
|
94 | + if (!$resCount) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | |
@@ -125,38 +125,38 @@ discard block |
||
125 | 125 | 'MESSAGE' => $lang['eco_mrk_errors'][$intError], |
126 | 126 | )); |
127 | 127 | |
128 | - foreach($shipList as $shipID => $shipCount) { |
|
128 | + foreach ($shipList as $shipID => $shipCount) { |
|
129 | 129 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
133 | 133 | $message = ''; |
134 | 134 | |
135 | -if(!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) { |
|
136 | - $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet')))); |
|
135 | +if (!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) { |
|
136 | + $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet')))); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | tpl_set_resource_info($template, $planetrow, array()); |
140 | 140 | |
141 | -if(!$array) { |
|
141 | +if (!$array) { |
|
142 | 142 | $array = array(); |
143 | 143 | } |
144 | 144 | |
145 | 145 | $group_fleet = sn_get_groups('fleet'); |
146 | -foreach($array as $key => $value) { |
|
147 | - if($mode == MARKET_SCRAPPER) { |
|
146 | +foreach ($array as $key => $value) { |
|
147 | + if ($mode == MARKET_SCRAPPER) { |
|
148 | 148 | $shipID = $value; |
149 | 149 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
150 | - } elseif($mode == MARKET_STOCKMAN) { |
|
150 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
151 | 151 | $shipID = $key; |
152 | 152 | $amount = $value; |
153 | 153 | } |
154 | 154 | |
155 | - if(!in_array($shipID, $group_fleet)) { |
|
155 | + if (!in_array($shipID, $group_fleet)) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | 158 | |
159 | - if($amount > 0) { |
|
159 | + if ($amount > 0) { |
|
160 | 160 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
161 | 161 | $template->assign_block_vars('ships', array( |
162 | 162 | 'ID' => $shipID, |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | global $config; |
8 | 8 | |
9 | 9 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
10 | - if($combat_data[UBE_REPORT_CYPHER]) |
|
10 | + if ($combat_data[UBE_REPORT_CYPHER]) |
|
11 | 11 | { |
12 | 12 | return false; |
13 | 13 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | $combat_data[UBE_REPORT_CYPHER] = sys_random_string(32); |
19 | 19 | } |
20 | - while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$combat_data[UBE_REPORT_CYPHER]}' LIMIT 1 FOR UPDATE", true)); |
|
20 | + while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$combat_data[UBE_REPORT_CYPHER]}' LIMIT 1 FOR UPDATE", true)); |
|
21 | 21 | |
22 | 22 | // Инициализация таблицы для пакетной вставки информации |
23 | 23 | $sql_perform = array( |
@@ -113,55 +113,55 @@ discard block |
||
113 | 113 | `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $combat_data[UBE_TIME]) . "', |
114 | 114 | `ube_report_time_spent` = {$combat_data[UBE_TIME_SPENT]}, |
115 | 115 | |
116 | - `ube_report_combat_admin` = " . (int)$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] . ", |
|
116 | + `ube_report_combat_admin` = " . (int) $combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] . ", |
|
117 | 117 | `ube_report_mission_type` = {$combat_data[UBE_OPTIONS][UBE_MISSION_TYPE]}, |
118 | 118 | |
119 | 119 | `ube_report_combat_result` = {$outcome[UBE_COMBAT_RESULT]}, |
120 | - `ube_report_combat_sfr` = " . (int)$outcome[UBE_SFR] .", |
|
120 | + `ube_report_combat_sfr` = " . (int) $outcome[UBE_SFR] . ", |
|
121 | 121 | |
122 | - `ube_report_debris_metal` = " . (float)$outcome[UBE_DEBRIS][RES_METAL] . ", |
|
123 | - `ube_report_debris_crystal` = " . (float)$outcome[UBE_DEBRIS][RES_CRYSTAL] . ", |
|
122 | + `ube_report_debris_metal` = " . (float) $outcome[UBE_DEBRIS][RES_METAL] . ", |
|
123 | + `ube_report_debris_crystal` = " . (float) $outcome[UBE_DEBRIS][RES_CRYSTAL] . ", |
|
124 | 124 | `ube_report_debris_total_in_metal` = " . $ube_report_debris_total_in_metal . ", |
125 | 125 | |
126 | - `ube_report_planet_id` = " . (int)$outcome[UBE_PLANET][PLANET_ID] . ", |
|
126 | + `ube_report_planet_id` = " . (int) $outcome[UBE_PLANET][PLANET_ID] . ", |
|
127 | 127 | `ube_report_planet_name` = '" . db_escape($outcome[UBE_PLANET][PLANET_NAME]) . "', |
128 | - `ube_report_planet_size` = " . (int)$outcome[UBE_PLANET][PLANET_SIZE] . ", |
|
129 | - `ube_report_planet_galaxy` = " . (int)$outcome[UBE_PLANET][PLANET_GALAXY] . ", |
|
130 | - `ube_report_planet_system` = " . (int)$outcome[UBE_PLANET][PLANET_SYSTEM] . ", |
|
131 | - `ube_report_planet_planet` = " . (int)$outcome[UBE_PLANET][PLANET_PLANET] . ", |
|
132 | - `ube_report_planet_planet_type` = " . (int)$outcome[UBE_PLANET][PLANET_TYPE] . ", |
|
128 | + `ube_report_planet_size` = " . (int) $outcome[UBE_PLANET][PLANET_SIZE] . ", |
|
129 | + `ube_report_planet_galaxy` = " . (int) $outcome[UBE_PLANET][PLANET_GALAXY] . ", |
|
130 | + `ube_report_planet_system` = " . (int) $outcome[UBE_PLANET][PLANET_SYSTEM] . ", |
|
131 | + `ube_report_planet_planet` = " . (int) $outcome[UBE_PLANET][PLANET_PLANET] . ", |
|
132 | + `ube_report_planet_planet_type` = " . (int) $outcome[UBE_PLANET][PLANET_TYPE] . ", |
|
133 | 133 | |
134 | - `ube_report_moon` = " . (int)$outcome[UBE_MOON] .", |
|
135 | - `ube_report_moon_chance` = " . (int)$outcome[UBE_MOON_CHANCE] . ", |
|
136 | - `ube_report_moon_size` = " . (float)$outcome[UBE_MOON_SIZE] . ", |
|
134 | + `ube_report_moon` = " . (int) $outcome[UBE_MOON] . ", |
|
135 | + `ube_report_moon_chance` = " . (int) $outcome[UBE_MOON_CHANCE] . ", |
|
136 | + `ube_report_moon_size` = " . (float) $outcome[UBE_MOON_SIZE] . ", |
|
137 | 137 | |
138 | - `ube_report_moon_reapers` = " . (int)$outcome[UBE_MOON_REAPERS] . ", |
|
139 | - `ube_report_moon_destroy_chance` = " . (int)$outcome[UBE_MOON_DESTROY_CHANCE] . ", |
|
140 | - `ube_report_moon_reapers_die_chance` = " . (int)$outcome[UBE_MOON_REAPERS_DIE_CHANCE] . ", |
|
138 | + `ube_report_moon_reapers` = " . (int) $outcome[UBE_MOON_REAPERS] . ", |
|
139 | + `ube_report_moon_destroy_chance` = " . (int) $outcome[UBE_MOON_DESTROY_CHANCE] . ", |
|
140 | + `ube_report_moon_reapers_die_chance` = " . (int) $outcome[UBE_MOON_REAPERS_DIE_CHANCE] . ", |
|
141 | 141 | |
142 | - `ube_report_capture_result` = " . (int)$outcome[UBE_CAPTURE_RESULT] . " |
|
142 | + `ube_report_capture_result` = " . (int) $outcome[UBE_CAPTURE_RESULT] . " |
|
143 | 143 | "); |
144 | 144 | $ube_report_id = $combat_data[UBE_REPORT_ID] = db_insert_id(); |
145 | 145 | |
146 | 146 | // Сохраняем общую информацию по игрокам |
147 | - foreach($combat_data[UBE_PLAYERS] as $player_id => &$player_info) |
|
147 | + foreach ($combat_data[UBE_PLAYERS] as $player_id => &$player_info) |
|
148 | 148 | { |
149 | 149 | $sql_perform['ube_report_player'][] = array( |
150 | 150 | $ube_report_id, |
151 | 151 | $player_id, |
152 | 152 | |
153 | 153 | "'" . db_escape($player_info[UBE_NAME]) . "'", |
154 | - (int)$player_info[UBE_ATTACKER], |
|
154 | + (int) $player_info[UBE_ATTACKER], |
|
155 | 155 | |
156 | - (float)$player_info[UBE_BONUSES][UBE_ATTACK], |
|
157 | - (float)$player_info[UBE_BONUSES][UBE_SHIELD], |
|
158 | - (float)$player_info[UBE_BONUSES][UBE_ARMOR], |
|
156 | + (float) $player_info[UBE_BONUSES][UBE_ATTACK], |
|
157 | + (float) $player_info[UBE_BONUSES][UBE_SHIELD], |
|
158 | + (float) $player_info[UBE_BONUSES][UBE_ARMOR], |
|
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
162 | 162 | // Всякая информация по флотам |
163 | 163 | $unit_sort_order = 0; |
164 | - foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) |
|
164 | + foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) |
|
165 | 165 | { |
166 | 166 | // Сохраняем общую информацию по флотам |
167 | 167 | $sql_perform['ube_report_fleet'][] = array( |
@@ -169,20 +169,20 @@ discard block |
||
169 | 169 | $fleet_info[UBE_OWNER], |
170 | 170 | $fleet_id, |
171 | 171 | |
172 | - (float)$fleet_info[UBE_PLANET][PLANET_ID], |
|
172 | + (float) $fleet_info[UBE_PLANET][PLANET_ID], |
|
173 | 173 | "'" . db_escape($fleet_info[UBE_PLANET][PLANET_NAME]) . "'", |
174 | - (int)$fleet_info[UBE_PLANET][PLANET_GALAXY], |
|
175 | - (int)$fleet_info[UBE_PLANET][PLANET_SYSTEM], |
|
176 | - (int)$fleet_info[UBE_PLANET][PLANET_PLANET], |
|
177 | - (int)$fleet_info[UBE_PLANET][PLANET_TYPE], |
|
178 | - |
|
179 | - (float)$fleet_info[UBE_RESOURCES][RES_METAL], |
|
180 | - (float)$fleet_info[UBE_RESOURCES][RES_CRYSTAL], |
|
181 | - (float)$fleet_info[UBE_RESOURCES][RES_DEUTERIUM], |
|
182 | - |
|
183 | - (float)$fleet_info[UBE_BONUSES][UBE_ATTACK], |
|
184 | - (float)$fleet_info[UBE_BONUSES][UBE_SHIELD], |
|
185 | - (float)$fleet_info[UBE_BONUSES][UBE_ARMOR], |
|
174 | + (int) $fleet_info[UBE_PLANET][PLANET_GALAXY], |
|
175 | + (int) $fleet_info[UBE_PLANET][PLANET_SYSTEM], |
|
176 | + (int) $fleet_info[UBE_PLANET][PLANET_PLANET], |
|
177 | + (int) $fleet_info[UBE_PLANET][PLANET_TYPE], |
|
178 | + |
|
179 | + (float) $fleet_info[UBE_RESOURCES][RES_METAL], |
|
180 | + (float) $fleet_info[UBE_RESOURCES][RES_CRYSTAL], |
|
181 | + (float) $fleet_info[UBE_RESOURCES][RES_DEUTERIUM], |
|
182 | + |
|
183 | + (float) $fleet_info[UBE_BONUSES][UBE_ATTACK], |
|
184 | + (float) $fleet_info[UBE_BONUSES][UBE_SHIELD], |
|
185 | + (float) $fleet_info[UBE_BONUSES][UBE_ARMOR], |
|
186 | 186 | ); |
187 | 187 | |
188 | 188 | // Сохраняем итоговую информацию по ресурсам флота - потеряно, выброшено, увезено |
@@ -191,25 +191,25 @@ discard block |
||
191 | 191 | $ube_report_id, |
192 | 192 | $fleet_id, |
193 | 193 | |
194 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_METAL], |
|
195 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_CRYSTAL], |
|
196 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_DEUTERIUM], |
|
194 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_METAL], |
|
195 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_CRYSTAL], |
|
196 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_DEUTERIUM], |
|
197 | 197 | |
198 | - (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_METAL], |
|
199 | - (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_CRYSTAL], |
|
200 | - (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_DEUTERIUM], |
|
198 | + (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_METAL], |
|
199 | + (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_CRYSTAL], |
|
200 | + (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_DEUTERIUM], |
|
201 | 201 | |
202 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_METAL], |
|
203 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_CRYSTAL], |
|
204 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_DEUTERIUM], |
|
202 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_METAL], |
|
203 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_CRYSTAL], |
|
204 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_DEUTERIUM], |
|
205 | 205 | |
206 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOST_IN_METAL][RES_METAL], |
|
206 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOST_IN_METAL][RES_METAL], |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | // Сохраняем результаты по юнитам - потеряно и восстановлено |
210 | - foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
210 | + foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
211 | 211 | { |
212 | - if($fleet_outcome_data[UBE_UNITS_LOST][$unit_id] || $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id]) |
|
212 | + if ($fleet_outcome_data[UBE_UNITS_LOST][$unit_id] || $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id]) |
|
213 | 213 | { |
214 | 214 | $unit_sort_order++; |
215 | 215 | $sql_perform['ube_report_outcome_unit'][] = array( |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | $fleet_id, |
218 | 218 | |
219 | 219 | $unit_id, |
220 | - (float)$fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id], |
|
221 | - (float)$fleet_outcome_data[UBE_UNITS_LOST][$unit_id], |
|
220 | + (float) $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id], |
|
221 | + (float) $fleet_outcome_data[UBE_UNITS_LOST][$unit_id], |
|
222 | 222 | |
223 | 223 | $unit_sort_order, |
224 | 224 | ); |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | |
229 | 229 | // Сохраняем информацию о раундах |
230 | 230 | $unit_sort_order = 0; |
231 | - foreach($combat_data[UBE_ROUNDS] as $round => &$round_data) |
|
231 | + foreach ($combat_data[UBE_ROUNDS] as $round => &$round_data) |
|
232 | 232 | { |
233 | - foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) |
|
233 | + foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) |
|
234 | 234 | { |
235 | - foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
235 | + foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
236 | 236 | { |
237 | 237 | $unit_sort_order++; |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | $unit_id, |
246 | 246 | $unit_count, |
247 | - (int)$fleet_data[UBE_UNITS_BOOM][$unit_id], |
|
247 | + (int) $fleet_data[UBE_UNITS_BOOM][$unit_id], |
|
248 | 248 | |
249 | 249 | $fleet_data[UBE_ATTACK][$unit_id], |
250 | 250 | $fleet_data[UBE_SHIELD][$unit_id], |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | // Пакетная вставка данных |
264 | - foreach($sql_perform as $table_name => $table_data) |
|
264 | + foreach ($sql_perform as $table_name => $table_data) |
|
265 | 265 | { |
266 | - if(count($table_data) < 2) |
|
266 | + if (count($table_data) < 2) |
|
267 | 267 | { |
268 | 268 | continue; |
269 | 269 | } |
270 | - foreach($table_data as &$record_data) |
|
270 | + foreach ($table_data as &$record_data) |
|
271 | 271 | { |
272 | 272 | $record_data = '(' . implode(',', $record_data) . ')'; |
273 | 273 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $report_cypher = db_escape($report_cypher); |
287 | 287 | |
288 | 288 | $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true); |
289 | - if(!$report_row) |
|
289 | + if (!$report_row) |
|
290 | 290 | { |
291 | 291 | return UBE_REPORT_NOT_FOUND; |
292 | 292 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $outcome = &$combat_data[UBE_OUTCOME]; |
341 | 341 | |
342 | 342 | $query = doquery("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
343 | - while($player_row = db_fetch($query)) |
|
343 | + while ($player_row = db_fetch($query)) |
|
344 | 344 | { |
345 | 345 | $combat_data[UBE_PLAYERS][$player_row['ube_report_player_player_id']] = array( |
346 | 346 | UBE_NAME => $player_row['ube_report_player_name'], |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | } |
356 | 356 | |
357 | 357 | $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
358 | - while($fleet_row = db_fetch($query)) |
|
358 | + while ($fleet_row = db_fetch($query)) |
|
359 | 359 | { |
360 | 360 | $combat_data[UBE_FLEETS][$fleet_row['ube_report_fleet_fleet_id']] = array( |
361 | 361 | UBE_OWNER => $fleet_row['ube_report_fleet_player_id'], |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $rounds_data = &$combat_data[UBE_ROUNDS]; |
390 | 390 | |
391 | 391 | $query = doquery("SELECT * FROM {{ube_report_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_unit_sort_order`"); |
392 | - while($round_row = db_fetch($query)) |
|
392 | + while ($round_row = db_fetch($query)) |
|
393 | 393 | { |
394 | 394 | $round = $round_row['ube_report_unit_round']; |
395 | 395 | $fleet_id = $round_row['ube_report_unit_fleet_id']; |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | $side = $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE]; |
398 | 398 | $rounds_data[$round][$side][UBE_ATTACK][$fleet_id] = 0; |
399 | 399 | |
400 | - if(!isset($rounds_data[$round][UBE_FLEETS][$fleet_id])) |
|
400 | + if (!isset($rounds_data[$round][UBE_FLEETS][$fleet_id])) |
|
401 | 401 | { |
402 | 402 | $rounds_data[$round][UBE_FLEETS][$fleet_id] = array(); |
403 | 403 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | |
419 | 419 | |
420 | 420 | $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
421 | - while($row = db_fetch($query)) |
|
421 | + while ($row = db_fetch($query)) |
|
422 | 422 | { |
423 | 423 | $fleet_id = $row['ube_report_outcome_fleet_fleet_id']; |
424 | 424 | |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`"); |
455 | - while($row = db_fetch($query)) |
|
455 | + while ($row = db_fetch($query)) |
|
456 | 456 | { |
457 | 457 | $fleet_id = $row['ube_report_outcome_unit_fleet_id']; |
458 | - $side= $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE]; |
|
458 | + $side = $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE]; |
|
459 | 459 | $outcome[$side][UBE_FLEETS][$fleet_id][UBE_UNITS_LOST][$row['ube_report_outcome_unit_unit_id']] = $row['ube_report_outcome_unit_lost']; |
460 | 460 | $outcome[$side][UBE_FLEETS][$fleet_id][UBE_DEFENCE_RESTORE][$row['ube_report_outcome_unit_unit_id']] = $row['ube_report_outcome_unit_restored']; |
461 | 461 | } |
@@ -487,10 +487,10 @@ discard block |
||
487 | 487 | $fleets_info = &$combat_data[UBE_FLEETS]; |
488 | 488 | $round_template = array(); |
489 | 489 | $round_data = &$combat_data[UBE_ROUNDS][$round]; |
490 | - foreach(array(UBE_ATTACKERS, UBE_DEFENDERS) as $side) |
|
490 | + foreach (array(UBE_ATTACKERS, UBE_DEFENDERS) as $side) |
|
491 | 491 | { |
492 | 492 | $round_data[$side][UBE_ATTACK] = $round_data[$side][UBE_ATTACK] ? $round_data[$side][UBE_ATTACK] : array(); |
493 | - foreach($round_data[$side][UBE_ATTACK] as $fleet_id => $temp) |
|
493 | + foreach ($round_data[$side][UBE_ATTACK] as $fleet_id => $temp) |
|
494 | 494 | { |
495 | 495 | $fleet_data = &$round_data[UBE_FLEETS][$fleet_id]; |
496 | 496 | $fleet_data_prev = &$combat_data[UBE_ROUNDS][$round - 1][UBE_FLEETS][$fleet_id]; |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | 'PLAYER_NAME' => htmlentities($combat_data[UBE_PLAYERS][$fleets_info[$fleet_id][UBE_OWNER]][UBE_NAME], ENT_COMPAT, 'UTF-8'), |
501 | 501 | ); |
502 | 502 | |
503 | - if(is_array($combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET])) |
|
503 | + if (is_array($combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET])) |
|
504 | 504 | { |
505 | 505 | $fleet_template += $combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET]; |
506 | 506 | $fleet_template[PLANET_NAME] = $fleet_template[PLANET_NAME] ? htmlentities($fleet_template[PLANET_NAME], ENT_COMPAT, 'UTF-8') : ''; |
507 | 507 | $fleet_template['PLANET_TYPE_TEXT'] = $lang['sys_planet_type_sh'][$fleet_template['PLANET_TYPE']]; |
508 | 508 | } |
509 | 509 | |
510 | - foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
510 | + foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
511 | 511 | { |
512 | 512 | $shields_original = $fleet_data[UBE_SHIELD_BASE][$unit_id] * $fleet_data_prev[UBE_COUNT][$unit_id]; |
513 | 513 | $ship_template = array( |
@@ -540,11 +540,11 @@ discard block |
||
540 | 540 | global $lang; |
541 | 541 | |
542 | 542 | $result = array(); |
543 | - if(!empty($array)) |
|
543 | + if (!empty($array)) |
|
544 | 544 | { |
545 | - foreach($array as $unit_id => $unit_count) |
|
545 | + foreach ($array as $unit_id => $unit_count) |
|
546 | 546 | { |
547 | - if($unit_count) |
|
547 | + if ($unit_count) |
|
548 | 548 | { |
549 | 549 | $result[] = array( |
550 | 550 | 'NAME' => $lang['tech'][$unit_id], |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | ); |
553 | 553 | } |
554 | 554 | } |
555 | - if($header && count($result)) |
|
555 | + if ($header && count($result)) |
|
556 | 556 | { |
557 | 557 | array_unshift($result, array('NAME' => $header)); |
558 | 558 | } |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | // Генерирует данные для отчета из разобранных данных боя |
566 | 566 | function sn_ube_report_generate(&$combat_data, &$template_result) |
567 | 567 | { |
568 | - if(!is_array($combat_data)) |
|
568 | + if (!is_array($combat_data)) |
|
569 | 569 | { |
570 | 570 | return; |
571 | 571 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $fleets_info = &$combat_data[UBE_FLEETS]; |
578 | 578 | $outcome = &$combat_data[UBE_OUTCOME]; |
579 | 579 | // Генерируем отчет по флотам |
580 | - for($round = 1; $round <= count($combat_data[UBE_ROUNDS]) - 1; $round++) |
|
580 | + for ($round = 1; $round <= count($combat_data[UBE_ROUNDS]) - 1; $round++) |
|
581 | 581 | { |
582 | 582 | $round_template = array( |
583 | 583 | 'NUMBER' => $round, |
@@ -589,13 +589,13 @@ discard block |
||
589 | 589 | } |
590 | 590 | |
591 | 591 | // Боевые потери флотов |
592 | - foreach(array(UBE_ATTACKERS, UBE_DEFENDERS) as $side) |
|
592 | + foreach (array(UBE_ATTACKERS, UBE_DEFENDERS) as $side) |
|
593 | 593 | { |
594 | - if(!is_array($outcome[$side][UBE_FLEETS])) |
|
594 | + if (!is_array($outcome[$side][UBE_FLEETS])) |
|
595 | 595 | { |
596 | 596 | continue; |
597 | 597 | } |
598 | - foreach($outcome[$side][UBE_FLEETS] as $fleet_id => $temp) |
|
598 | + foreach ($outcome[$side][UBE_FLEETS] as $fleet_id => $temp) |
|
599 | 599 | { |
600 | 600 | $player_info = &$players_info[$fleets_info[$fleet_id][UBE_OWNER]]; |
601 | 601 | $fleet_outcome = &$outcome[UBE_FLEETS][$fleet_id]; |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | |
621 | 621 | // Обломки |
622 | 622 | $debris = array(); |
623 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) |
|
623 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) |
|
624 | 624 | { |
625 | - if($resource_amount = $outcome[UBE_DEBRIS][$resource_id]) |
|
625 | + if ($resource_amount = $outcome[UBE_DEBRIS][$resource_id]) |
|
626 | 626 | { |
627 | 627 | $debris[] = array( |
628 | 628 | 'NAME' => $lang['tech'][$resource_id], |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | |
636 | 636 | // Координаты, тип и название планеты - если есть |
637 | 637 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
638 | - if(isset($combat_data[UBE_OUTCOME][UBE_PLANET])) |
|
638 | + if (isset($combat_data[UBE_OUTCOME][UBE_PLANET])) |
|
639 | 639 | { |
640 | 640 | $template_result += $combat_data[UBE_OUTCOME][UBE_PLANET]; |
641 | 641 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | // @version 1.0 |
6 | 6 | // @copyright 2008 by Chlorel for XNova |
7 | 7 | |
8 | -if($fleet_ship_sort = sys_get_param_id('sort_elements')) { |
|
8 | +if ($fleet_ship_sort = sys_get_param_id('sort_elements')) { |
|
9 | 9 | define('IN_AJAX', true); |
10 | - if(!empty($lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) { |
|
10 | + if (!empty($lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) { |
|
11 | 11 | // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT, $fleet_ship_sort); |
12 | 12 | // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE, sys_get_param_id('fleet_ship_sort_inverse', 0)); |
13 | 13 | classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT] = $fleet_ship_sort; |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | die(); |
17 | 17 | } |
18 | 18 | |
19 | -if(SN_IN_FLEET !== true) { |
|
19 | +if (SN_IN_FLEET !== true) { |
|
20 | 20 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
21 | 21 | } |
22 | 22 | |
23 | 23 | lng_include('overview'); |
24 | 24 | |
25 | -if(!$planetrow) { |
|
25 | +if (!$planetrow) { |
|
26 | 26 | message($lang['fl_noplanetrow'], $lang['fl_error']); |
27 | 27 | } |
28 | 28 | |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | $record_index = 0; |
32 | 32 | $ship_list = array(); |
33 | -foreach(sn_get_groups('fleet') as $n => $unit_id) { |
|
33 | +foreach (sn_get_groups('fleet') as $n => $unit_id) { |
|
34 | 34 | $unit_level = mrc_get_level($user, $planetrow, $unit_id, false, true); |
35 | - if($unit_level > 0) { |
|
35 | + if ($unit_level > 0) { |
|
36 | 36 | $ship_data = get_ship_data($unit_id, $user); |
37 | 37 | $ship_list[$unit_id] = array( |
38 | 38 | '__INDEX' => $record_index++, |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | |
51 | 51 | $fleet_ship_sort = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT]; |
52 | 52 | $fleet_ship_sort_inverse = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]; |
53 | -if($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
54 | - switch($fleet_ship_sort) { |
|
53 | +if ($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
54 | + switch ($fleet_ship_sort) { |
|
55 | 55 | case PLAYER_OPTION_SORT_NAME: $fleet_ship_sort_field = 'NAME'; break; |
56 | 56 | case PLAYER_OPTION_SORT_SPEED: $fleet_ship_sort_field = 'SPEED'; break; |
57 | 57 | case PLAYER_OPTION_SORT_COUNT: $fleet_ship_sort_field = 'AMOUNT'; break; |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | }); |
67 | 67 | } |
68 | 68 | |
69 | -foreach($ship_list as $ship_data) { |
|
69 | +foreach ($ship_list as $ship_data) { |
|
70 | 70 | $template->assign_block_vars('ships', $ship_data); |
71 | 71 | } |
72 | 72 | |
73 | -foreach($lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
73 | +foreach ($lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
74 | 74 | $template->assign_block_vars('ship_sort_list', array( |
75 | 75 | 'VALUE' => $sort_id, |
76 | 76 | 'TEXT' => $sort_text, |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) |
|
3 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) |
|
4 | 4 | { |
5 | 5 | $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
6 | 6 | } |
@@ -15,50 +15,50 @@ discard block |
||
15 | 15 | )); |
16 | 16 | |
17 | 17 | $info_action = sys_get_param_int('action'); |
18 | -if($info_action) |
|
18 | +if ($info_action) |
|
19 | 19 | { |
20 | 20 | try |
21 | 21 | { |
22 | 22 | sn_db_transaction_start(); |
23 | 23 | |
24 | 24 | $user = db_user_by_id($user['id'], true); |
25 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $config->rpg_cost_info) |
|
25 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $config->rpg_cost_info) |
|
26 | 26 | { |
27 | 27 | throw new Exception(MARKET_NO_DM, ERR_ERROR); |
28 | 28 | } |
29 | 29 | |
30 | - switch($info_action) |
|
30 | + switch ($info_action) |
|
31 | 31 | { |
32 | 32 | case MARKET_INFO_PLAYER: |
33 | 33 | $user_info_name_unsafe = sys_get_param_str_unsafe('user_info_name'); |
34 | - if(!$user_info_name_unsafe) |
|
34 | + if (!$user_info_name_unsafe) |
|
35 | 35 | { |
36 | 36 | throw new Exception(MARKET_INFO_PLAYER_WRONG, ERR_ERROR); |
37 | 37 | } |
38 | 38 | |
39 | - if(is_id($user_info_name_unsafe)) |
|
39 | + if (is_id($user_info_name_unsafe)) |
|
40 | 40 | { |
41 | 41 | $user_info = db_user_by_id($user_info_name_unsafe, true, '`id`, `username`', true); |
42 | 42 | } |
43 | - if(!is_array($user_info)) |
|
43 | + if (!is_array($user_info)) |
|
44 | 44 | { |
45 | 45 | $user_info = db_user_by_username($user_info_name_unsafe, true, '`id`, `username`', true, true); |
46 | 46 | } |
47 | - if(!is_array($user_info)) |
|
47 | + if (!is_array($user_info)) |
|
48 | 48 | { |
49 | 49 | throw new Exception(MARKET_INFO_PLAYER_NOT_FOUND, ERR_ERROR); |
50 | 50 | } |
51 | - if($user_info['id'] == $user['id']) |
|
51 | + if ($user_info['id'] == $user['id']) |
|
52 | 52 | { |
53 | 53 | throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR); |
54 | 54 | } |
55 | 55 | |
56 | 56 | $msg_text = array(); |
57 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) |
|
57 | + foreach (sn_get_groups('mercenaries') as $mercenary_id) |
|
58 | 58 | { |
59 | 59 | $msg_text[] = "{$lang['tech'][$mercenary_id]} - " . (($mercenary_level = mrc_get_level($user_info, false, $mercenary_id)) ? "{$lang['sys_level']} {$mercenary_level}" : $lang['eco_mrk_info_not_hired']); |
60 | 60 | } |
61 | - if($mercenary_level = mrc_get_level($user_info, false, UNIT_PREMIUM)) |
|
61 | + if ($mercenary_level = mrc_get_level($user_info, false, UNIT_PREMIUM)) |
|
62 | 62 | { |
63 | 63 | $msg_text[] = "{$lang['tech'][UNIT_PREMIUM]} - {$mercenary_level} {$lang['sys_level']}"; |
64 | 64 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | break; |
73 | 73 | } |
74 | 74 | |
75 | - if(!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -$config->rpg_cost_info, "Using Black Market page {$lang['eco_mrk_info']} - getting info about user ID {$user_info['id']}")) |
|
75 | + if (!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -$config->rpg_cost_info, "Using Black Market page {$lang['eco_mrk_info']} - getting info about user ID {$user_info['id']}")) |
|
76 | 76 | { |
77 | 77 | // TODO: throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR); |
78 | 78 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if((!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) && (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)) { |
|
3 | +if ((!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) && (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)) { |
|
4 | 4 | $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | // $dm_db_name = pname_resource_name(RES_DARK_MATTER); |
29 | 29 | $exchangeTo = in_array($exchangeTo = sys_get_param_int('exchangeTo'), sn_get_groups('resources_trader')) ? $exchangeTo : 0; |
30 | - if($exchangeTo && is_array($tradeList = $_POST['spend'])) { |
|
30 | + if ($exchangeTo && is_array($tradeList = $_POST['spend'])) { |
|
31 | 31 | $value = 0; |
32 | 32 | $qry = array(); |
33 | 33 | |
34 | 34 | sn_db_transaction_start(); |
35 | - if($planetrow['id_owner']) { |
|
35 | + if ($planetrow['id_owner']) { |
|
36 | 36 | $global_data = sys_o_get_updated($user, $planetrow, SN_TIME_NOW); |
37 | 37 | $planetrow = $global_data['planet']; |
38 | 38 | } |
@@ -41,27 +41,27 @@ discard block |
||
41 | 41 | $user = db_user_by_id($user['id'], true); |
42 | 42 | } |
43 | 43 | |
44 | - foreach(sn_get_groups('resources_trader') as $resource_id) { |
|
44 | + foreach (sn_get_groups('resources_trader') as $resource_id) { |
|
45 | 45 | $amount = floatval($tradeList[$resource_id]); |
46 | - if($amount < 0) { |
|
46 | + if ($amount < 0) { |
|
47 | 47 | $debug->error('Trying to supply negative resource amount on Black Market Page', 'Hack Attempt', 305); |
48 | 48 | } |
49 | 49 | |
50 | - if($resource_id == RES_DARK_MATTER && $exchangeTo == RES_DARK_MATTER) { |
|
50 | + if ($resource_id == RES_DARK_MATTER && $exchangeTo == RES_DARK_MATTER) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $resource_db_name = pname_resource_name($resource_id); |
55 | - if($exchangeTo == RES_DARK_MATTER) { |
|
55 | + if ($exchangeTo == RES_DARK_MATTER) { |
|
56 | 56 | $sign = '+'; |
57 | 57 | $amount = floor($tradeList[RES_DARK_MATTER] / 3 * $rates[RES_DARK_MATTER] / $rates[$resource_id]); |
58 | 58 | $value += $amount; |
59 | 59 | } else { |
60 | 60 | $value += floor($amount * $rates[$resource_id] / $rates[$exchangeTo]); |
61 | - if($resource_id == RES_DARK_MATTER) { |
|
61 | + if ($resource_id == RES_DARK_MATTER) { |
|
62 | 62 | $amount = 0; |
63 | 63 | } else { |
64 | - if(mrc_get_level($user, $planetrow, $resource_id, true) < $amount) { |
|
64 | + if (mrc_get_level($user, $planetrow, $resource_id, true) < $amount) { |
|
65 | 65 | $intError = MARKET_NO_RESOURCES; |
66 | 66 | break; |
67 | 67 | } |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - if($amount) { |
|
73 | + if ($amount) { |
|
74 | 74 | $qry[] = "`{$resource_db_name}` = `{$resource_db_name}` {$sign} {$amount}"; |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | - if($exchangeTo != RES_DARK_MATTER) { |
|
78 | + if ($exchangeTo != RES_DARK_MATTER) { |
|
79 | 79 | $amount = floor($value); |
80 | 80 | $exchange_to_db_name = pname_resource_name($exchangeTo); |
81 | 81 | $qry[] = "`{$exchange_to_db_name}` = `{$exchange_to_db_name}` + {$amount}"; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $intError = $value <= 0 ? MARKET_ZERO_DEAL : $intError; |
87 | 87 | $intError = mrc_get_level($user, null, RES_DARK_MATTER) < $operation_cost ? MARKET_NO_DM : $intError; |
88 | 88 | |
89 | - if($intError == MARKET_DEAL) { |
|
89 | + if ($intError == MARKET_DEAL) { |
|
90 | 90 | $qry = implode(', ', $qry); |
91 | 91 | $table = $planetrow['id_owner'] ? 'planets' : 'users'; |
92 | 92 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | 'EXCHANGE_TO_RESOURCE_ID' => $exchangeTo, |
112 | 112 | )); |
113 | 113 | |
114 | - foreach(sn_get_groups('resources_trader') as $resource_id) { |
|
115 | - if($resource_id == RES_DARK_MATTER) { |
|
114 | + foreach (sn_get_groups('resources_trader') as $resource_id) { |
|
115 | + if ($resource_id == RES_DARK_MATTER) { |
|
116 | 116 | $amount = floor(mrc_get_level($user, null, RES_DARK_MATTER) - $config->rpg_cost_trader); |
117 | 117 | } else { |
118 | 118 | $amount = floor(mrc_get_level($user, $planetrow, $resource_id)); |
@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | $query = db_user_list_to_celebrate($config->user_birthday_range); |
10 | 10 | |
11 | - while($row = db_fetch($query)) |
|
11 | + while ($row = db_fetch($query)) |
|
12 | 12 | { |
13 | 13 | $row['username'] = db_escape($row['username']); |
14 | 14 | rpg_points_change($row['id'], RPG_BIRTHDAY, $config->user_birthday_gift, "Birthday gift for user {$row['username']} ID {$row['id']} on his birthday on {$row['user_birthday']}. Gift last gaved at {$row['user_birthday_celebrated']}"); |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | print($round); |
28 | 28 | print('<table border=1>'); |
29 | 29 | print('<tr align="left">'); |
30 | - foreach($header as $key => $value) |
|
30 | + foreach ($header as $key => $value) |
|
31 | 31 | { |
32 | - if(is_array($value)) |
|
32 | + if (is_array($value)) |
|
33 | 33 | { |
34 | 34 | continue; |
35 | 35 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | ); |
62 | 62 | |
63 | 63 | print('<tr align="right">'); |
64 | - foreach($debug_unit_crossfire_result as $key => $value) |
|
64 | + foreach ($debug_unit_crossfire_result as $key => $value) |
|
65 | 65 | { |
66 | - if(is_array($value)) |
|
66 | + if (is_array($value)) |
|
67 | 67 | { |
68 | 68 | continue; |
69 | 69 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'START_NAME' => $planetrow['name'], |
28 | 28 | ); |
29 | 29 | |
30 | - if(!empty($TargetPlanet)) { |
|
30 | + if (!empty($TargetPlanet)) { |
|
31 | 31 | $template_route += array( |
32 | 32 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
33 | 33 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | $template->assign_block_vars('fleets', $template_route); |
39 | 39 | |
40 | 40 | $sn_groups_fleet = sn_get_groups('fleet'); |
41 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
42 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
41 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
42 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
43 | 43 | // $ship_base_data = get_ship_data($ship_id, $user); |
44 | 44 | $template->assign_block_vars('fleets.ships', array( |
45 | 45 | 'ID' => $ship_id, |
@@ -57,11 +57,10 @@ discard block |
||
57 | 57 | $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count; |
58 | 58 | } |
59 | 59 | |
60 | - $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : |
|
61 | - (isset($missiontype[MT_HOLD]) ? 12 : 0); |
|
62 | - if($max_duration) { |
|
60 | + $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0); |
|
61 | + if ($max_duration) { |
|
63 | 62 | $config_game_speed_expedition = ($target_mission == MT_EXPLORE && $config->game_speed_expedition ? $config->game_speed_expedition : 1); |
64 | - for($i = 1; $i <= $max_duration; $i++) { |
|
63 | + for ($i = 1; $i <= $max_duration; $i++) { |
|
65 | 64 | $template->assign_block_vars('duration', array( |
66 | 65 | 'ID' => $i, |
67 | 66 | 'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)), |
@@ -80,7 +79,7 @@ discard block |
||
80 | 79 | // $TableTitle = uni_render_planet_full($planetrow) . ' => ' . uni_render_planet_full($temp); |
81 | 80 | |
82 | 81 | $sn_group_resources = sn_get_groups('resources'); |
83 | - for($i = 0; $i<3; $i++) { |
|
82 | + for ($i = 0; $i < 3; $i++) { |
|
84 | 83 | $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0); |
85 | 84 | $template->assign_block_vars('resources', array( |
86 | 85 | 'ID' => $i, |
@@ -90,7 +89,7 @@ discard block |
||
90 | 89 | )); |
91 | 90 | } |
92 | 91 | |
93 | - if($sn_module['unit_captain']->manifest['active'] && ($captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { |
|
92 | + if ($sn_module['unit_captain']->manifest['active'] && ($captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { |
|
94 | 93 | $template->assign_vars(array( |
95 | 94 | 'CAPTAIN_ID' => $captain['unit_id'], |
96 | 95 | 'CAPTAIN_LEVEL' => $captain['captain_level'], |
@@ -111,9 +110,9 @@ discard block |
||
111 | 110 | // 'TableTitle' => $TableTitle, |
112 | 111 | |
113 | 112 | 'speedallsmin' => sys_get_param_float('speedallsmin'), |
114 | - 'speed' => sys_get_param_int('speed') , |
|
113 | + 'speed' => sys_get_param_int('speed'), |
|
115 | 114 | |
116 | - 'fleet_group' => sys_get_param_id('fleet_group') , |
|
115 | + 'fleet_group' => sys_get_param_id('fleet_group'), |
|
117 | 116 | 'acs_target_mr' => sys_get_param_str('acs_target_mr'), |
118 | 117 | |
119 | 118 | 'MAX_DURATION' => $max_duration, |
@@ -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 | } |
@@ -64,48 +64,48 @@ discard block |
||
64 | 64 | |
65 | 65 | $player_id = $player_id == -1 ? count($combat_data[UBE_PLAYERS]) : $player_id; |
66 | 66 | |
67 | - foreach($side_info as $fleet_data) |
|
67 | + foreach ($side_info as $fleet_data) |
|
68 | 68 | { |
69 | 69 | $combat_data[UBE_PLAYERS][$player_id][UBE_NAME] = $attacker ? 'Attacker' : 'Defender'; |
70 | 70 | $combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] = $attacker; |
71 | 71 | |
72 | 72 | $combat_data[UBE_FLEETS][$player_id][UBE_OWNER] = $player_id; |
73 | - foreach($fleet_data as $unit_id => $unit_count) |
|
73 | + foreach ($fleet_data as $unit_id => $unit_count) |
|
74 | 74 | { |
75 | - if(!$unit_count) |
|
75 | + if (!$unit_count) |
|
76 | 76 | { |
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | 80 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
81 | 81 | |
82 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) |
|
82 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) |
|
83 | 83 | { |
84 | 84 | $combat_data[UBE_FLEETS][$player_id][UBE_COUNT][$unit_id] = $unit_count; |
85 | 85 | } |
86 | - elseif($unit_type == UNIT_RESOURCES) |
|
86 | + elseif ($unit_type == UNIT_RESOURCES) |
|
87 | 87 | { |
88 | 88 | $combat_data[UBE_FLEETS][$player_id][UBE_RESOURCES][$unit_id] = $unit_count; |
89 | 89 | } |
90 | - elseif($unit_type == UNIT_TECHNOLOGIES) |
|
90 | + elseif ($unit_type == UNIT_TECHNOLOGIES) |
|
91 | 91 | { |
92 | 92 | $combat_data[UBE_PLAYERS][$player_id][UBE_BONUSES][$ube_convert_techs[$unit_id]] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100; |
93 | 93 | } |
94 | - elseif($unit_type == UNIT_GOVERNORS) |
|
94 | + elseif ($unit_type == UNIT_GOVERNORS) |
|
95 | 95 | { |
96 | - if($unit_id == MRC_FORTIFIER) |
|
96 | + if ($unit_id == MRC_FORTIFIER) |
|
97 | 97 | { |
98 | - foreach($ube_convert_techs as $ube_id) |
|
98 | + foreach ($ube_convert_techs as $ube_id) |
|
99 | 99 | { |
100 | 100 | $combat_data[UBE_FLEETS][$player_id][UBE_BONUSES][$ube_id] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100; |
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
104 | - elseif($unit_type == UNIT_MERCENARIES) |
|
104 | + elseif ($unit_type == UNIT_MERCENARIES) |
|
105 | 105 | { |
106 | - if($unit_id == MRC_ADMIRAL) |
|
106 | + if ($unit_id == MRC_ADMIRAL) |
|
107 | 107 | { |
108 | - foreach($ube_convert_techs as $ube_id) |
|
108 | + foreach ($ube_convert_techs as $ube_id) |
|
109 | 109 | { |
110 | 110 | $combat_data[UBE_PLAYERS][$player_id][UBE_BONUSES][$ube_id] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100; |
111 | 111 | } |