@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * @param $ube_report_id |
|
153 | + * @param integer $ube_report_id |
|
154 | 154 | * |
155 | 155 | * @return array |
156 | 156 | * |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | |
290 | 290 | /** |
291 | - * @param $ube_report_id |
|
291 | + * @param integer $ube_report_id |
|
292 | 292 | * |
293 | 293 | * @return array |
294 | 294 | */ |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | // Рендерит таблицу общего результата боя |
337 | 337 | /** |
338 | 338 | * @param $array |
339 | - * @param $lang_header_index |
|
339 | + * @param string $lang_header_index |
|
340 | 340 | * |
341 | 341 | * @return array |
342 | 342 | */ |
@@ -362,6 +362,9 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | |
365 | + /** |
|
366 | + * @param integer $ube_report_id |
|
367 | + */ |
|
365 | 368 | public function sql_generate_outcome_unit_array(&$sql_perform_report_unit, $ube_report_id) { |
366 | 369 | $fleet_id = $this->db_id; |
367 | 370 | |
@@ -468,6 +471,10 @@ discard block |
||
468 | 471 | $this->fleet_capacity -= $fleet_total_resources; |
469 | 472 | } |
470 | 473 | |
474 | + /** |
|
475 | + * @param integer $is_small_fleet_recce |
|
476 | + * @param integer $reapers_status |
|
477 | + */ |
|
471 | 478 | public function db_save_combat_result_fleet($is_small_fleet_recce, $reapers_status) { |
472 | 479 | $ship_count_initial = $this->unit_list->unitsCount(); |
473 | 480 | $ship_count_lost = $this->unit_list->unitCountLost(); |
@@ -535,7 +542,7 @@ discard block |
||
535 | 542 | |
536 | 543 | /** |
537 | 544 | * @param UBEFleetList $fleet_list |
538 | - * @param $is_simulator |
|
545 | + * @param boolean $is_simulator |
|
539 | 546 | * |
540 | 547 | * @version 2016-02-25 23:42:45 41a4.68 |
541 | 548 | */ |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | $this->owner_id, |
163 | 163 | $this->db_id, |
164 | 164 | |
165 | - (float)$this->UBE_PLANET[PLANET_ID], |
|
166 | - "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'", |
|
167 | - (int)$this->UBE_PLANET[PLANET_GALAXY], |
|
168 | - (int)$this->UBE_PLANET[PLANET_SYSTEM], |
|
169 | - (int)$this->UBE_PLANET[PLANET_PLANET], |
|
170 | - (int)$this->UBE_PLANET[PLANET_TYPE], |
|
171 | - |
|
172 | - (float)$this->resource_list[RES_METAL], |
|
173 | - (float)$this->resource_list[RES_CRYSTAL], |
|
174 | - (float)$this->resource_list[RES_DEUTERIUM], |
|
175 | - |
|
176 | - (float)$this->fleet_bonus->calcBonus(P_ATTACK), |
|
177 | - (float)$this->fleet_bonus->calcBonus(P_SHIELD), |
|
178 | - (float)$this->fleet_bonus->calcBonus(P_ARMOR), |
|
165 | + (float) $this->UBE_PLANET[PLANET_ID], |
|
166 | + "'".db_escape($this->UBE_PLANET[PLANET_NAME])."'", |
|
167 | + (int) $this->UBE_PLANET[PLANET_GALAXY], |
|
168 | + (int) $this->UBE_PLANET[PLANET_SYSTEM], |
|
169 | + (int) $this->UBE_PLANET[PLANET_PLANET], |
|
170 | + (int) $this->UBE_PLANET[PLANET_TYPE], |
|
171 | + |
|
172 | + (float) $this->resource_list[RES_METAL], |
|
173 | + (float) $this->resource_list[RES_CRYSTAL], |
|
174 | + (float) $this->resource_list[RES_DEUTERIUM], |
|
175 | + |
|
176 | + (float) $this->fleet_bonus->calcBonus(P_ATTACK), |
|
177 | + (float) $this->fleet_bonus->calcBonus(P_SHIELD), |
|
178 | + (float) $this->fleet_bonus->calcBonus(P_ARMOR), |
|
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | $this->owner_id = $objFleet->playerOwnerId; |
190 | 190 | $this->group_id = $objFleet->group_id; |
191 | 191 | |
192 | - foreach($objFleet->shipsIterator() as $unit_id => $unit) { |
|
193 | - if(!$unit->count) { |
|
192 | + foreach ($objFleet->shipsIterator() as $unit_id => $unit) { |
|
193 | + if (!$unit->count) { |
|
194 | 194 | continue; |
195 | 195 | } |
196 | 196 | |
197 | 197 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
198 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
198 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
199 | 199 | $this->unit_list->unitAdjustCount($unit_id, $unit->count); |
200 | 200 | } |
201 | 201 | } |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | // } |
232 | 232 | // } |
233 | 233 | |
234 | - foreach($sn_group_combat as $unit_id) { |
|
235 | - if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
234 | + foreach ($sn_group_combat as $unit_id) { |
|
235 | + if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
236 | 236 | $this->unit_list->unitAdjustCount($unit_id, $unit_count); |
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
240 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
241 | 241 | $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id)); |
242 | 242 | } |
243 | 243 | |
@@ -296,27 +296,27 @@ discard block |
||
296 | 296 | $ube_report_id, |
297 | 297 | $this->db_id, |
298 | 298 | |
299 | - (float)$this->resources_lost_on_units[RES_METAL], |
|
300 | - (float)$this->resources_lost_on_units[RES_CRYSTAL], |
|
301 | - (float)$this->resources_lost_on_units[RES_DEUTERIUM], |
|
302 | - (float)$this->cargo_dropped[RES_METAL], |
|
303 | - (float)$this->cargo_dropped[RES_CRYSTAL], |
|
304 | - (float)$this->cargo_dropped[RES_DEUTERIUM], |
|
305 | - (float)$this->resources_looted[RES_METAL], |
|
306 | - (float)$this->resources_looted[RES_CRYSTAL], |
|
307 | - (float)$this->resources_looted[RES_DEUTERIUM], |
|
308 | - (float)$this->resources_lost_in_metal[RES_METAL], |
|
299 | + (float) $this->resources_lost_on_units[RES_METAL], |
|
300 | + (float) $this->resources_lost_on_units[RES_CRYSTAL], |
|
301 | + (float) $this->resources_lost_on_units[RES_DEUTERIUM], |
|
302 | + (float) $this->cargo_dropped[RES_METAL], |
|
303 | + (float) $this->cargo_dropped[RES_CRYSTAL], |
|
304 | + (float) $this->cargo_dropped[RES_DEUTERIUM], |
|
305 | + (float) $this->resources_looted[RES_METAL], |
|
306 | + (float) $this->resources_looted[RES_CRYSTAL], |
|
307 | + (float) $this->resources_looted[RES_DEUTERIUM], |
|
308 | + (float) $this->resources_lost_in_metal[RES_METAL], |
|
309 | 309 | ); |
310 | 310 | } |
311 | 311 | |
312 | 312 | public function report_render_outcome_side_fleet() { |
313 | 313 | $UBE_DEFENCE_RESTORE = array(); |
314 | 314 | $UBE_UNITS_LOST = array(); |
315 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
316 | - if($UBEUnit->units_restored) { |
|
315 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
316 | + if ($UBEUnit->units_restored) { |
|
317 | 317 | $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored; |
318 | 318 | } |
319 | - if($UBEUnit->units_lost) { |
|
319 | + if ($UBEUnit->units_lost) { |
|
320 | 320 | $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost; |
321 | 321 | } |
322 | 322 | } |
@@ -341,16 +341,16 @@ discard block |
||
341 | 341 | */ |
342 | 342 | protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) { |
343 | 343 | $result = array(); |
344 | - if(!empty($array)) { |
|
345 | - foreach($array as $unit_id => $unit_count) { |
|
346 | - if($unit_count) { |
|
344 | + if (!empty($array)) { |
|
345 | + foreach ($array as $unit_id => $unit_count) { |
|
346 | + if ($unit_count) { |
|
347 | 347 | $result[] = array( |
348 | 348 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
349 | 349 | 'LOSS' => pretty_number($unit_count), |
350 | 350 | ); |
351 | 351 | } |
352 | 352 | } |
353 | - if($lang_header_index && count($result)) { |
|
353 | + if ($lang_header_index && count($result)) { |
|
354 | 354 | array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index])); |
355 | 355 | } |
356 | 356 | } |
@@ -363,16 +363,16 @@ discard block |
||
363 | 363 | $fleet_id = $this->db_id; |
364 | 364 | |
365 | 365 | $unit_sort_order = 0; |
366 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
367 | - if($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
366 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
367 | + if ($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
368 | 368 | $unit_sort_order++; |
369 | 369 | $sql_perform_report_unit[] = array( |
370 | 370 | $ube_report_id, |
371 | 371 | $fleet_id, |
372 | 372 | |
373 | 373 | $UBEUnit->unitId, |
374 | - (float)$UBEUnit->units_restored, |
|
375 | - (float)$UBEUnit->units_lost, |
|
374 | + (float) $UBEUnit->units_restored, |
|
375 | + (float) $UBEUnit->units_lost, |
|
376 | 376 | |
377 | 377 | $unit_sort_order, |
378 | 378 | ); |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | function ube_combat_result_calculate_resources() { |
389 | 389 | $resource_delta_fleet = array(); |
390 | 390 | // Если во флоте остались юниты или это планета - генерируем изменение ресурсов |
391 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
392 | - $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id]; |
|
393 | - if($resource_change) { |
|
391 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
392 | + $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id]; |
|
393 | + if ($resource_change) { |
|
394 | 394 | $resource_delta_fleet[$resource_id] = -($resource_change); |
395 | 395 | } |
396 | 396 | } |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | ); |
424 | 424 | |
425 | 425 | $this->fleet_capacity = 0; |
426 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
426 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
427 | 427 | $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount(); |
428 | 428 | |
429 | - if($UBEUnit->units_lost) { |
|
430 | - foreach($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
431 | - if(!$unit_resource_price) { |
|
429 | + if ($UBEUnit->units_lost) { |
|
430 | + foreach ($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
431 | + if (!$unit_resource_price) { |
|
432 | 432 | continue; |
433 | 433 | } |
434 | 434 | |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $this->resources_lost_on_units[$resource_id] += $resources_lost; |
437 | 437 | // Если это корабль - прибавляем потери к обломкам на орбите |
438 | 438 | // TODO - опция выбрасывания обороны в обломки |
439 | - if($UBEUnit->getType() == UNIT_SHIPS) { |
|
439 | + if ($UBEUnit->getType() == UNIT_SHIPS) { |
|
440 | 440 | $this->resources_lost_on_ships[$resource_id] += $resources_lost; |
441 | 441 | } |
442 | 442 | } |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | |
449 | 449 | // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй |
450 | 450 | // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются |
451 | - if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
451 | + if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
452 | 452 | $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена |
453 | - foreach($this->resource_list as $resource_id => &$resource_amount) { |
|
453 | + foreach ($this->resource_list as $resource_id => &$resource_amount) { |
|
454 | 454 | // Не просчитываем ресурсы, которых нет на борту кораблей флота |
455 | - if(!$resource_amount) { |
|
455 | + if (!$resource_amount) { |
|
456 | 456 | continue; |
457 | 457 | } |
458 | 458 | |
@@ -473,19 +473,19 @@ discard block |
||
473 | 473 | $objFleet2->setDbId($this->db_id); |
474 | 474 | |
475 | 475 | // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли |
476 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
476 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
477 | 477 | $objFleet2->dbDelete(); |
478 | - } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
478 | + } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
479 | 479 | $objFleet2->dbDelete(); |
480 | 480 | } else { |
481 | - if($ship_count_lost) { |
|
481 | + if ($ship_count_lost) { |
|
482 | 482 | // Просматриваем результаты изменения флотов |
483 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
483 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
484 | 484 | // Перебираем аутком на случай восстановления юнитов |
485 | 485 | // if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) { |
486 | 486 | // $fleet_real_array[$UBEUnit->unitId] = $units_left; |
487 | 487 | // }; |
488 | - if(floatval($UBEUnit->units_lost) != 0) { |
|
488 | + if (floatval($UBEUnit->units_lost) != 0) { |
|
489 | 489 | $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost)); |
490 | 490 | }; |
491 | 491 | } |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $objFleet2->resourcesAdjust($resource_delta_fleet); |
496 | 496 | |
497 | 497 | // Если защитник и не РМФ - отправляем флот назад |
498 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
498 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
499 | 499 | $objFleet2->markReturned(); |
500 | 500 | } |
501 | 501 | $objFleet2->dbSave(); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | public function calculate_unit_partial_data(UBEASA $side_ASA) { |
526 | 526 | $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor(); |
527 | 527 | |
528 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
528 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
529 | 529 | $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor(); |
530 | 530 | } |
531 | 531 | } |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | * @version 2016-02-25 23:42:45 41a4.68 |
538 | 538 | */ |
539 | 539 | public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) { |
540 | - foreach($fleet_list->_container as $defending_fleet) { |
|
540 | + foreach ($fleet_list->_container as $defending_fleet) { |
|
541 | 541 | // Не атакуются флоты на своей стороне |
542 | - if($this->is_attacker == $defending_fleet->is_attacker) { |
|
542 | + if ($this->is_attacker == $defending_fleet->is_attacker) { |
|
543 | 543 | continue; |
544 | 544 | } |
545 | 545 | $this->attack_fleet($defending_fleet, $is_simulator); |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) { |
556 | 556 | UBEDebug::unit_dump_header(); |
557 | 557 | |
558 | - foreach($this->unit_list->_container as $attacking_unit_pool) { |
|
558 | + foreach ($this->unit_list->_container as $attacking_unit_pool) { |
|
559 | 559 | UBEDebug::unit_dump($attacking_unit_pool, 'attacker'); |
560 | 560 | |
561 | 561 | // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..." |
562 | - foreach($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
563 | - if($defending_unit_pool->isEmpty()) { |
|
562 | + foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
563 | + if ($defending_unit_pool->isEmpty()) { |
|
564 | 564 | continue; |
565 | 565 | } |
566 | 566 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * |
11 | 11 | * @param Fleet $objFleet |
12 | 12 | * @param bool $start |
13 | - * @param null $result |
|
13 | + * @param integer $result |
|
14 | 14 | * |
15 | 15 | * @return mixed |
16 | 16 | */ |
@@ -19,15 +19,11 @@ discard block |
||
19 | 19 | // ------------------------------------------------------------------ |
20 | 20 | function flt_flyingFleetsSort($a, $b) { |
21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
23 | - // Если время - одинаковое, сравниваем события флотов |
|
22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
24 | 23 | // Если события - одинаковые, то флоты равны |
25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
26 | - // Если события разные - первыми считаем прибывающие флоты |
|
27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
32 | 28 | ( |
33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -45,13 +41,13 @@ discard block |
||
45 | 41 | $handler = fopen('event.log', 'a+'); |
46 | 42 | } |
47 | 43 | |
48 | - fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n"); |
|
44 | + fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n"); |
|
49 | 45 | } |
50 | 46 | |
51 | 47 | // ------------------------------------------------------------------ |
52 | 48 | function flt_flying_fleet_handler($skip_fleet_update = false) { |
53 | 49 | if (true) { |
54 | - if(!defined('IN_AJAX')) { |
|
50 | + if (!defined('IN_AJAX')) { |
|
55 | 51 | print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>'); |
56 | 52 | pdump('Fleet handler is disabled'); |
57 | 53 | } |
@@ -177,7 +173,7 @@ discard block |
||
177 | 173 | MT_EXPLORE => 'flt_mission_explore', |
178 | 174 | ); |
179 | 175 | foreach ($missions_used as $mission_id => $cork) { |
180 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
|
176 | + require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX); |
|
181 | 177 | } |
182 | 178 | |
183 | 179 | //log_file('Обработка миссий'); |
@@ -286,7 +286,6 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * Функция пытается залогиниться по всем известным провайдерам |
288 | 288 | * |
289 | - * @param null $result |
|
290 | 289 | */ |
291 | 290 | public function login() { |
292 | 291 | if(empty(sn_module::$sn_module_list['auth'])) { |
@@ -823,10 +822,17 @@ discard block |
||
823 | 822 | |
824 | 823 | // OK v4.5 |
825 | 824 | // TODO - REMEMBER_ME |
825 | + |
|
826 | + /** |
|
827 | + * @param integer $period |
|
828 | + */ |
|
826 | 829 | protected static function cookie_set($value, $impersonate = false, $period = null) { |
827 | 830 | sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE); |
828 | 831 | } |
829 | 832 | |
833 | + /** |
|
834 | + * @param string $message |
|
835 | + */ |
|
830 | 836 | protected static function flog($message, $die = false) { |
831 | 837 | if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
832 | 838 | return; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // Проверить наличие такого имени в истории имён |
225 | 225 | do { |
226 | 226 | sn_db_transaction_rollback(); |
227 | - $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
227 | + $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
228 | 228 | sn_db_transaction_start(); |
229 | 229 | } while (db_player_name_exists($this->player_suggested_name)); |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | if ($player_name_submitted) { |
234 | 234 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
235 | 235 | if ($this->register_status == LOGIN_SUCCESS) { |
236 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
|
236 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); |
|
237 | 237 | } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
238 | 238 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
239 | 239 | } |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | ); |
260 | 260 | |
261 | 261 | if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
262 | - $prohibited_characters = array_map(function ($value) { |
|
263 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
|
262 | + $prohibited_characters = array_map(function($value) { |
|
263 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; |
|
264 | 264 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
265 | 265 | $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters); |
266 | 266 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | foreach ($this->providers as $provider_id => $provider) { |
309 | 309 | $login_status = $provider->login(); // OK v4.5 |
310 | - self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
310 | + self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
311 | 311 | if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
312 | 312 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
313 | 313 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | if (!$this->is_player_register) { |
348 | 348 | // Нет - отправляем на процесс регистрации |
349 | 349 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
350 | - sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
|
350 | + sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : '')); |
|
351 | 351 | } |
352 | 352 | } else { |
353 | 353 | // Да, есть доступные игроки, которые так же прописаны в базе |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | if ($redirect === true) { |
410 | - sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
410 | + sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
411 | 411 | } elseif ($redirect !== false) { |
412 | 412 | sys_redirect($redirect); |
413 | 413 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | $user['vacation'] = SN_TIME_NOW; |
703 | 703 | } |
704 | 704 | |
705 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
705 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
706 | 706 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
707 | 707 | |
708 | 708 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -710,9 +710,9 @@ discard block |
||
710 | 710 | |
711 | 711 | $proxy_safe = static::$db->db_escape(self::$device->ip_v4_proxy_chain); |
712 | 712 | |
713 | - DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = " . SN_TIME_NOW . ", |
|
714 | - `banaday` = " . static::$db->db_escape($user['banaday']) . ", `vacation` = " . static::$db->db_escape($user['vacation']) . ", |
|
715 | - `user_lastip` = '" . static::$db->db_escape($user['user_lastip']) . "', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = " . self::$device->browser_id |
|
713 | + DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = ".SN_TIME_NOW.", |
|
714 | + `banaday` = " . static::$db->db_escape($user['banaday']).", `vacation` = ".static::$db->db_escape($user['vacation']).", |
|
715 | + `user_lastip` = '" . static::$db->db_escape($user['user_lastip'])."', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = ".self::$device->browser_id |
|
716 | 716 | ); |
717 | 717 | } |
718 | 718 | |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | */ |
806 | 806 | // OK v4 |
807 | 807 | public static function password_encode($password, $salt) { |
808 | - return md5($password . $salt); |
|
808 | + return md5($password.$salt); |
|
809 | 809 | } |
810 | 810 | /** |
811 | 811 | * Генерирует соль |
@@ -831,10 +831,10 @@ discard block |
||
831 | 831 | } |
832 | 832 | list($called, $caller) = debug_backtrace(false); |
833 | 833 | $caller_name = |
834 | - (!empty($caller['class']) ? $caller['class'] : '') . |
|
835 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
836 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
837 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
834 | + (!empty($caller['class']) ? $caller['class'] : ''). |
|
835 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
836 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
837 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
838 | 838 | |
839 | 839 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
840 | 840 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | if ($die) { |
843 | 843 | // pdump($caller); |
844 | 844 | // pdump(debug_backtrace(false)); |
845 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
845 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
846 | 846 | } |
847 | 847 | } |
848 | 848 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | |
22 | 22 | function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) { |
23 | 23 | $unit_list = sn_get_groups($mode); |
24 | - if(empty($unit_list)) { |
|
24 | + if (empty($unit_list)) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | $name_list = classLocale::$lang['tech']; |
28 | 28 | |
29 | - foreach($unit_list as $unit_id) { |
|
29 | + foreach ($unit_list as $unit_id) { |
|
30 | 30 | $template->assign_block_vars('unit', array( |
31 | 31 | 'ID' => $unit_id, |
32 | 32 | 'NAME' => $name_list[$unit_id], |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { return sn_function_call(__FUNCTION__, array($unit_id, $unit_amount, $mode)); } |
40 | 40 | |
41 | 41 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { |
42 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) { |
|
42 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) { |
|
43 | 43 | $unit_amount = round($unit_amount); |
44 | 44 | $unit_name = get_unit_param($unit_id, P_NAME); |
45 | 45 | $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))"; |
@@ -253,9 +253,11 @@ |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
256 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
256 | + if(!isset($planet_row['id'])) { |
|
257 | + // || $planet_row['id'] != $user['current_planet'] |
|
257 | 258 | { |
258 | 259 | $planet_row = db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
260 | + } |
|
259 | 261 | // Если текущей планеты не существует - выставляем Столицу |
260 | 262 | if(!isset($planet_row['id'])) { |
261 | 263 | $planet_row = db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
@@ -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 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) { |
58 | 58 | $Position = intval($Position); |
59 | 59 | |
60 | - if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
60 | + if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | |
67 | 67 | $planet_generator = sn_get_groups('planet_generator'); |
68 | 68 | |
69 | - if($HomeWorld) { |
|
69 | + if ($HomeWorld) { |
|
70 | 70 | $position_data = $planet_generator[0]; |
71 | 71 | } else { |
72 | 72 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
73 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
73 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
74 | 74 | // Корректируем температуру для планеты-странника |
75 | 75 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
76 | 76 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $planet_images = sn_get_groups('planet_images'); |
80 | 80 | $planet_image = $position_data['planet_images'][mt_rand(0, count($position_data['planet_images']) - 1)]; |
81 | - $planet_image .= 'planet' . $planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)]; |
|
81 | + $planet_image .= 'planet'.$planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)]; |
|
82 | 82 | |
83 | 83 | $t_max = sn_rand_gauss_range($position_data['t_max_min'], $position_data['t_max_max'], true, 1.3, true); |
84 | 84 | $t_min = $t_max - sn_rand_gauss_range($position_data['t_delta_min'], $position_data['t_delta_max'], true, 1.3, true); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $core_info = uni_create_planet_get_density($position_data, $user_row, $planet_sectors); |
91 | 91 | |
92 | - $planet_name_unsafe = $user_row['username'] . ' ' . ($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']); |
|
92 | + $planet_name_unsafe = $user_row['username'].' '.($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']); |
|
93 | 93 | |
94 | 94 | $planet['name'] = db_escape(strip_tags(trim($planet_name_unsafe))); |
95 | 95 | $planet['id_owner'] = $PlanetOwnerID; |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | $moon_name = ''; |
171 | 171 | $moon_row = array(); |
172 | 172 | $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
173 | - if(!$moon['id']) { |
|
173 | + if (!$moon['id']) { |
|
174 | 174 | $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`'); |
175 | 175 | |
176 | - if($moon_planet['id']) { |
|
176 | + if ($moon_planet['id']) { |
|
177 | 177 | $base_storage_size = BASE_STORAGE_SIZE; |
178 | 178 | |
179 | - if(!$moon_chance) { |
|
179 | + if (!$moon_chance) { |
|
180 | 180 | $size = mt_rand(1100, 8999); |
181 | - } elseif($moon_chance <= 100) { |
|
181 | + } elseif ($moon_chance <= 100) { |
|
182 | 182 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
183 | 183 | } else { |
184 | 184 | $size = $moon_chance; |
@@ -194,22 +194,22 @@ discard block |
||
194 | 194 | |
195 | 195 | $field_max = ceil($size / 1000); |
196 | 196 | |
197 | - if(isset($options['image']) && $options['image']) { |
|
197 | + if (isset($options['image']) && $options['image']) { |
|
198 | 198 | $moon_image = $options['image']; |
199 | 199 | } else { |
200 | 200 | $moon_image = 'mond'; |
201 | 201 | } |
202 | 202 | |
203 | 203 | $moon_row = classSupernova::db_ins_record(LOC_PLANET, |
204 | - "`id_owner` = '{$user_id}', `parent_planet` = '{$moon_planet['id']}', `name` = '{$moon_name_safe}', `last_update` = " . SN_TIME_NOW . ", `image` = '{$moon_image}', |
|
205 | - `galaxy` = '{$pos_galaxy}', `system` = '{$pos_system}', `planet` = '{$pos_planet}', `planet_type` = " . PT_MOON . ", |
|
204 | + "`id_owner` = '{$user_id}', `parent_planet` = '{$moon_planet['id']}', `name` = '{$moon_name_safe}', `last_update` = ".SN_TIME_NOW.", `image` = '{$moon_image}', |
|
205 | + `galaxy` = '{$pos_galaxy}', `system` = '{$pos_system}', `planet` = '{$pos_planet}', `planet_type` = ".PT_MOON.", |
|
206 | 206 | `diameter` = '{$size}', `field_max` = '{$field_max}', `density` = 2500, `density_index` = 2, `temp_min` = '{$temp_min}', `temp_max` = '{$temp_max}', |
207 | 207 | `metal` = '0', `metal_perhour` = '0', `metal_max` = '{$base_storage_size}', |
208 | 208 | `crystal` = '0', `crystal_perhour` = '0', `crystal_max` = '{$base_storage_size}', |
209 | 209 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
210 | 210 | ); |
211 | 211 | |
212 | - if($update_debris) { |
|
212 | + if ($update_debris) { |
|
213 | 213 | $debris_spent = $moon_chance * 1000000; |
214 | 214 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
215 | 215 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -244,28 +244,28 @@ discard block |
||
244 | 244 | $planet_row['id'] = $user['current_planet']; |
245 | 245 | |
246 | 246 | // Пытаемся переключить на новую планету |
247 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
247 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
248 | 248 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
249 | 249 | } else { |
250 | 250 | $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']); |
251 | 251 | } |
252 | 252 | |
253 | 253 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
254 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
254 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
255 | 255 | { |
256 | 256 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
257 | 257 | // Если текущей планеты не существует - выставляем Столицу |
258 | - if(!isset($planet_row['id'])) { |
|
258 | + if (!isset($planet_row['id'])) { |
|
259 | 259 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
260 | 260 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
261 | - if(!isset($planet_row['id'])) { |
|
261 | + if (!isset($planet_row['id'])) { |
|
262 | 262 | classSupernova::$debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Если производилось переключение планеты - делаем запись в юзере |
268 | - if($user['current_planet'] != $planet_row['id']) { |
|
268 | + if ($user['current_planet'] != $planet_row['id']) { |
|
269 | 269 | DBStaticUser::db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
270 | 270 | $user['current_planet'] = $planet_row['id']; |
271 | 271 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | // ---------------------------------------------------------------------------------------------------------------- |
284 | 284 | function uni_render_coordinates($from, $prefix = '') { |
285 | - return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]"; |
|
285 | + return "[{$from[$prefix.'galaxy']}:{$from[$prefix.'system']}:{$from[$prefix.'planet']}]"; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | function uni_render_planet($from) { |
@@ -290,17 +290,17 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
293 | - if(!$from['id']) { |
|
293 | + if (!$from['id']) { |
|
294 | 294 | $result = classLocale::$lang['sys_planet_expedition']; |
295 | 295 | } else { |
296 | 296 | $from_planet_id = $include_id ? ( |
297 | - 'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} ' |
|
297 | + 'ID {'.($from['id'] ? $from['id'] : ($from[$prefix.'planet_id'] ? $from[$prefix.'planet_id'] : 0)).'} ' |
|
298 | 298 | ) : ''; |
299 | 299 | |
300 | - $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix . 'type'] ? $from[$prefix . 'type'] : 0); |
|
301 | - $from_planet_type = ($from_planet_type ? ' ' . classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : ''); |
|
300 | + $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix.'type'] ? $from[$prefix.'type'] : 0); |
|
301 | + $from_planet_type = ($from_planet_type ? ' '.classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : ''); |
|
302 | 302 | |
303 | - $result = $from_planet_id . uni_render_coordinates($from, $prefix) . $from_planet_type . ($from['name'] ? ' ' . $from['name'] : ''); |
|
303 | + $result = $from_planet_id.uni_render_coordinates($from, $prefix).$from_planet_type.($from['name'] ? ' '.$from['name'] : ''); |
|
304 | 304 | $result = $html_safe ? str_replace(' ', ' ', htmlentities($result, ENT_COMPAT, 'UTF-8')) : $result; |
305 | 305 | } |
306 | 306 | |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') { |
311 | - return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}"; |
|
311 | + return $page.(strpos($page, '?') === false ? '?' : '&')."galaxy={$from[$prefix.'galaxy']}&system={$from[$prefix.'system']}&planet={$from[$prefix.'planet']}"; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') { |
315 | - return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>'; |
|
315 | + return '<a href="'.uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}").'"'.($fleet_type ? " {$fleet_type}" : '').'>'.uni_render_coordinates($from, $prefix).'</a>'; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | function uni_get_time_to_jump($moon_row) { |
@@ -340,30 +340,30 @@ discard block |
||
340 | 340 | $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]); |
341 | 341 | |
342 | 342 | return |
343 | - isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&& |
|
344 | - isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&& |
|
343 | + isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies && |
|
344 | + isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems && |
|
345 | 345 | isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets; |
346 | 346 | } |
347 | 347 | |
348 | 348 | function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) { |
349 | 349 | try { |
350 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
350 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
351 | 351 | throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR); |
352 | 352 | } |
353 | 353 | |
354 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
354 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
355 | 355 | throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
356 | 356 | } |
357 | 357 | |
358 | 358 | // TODO: Replace quick-check with using gathered flying fleet data |
359 | - if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
359 | + if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
360 | 360 | throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR); |
361 | 361 | } |
362 | 362 | |
363 | - if(is_array($new_coordinates)) { |
|
363 | + if (is_array($new_coordinates)) { |
|
364 | 364 | $new_coordinates['planet_type'] = PT_PLANET; |
365 | 365 | $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id'); |
366 | - if($incoming['id']) { |
|
366 | + if ($incoming['id']) { |
|
367 | 367 | throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
368 | 368 | } |
369 | 369 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | 'result' => ERR_NONE, |
373 | 373 | 'message' => '', |
374 | 374 | ); |
375 | - } catch(exception $e) { |
|
375 | + } catch (exception $e) { |
|
376 | 376 | $response = array( |
377 | 377 | 'result' => $e->getCode(), |
378 | 378 | 'message' => $e->getMessage(), |
@@ -16,7 +16,7 @@ |
||
16 | 16 | $query = db_user_list("`authlevel` > 0 ORDER BY `authlevel` ASC"); |
17 | 17 | |
18 | 18 | // while($row = db_fetch($query)) |
19 | - foreach($query as $row) { |
|
19 | + foreach ($query as $row) { |
|
20 | 20 | $template_result['.']['contact'][] = array( |
21 | 21 | 'NAME' => $row['username'], |
22 | 22 | 'LEVEL' => classLocale::$lang['user_level'][$row['authlevel']], |
@@ -171,6 +171,10 @@ discard block |
||
171 | 171 | * @return bool |
172 | 172 | */ |
173 | 173 | // OK v4.5 |
174 | + |
|
175 | + /** |
|
176 | + * @param string $account_name_unsafe |
|
177 | + */ |
|
174 | 178 | public function db_get_by_name($account_name_unsafe) { |
175 | 179 | $this->reset(); |
176 | 180 | |
@@ -207,6 +211,11 @@ discard block |
||
207 | 211 | * |
208 | 212 | */ |
209 | 213 | // OK v4.5 |
214 | + |
|
215 | + /** |
|
216 | + * @param string $account_name_unsafe |
|
217 | + * @param string $email_unsafe |
|
218 | + */ |
|
210 | 219 | public function db_get_by_name_or_email($account_name_unsafe, $email_unsafe) { |
211 | 220 | $this->reset(); |
212 | 221 | |
@@ -223,6 +232,13 @@ discard block |
||
223 | 232 | * @throws Exception |
224 | 233 | */ |
225 | 234 | // OK v4.5 |
235 | + |
|
236 | + /** |
|
237 | + * @param string $account_name_unsafe |
|
238 | + * @param string $password_raw |
|
239 | + * @param string $email_unsafe |
|
240 | + * @param string $language_unsafe |
|
241 | + */ |
|
226 | 242 | public function db_create($account_name_unsafe, $password_raw, $email_unsafe, $language_unsafe = null, $salt_unsafe = null) { |
227 | 243 | $this->reset(); |
228 | 244 | |
@@ -317,6 +333,11 @@ discard block |
||
317 | 333 | * @return int|string |
318 | 334 | */ |
319 | 335 | // OK 4.8 |
336 | + |
|
337 | + /** |
|
338 | + * @param integer $change_type |
|
339 | + * @param double $metamatter |
|
340 | + */ |
|
320 | 341 | protected function db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe) { |
321 | 342 | $provider_id_safe = intval(core_auth::$main_provider->provider_id); |
322 | 343 | //$account_id_safe = $this->db->db_escape($this->account_id); |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $this->reset(); |
80 | 80 | $this->db = is_object($db) ? $db : classSupernova::$db; |
81 | 81 | |
82 | - foreach($this->table_check as $table_name) { |
|
83 | - if(empty($this->db->table_list[$table_name])) { |
|
82 | + foreach ($this->table_check as $table_name) { |
|
83 | + if (empty($this->db->table_list[$table_name])) { |
|
84 | 84 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
85 | 85 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
86 | 86 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | // OK v4.6 |
106 | 106 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
107 | - if(!$this->password_check($old_password_unsafe)) { |
|
107 | + if (!$this->password_check($old_password_unsafe)) { |
|
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // OK v4.5 |
126 | 126 | public function assign_from_db_row($row) { |
127 | 127 | $this->reset(); |
128 | - if(empty($row) || !is_array($row)) { |
|
128 | + if (empty($row) || !is_array($row)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | $this->account_id = $row['account_id']; |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | `account_email` = LOWER('{$email_safe}'), |
243 | 243 | `account_language` = '{$language_safe}'" |
244 | 244 | ); |
245 | - if(!$result) { |
|
245 | + if (!$result) { |
|
246 | 246 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
247 | 247 | } |
248 | 248 | |
249 | - if(!($account_id = $this->db->db_insert_id())) { |
|
249 | + if (!($account_id = $this->db->db_insert_id())) { |
|
250 | 250 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
251 | 251 | } |
252 | 252 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | WHERE `account_id` = '{$account_id_safe}'" |
277 | 277 | ) ? true : false; |
278 | 278 | |
279 | - if($result) { |
|
279 | + if ($result) { |
|
280 | 280 | $result = $this->db_get_by_id($this->account_id); |
281 | 281 | } |
282 | 282 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) { |
364 | 364 | global $mm_change_legit; |
365 | 365 | |
366 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
366 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
367 | 367 | classSupernova::$debug->error('Ошибка при попытке манипуляции с ММ'); |
368 | 368 | |
369 | 369 | return false; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | $mm_change_legit = true; |
375 | 375 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
376 | - if($already_changed) { |
|
376 | + if ($already_changed) { |
|
377 | 377 | $metamatter_total_delta = 0; |
378 | 378 | $result = -1; |
379 | 379 | } else { |
@@ -383,17 +383,17 @@ discard block |
||
383 | 383 | $result = $this->db->doquery( |
384 | 384 | "UPDATE {{account}} |
385 | 385 | SET |
386 | - `account_metamatter` = `account_metamatter` + '{$metamatter}'" . |
|
387 | - ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') . |
|
386 | + `account_metamatter` = `account_metamatter` + '{$metamatter}'". |
|
387 | + ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : ''). |
|
388 | 388 | " WHERE `account_id` = {$account_id_safe}" |
389 | 389 | ); |
390 | - if(!$result) { |
|
390 | + if (!$result) { |
|
391 | 391 | classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
392 | 392 | } |
393 | 393 | $result = classSupernova::$db->db_affected_rows(); |
394 | 394 | } |
395 | 395 | |
396 | - if(empty(core_auth::$user['id'])) { |
|
396 | + if (empty(core_auth::$user['id'])) { |
|
397 | 397 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
398 | 398 | reset($user_list); |
399 | 399 | $user_id_unsafe = key($user_list); |
@@ -402,30 +402,30 @@ discard block |
||
402 | 402 | } |
403 | 403 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
404 | 404 | |
405 | - if(!$result) { |
|
405 | + if (!$result) { |
|
406 | 406 | classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
407 | 407 | } |
408 | 408 | |
409 | - if(!$already_changed) { |
|
409 | + if (!$already_changed) { |
|
410 | 410 | $this->account_metamatter += $metamatter; |
411 | 411 | $this->account_metamatter_total += $metamatter_total_delta; |
412 | 412 | } |
413 | 413 | |
414 | - if(is_array($comment)) { |
|
414 | + if (is_array($comment)) { |
|
415 | 415 | $comment = call_user_func_array('sprintf', $comment); |
416 | 416 | } |
417 | 417 | |
418 | 418 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
419 | 419 | |
420 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
420 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
421 | 421 | $old_referral = db_referral_get_by_id($user_id_safe); |
422 | - if($old_referral['id']) { |
|
422 | + if ($old_referral['id']) { |
|
423 | 423 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
424 | 424 | db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter); |
425 | 425 | $new_referral = db_referral_get_by_id($user_id_safe); |
426 | 426 | |
427 | 427 | $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0); |
428 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
428 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
429 | 429 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
430 | 430 | } |
431 | 431 | } |
@@ -188,6 +188,11 @@ discard block |
||
188 | 188 | */ |
189 | 189 | // OK v4 |
190 | 190 | // TODO - вынести в отдельный класс |
191 | +/** |
|
192 | + * @param string $db_id_field_name |
|
193 | + * @param string $db_table_name |
|
194 | + * @param string $db_value_field_name |
|
195 | + */ |
|
191 | 196 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
192 | 197 | $current_value_safe = db_escape($current_value_unsafe); |
193 | 198 | $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); |
@@ -220,7 +225,7 @@ discard block |
||
220 | 225 | |
221 | 226 | /** |
222 | 227 | * @param $user |
223 | - * @param $username_safe |
|
228 | + * @param string $username_safe |
|
224 | 229 | */ |
225 | 230 | function db_player_name_history_replace($user, $username_safe) { |
226 | 231 | doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user['id']}, `player_name` = '{$username_safe}'"); |
@@ -228,7 +233,7 @@ discard block |
||
228 | 233 | |
229 | 234 | |
230 | 235 | /** |
231 | - * @param $username_safe |
|
236 | + * @param string $username_safe |
|
232 | 237 | * |
233 | 238 | * @return array|bool|mysqli_result|null |
234 | 239 | */ |
@@ -485,12 +490,12 @@ discard block |
||
485 | 490 | |
486 | 491 | |
487 | 492 | /** |
488 | - * @param $user_id |
|
489 | - * @param $change_type |
|
493 | + * @param integer $user_id |
|
494 | + * @param integer $change_type |
|
490 | 495 | * @param $dark_matter |
491 | - * @param $comment |
|
496 | + * @param string $comment |
|
492 | 497 | * @param $row |
493 | - * @param $page_url |
|
498 | + * @param string $page_url |
|
494 | 499 | */ |
495 | 500 | function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment, $row, $page_url) { |
496 | 501 | doquery( |
@@ -506,7 +511,7 @@ discard block |
||
506 | 511 | /** |
507 | 512 | * @param $user_id_safe |
508 | 513 | * |
509 | - * @return array|bool|mysqli_result|null |
|
514 | + * @return integer |
|
510 | 515 | */ |
511 | 516 | function db_referral_get_by_id($user_id_safe) { |
512 | 517 | $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", true); |
@@ -534,9 +539,9 @@ discard block |
||
534 | 539 | |
535 | 540 | // Quests *********************************************************************************************************** |
536 | 541 | /** |
537 | - * @param $query_add_select |
|
542 | + * @param string $query_add_select |
|
538 | 543 | * @param $query_add_from |
539 | - * @param $query_add_where |
|
544 | + * @param string $query_add_where |
|
540 | 545 | * |
541 | 546 | * @return array|bool|mysqli_result|null |
542 | 547 | */ |
@@ -580,11 +585,11 @@ discard block |
||
580 | 585 | } |
581 | 586 | |
582 | 587 | /** |
583 | - * @param $quest_name |
|
584 | - * @param $quest_type |
|
585 | - * @param $quest_description |
|
588 | + * @param string $quest_name |
|
589 | + * @param integer $quest_type |
|
590 | + * @param string $quest_description |
|
586 | 591 | * @param $quest_conditions |
587 | - * @param $quest_rewards |
|
592 | + * @param string $quest_rewards |
|
588 | 593 | * @param $quest_id |
589 | 594 | */ |
590 | 595 | function db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id) { |
@@ -607,7 +612,7 @@ discard block |
||
607 | 612 | /** |
608 | 613 | * @param $banner |
609 | 614 | * @param $banned |
610 | - * @param $reason |
|
615 | + * @param string $reason |
|
611 | 616 | * @param $ban_until |
612 | 617 | */ |
613 | 618 | function db_ban_insert($banner, $banned, $reason, $ban_until) { |
@@ -630,7 +635,7 @@ discard block |
||
630 | 635 | /** |
631 | 636 | * @param $banner |
632 | 637 | * @param $banned |
633 | - * @param $reason |
|
638 | + * @param string $reason |
|
634 | 639 | */ |
635 | 640 | function db_ban_insert_unset($banner, $banned, $reason) { |
636 | 641 | doquery( |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | |
18 | 18 | function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
19 | 19 | return doquery( |
20 | - "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
|
20 | + "SELECT p.*, u.username".($table_parent_columns ? ', p1.name AS parent_name' : ''). |
|
21 | 21 | " FROM {{planets}} AS p |
22 | 22 | LEFT JOIN {{users}} AS u ON u.id = p.id_owner" . |
23 | - ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : '') . |
|
24 | - " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
23 | + ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : ''). |
|
24 | + " WHERE ".($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | function db_planet_list_search($searchtext) { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ORDER BY |
122 | 122 | sp.`{$Rank}_rank`, subject.{$source['id']} |
123 | 123 | LIMIT |
124 | - " . $start . ",100;"; |
|
124 | + ".$start.",100;"; |
|
125 | 125 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
126 | 126 | $query_str = |
127 | 127 | "SELECT |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ORDER BY |
135 | 135 | subject.{$Rank} DESC, subject.{$source['id']} |
136 | 136 | LIMIT |
137 | - " . $start . ",100;"; |
|
137 | + ".$start.",100;"; |
|
138 | 138 | } |
139 | 139 | } else { |
140 | 140 | // TODO |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ORDER BY |
152 | 152 | sp.`{$Rank}_rank`, subject.id |
153 | 153 | LIMIT |
154 | - " . $start . ",100;"; |
|
154 | + ".$start.",100;"; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return doquery($query_str); |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | */ |
375 | 375 | function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) { |
376 | 376 | $extra_conditions = |
377 | - ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') . |
|
378 | - ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') . |
|
379 | - ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') . |
|
377 | + ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : ''). |
|
378 | + ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : ''). |
|
379 | + ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : ''). |
|
380 | 380 | ($flt_module ? "AND payment_module_name = '{$flt_module}' " : ''); |
381 | 381 | $query = doquery("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;"); |
382 | 382 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | |
405 | 405 | // Log Online ************************************************************************************************************* |
406 | 406 | function db_log_online_insert() { |
407 | - doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . classSupernova::$config->var_online_user_count); |
|
407 | + doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = ".classSupernova::$config->var_online_user_count); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | // Log ************************************************************************************************************* |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | `ban_user_id` = '{$banned['id']}', |
613 | 613 | `ban_user_name` = '{$banned['username']}', |
614 | 614 | `ban_reason` = '{$reason}', |
615 | - `ban_time` = " . SN_TIME_NOW . ", |
|
615 | + `ban_time` = ".SN_TIME_NOW.", |
|
616 | 616 | `ban_until` = {$ban_until}, |
617 | 617 | `ban_issuer_id` = '{$banner['id']}', |
618 | 618 | `ban_issuer_name` = '{$banner['username']}', |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | `ban_user_name` = '{$banned['username']}', |
635 | 635 | `ban_reason` = '{$reason}', |
636 | 636 | `ban_time` = 0, |
637 | - `ban_until` = " . SN_TIME_NOW . ", |
|
637 | + `ban_until` = ".SN_TIME_NOW.", |
|
638 | 638 | `ban_issuer_id` = '{$banner['id']}', |
639 | 639 | `ban_issuer_name` = '{$banner['username']}', |
640 | 640 | `ban_issuer_email` = '{$banner['email']}' |
@@ -693,9 +693,9 @@ discard block |
||
693 | 693 | function db_ube_report_get_best_battles() { |
694 | 694 | $query = doquery("SELECT * |
695 | 695 | FROM {{ube_report}} |
696 | - WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY)) |
|
696 | + WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY)) |
|
697 | 697 | ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC |
698 | - LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";"); |
|
698 | + LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";"); |
|
699 | 699 | |
700 | 700 | return $query; |
701 | 701 | } |
@@ -756,9 +756,11 @@ |
||
756 | 756 | !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
757 | 757 | } |
758 | 758 | |
759 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
759 | + if(isset($update_tables['counter']['page'])) { |
|
760 | + // TODO REMOVE |
|
760 | 761 | { |
761 | 762 | update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}"); |
763 | + } |
|
762 | 764 | update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}"); |
763 | 765 | } |
764 | 766 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | [!] DB code updates |
22 | 22 | */ |
23 | 23 | |
24 | -if(!defined('INIT')) { |
|
24 | +if (!defined('INIT')) { |
|
25 | 25 | // include_once('init.php'); |
26 | 26 | die('Unauthorized access'); |
27 | 27 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | classSupernova::$config->debug = 0; |
40 | 40 | |
41 | 41 | |
42 | -if(classSupernova::$config->db_version == DB_VERSION) { |
|
43 | -} elseif(classSupernova::$config->db_version > DB_VERSION) { |
|
42 | +if (classSupernova::$config->db_version == DB_VERSION) { |
|
43 | +} elseif (classSupernova::$config->db_version > DB_VERSION) { |
|
44 | 44 | classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW); |
45 | 45 | die( |
46 | 46 | 'Internal error! Auotupdater detects DB version greater then can be handled!<br /> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | -if(classSupernova::$config->db_version < 26) { |
|
52 | +if (classSupernova::$config->db_version < 26) { |
|
53 | 53 | $sys_log_disabled = true; |
54 | 54 | } |
55 | 55 | |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | $update_tables = array(); |
69 | 69 | $update_indexes = array(); |
70 | 70 | $query = upd_do_query('SHOW TABLES;', true); |
71 | -while($row = db_fetch_row($query)) { |
|
71 | +while ($row = db_fetch_row($query)) { |
|
72 | 72 | upd_load_table_info($row[0]); |
73 | 73 | } |
74 | 74 | upd_log_message('Table info loaded. Now looking DB for upgrades...'); |
75 | 75 | |
76 | 76 | upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true); |
77 | 77 | |
78 | -if($new_version < 37) { |
|
78 | +if ($new_version < 37) { |
|
79 | 79 | require_once('update_old.php'); |
80 | 80 | } |
81 | 81 | |
82 | 82 | ini_set('memory_limit', '1024M'); |
83 | 83 | |
84 | -switch($new_version) { |
|
84 | +switch ($new_version) { |
|
85 | 85 | case 37: |
86 | 86 | upd_log_version_update(); |
87 | 87 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_); |
98 | 98 | |
99 | - if(!$update_tables['log_metamatter']) { |
|
99 | + if (!$update_tables['log_metamatter']) { |
|
100 | 100 | upd_create_table('log_metamatter', |
101 | 101 | "( |
102 | 102 | `id` SERIAL, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
122 | 122 | ), !$update_tables['payment']['payment_test']); |
123 | 123 | |
124 | - if($update_tables['payment']['payment_test']['Default'] == 1) { |
|
124 | + if ($update_tables['payment']['payment_test']['Default'] == 1) { |
|
125 | 125 | upd_alter_table('payment', array( |
126 | 126 | "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
127 | 127 | )); |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | "MODIFY COLUMN `metamatter` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Metamatter amount'", |
138 | 138 | ), $update_tables['users']['metamatter']['Type'] == 'int(20)'); |
139 | 139 | |
140 | - $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE"); |
|
141 | - while($row = db_fetch($query)) { |
|
140 | + $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = ".QUE_RESEARCH." AND que_unit_id IN (".TECH_EXPEDITION.",".TECH_COLONIZATION.") FOR UPDATE"); |
|
141 | + while ($row = db_fetch($query)) { |
|
142 | 142 | $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']); |
143 | 143 | upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE"); |
144 | 144 | $price = sys_unit_str2arr($row['que_unit_price']); |
145 | - upd_do_query("UPDATE {{planets}} SET " . |
|
146 | - "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," . |
|
147 | - "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," . |
|
148 | - "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) . |
|
145 | + upd_do_query("UPDATE {{planets}} SET ". |
|
146 | + "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",". |
|
147 | + "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",". |
|
148 | + "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0). |
|
149 | 149 | " WHERE id = {$planet_id}" |
150 | 150 | ); |
151 | 151 | upd_do_query("DELETE FROM {{que}} WHERE que_id = {$row['que_id']}"); |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | $query = upd_do_query("SELECT unit_id, unit_snid, unit_level, id_planet FROM {{unit}} AS un |
155 | 155 | LEFT JOIN {{users}} AS u ON u.id = un.unit_player_id |
156 | 156 | LEFT JOIN {{planets}} AS p ON p.id = u.id_planet |
157 | - WHERE unit_snid IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") |
|
157 | + WHERE unit_snid IN (" . TECH_EXPEDITION.",".TECH_COLONIZATION.") |
|
158 | 158 | FOR UPDATE"); |
159 | - while($row = db_fetch($query)) { |
|
160 | - if(!$row['id_planet']) { |
|
159 | + while ($row = db_fetch($query)) { |
|
160 | + if (!$row['id_planet']) { |
|
161 | 161 | continue; |
162 | 162 | } |
163 | 163 | |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | $unit_level = $row['unit_level']; |
166 | 166 | $price = get_unit_param($unit_id, P_COST); |
167 | 167 | $factor = $price['factor']; |
168 | - foreach($price as $resource_id => &$resource_amount) { |
|
168 | + foreach ($price as $resource_id => &$resource_amount) { |
|
169 | 169 | $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1); |
170 | 170 | } |
171 | 171 | // upd_do_query |
172 | - upd_do_query($q = "UPDATE {{planets}} SET " . |
|
173 | - "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," . |
|
174 | - "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," . |
|
175 | - "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) . |
|
172 | + upd_do_query($q = "UPDATE {{planets}} SET ". |
|
173 | + "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",". |
|
174 | + "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",". |
|
175 | + "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0). |
|
176 | 176 | " WHERE id = {$row['id_planet']}" |
177 | 177 | ); |
178 | 178 | upd_do_query("DELETE FROM {{unit}} WHERE unit_id = {$row['unit_id']}"); |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | // Вернуть ресы за уже исследованную Экспедиционную технологию |
185 | 185 | upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0); |
186 | 186 | |
187 | - if(!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
187 | + if (!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
188 | 188 | upd_alter_table('users', array( |
189 | 189 | "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
190 | 190 | "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
191 | 191 | ), !isset($update_tables['users']['player_rpg_explore_xp'])); |
192 | 192 | } |
193 | 193 | |
194 | - if(!$update_tables['log_users_online']) { |
|
194 | + if (!$update_tables['log_users_online']) { |
|
195 | 195 | upd_create_table('log_users_online', "( |
196 | 196 | `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time', |
197 | 197 | `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online', |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`", |
207 | 207 | ), !$update_tables['users']['user_time_measured']); |
208 | 208 | |
209 | - if($update_tables['rw']) { |
|
209 | + if ($update_tables['rw']) { |
|
210 | 210 | upd_do_query("DROP TABLE IF EXISTS {{rw}};"); |
211 | 211 | } |
212 | 212 | |
213 | - if(!$update_tables['player_award']) { |
|
213 | + if (!$update_tables['player_award']) { |
|
214 | 214 | upd_create_table('player_award', "( |
215 | 215 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
216 | 216 | `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc', |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | upd_log_version_update(); |
253 | 253 | |
254 | 254 | |
255 | - if(!isset($update_tables['planets']['que_processed'])) { |
|
255 | + if (!isset($update_tables['planets']['que_processed'])) { |
|
256 | 256 | upd_alter_table('planets', array( |
257 | 257 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`", |
258 | 258 | ), true); |
259 | 259 | upd_do_query("UPDATE {{planets}} SET que_processed = last_update;"); |
260 | 260 | } |
261 | 261 | |
262 | - if(!isset($update_tables['users']['que_processed'])) { |
|
262 | + if (!isset($update_tables['users']['que_processed'])) { |
|
263 | 263 | upd_alter_table('users', array( |
264 | 264 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`", |
265 | 265 | ), true); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | |
270 | - if(isset($update_tables['planets']['que'])) { |
|
270 | + if (isset($update_tables['planets']['que'])) { |
|
271 | 271 | $sn_data_aux = array( |
272 | 272 | SHIP_SMALL_FIGHTER_WRATH => array( |
273 | 273 | 'name' => 'ship_fighter_wrath', |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | $unit_data = array(); |
353 | 353 | $planets = array(); |
354 | 354 | |
355 | - foreach($planet_unit_list as $unit_id) { |
|
356 | - if(!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
355 | + foreach ($planet_unit_list as $unit_id) { |
|
356 | + if (!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
357 | 357 | $unit_name = $sn_data_aux[$unit_id][P_NAME]; |
358 | 358 | } |
359 | - if(isset($update_tables['planets'][$unit_name])) { |
|
359 | + if (isset($update_tables['planets'][$unit_name])) { |
|
360 | 360 | $drop[] = "DROP COLUMN `{$unit_name}`"; |
361 | 361 | |
362 | - if(isset($aux_group[$unit_id])) { |
|
362 | + if (isset($aux_group[$unit_id])) { |
|
363 | 363 | $units_info[$unit_id] = $sn_data_aux[$unit_id]; |
364 | 364 | $units_info[$unit_id]['que'] = QUE_HANGAR; |
365 | 365 | } else { |
366 | 366 | $units_info[$unit_id] = get_unit_param($unit_id); |
367 | - foreach($ques_info as $que_id => $que_data1) { |
|
368 | - if(in_array($unit_id, $que_data1['unit_list'])) { |
|
367 | + foreach ($ques_info as $que_id => $que_data1) { |
|
368 | + if (in_array($unit_id, $que_data1['unit_list'])) { |
|
369 | 369 | $units_info[$unit_id]['que'] = $que_id; |
370 | 370 | break; |
371 | 371 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE"); |
378 | - while($row = db_fetch($query)) { |
|
378 | + while ($row = db_fetch($query)) { |
|
379 | 379 | $user_id = $row['id_owner']; |
380 | 380 | $planet_id = $row['id']; |
381 | 381 | |
@@ -383,25 +383,25 @@ discard block |
||
383 | 383 | |
384 | 384 | // Конвертируем юниты |
385 | 385 | $units_levels = array(); |
386 | - foreach($planet_unit_list as $unit_id) { |
|
386 | + foreach ($planet_unit_list as $unit_id) { |
|
387 | 387 | $unit_name = &$units_info[$unit_id][P_NAME]; |
388 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
388 | + if (!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
389 | 389 | continue; |
390 | 390 | } |
391 | 391 | $units_levels[$unit_id] = $row[$unit_name]; |
392 | - $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
|
393 | - if(count($unit_data) > 30) { |
|
392 | + $unit_data[] = "({$user_id},".LOC_PLANET.",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
|
393 | + if (count($unit_data) > 30) { |
|
394 | 394 | $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max; |
395 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
395 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES '.implode(',', $unit_data).';'); |
|
396 | 396 | $unit_data = array(); |
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
400 | 400 | // Конвертируем очередь построек |
401 | - if($row['que']) { |
|
401 | + if ($row['que']) { |
|
402 | 402 | $que = explode(';', $row['que']); |
403 | - foreach($que as $que_item) { |
|
404 | - if(!$que_item) { |
|
403 | + foreach ($que as $que_item) { |
|
404 | + if (!$que_item) { |
|
405 | 405 | continue; |
406 | 406 | } |
407 | 407 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1; |
417 | 417 | $price_increase = pow($unit_factor, $unit_level); |
418 | 418 | // $unit_time = 0; |
419 | - foreach($unit_cost as $resource_id => &$resource_amount) { |
|
420 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
419 | + foreach ($unit_cost as $resource_id => &$resource_amount) { |
|
420 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
421 | 421 | unset($unit_cost[$resource_id]); |
422 | 422 | continue; |
423 | 423 | } |
@@ -431,39 +431,39 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | // Конвертируем очередь верфи |
434 | - if($row['b_hangar_id']) { |
|
434 | + if ($row['b_hangar_id']) { |
|
435 | 435 | $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,); |
436 | 436 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
437 | - foreach($hangar_units as $unit_id => $unit_count) { |
|
438 | - if($unit_count <= 0) { |
|
437 | + foreach ($hangar_units as $unit_id => $unit_count) { |
|
438 | + if ($unit_count <= 0) { |
|
439 | 439 | continue; |
440 | 440 | } |
441 | - foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
442 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
441 | + foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
442 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
443 | 443 | continue; |
444 | 444 | } |
445 | 445 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
446 | 446 | } |
447 | 447 | } |
448 | - if(array_sum($return_resources) > 0) { |
|
448 | + if (array_sum($return_resources) > 0) { |
|
449 | 449 | upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1"); |
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
453 | 453 | |
454 | - if(count($que_data) > 10) { |
|
454 | + if (count($que_data) > 10) { |
|
455 | 455 | $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max; |
456 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
456 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES '.implode(',', $que_data).';'); |
|
457 | 457 | $que_data = array(); |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | - if(!empty($unit_data)) { |
|
462 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
461 | + if (!empty($unit_data)) { |
|
462 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES '.implode(',', $unit_data).';'); |
|
463 | 463 | } |
464 | 464 | |
465 | - if(!empty($que_data)) { |
|
466 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
465 | + if (!empty($que_data)) { |
|
466 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES '.implode(',', $que_data).';'); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | upd_alter_table('planets', $drop, true); |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = '' |
474 | 474 | SET u.`username` = CONCAT('[', a.`ally_tag`, ']');"); |
475 | 475 | |
476 | - if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
476 | + if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
477 | 477 | upd_do_query("SET FOREIGN_KEY_CHECKS=0;"); |
478 | 478 | upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']); |
479 | 479 | upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{security_browser}}` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE", |
570 | 570 | ), !isset($update_tables['users']['user_last_proxy'])); |
571 | 571 | |
572 | - if(!isset($update_tables['notes']['planet_type'])) { |
|
572 | + if (!isset($update_tables['notes']['planet_type'])) { |
|
573 | 573 | upd_alter_table('notes', array( |
574 | 574 | "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`", |
575 | 575 | "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`", |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot'])); |
588 | 588 | upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']); |
589 | 589 | |
590 | - if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
590 | + if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
591 | 591 | upd_alter_table('users', array( |
592 | 592 | "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'", |
593 | 593 | ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint'); |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;"); |
596 | 596 | } |
597 | 597 | |
598 | - if(!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
598 | + if (!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
599 | 599 | upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated'])); |
600 | 600 | upd_alter_table('log_users_online', array( |
601 | 601 | "DROP PRIMARY KEY", |
@@ -603,13 +603,13 @@ discard block |
||
603 | 603 | ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,'); |
604 | 604 | } |
605 | 605 | |
606 | - if(!isset($update_tables['users']['gender'])) { |
|
607 | - upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
|
608 | - upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
606 | + if (!isset($update_tables['users']['gender'])) { |
|
607 | + upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT ".GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
|
608 | + upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', ".GENDER_FEMALE.", IF(UPPER(`sex`) = 'M', ".GENDER_MALE.", ".GENDER_UNKNOWN."));"); |
|
609 | 609 | } |
610 | 610 | upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex'])); |
611 | 611 | |
612 | - if(!$update_tables['users']['dark_matter_total']) { |
|
612 | + if (!$update_tables['users']['dark_matter_total']) { |
|
613 | 613 | upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']); |
614 | 614 | upd_do_query( |
615 | 615 | "UPDATE `{{users}}` AS u |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | } |
623 | 623 | |
624 | 624 | upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal)); |
625 | - if(!$update_tables['users']['metamatter_total']) { |
|
625 | + if (!$update_tables['users']['metamatter_total']) { |
|
626 | 626 | upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']); |
627 | 627 | |
628 | 628 | upd_do_query( |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0) |
635 | 635 | );"); |
636 | 636 | } |
637 | - if(!isset($update_tables['users']['immortal'])) { |
|
637 | + if (!isset($update_tables['users']['immortal'])) { |
|
638 | 638 | upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal'])); |
639 | 639 | upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;"); |
640 | 640 | } |
641 | - if(isset($update_tables['player_award'])) { |
|
641 | + if (isset($update_tables['player_award'])) { |
|
642 | 642 | upd_do_query( |
643 | 643 | "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id |
644 | 644 | SET metamatter_total = 1, immortal = NOW() |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
666 | 666 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); |
667 | 667 | |
668 | - if(empty($update_tables['blitz_statpoints'])) { |
|
668 | + if (empty($update_tables['blitz_statpoints'])) { |
|
669 | 669 | upd_create_table('blitz_statpoints', " ( |
670 | 670 | `stat_date` int(11) NOT NULL DEFAULT '0', |
671 | 671 | `id_owner` bigint(20) unsigned DEFAULT NULL, |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE |
734 | 734 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
735 | 735 | |
736 | - if(empty($update_tables['security_url'])) { |
|
736 | + if (empty($update_tables['security_url'])) { |
|
737 | 737 | upd_create_table('security_url', " ( |
738 | 738 | `url_id` int unsigned NOT NULL AUTO_INCREMENT, |
739 | 739 | `url_string` VARCHAR(250) NOT NULL DEFAULT '', |
@@ -746,17 +746,17 @@ discard block |
||
746 | 746 | |
747 | 747 | $strings = array(); |
748 | 748 | $query = doquery($query); |
749 | - while($row = db_fetch($query)) { |
|
750 | - $strings[] = '("' . db_escape($row['url']) . '")'; |
|
751 | - if(count($strings) > 100) { |
|
752 | - doquery($query_string . implode(',', $strings)); |
|
749 | + while ($row = db_fetch($query)) { |
|
750 | + $strings[] = '("'.db_escape($row['url']).'")'; |
|
751 | + if (count($strings) > 100) { |
|
752 | + doquery($query_string.implode(',', $strings)); |
|
753 | 753 | $strings = array(); |
754 | 754 | } |
755 | 755 | } |
756 | - !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
|
756 | + !empty($strings) ? doquery($query_string.implode(',', $strings)) : false; |
|
757 | 757 | } |
758 | 758 | |
759 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
759 | + if (isset($update_tables['counter']['page'])) // TODO REMOVE |
|
760 | 760 | { |
761 | 761 | update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}"); |
762 | 762 | update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}"); |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
782 | 782 | "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
783 | 783 | ), !isset($update_tables['counter']['device_id'])); |
784 | - if(isset($update_tables['counter']['ip'])) { |
|
784 | + if (isset($update_tables['counter']['ip'])) { |
|
785 | 785 | // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)'); |
786 | 786 | upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)'); |
787 | 787 | upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id'); |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | |
833 | 833 | upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days); |
834 | 834 | |
835 | - if(classSupernova::$config->payment_currency_default != 'USD') { |
|
835 | + if (classSupernova::$config->payment_currency_default != 'USD') { |
|
836 | 836 | upd_check_key('payment_currency_default', 'USD', true); |
837 | 837 | upd_check_key('payment_currency_exchange_dm_', 20000, true); |
838 | 838 | upd_check_key('payment_currency_exchange_mm_', 20000, true); |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | |
890 | 890 | $virtual_exploded = explode('/', SN_ROOT_VIRTUAL_PARENT); |
891 | 891 | // TODO - переделать всё на db_loadItem... НАВЕРНОЕ |
892 | - upd_check_key('server_email', 'root@' . $virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email')); |
|
892 | + upd_check_key('server_email', 'root@'.$virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email')); |
|
893 | 893 | |
894 | 894 | upd_alter_table('survey_votes', array( |
895 | 895 | "DROP FOREIGN KEY `FK_survey_votes_user`", |
@@ -915,12 +915,12 @@ discard block |
||
915 | 915 | function propagade_player_options($old_option_name, $new_option_id) { |
916 | 916 | global $update_tables; |
917 | 917 | |
918 | - if(!empty($update_tables['users'][$old_option_name])) { |
|
918 | + if (!empty($update_tables['users'][$old_option_name])) { |
|
919 | 919 | upd_do_query( |
920 | 920 | "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) |
921 | 921 | SELECT `id`, {$new_option_id}, `{$old_option_name}` |
922 | 922 | FROM {{users}} |
923 | - WHERE `user_as_ally` is null and `user_bot` = " . USER_BOT_PLAYER); |
|
923 | + WHERE `user_as_ally` is null and `user_bot` = ".USER_BOT_PLAYER); |
|
924 | 924 | // TODO - UNCOMMENT !!! |
925 | 925 | upd_alter_table('users', array("DROP COLUMN `{$old_option_name}`",)); |
926 | 926 | } |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | |
950 | 950 | |
951 | 951 | // 2015-08-03 15:05:26 40a6.0 |
952 | - if(empty($update_tables['planets']['position_original'])) { |
|
952 | + if (empty($update_tables['planets']['position_original'])) { |
|
953 | 953 | upd_alter_table('planets', array( |
954 | 954 | "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0", |
955 | 955 | "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0", |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | upd_do_query('UPDATE {{planets}} SET `position_original` = `planet`, `field_max_original` = `field_max`, `temp_min_original` = `temp_min`, `temp_max_original` = `temp_max`;'); |
965 | 965 | |
966 | 966 | // Миграция тяжмета в оливин |
967 | - upd_do_query('UPDATE {{planets}} SET `density_index` = ' . PLANET_DENSITY_METAL_PERIDOT . ' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7); |
|
967 | + upd_do_query('UPDATE {{planets}} SET `density_index` = '.PLANET_DENSITY_METAL_PERIDOT.' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7); |
|
968 | 968 | |
969 | 969 | // Добавляем планету-странника |
970 | 970 | upd_check_key('game_maxPlanet', 16, Vector::$knownPlanets == 15); |
@@ -977,12 +977,12 @@ discard block |
||
977 | 977 | |
978 | 978 | // 2015-08-27 19:14:05 40a10.0 |
979 | 979 | // Старая версия таблицы |
980 | - if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
980 | + if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
981 | 981 | upd_drop_table('account'); |
982 | 982 | upd_drop_table('account_translate'); |
983 | 983 | } |
984 | 984 | |
985 | - if(empty($update_tables['account'])) { |
|
985 | + if (empty($update_tables['account'])) { |
|
986 | 986 | upd_create_table('account', " ( |
987 | 987 | `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
988 | 988 | `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
1002 | 1002 | |
1003 | 1003 | upd_create_table('account_translate', " ( |
1004 | - `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider', |
|
1004 | + `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider', |
|
1005 | 1005 | `provider_account_id` bigint(20) unsigned NOT NULL COMMENT 'Account ID on provider', |
1006 | 1006 | `user_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
1007 | 1007 | `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, |
@@ -1016,12 +1016,12 @@ discard block |
||
1016 | 1016 | (`account_id`, `account_name`, `account_password`, `account_salt`, `account_email`, `account_register_time`, `account_language`, `account_metamatter`, `account_metamatter_total`, `account_immortal`) |
1017 | 1017 | SELECT |
1018 | 1018 | `id`, `username`, `password`, `salt`, `email_2`, FROM_UNIXTIME(register_time), `lang`, `metamatter`, `metamatter_total`, `immortal` |
1019 | - FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER . ";" |
|
1019 | + FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER.";" |
|
1020 | 1020 | ); |
1021 | 1021 | |
1022 | 1022 | upd_do_query( |
1023 | 1023 | "REPLACE INTO {{account_translate}} (`provider_id`, `provider_account_id`, `user_id`, `timestamp`) |
1024 | - SELECT " . ACCOUNT_PROVIDER_LOCAL . ", a.account_id, u.id, a.`account_register_time` |
|
1024 | + SELECT " . ACCOUNT_PROVIDER_LOCAL.", a.account_id, u.id, a.`account_register_time` |
|
1025 | 1025 | FROM {{users}} AS u |
1026 | 1026 | JOIN {{account}} AS a ON |
1027 | 1027 | a.account_name = u.username |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | |
1038 | 1038 | // 2015-09-05 17:07:15 40a10.17 |
1039 | - upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT " . UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result'])); |
|
1039 | + upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT ".UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result'])); |
|
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | // 2015-09-07 21:11:48 40a10.19 |
@@ -1044,18 +1044,18 @@ discard block |
||
1044 | 1044 | |
1045 | 1045 | |
1046 | 1046 | // 2015-09-24 11:39:37 40a10.25 |
1047 | - if(empty($update_tables['log_metamatter']['provider_id'])) { |
|
1047 | + if (empty($update_tables['log_metamatter']['provider_id'])) { |
|
1048 | 1048 | upd_alter_table('log_metamatter', array( |
1049 | - "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'", |
|
1049 | + "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider'", |
|
1050 | 1050 | "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0", |
1051 | 1051 | "ADD COLUMN `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''", |
1052 | - "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '" . SN_ROOT_VIRTUAL . "'", |
|
1052 | + "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '".SN_ROOT_VIRTUAL."'", |
|
1053 | 1053 | ), empty($update_tables['log_metamatter']['provider_id'])); |
1054 | 1054 | |
1055 | 1055 | upd_do_query("UPDATE {{log_metamatter}} SET `account_id` = `user_id`, `account_name` = `username`"); |
1056 | 1056 | |
1057 | 1057 | upd_alter_table('payment', array( |
1058 | - "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Payment account provider'", |
|
1058 | + "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Payment account provider'", |
|
1059 | 1059 | "ADD COLUMN `payment_account_id` bigint(20) unsigned NOT NULL", |
1060 | 1060 | "ADD COLUMN `payment_account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''", |
1061 | 1061 | ), !$update_tables['payment']['payment_account_id']); |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code)); |
1097 | 1097 | upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp)); |
1098 | 1098 | upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used)); |
1099 | - if(empty($update_tables['log_halloween_2015'])) { |
|
1099 | + if (empty($update_tables['log_halloween_2015'])) { |
|
1100 | 1100 | upd_create_table('log_halloween_2015', " ( |
1101 | 1101 | `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1102 | 1102 | `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | |
1113 | 1113 | // 2015-11-28 06:30:27 40a19.21 |
1114 | - if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1114 | + if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1115 | 1115 | upd_alter_table('ube_report', array( |
1116 | 1116 | "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", |
1117 | 1117 | "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | |
1128 | 1128 | // 2015-12-06 15:10:58 40b1.0 |
1129 | - if(!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1129 | + if (!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1130 | 1130 | upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']); |
1131 | 1131 | upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']); |
1132 | 1132 | upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']); |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | case 40: |
1190 | 1190 | upd_log_version_update(); |
1191 | 1191 | |
1192 | - if(empty($update_tables['festival'])) { |
|
1192 | + if (empty($update_tables['festival'])) { |
|
1193 | 1193 | upd_create_table('festival', " ( |
1194 | 1194 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
1195 | 1195 | `start` datetime NOT NULL COMMENT 'Festival start datetime', |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | ); |
1231 | 1231 | } |
1232 | 1232 | |
1233 | - if(empty($update_tables['festival_unit'])) { |
|
1233 | + if (empty($update_tables['festival_unit'])) { |
|
1234 | 1234 | upd_create_table('festival_unit', " ( |
1235 | 1235 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1236 | 1236 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | // 2015-12-21 06:06:09 41a0.12 |
1250 | - if(empty($update_tables['festival_unit_log'])) { |
|
1250 | + if (empty($update_tables['festival_unit_log'])) { |
|
1251 | 1251 | upd_create_table('festival_unit_log', " ( |
1252 | 1252 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1253 | 1253 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1277,19 +1277,19 @@ discard block |
||
1277 | 1277 | $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin' |
1278 | 1278 | ); |
1279 | 1279 | |
1280 | - if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1280 | + if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1281 | 1281 | upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true); |
1282 | 1282 | upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true); |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - if(!empty($update_tables['fleets']['fleet_array'])) { |
|
1285 | + if (!empty($update_tables['fleets']['fleet_array'])) { |
|
1286 | 1286 | $query = upd_do_query("SELECT * FROM {{fleets}}"); |
1287 | - while($row = db_fetch($query)) { |
|
1287 | + while ($row = db_fetch($query)) { |
|
1288 | 1288 | $unit_list = sys_unit_str2arr($row['fleet_array']); |
1289 | - foreach($unit_list as $unit_id => $unit_count) { |
|
1289 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
1290 | 1290 | upd_do_query( |
1291 | 1291 | "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES |
1292 | - ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});", |
|
1292 | + ({$row['fleet_owner']}, ".LOC_FLEET.", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});", |
|
1293 | 1293 | // ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, " . get_unit_param($unit_id, P_UNIT_TYPE) . ", {$unit_id}, {$unit_count});", |
1294 | 1294 | true |
1295 | 1295 | ); |
@@ -1323,11 +1323,11 @@ discard block |
||
1323 | 1323 | |
1324 | 1324 | classSupernova::$cache->unset_by_prefix('lng_'); |
1325 | 1325 | |
1326 | -if($new_version) { |
|
1326 | +if ($new_version) { |
|
1327 | 1327 | classSupernova::$config->db_saveItem('db_version', $new_version); |
1328 | 1328 | upd_log_message("<font color=green>DB version is now {$new_version}</font>"); |
1329 | 1329 | } else { |
1330 | - upd_log_message("DB version didn't changed from " . classSupernova::$config->db_version); |
|
1330 | + upd_log_message("DB version didn't changed from ".classSupernova::$config->db_version); |
|
1331 | 1331 | } |
1332 | 1332 | |
1333 | 1333 | classSupernova::$config->db_loadAll(); |