@@ -7,28 +7,28 @@ discard block |
||
7 | 7 | |
8 | 8 | $classLocale = classLocale::$lang; |
9 | 9 | |
10 | -if(SN_IN_FLEET !== true) { |
|
10 | +if (SN_IN_FLEET !== true) { |
|
11 | 11 | classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
12 | 12 | } |
13 | 13 | |
14 | 14 | $fleetid = sys_get_param_id('fleetid'); |
15 | 15 | |
16 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
16 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
17 | 17 | header("Location: fleet.php"); |
18 | 18 | exit(); |
19 | 19 | } |
20 | 20 | |
21 | 21 | $objFleet = new Fleet(); |
22 | 22 | $objFleet->dbLoad($fleetid); |
23 | -if(!$objFleet->dbId) { |
|
23 | +if (!$objFleet->dbId) { |
|
24 | 24 | message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']); |
25 | 25 | } |
26 | 26 | |
27 | -if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
27 | +if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
28 | 28 | message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']); |
29 | 29 | } |
30 | 30 | |
31 | -if($objFleet->playerOwnerId != $user['id']) { |
|
31 | +if ($objFleet->playerOwnerId != $user['id']) { |
|
32 | 32 | classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
33 | 33 | message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']); |
34 | 34 | } |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | |
40 | 40 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
41 | 41 | |
42 | -if($userToAdd_unsafe) { |
|
42 | +if ($userToAdd_unsafe) { |
|
43 | 43 | $userToAdd = db_escape($userToAdd_unsafe); |
44 | 44 | $userToAddID = DBStaticUser::db_user_by_username($userToAdd_unsafe, false, 'id', true, true); |
45 | 45 | $userToAddID = $userToAddID['id']; |
46 | 46 | |
47 | - if($objFleet->target_owner_id == $userToAddID) { |
|
47 | + if ($objFleet->target_owner_id == $userToAddID) { |
|
48 | 48 | message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']); |
49 | 49 | } |
50 | 50 | |
51 | - if($userToAddID) { |
|
52 | - if(!$aks) { |
|
51 | + if ($userToAddID) { |
|
52 | + if (!$aks) { |
|
53 | 53 | // No AСS exists - making one |
54 | - if(!$objFleet->group_id) { |
|
54 | + if (!$objFleet->group_id) { |
|
55 | 55 | DBStaticFleetACS::db_acs_insert($fleetid, $user['id'], $objFleet); |
56 | 56 | |
57 | 57 | $aks = DBStaticFleetACS::db_acs_get_by_fleet($fleetid); |
@@ -66,21 +66,21 @@ discard block |
||
66 | 66 | |
67 | 67 | $isUserExists = false; |
68 | 68 | $invited_ar = explode(",", $aks['eingeladen']); |
69 | - foreach($invited_ar as $inv) { |
|
70 | - if($userToAddID == $inv) { |
|
69 | + foreach ($invited_ar as $inv) { |
|
70 | + if ($userToAddID == $inv) { |
|
71 | 71 | $isUserExists = true; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - if(count($invited_ar) >= 5) { |
|
75 | + if (count($invited_ar) >= 5) { |
|
76 | 76 | message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']); |
77 | 77 | } |
78 | 78 | |
79 | - if($isUserExists) { |
|
79 | + if ($isUserExists) { |
|
80 | 80 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false; |
81 | 81 | } else { |
82 | 82 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd); |
83 | - if(!(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid))) { |
|
83 | + if (!(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid))) { |
|
84 | 84 | die(sprintf(classLocale::$lang['fl_aks_adding_error'], classSupernova::$db->db_error())); |
85 | 85 | } |
86 | 86 | $aks['eingeladen'] .= ',' . $userToAddID; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | 'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS], |
100 | 100 | )); |
101 | 101 | |
102 | -if($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
103 | - foreach($members as $row) { |
|
102 | +if ($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
103 | + foreach ($members as $row) { |
|
104 | 104 | $template->assign_block_vars('invited', array( |
105 | 105 | 'NAME' => $row['username'], |
106 | 106 | )); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
126 | 126 | |
127 | 127 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
128 | -foreach($fleet_data['ships'] as $ship_data) { |
|
128 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
129 | 129 | $template->assign_block_vars('fleets.ships', $ship_data); |
130 | 130 | } |
131 | 131 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | $classLocale = classLocale::$lang; |
7 | 7 | |
8 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
8 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
9 | 9 | classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
10 | 10 | } |
11 | 11 | |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | 'rpg_cost' => $rpg_cost, |
18 | 18 | )); |
19 | 19 | |
20 | -if(is_array($shipList)) { |
|
21 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
20 | +if (is_array($shipList)) { |
|
21 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
22 | 22 | $intError = MARKET_NO_DM; |
23 | 23 | } |
24 | 24 | |
@@ -33,30 +33,30 @@ discard block |
||
33 | 33 | |
34 | 34 | $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>'; |
35 | 35 | $total = array(); |
36 | - foreach($shipList as $shipID => &$shipCount) { |
|
36 | + foreach ($shipList as $shipID => &$shipCount) { |
|
37 | 37 | $shipCount = ceil(floatval($shipCount)); |
38 | - if(!$shipCount) { |
|
38 | + if (!$shipCount) { |
|
39 | 39 | continue; |
40 | 40 | } |
41 | 41 | |
42 | - if($shipCount < 0) { |
|
42 | + if ($shipCount < 0) { |
|
43 | 43 | classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
44 | 44 | $intError = MARKET_NEGATIVE_SHIPS; |
45 | 45 | break; |
46 | 46 | } |
47 | 47 | |
48 | - if($mode == MARKET_SCRAPPER) { |
|
48 | + if ($mode == MARKET_SCRAPPER) { |
|
49 | 49 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
50 | - } elseif($mode == MARKET_STOCKMAN) { |
|
50 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
51 | 51 | $amount = $stock[$shipID]; |
52 | 52 | } |
53 | 53 | |
54 | - if($amount < $shipCount) { |
|
54 | + if ($amount < $shipCount) { |
|
55 | 55 | $intError = $error_no_stock; |
56 | 56 | break; |
57 | 57 | } |
58 | 58 | |
59 | - if(!in_array($shipID, classSupernova::$gc->groupFleet)) { |
|
59 | + if (!in_array($shipID, classSupernova::$gc->groupFleet)) { |
|
60 | 60 | classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
61 | 61 | $intError = MARKET_NOT_A_SHIP; |
62 | 62 | break; |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
73 | 73 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
74 | 74 | |
75 | - foreach($resTemp as $resID => $resCount) { |
|
75 | + foreach ($resTemp as $resID => $resCount) { |
|
76 | 76 | $total[$resID] += $resCount; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount); |
80 | 80 | } |
81 | 81 | |
82 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
83 | - foreach($total as $resID => $resCount) { |
|
84 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
82 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
83 | + foreach ($total as $resID => $resCount) { |
|
84 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
85 | 85 | $intError = MARKET_NO_RESOURCES; |
86 | 86 | classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
87 | 87 | break; |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
93 | 93 | |
94 | 94 | $qry = array(); |
95 | - if($intError == MARKET_DEAL) { |
|
95 | + if ($intError == MARKET_DEAL) { |
|
96 | 96 | $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>'; |
97 | - foreach($total as $resID => $resCount) { |
|
98 | - if(!$resCount) { |
|
97 | + foreach ($total as $resID => $resCount) { |
|
98 | + if (!$resCount) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
@@ -128,38 +128,38 @@ discard block |
||
128 | 128 | 'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError], |
129 | 129 | )); |
130 | 130 | |
131 | - foreach($shipList as $shipID => $shipCount) { |
|
131 | + foreach ($shipList as $shipID => $shipCount) { |
|
132 | 132 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | $message = ''; |
137 | 137 | |
138 | -if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
139 | - classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, classSupernova::$gc->groupFleet))); |
|
138 | +if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
139 | + classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, classSupernova::$gc->groupFleet))); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | tpl_set_resource_info($template, $planetrow, array()); |
143 | 143 | |
144 | -if(!$array) { |
|
144 | +if (!$array) { |
|
145 | 145 | $array = array(); |
146 | 146 | } |
147 | 147 | |
148 | 148 | $group_fleet = classSupernova::$gc->groupFleet; |
149 | -foreach($array as $key => $value) { |
|
150 | - if($mode == MARKET_SCRAPPER) { |
|
149 | +foreach ($array as $key => $value) { |
|
150 | + if ($mode == MARKET_SCRAPPER) { |
|
151 | 151 | $shipID = $value; |
152 | 152 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
153 | - } elseif($mode == MARKET_STOCKMAN) { |
|
153 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
154 | 154 | $shipID = $key; |
155 | 155 | $amount = $value; |
156 | 156 | } |
157 | 157 | |
158 | - if(!in_array($shipID, $group_fleet)) { |
|
158 | + if (!in_array($shipID, $group_fleet)) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | - if($amount > 0) { |
|
162 | + if ($amount > 0) { |
|
163 | 163 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
164 | 164 | $template->assign_block_vars('ships', array( |
165 | 165 | 'ID' => $shipID, |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | |
44 | 44 | $sta_update_msg = db_escape($sta_update_msg); |
45 | 45 | |
46 | - if($next_step) { |
|
46 | + if ($next_step) { |
|
47 | 47 | $sta_update_step++; |
48 | 48 | } |
49 | 49 | $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}."; |
50 | 50 | |
51 | 51 | classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg); |
52 | - if($next_step) { |
|
52 | + if ($next_step) { |
|
53 | 53 | classSupernova::$debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | 57 | function sys_stat_calculate_flush(&$data, $force = false) { |
58 | - if(count($data) < 25 && !$force) { |
|
58 | + if (count($data) < 25 && !$force) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - if(!empty($data)) { |
|
62 | + if (!empty($data)) { |
|
63 | 63 | classSupernova::$gc->db->doInsertBatch( |
64 | 64 | TABLE_STAT_POINTS, $data, array( |
65 | 65 | 'id_owner', |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | classSupernova::$gc->cacheOperator->db_lock_tables('users'); |
115 | 115 | $user_list = DBStaticUser::db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id'); |
116 | 116 | $row_num = count($user_list); |
117 | - foreach($user_list as $player) { |
|
118 | - if($i++ % 100 == 0) { |
|
117 | + foreach ($user_list as $player) { |
|
118 | + if ($i++ % 100 == 0) { |
|
119 | 119 | sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false); |
120 | 120 | } |
121 | - if(array_key_exists($user_id = $player['id'], $user_skip_list)) { |
|
121 | + if (array_key_exists($user_id = $player['id'], $user_skip_list)) { |
|
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $counts[$user_id][UNIT_RESOURCES] += $resources; |
128 | 128 | |
129 | 129 | // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что |
130 | - if(!isset($user_skip_list[$user_id])) { |
|
130 | + if (!isset($user_skip_list[$user_id])) { |
|
131 | 131 | $user_allies[$user_id] = $player['ally_id']; |
132 | 132 | } |
133 | 133 | } |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | $i = 0; |
140 | 140 | $query = DBStaticPlanet::db_planet_list_resources_by_owner(); |
141 | 141 | $row_num = classSupernova::$db->db_num_rows($query); |
142 | - while($planet = db_fetch($query)) { |
|
143 | - if($i++ % 100 == 0) { |
|
142 | + while ($planet = db_fetch($query)) { |
|
143 | + if ($i++ % 100 == 0) { |
|
144 | 144 | sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false); |
145 | 145 | } |
146 | - if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
|
146 | + if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
|
147 | 147 | continue; |
148 | 148 | } |
149 | 149 | |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | $i = 0; |
158 | 158 | $query = FleetList::dbQueryAllId(); |
159 | 159 | $row_num = classSupernova::$db->db_num_rows($query); |
160 | - while($fleet_row = db_fetch($query)) { |
|
161 | - if($i++ % 100 == 0) { |
|
160 | + while ($fleet_row = db_fetch($query)) { |
|
161 | + if ($i++ % 100 == 0) { |
|
162 | 162 | sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false); |
163 | 163 | } |
164 | 164 | $objFleet = new Fleet(); |
165 | 165 | // TODO - без дополнительной инициализации и перераспределений памяти на каждый new Fleet()/unset($fleet) |
166 | 166 | // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными |
167 | 167 | $objFleet->dbRowParse($fleet_row); |
168 | - if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) { |
|
168 | + if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) { |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | |
172 | - foreach($objFleet->shipsIterator() as $unit_id => $unit) { |
|
172 | + foreach ($objFleet->shipsIterator() as $unit_id => $unit) { |
|
173 | 173 | $counts[$user_id][UNIT_SHIPS] += $unit->count; |
174 | 174 | |
175 | - if(!isset($unit_cost_cache[$unit_id][0])) { |
|
175 | + if (!isset($unit_cost_cache[$unit_id][0])) { |
|
176 | 176 | $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST); |
177 | 177 | } |
178 | 178 | $unit_cost_data = &$unit_cost_cache[$unit_id][0]; |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $i = 0; |
192 | 192 | $query = DBStaticUnit::db_unit_list_stat_calculate(); |
193 | 193 | $row_num = classSupernova::$db->db_num_rows($query); |
194 | - while($unit = db_fetch($query)) { |
|
195 | - if($i++ % 100 == 0) { |
|
194 | + while ($unit = db_fetch($query)) { |
|
195 | + if ($i++ % 100 == 0) { |
|
196 | 196 | sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false); |
197 | 197 | } |
198 | - if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
|
198 | + if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
|
199 | 199 | continue; |
200 | 200 | } |
201 | 201 | |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | $i = 0; |
210 | 210 | $query = DBStaticQue::db_que_list_stat(); |
211 | 211 | $row_num = classSupernova::$db->db_num_rows($query); |
212 | - while($que_item = db_fetch($query)) { |
|
213 | - if($i++ % 100 == 0) { |
|
212 | + while ($que_item = db_fetch($query)) { |
|
213 | + if ($i++ % 100 == 0) { |
|
214 | 214 | sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false); |
215 | 215 | } |
216 | - if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
|
216 | + if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
|
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | $que_unit_amount = $que_item['que_unit_amount']; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | sta_set_time_limit('posting new user stats to DB'); |
242 | 242 | $data = array(); |
243 | - foreach($user_allies as $user_id => $ally_id) { |
|
243 | + foreach ($user_allies as $user_id => $ally_id) { |
|
244 | 244 | $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000; |
245 | 245 | $points[$user_id] = array_map('floor', $points[$user_id]); |
246 | 246 | $counts[$user_id] = array_map('floor', $counts[$user_id]); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | // Updating player's ranks |
316 | 316 | sta_set_time_limit("updating ranks for players"); |
317 | - foreach($rankNames as $rankName) { |
|
317 | + foreach ($rankNames as $rankName) { |
|
318 | 318 | sta_set_time_limit("updating player rank '{$rankName}'", false); |
319 | 319 | classSupernova::$db->doSql($qryResetRowNum); |
320 | 320 | classSupernova::$db->doUpdateReallyComplex(sprintf($qryFormat, $rankName, 1)); |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | sta_set_time_limit("updating ranks for Alliances"); |
324 | 324 | // Updating Allie's ranks |
325 | - foreach($rankNames as $rankName) { |
|
325 | + foreach ($rankNames as $rankName) { |
|
326 | 326 | sta_set_time_limit("updating Alliances rank '{$rankName}'", false); |
327 | 327 | classSupernova::$db->doSql($qryResetRowNum); |
328 | 328 | classSupernova::$db->doUpdateReallyComplex(sprintf($qryFormat, $rankName, 2)); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | $unit_level = $artifact_level_old = mrc_get_level($user, null, $unit_id, true); |
20 | 20 | if ($unit_level > 0) { |
21 | - switch($unit_id) { |
|
21 | + switch ($unit_id) { |
|
22 | 22 | case ART_LHC: |
23 | 23 | case ART_HOOK_SMALL: |
24 | 24 | case ART_HOOK_MEDIUM: |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | function flt_mission_relocate($mission_data) { |
13 | 13 | $objFleet = $mission_data->fleet; |
14 | 14 | $destination_planet = &$mission_data->dst_planet; |
15 | - if($objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
15 | + if ($objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
16 | 16 | $objFleet->markReturnedAndSave(); |
17 | 17 | |
18 | 18 | return; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $fleet_resources[RES_CRYSTAL], classLocale::$lang['Crystal'], |
27 | 27 | $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium'] |
28 | 28 | ) . '<br />' . classLocale::$lang['sys_relocate_mess_user']; |
29 | - foreach($objFleet->shipsIterator() as $ship_id => $ship) { |
|
29 | + foreach ($objFleet->shipsIterator() as $ship_id => $ship) { |
|
30 | 30 | $Message .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship->count . '<br />'; |
31 | 31 | } |
32 | 32 | DBStaticMessages::msg_send_simple_message( |
@@ -4,19 +4,19 @@ discard block |
||
4 | 4 | |
5 | 5 | $classLocale = classLocale::$lang; |
6 | 6 | |
7 | -if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
7 | +if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
8 | 8 | include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX); |
9 | 9 | } |
10 | 10 | |
11 | -if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
11 | +if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
12 | 12 | require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX); |
13 | 13 | sn_user_birthday_celebrate(); |
14 | 14 | } |
15 | 15 | |
16 | -if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
16 | +if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
17 | 17 | classSupernova::$config->db_saveItem('var_online_user_count', DBStaticUser::db_user_count(true)); |
18 | 18 | classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW); |
19 | - if(classSupernova::$config->server_log_online) { |
|
19 | + if (classSupernova::$config->server_log_online) { |
|
20 | 20 | db_log_online_insert(); |
21 | 21 | } |
22 | 22 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id']; |
44 | 44 | //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die(); |
45 | 45 | |
46 | -if(!empty($user['id'])) { |
|
46 | +if (!empty($user['id'])) { |
|
47 | 47 | classSupernova::$user_options->user_change($user['id']); |
48 | 48 | } |
49 | 49 | |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | : false |
57 | 57 | ); |
58 | 58 | |
59 | -if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
60 | - $prohibited_characters = array_map(function ($value) { |
|
59 | +if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
60 | + $prohibited_characters = array_map(function($value) { |
|
61 | 61 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
62 | 62 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
63 | 63 | $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters); |
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | -if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
67 | +if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
68 | 68 | pdump("Отключи отладку перед продакшном!"); |
69 | 69 | } |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ? define('INSTALL_MODE', GAME_DISABLE_INSTALL) |
79 | 79 | : false; |
80 | 80 | |
81 | -if( |
|
81 | +if ( |
|
82 | 82 | classSupernova::$config->game_disable == GAME_DISABLE_STAT |
83 | 83 | && |
84 | 84 | SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) > 600 |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | classSupernova::$debug->warning('Stat worked too long - watchdog unlocked', 'Stat WARNING'); |
92 | 92 | } |
93 | 93 | |
94 | -if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
94 | +if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
95 | 95 | $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse( |
96 | 96 | classSupernova::$config->game_disable == GAME_DISABLE_REASON |
97 | 97 | ? classSupernova::$config->game_disable_reason |
98 | 98 | : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable] |
99 | 99 | ); |
100 | - if(defined('IN_API')) { |
|
100 | + if (defined('IN_API')) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
104 | - if( |
|
104 | + if ( |
|
105 | 105 | ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN)) |
106 | 106 | && |
107 | 107 | !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT')) |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | |
116 | 116 | // TODO ban |
117 | 117 | // TODO $skip_ban_check |
118 | -if($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
119 | - if(defined('IN_API')) { |
|
118 | +if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
119 | + if (defined('IN_API')) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | // pdump($allow_anonymous, '$allow_anonymous'); |
135 | 135 | // pdump($sys_user_logged_in, '$sys_user_logged_in'); |
136 | 136 | |
137 | -if($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
137 | +if ($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
138 | 138 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
139 | -} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
139 | +} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
140 | 140 | // pdump($sn_page_name); |
141 | 141 | // pdump(INITIAL_PAGE); |
142 | 142 | // die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}'); |
143 | -} elseif(!$allow_anonymous && !$sys_user_logged_in) { |
|
143 | +} elseif (!$allow_anonymous && !$sys_user_logged_in) { |
|
144 | 144 | // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
145 | 145 | sys_redirect(SN_ROOT_VIRTUAL . 'login.php'); |
146 | 146 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | global $skip_fleet_update; |
163 | 163 | $skip_fleet_update = $skip_fleet_update || classSupernova::$options['fleet_update_skip'] || defined('IN_ADMIN'); |
164 | -if( |
|
164 | +if ( |
|
165 | 165 | !$skip_fleet_update |
166 | 166 | && !(defined('IN_AJAX') && IN_AJAX === true) |
167 | 167 | && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | flt_flying_fleet_handler($skip_fleet_update); |
171 | 171 | } |
172 | 172 | |
173 | -if(!defined('IN_AJAX')) { |
|
173 | +if (!defined('IN_AJAX')) { |
|
174 | 174 | pdump("Scheduled processes is disabled"); |
175 | 175 | } |
176 | 176 | // scheduler_process(); |
@@ -298,7 +298,7 @@ |
||
298 | 298 | |
299 | 299 | if (!empty($resourcesChange)) { |
300 | 300 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
301 | - if($planet_id) { |
|
301 | + if ($planet_id) { |
|
302 | 302 | // update planet |
303 | 303 | DBStaticPlanet::db_planet_update_resources($resourcesChange, $planet_id); |
304 | 304 | } else { |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | $ts_var_stat_update = strtotime(classSupernova::$config->db_loadItem('var_stat_update')); |
10 | 10 | $ts_scheduled_update = sys_schedule_get_prev_run(classSupernova::$config->db_loadItem('stats_schedule'), classSupernova::$config->var_stat_update); |
11 | 11 | |
12 | - if(sys_get_param_int('admin_update')) { |
|
12 | + if (sys_get_param_int('admin_update')) { |
|
13 | 13 | define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1); |
14 | - if(USER_LEVEL > 0) { |
|
14 | + if (USER_LEVEL > 0) { |
|
15 | 15 | $is_admin_request = true; |
16 | 16 | $ts_scheduled_update = SN_TIME_NOW; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - if($ts_scheduled_update > $ts_var_stat_update) { |
|
20 | + if ($ts_scheduled_update > $ts_var_stat_update) { |
|
21 | 21 | lng_include('admin'); |
22 | 22 | sn_db_transaction_start(); |
23 | 23 | $ts_var_stat_update_end = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')); |
24 | - if(SN_TIME_NOW > $ts_var_stat_update_end) { |
|
24 | + if (SN_TIME_NOW > $ts_var_stat_update_end) { |
|
25 | 25 | $old_server_status = classSupernova::$config->db_loadItem('game_disable'); |
26 | 26 | classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_STAT); |
27 | 27 | |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | classSupernova::$config->db_saveItem('var_stat_update_admin_forced', SN_TIME_SQL); |
57 | 57 | classSupernova::$config->db_saveItem('var_stat_update_end', SN_TIME_SQL); |
58 | 58 | |
59 | - if($old_server_status == GAME_DISABLE_STAT) { |
|
59 | + if ($old_server_status == GAME_DISABLE_STAT) { |
|
60 | 60 | $old_server_status = GAME_DISABLE_NONE; |
61 | 61 | } |
62 | 62 | classSupernova::$config->db_saveItem('game_disable', $old_server_status); |
63 | - } elseif($ts_scheduled_update > $ts_var_stat_update) { |
|
63 | + } elseif ($ts_scheduled_update > $ts_var_stat_update) { |
|
64 | 64 | $timeout = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW; |
65 | 65 | $msg = classSupernova::$config->db_loadItem('var_stat_update_msg'); |
66 | 66 | $msg = "{$msg} ETA {$timeout} seconds. Please wait..."; |
67 | 67 | } |
68 | 68 | sn_db_transaction_rollback(); |
69 | - } elseif($is_admin_request) { |
|
69 | + } elseif ($is_admin_request) { |
|
70 | 70 | $msg = 'Stat is up to date'; |
71 | 71 | } |
72 | 72 |
@@ -83,8 +83,8 @@ |
||
83 | 83 | $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4; |
84 | 84 | } |
85 | 85 | |
86 | - $return['structures'] = $structures; // Structures left after attack |
|
87 | - $return['metal'] = floor($metal); // Metal scraps |
|
86 | + $return['structures'] = $structures; // Structures left after attack |
|
87 | + $return['metal'] = floor($metal); // Metal scraps |
|
88 | 88 | $return['crystal'] = floor($crystal); // Crystal scraps |
89 | 89 | |
90 | 90 | return $return; |