Passed
Push — work-fleets ( 4e1f0c...91349a )
by SuperNova.WS
10:40
created
classes/FleetList.php 2 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -64,6 +64,10 @@  discard block
 block discarded – undo
64 64
    *
65 65
    */
66 66
   // DEPRECATED
67
+
68
+  /**
69
+   * @param boolean $for_update
70
+   */
67 71
   public static function dbGetFleetList($where_safe = '', $for_update = DB_SELECT_FOR_UPDATE) {
68 72
     $fleetList = new static();
69 73
     $fleetList->dbLoadWhere($where_safe, $for_update);
@@ -246,6 +250,7 @@  discard block
 block discarded – undo
246 250
    * LIST - Get missile attack list by condition
247 251
    *
248 252
    * @param string $where
253
+   * @param boolean $for_update
249 254
    */
250 255
   public function dbMergeMissileList($where, $for_update = DB_SELECT_FOR_UPDATE) {
251 256
     $query = classSupernova::$db->doSelect(
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
     $fleets_added = array();
34 34
 
35 35
     $query = classSupernova::$db->doSelect(
36
-      "SELECT * FROM `{{fleets}}`" .
37
-      (!empty($where_safe) ? " WHERE {$where_safe}" : '') .
36
+      "SELECT * FROM `{{fleets}}`".
37
+      (!empty($where_safe) ? " WHERE {$where_safe}" : '').
38 38
       ($for_update == DB_SELECT_FOR_UPDATE ? " FOR UPDATE;" : '')
39 39
     );
40
-    while($row = db_fetch($query)) {
40
+    while ($row = db_fetch($query)) {
41 41
       /**
42 42
        * @var Fleet $fleet
43 43
        */
44 44
       $fleet = $this->_createElement();
45 45
       $fleet->dbRowParse($row);
46 46
 
47
-      if(isset($this[$fleet->dbId])) {
47
+      if (isset($this[$fleet->dbId])) {
48 48
         // Нужно ли ????
49 49
         classSupernova::$debug->error('Fleet list already set');
50 50
       }
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
   public static function dbGetFleetListCurrentTick() {
120 120
     return static::dbGetFleetList(
121 121
       "
122
-    (`fleet_start_time` <= " . SN_TIME_NOW . " AND `fleet_mess` = 0)
122
+    (`fleet_start_time` <= " . SN_TIME_NOW." AND `fleet_mess` = 0)
123 123
     OR
124
-    (`fleet_end_stay` <= " . SN_TIME_NOW . " AND `fleet_end_stay` > 0 AND `fleet_mess` = 0)
124
+    (`fleet_end_stay` <= " . SN_TIME_NOW." AND `fleet_end_stay` > 0 AND `fleet_mess` = 0)
125 125
     OR
126
-    (`fleet_end_time` <= " . SN_TIME_NOW . ")"
126
+    (`fleet_end_time` <= " . SN_TIME_NOW.")"
127 127
       , DB_SELECT_PLAIN
128 128
     );
129 129
   }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     AND `fleet_end_planet` = {$planet_row['planet']}
145 145
     AND `fleet_end_type`   = {$planet_row['planet_type']}
146 146
     AND `fleet_owner` = {$fleet_owner_id}
147
-    AND `fleet_mission` IN (" . MT_ATTACK . "," . MT_ACS . "," . MT_DESTROY . ")
147
+    AND `fleet_mission` IN (".MT_ATTACK.",".MT_ACS.",".MT_DESTROY.")
148 148
     AND `fleet_mess` = 0"
149 149
       , DB_SELECT_FOR_UPDATE
150 150
     );
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
    * @return static|array
171 171
    */
172 172
   public static function dbGetFleetListAndMissileByCoordinates($coordinates, $for_phalanx = false) {
173
-    if(empty($coordinates) || !is_array($coordinates)) {
173
+    if (empty($coordinates) || !is_array($coordinates)) {
174 174
       return array();
175 175
     }
176 176
 
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
      * @var Fleet[] $array_of_Fleet
202 202
      */
203 203
     $array_of_Fleet = array();
204
-    if(!empty($fleet_db_list) && $fleet_db_list->count()) {
205
-      foreach($fleet_db_list->_container as $fleet_id => $objFleet) {
204
+    if (!empty($fleet_db_list) && $fleet_db_list->count()) {
205
+      foreach ($fleet_db_list->_container as $fleet_id => $objFleet) {
206 206
         $array_of_Fleet[$fleet_id] = $objFleet;
207 207
       }
208 208
       $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet);
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
     return static::dbGetFleetList(
228 228
       "(
229 229
       fleet_start_galaxy = {$galaxy}
230
-      AND fleet_start_system = {$system}" .
231
-      ($planet ? " AND fleet_start_planet = {$planet}" : '') .
232
-      ($planet_type != PT_ALL ? " AND fleet_start_type = {$planet_type}" : '') .
233
-      ($for_phalanx ? '' : " AND fleet_mess = 1") .
230
+      AND fleet_start_system = {$system}".
231
+      ($planet ? " AND fleet_start_planet = {$planet}" : '').
232
+      ($planet_type != PT_ALL ? " AND fleet_start_type = {$planet_type}" : '').
233
+      ($for_phalanx ? '' : " AND fleet_mess = 1").
234 234
       ") OR (
235 235
       fleet_end_galaxy = {$galaxy}
236
-      AND fleet_end_system = {$system}" .
237
-      ($planet ? " AND fleet_end_planet = {$planet}" : '') .
238
-      ($planet_type != PT_ALL ? " AND fleet_end_type = {$planet_type} " : '') .
239
-      ($for_phalanx ? '' : " AND fleet_mess = 0") .
236
+      AND fleet_end_system = {$system}".
237
+      ($planet ? " AND fleet_end_planet = {$planet}" : '').
238
+      ($planet_type != PT_ALL ? " AND fleet_end_type = {$planet_type} " : '').
239
+      ($for_phalanx ? '' : " AND fleet_mess = 0").
240 240
       ")"
241 241
       , DB_SELECT_PLAIN
242 242
     );
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
    */
250 250
   public function dbMergeMissileList($where, $for_update = DB_SELECT_FOR_UPDATE) {
251 251
     $query = classSupernova::$db->doSelect(
252
-      "SELECT * FROM `{{iraks}}`" .
253
-      (!empty($where) ? " WHERE {$where}" : '') .
252
+      "SELECT * FROM `{{iraks}}`".
253
+      (!empty($where) ? " WHERE {$where}" : '').
254 254
       ($for_update == DB_SELECT_FOR_UPDATE ? " FOR UPDATE;" : '')
255 255
     );
256
-    while($missile_db_row = db_fetch($query)) {
256
+    while ($missile_db_row = db_fetch($query)) {
257 257
       /**
258 258
        * @var Fleet $objFleet
259 259
        */
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
    */
276 276
   public static function dbGetFleetListAndMissileINCOMING($owner_id) {
277 277
     $owner_id_safe = idval($owner_id);
278
-    if(empty($owner_id_safe)) {
278
+    if (empty($owner_id_safe)) {
279 279
       return array();
280 280
     }
281 281
 
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
    */
310 310
   public static function fleet_count_flying($player_id, $mission_id = 0) {
311 311
     $player_id_safe = idval($player_id);
312
-    if(!empty($player_id_safe)) {
312
+    if (!empty($player_id_safe)) {
313 313
       $mission_id_safe = intval($mission_id);
314 314
       $result = static::db_fleet_count(
315
-        "`fleet_owner` = {$player_id_safe}" .
315
+        "`fleet_owner` = {$player_id_safe}".
316 316
         ($mission_id_safe ? " AND `fleet_mission` = {$mission_id_safe}" : '')
317 317
       );
318 318
     } else {
Please login to merge, or discard this patch.
admin/statbuilder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,18 +9,18 @@
 block discarded – undo
9 9
  * @copyright 2008 by Chlorel for XNova
10 10
  */
11 11
 
12
-define('INSIDE'  , true);
13
-define('INSTALL' , false);
12
+define('INSIDE', true);
13
+define('INSTALL', false);
14 14
 define('IN_ADMIN', true);
15
-require_once('../common.' . substr(strrchr(__FILE__, '.'), 1));
15
+require_once('../common.'.substr(strrchr(__FILE__, '.'), 1));
16 16
 
17 17
 // if($user['authlevel'] < 1)
18
-if($user['authlevel'] < 3)
18
+if ($user['authlevel'] < 3)
19 19
 {
20 20
   AdminMessage(classLocale::$lang['adm_err_denied']);
21 21
 }
22 22
 
23
-if(SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_stat_update_admin_forced') && SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_stat_update_end'))
23
+if (SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_stat_update_admin_forced') && SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_stat_update_end'))
24 24
 {
25 25
   classSupernova::$config->db_saveItem('var_stat_update_admin_forced', SN_TIME_NOW + 120);
26 26
 
Please login to merge, or discard this patch.
classes/Entity/EntityModel.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     $this->rowOperator = $gc->dbGlobalRowOperator;
76 76
     $this->accessors = new Accessors();
77 77
 
78
-    if(property_exists($this, 'newProperties') && !empty($this->newProperties)) {
78
+    if (property_exists($this, 'newProperties') && !empty($this->newProperties)) {
79 79
       $this->extendProperties($this->newProperties);
80 80
     }
81 81
   }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
   }
217 217
 
218 218
   protected function delete(EntityContainer $cEntity) {
219
-    throw new \Exception(__CLASS__ . '::delete() in ' . get_called_class() . 'is not yet implemented');
219
+    throw new \Exception(__CLASS__.'::delete() in '.get_called_class().'is not yet implemented');
220 220
   }
221 221
 
222 222
   protected function insert(EntityContainer $cEntity) {
@@ -229,19 +229,19 @@  discard block
 block discarded – undo
229 229
     // Generate changeset row
230 230
     // Foreach all rows. If there is change and no delta - then put delta. Otherwise put change
231 231
     // If row not empty - update
232
-    throw new \Exception(__CLASS__ . '::update() in ' . get_called_class() . 'is not yet implemented');
232
+    throw new \Exception(__CLASS__.'::update() in '.get_called_class().'is not yet implemented');
233 233
   }
234 234
 
235
-  protected function unchanged(EntityContainer $cEntity){
235
+  protected function unchanged(EntityContainer $cEntity) {
236 236
     // TODO - or just save nothing ?????
237 237
 //    throw new \Exception('EntityModel isNotEmpty, have dbId and not CHANGED! It can\'t be!');
238
-    throw new \Exception(__CLASS__ . '::unchanged() in ' . get_called_class() . 'is not yet implemented');
238
+    throw new \Exception(__CLASS__.'::unchanged() in '.get_called_class().'is not yet implemented');
239 239
   }
240 240
 
241 241
   protected function emptyAction(EntityContainer $cEntity) {
242 242
     // Just created container and doesn't use it
243 243
 //    throw new \Exception('EntityModel isEmpty but not loaded! It can\'t be!');
244
-    throw new \Exception(__CLASS__ . '::emptyAction() in ' . get_called_class() . 'is not yet implemented');
244
+    throw new \Exception(__CLASS__.'::emptyAction() in '.get_called_class().'is not yet implemented');
245 245
   }
246 246
 
247 247
   protected function save(EntityContainer $cEntity) {
Please login to merge, or discard this patch.
classes/Entity/EntityContainer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
     elseif ($value != $this->original[$name]) {
70 70
       $this->delta[$name] = $value;
71 71
       // New value not equal original value. We should update delta
72
-      if((is_int($value) || is_float($value))) {
72
+      if ((is_int($value) || is_float($value))) {
73 73
         $this->delta[$name] -= $this->original[$name];
74 74
       }
75 75
     }
Please login to merge, or discard this patch.
classes/Entity/KeyedModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
     throw new \Exception('KeyedModel::update() is not yet implemented');
80 80
   }
81 81
 
82
-  protected function unchanged(KeyedContainer $cEntity){
82
+  protected function unchanged(KeyedContainer $cEntity) {
83 83
     // TODO - or just save nothing ?????
84 84
     // throw new \Exception('EntityModel isNotEmpty, have dbId and not CHANGED! It can\'t be!');
85 85
     // Do nothing
Please login to merge, or discard this patch.
classes/db_mysql_v5.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,19 +37,19 @@
 block discarded – undo
37 37
 
38 38
     $this->link = mysqli_connect($settings['server'], $settings['user'], $settings['pass'], $settings['name']);
39 39
     if (!is_object($this->link) || $this->link->connect_error) {
40
-      classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #' . $this->link->connect_errno, $this->link->connect_error);
40
+      classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #'.$this->link->connect_errno, $this->link->connect_error);
41 41
     }
42 42
 
43 43
 
44 44
     !$this->mysql_query("/*!40101 SET NAMES 'utf8' */")
45
-      ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #' . $this->link->errno, $this->link->error)
45
+      ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #'.$this->link->errno, $this->link->error)
46 46
       : false;
47 47
     !$this->mysql_query("SET NAMES 'utf8';")
48
-      ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #' . $this->link->errno, $this->link->error)
48
+      ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #'.$this->link->errno, $this->link->error)
49 49
       : false;
50 50
 
51
-    !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_SERIALIZABLE . ';')
52
-      ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #' . $this->link->errno, $this->link->error)
51
+    !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_SERIALIZABLE.';')
52
+      ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #'.$this->link->errno, $this->link->error)
53 53
       : false;
54 54
 
55 55
     $this->connected = true;
Please login to merge, or discard this patch.
includes/init_secondary.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -4,19 +4,19 @@  discard block
 block discarded – undo
4 4
 
5 5
 $classLocale = classLocale::$lang;
6 6
 
7
-if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
8
-  include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX);
7
+if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
8
+  include(SN_ROOT_PHYSICAL.'ajax_version_check'.DOT_PHP_EX);
9 9
 }
10 10
 
11
-if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
12
-  require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX);
11
+if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
12
+  require_once(SN_ROOT_PHYSICAL."includes/includes/user_birthday_celebrate".DOT_PHP_EX);
13 13
   sn_user_birthday_celebrate();
14 14
 }
15 15
 
16
-if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
16
+if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
17 17
   classSupernova::$config->db_saveItem('var_online_user_count', DBStaticUser::db_user_count(true));
18 18
   classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW);
19
-  if(classSupernova::$config->server_log_online) {
19
+  if (classSupernova::$config->server_log_online) {
20 20
     db_log_online_insert();
21 21
   }
22 22
 }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
44 44
 //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die();
45 45
 
46
-if(!empty($user['id'])) {
46
+if (!empty($user['id'])) {
47 47
   classSupernova::$user_options->user_change($user['id']);
48 48
 }
49 49
 
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
     : false
57 57
   );
58 58
 
59
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
60
-  $prohibited_characters = array_map(function ($value) {
61
-    return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
59
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
60
+  $prohibited_characters = array_map(function($value) {
61
+    return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'";
62 62
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
63 63
   $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters);
64 64
 }
65 65
 
66 66
 
67
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
67
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
68 68
   pdump("Отключи отладку перед продакшном!");
69 69
 }
70 70
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
   ? define('INSTALL_MODE', GAME_DISABLE_INSTALL)
79 79
   : false;
80 80
 
81
-if(
81
+if (
82 82
   classSupernova::$config->game_disable == GAME_DISABLE_STAT
83 83
   &&
84 84
   SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) > 600
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
   classSupernova::$debug->warning('Stat worked too long - watchdog unlocked', 'Stat WARNING');
92 92
 }
93 93
 
94
-if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
94
+if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
95 95
   $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse(
96 96
     classSupernova::$config->game_disable == GAME_DISABLE_REASON
97 97
       ? classSupernova::$config->game_disable_reason
98 98
       : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable]
99 99
   );
100
-  if(defined('IN_API')) {
100
+  if (defined('IN_API')) {
101 101
     return;
102 102
   }
103 103
 
104
-  if(
104
+  if (
105 105
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
106 106
     &&
107 107
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 
116 116
 // TODO ban
117 117
 // TODO $skip_ban_check
118
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
119
-  if(defined('IN_API')) {
118
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
119
+  if (defined('IN_API')) {
120 120
     return;
121 121
   }
122 122
 
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
 // pdump($allow_anonymous, '$allow_anonymous');
135 135
 // pdump($sys_user_logged_in, '$sys_user_logged_in');
136 136
 
137
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
138
-  sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
139
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
137
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
138
+  sys_redirect(SN_ROOT_VIRTUAL.'overview.php');
139
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
140 140
 //  pdump($sn_page_name);
141 141
 //  pdump(INITIAL_PAGE);
142 142
 //  die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}');
143
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
143
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
144 144
   // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
145
-  sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
145
+  sys_redirect(SN_ROOT_VIRTUAL.'login.php');
146 146
 }
147 147
 
148 148
 $user_time_diff = playerTimeDiff::user_time_diff_get();
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 
162 162
 global $skip_fleet_update;
163 163
 $skip_fleet_update = $skip_fleet_update || classSupernova::$options['fleet_update_skip'] || defined('IN_ADMIN');
164
-if(
164
+if (
165 165
   !$skip_fleet_update
166 166
   && !(defined('IN_AJAX') && IN_AJAX === true)
167 167
   && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval
168 168
 ) {
169
-  require_once(SN_ROOT_PHYSICAL . "includes/includes/flt_flying_fleet_handler2" . DOT_PHP_EX);
169
+  require_once(SN_ROOT_PHYSICAL."includes/includes/flt_flying_fleet_handler2".DOT_PHP_EX);
170 170
   flt_flying_fleet_handler($skip_fleet_update);
171 171
 }
172 172
 
173
-if(!defined('IN_AJAX')) {
173
+if (!defined('IN_AJAX')) {
174 174
   pdump("Scheduled processes is disabled");
175 175
 }
176 176
 // scheduler_process();
Please login to merge, or discard this patch.
includes/functions/scheduler_process.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@  discard block
 block discarded – undo
9 9
   $ts_var_stat_update = strtotime(classSupernova::$config->db_loadItem('var_stat_update'));
10 10
   $ts_scheduled_update = sys_schedule_get_prev_run(classSupernova::$config->db_loadItem('stats_schedule'), classSupernova::$config->var_stat_update);
11 11
 
12
-  if(sys_get_param_int('admin_update')) {
12
+  if (sys_get_param_int('admin_update')) {
13 13
     define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1);
14
-    if(USER_LEVEL > 0) {
14
+    if (USER_LEVEL > 0) {
15 15
       $is_admin_request = true;
16 16
       $ts_scheduled_update = SN_TIME_NOW;
17 17
     }
18 18
   }
19 19
 
20
-  if($ts_scheduled_update > $ts_var_stat_update) {
20
+  if ($ts_scheduled_update > $ts_var_stat_update) {
21 21
     lng_include('admin');
22 22
     sn_db_transaction_start();
23 23
     $ts_var_stat_update_end = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end'));
24
-    if(SN_TIME_NOW > $ts_var_stat_update_end) {
24
+    if (SN_TIME_NOW > $ts_var_stat_update_end) {
25 25
       $old_server_status = classSupernova::$config->db_loadItem('game_disable');
26 26
       classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_STAT);
27 27
 
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 
32 32
       $msg = $is_admin_request ? 'admin request' : 'scheduler';
33 33
       $next_run = date(FMT_DATE_TIME_SQL, sys_schedule_get_prev_run(classSupernova::$config->stats_schedule, classSupernova::$config->var_stat_update, true));
34
-      $msg = "Running stat updates: {$msg}. Config->var_stat_update = " . classSupernova::$config->var_stat_update .
35
-        ', $ts_scheduled_update = ' . date(FMT_DATE_TIME_SQL, $ts_scheduled_update) .
36
-        ', next_stat_update = ' . $next_run;
34
+      $msg = "Running stat updates: {$msg}. Config->var_stat_update = ".classSupernova::$config->var_stat_update.
35
+        ', $ts_scheduled_update = '.date(FMT_DATE_TIME_SQL, $ts_scheduled_update).
36
+        ', next_stat_update = '.$next_run;
37 37
       classSupernova::$debug->warning($msg, 'Stat update', LOG_INFO_STAT_PROCESS);
38 38
       $total_time = microtime(true);
39 39
 
40 40
       // require_once('../includes/sys_stat.php');
41
-      require_once(SN_ROOT_PHYSICAL . 'includes/includes/sys_stat.php');
41
+      require_once(SN_ROOT_PHYSICAL.'includes/includes/sys_stat.php');
42 42
       sys_stat_calculate();
43 43
 
44 44
       $total_time = microtime(true) - $total_time;
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
       classSupernova::$config->db_saveItem('var_stat_update_admin_forced', SN_TIME_SQL);
57 57
       classSupernova::$config->db_saveItem('var_stat_update_end', SN_TIME_SQL);
58 58
 
59
-      if($old_server_status == GAME_DISABLE_STAT) {
59
+      if ($old_server_status == GAME_DISABLE_STAT) {
60 60
         $old_server_status = GAME_DISABLE_NONE;
61 61
       }
62 62
       classSupernova::$config->db_saveItem('game_disable', $old_server_status);
63
-    } elseif($ts_scheduled_update > $ts_var_stat_update) {
63
+    } elseif ($ts_scheduled_update > $ts_var_stat_update) {
64 64
       $timeout = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW;
65 65
       $msg = classSupernova::$config->db_loadItem('var_stat_update_msg');
66 66
       $msg = "{$msg} ETA {$timeout} seconds. Please wait...";
67 67
     }
68 68
     sn_db_transaction_rollback();
69
-  } elseif($is_admin_request) {
69
+  } elseif ($is_admin_request) {
70 70
     $msg = 'Stat is up to date';
71 71
   }
72 72
 
Please login to merge, or discard this patch.
includes/includes/flt_flying_fleet_handler2.php 1 patch
Spacing   +9 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,15 +23,11 @@  discard block
 block discarded – undo
23 23
 // ------------------------------------------------------------------
24 24
 function flt_flyingFleetsSort($a, $b) {
25 25
   // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
26
-  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
27
-    // Если время - одинаковое, сравниваем события флотов
26
+  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
28 27
     // Если события - одинаковые, то флоты равны
29
-    ($a['fleet_event'] == $b['fleet_event'] ? 0 :
30
-      // Если события разные - первыми считаем прибывающие флоты
31
-      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
32
-        // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
33
-        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
34
-          // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
28
+    ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
29
+      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
30
+        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
35 31
           // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
36 32
           (
37 33
           0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -49,13 +45,13 @@  discard block
 block discarded – undo
49 45
     $handler = fopen('event.log', 'a+');
50 46
   }
51 47
 
52
-  fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n");
48
+  fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n");
53 49
 }
54 50
 
55 51
 // ------------------------------------------------------------------
56 52
 function flt_flying_fleet_handler($skip_fleet_update = false) {
57 53
   if (true) {
58
-    if(!defined('IN_AJAX')) {
54
+    if (!defined('IN_AJAX')) {
59 55
       print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>');
60 56
       pdump('Fleet handler is disabled');
61 57
     }
@@ -181,7 +177,7 @@  discard block
 block discarded – undo
181 177
     MT_EXPLORE   => 'flt_mission_explore',
182 178
   );
183 179
   foreach ($missions_used as $mission_id => $cork) {
184
-    require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX);
180
+    require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX);
185 181
   }
186 182
 
187 183
 //log_file('Обработка миссий');
@@ -190,7 +186,7 @@  discard block
 block discarded – undo
190 186
     // Watchdog timer
191 187
     // If flying fleet handler works more then 10 seconds - stopping it
192 188
     // Let next run handle rest of fleets
193
-    if(time() - SN_TIME_NOW > 10) {
189
+    if (time() - SN_TIME_NOW > 10) {
194 190
       $debug->warning('Flying fleet handler standard routine works more then 10 seconds - watchdog unlocked', 'FFH Warning', 504);
195 191
       break;
196 192
     }
@@ -256,7 +252,7 @@  discard block
 block discarded – undo
256 252
     $objMission->fleet_event = $fleet_event['fleet_event'];
257 253
 
258 254
     // Fleet that have planet destination is returned
259
-    if($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
255
+    if ($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
260 256
       $objFleet->markReturnedAndSave();
261 257
       sn_db_transaction_commit();
262 258
       continue;
Please login to merge, or discard this patch.