Completed
Push — work-fleets ( d40084...46e295 )
by SuperNova.WS
05:22
created
tests.int/FleetTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 define('SN_IN_FLEET', true);
6 6
 define('SN_RENDER_NAVBAR_PLANET', true);
7 7
 
8
-include('../common.' . substr(strrchr(__FILE__, '.'), 1));
8
+include('../common.'.substr(strrchr(__FILE__, '.'), 1));
9 9
 
10 10
 // TODO - Переместить это куда-нибудь
11 11
 $fleet_page = sys_get_param_int('fleet_page', sys_get_param_int('mode'));
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     print('Passed');
102 102
   } catch (Exception $e) {
103 103
     if ($exceptionCode !== null && $e->getCode() === $exceptionCode) {
104
-      print('<font color="green">Exception [' . $exceptionCode . ']: "' . classLocale::$lang['fl_attack_error'][$e->getCode()] . '" - passed</font><br />');
104
+      print('<font color="green">Exception ['.$exceptionCode.']: "'.classLocale::$lang['fl_attack_error'][$e->getCode()].'" - passed</font><br />');
105 105
     } else {
106 106
       print('<font color="red">');
107 107
       throw $e;
Please login to merge, or discard this patch.
includes/classes/Fleet.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
     parent::__construct();
326 326
     $this->exists_missions = sn_get_groups('missions');
327 327
     $this->allowed_missions = $this->exists_missions;
328
-    if(empty(static::$snGroupFleet)) {
328
+    if (empty(static::$snGroupFleet)) {
329 329
       static::$snGroupFleet = sn_get_groups('fleet');
330 330
       static::$snGroupFleetAndMissiles = sn_get_groups(array('fleet', 'missile'));
331 331
       static::$snGroupRecyclers = sn_get_groups('flt_recyclers');
@@ -408,31 +408,31 @@  discard block
 block discarded – undo
408 408
 
409 409
     return doquery(
410 410
     // Блокировка самого флота
411
-      "SELECT 1 FROM {{fleets}} AS f " .
411
+      "SELECT 1 FROM {{fleets}} AS f ".
412 412
 
413 413
       // Блокировка всех юнитов, принадлежащих этому флоту
414
-      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " .
414
+      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ".
415 415
 
416 416
       // Блокировка всех прилетающих и улетающих флотов, если нужно
417 417
       // TODO - lock fleets by COORDINATES
418
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') .
418
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '').
419 419
       // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination
420
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') .
420
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : '').
421 421
 
422
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') .
422
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '').
423 423
       // Блокировка всех юнитов, принадлежащих владельцу планеты-цели
424
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') .
424
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '').
425 425
       // Блокировка планеты-цели
426
-      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') .
426
+      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '').
427 427
       // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели
428 428
 //      ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') .
429 429
 
430 430
 
431
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') .
431
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '').
432 432
       // Блокировка всех юнитов, принадлежащих владельцу флота
433
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') .
433
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '').
434 434
       // Блокировка планеты отправления
435
-      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') .
435
+      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '').
436 436
       // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота
437 437
 //      ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') .
