@@ -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($unit_crossfire_result as $key => $value) |
|
64 | + foreach ($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 | } |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | $TargetAddress = sprintf(classLocale::$lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']); |
21 | 21 | |
22 | 22 | $TheMessage = classLocale::$lang['sys_colo_no_colonizer']; |
23 | - if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
23 | + if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
24 | 24 | $TheMessage = classLocale::$lang['sys_colo_notfree']; |
25 | - if(empty($mission_data->dst_planet)) { |
|
25 | + if (empty($mission_data->dst_planet)) { |
|
26 | 26 | $iPlanetCount = get_player_current_colonies($src_user_row); |
27 | 27 | |
28 | 28 | // Can we colonize more planets? |
29 | 29 | $TheMessage = classLocale::$lang['sys_colo_maxcolo']; |
30 | - if($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
30 | + if ($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
31 | 31 | // Yes, we can colonize |
32 | 32 | $TheMessage = classLocale::$lang['sys_colo_badpos']; |
33 | 33 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'], |
36 | 36 | $objFleet->playerOwnerId, "{$classLocale['sys_colo_defaultname']} {$iPlanetCount}", false, |
37 | 37 | array('user_row' => $src_user_row)); |
38 | - if($NewOwnerPlanet) { |
|
39 | - $TheMessage = classLocale::$lang['sys_colo_arrival'] . $TargetAddress . classLocale::$lang['sys_colo_allisok']; |
|
38 | + if ($NewOwnerPlanet) { |
|
39 | + $TheMessage = classLocale::$lang['sys_colo_arrival'].$TargetAddress.classLocale::$lang['sys_colo_allisok']; |
|
40 | 40 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_colo_mess_from'], classLocale::$lang['sys_colo_mess_report'], $TheMessage); |
41 | 41 | |
42 | 42 | $objFleet->shipAdjustCount(SHIP_COLONIZER, -1); |
@@ -2,28 +2,28 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(SN_IN_FLEET !== true) { |
|
5 | +if (SN_IN_FLEET !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | 9 | $fleetid = sys_get_param_id('fleetid'); |
10 | 10 | |
11 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
11 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
12 | 12 | header("Location: fleet.php"); |
13 | 13 | exit(); |
14 | 14 | } |
15 | 15 | |
16 | 16 | $objFleet = new Fleet(); |
17 | 17 | $objFleet->dbLoad($fleetid); |
18 | -if(!$objFleet->dbId) { |
|
18 | +if (!$objFleet->dbId) { |
|
19 | 19 | message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']); |
20 | 20 | } |
21 | 21 | |
22 | -if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
22 | +if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
23 | 23 | message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']); |
24 | 24 | } |
25 | 25 | |
26 | -if($objFleet->playerOwnerId != $user['id']) { |
|
26 | +if ($objFleet->playerOwnerId != $user['id']) { |
|
27 | 27 | classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
28 | 28 | message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']); |
29 | 29 | } |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | |
35 | 35 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
36 | 36 | |
37 | -if($userToAdd_unsafe) { |
|
37 | +if ($userToAdd_unsafe) { |
|
38 | 38 | $userToAdd = db_escape($userToAdd_unsafe); |
39 | 39 | $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true); |
40 | 40 | $userToAddID = $userToAddID['id']; |
41 | 41 | |
42 | - if($objFleet->target_owner_id == $userToAddID) { |
|
42 | + if ($objFleet->target_owner_id == $userToAddID) { |
|
43 | 43 | message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']); |
44 | 44 | } |
45 | 45 | |
46 | - if($userToAddID) { |
|
47 | - if(!$aks) { |
|
46 | + if ($userToAddID) { |
|
47 | + if (!$aks) { |
|
48 | 48 | // No AСS exists - making one |
49 | - if(!$objFleet->group_id) { |
|
49 | + if (!$objFleet->group_id) { |
|
50 | 50 | db_acs_insert($fleetid, $user, $objFleet); |
51 | 51 | |
52 | 52 | $aks = db_acs_get_by_fleet($fleetid); |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | |
62 | 62 | $isUserExists = false; |
63 | 63 | $invited_ar = explode(",", $aks['eingeladen']); |
64 | - foreach($invited_ar as $inv) { |
|
65 | - if($userToAddID == $inv) { |
|
64 | + foreach ($invited_ar as $inv) { |
|
65 | + if ($userToAddID == $inv) { |
|
66 | 66 | $isUserExists = true; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - if(count($invited_ar) >= 5) { |
|
70 | + if (count($invited_ar) >= 5) { |
|
71 | 71 | message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']); |
72 | 72 | } |
73 | 73 | |
74 | - if($isUserExists) { |
|
74 | + if ($isUserExists) { |
|
75 | 75 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false; |
76 | 76 | } else { |
77 | 77 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd); |
78 | 78 | !(db_acs_update($userToAddID, $fleetid)) ? die(sprintf(classLocale::$lang['fl_aks_adding_error'], db_error())) : false; |
79 | - $aks['eingeladen'] .= ',' . $userToAddID; |
|
79 | + $aks['eingeladen'] .= ','.$userToAddID; |
|
80 | 80 | } |
81 | 81 | msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
82 | 82 | classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username'])); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | 'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS], |
94 | 94 | )); |
95 | 95 | |
96 | -if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | - foreach($members as $row) { |
|
96 | +if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | + foreach ($members as $row) { |
|
98 | 98 | $template->assign_block_vars('invited', array( |
99 | 99 | 'NAME' => $row['username'], |
100 | 100 | )); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
120 | 120 | |
121 | 121 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
122 | -foreach($fleet_data['ships'] as $ship_data) { |
|
122 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
123 | 123 | $template->assign_block_vars('fleets.ships', $ship_data); |
124 | 124 | } |
125 | 125 |
@@ -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() |
@@ -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']), |