@@ -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 | } |
@@ -19,15 +19,11 @@ discard block |
||
19 | 19 | // ------------------------------------------------------------------ |
20 | 20 | function flt_flyingFleetsSort($a, $b) { |
21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
23 | - // Если время - одинаковое, сравниваем события флотов |
|
22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
24 | 23 | // Если события - одинаковые, то флоты равны |
25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
26 | - // Если события разные - первыми считаем прибывающие флоты |
|
27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
32 | 28 | ( |
33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -41,11 +37,11 @@ discard block |
||
41 | 37 | function log_file($msg) { |
42 | 38 | static $handler; |
43 | 39 | |
44 | - if(!$handler) { |
|
40 | + if (!$handler) { |
|
45 | 41 | $handler = fopen('event.log', 'a+'); |
46 | 42 | } |
47 | 43 | |
48 | - fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n"); |
|
44 | + fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n"); |
|
49 | 45 | } |
50 | 46 | |
51 | 47 | // ------------------------------------------------------------------ |
@@ -80,12 +76,12 @@ discard block |
||
80 | 76 | |
81 | 77 | */ |
82 | 78 | |
83 | - if(classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) { |
|
79 | + if (classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) { |
|
84 | 80 | return; |
85 | 81 | } |
86 | 82 | |
87 | 83 | sn_db_transaction_start(); |
88 | - if(classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) { |
|
84 | + if (classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) { |
|
89 | 85 | sn_db_transaction_rollback(); |
90 | 86 | |
91 | 87 | return; |
@@ -93,14 +89,14 @@ discard block |
||
93 | 89 | |
94 | 90 | |
95 | 91 | // Watchdog timer |
96 | - if(classSupernova::$config->db_loadItem('fleet_update_lock')) { |
|
97 | - if(defined('DEBUG_FLYING_FLEETS')) { |
|
92 | + if (classSupernova::$config->db_loadItem('fleet_update_lock')) { |
|
93 | + if (defined('DEBUG_FLYING_FLEETS')) { |
|
98 | 94 | $random = 0; |
99 | 95 | } else { |
100 | 96 | $random = mt_rand(240, 300); |
101 | 97 | } |
102 | 98 | |
103 | - if(SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) { |
|
99 | + if (SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) { |
|
104 | 100 | sn_db_transaction_rollback(); |
105 | 101 | |
106 | 102 | return; |
@@ -124,11 +120,11 @@ discard block |
||
124 | 120 | $missions_used = array(); |
125 | 121 | |
126 | 122 | $objFleetList = FleetList::dbGetFleetListCurrentTick(); |
127 | - foreach($objFleetList->_container as $objFleet) { |
|
123 | + foreach ($objFleetList->_container as $objFleet) { |
|
128 | 124 | set_time_limit(15); |
129 | 125 | // TODO - Унифицировать код с темплейтным разбором эвентов на планете! |
130 | 126 | $missions_used[$objFleet->mission_type] = 1; |
131 | - if($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
127 | + if ($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
132 | 128 | $fleet_event_list[] = array( |
133 | 129 | 'object' => $objFleet, |
134 | 130 | 'fleet_time' => $objFleet->time_arrive_to_target, |
@@ -136,7 +132,7 @@ discard block |
||
136 | 132 | ); |
137 | 133 | } |
138 | 134 | |
139 | - if($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
135 | + if ($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
140 | 136 | $fleet_event_list[] = array( |
141 | 137 | 'object' => $objFleet, |
142 | 138 | 'fleet_time' => $objFleet->time_mission_job_complete, |
@@ -144,7 +140,7 @@ discard block |
||
144 | 140 | ); |
145 | 141 | } |
146 | 142 | |
147 | - if($objFleet->time_return_to_source <= SN_TIME_NOW) { |
|
143 | + if ($objFleet->time_return_to_source <= SN_TIME_NOW) { |
|
148 | 144 | $fleet_event_list[] = array( |
149 | 145 | 'object' => $objFleet, |
150 | 146 | 'fleet_time' => $objFleet->time_return_to_source, |
@@ -170,17 +166,17 @@ discard block |
||
170 | 166 | // MT_MISSILE => 'flt_mission_missile.php', |
171 | 167 | MT_EXPLORE => 'flt_mission_explore', |
172 | 168 | ); |
173 | - foreach($missions_used as $mission_id => $cork) { |
|
174 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
|
169 | + foreach ($missions_used as $mission_id => $cork) { |
|
170 | + require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX); |
|
175 | 171 | } |
176 | 172 | |
177 | 173 | //log_file('Обработка миссий'); |
178 | 174 | $sn_groups_mission = sn_get_groups('missions'); |
179 | - foreach($fleet_event_list as $fleet_event) { |
|
175 | + foreach ($fleet_event_list as $fleet_event) { |
|
180 | 176 | // TODO: Указатель тут потом сделать |
181 | 177 | // TODO: СЕЙЧАС НАДО ПРОВЕРЯТЬ ПО БАЗЕ - А ЖИВОЙ ЛИ ФЛОТ?! |
182 | 178 | $fleet_row = $fleet_event['fleet_row']; |
183 | - if(empty($fleet_event['object'])) { |
|
179 | + if (empty($fleet_event['object'])) { |
|
184 | 180 | // Fleet was destroyed in course of previous actions |
185 | 181 | continue; |
186 | 182 | } |
@@ -205,20 +201,20 @@ discard block |
||
205 | 201 | |
206 | 202 | $objFleet->dbLoad($objFleet->dbId); |
207 | 203 | |
208 | - if(!$objFleet->dbId) { |
|
204 | + if (!$objFleet->dbId) { |
|
209 | 205 | // Fleet was destroyed in course of previous actions |
210 | 206 | sn_db_transaction_commit(); |
211 | 207 | continue; |
212 | 208 | } |
213 | 209 | |
214 | - if($fleet_event['fleet_event'] == EVENT_FLT_RETURN) { |
|
210 | + if ($fleet_event['fleet_event'] == EVENT_FLT_RETURN) { |
|
215 | 211 | // Fleet returns to planet |
216 | 212 | $objFleet->shipsLand(true); |
217 | 213 | sn_db_transaction_commit(); |
218 | 214 | continue; |
219 | 215 | } |
220 | 216 | |
221 | - if($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) { |
|
217 | + if ($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) { |
|
222 | 218 | // При событии EVENT_FLT_ARRIVE флот всегда должен иметь fleet_mess == 0 |
223 | 219 | // В противном случае это означает, что флот уже был обработан ранее - например, при САБе |
224 | 220 | sn_db_transaction_commit(); |
@@ -238,13 +234,13 @@ discard block |
||
238 | 234 | $objMission->dst_planet = $mission_data['dst_planet'] ? db_planet_by_vector($objFleet->target_coordinates_typed(), '', true, '`id`, `id_owner`, `name`') : null; |
239 | 235 | $objMission->fleet_event = $fleet_event['fleet_event']; |
240 | 236 | |
241 | - if($objMission->dst_planet && $objMission->dst_planet['id_owner']) { |
|
237 | + if ($objMission->dst_planet && $objMission->dst_planet['id_owner']) { |
|
242 | 238 | $update_result = sys_o_get_updated($objMission->dst_planet['id_owner'], $objMission->dst_planet['id'], $objFleet->time_arrive_to_target); |
243 | 239 | $objMission->dst_user = !empty($objMission->dst_user) ? $update_result['user'] : null; |
244 | 240 | $objMission->dst_planet = $update_result['planet']; |
245 | 241 | } |
246 | 242 | |
247 | - switch($objFleet->mission_type) { |
|
243 | + switch ($objFleet->mission_type) { |
|
248 | 244 | // Для боевых атак нужно обновлять по САБу и по холду - таки надо возвращать данные из обработчика миссий! |
249 | 245 | case MT_ACS: |
250 | 246 | case MT_ATTACK: |
@@ -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 |
@@ -2,7 +2,7 @@ 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 | { |
7 | 7 | classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
8 | 8 | } |
@@ -17,54 +17,54 @@ discard block |
||
17 | 17 | )); |
18 | 18 | |
19 | 19 | $info_action = sys_get_param_int('action'); |
20 | -if($info_action) |
|
20 | +if ($info_action) |
|
21 | 21 | { |
22 | 22 | try |
23 | 23 | { |
24 | 24 | sn_db_transaction_start(); |
25 | 25 | |
26 | 26 | $user = db_user_by_id($user['id'], true); |
27 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->rpg_cost_info) |
|
27 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->rpg_cost_info) |
|
28 | 28 | { |
29 | 29 | throw new Exception(MARKET_NO_DM, ERR_ERROR); |
30 | 30 | } |
31 | 31 | |
32 | - switch($info_action) |
|
32 | + switch ($info_action) |
|
33 | 33 | { |
34 | 34 | case MARKET_INFO_PLAYER: |
35 | 35 | $user_info_name_unsafe = sys_get_param_str_unsafe('user_info_name'); |
36 | - if(!$user_info_name_unsafe) |
|
36 | + if (!$user_info_name_unsafe) |
|
37 | 37 | { |
38 | 38 | throw new Exception(MARKET_INFO_PLAYER_WRONG, ERR_ERROR); |
39 | 39 | } |
40 | 40 | |
41 | - if(is_id($user_info_name_unsafe)) |
|
41 | + if (is_id($user_info_name_unsafe)) |
|
42 | 42 | { |
43 | 43 | $user_info = db_user_by_id($user_info_name_unsafe, true, '`id`, `username`', true); |
44 | 44 | } |
45 | - if(!is_array($user_info)) |
|
45 | + if (!is_array($user_info)) |
|
46 | 46 | { |
47 | 47 | $user_info = db_user_by_username($user_info_name_unsafe, true, '`id`, `username`', true, true); |
48 | 48 | } |
49 | - if(!is_array($user_info)) |
|
49 | + if (!is_array($user_info)) |
|
50 | 50 | { |
51 | 51 | throw new Exception(MARKET_INFO_PLAYER_NOT_FOUND, ERR_ERROR); |
52 | 52 | } |
53 | - if($user_info['id'] == $user['id']) |
|
53 | + if ($user_info['id'] == $user['id']) |
|
54 | 54 | { |
55 | 55 | throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR); |
56 | 56 | } |
57 | 57 | |
58 | 58 | $msg_text = array(); |
59 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) |
|
59 | + foreach (sn_get_groups('mercenaries') as $mercenary_id) |
|
60 | 60 | { |
61 | - $msg_text[] = "{$classLocale['tech'][$mercenary_id]} - " . (($mercenary_level = mrc_get_level($user_info, null, $mercenary_id)) ? "{$classLocale['sys_level']} {$mercenary_level}" : classLocale::$lang['eco_mrk_info_not_hired']); |
|
61 | + $msg_text[] = "{$classLocale['tech'][$mercenary_id]} - ".(($mercenary_level = mrc_get_level($user_info, null, $mercenary_id)) ? "{$classLocale['sys_level']} {$mercenary_level}" : classLocale::$lang['eco_mrk_info_not_hired']); |
|
62 | 62 | } |
63 | - if($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM)) |
|
63 | + if ($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM)) |
|
64 | 64 | { |
65 | 65 | $msg_text[] = "{$classLocale['tech'][UNIT_PREMIUM]} - {$mercenary_level} {$classLocale['sys_level']}"; |
66 | 66 | } |
67 | - $msg_text = sprintf(classLocale::$lang['eco_mrk_info_player_message'], $user_info['id'], $user_info['username']) . "\r\n" . implode("\r\n", $msg_text); |
|
67 | + $msg_text = sprintf(classLocale::$lang['eco_mrk_info_player_message'], $user_info['id'], $user_info['username'])."\r\n".implode("\r\n", $msg_text); |
|
68 | 68 | |
69 | 69 | msg_send_simple_message($user['id'], 0, SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['eco_mrk_info_msg_from'], "{$classLocale['eco_mrk_info_player']} ID {$user_info['id']} [{$user_info['username']}]", $msg_text, false, true); |
70 | 70 | break; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | break; |
75 | 75 | } |
76 | 76 | |
77 | - if(!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -classSupernova::$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}")) |
|
77 | + if (!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -classSupernova::$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}")) |
|
78 | 78 | { |
79 | 79 | // TODO: throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR); |
80 | 80 | } |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | $uni_galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']); |
12 | 12 | $uni_system = sys_get_param_int('system'); |
13 | 13 | |
14 | - if($uni_galaxy < 1 || $uni_galaxy > Vector::$knownGalaxies) |
|
14 | + if ($uni_galaxy < 1 || $uni_galaxy > Vector::$knownGalaxies) |
|
15 | 15 | { |
16 | 16 | throw new exception(classLocale::$lang['uni_msg_error_wrong_galaxy'], ERR_ERROR); |
17 | 17 | } |
18 | 18 | |
19 | - if($uni_system < 0 || $uni_system > Vector::$knownSystems) |
|
19 | + if ($uni_system < 0 || $uni_system > Vector::$knownSystems) |
|
20 | 20 | { |
21 | 21 | throw new exception(classLocale::$lang['uni_msg_error_wrong_system'], ERR_ERROR); |
22 | 22 | } |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | $uni_row['universe_price'] += $uni_system ? classSupernova::$config->uni_price_system : classSupernova::$config->uni_price_galaxy; |
26 | 26 | $uni_row['universe_name'] = strip_tags($uni_row['universe_name'] ? $uni_row['universe_name'] : ($uni_system ? "{$classLocale['sys_system']} [{$uni_galaxy}:{$uni_system}]" : "{$classLocale['sys_galaxy']} {$uni_galaxy}")); |
27 | 27 | |
28 | - if(sys_get_param_str('uni_name_submit')) |
|
28 | + if (sys_get_param_str('uni_name_submit')) |
|
29 | 29 | { |
30 | 30 | $uni_row['universe_name'] = strip_tags(sys_get_param_str('uni_name')); |
31 | 31 | |
32 | 32 | $uni_price = sys_get_param_float('uni_price'); |
33 | - if($uni_price < $uni_row['universe_price']) |
|
33 | + if ($uni_price < $uni_row['universe_price']) |
|
34 | 34 | { |
35 | 35 | throw new exception(classLocale::$lang['uni_msg_error_low_price'], ERR_ERROR); |
36 | 36 | } |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | sn_db_transaction_start(); |
40 | 40 | $user = db_user_by_id($user['id'], true); |
41 | 41 | // if($user[get_unit_param(RES_DARK_MATTER, P_NAME)] < $uni_price) |
42 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) |
|
42 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) |
|
43 | 43 | { |
44 | 44 | throw new exception(classLocale::$lang['uni_msg_error_no_dm'], ERR_ERROR); |
45 | 45 | } |
46 | 46 | |
47 | - if(!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name'))) |
|
47 | + if (!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to ".sys_get_param_str_unsafe('uni_name'))) |
|
48 | 48 | { |
49 | 49 | throw new exception(classLocale::$lang['sys_msg_err_update_dm'], ERR_ERROR); |
50 | 50 | } |
@@ -74,4 +74,4 @@ discard block |
||
74 | 74 | 'PAGE_HINT' => classLocale::$lang['uni_name_page_hint'], |
75 | 75 | )); |
76 | 76 | |
77 | - display($template, classLocale::$lang['sys_universe'] . ' - ' . classLocale::$lang['uni_naming'], true, '', false); |
|
77 | + display($template, classLocale::$lang['sys_universe'].' - '.classLocale::$lang['uni_naming'], true, '', false); |
@@ -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, |
@@ -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; |
@@ -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']), |