438 438
 
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
   public function dbGetLockById($dbId) {
450 450
     doquery(
451 451
     // Блокировка самого флота
452
-      "SELECT 1 FROM {{fleets}} AS FLEET0 " .
452
+      "SELECT 1 FROM {{fleets}} AS FLEET0 ".
453 453
       // Lock fleet owner
454
-      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " .
454
+      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ".
455 455
       // Блокировка всех юнитов, принадлежащих этому флоту
456
-      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " .
456
+      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ".
457 457
 
458 458
       // Без предварительной выборки неизвестно - куда летит этот флот.
459 459
       // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота.
@@ -469,9 +469,9 @@  discard block
 block discarded – undo
469 469
         FLEET1.fleet_end_planet = FLEET0.fleet_end_planet
470 470
       " .
471 471
       // Блокировка всех юнитов, принадлежащих этим флотам
472
-      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " .
472
+      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ".
473 473
       // Lock fleet owner
474
-      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " .
474
+      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ".
475 475
 
476 476
       "LEFT JOIN {{fleets}} AS FLEET2 ON
477 477
         FLEET2.fleet_mess = 1   AND FLEET0.fleet_mess = 0 AND
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
       " .
482 482
       // Блокировка всех юнитов, принадлежащих этим флотам
483 483
       "LEFT JOIN {{unit}} as UNIT2 ON
484
-        UNIT2.unit_location_type = " . LOC_FLEET . " AND
484
+        UNIT2.unit_location_type = " . LOC_FLEET." AND
485 485
         UNIT2.unit_location_id = FLEET2.fleet_id
486 486
       " .
487 487
       // Lock fleet owner
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
       " .
499 499
       // Блокировка всех юнитов, принадлежащих этим флотам
500 500
       "LEFT JOIN {{unit}} as UNIT3 ON
501
-        UNIT3.unit_location_type = " . LOC_FLEET . " AND
501
+        UNIT3.unit_location_type = " . LOC_FLEET." AND
502 502
         UNIT3.unit_location_id = FLEET3.fleet_id
503 503
       " .
504 504
       // Lock fleet owner
505
-      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " .
505
+      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ".
506 506
 
507 507
       "LEFT JOIN {{fleets}} AS FLEET4 ON
508 508
         FLEET4.fleet_mess = 1   AND FLEET0.fleet_mess = 1 AND
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
       " .
513 513
       // Блокировка всех юнитов, принадлежащих этим флотам
514 514
       "LEFT JOIN {{unit}} as UNIT4 ON
515
-        UNIT4.unit_location_type = " . LOC_FLEET . " AND
515
+        UNIT4.unit_location_type = " . LOC_FLEET." AND
516 516
         UNIT4.unit_location_id = FLEET4.fleet_id
517 517
       " .
518 518
       // Lock fleet owner
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
       " .
535 535
       // Блокировка всех юнитов, принадлежащих этой планете
536 536
       "LEFT JOIN {{unit}} as UNIT5 ON
537
-        UNIT5.unit_location_type = " . LOC_PLANET . " AND
537
+        UNIT5.unit_location_type = " . LOC_PLANET." AND
538 538
         UNIT5.unit_location_id = PLANETS5.id
539 539
       " .
540 540
 
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
       " .
553 553
       // Блокировка всех юнитов, принадлежащих этой планете
554 554
       "LEFT JOIN {{unit}} as UNIT6 ON
555
-        UNIT6.unit_location_type = " . LOC_PLANET . " AND
555
+        UNIT6.unit_location_type = " . LOC_PLANET." AND
556 556
         UNIT6.unit_location_id = PLANETS6.id
557 557
       " .
558 558
       "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE"
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
       } elseif ($this->isResource($unit_id)) {
672 672
         $this->resource_list[$unit_id] = $unit_count;
673 673
       } else {
674
-        throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
674
+        throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), ERR_ERROR);
675 675
       }
676 676
     }
677 677
   }
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
    * @param int $unit_count
802 802
    */
803 803
   public function shipSetCount($unit_id, $unit_count = 0) {
804
-pdump(__CLASS__ . '->' . __FUNCTION__);
804
+pdump(__CLASS__.'->'.__FUNCTION__);
805 805
     $this->shipAdjustCount($unit_id, $unit_count, true);
806 806
   }
807 807
 
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
    */
878 878
   public function shipsGetCapacityRecyclers($recycler_info) {
879 879
     $recyclers_incoming_capacity = 0;
880
-    foreach($this->shipsIterator() as $unitId => $unit) {
881
-      if(!empty(static::$snGroupRecyclers[$unitId]) && $unit->count >= 1) {
880
+    foreach ($this->shipsIterator() as $unitId => $unit) {
881
+      if (!empty(static::$snGroupRecyclers[$unitId]) && $unit->count >= 1) {
882 882
         $recyclers_incoming_capacity += $unit->count * $recycler_info[$unitId]['capacity'];
883 883
       }
884 884
     }
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
    */
1010 1010
   public function resourcesSet($resource_list) {
1011 1011
     if (!empty($this->propertiesAdjusted['resource_list'])) {
1012
-      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
1012
+      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR);
1013 1013
     }
1014 1014
     $this->resourcesAdjust($resource_list, true);
1015 1015
   }
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
       // Check for negative unit value
1044 1044
       if ($this->resource_list[$resource_id] < 0) {
1045 1045
         // TODO
1046
-        throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
1046
+        throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR);
1047 1047
       }
1048 1048
     }
