@@ -278,6 +278,9 @@ |
||
278 | 278 | return count($this->ube_side_present_at_round_start); |
279 | 279 | } |
280 | 280 | |
281 | + /** |
|
282 | + * @param integer $round |
|
283 | + */ |
|
281 | 284 | public function ubeAnalyzeFleetOutcome($round) { |
282 | 285 | $this->ube_actualize_sides(); |
283 | 286 |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function ube_db_load_fleets_outcome($report_row) { |
84 | 84 | $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
85 | - while($row = db_fetch($query)) { |
|
85 | + while ($row = db_fetch($query)) { |
|
86 | 86 | $fleet_id = $row['ube_report_outcome_fleet_fleet_id']; |
87 | 87 | $this[$fleet_id]->load_outcome_from_report_row($row); |
88 | 88 | } |
89 | 89 | |
90 | 90 | $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`"); |
91 | - while($row = db_fetch($query)) { |
|
91 | + while ($row = db_fetch($query)) { |
|
92 | 92 | $fleet_id = $row['ube_report_outcome_unit_fleet_id']; |
93 | 93 | $this[$fleet_id]->load_unit_outcome_from_row($row); |
94 | 94 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | UBE_PLAYER_IS_DEFENDER => array(), |
109 | 109 | ); |
110 | 110 | |
111 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
111 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
112 | 112 | $result[$UBEFleet->is_attacker][] = array( |
113 | 113 | 'ID' => $fleet_id, |
114 | 114 | 'NAME' => $ube->players[$UBEFleet->owner_id]->name, |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function ube_analyze_fleets($is_simulator, UBEDebris $debris, array $resource_exchange_rates) { |
133 | 133 | // Генерируем результат боя |
134 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
134 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
135 | 135 | // Инициализируем массив результатов для флота |
136 | 136 | // $this->init_fleet_outcome_and_link_to_side($UBEFleet); |
137 | 137 | |
138 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
138 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
139 | 139 | $UBEUnit->ube_analyze_unit($is_simulator); |
140 | 140 | } |
141 | 141 | |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | $this->resources_lost_in_metal = array( |
153 | 153 | RES_METAL => 0, |
154 | 154 | ); |
155 | - foreach($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) { |
|
155 | + foreach ($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) { |
|
156 | 156 | $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id]; |
157 | 157 | } |
158 | - foreach($UBEFleet->cargo_dropped as $resource_id => $resource_amount) { |
|
158 | + foreach ($UBEFleet->cargo_dropped as $resource_id => $resource_amount) { |
|
159 | 159 | $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id]; |
160 | 160 | } |
161 | 161 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function ube_get_groups() { |
168 | 168 | $result = array(); |
169 | - foreach($this->_container as $UBEFleet) { |
|
170 | - if($UBEFleet->group_id) { |
|
169 | + foreach ($this->_container as $UBEFleet) { |
|
170 | + if ($UBEFleet->group_id) { |
|
171 | 171 | $result[$UBEFleet->group_id] = $UBEFleet->group_id; |
172 | 172 | } |
173 | 173 | } |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function ube_get_capacity_attackers() { |
182 | 182 | $result = 0; |
183 | - foreach($this->_container as $UBEFleet) { |
|
184 | - if($UBEFleet->is_attacker) { |
|
183 | + foreach ($this->_container as $UBEFleet) { |
|
184 | + if ($UBEFleet->is_attacker) { |
|
185 | 185 | $result += $UBEFleet->fleet_capacity; |
186 | 186 | } |
187 | 187 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function ube_db_load_from_report_row(array $report_row, UBE $ube) { |
197 | 197 | $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
198 | - while($fleet_row = db_fetch($query)) { |
|
198 | + while ($fleet_row = db_fetch($query)) { |
|
199 | 199 | $objFleet = new UBEFleet(); |
200 | 200 | $objFleet->load_from_report($fleet_row, $ube); |
201 | 201 | $this[$objFleet->db_id] = $objFleet; |
@@ -209,20 +209,20 @@ discard block |
||
209 | 209 | * @version 2016-02-25 23:42:45 41a4.68 |
210 | 210 | */ |
211 | 211 | public function ube_prepare_for_next_round($is_simulator) { |
212 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
212 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
213 | 213 | $UBEFleet->prepare_for_next_round($is_simulator); |
214 | 214 | } |
215 | 215 | |
216 | 216 | // Суммируем данные по атакующим и защитникам |
217 | 217 | $this->ube_total[UBE_PLAYER_IS_ATTACKER]->_reset(); |
218 | 218 | $this->ube_total[UBE_PLAYER_IS_DEFENDER]->_reset(); |
219 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
219 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
220 | 220 | $this->ube_total[$UBEFleet->is_attacker]->add_unit_stats_array($UBEFleet->total_stats); |
221 | 221 | } |
222 | 222 | //pvar_dump($this->ube_total); |
223 | 223 | |
224 | 224 | // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще |
225 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
225 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
226 | 226 | $UBEFleet->calculate_unit_partial_data($this->ube_total[$UBEFleet->is_attacker]); |
227 | 227 | } |
228 | 228 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function ube_calculate_attack_results(UBE $ube) { |
238 | 238 | // Каждый флот атакует все |
239 | - foreach($this->_container as $attack_fleet_data) { |
|
239 | + foreach ($this->_container as $attack_fleet_data) { |
|
240 | 240 | defined('DEBUG_UBE') ? print("Fleet {$attack_fleet_data->db_id} attacks<br /><div style='margin-left: 30px;'>") : false; |
241 | 241 | |
242 | 242 | $attack_fleet_data->attack_fleets($this, $ube->is_simulator); |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @version 2016-02-25 23:42:45 41a4.68 |
252 | 252 | */ |
253 | 253 | public function ube_actualize_sides() { |
254 | - foreach($this->_container as $UBEFleet) { |
|
255 | - if($UBEFleet->get_unit_count() > 0) { |
|
254 | + foreach ($this->_container as $UBEFleet) { |
|
255 | + if ($UBEFleet->get_unit_count() > 0) { |
|
256 | 256 | $this->ube_side_present_at_round_start[$UBEFleet->is_attacker] = 1; |
257 | 257 | } |
258 | 258 | } |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function ube_calculate_attack_reapers() { |
267 | 267 | $reapers = 0; |
268 | - foreach($this->_container as $fleet_id => $UBERoundFleetCombat) { |
|
269 | - if($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) { |
|
268 | + foreach ($this->_container as $fleet_id => $UBERoundFleetCombat) { |
|
269 | + if ($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) { |
|
270 | 270 | $reapers += $UBERoundFleetCombat->unit_list->unitCountReapers(); |
271 | 271 | } |
272 | 272 | } |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | |
284 | 284 | $result = UBE_COMBAT_RESULT_DRAW; |
285 | 285 | // Проверяем результат боя |
286 | - if($this->ube_get_sides_count() == 0 || $round >= 10) { |
|
286 | + if ($this->ube_get_sides_count() == 0 || $round >= 10) { |
|
287 | 287 | // Если кого-то не осталось или не осталось обоих - заканчиваем цикл |
288 | 288 | $result = UBE_COMBAT_RESULT_DRAW_END; |
289 | - } elseif($this->ube_get_sides_count() == 1) { |
|
289 | + } elseif ($this->ube_get_sides_count() == 1) { |
|
290 | 290 | // Если осталась одна сторона - она и выиграла |
291 | 291 | $result = isset($this->ube_side_present_at_round_start[UBE_PLAYER_IS_ATTACKER]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS; |
292 | 292 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @version 41a6.16 |
304 | 304 | */ |
305 | 305 | public function ubeInitGetAttackers(Fleet $objFleet, UBEPlayerList $players) { |
306 | - if($objFleet->group_id) { |
|
306 | + if ($objFleet->group_id) { |
|
307 | 307 | $fleets_added = $this->dbLoadWhere("`fleet_group` = {$objFleet->group_id}"); |
308 | 308 | } else { |
309 | 309 | $this->ube_insert_from_Fleet($objFleet); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @param UBE $ube |
9 | 9 | * |
10 | - * @return bool|string |
|
10 | + * @return false|string |
|
11 | 11 | * |
12 | 12 | * @version 2016-02-25 23:42:45 41a4.68 |
13 | 13 | */ |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | // ------------------------------------------------------------------------------------------------ |
187 | 187 | // Читает боевой отчет из БД |
188 | 188 | /** |
189 | - * @param $report_cypher |
|
189 | + * @param string $report_cypher |
|
190 | 190 | * |
191 | 191 | * @return string|UBE |
192 | 192 | */ |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function sn_ube_report_save($ube) { |
15 | 15 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
16 | - if($ube->get_cypher()) { |
|
16 | + if ($ube->get_cypher()) { |
|
17 | 17 | return false; |
18 | 18 | } |
19 | 19 | |
20 | 20 | // Генерируем уникальный секретный ключ и проверяем наличие в базе |
21 | 21 | do { |
22 | 22 | $ube->report_cypher = sys_random_string(32); |
23 | - } while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true)); |
|
23 | + } while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true)); |
|
24 | 24 | |
25 | 25 | // Инициализация таблицы для пакетной вставки информации |
26 | 26 | $sql_perform = array( |
@@ -108,24 +108,24 @@ discard block |
||
108 | 108 | $sql_str = "INSERT INTO `{{ube_report}}` |
109 | 109 | SET |
110 | 110 | `ube_report_cypher` = '{$ube->report_cypher}', |
111 | - `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $ube->combat_timestamp) . "', |
|
111 | + `ube_report_time_combat` = '".date(FMT_DATE_TIME_SQL, $ube->combat_timestamp)."', |
|
112 | 112 | `ube_report_time_spent` = {$ube->time_spent}, |
113 | 113 | |
114 | - `ube_report_combat_admin` = " . (int)$ube->is_admin_in_combat . ", |
|
114 | + `ube_report_combat_admin` = ".(int) $ube->is_admin_in_combat.", |
|
115 | 115 | `ube_report_mission_type` = {$ube->mission_type_id}, |
116 | 116 | |
117 | 117 | `ube_report_combat_result` = {$ube->combat_result}, |
118 | - `ube_report_combat_sfr` = " . (int)$ube->is_small_fleet_recce . ", |
|
118 | + `ube_report_combat_sfr` = ".(int) $ube->is_small_fleet_recce.", |
|
119 | 119 | |
120 | - `ube_report_planet_id` = " . (int)$ube->ube_planet_info[PLANET_ID] . ", |
|
121 | - `ube_report_planet_name` = '" . db_escape($ube->ube_planet_info[PLANET_NAME]) . "', |
|
122 | - `ube_report_planet_size` = " . (int)$ube->ube_planet_info[PLANET_SIZE] . ", |
|
123 | - `ube_report_planet_galaxy` = " . (int)$ube->ube_planet_info[PLANET_GALAXY] . ", |
|
124 | - `ube_report_planet_system` = " . (int)$ube->ube_planet_info[PLANET_SYSTEM] . ", |
|
125 | - `ube_report_planet_planet` = " . (int)$ube->ube_planet_info[PLANET_PLANET] . ", |
|
126 | - `ube_report_planet_planet_type` = " . (int)$ube->ube_planet_info[PLANET_TYPE] . ", |
|
120 | + `ube_report_planet_id` = " . (int) $ube->ube_planet_info[PLANET_ID].", |
|
121 | + `ube_report_planet_name` = '" . db_escape($ube->ube_planet_info[PLANET_NAME])."', |
|
122 | + `ube_report_planet_size` = " . (int) $ube->ube_planet_info[PLANET_SIZE].", |
|
123 | + `ube_report_planet_galaxy` = " . (int) $ube->ube_planet_info[PLANET_GALAXY].", |
|
124 | + `ube_report_planet_system` = " . (int) $ube->ube_planet_info[PLANET_SYSTEM].", |
|
125 | + `ube_report_planet_planet` = " . (int) $ube->ube_planet_info[PLANET_PLANET].", |
|
126 | + `ube_report_planet_planet_type` = " . (int) $ube->ube_planet_info[PLANET_TYPE].", |
|
127 | 127 | |
128 | - `ube_report_capture_result` = " . (int)$ube->capture_result . ", " |
|
128 | + `ube_report_capture_result` = " . (int) $ube->capture_result.", " |
|
129 | 129 | . $ube->debris->report_generate_sql() |
130 | 130 | . $ube->moon_calculator->report_generate_sql(); |
131 | 131 | |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | |
135 | 135 | // Сохраняем общую информацию по игрокам |
136 | 136 | $player_sides = $ube->players->get_player_sides(); |
137 | - foreach($player_sides as $player_id => $player_side) { |
|
137 | + foreach ($player_sides as $player_id => $player_side) { |
|
138 | 138 | $sql_perform['ube_report_player'][] = array( |
139 | 139 | $ube_report_id, |
140 | 140 | $player_id, |
141 | 141 | |
142 | - "'" . db_escape($ube->players[$player_id]->name) . "'", |
|
142 | + "'".db_escape($ube->players[$player_id]->name)."'", |
|
143 | 143 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
144 | 144 | |
145 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
146 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
147 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
145 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
146 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
147 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Всякая информация по флотам |
152 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
152 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
153 | 153 | // Сохраняем общую информацию по флотам |
154 | 154 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
155 | 155 | |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list); |
166 | 166 | |
167 | 167 | // Пакетная вставка данных |
168 | - foreach($sql_perform as $table_name => $table_data) { |
|
169 | - if(count($table_data) < 2) { |
|
168 | + foreach ($sql_perform as $table_name => $table_data) { |
|
169 | + if (count($table_data) < 2) { |
|
170 | 170 | continue; |
171 | 171 | } |
172 | - foreach($table_data as &$record_data) { |
|
173 | - $record_data = '(' . implode(',', $record_data) . ')'; |
|
172 | + foreach ($table_data as &$record_data) { |
|
173 | + $record_data = '('.implode(',', $record_data).')'; |
|
174 | 174 | } |
175 | 175 | $fields = $table_data[0]; |
176 | 176 | unset($table_data[0]); |
177 | - doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES " . implode(',', $table_data)); |
|
177 | + doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES ".implode(',', $table_data)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | return $ube->report_cypher; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $report_cypher = db_escape($report_cypher); |
193 | 193 | |
194 | 194 | $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true); |
195 | - if(!$report_row) { |
|
195 | + if (!$report_row) { |
|
196 | 196 | return UBE_REPORT_NOT_FOUND; |
197 | 197 | } |
198 | 198 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param $template_result |
209 | 209 | */ |
210 | 210 | function sn_ube_report_generate(UBE $ube, &$template_result) { |
211 | - if(!is_object($ube)) { |
|
211 | + if (!is_object($ube)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | |
224 | 224 | // Координаты, тип и название планеты - если есть |
225 | 225 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
226 | - if(isset($ube->ube_planet_info)) { |
|
226 | + if (isset($ube->ube_planet_info)) { |
|
227 | 227 | $template_result += $ube->ube_planet_info; |
228 | 228 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Обломки |
232 | 232 | $debris = array(); |
233 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
234 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
233 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
234 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
235 | 235 | $debris[] = array( |
236 | 236 | 'NAME' => classLocale::$lang['tech'][$resource_id], |
237 | 237 | 'AMOUNT' => pretty_number($resource_amount), |
@@ -69,8 +69,8 @@ |
||
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @param Fleet $objFleet |
72 | - * @param $ov_label |
|
73 | - * @param $planet_end_type |
|
72 | + * @param integer $ov_label |
|
73 | + * @param integer $planet_end_type |
|
74 | 74 | * |
75 | 75 | * @return mixed |
76 | 76 | */ |
@@ -6,26 +6,26 @@ discard block |
||
6 | 6 | $fleet_events = array(); |
7 | 7 | $fleet_number = 0; |
8 | 8 | |
9 | - if($objFleetList->count() <= 0) { |
|
9 | + if ($objFleetList->count() <= 0) { |
|
10 | 10 | return; |
11 | 11 | } |
12 | 12 | |
13 | - foreach($objFleetList->_container as $objFleet) { |
|
13 | + foreach ($objFleetList->_container as $objFleet) { |
|
14 | 14 | $planet_start_type = $objFleet->fleet_start_type == PT_MOON ? PT_MOON : PT_PLANET; |
15 | 15 | $planet_start = db_planet_by_gspt($objFleet->fleet_start_galaxy, $objFleet->fleet_start_system, $objFleet->fleet_start_planet, $planet_start_type, false, 'name'); |
16 | 16 | $objFleet->fleet_start_name = $planet_start['name']; |
17 | 17 | |
18 | 18 | $planet_end_type = $objFleet->fleet_end_type == PT_MOON ? PT_MOON : PT_PLANET; |
19 | - if($objFleet->fleet_end_planet > Vector::$knownPlanets) { |
|
19 | + if ($objFleet->fleet_end_planet > Vector::$knownPlanets) { |
|
20 | 20 | $objFleet->fleet_end_name = classLocale::$lang['ov_fleet_exploration']; |
21 | - } elseif($objFleet->mission_type == MT_COLONIZE) { |
|
21 | + } elseif ($objFleet->mission_type == MT_COLONIZE) { |
|
22 | 22 | $objFleet->fleet_end_name = classLocale::$lang['ov_fleet_colonization']; |
23 | 23 | } else { |
24 | 24 | $planet_end = db_planet_by_gspt($objFleet->fleet_end_galaxy, $objFleet->fleet_end_system, $objFleet->fleet_end_planet, $planet_end_type, false, 'name'); |
25 | 25 | $objFleet->fleet_end_name = $planet_end['name']; |
26 | 26 | } |
27 | 27 | |
28 | - if($objFleet->time_arrive_to_target > SN_TIME_NOW && !$objFleet->isReturning() && $objFleet->mission_type != MT_MISSILE && |
|
28 | + if ($objFleet->time_arrive_to_target > SN_TIME_NOW && !$objFleet->isReturning() && $objFleet->mission_type != MT_MISSILE && |
|
29 | 29 | ($planet_scanned === false |
30 | 30 | || |
31 | 31 | ( |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | $fleet_events[] = flt_register_event_objFleet($objFleet, 0, $planet_end_type); |
40 | 40 | } |
41 | 41 | |
42 | - if($objFleet->time_mission_job_complete > SN_TIME_NOW && !$objFleet->isReturning() && $planet_scanned === false && $objFleet->mission_type != MT_MISSILE) { |
|
42 | + if ($objFleet->time_mission_job_complete > SN_TIME_NOW && !$objFleet->isReturning() && $planet_scanned === false && $objFleet->mission_type != MT_MISSILE) { |
|
43 | 43 | $fleet_events[] = flt_register_event_objFleet($objFleet, 1, $planet_end_type); |
44 | 44 | } |
45 | 45 | |
46 | - if( |
|
46 | + if ( |
|
47 | 47 | $objFleet->time_return_to_source > SN_TIME_NOW && $objFleet->mission_type != MT_MISSILE && ($objFleet->isReturning() || ($objFleet->mission_type != MT_RELOCATE && $objFleet->mission_type != MT_COLONIZE)) && |
48 | 48 | ( |
49 | 49 | ($planet_scanned === false && $objFleet->playerOwnerId == $user['id']) |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $fleet_events[] = flt_register_event_objFleet($objFleet, 2, $planet_end_type); |
60 | 60 | } |
61 | 61 | |
62 | - if($objFleet->mission_type == MT_MISSILE) { |
|
62 | + if ($objFleet->mission_type == MT_MISSILE) { |
|
63 | 63 | $fleet_events[] = flt_register_event_objFleet($objFleet, 3, $planet_end_type); |
64 | 64 | } |
65 | 65 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $is_this_planet = false; |
81 | 81 | |
82 | - switch($objFleet->ov_label = $ov_label) { |
|
82 | + switch ($objFleet->ov_label = $ov_label) { |
|
83 | 83 | case 0: |
84 | 84 | $objFleet->event_time = $objFleet->time_arrive_to_target; |
85 | 85 | $is_this_planet = ( |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | |
111 | 111 | } |
112 | 112 | |
113 | - $objFleet->ov_this_planet = $is_this_planet;// || $planet_scanned != false; |
|
113 | + $objFleet->ov_this_planet = $is_this_planet; // || $planet_scanned != false; |
|
114 | 114 | |
115 | - if($objFleet->playerOwnerId == $user['id']) { |
|
115 | + if ($objFleet->playerOwnerId == $user['id']) { |
|
116 | 116 | $user_data = $user; |
117 | 117 | } else { |
118 | 118 | $user_data = db_user_by_id($objFleet->playerOwnerId); |
@@ -185,6 +185,9 @@ |
||
185 | 185 | return $result; |
186 | 186 | } |
187 | 187 | |
188 | +/** |
|
189 | + * @param integer $que_id |
|
190 | + */ |
|
188 | 191 | function tpl_parse_planet_que($que, $planet, $que_id) { |
189 | 192 | $hangar_que = array(); |
190 | 193 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | // Compare function to sort fleet in time order |
4 | 4 | function tpl_assign_fleet_compare($a, $b) { |
5 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
6 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
5 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
6 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
7 | 7 | return 0; |
8 | 8 | } |
9 | 9 | |
@@ -19,17 +19,17 @@ discard block |
||
19 | 19 | * @param string $js_name |
20 | 20 | */ |
21 | 21 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
22 | - if(!$fleets) { |
|
22 | + if (!$fleets) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | 26 | usort($fleets, 'tpl_assign_fleet_compare'); |
27 | 27 | |
28 | - foreach($fleets as $fleet_data) { |
|
28 | + foreach ($fleets as $fleet_data) { |
|
29 | 29 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
30 | 30 | |
31 | - if($fleet_data['ships']) { |
|
32 | - foreach($fleet_data['ships'] as $ship_data) { |
|
31 | + if ($fleet_data['ships']) { |
|
32 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
33 | 33 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
34 | 34 | } |
35 | 35 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | 'DEUTERIUM' => $fleet[RES_DEUTERIUM], |
51 | 51 | ); |
52 | 52 | |
53 | - foreach($fleet as $ship_id => $ship_amount) { |
|
54 | - if(in_array($ship_id, Fleet::$snGroupFleet)) { |
|
53 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
54 | + if (in_array($ship_id, Fleet::$snGroupFleet)) { |
|
55 | 55 | $single_ship_data = get_ship_data($ship_id, $user_data); |
56 | 56 | $return['ships'][$ship_id] = array( |
57 | 57 | 'ID' => $ship_id, |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | $result = array(); |
92 | 92 | |
93 | - if(!$user_data) { |
|
93 | + if (!$user_data) { |
|
94 | 94 | $user_data = $user; |
95 | 95 | } |
96 | 96 | |
97 | - if(!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
97 | + if (!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
98 | 98 | $aks = DBStaticFleetACS::db_acs_get_by_group_id($objFleet->group_id); |
99 | 99 | } |
100 | 100 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'MISSION' => $objFleet->mission_type, |
114 | 114 | 'MISSION_NAME' => classLocale::$lang['type_mission'][$objFleet->mission_type], |
115 | 115 | 'ACS' => !empty($aks['name']) ? $aks['name'] : (!empty($objFleet->group_id) ? $objFleet->group_id : ''), |
116 | - 'AMOUNT' => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()) . (array_sum($fleet_resources) ? '+' : '')) : '?', |
|
116 | + 'AMOUNT' => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()).(array_sum($fleet_resources) ? '+' : '')) : '?', |
|
117 | 117 | |
118 | 118 | 'METAL' => $spy_level >= 8 ? $fleet_resources[RES_METAL] : 0, |
119 | 119 | 'CRYSTAL' => $spy_level >= 8 ? $fleet_resources[RES_CRYSTAL] : 0, |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | 'STAY_LEFT' => floor($objFleet->time_mission_job_complete + 1 - SN_TIME_NOW), |
136 | 136 | ); |
137 | 137 | |
138 | - if(property_exists($objFleet, 'fleet_start_name')) { |
|
138 | + if (property_exists($objFleet, 'fleet_start_name')) { |
|
139 | 139 | $result['START_NAME'] = $objFleet->fleet_start_name; |
140 | 140 | } |
141 | - if(property_exists($objFleet, 'fleet_end_name')) { |
|
141 | + if (property_exists($objFleet, 'fleet_end_name')) { |
|
142 | 142 | $result['END_NAME'] = $objFleet->fleet_end_name; |
143 | 143 | } |
144 | 144 | |
145 | - if(property_exists($objFleet, 'event_time')) { |
|
145 | + if (property_exists($objFleet, 'event_time')) { |
|
146 | 146 | $result['fleet'] = array_merge($result['fleet'], array( |
147 | 147 | 'OV_LABEL' => $objFleet->ov_label, |
148 | 148 | 'EVENT_TIME_TEXT' => property_exists($objFleet, 'event_time') ? date(FMT_DATE_TIME, $objFleet->event_time + SN_CLIENT_TIME_DIFF) : '', |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | |
154 | 154 | $ship_id = 0; |
155 | 155 | $result['ships'] = array(); |
156 | - if($spy_level >= 6) { |
|
157 | - foreach($objFleet->shipsIterator() as $ship_sn_id => $ship) { |
|
158 | - if($spy_level >= 10) { |
|
156 | + if ($spy_level >= 6) { |
|
157 | + foreach ($objFleet->shipsIterator() as $ship_sn_id => $ship) { |
|
158 | + if ($spy_level >= 10) { |
|
159 | 159 | $single_ship_data = get_ship_data($ship_sn_id, $user_data); |
160 | 160 | $result['ships'][$ship_sn_id] = array( |
161 | 161 | 'ID' => $ship_sn_id, |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | function tpl_parse_planet_que($que, $planet, $que_id) { |
189 | 189 | $hangar_que = array(); |
190 | 190 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
191 | - if(!empty($que_hangar)) { |
|
192 | - foreach($que_hangar as $que_item) { |
|
191 | + if (!empty($que_hangar)) { |
|
192 | + foreach ($que_hangar as $que_item) { |
|
193 | 193 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
194 | 194 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
195 | 195 | } |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
250 | 250 | ); |
251 | 251 | |
252 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
252 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
253 | 253 | $result['building_que'] = array(); |
254 | 254 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
255 | - foreach($building_que as $que_element) { |
|
255 | + foreach ($building_que as $que_element) { |
|
256 | 256 | $result['building_que'][] = que_tpl_parse_element($que_element); |
257 | 257 | } |
258 | 258 | } |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | static $snGroupFleet; |
272 | 272 | !$snGroupFleet ? $snGroupFleet = Fleet::$snGroupFleet : false; |
273 | 273 | |
274 | - if(empty($array_of_Fleet)) { |
|
274 | + if (empty($array_of_Fleet)) { |
|
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | |
278 | 278 | $fleet_list = array(); |
279 | - foreach($array_of_Fleet as $fleet) { |
|
280 | - if($fleet->playerOwnerId == $user['id']) { |
|
281 | - if($fleet->mission_type == MT_MISSILE) { |
|
279 | + foreach ($array_of_Fleet as $fleet) { |
|
280 | + if ($fleet->playerOwnerId == $user['id']) { |
|
281 | + if ($fleet->mission_type == MT_MISSILE) { |
|
282 | 282 | continue; |
283 | 283 | } |
284 | 284 | $fleet_ownage = 'own'; |
285 | 285 | } else { |
286 | - switch($fleet->mission_type) { |
|
286 | + switch ($fleet->mission_type) { |
|
287 | 287 | case MT_ATTACK: |
288 | 288 | case MT_ACS: |
289 | 289 | case MT_DESTROY: |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | |
301 | 301 | $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet; |
302 | 302 | |
303 | - if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
304 | - foreach($fleet->shipsIterator() as $ship_id => $ship) { |
|
305 | - if(!empty($snGroupFleet[$ship_id])) { |
|
303 | + if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
304 | + foreach ($fleet->shipsIterator() as $ship_id => $ship) { |
|
305 | + if (!empty($snGroupFleet[$ship_id])) { |
|
306 | 306 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship->count; |
307 | 307 | } |
308 | 308 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | return $fleet_list; |
320 | 320 | } |
321 | 321 | |
322 | -function tpl_set_resource_info(template &$template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
322 | +function tpl_set_resource_info(template & $template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
323 | 323 | $template->assign_vars(array( |
324 | 324 | 'RESOURCE_ROUNDING' => $round, |
325 | 325 |
@@ -1,5 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | +/** |
|
4 | + * @param string $type |
|
5 | + */ |
|
3 | 6 | function sn_ube_simulator_encode_replay($combat, $type) |
4 | 7 | { |
5 | 8 | $strPacked = "{$type}!"; |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | { |
5 | 5 | $strPacked = "{$type}!"; |
6 | 6 | |
7 | - foreach($combat as $fleetID => $fleetCompress) |
|
7 | + foreach ($combat as $fleetID => $fleetCompress) |
|
8 | 8 | { |
9 | - foreach($fleetCompress as $key => $value) |
|
9 | + foreach ($fleetCompress as $key => $value) |
|
10 | 10 | { |
11 | 11 | $value = intval($value); |
12 | 12 | $strPacked .= "{$key},{$value};"; |
@@ -22,29 +22,29 @@ discard block |
||
22 | 22 | $fleet_id = 0; |
23 | 23 | |
24 | 24 | $arr_data_unpacked = explode('!', $str_data); |
25 | - foreach($arr_data_unpacked as $data_piece) |
|
25 | + foreach ($arr_data_unpacked as $data_piece) |
|
26 | 26 | { |
27 | - if(!$data_piece) |
|
27 | + if (!$data_piece) |
|
28 | 28 | { |
29 | 29 | continue; |
30 | 30 | } |
31 | 31 | |
32 | - if($data_piece == 'A' || $data_piece == 'D') |
|
32 | + if ($data_piece == 'A' || $data_piece == 'D') |
|
33 | 33 | { |
34 | 34 | $fleet_type = $data_piece; |
35 | 35 | continue; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $arr_unit_strings = explode(';', $data_piece); |
39 | - foreach($arr_unit_strings as $str_unit_string) |
|
39 | + foreach ($arr_unit_strings as $str_unit_string) |
|
40 | 40 | { |
41 | - if(!$str_unit_string) |
|
41 | + if (!$str_unit_string) |
|
42 | 42 | { |
43 | 43 | continue; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $arr_unit_data = explode(',', $str_unit_string); |
47 | - if($arr_unit_data[1]) |
|
47 | + if ($arr_unit_data[1]) |
|
48 | 48 | { |
49 | 49 | $unpacked[$fleet_type][$fleet_id][$arr_unit_data[0]] = intval($arr_unit_data[1]); |
50 | 50 | } |
@@ -10,9 +10,8 @@ |
||
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @param Mission $objMission |
13 | - * @param array $mission_data |
|
14 | 13 | * |
15 | - * @return array|null |
|
14 | + * @return null|boolean |
|
16 | 15 | */ |
17 | 16 | function flt_mission_attack($objMission) { |
18 | 17 | $objFleet = $objMission->fleet; |
@@ -17,14 +17,14 @@ |
||
17 | 17 | function flt_mission_attack($objMission) { |
18 | 18 | $objFleet = $objMission->fleet; |
19 | 19 | |
20 | - if($objFleet->shipsGetTotal() <= 0) { |
|
20 | + if ($objFleet->shipsGetTotal() <= 0) { |
|
21 | 21 | return null; |
22 | 22 | } |
23 | 23 | |
24 | 24 | $destination_user = $objMission->dst_user; |
25 | 25 | $destination_planet = $objMission->dst_planet; |
26 | 26 | |
27 | - if( |
|
27 | + if ( |
|
28 | 28 | // Нет данных о планете назначения или её владельце |
29 | 29 | empty($destination_user) || empty($destination_planet) || !is_array($destination_user) || !is_array($destination_planet) |
30 | 30 | || |
@@ -31,7 +31,7 @@ |
||
31 | 31 | /** |
32 | 32 | * Fleet mission "Relocate" |
33 | 33 | * |
34 | - * @param $mission_data Mission |
|
34 | + * @param Mission $mission_data Mission |
|
35 | 35 | * |
36 | 36 | * @return int |
37 | 37 | * |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | // TODO - Currently $ship_data is one for all players |
22 | 22 | static $shipCostInMetalPerPiece, $rates; |
23 | 23 | |
24 | - if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
24 | + if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
25 | 25 | return CACHE_NONE; |
26 | 26 | } |
27 | 27 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | $outcome_value = &$result['$outcome_value']; |
47 | 47 | $outcome_list = &$result['$outcome_list']; |
48 | 48 | |
49 | - if(!$shipCostInMetalPerPiece) { |
|
49 | + if (!$shipCostInMetalPerPiece) { |
|
50 | 50 | $rates = get_resource_exchange(); |
51 | 51 | |
52 | - foreach(Fleet::$snGroupFleet as $unit_id) { |
|
52 | + foreach (Fleet::$snGroupFleet as $unit_id) { |
|
53 | 53 | $unit_info = get_unit_param($unit_id); |
54 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
54 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | $shipCostInMetalPerPiece[$unit_id] = get_unit_cost_in($unit_info[P_COST], RES_METAL); |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
72 | 72 | |
73 | 73 | $chance_max = 0; |
74 | - foreach($outcome_list as $key => &$value) { |
|
75 | - if(!$value['chance']) { |
|
74 | + foreach ($outcome_list as $key => &$value) { |
|
75 | + if (!$value['chance']) { |
|
76 | 76 | unset($outcome_list[$key]); |
77 | 77 | continue; |
78 | 78 | } |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | } |
81 | 81 | $outcome_value = mt_rand(0, $chance_max); |
82 | 82 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
83 | - foreach($outcome_list as $key => &$value) { |
|
84 | - if(!$value['chance']) { |
|
83 | + foreach ($outcome_list as $key => &$value) { |
|
84 | + if (!$value['chance']) { |
|
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | $mission_outcome = $key; |
88 | 88 | $outcome_description = $value; |
89 | - if($outcome_value <= $outcome_description['value']) { |
|
89 | + if ($outcome_value <= $outcome_description['value']) { |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | // $outcome_mission_sub = -1; |
104 | 104 | |
105 | 105 | $fleet_found = array(); |
106 | - switch($mission_outcome) { |
|
106 | + switch ($mission_outcome) { |
|
107 | 107 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
108 | 108 | $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000); |
109 | 109 | break; |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | |
125 | 125 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
126 | 126 | $can_be_found = array(); |
127 | - foreach($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) { |
|
128 | - if($shipMetalCost < $max_metal_cost) { |
|
127 | + foreach ($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) { |
|
128 | + if ($shipMetalCost < $max_metal_cost) { |
|
129 | 129 | $can_be_found[$ship_id] = $shipMetalCost; |
130 | 130 | } |
131 | 131 | } |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | unset($can_be_found[SHIP_COLONIZER]); |
134 | 134 | unset($can_be_found[SHIP_SPY]); |
135 | 135 | |
136 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
136 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
137 | 137 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
138 | 138 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
139 | 139 | $found_ship_cost = reset($found_ship); |
140 | 140 | $found_ship_id = key($found_ship); |
141 | 141 | |
142 | - if($found_ship_cost > $found_in_metal) { |
|
142 | + if ($found_ship_cost > $found_in_metal) { |
|
143 | 143 | unset($can_be_found[$found_ship_id]); |
144 | 144 | } else { |
145 | 145 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - if(empty($fleet_found)) { |
|
151 | + if (empty($fleet_found)) { |
|
152 | 152 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
153 | 153 | } else { |
154 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
154 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
155 | 155 | $objFleet->shipAdjustCount($unit_id, $unit_amount); |
156 | 156 | } |
157 | 157 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $objFleet->resourcesAdjust($resources_found); |
177 | 177 | |
178 | - if(array_sum($resources_found) == 0) { |
|
178 | + if (array_sum($resources_found) == 0) { |
|
179 | 179 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
180 | 180 | } |
181 | 181 | break; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | // Рассчитываем количество найденной ТМ |
187 | 187 | $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
188 | 188 | |
189 | - if(!$found_dark_matter) { |
|
189 | + if (!$found_dark_matter) { |
|
190 | 190 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
191 | 191 | } |
192 | 192 | break; |
@@ -200,46 +200,45 @@ discard block |
||
200 | 200 | |
201 | 201 | mission_expedition_result_adjust($result, $objFleet); |
202 | 202 | |
203 | - if($found_dark_matter) { |
|
203 | + if ($found_dark_matter) { |
|
204 | 204 | rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
205 | 205 | $msg_text_addon = sprintf(classLocale::$lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
206 | 206 | } |
207 | 207 | |
208 | - if(!empty($fleet_lost)) { |
|
208 | + if (!empty($fleet_lost)) { |
|
209 | 209 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['lost_fleet']; |
210 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
211 | - $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
|
210 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
211 | + $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n"; |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if(!empty($fleet_found)) { |
|
215 | + if (!empty($fleet_found)) { |
|
216 | 216 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_fleet']; |
217 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
218 | - $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
|
217 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
218 | + $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n"; |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
222 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
223 | 223 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_resources']; |
224 | - foreach($resources_found as $resource_id => $resource_amount) { |
|
225 | - $msg_text_addon .= classLocale::$lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n"; |
|
224 | + foreach ($resources_found as $resource_id => $resource_amount) { |
|
225 | + $msg_text_addon .= classLocale::$lang['tech'][$resource_id].' - '.$resource_amount."\r\n"; |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - if(!$msg_text) { |
|
229 | + if (!$msg_text) { |
|
230 | 230 | $messages = &classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
231 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
231 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
232 | 232 | $messages = &$messages[$outcome_mission_sub]; |
233 | 233 | } |
234 | 234 | |
235 | - $msg_text = is_string($messages) ? $messages : |
|
236 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
235 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
237 | 236 | } |
238 | 237 | |
239 | 238 | $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type(); |
240 | 239 | |
241 | - $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)) . |
|
242 | - ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
240 | + $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)). |
|
241 | + ($msg_text_addon ? "\r\n".$msg_text_addon : ''); |
|
243 | 242 | |
244 | 243 | DBStaticMessages::msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_mission_job_complete, MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
245 | 244 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $title |
35 | 35 | * @param string $dest |
36 | 36 | * @param int $time |
37 | - * @param bool|true $show_header |
|
37 | + * @param boolean $show_header |
|
38 | 38 | */ |
39 | 39 | function message($mes, $title = 'Error', $dest = '', $time = 5, $show_header = true) { |
40 | 40 | $template = gettemplate('message_body', true); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param bool|true $isDisplayTopNav |
196 | 196 | * @param string $metatags |
197 | 197 | * @param bool|false $AdminPage |
198 | - * @param bool|true $isDisplayMenu |
|
198 | + * @param boolean $isDisplayMenu |
|
199 | 199 | * |
200 | 200 | * @return mixed |
201 | 201 | */ |
@@ -208,7 +208,6 @@ discard block |
||
208 | 208 | * @param string $title |
209 | 209 | * @param bool|true $isDisplayTopNav |
210 | 210 | * @param string $metatags |
211 | - * @param bool|false $AdminPage |
|
212 | 211 | * @param bool|true $isDisplayMenu |
213 | 212 | * @param bool|int|string $exitStatus - Код или сообщение выхода |
214 | 213 | */ |
@@ -385,10 +384,10 @@ discard block |
||
385 | 384 | |
386 | 385 | /** |
387 | 386 | * @param $time |
388 | - * @param $event |
|
387 | + * @param integer $event |
|
389 | 388 | * @param $msg |
390 | 389 | * @param $coordinates |
391 | - * @param $is_decrease |
|
390 | + * @param boolean $is_decrease |
|
392 | 391 | * @param Fleet $objFleet |
393 | 392 | * @param $fleet_flying_sorter |
394 | 393 | * @param $fleet_flying_events |
@@ -708,7 +707,7 @@ discard block |
||
708 | 707 | } |
709 | 708 | |
710 | 709 | /** |
711 | - * @param array|string $files |
|
710 | + * @param string $files |
|
712 | 711 | * @param template|bool $template |
713 | 712 | * @param string|bool $template_path |
714 | 713 | * |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | function gettemplatename($u_dpath) { |
11 | 11 | static $template_names = array(); |
12 | 12 | |
13 | - if(!isset($template_names[$u_dpath])) { |
|
14 | - $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') : TEMPLATE_NAME; |
|
13 | + if (!isset($template_names[$u_dpath])) { |
|
14 | + $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL.$u_dpath.'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL.$u_dpath.'tmpl.ini') : TEMPLATE_NAME; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | return $template_names[$u_dpath]; |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * @param $sn_menu_extra |
53 | 53 | */ |
54 | 54 | function tpl_menu_merge_extra(&$sn_menu, &$sn_menu_extra) { |
55 | - if(empty($sn_menu) || empty($sn_menu_extra)) { |
|
55 | + if (empty($sn_menu) || empty($sn_menu_extra)) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - foreach($sn_menu_extra as $menu_item_id => $menu_item) { |
|
60 | - if(empty($menu_item['LOCATION'])) { |
|
59 | + foreach ($sn_menu_extra as $menu_item_id => $menu_item) { |
|
60 | + if (empty($menu_item['LOCATION'])) { |
|
61 | 61 | $sn_menu[$menu_item_id] = $menu_item; |
62 | 62 | continue; |
63 | 63 | } |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | unset($menu_item['LOCATION']); |
67 | 67 | |
68 | 68 | $is_positioned = $item_location[0]; |
69 | - if($is_positioned == '+' || $is_positioned == '-') { |
|
69 | + if ($is_positioned == '+' || $is_positioned == '-') { |
|
70 | 70 | $item_location = substr($item_location, 1); |
71 | 71 | } else { |
72 | 72 | $is_positioned = ''; |
73 | 73 | } |
74 | 74 | |
75 | - if($item_location) { |
|
75 | + if ($item_location) { |
|
76 | 76 | $menu_keys = array_keys($sn_menu); |
77 | 77 | $insert_position = array_search($item_location, $menu_keys); |
78 | - if($insert_position === false) { |
|
78 | + if ($insert_position === false) { |
|
79 | 79 | $insert_position = count($sn_menu) - 1; |
80 | 80 | $is_positioned = '+'; |
81 | 81 | $item_location = ''; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $spliced = array_splice($sn_menu, $insert_position, count($sn_menu) - $insert_position); |
89 | 89 | $sn_menu[$menu_item_id] = $menu_item; |
90 | 90 | |
91 | - if(!$is_positioned && $item_location) { |
|
91 | + if (!$is_positioned && $item_location) { |
|
92 | 92 | unset($spliced[$item_location]); |
93 | 93 | } |
94 | 94 | $sn_menu = array_merge($sn_menu, $spliced); |
@@ -102,24 +102,24 @@ discard block |
||
102 | 102 | * @param template $template |
103 | 103 | */ |
104 | 104 | function tpl_menu_assign_to_template(&$sn_menu, &$template) { |
105 | - if(empty($sn_menu) || !is_array($sn_menu)) { |
|
105 | + if (empty($sn_menu) || !is_array($sn_menu)) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | - foreach($sn_menu as $menu_item_id => $menu_item) { |
|
110 | - if(!$menu_item) { |
|
109 | + foreach ($sn_menu as $menu_item_id => $menu_item) { |
|
110 | + if (!$menu_item) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | - if(is_string($menu_item_id)) { |
|
114 | + if (is_string($menu_item_id)) { |
|
115 | 115 | $menu_item['ID'] = $menu_item_id; |
116 | 116 | } |
117 | 117 | |
118 | - if($menu_item['TYPE'] == 'lang') { |
|
118 | + if ($menu_item['TYPE'] == 'lang') { |
|
119 | 119 | $lang_string = &classLocale::$lang; |
120 | - if(preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
|
121 | - for($i = 1; $i < count($matches); $i++) { |
|
122 | - if(defined($matches[$i])) { |
|
120 | + if (preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
|
121 | + for ($i = 1; $i < count($matches); $i++) { |
|
122 | + if (defined($matches[$i])) { |
|
123 | 123 | $matches[$i] = constant($matches[$i]); |
124 | 124 | } |
125 | 125 | $lang_string = &$lang_string[$matches[$i]]; |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | $menu_item['ALT'] = htmlentities($menu_item['ALT']); |
132 | 132 | $menu_item['TITLE'] = htmlentities($menu_item['TITLE']); |
133 | 133 | |
134 | - if(!empty($menu_item['ICON'])) { |
|
135 | - if(is_string($menu_item['ICON'])) { |
|
134 | + if (!empty($menu_item['ICON'])) { |
|
135 | + if (is_string($menu_item['ICON'])) { |
|
136 | 136 | $menu_item['ICON_PATH'] = $menu_item['ICON']; |
137 | 137 | } else { |
138 | 138 | $menu_item['ICON'] = $menu_item_id; |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | 'USER_AUTHLEVEL_NAME' => classLocale::$lang['user_level'][$user['authlevel']], |
160 | 160 | // 'USER_IMPERSONATOR' => $template_result[F_IMPERSONATE_STATUS] != LOGIN_UNDEFINED, |
161 | 161 | 'PAYMENT' => sn_module_get_active_count('payment'), |
162 | - 'MENU_START_HIDE' => !empty($_COOKIE[SN_COOKIE . '_menu_hidden']) || defined('SN_GOOGLE'), |
|
162 | + 'MENU_START_HIDE' => !empty($_COOKIE[SN_COOKIE.'_menu_hidden']) || defined('SN_GOOGLE'), |
|
163 | 163 | )); |
164 | 164 | |
165 | - if(isset($template_result['MENU_CUSTOMIZE'])) { |
|
165 | + if (isset($template_result['MENU_CUSTOMIZE'])) { |
|
166 | 166 | $template->assign_vars(array( |
167 | 167 | 'PLAYER_OPTION_MENU_SHOW_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON], |
168 | 168 | 'PLAYER_OPTION_MENU_HIDE_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON], |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | 'PLAYER_OPTION_MENU_ITEMS_AS_BUTTONS' => classSupernova::$user_options[PLAYER_OPTION_MENU_ITEMS_AS_BUTTONS], |
172 | 172 | 'PLAYER_OPTION_MENU_WHITE_TEXT' => classSupernova::$user_options[PLAYER_OPTION_MENU_WHITE_TEXT], |
173 | 173 | 'PLAYER_OPTION_MENU_OLD' => classSupernova::$user_options[PLAYER_OPTION_MENU_OLD], |
174 | - 'PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON' => empty($_COOKIE[SN_COOKIE . '_menu_hidden']) && !defined('SN_GOOGLE') |
|
174 | + 'PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON' => empty($_COOKIE[SN_COOKIE.'_menu_hidden']) && !defined('SN_GOOGLE') |
|
175 | 175 | ? classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON] : 1, |
176 | 176 | )); |
177 | 177 | } |
178 | 178 | |
179 | - if(defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
|
179 | + if (defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
|
180 | 180 | tpl_menu_merge_extra($sn_menu_admin, $sn_menu_admin_extra); |
181 | 181 | tpl_menu_assign_to_template($sn_menu_admin, $template); |
182 | 182 | } else { |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
217 | 217 | $is_login = defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true; |
218 | 218 | |
219 | - if(is_object($page)) { |
|
219 | + if (is_object($page)) { |
|
220 | 220 | isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false; |
221 | 221 | isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false; |
222 | 222 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false; |
225 | 225 | } |
226 | 226 | |
227 | - if(empty($user['id']) || !is_numeric($user['id'])) { |
|
227 | + if (empty($user['id']) || !is_numeric($user['id'])) { |
|
228 | 228 | $isDisplayMenu = false; |
229 | 229 | $isDisplayTopNav = false; |
230 | 230 | } |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0); |
237 | 237 | |
238 | 238 | $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE]; |
239 | - if(strpos($font_size, '%') !== false) { |
|
239 | + if (strpos($font_size, '%') !== false) { |
|
240 | 240 | // Размер шрифта в процентах |
241 | - $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%'; |
|
242 | - } elseif(strpos($font_size, 'px') !== false) { |
|
241 | + $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX).'%'; |
|
242 | + } elseif (strpos($font_size, 'px') !== false) { |
|
243 | 243 | // Размер шрифта в пикселях |
244 | - $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px'; |
|
244 | + $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX).'px'; |
|
245 | 245 | } else { |
246 | 246 | // Не мышонка, не лягушка... |
247 | 247 | $font_size = FONT_SIZE_PERCENT_DEFAULT_STRING; |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | |
252 | 252 | $template = gettemplate('_global_header', true); |
253 | 253 | |
254 | - if(!empty(classSupernova::$sn_mvc['javascript'])) { |
|
255 | - foreach(classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) { |
|
256 | - if(empty($page_name) || $page_name == $sn_page_name) { |
|
257 | - foreach($script_list as $filename => $content) { |
|
254 | + if (!empty(classSupernova::$sn_mvc['javascript'])) { |
|
255 | + foreach (classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) { |
|
256 | + if (empty($page_name) || $page_name == $sn_page_name) { |
|
257 | + foreach ($script_list as $filename => $content) { |
|
258 | 258 | $template_result['.']['javascript'][] = array( |
259 | 259 | 'FILE' => $filename, |
260 | 260 | 'CONTENT' => $content, |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | $is_login ? $standard_css['design/css/login.min.css'] = '' : false; |
273 | 273 | $standard_css += array( |
274 | 274 | // 'design/css/design/css/global-ie.min.css' => '', // TODO |
275 | - TEMPLATE_PATH . '/_template.min.css' => '', |
|
276 | - ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'skin.min.css' => '', |
|
275 | + TEMPLATE_PATH.'/_template.min.css' => '', |
|
276 | + ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH).'skin.min.css' => '', |
|
277 | 277 | ); |
278 | 278 | |
279 | 279 | // Prepending standard CSS files |
280 | 280 | classSupernova::$sn_mvc['css'][''] = array_merge($standard_css, classSupernova::$sn_mvc['css']['']); |
281 | 281 | |
282 | 282 | |
283 | - foreach(classSupernova::$sn_mvc['css'] as $page_name => $script_list) { |
|
284 | - if(empty($page_name) || $page_name == $sn_page_name) { |
|
285 | - foreach($script_list as $filename => $content) { |
|
283 | + foreach (classSupernova::$sn_mvc['css'] as $page_name => $script_list) { |
|
284 | + if (empty($page_name) || $page_name == $sn_page_name) { |
|
285 | + foreach ($script_list as $filename => $content) { |
|
286 | 286 | $template_result['.']['css'][] = array( |
287 | 287 | 'FILE' => $filename, |
288 | 288 | 'CONTENT' => $content, |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | ), // Проводить замер только если не выставлен флаг форсированного замера И (иссяк интервал замера ИЛИ замера еще не было) |
310 | 310 | //'TIME_UTC_OFFSET' => defined('SN_CLIENT_TIME_UTC_OFFSET') ? SN_CLIENT_TIME_UTC_OFFSET : '', |
311 | 311 | |
312 | - 'title' => ($title ? "{$title} - " : '') . classLocale::$lang['sys_server'] . " {$classConfig->game_name} - " . classLocale::$lang['sys_supernova'], |
|
312 | + 'title' => ($title ? "{$title} - " : '').classLocale::$lang['sys_server']." {$classConfig->game_name} - ".classLocale::$lang['sys_supernova'], |
|
313 | 313 | '-meta-' => $metatags, |
314 | 314 | 'ADV_SEO_META_DESCRIPTION' => classSupernova::$config->adv_seo_meta_description, |
315 | 315 | 'ADV_SEO_META_KEYWORDS' => classSupernova::$config->adv_seo_meta_keywords, |
@@ -329,12 +329,12 @@ discard block |
||
329 | 329 | $template->assign_recursive($template_result); |
330 | 330 | displayP(parsetemplate($template)); |
331 | 331 | |
332 | - if(($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) { |
|
332 | + if (($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) { |
|
333 | 333 | // $AdminPage = $AdminPage ? $user['authlevel'] : 0; |
334 | 334 | displayP(parsetemplate(tpl_render_menu())); |
335 | 335 | } |
336 | 336 | |
337 | - if($isDisplayTopNav && !$in_admin) { |
|
337 | + if ($isDisplayTopNav && !$in_admin) { |
|
338 | 338 | displayP(parsetemplate(tpl_render_topnav($user, $planetrow))); |
339 | 339 | } |
340 | 340 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | |
343 | 343 | !is_array($page) ? $page = array($page) : false; |
344 | 344 | $result_added = false; |
345 | - foreach($page as $page_item) { |
|
346 | - if(!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
|
345 | + foreach ($page as $page_item) { |
|
346 | + if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
|
347 | 347 | $page_item = gettemplate('_result_message', $page_item); |
348 | 348 | $temp = $page_item->files['_result_message']; |
349 | 349 | unset($page_item->files['_result_message']); |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | )); |
367 | 367 | displayP(parsetemplate($template)); |
368 | 368 | |
369 | - $user['authlevel'] >= 3 && classSupernova::$config->debug ? classSupernova::$debug->echo_log() : false;; |
|
369 | + $user['authlevel'] >= 3 && classSupernova::$config->debug ? classSupernova::$debug->echo_log() : false; ; |
|
370 | 370 | |
371 | 371 | classSupernova::$db->db_disconnect(); |
372 | 372 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @param string $type |
405 | 405 | */ |
406 | 406 | function tpl_topnav_event_build(&$template, $FleetList, $type = 'fleet') { |
407 | - if(empty($FleetList)) { |
|
407 | + if (empty($FleetList)) { |
|
408 | 408 | return; |
409 | 409 | } |
410 | 410 | |
@@ -413,19 +413,19 @@ discard block |
||
413 | 413 | $fleet_event_count = 0; |
414 | 414 | $fleet_flying_sorter = array(); |
415 | 415 | $fleet_flying_events = array(); |
416 | - foreach($FleetList->_container as $objFleet) { |
|
416 | + foreach ($FleetList->_container as $objFleet) { |
|
417 | 417 | $will_return = true; |
418 | - if(!$objFleet->isReturning()) { |
|
418 | + if (!$objFleet->isReturning()) { |
|
419 | 419 | // cut fleets on Hold and Expedition |
420 | - if($objFleet->time_arrive_to_target >= SN_TIME_NOW) { |
|
420 | + if ($objFleet->time_arrive_to_target >= SN_TIME_NOW) { |
|
421 | 421 | $objFleet->mission_type == MT_RELOCATE ? $will_return = false : false; |
422 | 422 | tpl_topnav_event_build_helper($objFleet->time_arrive_to_target, EVENT_FLEET_ARRIVE, classLocale::$lang['sys_event_arrive'], $objFleet->target_coordinates_typed(), !$will_return, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
423 | 423 | } |
424 | - if($objFleet->time_mission_job_complete) { |
|
424 | + if ($objFleet->time_mission_job_complete) { |
|
425 | 425 | tpl_topnav_event_build_helper($objFleet->time_mission_job_complete, EVENT_FLEET_STAY, classLocale::$lang['sys_event_stay'], $objFleet->target_coordinates_typed(), false, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
426 | 426 | } |
427 | 427 | } |
428 | - if($will_return) { |
|
428 | + if ($will_return) { |
|
429 | 429 | tpl_topnav_event_build_helper($objFleet->time_return_to_source, EVENT_FLEET_RETURN, classLocale::$lang['sys_event_return'], $objFleet->launch_coordinates_typed(), true, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
430 | 430 | } |
431 | 431 | } |
@@ -433,12 +433,12 @@ discard block |
||
433 | 433 | asort($fleet_flying_sorter); |
434 | 434 | |
435 | 435 | $fleet_flying_count = $FleetList->count(); |
436 | - foreach($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
|
436 | + foreach ($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
|
437 | 437 | $fleet_event = &$fleet_flying_events[$fleet_event_id]; |
438 | 438 | $template->assign_block_vars("flying_{$type}s", array( |
439 | 439 | 'TIME' => max(0, $fleet_time - SN_TIME_NOW), |
440 | 440 | 'TEXT' => $fleet_flying_count, |
441 | - 'HINT' => date(FMT_DATE_TIME, $fleet_time + SN_CLIENT_TIME_DIFF) . " - {$classLocale['sys_fleet']} {$fleet_event['TEXT']} {$fleet_event['COORDINATES']} {$classLocale['sys_planet_type_sh'][$fleet_event['COORDINATES_TYPE']]} {$classLocale['type_mission'][$fleet_event['OBJECT']->mission_type]}", |
|
441 | + 'HINT' => date(FMT_DATE_TIME, $fleet_time + SN_CLIENT_TIME_DIFF)." - {$classLocale['sys_fleet']} {$fleet_event['TEXT']} {$fleet_event['COORDINATES']} {$classLocale['sys_planet_type_sh'][$fleet_event['COORDINATES_TYPE']]} {$classLocale['type_mission'][$fleet_event['OBJECT']->mission_type]}", |
|
442 | 442 | )); |
443 | 443 | $fleet_event['DECREASE'] ? $fleet_flying_count-- : false; |
444 | 444 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | global $template_result; |
463 | 463 | $classLocale = classLocale::$lang; |
464 | 464 | |
465 | - if(!is_array($user)) { |
|
465 | + if (!is_array($user)) { |
|
466 | 466 | return ''; |
467 | 467 | } |
468 | 468 | |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | |
484 | 484 | $ThisUsersPlanets = db_planet_list_sorted($user); |
485 | 485 | // while ($CurPlanet = db_fetch($ThisUsersPlanets)) |
486 | - foreach($ThisUsersPlanets as $CurPlanet) { |
|
487 | - if($CurPlanet['destruyed']) { |
|
486 | + foreach ($ThisUsersPlanets as $CurPlanet) { |
|
487 | + if ($CurPlanet['destruyed']) { |
|
488 | 488 | continue; |
489 | 489 | } |
490 | 490 | |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | */ |
509 | 509 | $fleet_flying_list = array(); |
510 | 510 | $fleet_flying_list[0] = FleetList::dbGetFleetListByOwnerId($user['id']); |
511 | - foreach($fleet_flying_list[0]->_container as $fleet_id => $objFleet) { |
|
512 | - if(empty($fleet_flying_list[$objFleet->mission_type])) { |
|
511 | + foreach ($fleet_flying_list[0]->_container as $fleet_id => $objFleet) { |
|
512 | + if (empty($fleet_flying_list[$objFleet->mission_type])) { |
|
513 | 513 | $fleet_flying_list[$objFleet->mission_type] = new FleetList(); |
514 | 514 | } |
515 | 515 | $fleet_flying_list[$objFleet->mission_type][$fleet_id] = $objFleet; |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | que_tpl_parse($template, QUE_RESEARCH, $user, array(), null, !classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE]); |
522 | 522 | que_tpl_parse($template, SUBQUE_FLEET, $user, $planetrow, null, true); |
523 | 523 | |
524 | - if(!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) { |
|
525 | - foreach(classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) { |
|
524 | + if (!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) { |
|
525 | + foreach (classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) { |
|
526 | 526 | $template->assign_block_vars('navbar_prefix_button', array( |
527 | 527 | 'IMAGE' => $navbar_button_image, |
528 | 528 | 'URL_RELATIVE' => $navbar_button_url, |
@@ -536,13 +536,13 @@ discard block |
||
536 | 536 | $time_now_parsed = getdate(SN_TIME_NOW); |
537 | 537 | $time_local_parsed = getdate(defined('SN_CLIENT_TIME_LOCAL') ? SN_CLIENT_TIME_LOCAL : SN_TIME_NOW); |
538 | 538 | |
539 | - if(classSupernova::$config->game_news_overview) { |
|
539 | + if (classSupernova::$config->game_news_overview) { |
|
540 | 540 | $user_last_read_safe = intval($user['news_lastread']); |
541 | 541 | nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`) >= {$user_last_read_safe}", classSupernova::$config->game_news_overview); |
542 | 542 | } |
543 | 543 | |
544 | 544 | $notes_query = db_note_list_by_owner($user['id'], true); |
545 | - while($note_row = db_fetch($notes_query)) { |
|
545 | + while ($note_row = db_fetch($notes_query)) { |
|
546 | 546 | note_assign($template, $note_row); |
547 | 547 | } |
548 | 548 | |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | 'QUE_ID' => QUE_RESEARCH, |
557 | 557 | 'QUE_HTML' => 'topnav', |
558 | 558 | |
559 | - 'RESEARCH_ONGOING' => (boolean)$user['que'], |
|
559 | + 'RESEARCH_ONGOING' => (boolean) $user['que'], |
|
560 | 560 | |
561 | 561 | 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], classLocale::$lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], |
562 | 562 | $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds'] |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | 'QUE_STRUCTURES' => QUE_STRUCTURES, |
634 | 634 | )); |
635 | 635 | |
636 | - if((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
|
636 | + if ((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
|
637 | 637 | tpl_set_resource_info($template, $planetrow); |
638 | 638 | $template->assign_vars(array( |
639 | 639 | 'SN_RENDER_NAVBAR_PLANET' => true, |
@@ -648,12 +648,12 @@ discard block |
||
648 | 648 | * @param template|string $template |
649 | 649 | */ |
650 | 650 | function displayP($template) { |
651 | - if(is_object($template)) { |
|
652 | - if(empty($template->parsed)) { |
|
651 | + if (is_object($template)) { |
|
652 | + if (empty($template->parsed)) { |
|
653 | 653 | parsetemplate($template); |
654 | 654 | } |
655 | 655 | |
656 | - foreach($template->files as $section => $filename) { |
|
656 | + foreach ($template->files as $section => $filename) { |
|
657 | 657 | $template->display($section); |
658 | 658 | } |
659 | 659 | } else { |
@@ -668,11 +668,11 @@ discard block |
||
668 | 668 | * @return mixed |
669 | 669 | */ |
670 | 670 | function parsetemplate($template, $array = false) { |
671 | - if(is_object($template)) { |
|
671 | + if (is_object($template)) { |
|
672 | 672 | global $user; |
673 | 673 | |
674 | - if(!empty($array) && is_array($array)) { |
|
675 | - foreach($array as $key => $data) { |
|
674 | + if (!empty($array) && is_array($array)) { |
|
675 | + foreach ($array as $key => $data) { |
|
676 | 676 | $template->assign_var($key, $data); |
677 | 677 | } |
678 | 678 | } |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | |
714 | 714 | $template_ex = '.tpl.html'; |
715 | 715 | |
716 | - if($template === false) { |
|
717 | - return sys_file_read(TEMPLATE_DIR . '/' . $files . $template_ex); |
|
716 | + if ($template === false) { |
|
717 | + return sys_file_read(TEMPLATE_DIR.'/'.$files.$template_ex); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | is_string($files) ? $files = array(basename($files) => $files) : false; |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | //$template->set_custom_template($template_path ? $template_path : TEMPLATE_DIR, TEMPLATE_NAME, TEMPLATE_DIR); |
724 | 724 | |
725 | 725 | $tmpl_name = gettemplatename($user['dpath']); |
726 | - $template->set_custom_template(($template_path ? $template_path : SN_ROOT_PHYSICAL . 'design/templates/') . $tmpl_name . '/', $tmpl_name, TEMPLATE_DIR); |
|
726 | + $template->set_custom_template(($template_path ? $template_path : SN_ROOT_PHYSICAL.'design/templates/').$tmpl_name.'/', $tmpl_name, TEMPLATE_DIR); |
|
727 | 727 | |
728 | 728 | // TODO ГРЯЗНЫЙ ХАК! Это нужно, что бы по возможности перезаписать инфу из языковых пакетов модулей там, где она была перезаписана раньше инфой из основного пакета. Почему? |
729 | 729 | // - сначала грузятся модули и их языковые пакеты |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | !empty(classSupernova::$sn_mvc['i18n']['']) ? lng_load_i18n(classSupernova::$sn_mvc['i18n']['']) : false; |
734 | 734 | $sn_page_name ? lng_load_i18n(classSupernova::$sn_mvc['i18n'][$sn_page_name]) : false; |
735 | 735 | |
736 | - foreach($files as &$filename) { |
|
737 | - $filename = $filename . $template_ex; |
|
736 | + foreach ($files as &$filename) { |
|
737 | + $filename = $filename.$template_ex; |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | $template->set_filenames($files); |
@@ -756,15 +756,15 @@ discard block |
||
756 | 756 | |
757 | 757 | $template->assign_vars($q = array( |
758 | 758 | 'LANG' => $language ? $language : '', |
759 | - 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', |
|
759 | + 'referral' => $id_ref ? '&id_ref='.$id_ref : '', |
|
760 | 760 | |
761 | - 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
761 | + 'REQUEST_PARAMS' => !empty($url_params) ? '?'.implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
762 | 762 | 'FILENAME' => basename($_SERVER['PHP_SELF']), |
763 | 763 | )); |
764 | 764 | |
765 | - foreach(lng_get_list() as $lng_id => $lng_data) { |
|
766 | - if(isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
|
767 | - foreach($lng_data['LANG_VARIANTS'] as $lang_variant) { |
|
765 | + foreach (lng_get_list() as $lng_id => $lng_data) { |
|
766 | + if (isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
|
767 | + foreach ($lng_data['LANG_VARIANTS'] as $lang_variant) { |
|
768 | 768 | $lng_data1 = $lng_data; |
769 | 769 | $lng_data1 = array_merge($lng_data1, $lang_variant); |
770 | 770 | $template->assign_block_vars('language', $lng_data1); |
@@ -787,8 +787,8 @@ discard block |
||
787 | 787 | $que = $que['ques'][$que_type][$planet['id_owner']][$planet['id']]; |
788 | 788 | |
789 | 789 | $que_length = 0; |
790 | - if(!empty($que)) { |
|
791 | - foreach($que as $que_item) { |
|
790 | + if (!empty($que)) { |
|
791 | + foreach ($que as $que_item) { |
|
792 | 792 | $template->assign_block_vars('que', que_tpl_parse_element($que_item)); |
793 | 793 | } |
794 | 794 | $que_length = count($que); |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | * @param int $user_dark_matter |
804 | 804 | */ |
805 | 805 | function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter) { |
806 | - foreach($density_price_chart as $density_price_index => &$density_price_data) { |
|
806 | + foreach ($density_price_chart as $density_price_index => &$density_price_data) { |
|
807 | 807 | $density_cost = $density_price_data; |
808 | 808 | $density_number_style = pretty_number($density_cost, true, $user_dark_matter, false, false); |
809 | 809 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | function tpl_assign_select(&$template, $name, $values) { |
828 | 828 | !is_array($values) ? $values = array($values => $values) : false; |
829 | 829 | |
830 | - foreach($values as $key => $value) { |
|
830 | + foreach ($values as $key => $value) { |
|
831 | 831 | $template->assign_block_vars($name, array( |
832 | 832 | 'KEY' => htmlentities($key, ENT_COMPAT, 'UTF-8'), |
833 | 833 | 'VALUE' => htmlentities($value, ENT_COMPAT, 'UTF-8'), |
@@ -57,9 +57,11 @@ discard block |
||
57 | 57 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
58 | 58 | } |
59 | 59 | |
60 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
60 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
61 | + // Existing friendship |
|
61 | 62 | { |
62 | 63 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
64 | + } |
|
63 | 65 | |
64 | 66 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
65 | 67 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -67,15 +69,19 @@ discard block |
||
67 | 69 | db_buddy_delete($buddy_id); |
68 | 70 | sn_db_transaction_commit(); |
69 | 71 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
70 | - } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
72 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
73 | + // Player's outcoming request - either denied or waiting |
|
71 | 74 | { |
72 | 75 | db_buddy_delete($buddy_id); |
76 | + } |
|
73 | 77 | sn_db_transaction_commit(); |
74 | 78 | throw new exception('buddy_err_delete_own', ERR_NONE); |
75 | - } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
79 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
80 | + // Deny incoming request |
|
76 | 81 | { |
77 | 82 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
78 | 83 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
84 | + } |
|
79 | 85 | |
80 | 86 | db_buddy_update_status($buddy_id, BUDDY_REQUEST_DENIED); |
81 | 87 | sn_db_transaction_commit(); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * Idea from buddy.php Created by Perberos. All rights reversed (C) 2006 |
11 | 11 | * */ |
12 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
12 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
13 | 13 | |
14 | 14 | lng_include('buddy'); |
15 | 15 | |
@@ -17,32 +17,32 @@ discard block |
||
17 | 17 | try { |
18 | 18 | sn_db_transaction_start(); |
19 | 19 | |
20 | - if($buddy_id = sys_get_param_id('buddy_id')) { |
|
20 | + if ($buddy_id = sys_get_param_id('buddy_id')) { |
|
21 | 21 | $buddy_row = db_buddy_get_row($buddy_id); |
22 | - if(!is_array($buddy_row)) { |
|
22 | + if (!is_array($buddy_row)) { |
|
23 | 23 | throw new exception('buddy_err_not_exist', ERR_ERROR); |
24 | 24 | } |
25 | 25 | |
26 | - switch($mode = sys_get_param_str('mode')) { |
|
26 | + switch ($mode = sys_get_param_str('mode')) { |
|
27 | 27 | case 'accept': |
28 | - if($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
28 | + if ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
29 | 29 | throw new exception('buddy_err_accept_own', ERR_ERROR); |
30 | 30 | } |
31 | 31 | |
32 | - if($buddy_row['BUDDY_OWNER_ID'] != $user['id']) { |
|
32 | + if ($buddy_row['BUDDY_OWNER_ID'] != $user['id']) { |
|
33 | 33 | throw new exception('buddy_err_accept_alien', ERR_ERROR); |
34 | 34 | } |
35 | 35 | |
36 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
36 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
37 | 37 | throw new exception('buddy_err_accept_already', ERR_WARNING); |
38 | 38 | } |
39 | 39 | |
40 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) { |
|
40 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) { |
|
41 | 41 | throw new exception('buddy_err_accept_denied', ERR_ERROR); |
42 | 42 | } |
43 | 43 | |
44 | 44 | db_buddy_update_status($buddy_id, BUDDY_REQUEST_ACTIVE); |
45 | - if(classSupernova::$db->db_affected_rows()) { |
|
45 | + if (classSupernova::$db->db_affected_rows()) { |
|
46 | 46 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], classLocale::$lang['buddy_msg_accept_title'], |
47 | 47 | sprintf(classLocale::$lang['buddy_msg_accept_text'], $user['username'])); |
48 | 48 | sn_db_transaction_commit(); |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | break; |
54 | 54 | |
55 | 55 | case 'delete': |
56 | - if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) { |
|
56 | + if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) { |
|
57 | 57 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
58 | 58 | } |
59 | 59 | |
60 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
60 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
61 | 61 | { |
62 | 62 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
63 | 63 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | db_buddy_delete($buddy_id); |
68 | 68 | sn_db_transaction_commit(); |
69 | 69 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
70 | - } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
70 | + } elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
71 | 71 | { |
72 | 72 | db_buddy_delete($buddy_id); |
73 | 73 | sn_db_transaction_commit(); |
74 | 74 | throw new exception('buddy_err_delete_own', ERR_NONE); |
75 | - } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
75 | + } elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
76 | 76 | { |
77 | 77 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], classLocale::$lang['buddy_msg_deny_title'], |
78 | 78 | sprintf(classLocale::$lang['buddy_msg_deny_text'], $user['username'])); |
@@ -87,22 +87,22 @@ discard block |
||
87 | 87 | |
88 | 88 | // New request? |
89 | 89 | // Checking for user ID - in case if it was request from outside buddy system |
90 | - if($new_friend_id = sys_get_param_id('request_user_id')) { |
|
90 | + if ($new_friend_id = sys_get_param_id('request_user_id')) { |
|
91 | 91 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
92 | - } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) { |
|
92 | + } elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name')) { |
|
93 | 93 | $new_friend_row = db_user_by_username($new_friend_name, true, '`id`, `username`'); |
94 | 94 | $new_friend_name = db_escape($new_friend_name); |
95 | 95 | } |
96 | 96 | |
97 | - if($new_friend_row['id'] == $user['id']) { |
|
97 | + if ($new_friend_row['id'] == $user['id']) { |
|
98 | 98 | unset($new_friend_row); |
99 | 99 | throw new exception('buddy_err_adding_self', ERR_ERROR); |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Checking for user name & request text - in case if it was request to adding new request |
103 | - if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) { |
|
103 | + if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) { |
|
104 | 104 | $check_relation = db_buddy_check_relation($user, $new_friend_row); |
105 | - if(isset($check_relation['BUDDY_ID'])) { |
|
105 | + if (isset($check_relation['BUDDY_ID'])) { |
|
106 | 106 | throw new exception('buddy_err_adding_exists', ERR_WARNING); |
107 | 107 | } |
108 | 108 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | sn_db_transaction_commit(); |
114 | 114 | throw new exception('buddy_err_adding_none', ERR_NONE); |
115 | 115 | } |
116 | -} catch(Exception $e) { |
|
116 | +} catch (Exception $e) { |
|
117 | 117 | $result[] = array( |
118 | 118 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
119 | 119 | 'MESSAGE' => classLocale::$lang[$e->getMessage()], |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | sn_db_transaction_rollback(); |
124 | 124 | |
125 | 125 | $query = db_buddy_list_by_user($user['id']); |
126 | -while($row = db_fetch($query)) { |
|
126 | +while ($row = db_fetch($query)) { |
|
127 | 127 | $row['BUDDY_REQUEST'] = sys_bbcodeParse($row['BUDDY_REQUEST']); |
128 | 128 | |
129 | 129 | $row['BUDDY_ACTIVE'] = $row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE; |