@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
40 | 40 | |
41 | 41 | $target_mission = sys_get_param_int('target_mission'); |
42 | -if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
42 | +if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
43 | 43 | $planet_type = PT_PLANET; |
44 | -} elseif($target_mission == MT_RECYCLE) { |
|
44 | +} elseif ($target_mission == MT_RECYCLE) { |
|
45 | 45 | $planet_type = PT_DEBRIS; |
46 | -} elseif($target_mission == MT_DESTROY) { |
|
46 | +} elseif ($target_mission == MT_DESTROY) { |
|
47 | 47 | $planet_type = PT_MOON; |
48 | 48 | } else { |
49 | 49 | $planet_type = sys_get_param_int('planet_type'); |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | //$FlyingFleets = doquery("SELECT COUNT(fleet_id) as Number FROM {{fleets}} WHERE `fleet_owner`='{$user['id']}'", true); |
60 | 60 | //$FlyingFleets = $FlyingFleets['Number']; |
61 | 61 | $FlyingFleets = fleet_count_flying($user['id']); |
62 | -if($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) { |
|
62 | +if ($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) { |
|
63 | 63 | message($lang['fl_noslotfree'], $lang['fl_error'], "fleet." . PHP_EX, 5); |
64 | 64 | } |
65 | 65 | |
66 | 66 | $MaxExpeditions = get_player_max_expeditons($user); |
67 | -if($MaxExpeditions) { |
|
67 | +if ($MaxExpeditions) { |
|
68 | 68 | // $FlyingExpeditions = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", '', true); |
69 | 69 | // $FlyingExpeditions = $FlyingExpeditions['expedi']; |
70 | - $FlyingExpeditions = fleet_count_flying($user['id'], MT_EXPLORE); |
|
70 | + $FlyingExpeditions = fleet_count_flying($user['id'], MT_EXPLORE); |
|
71 | 71 | } else { |
72 | 72 | $FlyingExpeditions = 0; |
73 | 73 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | $fleetarray = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet')))); |
81 | 81 | $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
82 | 82 | |
83 | - foreach($fleetarray as $ship_id => &$ship_amount) { |
|
84 | - if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
83 | + foreach ($fleetarray as $ship_id => &$ship_amount) { |
|
84 | + if (!in_array($ship_id, sn_get_groups('fleet')) || (string) floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
85 | 85 | $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
86 | 86 | die(); |
87 | 87 | } |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | $target_mission = MT_COLONIZE; |
113 | 113 | $planet_type = PT_PLANET; |
114 | 114 | } else { |
115 | - message ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']); |
|
115 | + message("<font color=\"red\"><b>" . $lang['fl_no_planet_type'] . "</b></font>", $lang['fl_error']); |
|
116 | 116 | } |
117 | 117 | } else { |
118 | 118 | $recyclers = 0; |
119 | - foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
119 | + foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
|
120 | 120 | $recyclers += $fleetarray[$recycler_id]; |
121 | 121 | } |
122 | 122 | if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD]; |
143 | 143 | |
144 | - if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
144 | + if ($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
145 | 145 | $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY]; |
146 | 146 | } |
147 | 147 | } |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | ); |
202 | 202 | |
203 | 203 | $is_transport_missions = false; |
204 | -if($missiontype) { |
|
204 | +if ($missiontype) { |
|
205 | 205 | $sn_group_missions = sn_get_groups('missions'); |
206 | - foreach($missiontype as $mission_data_id => $mission_data) { |
|
206 | + foreach ($missiontype as $mission_data_id => $mission_data) { |
|
207 | 207 | $is_transport_missions = $is_transport_missions || (isset($sn_group_missions[$mission_data_id]['transport']) && $sn_group_missions[$mission_data_id]['transport']); |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | -switch($fleet_page) { |
|
211 | +switch ($fleet_page) { |
|
212 | 212 | case 1: |
213 | 213 | require('includes/includes/flt_page1.inc'); |
214 | 214 | break; |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | $sn_group_factories = sn_get_groups('factories'); |
23 | 23 | $planet_density = sn_get_groups('planet_density'); |
24 | 24 | |
25 | - if(sys_get_param('save_production')) { |
|
25 | + if (sys_get_param('save_production')) { |
|
26 | 26 | $production = sys_get_param('percent'); |
27 | - if(is_array($production) && !empty($production)) { |
|
27 | + if (is_array($production) && !empty($production)) { |
|
28 | 28 | // sn_db_transaction_start(); |
29 | 29 | $query = array(); |
30 | 30 | $planet_row_list = DBStaticPlanet::db_planet_list_sorted($user, false, '*'); |
31 | 31 | // while($planet = db_fetch($planet_row_list)) |
32 | - foreach($planet_row_list as $planet) { |
|
33 | - foreach($sn_group_factories as $factory_unit_id) { |
|
32 | + foreach ($planet_row_list as $planet) { |
|
33 | + foreach ($sn_group_factories as $factory_unit_id) { |
|
34 | 34 | $unit_db_name_porcent = pname_factory_production_field_name($factory_unit_id); |
35 | - if( |
|
35 | + if ( |
|
36 | 36 | get_unit_param($factory_unit_id, P_MINING_IS_MANAGED) |
37 | 37 | && isset($production[$factory_unit_id][$planet['id']]) |
38 | 38 | && ($actual_porcent = intval($production[$factory_unit_id][$planet['id']] / 10)) >= 0 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | - foreach($query as $planet_id => $query_data) { |
|
46 | + foreach ($query as $planet_id => $query_data) { |
|
47 | 47 | DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $query_data)); |
48 | 48 | } |
49 | 49 | // sn_db_transaction_commit(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | $planet_row_list = DBStaticPlanet::db_planet_list_sorted($user); |
54 | 54 | // while ($planet = db_fetch($planet_row_list)) |
55 | - foreach($planet_row_list as $planet) { |
|
55 | + foreach ($planet_row_list as $planet) { |
|
56 | 56 | sn_db_transaction_start(); |
57 | 57 | $global_data = sys_o_get_updated($user, $planet['id'], SN_TIME_NOW, false, true); |
58 | 58 | $planets[$planet['id']] = $global_data['planet']; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $template = gettemplate('imperium', $template); |
65 | 65 | $template->assign_var('amount', count($planets) + 2); |
66 | 66 | |
67 | - for($i = 100; $i >= 0; $i -= 10) { |
|
67 | + for ($i = 100; $i >= 0; $i -= 10) { |
|
68 | 68 | $template->assign_block_vars('percent', array('PERCENT' => $i)); |
69 | 69 | } |
70 | 70 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $planet_template = tpl_parse_planet($planet); |
80 | 80 | |
81 | 81 | $planet_fleet_id = 0; |
82 | - $fleet_list = $planet_template['fleet_list'];//flt_get_fleets_to_planet($planet); |
|
83 | - if($fleet_list['own']['count']) |
|
82 | + $fleet_list = $planet_template['fleet_list']; //flt_get_fleets_to_planet($planet); |
|
83 | + if ($fleet_list['own']['count']) |
|
84 | 84 | { |
85 | 85 | $planet_fleet_id = "p{$fleet_id}"; |
86 | 86 | $fleets[] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id); |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | UNIT_DEFENCE => 'defense', |
143 | 143 | ); |
144 | 144 | |
145 | - foreach($show_groups as $unit_group_id => $mode) |
|
145 | + foreach ($show_groups as $unit_group_id => $mode) |
|
146 | 146 | { |
147 | 147 | $template->assign_block_vars('prods', array( |
148 | 148 | 'NAME' => $lang['tech'][$unit_group_id], |
149 | 149 | )); |
150 | 150 | $unit_group = get_unit_param('techtree', $unit_group_id); |
151 | - foreach($unit_group as $unit_id) |
|
151 | + foreach ($unit_group as $unit_id) |
|
152 | 152 | { |
153 | 153 | $unit_count = $unit_count_abs = 0; |
154 | 154 | $block_vars = array(); |
155 | 155 | $unit_is_factory = in_array($unit_id, $sn_group_factories) && get_unit_param($unit_id, P_MINING_IS_MANAGED); |
156 | 156 | // $unit_db_name = pname_resource_name($unit_id); |
157 | - foreach($planets as $planet) |
|
157 | + foreach ($planets as $planet) |
|
158 | 158 | { |
159 | 159 | $unit_level_plain = mrc_get_level($user, $planet, $unit_id, false, true); |
160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $level_plus['LEVEL_PLUS_GREEN'] = 0; |
164 | 164 | |
165 | 165 | $level_plus['PERCENT'] = $unit_is_factory ? ($unit_level_plain ? $planet[pname_factory_production_field_name($unit_id)] * 10 : -1) : -1; |
166 | - switch($mode) |
|
166 | + switch ($mode) |
|
167 | 167 | { |
168 | 168 | /* |
169 | 169 | case 'structures': |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | |
179 | 179 | /** @noinspection PhpMissingBreakStatementInspection */ |
180 | 180 | case 'fleet': |
181 | - $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id]<=0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}"; |
|
181 | + $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id] <= 0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}"; |
|
182 | 182 | $total['units'][$unit_id]['LEVEL_PLUS_YELLOW'] += $level_plus['LEVEL_PLUS_YELLOW']; |
183 | 183 | |
184 | 184 | case 'structures': |
185 | 185 | case 'defense': |
186 | 186 | $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id]; |
187 | - if($level_plus_build) |
|
187 | + if ($level_plus_build) |
|
188 | 188 | { |
189 | 189 | $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build < 0 ? $level_plus_build : "+{$level_plus_build}"; |
190 | 190 | // $level_plus['LEVEL_PLUS_GREEN'] = "+{$level_plus_build}"; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $unit_count_abs += $unit_level_plain + abs($level_plus['LEVEL_PLUS_YELLOW']) + abs($level_plus['LEVEL_PLUS_GREEN']); |
206 | 206 | } |
207 | 207 | |
208 | - if($unit_count_abs) |
|
208 | + if ($unit_count_abs) |
|
209 | 209 | { |
210 | 210 | $template->assign_block_vars('prods', array( |
211 | 211 | 'ID' => $unit_id, |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | 'MODE' => $mode, |
215 | 215 | )); |
216 | 216 | |
217 | - foreach($block_vars as $block_var) |
|
217 | + foreach ($block_vars as $block_var) |
|
218 | 218 | { |
219 | 219 | $template->assign_block_vars('prods.planet', $block_var); |
220 | 220 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // $same_user = false; |
54 | 54 | // } |
55 | 55 | |
56 | - if(!$user_data) { |
|
56 | + if (!$user_data) { |
|
57 | 57 | message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10); |
58 | 58 | die(); |
59 | 59 | } |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $stat_array = array(); |
65 | 65 | $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;"); |
66 | 66 | $stat_count = classSupernova::$db->db_affected_rows(); |
67 | - while($row = db_fetch($query)) { |
|
68 | - foreach($stat_fields as $field_db_name => $field_template_name) { |
|
67 | + while ($row = db_fetch($query)) { |
|
68 | + foreach ($stat_fields as $field_db_name => $field_template_name) { |
|
69 | 69 | // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS |
70 | 70 | $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name]; |
71 | 71 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $stat_array_date = $stat_array['STAT_DATE']; |
75 | 75 | empty($stat_array_date['DATA']) ? $stat_array_date['DATA'] = array() : false; |
76 | - foreach($stat_array_date['DATA'] as $key => $value) { |
|
76 | + foreach ($stat_array_date['DATA'] as $key => $value) { |
|
77 | 77 | $template->assign_block_vars('stat_date', array( |
78 | 78 | 'ID' => $key, |
79 | 79 | 'VALUE' => $value, |
@@ -83,21 +83,21 @@ discard block |
||
83 | 83 | |
84 | 84 | unset($stat_array['STAT_DATE']); |
85 | 85 | $template_data = array(); |
86 | - foreach($stat_array as $stat_type => &$stat_type_data) { |
|
86 | + foreach ($stat_array as $stat_type => &$stat_type_data) { |
|
87 | 87 | $reverse_min_max = strpos($stat_type, '_RANK') !== false; |
88 | 88 | $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']); |
89 | 89 | $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']); |
90 | 90 | $stat_type_data['AVG'] = average($stat_type_data['DATA']); |
91 | - foreach($stat_type_data['DATA'] as $key => $value) { |
|
91 | + foreach ($stat_type_data['DATA'] as $key => $value) { |
|
92 | 92 | $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100; |
93 | 93 | $template_data[$stat_type][$key]['ID'] = $key; |
94 | 94 | $template_data[$stat_type][$key]['VALUE'] = $value; |
95 | - $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
95 | + $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
96 | 96 | $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key]; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - foreach($template_data as $stat_type => $stat_type_data) { |
|
100 | + foreach ($template_data as $stat_type => $stat_type_data) { |
|
101 | 101 | $template->assign_block_vars('stat', array( |
102 | 102 | 'TYPE' => $stat_type, |
103 | 103 | 'TEXT' => $lang['imp_stat_types'][$stat_type], |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | 'MAX' => $stat_array[$stat_type]['MAX'], |
106 | 106 | 'AVG' => $stat_array[$stat_type]['AVG'], |
107 | 107 | )); |
108 | - foreach($stat_type_data as $stat_entry) { |
|
108 | + foreach ($stat_type_data as $stat_entry) { |
|
109 | 109 | $template->assign_block_vars('stat.entry', $stat_entry); |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | 113 | |
114 | - if($same_user) { |
|
114 | + if ($same_user) { |
|
115 | 115 | rpg_level_up($user, RPG_STRUCTURE); |
116 | 116 | rpg_level_up($user, RPG_RAID); |
117 | 117 | rpg_level_up($user, RPG_TECH); |
@@ -145,29 +145,29 @@ discard block |
||
145 | 145 | 'builder_xp' => pretty_number($user_data['xpminier']), |
146 | 146 | 'builder_lvl' => pretty_number($user_data['lvl_minier']), |
147 | 147 | 'builder_lvl_st' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])), |
148 | - 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)), |
|
148 | + 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), |
|
149 | 149 | 'raid_xp' => pretty_number($user_data['xpraid']), |
150 | 150 | 'raid_lvl' => pretty_number($user_data['lvl_raid']), |
151 | - 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)), |
|
151 | + 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), |
|
152 | 152 | 'raids' => pretty_number($user_data['raids']), |
153 | 153 | 'raidswin' => pretty_number($user_data['raidswin']), |
154 | 154 | 'raidsloose' => pretty_number($user_data['raidsloose']), |
155 | 155 | 'tech_xp' => pretty_number($user_data['player_rpg_tech_xp']), |
156 | 156 | 'tech_lvl' => pretty_number($user_data['player_rpg_tech_level']), |
157 | 157 | 'tech_lvl_st' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), |
158 | - 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)), |
|
158 | + 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), |
|
159 | 159 | |
160 | 160 | 'explore_xp' => pretty_number($user_data['player_rpg_explore_xp']), |
161 | 161 | 'explore_lvl' => pretty_number($user_data['player_rpg_explore_level']), |
162 | 162 | 'explore_lvl_st' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), |
163 | - 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)), |
|
164 | - |
|
165 | - 'build_points' => pretty_number( $StatRecord['build_points'] ), |
|
166 | - 'tech_points' => pretty_number( $StatRecord['tech_points'] ), |
|
167 | - 'fleet_points' => pretty_number( $StatRecord['fleet_points'] ), |
|
168 | - 'defs_points' => pretty_number( $StatRecord['defs_points'] ), |
|
169 | - 'res_points' => pretty_number( $StatRecord['res_points'] ), |
|
170 | - 'total_points' => pretty_number( $StatRecord['total_points'] ), |
|
163 | + 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), |
|
164 | + |
|
165 | + 'build_points' => pretty_number($StatRecord['build_points']), |
|
166 | + 'tech_points' => pretty_number($StatRecord['tech_points']), |
|
167 | + 'fleet_points' => pretty_number($StatRecord['fleet_points']), |
|
168 | + 'defs_points' => pretty_number($StatRecord['defs_points']), |
|
169 | + 'res_points' => pretty_number($StatRecord['res_points']), |
|
170 | + 'total_points' => pretty_number($StatRecord['total_points']), |
|
171 | 171 | 'user_rank' => $StatRecord['total_rank'], |
172 | 172 | 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], |
173 | 173 |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | function db_unit_records_sum($unit_id, $user_skip_list_unit) |
105 | 105 | { |
106 | - return doquery ( |
|
106 | + return doquery( |
|
107 | 107 | "SELECT unit_player_id, username, sum(unit_level) as unit_level |
108 | 108 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
109 | 109 | WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit} |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | function db_unit_records_plain($unit_id, $user_skip_list_unit) |
117 | 117 | { |
118 | - return doquery ( |
|
118 | + return doquery( |
|
119 | 119 | "SELECT unit_player_id, username, unit_level |
120 | 120 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
121 | 121 | WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit} |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) { |
128 | - if(!$source) { |
|
128 | + if (!$source) { |
|
129 | 129 | $source = array( |
130 | 130 | 'statpoints' => 'statpoints', |
131 | 131 | 'users' => 'users', |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | ); |
147 | 147 | } |
148 | 148 | |
149 | - if($who == 1) { |
|
150 | - if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
149 | + if ($who == 1) { |
|
150 | + if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
151 | 151 | $query_str = |
152 | 152 | "SELECT |
153 | 153 | @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.* |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | ORDER BY |
162 | 162 | sp.`{$Rank}_rank`, subject.{$source['id']} |
163 | 163 | LIMIT |
164 | - ". $start .",100;"; |
|
164 | + " . $start . ",100;"; |
|
165 | 165 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
166 | 166 | $query_str = |
167 | 167 | "SELECT |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | ORDER BY |
175 | 175 | subject.{$Rank} DESC, subject.{$source['id']} |
176 | 176 | LIMIT |
177 | - ". $start .",100;"; |
|
177 | + " . $start . ",100;"; |
|
178 | 178 | } |
179 | 179 | } else { |
180 | 180 | // TODO |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | ORDER BY |
192 | 192 | sp.`{$Rank}_rank`, subject.id |
193 | 193 | LIMIT |
194 | - ". $start .",100;"; |
|
194 | + " . $start . ",100;"; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return doquery($query_str); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
278 | 278 | $current_value_safe = db_escape($current_value_unsafe); |
279 | 279 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
280 | - if(!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
280 | + if (!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
281 | 281 | doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');"); |
282 | 282 | $variable_id = db_insert_id(); |
283 | 283 | } else { |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | */ |
28 | 28 | function db_set_make_safe_string($set, $delta = false) { |
29 | 29 | $set_safe = array(); |
30 | - foreach($set as $field => $value) { |
|
31 | - if(empty($field)) { |
|
30 | + foreach ($set as $field => $value) { |
|
31 | + if (empty($field)) { |
|
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $field = '`' . db_escape($field) . '`'; |
36 | 36 | $new_value = $value; |
37 | - if($value === null) { |
|
37 | + if ($value === null) { |
|
38 | 38 | $new_value = 'NULL'; |
39 | - } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) { |
|
39 | + } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) { |
|
40 | 40 | // non-float |
41 | 41 | $new_value = '"' . db_escape($value) . '"'; |
42 | - } elseif($delta) { |
|
42 | + } elseif ($delta) { |
|
43 | 43 | // float and DELTA-set |
44 | 44 | $new_value = "{$field} + ({$new_value})"; |
45 | 45 | } |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function missile_list_convert_to_fleet(&$missile_db_list, &$fleet_db_list) { |
61 | 61 | // Missile attack |
62 | - foreach($missile_db_list as $irak) { |
|
63 | - if($irak['fleet_end_time'] >= SN_TIME_NOW) { |
|
62 | + foreach ($missile_db_list as $irak) { |
|
63 | + if ($irak['fleet_end_time'] >= SN_TIME_NOW) { |
|
64 | 64 | $irak['fleet_start_type'] = PT_PLANET; |
65 | 65 | $planet_start = DBStaticPlanet::db_planet_by_vector($irak, 'fleet_start_', false, 'name'); |
66 | 66 | $irak['fleet_id'] = -$irak['id']; |
@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | $fleet_events = array(); |
9 | 9 | $fleet_number = 0; |
10 | 10 | |
11 | - if(empty($fleet_list)) |
|
11 | + if (empty($fleet_list)) |
|
12 | 12 | { |
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
16 | - foreach($fleet_list as $fleet) |
|
16 | + foreach ($fleet_list as $fleet) |
|
17 | 17 | { |
18 | 18 | $planet_start_type = $fleet['fleet_start_type'] == PT_MOON ? PT_MOON : PT_PLANET; |
19 | 19 | $planet_start = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_start_galaxy'], $fleet['fleet_start_system'], $fleet['fleet_start_planet'], $planet_start_type, false, 'name'); |
20 | 20 | $fleet['fleet_start_name'] = $planet_start['name']; |
21 | 21 | |
22 | 22 | $planet_end_type = $fleet['fleet_end_type'] == PT_MOON ? PT_MOON : PT_PLANET; |
23 | - if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
|
23 | + if ($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
|
24 | 24 | { |
25 | 25 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
26 | 26 | } |
27 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
27 | + elseif ($fleet['fleet_mission'] == MT_COLONIZE) |
|
28 | 28 | { |
29 | 29 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $fleet['fleet_end_name'] = $planet_end['name']; |
35 | 35 | } |
36 | 36 | |
37 | - if($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE && |
|
37 | + if ($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE && |
|
38 | 38 | ($planet_scanned === false |
39 | 39 | || |
40 | 40 | ( |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | $fleet_events[] = flt_register_fleet_event($fleet, 0, $planet_end_type); |
50 | 50 | } |
51 | 51 | |
52 | - if($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE) |
|
52 | + if ($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE) |
|
53 | 53 | { |
54 | 54 | $fleet_events[] = flt_register_fleet_event($fleet, 1, $planet_end_type); |
55 | 55 | } |
56 | 56 | |
57 | - if( |
|
57 | + if ( |
|
58 | 58 | $fleet['fleet_end_time'] > SN_TIME_NOW && $fleet['fleet_mission'] != MT_MISSILE && ($fleet['fleet_mess'] == 1 || ($fleet['fleet_mission'] != MT_RELOCATE && $fleet['fleet_mission'] != MT_COLONIZE)) && |
59 | 59 | ( |
60 | 60 | ($planet_scanned === false && $fleet['fleet_owner'] == $user['id']) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $fleet_events[] = flt_register_fleet_event($fleet, 2, $planet_end_type); |
72 | 72 | } |
73 | 73 | |
74 | - if($fleet['fleet_mission'] == MT_MISSILE) |
|
74 | + if ($fleet['fleet_mission'] == MT_MISSILE) |
|
75 | 75 | { |
76 | 76 | $fleet_events[] = flt_register_fleet_event($fleet, 3, $planet_end_type); |
77 | 77 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | global $user, $planetrow, $fleet_number; |
86 | 86 | |
87 | - switch($fleet['ov_label'] = $ov_label) |
|
87 | + switch ($fleet['ov_label'] = $ov_label) |
|
88 | 88 | { |
89 | 89 | case 0: |
90 | 90 | $fleet['event_time'] = $fleet['fleet_start_time']; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | - $fleet['ov_this_planet'] = $is_this_planet;// || $planet_scanned != false; |
|
119 | + $fleet['ov_this_planet'] = $is_this_planet; // || $planet_scanned != false; |
|
120 | 120 | |
121 | - if($fleet['fleet_owner'] == $user['id']) |
|
121 | + if ($fleet['fleet_owner'] == $user['id']) |
|
122 | 122 | { |
123 | 123 | $user_data = $user; |
124 | 124 | } |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | $possible_cores = array(); |
9 | 9 | $probability = 0; |
10 | - foreach($density_list as $possible_core_id => $core_data) { |
|
11 | - if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
10 | + foreach ($density_list as $possible_core_id => $core_data) { |
|
11 | + if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
12 | 12 | continue; |
13 | 13 | } |
14 | 14 | |
15 | - if( |
|
15 | + if ( |
|
16 | 16 | // Core type exists |
17 | 17 | in_array($possible_core_id, $position_data['core_types']) |
18 | 18 | // Limit core type with planet sector count |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | $random = mt_rand(1, $probability); |
35 | 35 | $selected_core = null; |
36 | - foreach($possible_cores as $core_type => $core_info) { |
|
37 | - if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
36 | + foreach ($possible_cores as $core_type => $core_info) { |
|
37 | + if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
38 | 38 | $selected_core = $core_info; |
39 | 39 | break; |
40 | 40 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | $Position = intval($Position); |
61 | 61 | |
62 | - if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
62 | + if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | |
69 | 69 | $planet_generator = sn_get_groups('planet_generator'); |
70 | 70 | |
71 | - if($HomeWorld) { |
|
71 | + if ($HomeWorld) { |
|
72 | 72 | $position_data = $planet_generator[0]; |
73 | 73 | } else { |
74 | 74 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
75 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
75 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
76 | 76 | // Корректируем температуру для планеты-странника |
77 | 77 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
78 | 78 | } |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | $moon_name = ''; |
173 | 173 | $moon_row = array(); |
174 | 174 | $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
175 | - if(!$moon['id']) { |
|
175 | + if (!$moon['id']) { |
|
176 | 176 | $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
177 | 177 | |
178 | - if($moon_planet['id']) { |
|
178 | + if ($moon_planet['id']) { |
|
179 | 179 | $base_storage_size = BASE_STORAGE_SIZE; |
180 | 180 | |
181 | - if(!$moon_chance) { |
|
181 | + if (!$moon_chance) { |
|
182 | 182 | $size = mt_rand(1100, 8999); |
183 | - } elseif($moon_chance <= 100) { |
|
183 | + } elseif ($moon_chance <= 100) { |
|
184 | 184 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
185 | 185 | } else { |
186 | 186 | $size = $moon_chance; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $field_max = ceil($size / 1000); |
198 | 198 | |
199 | - if(isset($options['image']) && $options['image']) { |
|
199 | + if (isset($options['image']) && $options['image']) { |
|
200 | 200 | $moon_image = $options['image']; |
201 | 201 | } else { |
202 | 202 | $moon_image = 'mond'; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
212 | 212 | ); |
213 | 213 | |
214 | - if($update_debris) { |
|
214 | + if ($update_debris) { |
|
215 | 215 | $debris_spent = $moon_chance * 1000000; |
216 | 216 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
217 | 217 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $planet_row['id'] = $user['current_planet']; |
248 | 248 | |
249 | 249 | // Пытаемся переключить на новую планету |
250 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
|
250 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
|
251 | 251 | { |
252 | 252 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
253 | 253 | } |
@@ -257,15 +257,15 @@ discard block |
||
257 | 257 | } |
258 | 258 | |
259 | 259 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
260 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
260 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
261 | 261 | { |
262 | 262 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
263 | 263 | // Если текущей планеты не существует - выставляем Столицу |
264 | - if(!isset($planet_row['id'])) |
|
264 | + if (!isset($planet_row['id'])) |
|
265 | 265 | { |
266 | 266 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
267 | 267 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
268 | - if(!isset($planet_row['id'])) |
|
268 | + if (!isset($planet_row['id'])) |
|
269 | 269 | { |
270 | 270 | global $debug; |
271 | 271 | $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | // Если производилось переключение планеты - делаем запись в юзере |
277 | - if($user['current_planet'] != $planet_row['id']) |
|
277 | + if ($user['current_planet'] != $planet_row['id']) |
|
278 | 278 | { |
279 | 279 | db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
280 | 280 | $user['current_planet'] = $planet_row['id']; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | global $lang; |
300 | 300 | |
301 | - if(!$from['id']) |
|
301 | + if (!$from['id']) |
|
302 | 302 | { |
303 | 303 | $result = $lang['sys_planet_expedition']; |
304 | 304 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | function uni_calculate_moon_chance($FleetDebris) |
338 | 338 | { |
339 | 339 | $MoonChance = $FleetDebris / 1000000; |
340 | - return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance); |
|
340 | + return ($MoonChance < 1) ? 0 : ($MoonChance > 30 ? 30 : $MoonChance); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | function uni_coordinates_valid($coordinates, $prefix = '') |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | global $lang, $config; |
360 | 360 | |
361 | 361 | try { |
362 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
362 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
363 | 363 | throw new exception($lang['ov_teleport_err_cooldown'], ERR_ERROR); |
364 | 364 | } |
365 | 365 | |
366 | - if(mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
366 | + if (mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
367 | 367 | throw new exception($lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
368 | 368 | } |
369 | 369 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | // if(!empty($incoming['incoming'])) { |
376 | 376 | // throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
377 | 377 | // } |
378 | - if(fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
378 | + if (fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
379 | 379 | throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
380 | 380 | } |
381 | 381 | |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | // throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
385 | 385 | //} |
386 | 386 | |
387 | - if(is_array($new_coordinates)) { |
|
387 | + if (is_array($new_coordinates)) { |
|
388 | 388 | $new_coordinates['planet_type'] = PT_PLANET; |
389 | 389 | $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id'); |
390 | - if($incoming['id']) { |
|
390 | + if ($incoming['id']) { |
|
391 | 391 | throw new exception($lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
392 | 392 | } |
393 | 393 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | 'result' => ERR_NONE, |
397 | 397 | 'message' => '', |
398 | 398 | ); |
399 | - } catch(exception $e) { |
|
399 | + } catch (exception $e) { |
|
400 | 400 | $response = array( |
401 | 401 | 'result' => $e->getCode(), |
402 | 402 | 'message' => $e->getMessage(), |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | array('query' => 'DELETE FROM {{aks}} WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM {{fleets}});', 'result' => false, 'error' => '', 'affected_rows' => 0), |
16 | 16 | ); |
17 | 17 | |
18 | - foreach($queries as &$query) |
|
18 | + foreach ($queries as &$query) |
|
19 | 19 | { |
20 | 20 | $query['result'] = doquery($query['query']); |
21 | 21 | $query['error'] = classSupernova::$db->db_error(); |
22 | - $query['affected_rows'] = classSupernova::$db->db_affected_rows(); |
|
22 | + $query['affected_rows'] = classSupernova::$db->db_affected_rows(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | return $queries; |
@@ -51,30 +51,30 @@ discard block |
||
51 | 51 | $recorded_run = strtotime($recorded_run); |
52 | 52 | |
53 | 53 | $prev_run_array = getdate($recorded_run); |
54 | - $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']); |
|
54 | + $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']); |
|
55 | 55 | $today_array = getdate(SN_TIME_NOW); |
56 | - $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']); |
|
56 | + $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']); |
|
57 | 57 | $scheduleList = explode(',', $scheduleList); |
58 | 58 | array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
59 | 59 | $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule)))); |
60 | 60 | |
61 | 61 | $interval = $date_part_names_reverse[count($schedule['schedule_array'])]; |
62 | 62 | |
63 | - foreach($prev_run_array as $index => $date_part) { |
|
63 | + foreach ($prev_run_array as $index => $date_part) { |
|
64 | 64 | $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part; |
65 | 65 | $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index]; |
66 | 66 | } |
67 | - if($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
67 | + if ($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
68 | 68 | unset($schedule['array']['now']); |
69 | 69 | } |
70 | 70 | |
71 | - foreach($schedule['array'] as $name => $array) { |
|
71 | + foreach ($schedule['array'] as $name => $array) { |
|
72 | 72 | $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}"; |
73 | 73 | $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval; |
74 | 74 | $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval; |
75 | 75 | } |
76 | 76 | |
77 | - foreach($schedule['string'] as $string) { |
|
77 | + foreach ($schedule['string'] as $string) { |
|
78 | 78 | $timestamp = strtotime($string); |
79 | 79 | $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string)); |
80 | 80 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | $prev_run = 0; |
86 | 86 | $next_run = 0; |
87 | - foreach($possible_schedules as $timestamp => $string_date) { |
|
87 | + foreach ($possible_schedules as $timestamp => $string_date) { |
|
88 | 88 | $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run; |
89 | 89 | $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run; |
90 | 90 | } |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | |
15 | 15 | $no_data = array('user' => false, 'planet' => false, 'que' => false); |
16 | 16 | |
17 | - if(!$planet) { |
|
17 | + if (!$planet) { |
|
18 | 18 | return $no_data; |
19 | 19 | } |
20 | 20 | |
21 | - if(!$no_user_update) { |
|
21 | + if (!$no_user_update) { |
|
22 | 22 | $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user); |
23 | - if(!$user) { |
|
23 | + if (!$user) { |
|
24 | 24 | // TODO - Убрать позже |
25 | 25 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>'); |
26 | 26 | $backtrace = debug_backtrace(); |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | $user = db_user_by_id($user, !$simulation, '*', true); |
33 | 33 | } |
34 | 34 | |
35 | - if(empty($user['id'])) { |
|
35 | + if (empty($user['id'])) { |
|
36 | 36 | return $no_data; |
37 | 37 | } |
38 | 38 | |
39 | - if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
39 | + if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
40 | 40 | $planet = DBStaticPlanet::db_planet_by_vector($planet, '', !$simulation); |
41 | 41 | } else { |
42 | 42 | $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet); |
43 | 43 | $planet = DBStaticPlanet::db_planet_by_id($planet, !$simulation); |
44 | 44 | } |
45 | - if(!is_array($planet) || !isset($planet['id'])) { |
|
45 | + if (!is_array($planet) || !isset($planet['id'])) { |
|
46 | 46 | return $no_data; |
47 | 47 | } |
48 | 48 | |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | RES_DEUTERIUM => 0, |
66 | 66 | ); |
67 | 67 | |
68 | - switch($planet['planet_type']) { |
|
68 | + switch ($planet['planet_type']) { |
|
69 | 69 | case PT_PLANET: |
70 | - foreach($resources_increase as $resource_id => &$increment) { |
|
70 | + foreach ($resources_increase as $resource_id => &$increment) { |
|
71 | 71 | $resource_name = pname_resource_name($resource_id); |
72 | 72 | $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600; |
73 | 73 | $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name]; |
74 | 74 | $increment = min($increment, max(0, $store_free)); |
75 | 75 | |
76 | - if($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
76 | + if ($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
77 | 77 | global $debug; |
78 | 78 | $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501); |
79 | 79 | } |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора |
96 | 96 | $planet['field_current'] = 0; |
97 | 97 | $sn_group_build_allow = sn_get_groups('build_allow'); |
98 | - if(is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
99 | - foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
98 | + if (is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
99 | + foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
100 | 100 | $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true); |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - if($simulation) { |
|
104 | + if ($simulation) { |
|
105 | 105 | return array('user' => $user, 'planet' => $planet, 'que' => $que); |
106 | 106 | } |
107 | 107 |