Completed
Push — work-fleets ( 094cef...4ec5b3 )
by SuperNova.WS
06:12
created
includes/classes/db_mysql_v5.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,19 +39,19 @@
 block discarded – undo
39 39
 
40 40
     @$this->link = mysqli_connect($settings['server'], $settings['user'], $settings['pass'], $settings['name']);
41 41
     if (!is_object($this->link) || $this->link->connect_error) {
42
-      classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #' . $this->link->connect_errno, $this->link->connect_error);
42
+      classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #'.$this->link->connect_errno, $this->link->connect_error);
43 43
     }
44 44
 
45 45
 
46 46
     !$this->mysql_query("/*!40101 SET NAMES 'utf8' */")
47
-      ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #' . $this->link->errno, $this->link->error)
47
+      ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #'.$this->link->errno, $this->link->error)
48 48
       : false;
49 49
     !$this->mysql_query("SET NAMES 'utf8';")
50
-      ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #' . $this->link->errno, $this->link->error)
50
+      ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #'.$this->link->errno, $this->link->error)
51 51
       : false;
52 52
 
53
-    !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_REPEATABLE_READ . ';')
54
-      ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #' . $this->link->errno, $this->link->error)
53
+    !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_REPEATABLE_READ.';')
54
+      ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #'.$this->link->errno, $this->link->error)
55 55
       : false;
56 56
 
57 57
     $this->connected = true;
Please login to merge, or discard this patch.
includes/classes/PlayerToAccountTranslate.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   protected static $is_init = false;
20 20
 