1049 1049
   }
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
   protected function populateTargetPlanetAndOwner() {
1212 1212
     // If vector points to no exact object OR debris - then getting planet on coordinates
1213 1213
     $targetVector = clone $this->targetVector;
1214
-    if($targetVector->type == PT_DEBRIS || $targetVector == PT_NONE) {
1214
+    if ($targetVector->type == PT_DEBRIS || $targetVector == PT_NONE) {
1215 1215
       $targetVector->type = PT_PLANET;
1216 1216
     }
1217 1217
 
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
 
1225 1225
   protected function printErrorIfNoShips() {
1226 1226
     if ($this->unitList->unitsCount() <= 0) {
1227
-      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1227
+      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5);
1228 1228
     }
1229 1229
   }
1230 1230
 
@@ -1559,8 +1559,8 @@  discard block
 block discarded – undo
1559 1559
 
1560 1560
   public function fleetSpeed() {
1561 1561
     $maxSpeed = array();
1562
-    foreach($this->shipsIterator() as $ship_id => $unit) {
1563
-      if($unit->count > 0 && !empty(static::$snGroupFleetAndMissiles[$ship_id])) {
1562
+    foreach ($this->shipsIterator() as $ship_id => $unit) {
1563
+      if ($unit->count > 0 && !empty(static::$snGroupFleetAndMissiles[$ship_id])) {
1564 1564
         $single_ship_data = get_ship_data($ship_id, $this->dbOwnerRow);
1565 1565
         $maxSpeed[$ship_id] = $single_ship_data['speed'];
1566 1566
       }
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
       $this->fleetPage2Prepare($planetResourcesWithoutConsumption);
1593 1593
     } catch (Exception $e) {
1594 1594
       // TODO - MESSAGE BOX
1595
-      if($e instanceof ExceptionFleetInvalid) {
1595
+      if ($e instanceof ExceptionFleetInvalid) {
1596 1596
         sn_db_transaction_rollback();
1597 1597
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1598 1598
       } else {
@@ -1683,7 +1683,7 @@  discard block
 block discarded – undo
1683 1683
       $validator->validate();
1684 1684
     } catch (Exception $e) {
1685 1685
       // TODO - MESSAGE BOX
1686
-      if($e instanceof ExceptionFleetInvalid) {
1686
+      if ($e instanceof ExceptionFleetInvalid) {
1687 1687
         sn_db_transaction_rollback();
1688 1688
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1689 1689
       } else {
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
 
1748 1748
 
1749 1749
     if (!empty($this->captain['unit_id'])) {
1750
-      DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}");
1750
+      DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}");
1751 1751
     }
1752 1752
 
1753 1753
 //    return $this->fleet->acs['ankunft'] - $this->fleet->time_launch >= $this->fleet->travelData['duration'];
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
     $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob);
1760 1760
 
1761 1761
     $template_result += array(
1762
-      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''),
1762
+      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''),
1763 1763
       'dist'            => pretty_number($this->travelData['distance']),
1764 1764
       'speed'           => pretty_number($this->travelData['fleet_speed']),
1765 1765
       'deute_need'      => pretty_number($this->travelData['consumption']),
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
   protected function resourcesSubstractConsumption($planetResources) {
1804 1804
     !isset($planetResources[RES_DEUTERIUM]) ? $planetResources[RES_DEUTERIUM] = 0 : false;
1805 1805
 
1806
-    if($this->travelData['consumption'] >= 0) {
1806
+    if ($this->travelData['consumption'] >= 0) {
1807 1807
       $planetResources[RES_DEUTERIUM] -= ceil($this->travelData['consumption']);
1808 1808
     }
1809 1809
 
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Защита от двойного инита
4
-if(defined('INIT')) {
4
+if (defined('INIT')) {
5 5
   return;
6 6
 }
7 7
 
@@ -20,22 +20,22 @@  discard block
 block discarded – undo
20 20
 version_compare(PHP_VERSION, '5.3.2') < 0 ? die('FATAL ERROR: SuperNova REQUIRE PHP version > 5.3.2') : false;
21 21
 
22 22
 // Бенчмарк
23
-register_shutdown_function(function () {
24
-  if(defined('IN_AJAX')) {
23
+register_shutdown_function(function() {
24
+  if (defined('IN_AJAX')) {
25 25
     return;
26 26
   }
27 27
 
28 28
   global $user, $locale_cache_statistic;
29 29
 
30
-  print('<hr><div class="benchmark">Benchmark ' . (microtime(true) - SN_TIME_MICRO) . 's, memory: ' . number_format(memory_get_usage() - SN_MEM_START) .
31
-    (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') .
32
-    (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') .
30
+  print('<hr><div class="benchmark">Benchmark '.(microtime(true) - SN_TIME_MICRO).'s, memory: '.number_format(memory_get_usage() - SN_MEM_START).
31
+    (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '').
32
+    (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: '.classSupernova::$db->time_mysql_total.'ms' : '').
33 33
     '</div>');
34
-  if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
34
+  if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL.'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL.'badqrys.txt') > 0) {
35 35
     echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>';
36 36
   }
37 37
 
38
-  if(!empty($locale_cache_statistic['misses'])) {
38
+  if (!empty($locale_cache_statistic['misses'])) {
39 39
     print('<!--');
40 40
     pdump($locale_cache_statistic);
41 41
     print('-->');
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW));
57 57
 
58
-if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
58
+if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
59 59
   define('SN_GOOGLE', true);
60 60
 }
61 61
 
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 $sn_root_relative = str_replace($sn_root_relative, '', $_SERVER['SCRIPT_NAME']);
75 75
 define('SN_ROOT_RELATIVE', $sn_root_relative);
76 76
 
77
-define('SN_ROOT_VIRTUAL', 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . SN_ROOT_RELATIVE);
77
+define('SN_ROOT_VIRTUAL', 'http'.(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '').'://'.$_SERVER['HTTP_HOST'].SN_ROOT_RELATIVE);
78 78
 define('SN_ROOT_VIRTUAL_PARENT', str_replace('//google.', '//', SN_ROOT_VIRTUAL));
79 79
 
80 80
 $phpEx = strpos($phpEx = substr(strrchr(__FILE__, '.'), 1), '/') === false ? $phpEx : '';
81 81
 define('PHP_EX', $phpEx); // PHP extension on this server
82
-define('DOT_PHP_EX', '.' . PHP_EX); // PHP extension on this server
82
+define('DOT_PHP_EX', '.'.PHP_EX); // PHP extension on this server
83 83
 
84 84
 
85 85
 require_once('constants.php');
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
 
101 101
 // required for db.php
102 102
 // Initializing global 'debug' object
103
-require_once(SN_ROOT_PHYSICAL . "includes/debug.class" . DOT_PHP_EX);
103
+require_once(SN_ROOT_PHYSICAL."includes/debug.class".DOT_PHP_EX);
104 104
 classSupernova::$debug = new debug();
105 105
 
106
-empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL . 'includes/classes/' : false;
107
-spl_autoload_register(function ($class) use ($classRoot) {
106
+empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL.'includes/classes/' : false;
107
+spl_autoload_register(function($class) use ($classRoot) {
108 108
   $class = str_replace('\\', '/', $class);
109
-  if (file_exists($classRoot . $class . '.php')) {
110
-    require_once $classRoot . $class . '.php';
111
-  } elseif (file_exists($classRoot . 'UBE/' . $class . '.php')) {
112
-    require_once $classRoot . 'UBE/' . $class . '.php';
109
+  if (file_exists($classRoot.$class.'.php')) {
110
+    require_once $classRoot.$class.'.php';
111
+  } elseif (file_exists($classRoot.'UBE/'.$class.'.php')) {
112
+    require_once $classRoot.'UBE/'.$class.'.php';
113 113
   }
114 114
 });
115 115
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 //});
125 125
 
126 126
 
127
-require_once(SN_ROOT_PHYSICAL . "includes/db" . DOT_PHP_EX);
127
+require_once(SN_ROOT_PHYSICAL."includes/db".DOT_PHP_EX);
128 128
 require_once('classes/db_mysql_v4.php');
129 129
 require_once('classes/db_mysql_v5.php');
130 130
 require_once('classes/db_mysql.php');
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 require_once('classes/module.php');
138 138
 
139 139
 require_once('classes/user_options.php');
140
-require_once(SN_ROOT_PHYSICAL . "includes/init/init_functions" . DOT_PHP_EX);
140
+require_once(SN_ROOT_PHYSICAL."includes/init/init_functions".DOT_PHP_EX);
141 141
 
142 142
 /**
143 143
  * @var classConfig    $config
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 // define('BE_DEBUG', true); // Отладка боевого движка
151 151
 classSupernova::init_debug_state();
152 152
 
153
-require_once(SN_ROOT_PHYSICAL . "includes/vars" . DOT_PHP_EX);
154
-require_once(SN_ROOT_PHYSICAL . "includes/general" . DOT_PHP_EX);
153
+require_once(SN_ROOT_PHYSICAL."includes/vars".DOT_PHP_EX);
154
+require_once(SN_ROOT_PHYSICAL."includes/general".DOT_PHP_EX);
155 155
 
156 156
 init_update();
157 157
 
@@ -160,28 +160,28 @@  discard block
 block discarded – undo
160 160
   ? trim(strip_tags($_GET['page']))
161 161
   : str_replace(DOT_PHP_EX, '', str_replace(SN_ROOT_RELATIVE, '', str_replace('\\', '/', $_SERVER['SCRIPT_NAME'])));
162 162
 define('INITIAL_PAGE', $sn_page_name_original);
163
-define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova') . (defined('SN_GOOGLE') ? '_G' : ''));
164
-define('SN_COOKIE_I', SN_COOKIE . AUTH_COOKIE_IMPERSONATE_SUFFIX);
165
-define('SN_COOKIE_D', SN_COOKIE . '_D');
166
-define('SN_COOKIE_T', SN_COOKIE . '_T'); // Time measure cookie
167
-define('SN_COOKIE_F', SN_COOKIE . '_F'); // Font size cookie
168
-define('SN_COOKIE_U', SN_COOKIE . '_U'); // Current user cookie aka user ID
169
-define('SN_COOKIE_U_I', SN_COOKIE_U . AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID
163
+define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova').(defined('SN_GOOGLE') ? '_G' : ''));
164
+define('SN_COOKIE_I', SN_COOKIE.AUTH_COOKIE_IMPERSONATE_SUFFIX);
165
+define('SN_COOKIE_D', SN_COOKIE.'_D');
166
+define('SN_COOKIE_T', SN_COOKIE.'_T'); // Time measure cookie
167
+define('SN_COOKIE_F', SN_COOKIE.'_F'); // Font size cookie
168
+define('SN_COOKIE_U', SN_COOKIE.'_U'); // Current user cookie aka user ID
169
+define('SN_COOKIE_U_I', SN_COOKIE_U.AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID
170 170
 define('TEMPLATE_NAME', classSupernova::$config->game_default_template ? classSupernova::$config->game_default_template : 'OpenGame');
171
-define('TEMPLATE_PATH', 'design/templates/' . TEMPLATE_NAME);
172
-define('TEMPLATE_DIR', SN_ROOT_PHYSICAL . TEMPLATE_PATH);
171
+define('TEMPLATE_PATH', 'design/templates/'.TEMPLATE_NAME);
172
+define('TEMPLATE_DIR', SN_ROOT_PHYSICAL.TEMPLATE_PATH);
173 173
 define('DEFAULT_SKINPATH', classSupernova::$config->game_default_skin ? classSupernova::$config->game_default_skin : 'skins/EpicBlue/');
174 174
 define('DEFAULT_LANG', classSupernova::$config->game_default_language ? classSupernova::$config->game_default_language : 'ru');
175 175
 define('FMT_DATE', classSupernova::$config->int_format_date ? classSupernova::$config->int_format_date : 'd.m.Y');
176 176
 define('FMT_TIME', classSupernova::$config->int_format_time ? classSupernova::$config->int_format_time : 'H:i:s');
177
-define('FMT_DATE_TIME', FMT_DATE . ' ' . FMT_TIME);
177
+define('FMT_DATE_TIME', FMT_DATE.' '.FMT_TIME);
178 178
 
179 179
 $HTTP_ACCEPT_LANGUAGE = DEFAULT_LANG;
180 180
 
181
-require_once(SN_ROOT_PHYSICAL . "includes/template" . DOT_PHP_EX);
181
+require_once(SN_ROOT_PHYSICAL."includes/template".DOT_PHP_EX);
182 182
 $template_result = array('.' => array('result' => array()));
183 183
 
184
-sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX);
184
+sn_sys_load_php_files(SN_ROOT_PHYSICAL."includes/functions/", PHP_EX);
185 185
 
186 186
 
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 // Конфиг - часть манифеста?
193 193
 classSupernova::$auth = new core_auth();
194 194
 
195
-sn_sys_load_php_files(SN_ROOT_PHYSICAL . "modules/", PHP_EX, true);
195
+sn_sys_load_php_files(SN_ROOT_PHYSICAL."modules/", PHP_EX, true);
196 196
 // Здесь - потому что core_auth модуль лежит в другом каталоге и его нужно инициализировать отдельно
197 197
 
198 198
 // Подключаем дефолтную страницу
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 // Сейчас мы делаем это здесь только для того, что бы содержание дефолтной страницы оказалось вверху. Что не факт, что нужно всегда
201 201
 // Но нужно, пока у нас есть не MVC-страницы
202 202
 $sn_page_data = $sn_data['pages'][$sn_page_name];
203
-$sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
204
-if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
203
+$sn_page_name_file = 'includes/pages/'.$sn_page_data['filename'].DOT_PHP_EX;
204
+if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
205 205
   require_once($sn_page_name_file);
206
-  if(is_array($sn_page_data['options'])) {
206
+  if (is_array($sn_page_data['options'])) {
207 207
     classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']);
208 208
   }
209 209
 }
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 $load_order = array();
219 219
 $sn_req = array();
220 220
 
221
-foreach(sn_module::$sn_module as $loaded_module_name => $module_data) {
221
+foreach (sn_module::$sn_module as $loaded_module_name => $module_data) {
222 222
   $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000;
223
-  if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
224
-    foreach($module_data->manifest['require'] as $require_name) {
223
+  if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
224
+    foreach ($module_data->manifest['require'] as $require_name) {
225 225
       $sn_req[$loaded_module_name][$require_name] = 0;
226 226
     }
227 227
   }
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 do {
235 235
   $prev_order = $load_order;
236 236
 
237
-  foreach($sn_req as $loaded_module_name => &$req_data) {
237
+  foreach ($sn_req as $loaded_module_name => &$req_data) {
238 238
     $level = 1;
239
-    foreach($req_data as $req_name => &$req_level) {
240
-      if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
239
+    foreach ($req_data as $req_name => &$req_level) {
240
+      if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
241 241
         $level = $req_level = -1;
242 242
         break;
243 243
       } else {
@@ -245,20 +245,20 @@  discard block
 block discarded – undo
245 245
       }
246 246
       $req_level = $load_order[$req_name];
247 247
     }
248
-    if($level > $load_order[$loaded_module_name] || $level == -1) {
248
+    if ($level > $load_order[$loaded_module_name] || $level == -1) {
249 249
       $load_order[$loaded_module_name] = $level;
250 250
     }
251 251
   }
252
-} while($prev_order != $load_order);
252
+} while ($prev_order != $load_order);
253 253
 
254 254
 asort($load_order);
255 255
 
256 256
 // Инициализируем модули
257 257
 // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти
258
-foreach($load_order as $loaded_module_name => $load_order_order) {
259
-  if($load_order_order >= 0) {
258
+foreach ($load_order as $loaded_module_name => $load_order_order) {
259
+  if ($load_order_order >= 0) {
260 260
     sn_module::$sn_module[$loaded_module_name]->check_status();
261
-    if(!sn_module::$sn_module[$loaded_module_name]->manifest['active']) {
261
+    if (!sn_module::$sn_module[$loaded_module_name]->manifest['active']) {
262 262
       unset(sn_module::$sn_module[$loaded_module_name]);
263 263
       continue;
264 264
     }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 unset($sn_req);
276 276
 
277 277
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
278
-if(!isset($sn_data['pages'][$sn_page_name])) {
278
+if (!isset($sn_data['pages'][$sn_page_name])) {
279 279
   $sn_page_name = '';
280 280
 }
281 281
 
@@ -283,6 +283,6 @@  discard block
 block discarded – undo
283 283
 classLocale::$lang = $lang = new classLocale(classSupernova::$config->server_locale_log_usage);
284 284
 classLocale::$lang->lng_switch(sys_get_param_str('lang'));
285 285
 
286
-if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
286
+if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
287 287
   require_once "init_secondary.php";
288 288
 }
Please login to merge, or discard this patch.