21 21
   protected static function init() {
22
-    if(!empty(static::$db)) {
22
+    if (!empty(static::$db)) {
23 23
       return;
24 24
     }
25 25
     static::$db = classSupernova::$db;
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     $provider_id_safe = intval($provider_id_unsafe);
67 67
     !is_array($account_list) ? $account_list = array($account_list) : false;
68 68
 
69
-    foreach($account_list as $provider_account_id_unsafe) {
69
+    foreach ($account_list as $provider_account_id_unsafe) {
70 70
       $provider_account_id_safe = intval($provider_account_id_unsafe);
71 71
 
72 72
       // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером
73 73
       $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE");
74
-      while($row = static::$db->db_fetch($query)) {
74
+      while ($row = static::$db->db_fetch($query)) {
75 75
         $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true;
76 76
       }
77 77
     }
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
     $account_translation = array();
89 89
 
90 90
     $query = static::$db->doquery(
91
-      "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " .
92
-      ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') .
91
+      "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} ".
92
+      ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '').
93 93
       "ORDER BY `timestamp` FOR UPDATE");
94
-    while($row = static::$db->db_fetch($query)) {
94
+    while ($row = static::$db->db_fetch($query)) {
95 95
       $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row;
96 96
     }
97 97
 
Please login to merge, or discard this patch.
includes/classes/Account.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
       }
Please login to merge, or discard this patch.
includes/classes/skin.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
    * Инициализация харнилища скинов
153 153
    */
154 154
   protected static function init() {
155
-    if(static::$is_init) {
155
+    if (static::$is_init) {
156 156
       return;
157 157
     }
158 158
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
     // Загружены ли уже данные по текущему скину?
167 167
 //pdump(static::$skin_list[$ini_path], 'static');
168
-    if(empty(static::$skin_list[$skin_path])) {
168
+    if (empty(static::$skin_list[$skin_path])) {
169 169
       // Прогружаем текущий скин
170 170
       static::$skin_list[$skin_path] = new skin($skin_path);
171 171
       static::$active = static::$skin_list[$skin_path];
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
     strpos($skin_path, 'skins/') !== false ? $skin_path = substr($skin_path, 6) : false;
192 192
     strpos($skin_path, '/') !== false ? $skin_path = str_replace('/', '', $skin_path) : false;
193 193
 
194
-    $this->root_http_relative = 'skins/' . $skin_path . '/'; // Пока стоит base="" в body SN_ROOT_VIRTUAL - не нужен
194
+    $this->root_http_relative = 'skins/'.$skin_path.'/'; // Пока стоит base="" в body SN_ROOT_VIRTUAL - не нужен
195 195
 //    $this->root_http = SN_ROOT_VIRTUAL . 'skins/' . $skin_path . '/'; // Всегда абсолютный путь от корня сайта
196
-    $this->root_physical_absolute = SN_ROOT_PHYSICAL . 'skins/' . $skin_path . '/';
196
+    $this->root_physical_absolute = SN_ROOT_PHYSICAL.'skins/'.$skin_path.'/';
197 197
     $this->name = $skin_path;
198 198
 //    pdump($this->root_folder);
199 199
     // Искать скин среди пользовательских - когда будет конструктор скинов
@@ -201,22 +201,22 @@  discard block
 block discarded – undo
201 201
 
202 202
     $this->is_ini_present = false;
203 203
     // Проверка на корректность и существование пути
204
-    if(is_file($this->root_physical_absolute . 'skin.ini')) {
204
+    if (is_file($this->root_physical_absolute.'skin.ini')) {
205 205
       // Пытаемся распарсить файл
206 206
 
207 207
       // По секциям? images и config? Что бы не копировать конфигурацию? Или просто unset(__inherit) а затем заново записать
208
-      $this->config = parse_ini_file($this->root_physical_absolute . 'skin.ini');
209
-      if(!empty($this->config)) {
208
+      $this->config = parse_ini_file($this->root_physical_absolute.'skin.ini');
209
+      if (!empty($this->config)) {
210 210
 
211 211
         $this->is_ini_present = true;
212 212
 
213
-        if(!empty($this->config['_inherit'])) {
213
+        if (!empty($this->config['_inherit'])) {
214 214
           // Если скин наследует себя...
215
-          if($this->config['_inherit'] == $skin_path) {
215
+          if ($this->config['_inherit'] == $skin_path) {
216 216
             // TODO - определять более сложные случаи циклических ссылок в _inherit
217 217
             die('">circular skin inheritance!');
218 218
           }
219
-          if(empty(static::$skin_list[$this->config['_inherit']])) {
219
+          if (empty(static::$skin_list[$this->config['_inherit']])) {
220 220
             static::$skin_list[$this->config['_inherit']] = new skin($this->config['_inherit']);
221 221
           }
222 222
           $this->parent = static::$skin_list[$this->config['_inherit']];
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
     }
233 233
 
234 234
     // Пытаемся скомпилировать _no_image заранее
235
-    if(!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) {
235
+    if (!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) {
236 236
       $this->container[SKIN_IMAGE_MISSED_FIELD] = $this->compile_try_path(SKIN_IMAGE_MISSED_FIELD, $this->config[SKIN_IMAGE_MISSED_FIELD]);
237 237
     }
238 238
 
239 239
     // Если нет заглушки
240
-    if(empty($this->container[SKIN_IMAGE_MISSED_FIELD])) {
240
+    if (empty($this->container[SKIN_IMAGE_MISSED_FIELD])) {
241 241
       $this->container[SKIN_IMAGE_MISSED_FIELD] = empty($this->parent)
242 242
         // Если нет парента - берем хардкод
243
-        ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL . SKIN_IMAGE_MISSED_FILE_PATH
243
+        ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL.SKIN_IMAGE_MISSED_FILE_PATH
244 244
         // Если есть парент - берем у парента. У предков всегда всё есть
245 245
         : $this->parent->compile_image(SKIN_IMAGE_MISSED_FIELD, null);
246 246
     }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     $image_tag = $this->image_tag_parse($image_tag, $template);
268 268
 
269 269
     // Проверяем наличие ключа RIT в хранилища. В нём не может быть несуществующих файлов по построению
270
-    if(!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) {
270
+    if (!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) {
271 271
       return $this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]];
272 272
     }
273 273
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     // Нет - image ID не является путём к файлу. Пора обратиться к предкам за помощью...
286 286
     // Пытаемся вытащить путь из родителя и применить к нему свои параметры
287 287
     // Тащим по ID изображения, а не по ТЭГУ - мало ли что там делает с путём родитель и как преобразовывает его в строку?
288
-    if(empty($this->container[$image_id]) && !empty($this->parent)) {
288
+    if (empty($this->container[$image_id]) && !empty($this->parent)) {
289 289
       $this->container[$image_id] = $this->parent->compile_image($image_id, $template);
290 290
 
291 291
       // Если у родителя нет картинки - он вернет пустую строку. Тогда нам надо использовать заглушку - свою или родительскую
@@ -306,18 +306,18 @@  discard block
 block discarded – undo
306 306
   protected function image_tag_parse($image_tag, $template) {
307 307
     $image_tag_ptl_resolved = $image_tag;
308 308
     // Есть переменные из темплейта ?
309
-    if(strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) {
309
+    if (strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) {
310 310
       // Что бы лишний раз не запускать регексп
311 311
       // TODO - многоуровневые вложения ?! Надо ли и где их можно применить
312 312
       preg_match_all('#(\[.+?\])#', $image_tag_ptl_resolved, $matches);
313
-      foreach($matches[0] as &$match) {
313
+      foreach ($matches[0] as &$match) {
314 314
         $var_name = str_replace(array('[', ']'), '', $match);
315
-        if(strpos($var_name, '.') !== false) {
315
+        if (strpos($var_name, '.') !== false) {
316 316
           // Вложенная переменная темплейта - на текущем уровне
317 317
           // TODO Вложенная переменная из корня через "!"
318 318
           list($block_name, $block_var) = explode('.', $var_name);
319 319
           isset($template->_block_value[$block_name][$block_var]) ? $image_tag_ptl_resolved = str_replace($match, $template->_block_value[$block_name][$block_var], $image_tag_ptl_resolved) : false;
320
-        } elseif(strpos($var_name, '$') !== false) {
320
+        } elseif (strpos($var_name, '$') !== false) {
321 321
           // Корневой DEFINE
322 322
           $define_name = substr($var_name, 1);
323 323
           isset($template->_tpldata['DEFINE']['.'][$define_name]) ? $image_tag_ptl_resolved = str_replace($match, $template->_tpldata['DEFINE']['.'][$define_name], $image_tag_ptl_resolved) : false;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
       }
329 329
     }
330 330
 
331
-    if(strpos($image_tag_ptl_resolved, '|') !== false) {
331
+    if (strpos($image_tag_ptl_resolved, '|') !== false) {
332 332
       $params = explode('|', $image_tag_ptl_resolved);
333 333
       $image_id = $params[0];
334 334
       unset($params[0]);
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
   protected function compile_try_path($image_id, $file_path) {
359 359
     // Если первый символ пути '/' - значит это путь от HTTP-корня
360 360
     // Откусываем его и пользуем остальное
361
-    $relative_path = strpos($file_path, '/') !== 0 ? $this->root_http_relative . $file_path : substr($file_path, 1);
361
+    $relative_path = strpos($file_path, '/') !== 0 ? $this->root_http_relative.$file_path : substr($file_path, 1);
362 362
 
363
-    return is_file(SN_ROOT_PHYSICAL . $relative_path) ? $this->container[$image_id] = SN_ROOT_VIRTUAL . $relative_path : '';
363
+    return is_file(SN_ROOT_PHYSICAL.$relative_path) ? $this->container[$image_id] = SN_ROOT_VIRTUAL.$relative_path : '';
364 364
   }
365 365
 
366 366
 
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
     $image_string = $this->container[$image_tag];
393 393
 
394 394
     // Нет параметров - просто возвращаем значение по $image_name из контейнера
395
-    if(!empty($params) && is_array($params)) {
395
+    if (!empty($params) && is_array($params)) {
396 396
       // Здесь автоматически произойдёт упорядочивание параметров
397 397
 
398 398
       // Параметр 'html' - выводить изображение в виде HTML-тэга
399
-      if(in_array('html', $params)) {
400
-        $image_tag = $image_tag . '|html';
401
-        $image_string = '<img src="' . $image_string . '" />';
399
+      if (in_array('html', $params)) {
400
+        $image_tag = $image_tag.'|html';
401
+        $image_string = '<img src="'.$image_string.'" />';
402 402
         $this->container[$image_tag] = $image_string;
403 403
       }
404 404
     }
Please login to merge, or discard this patch.
includes/classes/DBLock.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,6 +30,6 @@
 block discarded – undo
30 30
 
31 31
 
32 32
   public function addPlayerLock($table, $playerIdFieldName) {
33
-    $this->lock_player[$table . '-' . $playerIdFieldName] = array($table, $playerIdFieldName);
33
+    $this->lock_player[$table.'-'.$playerIdFieldName] = array($table, $playerIdFieldName);
34 34
   }
35 35
 }
Please login to merge, or discard this patch.
includes/classes/FleetList.php 1 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 = doquery(
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;"
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
       }
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
   public static function dbGetFleetListCurrentTick() {
122 122
     return static::dbGetFleetList(
123 123
       "
124
-    (`fleet_start_time` <= " . SN_TIME_NOW . " AND `fleet_mess` = 0)
124
+    (`fleet_start_time` <= " . SN_TIME_NOW." AND `fleet_mess` = 0)
125 125
     OR
126
-    (`fleet_end_stay` <= " . SN_TIME_NOW . " AND `fleet_end_stay` > 0 AND `fleet_mess` = 0)
126
+    (`fleet_end_stay` <= " . SN_TIME_NOW." AND `fleet_end_stay` > 0 AND `fleet_mess` = 0)
127 127
     OR
128
-    (`fleet_end_time` <= " . SN_TIME_NOW . ")");
128
+    (`fleet_end_time` <= " . SN_TIME_NOW.")");
129 129
   }
130 130
 
131 131
   /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     AND `fleet_end_planet` = {$planet_row['planet']}
146 146
     AND `fleet_end_type`   = {$planet_row['planet_type']}
147 147
     AND `fleet_owner` = {$fleet_owner_id}
148
-    AND `fleet_mission` IN (" . MT_ATTACK . "," . MT_ACS . "," . MT_DESTROY . ")
148
+    AND `fleet_mission` IN (".MT_ATTACK.",".MT_ACS.",".MT_DESTROY.")
149 149
     AND `fleet_mess` = 0"
150 150
     );
151 151
   }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
    * @return static
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
 
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
      * @var Fleet[] $array_of_Fleet
200 200
      */
201 201
     $array_of_Fleet = array();
202
-    if(!empty($fleet_db_list) && $fleet_db_list->count()) {
203
-      foreach($fleet_db_list->_container as $fleet_id => $objFleet) {
202
+    if (!empty($fleet_db_list) && $fleet_db_list->count()) {
203
+      foreach ($fleet_db_list->_container as $fleet_id => $objFleet) {
204 204
         $array_of_Fleet[$fleet_id] = $objFleet;
205 205
       }
206 206
       $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet);
@@ -225,16 +225,16 @@  discard block
 block discarded – undo
225 225
     return static::dbGetFleetList(
226 226
       "(
227 227
       fleet_start_galaxy = {$galaxy}
228
-      AND fleet_start_system = {$system}" .
229
-      ($planet ? " AND fleet_start_planet = {$planet}" : '') .
230
-      ($planet_type != PT_ALL ? " AND fleet_start_type = {$planet_type}" : '') .
231
-      ($for_phalanx ? '' : " AND fleet_mess = 1") .
228
+      AND fleet_start_system = {$system}".
229
+      ($planet ? " AND fleet_start_planet = {$planet}" : '').
230
+      ($planet_type != PT_ALL ? " AND fleet_start_type = {$planet_type}" : '').
231
+      ($for_phalanx ? '' : " AND fleet_mess = 1").
232 232
       ") OR (
233 233
       fleet_end_galaxy = {$galaxy}
234
-      AND fleet_end_system = {$system}" .
235
-      ($planet ? " AND fleet_end_planet = {$planet}" : '') .
236
-      ($planet_type != PT_ALL ? " AND fleet_end_type = {$planet_type} " : '') .
237
-      ($for_phalanx ? '' : " AND fleet_mess = 0") .
234
+      AND fleet_end_system = {$system}".
235
+      ($planet ? " AND fleet_end_planet = {$planet}" : '').
236
+      ($planet_type != PT_ALL ? " AND fleet_end_type = {$planet_type} " : '').
237
+      ($for_phalanx ? '' : " AND fleet_mess = 0").
238 238
       ")"
239 239
     );
240 240
   }
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
    */
247 247
   public function dbMergeMissileList($where) {
248 248
     $query = doquery(
249
-      "SELECT * FROM `{{iraks}}`" .
250
-      (!empty($where) ? " WHERE {$where}" : '') .
249
+      "SELECT * FROM `{{iraks}}`".
250
+      (!empty($where) ? " WHERE {$where}" : '').
251 251
       " FOR UPDATE;");
252
-    while($missile_db_row = db_fetch($query)) {
252
+    while ($missile_db_row = db_fetch($query)) {
253 253
       /**
254 254
        * @var Fleet $objFleet
255 255
        */
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
    */
272 272
   public static function dbGetFleetListAndMissileINCOMING($owner_id) {
273 273
     $owner_id_safe = idval($owner_id);
274
-    if(empty($owner_id_safe)) {
274
+    if (empty($owner_id_safe)) {
275 275
       return array();
276 276
     }
277 277
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
    */
306 306
   public static function fleet_count_flying($player_id, $mission_id = 0) {
307 307
     $player_id_safe = idval($player_id);
308
-    if(!empty($player_id_safe)) {
308
+    if (!empty($player_id_safe)) {
309 309
       $mission_id_safe = intval($mission_id);
310 310
       $result = static::db_fleet_count(
311
-        "`fleet_owner` = {$player_id_safe}" .
311
+        "`fleet_owner` = {$player_id_safe}".
312 312
         ($mission_id_safe ? " AND `fleet_mission` = {$mission_id_safe}" : '')
313 313
       );
314 314
     } else {
Please login to merge, or discard this patch.
includes/template.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 function gettemplatename($u_dpath) {
11 11
   static $template_names = array();
12 12
 
13
-  if(!isset($template_names[$u_dpath])) {
14
-    $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') : TEMPLATE_NAME;
13
+  if (!isset($template_names[$u_dpath])) {
14
+    $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL.$u_dpath.'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL.$u_dpath.'tmpl.ini') : TEMPLATE_NAME;
15 15
   }
16 16
 
17 17
   return $template_names[$u_dpath];
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
  * @param $sn_menu_extra
53 53
  */
54 54
 function tpl_menu_merge_extra(&$sn_menu, &$sn_menu_extra) {
55
-  if(empty($sn_menu) || empty($sn_menu_extra)) {
55
+  if (empty($sn_menu) || empty($sn_menu_extra)) {
56 56
     return;
57 57
   }
58 58
 
59
-  foreach($sn_menu_extra as $menu_item_id => $menu_item) {
60
-    if(empty($menu_item['LOCATION'])) {
59
+  foreach ($sn_menu_extra as $menu_item_id => $menu_item) {
60
+    if (empty($menu_item['LOCATION'])) {
61 61
       $sn_menu[$menu_item_id] = $menu_item;
62 62
       continue;
63 63
     }
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
     unset($menu_item['LOCATION']);
67 67
 
68 68
     $is_positioned = $item_location[0];
69
-    if($is_positioned == '+' || $is_positioned == '-') {
69
+    if ($is_positioned == '+' || $is_positioned == '-') {
70 70
       $item_location = substr($item_location, 1);
71 71
     } else {
72 72
       $is_positioned = '';
73 73
     }
74 74
 
75
-    if($item_location) {
75
+    if ($item_location) {
76 76
       $menu_keys = array_keys($sn_menu);
77 77
       $insert_position = array_search($item_location, $menu_keys);
78
-      if($insert_position === false) {
78
+      if ($insert_position === false) {
79 79
         $insert_position = count($sn_menu) - 1;
80 80
         $is_positioned = '+';
81 81
         $item_location = '';
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     $spliced = array_splice($sn_menu, $insert_position, count($sn_menu) - $insert_position);
89 89
     $sn_menu[$menu_item_id] = $menu_item;
90 90
 
91
-    if(!$is_positioned && $item_location) {
91
+    if (!$is_positioned && $item_location) {
92 92
       unset($spliced[$item_location]);
93 93
     }
94 94
     $sn_menu = array_merge($sn_menu, $spliced);
@@ -102,24 +102,24 @@  discard block
 block discarded – undo
102 102
  * @param template $template
103 103
  */
104 104
 function tpl_menu_assign_to_template(&$sn_menu, &$template) {
105
-  if(empty($sn_menu) || !is_array($sn_menu)) {
105
+  if (empty($sn_menu) || !is_array($sn_menu)) {
106 106
     return;
107 107
   }
108 108
 
109
-  foreach($sn_menu as $menu_item_id => $menu_item) {
110
-    if(!$menu_item) {
109
+  foreach ($sn_menu as $menu_item_id => $menu_item) {
110
+    if (!$menu_item) {
111 111
       continue;
112 112
     }
113 113
 
114
-    if(is_string($menu_item_id)) {
114
+    if (is_string($menu_item_id)) {
115 115
       $menu_item['ID'] = $menu_item_id;
116 116
     }
117 117
 
118
-    if($menu_item['TYPE'] == 'lang') {
118
+    if ($menu_item['TYPE'] == 'lang') {
119 119
       $lang_string = &classLocale::$lang;
120
-      if(preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) {
121
-        for($i = 1; $i < count($matches); $i++) {
122
-          if(defined($matches[$i])) {
120
+      if (preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) {
121
+        for ($i = 1; $i < count($matches); $i++) {
122
+          if (defined($matches[$i])) {
123 123
             $matches[$i] = constant($matches[$i]);
124 124
           }
125 125
           $lang_string = &$lang_string[$matches[$i]];
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
     $menu_item['ALT'] = htmlentities($menu_item['ALT']);
132 132
     $menu_item['TITLE'] = htmlentities($menu_item['TITLE']);
133 133
 
134
-    if(!empty($menu_item['ICON'])) {
135
-      if(is_string($menu_item['ICON'])) {
134
+    if (!empty($menu_item['ICON'])) {
135
+      if (is_string($menu_item['ICON'])) {
136 136
         $menu_item['ICON_PATH'] = $menu_item['ICON'];
137 137
       } else {
138 138
         $menu_item['ICON'] = $menu_item_id;
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
     'USER_AUTHLEVEL_NAME' => classLocale::$lang['user_level'][$user['authlevel']],
160 160
 //    'USER_IMPERSONATOR'   => $template_result[F_IMPERSONATE_STATUS] != LOGIN_UNDEFINED,
161 161
     'PAYMENT'             => sn_module_get_active_count('payment'),
162
-    'MENU_START_HIDE'     => !empty($_COOKIE[SN_COOKIE . '_menu_hidden']) || defined('SN_GOOGLE'),
162
+    'MENU_START_HIDE'     => !empty($_COOKIE[SN_COOKIE.'_menu_hidden']) || defined('SN_GOOGLE'),
163 163
   ));
164 164
 
165
-  if(isset($template_result['MENU_CUSTOMIZE'])) {
165
+  if (isset($template_result['MENU_CUSTOMIZE'])) {
166 166
     $template->assign_vars(array(
167 167
       'PLAYER_OPTION_MENU_SHOW_ON_BUTTON'   => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON],
168 168
       'PLAYER_OPTION_MENU_HIDE_ON_BUTTON'   => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON],
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
       'PLAYER_OPTION_MENU_ITEMS_AS_BUTTONS' => classSupernova::$user_options[PLAYER_OPTION_MENU_ITEMS_AS_BUTTONS],
172 172
       'PLAYER_OPTION_MENU_WHITE_TEXT'       => classSupernova::$user_options[PLAYER_OPTION_MENU_WHITE_TEXT],
173 173
       'PLAYER_OPTION_MENU_OLD'              => classSupernova::$user_options[PLAYER_OPTION_MENU_OLD],
174
-      'PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON' => empty($_COOKIE[SN_COOKIE . '_menu_hidden']) && !defined('SN_GOOGLE')
174
+      'PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON' => empty($_COOKIE[SN_COOKIE.'_menu_hidden']) && !defined('SN_GOOGLE')
175 175
         ? classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON] : 1,
176 176
     ));
177 177
   }
178 178
 
179
-  if(defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) {
179
+  if (defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) {
180 180
     tpl_menu_merge_extra($sn_menu_admin, $sn_menu_admin_extra);
181 181
     tpl_menu_assign_to_template($sn_menu_admin, $template);
182 182
   } else {
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
   $in_admin = defined('IN_ADMIN') && IN_ADMIN === true;
217 217
   $is_login = defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true;
218 218
 
219
-  if(is_object($page)) {
219
+  if (is_object($page)) {
220 220
     isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false;
221 221
     isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false;
222 222
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false;
225 225
   }
226 226
 
227
-  if(empty($user['id']) || !is_numeric($user['id'])) {
227
+  if (empty($user['id']) || !is_numeric($user['id'])) {
228 228
     $isDisplayMenu = false;
229 229
     $isDisplayTopNav = false;
230 230
   }
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
   $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0);
237 237
 
238 238
   $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE];
239
-  if(strpos($font_size, '%') !== false) {
239
+  if (strpos($font_size, '%') !== false) {
240 240
     // Размер шрифта в процентах
241
-    $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%';
242
-  } elseif(strpos($font_size, 'px') !== false) {
241
+    $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX).'%';
242
+  } elseif (strpos($font_size, 'px') !== false) {
243 243
     // Размер шрифта в пикселях
244
-    $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px';
244
+    $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX).'px';
245 245
   } else {
246 246
     // Не мышонка, не лягушка...
247 247
     $font_size = FONT_SIZE_PERCENT_DEFAULT_STRING;
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 
252 252
   $template = gettemplate('_global_header', true);
253 253
 
254
-  if(!empty(classSupernova::$sn_mvc['javascript'])) {
255
-    foreach(classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) {
256
-      if(empty($page_name) || $page_name == $sn_page_name) {
257
-        foreach($script_list as $filename => $content) {
254
+  if (!empty(classSupernova::$sn_mvc['javascript'])) {
255
+    foreach (classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) {
256
+      if (empty($page_name) || $page_name == $sn_page_name) {
257
+        foreach ($script_list as $filename => $content) {
258 258
           $template_result['.']['javascript'][] = array(
259 259
             'FILE'    => $filename,
260 260
             'CONTENT' => $content,
@@ -272,17 +272,17 @@  discard block
 block discarded – undo
272 272
   $is_login ? $standard_css['design/css/login.min.css'] = '' : false;
273 273
   $standard_css += array(
274 274
 //    'design/css/design/css/global-ie.min.css' => '', // TODO
275
-    TEMPLATE_PATH . '/_template.min.css'                                  => '',
276
-    ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'skin.min.css' => '',
275
+    TEMPLATE_PATH.'/_template.min.css'                                  => '',
276
+    ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH).'skin.min.css' => '',
277 277
   );
278 278
 
279 279
   // Prepending standard CSS files
280 280
   classSupernova::$sn_mvc['css'][''] = array_merge($standard_css, classSupernova::$sn_mvc['css']['']);
281 281
 
282 282
 
283
-  foreach(classSupernova::$sn_mvc['css'] as $page_name => $script_list) {
284
-    if(empty($page_name) || $page_name == $sn_page_name) {
285
-      foreach($script_list as $filename => $content) {
283
+  foreach (classSupernova::$sn_mvc['css'] as $page_name => $script_list) {
284
+    if (empty($page_name) || $page_name == $sn_page_name) {
285
+      foreach ($script_list as $filename => $content) {
286 286
         $template_result['.']['css'][] = array(
287 287
           'FILE'    => $filename,
288 288
           'CONTENT' => $content,
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     ), // Проводить замер только если не выставлен флаг форсированного замера И (иссяк интервал замера ИЛИ замера еще не было)
310 310
     //'TIME_UTC_OFFSET'          => defined('SN_CLIENT_TIME_UTC_OFFSET') ? SN_CLIENT_TIME_UTC_OFFSET : '',
311 311
 
312
-    'title'                    => ($title ? "{$title} - " : '') . classLocale::$lang['sys_server'] . " {$classConfig->game_name} - " . classLocale::$lang['sys_supernova'],
312
+    'title'                    => ($title ? "{$title} - " : '').classLocale::$lang['sys_server']." {$classConfig->game_name} - ".classLocale::$lang['sys_supernova'],
313 313
     '-meta-'                   => $metatags,
314 314
     'ADV_SEO_META_DESCRIPTION' => classSupernova::$config->adv_seo_meta_description,
315 315
     'ADV_SEO_META_KEYWORDS'    => classSupernova::$config->adv_seo_meta_keywords,
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
   $template->assign_recursive($template_result);
330 330
   displayP(parsetemplate($template));
331 331
 
332
-  if(($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) {
332
+  if (($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) {
333 333
     // $AdminPage = $AdminPage ? $user['authlevel'] : 0;
334 334
     displayP(parsetemplate(tpl_render_menu()));
335 335
   }
336 336
 
337
-  if($isDisplayTopNav && !$in_admin) {
337
+  if ($isDisplayTopNav && !$in_admin) {
338 338
     displayP(parsetemplate(tpl_render_topnav($user, $planetrow)));
339 339
   }
340 340
 
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 
343 343
   !is_array($page) ? $page = array($page) : false;
344 344
   $result_added = false;
345
-  foreach($page as $page_item) {
346
-    if(!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
345
+  foreach ($page as $page_item) {
346
+    if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
347 347
       $page_item = gettemplate('_result_message', $page_item);
348 348
       $temp = $page_item->files['_result_message'];
349 349
       unset($page_item->files['_result_message']);
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
   ));
367 367
   displayP(parsetemplate($template));
368 368
 
369
-  $user['authlevel'] >= 3 && classSupernova::$config->debug ? classSupernova::$debug->echo_log() : false;;
369
+  $user['authlevel'] >= 3 && classSupernova::$config->debug ? classSupernova::$debug->echo_log() : false; ;
370 370
 
371 371
   classSupernova::$db->db_disconnect();
372 372
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
  * @param string         $type
405 405
  */
406 406
 function tpl_topnav_event_build(&$template, $FleetList, $type = 'fleet') {
407
-  if(empty($FleetList)) {
407
+  if (empty($FleetList)) {
408 408
     return;
409 409
   }
410 410
 
@@ -413,19 +413,19 @@  discard block
 block discarded – undo
413 413
   $fleet_event_count = 0;
414 414
   $fleet_flying_sorter = array();
415 415
   $fleet_flying_events = array();
416
-  foreach($FleetList->_container as $objFleet) {
416
+  foreach ($FleetList->_container as $objFleet) {
417 417
     $will_return = true;
418
-    if(!$objFleet->isReturning()) {
418
+    if (!$objFleet->isReturning()) {
419 419
       // cut fleets on Hold and Expedition
420
-      if($objFleet->time_arrive_to_target >= SN_TIME_NOW) {
420
+      if ($objFleet->time_arrive_to_target >= SN_TIME_NOW) {
421 421
         $objFleet->mission_type == MT_RELOCATE ? $will_return = false : false;
422 422
         tpl_topnav_event_build_helper($objFleet->time_arrive_to_target, EVENT_FLEET_ARRIVE, classLocale::$lang['sys_event_arrive'], $objFleet->target_coordinates_typed(), !$will_return, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
423 423
       }
424
-      if($objFleet->time_mission_job_complete) {
424
+      if ($objFleet->time_mission_job_complete) {
425 425
         tpl_topnav_event_build_helper($objFleet->time_mission_job_complete, EVENT_FLEET_STAY, classLocale::$lang['sys_event_stay'], $objFleet->target_coordinates_typed(), false, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
426 426
       }
427 427
     }
428
-    if($will_return) {
428
+    if ($will_return) {
429 429
       tpl_topnav_event_build_helper($objFleet->time_return_to_source, EVENT_FLEET_RETURN, classLocale::$lang['sys_event_return'], $objFleet->launch_coordinates_typed(), true, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
430 430
     }
431 431
   }
@@ -433,12 +433,12 @@  discard block
 block discarded – undo
433 433
   asort($fleet_flying_sorter);
434 434
 
435 435
   $fleet_flying_count = $FleetList->count();
436
-  foreach($fleet_flying_sorter as $fleet_event_id => $fleet_time) {
436
+  foreach ($fleet_flying_sorter as $fleet_event_id => $fleet_time) {
437 437
     $fleet_event = &$fleet_flying_events[$fleet_event_id];
438 438
     $template->assign_block_vars("flying_{$type}s", array(
439 439
       'TIME' => max(0, $fleet_time - SN_TIME_NOW),
440 440
       'TEXT' => $fleet_flying_count,
441
-      'HINT' => date(FMT_DATE_TIME, $fleet_time + SN_CLIENT_TIME_DIFF) . " - {$classLocale['sys_fleet']} {$fleet_event['TEXT']} {$fleet_event['COORDINATES']} {$classLocale['sys_planet_type_sh'][$fleet_event['COORDINATES_TYPE']]} {$classLocale['type_mission'][$fleet_event['OBJECT']->mission_type]}",
441
+      'HINT' => date(FMT_DATE_TIME, $fleet_time + SN_CLIENT_TIME_DIFF)." - {$classLocale['sys_fleet']} {$fleet_event['TEXT']} {$fleet_event['COORDINATES']} {$classLocale['sys_planet_type_sh'][$fleet_event['COORDINATES_TYPE']]} {$classLocale['type_mission'][$fleet_event['OBJECT']->mission_type]}",
442 442
     ));
443 443
     $fleet_event['DECREASE'] ? $fleet_flying_count-- : false;
444 444
   }
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
   global $template_result;
463 463
   $classLocale = classLocale::$lang;
464 464
 
465
-  if(!is_array($user)) {
465
+  if (!is_array($user)) {
466 466
     return '';
467 467
   }
468 468
 
@@ -483,8 +483,8 @@  discard block
 block discarded – undo
483 483
 
484 484
   $ThisUsersPlanets = db_planet_list_sorted($user);
485 485
   // while ($CurPlanet = db_fetch($ThisUsersPlanets))
486
-  foreach($ThisUsersPlanets as $CurPlanet) {
487
-    if($CurPlanet['destruyed']) {
486
+  foreach ($ThisUsersPlanets as $CurPlanet) {
487
+    if ($CurPlanet['destruyed']) {
488 488
       continue;
489 489
     }
490 490
 
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
    */
509 509
   $fleet_flying_list = array();
510 510
   $fleet_flying_list[0] = FleetList::dbGetFleetListByOwnerId($user['id']);
511
-  foreach($fleet_flying_list[0]->_container as $fleet_id => $objFleet) {
512
-    if(empty($fleet_flying_list[$objFleet->mission_type])) {
511
+  foreach ($fleet_flying_list[0]->_container as $fleet_id => $objFleet) {
512
+    if (empty($fleet_flying_list[$objFleet->mission_type])) {
513 513
       $fleet_flying_list[$objFleet->mission_type] = new FleetList();
514 514
     }
515 515
     $fleet_flying_list[$objFleet->mission_type][$fleet_id] = $objFleet;
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
   que_tpl_parse($template, QUE_RESEARCH, $user, array(), null, !classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE]);
522 522
   que_tpl_parse($template, SUBQUE_FLEET, $user, $planetrow, null, true);
523 523
 
524
-  if(!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) {
525
-    foreach(classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) {
524
+  if (!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) {
525
+    foreach (classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) {
526 526
       $template->assign_block_vars('navbar_prefix_button', array(
527 527
         'IMAGE'        => $navbar_button_image,
528 528
         'URL_RELATIVE' => $navbar_button_url,
@@ -536,13 +536,13 @@  discard block
 block discarded – undo
536 536
   $time_now_parsed = getdate(SN_TIME_NOW);
537 537
   $time_local_parsed = getdate(defined('SN_CLIENT_TIME_LOCAL') ? SN_CLIENT_TIME_LOCAL : SN_TIME_NOW);
538 538
 
539
-  if(classSupernova::$config->game_news_overview) {
539
+  if (classSupernova::$config->game_news_overview) {
540 540
     $user_last_read_safe = intval($user['news_lastread']);
541 541
     nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`) >= {$user_last_read_safe}", classSupernova::$config->game_news_overview);
542 542
   }
543 543
 
544 544
   $notes_query = db_note_list_by_owner($user['id'], true);
545
-  while($note_row = db_fetch($notes_query)) {
545
+  while ($note_row = db_fetch($notes_query)) {
546 546
     note_assign($template, $note_row);
547 547
   }
548 548
 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
     'QUE_ID'   => QUE_RESEARCH,
557 557
     'QUE_HTML' => 'topnav',
558 558
 
559
-    'RESEARCH_ONGOING' => (boolean)$user['que'],
559
+    'RESEARCH_ONGOING' => (boolean) $user['que'],
560 560
 
561 561
     'TIME_TEXT'       => sprintf($str_date_format, $time_now_parsed['year'], classLocale::$lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'],
562 562
       $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds']
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
     'QUE_STRUCTURES' => QUE_STRUCTURES,
634 634
   ));
635 635
 
636
-  if((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) {
636
+  if ((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) {
637 637
     tpl_set_resource_info($template, $planetrow);
638 638
     $template->assign_vars(array(
639 639
       'SN_RENDER_NAVBAR_PLANET' => true,
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
  * @param template|string $template
649 649
  */
650 650
 function displayP($template) {
651
-  if(is_object($template)) {
652
-    if(empty($template->parsed)) {
651
+  if (is_object($template)) {
652
+    if (empty($template->parsed)) {
653 653
       parsetemplate($template);
654 654
     }
655 655
 
656
-    foreach($template->files as $section => $filename) {
656
+    foreach ($template->files as $section => $filename) {
657 657
       $template->display($section);
658 658
     }
659 659
   } else {
@@ -668,11 +668,11 @@  discard block
 block discarded – undo
668 668
  * @return mixed
669 669
  */
670 670
 function parsetemplate($template, $array = false) {
671
-  if(is_object($template)) {
671
+  if (is_object($template)) {
672 672
     global $user;
673 673
 
674
-    if(!empty($array) && is_array($array)) {
675
-      foreach($array as $key => $data) {
674
+    if (!empty($array) && is_array($array)) {
675
+      foreach ($array as $key => $data) {
676 676
         $template->assign_var($key, $data);
677 677
       }
678 678
     }
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 
714 714
   $template_ex = '.tpl.html';
715 715
 
716
-  if($template === false) {
717
-    return sys_file_read(TEMPLATE_DIR . '/' . $files . $template_ex);
716
+  if ($template === false) {
717
+    return sys_file_read(TEMPLATE_DIR.'/'.$files.$template_ex);
718 718
   }
719 719
 
720 720
   is_string($files) ? $files = array(basename($files) => $files) : false;
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
   //$template->set_custom_template($template_path ? $template_path : TEMPLATE_DIR, TEMPLATE_NAME, TEMPLATE_DIR);
724 724
 
725 725
   $tmpl_name = gettemplatename($user['dpath']);
726
-  $template->set_custom_template(($template_path ? $template_path : SN_ROOT_PHYSICAL . 'design/templates/') . $tmpl_name . '/', $tmpl_name, TEMPLATE_DIR);
726
+  $template->set_custom_template(($template_path ? $template_path : SN_ROOT_PHYSICAL.'design/templates/').$tmpl_name.'/', $tmpl_name, TEMPLATE_DIR);
727 727
 
728 728
   // TODO ГРЯЗНЫЙ ХАК! Это нужно, что бы по возможности перезаписать инфу из языковых пакетов модулей там, где она была перезаписана раньше инфой из основного пакета. Почему?
729 729
   //  - сначала грузятся модули и их языковые пакеты
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
   !empty(classSupernova::$sn_mvc['i18n']['']) ? lng_load_i18n(classSupernova::$sn_mvc['i18n']['']) : false;
734 734
   $sn_page_name ? lng_load_i18n(classSupernova::$sn_mvc['i18n'][$sn_page_name]) : false;
735 735
 
736
-  foreach($files as &$filename) {
737
-    $filename = $filename . $template_ex;
736
+  foreach ($files as &$filename) {
737
+    $filename = $filename.$template_ex;
738 738
   }
739 739
 
740 740
   $template->set_filenames($files);
@@ -756,15 +756,15 @@  discard block
 block discarded – undo
756 756
 
757 757
   $template->assign_vars($q = array(
758 758
     'LANG'     => $language ? $language : '',
759
-    'referral' => $id_ref ? '&id_ref=' . $id_ref : '',
759
+    'referral' => $id_ref ? '&id_ref='.$id_ref : '',
760 760
 
761
-    'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''),
761
+    'REQUEST_PARAMS' => !empty($url_params) ? '?'.implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''),
762 762
     'FILENAME'       => basename($_SERVER['PHP_SELF']),
763 763
   ));
764 764
 
765
-  foreach(lng_get_list() as $lng_id => $lng_data) {
766
-    if(isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) {
767
-      foreach($lng_data['LANG_VARIANTS'] as $lang_variant) {
765
+  foreach (lng_get_list() as $lng_id => $lng_data) {
766
+    if (isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) {
767
+      foreach ($lng_data['LANG_VARIANTS'] as $lang_variant) {
768 768
         $lng_data1 = $lng_data;
769 769
         $lng_data1 = array_merge($lng_data1, $lang_variant);
770 770
         $template->assign_block_vars('language', $lng_data1);
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
   $que = $que['ques'][$que_type][$planet['id_owner']][$planet['id']];
788 788
 
789 789
   $que_length = 0;
790
-  if(!empty($que)) {
791
-    foreach($que as $que_item) {
790
+  if (!empty($que)) {
791
+    foreach ($que as $que_item) {
792 792
       $template->assign_block_vars('que', que_tpl_parse_element($que_item));
793 793
     }
794 794
     $que_length = count($que);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
  * @param int      $user_dark_matter
804 804
  */
805 805
 function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter) {
806
-  foreach($density_price_chart as $density_price_index => &$density_price_data) {
806
+  foreach ($density_price_chart as $density_price_index => &$density_price_data) {
807 807
     $density_cost = $density_price_data;
808 808
     $density_number_style = pretty_number($density_cost, true, $user_dark_matter, false, false);
809 809
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 function tpl_assign_select(&$template, $name, $values) {
828 828
   !is_array($values) ? $values = array($values => $values) : false;
829 829
 
830
-  foreach($values as $key => $value) {
830
+  foreach ($values as $key => $value) {
831 831
     $template->assign_block_vars($name, array(
832 832
       'KEY'   => htmlentities($key, ENT_COMPAT, 'UTF-8'),
833 833
       'VALUE' => htmlentities($value, ENT_COMPAT, 'UTF-8'),
Please login to merge, or discard this patch.
includes/alliance/ali_info.inc 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,37 +1,37 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
4 4
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
5 5
 }
6 6
 
7 7
 $template = gettemplate('ali_info', true);
8 8
 
9
-if($mode == 'exit') {
10
-  if($ally['ally_owner'] == $user['id']) {
9
+if ($mode == 'exit') {
10
+  if ($ally['ally_owner'] == $user['id']) {
11 11
     message(classLocale::$lang['Owner_cant_go_out'], classLocale::$lang['Alliance']);
12 12
   }
13 13
 
14
-  if(sys_get_param_int('ali_info_leave_confirm')) {
14
+  if (sys_get_param_int('ali_info_leave_confirm')) {
15 15
     sn_db_transaction_start();
16 16
     db_user_set_by_id($user['id'], "`ally_id` = null, `ally_name` = null, `ally_tag` = null, `ally_register_time` = 0, `ally_rank_id` = 0");
17 17
     db_ally_list_recalc_counts();
18 18
     sn_db_transaction_commit();
19 19
     message(sprintf(classLocale::$lang['ali_info_leave_success'], $ally['ally_name']), classLocale::$lang['sys_alliance']);
20 20
   }
21
-} elseif($mode == 'ainfo') {
21
+} elseif ($mode == 'ainfo') {
22 22
   $tag = sys_get_param_str('tag');
23 23
   $id_ally = sys_get_param_id('a');
24
-  if($tag) {
24
+  if ($tag) {
25 25
     $ally = db_ally_get_by_tag($tag);
26
-  } elseif($id_ally) {
26
+  } elseif ($id_ally) {
27 27
     $ally = db_ally_get_by_id($id_ally);
28 28
   }
29 29
 
30
-  if(!$ally) {
30
+  if (!$ally) {
31 31
     message(classLocale::$lang['ali_sys_notFound'], classLocale::$lang['Ally_info_1']);
32 32
   }
33 33
 
34
-  if(!$ally['ally_description']) {
34
+  if (!$ally['ally_description']) {
35 35
     $ally['ally_description'] = classLocale::$lang['Ally_nodescription'];
36 36
   }
37 37
 
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 } else {
44 44
   $page_header = classLocale::$lang['your_alliance'];
45 45
 
46
-  if($ally['ally_owner'] == $user['id']) {
46
+  if ($ally['ally_owner'] == $user['id']) {
47 47
     $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : classLocale::$lang['Founder'];
48
-  } elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) {
48
+  } elseif ($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) {
49 49
     $range = $ranks[$user['ally_rank_id']]['name'];
50 50
   } else {
51 51
     $range = classLocale::$lang['member'];
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 ));
87 87
 
88 88
 $relations = ali_relations($ally['id']);
89
-foreach($relations as $relation) {
90
-  if($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) {
89
+foreach ($relations as $relation) {
90
+  if ($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) {
91 91
     $template->assign_block_vars('relation', array(
92 92
       'NAME'     => $relation['alliance_diplomacy_contr_ally_name'],
93 93
       'RELATION' => classLocale::$lang['ali_dip_relations'][$relation['alliance_diplomacy_relation']],
@@ -106,4 +106,4 @@  discard block
 block discarded – undo
106 106
 
107 107
 ali_render();
108 108
 
109
-display($template, classLocale::$lang['your_alliance'] . ' [' . $ally['ally_name'] . ']');
109
+display($template, classLocale::$lang['your_alliance'].' ['.$ally['ally_name'].']');
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_rights.inc 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
4 4
 {
5 5
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
6 6
 }
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 $new_rank_name = sys_get_param_str('newRankName');
15 15
 if ($new_rank_name)
16 16
 {
17
-  foreach($ally_rights as $fieldName)
17
+  foreach ($ally_rights as $fieldName)
18 18
   {
19 19
     $newRank[$fieldName] = 0;
20 20
   }
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 {
29 29
   unset($ranks);
30 30
 
31
-  foreach($rankListInput as $rankID => $rank)
31
+  foreach ($rankListInput as $rankID => $rank)
32 32
   {
33
-    foreach($ally_rights as $rightName)
33
+    foreach ($ally_rights as $rightName)
34 34
     {
35 35
       $ranks[$rankID][$rightName] = $rank[$rightName] ? 1 : 0;
36 36
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 $d = sys_get_param_int('d');
42 42
 if ($d && isset($ranks[$d]))
43 43
 {
44
-  if(count($ranks) == 1)
44
+  if (count($ranks) == 1)
45 45
   {
46 46
     message(classLocale::$lang['ali_adm_lastRank'], classLocale::$lang['ali_adm_rights_title']);
47 47
   }
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 
54 54
 if (count($ranks))
55 55
 {
56
-  foreach($ranks as $rankID => $rank)
56
+  foreach ($ranks as $rankID => $rank)
57 57
   {
58 58
     $rank_data = array(
59 59
       'ID'   => $rankID,
60 60
       'NAME' => $rank['name'],
61 61
     );
62 62
 
63
-    for($i = 1; $i < count($rank); $i++)
63
+    for ($i = 1; $i < count($rank); $i++)
64 64
     {
65
-      $rank_data['R' . $i] = (($rank[$ally_rights[$i]] == 1) ? ' checked' : '') ;
66
-      $rank_data['N' . $i] = $ally_rights[$i];
65
+      $rank_data['R'.$i] = (($rank[$ally_rights[$i]] == 1) ? ' checked' : '');
66
+      $rank_data['N'.$i] = $ally_rights[$i];
67 67
     }
68 68
 
69 69
     $template->assign_block_vars('rank', $rank_data);
Please login to merge, or discard this patch.