Test Failed
Branch trunk (c9c94d)
by SuperNova.WS
10:03 queued 05:45
created
index.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,14 +5,14 @@
 block discarded – undo
5 5
  */
6 6
 global $template;
7 7
 
8
-if(isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) {
8
+if (isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) {
9 9
   require_once('common.' . substr(strrchr(__FILE__, '.'), 1));
10
-  if($sn_page_name) {
10
+  if ($sn_page_name) {
11 11
     // Loading page-specific language files
12 12
 
13 13
     !empty($sn_mvc['model'][$sn_page_name]) and execute_hooks($sn_mvc['model'][$sn_page_name], $template, 'model', $sn_page_name);
14 14
     !empty($sn_mvc['view'][$sn_page_name]) and execute_hooks($sn_mvc['view'][$sn_page_name], $template, 'view', $sn_page_name);
15
-    if(!empty($template_result) && is_object($template)) {
15
+    if (!empty($template_result) && is_object($template)) {
16 16
       $template->assign_recursive($template_result);
17 17
     }
18 18
 
Please login to merge, or discard this patch.
classes/Common/GlobalContainer.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -65,55 +65,55 @@
 block discarded – undo
65 65
 
66 66
     // Services --------------------------------------------------------------------------------------------------------
67 67
     // Default db
68
-    $gc->db = function (GlobalContainer $c) {
68
+    $gc->db = function(GlobalContainer $c) {
69 69
       classSupernova::$db = new \db_mysql($c);
70 70
 
71 71
       return classSupernova::$db;
72 72
     };
73 73
 
74
-    $gc->debug = function (GlobalContainer $c) {
74
+    $gc->debug = function(GlobalContainer $c) {
75 75
       return new \debug();
76 76
     };
77 77
 
78
-    $gc->cache = function (GlobalContainer $gc) {
78
+    $gc->cache = function(GlobalContainer $gc) {
79 79
       return new \classCache($gc->cachePrefix);
80 80
     };
81 81
 
82
-    $gc->config = function (GlobalContainer $gc) {
82
+    $gc->config = function(GlobalContainer $gc) {
83 83
       return new \classConfig($gc->cachePrefix);
84 84
     };
85 85
 
86 86
 
87
-    $gc->repository = function (GlobalContainer $gc) {
87
+    $gc->repository = function(GlobalContainer $gc) {
88 88
       return new \Repository($gc);
89 89
     };
90 90
 
91
-    $gc->storage = function (GlobalContainer $gc) {
91
+    $gc->storage = function(GlobalContainer $gc) {
92 92
       return new \Storage($gc);
93 93
     };
94 94
 
95
-    $gc->design = function (GlobalContainer $gc) {
95
+    $gc->design = function(GlobalContainer $gc) {
96 96
       return new \Design($gc);
97 97
     };
98 98
 
99
-    $gc->bbCodeParser = function (GlobalContainer $gc) {
99
+    $gc->bbCodeParser = function(GlobalContainer $gc) {
100 100
       return new \BBCodeParser($gc);
101 101
     };
102 102
 
103 103
 
104 104
     // Dummy objects ---------------------------------------------------------------------------------------------------
105
-    $gc->theUser = function (GlobalContainer $gc) {
105
+    $gc->theUser = function(GlobalContainer $gc) {
106 106
       return new \TheUser($gc);
107 107
     };
108 108
 
109 109
 
110 110
     // Models ----------------------------------------------------------------------------------------------------------
111 111
     $gc->skinEntityClass = 'SkinV2';
112
-    $gc->skinModel = function (GlobalContainer $gc) {
112
+    $gc->skinModel = function(GlobalContainer $gc) {
113 113
       return new \SkinModel($gc);
114 114
     };
115 115
 
116
-    $gc->textModel = function (GlobalContainer $gc) {
116
+    $gc->textModel = function(GlobalContainer $gc) {
117 117
       return new \TextModel($gc);
118 118
     };
119 119
 
Please login to merge, or discard this patch.
classes/classSupernova.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 
182 182
   public static function log_file($message, $spaces = 0) {
183
-    if(self::$debug) {
183
+    if (self::$debug) {
184 184
       self::$debug->log_file($message, $spaces);
185 185
     }
186 186
   }
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
   // Перепаковывает массив на заданную глубину, убирая поля с null
189 189
   public static function array_repack(&$array, $level = 0) {
190 190
     // TODO $lock_table не нужна тут
191
-    if(!is_array($array)) return;
191
+    if (!is_array($array)) return;
192 192
 
193
-    foreach($array as $key => &$value) {
194
-      if($value === null) {
193
+    foreach ($array as $key => &$value) {
194
+      if ($value === null) {
195 195
         unset($array[$key]);
196
-      } elseif($level > 0 && is_array($value)) {
196
+      } elseif ($level > 0 && is_array($value)) {
197 197
         static::array_repack($value, $level - 1);
198
-        if(empty($value)) unset($array[$key]);
198
+        if (empty($value)) unset($array[$key]);
199 199
       }
200 200
     }
201 201
   }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
   // TODO Вынести в отдельный объект
205 205
   public static function cache_repack($location_type, $record_id = 0) {
206 206
     // Если есть $user_id - проверяем, а надо ли перепаковывать?
207
-    if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) return;
207
+    if ($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) return;
208 208
 
209 209
     static::array_repack(static::$data[$location_type]);
210 210
     static::array_repack(static::$locator[$location_type], 3); // TODO У каждого типа локации - своя глубина!!!! Но можно и глубже ???
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
   }
213 213
   public static function cache_clear($location_type, $hard = true) {
214 214
     //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />");
215
-    if($hard && !empty(static::$data[$location_type])) {
215
+    if ($hard && !empty(static::$data[$location_type])) {
216 216
       // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях
217
-      array_walk(static::$data[$location_type], function(&$item){$item = null;});
217
+      array_walk(static::$data[$location_type], function(&$item) {$item = null; });
218 218
     }
219 219
     static::$locator[$location_type] = array();
220 220
     static::$queries[$location_type] = array();
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
   }
223 223
   public static function cache_clear_all($hard = true) {
224 224
     //print('<br />CACHE CLEAR ALL<br />');
225
-    if($hard) {
225
+    if ($hard) {
226 226
       static::$data = array();
227 227
       static::cache_lock_unset_all();
228 228
     }
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
   */
250 250
   public static function cache_set($location_type, $record_id, $record, $force_overwrite = false, $skip_lock = false) {
251 251
     // нет идентификатора - выход
252
-    if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) return;
252
+    if (!($record_id = $record[static::$location_info[$location_type][P_ID]])) return;
253 253
 
254 254
     $in_transaction = static::db_transaction_check(false);
255
-    if(
255
+    if (
256 256
       $force_overwrite
257 257
       ||
258 258
       // Не заменяются заблокированные записи во время транзакции
@@ -262,14 +262,14 @@  discard block
 block discarded – undo
262 262
       !static::cache_isset($location_type, $record_id)
263 263
     ) {
264 264
       static::$data[$location_type][$record_id] = $record;
265
-      if($in_transaction && !$skip_lock) {
265
+      if ($in_transaction && !$skip_lock) {
266 266
         static::cache_lock_set($location_type, $record_id);
267 267
       }
268 268
     }
269 269
   }
270 270
   public static function cache_unset($cache_id, $safe_record_id) {
271 271
     // $record_id должен быть проверен заранее !
272
-    if(isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) {
272
+    if (isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) {
273 273
       // Выставляем запись в null
274 274
       static::$data[$cache_id][$safe_record_id] = null;
275 275
       // Очищаем кэш мягко - что бы удалить очистить связанные данные - кэш локаций и кэш запоросов и всё, что потребуется впредь
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
     return static::$locks[$location_type][$record_id] = true; // Не всегда - от результата
284 284
   }
285 285
   public static function cache_lock_unset($location_type, $record_id) {
286
-    if(isset(static::$locks[$location_type][$record_id]))
286
+    if (isset(static::$locks[$location_type][$record_id]))
287 287
       unset(static::$locks[$location_type][$record_id]);
288 288
     return true; // Не всегда - от результата
289 289
   }
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
    */
314 314
   public static function db_transaction_check($status = null) {
315 315
     $error_msg = false;
316
-    if($status && !static::$db_in_transaction) {
316
+    if ($status && !static::$db_in_transaction) {
317 317
       $error_msg = 'No transaction started for current operation';
318
-    } elseif($status === null && static::$db_in_transaction) {
318
+    } elseif ($status === null && static::$db_in_transaction) {
319 319
       $error_msg = 'Transaction is already started';
320 320
     }
321 321
 
322
-    if($error_msg) {
322
+    if ($error_msg) {
323 323
       // TODO - Убрать позже
324 324
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>');
325 325
       $backtrace = debug_backtrace();
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     static::$transaction_id++;
341 341
     doquery('START TRANSACTION');
342 342
 
343
-    if($config->db_manual_lock_enabled) {
343
+    if ($config->db_manual_lock_enabled) {
344 344
       $config->db_loadItem('var_db_manually_locked');
345 345
       $config->db_saveItem('var_db_manually_locked', SN_TIME_SQL);
346 346
     }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
    */
383 383
   public static function db_lock_tables($tables) {
384 384
     $tables = is_array($tables) ? $tables : array($tables => '');
385
-    foreach($tables as $table_name => $condition) {
385
+    foreach ($tables as $table_name => $condition) {
386 386
       self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
387 387
     }
388 388
   }
@@ -431,14 +431,14 @@  discard block
 block discarded – undo
431 431
   public static function db_get_record_list($location_type, $filter = '', $fetch = false, $no_return = false) {
432 432
     $query_cache = &static::$queries[$location_type][$filter];
433 433
 
434
-    if(!isset($query_cache) || $query_cache === null) {
434
+    if (!isset($query_cache) || $query_cache === null) {
435 435
       $location_info = &static::$location_info[$location_type];
436 436
       $id_field = $location_info[P_ID];
437 437
       $query_cache = array();
438 438
 
439
-      if(static::db_transaction_check(false)) {
439
+      if (static::db_transaction_check(false)) {
440 440
         // Проходим по всем родителям данной записи
441
-        foreach($location_info[P_OWNER_INFO] as $owner_data) {
441
+        foreach ($location_info[P_OWNER_INFO] as $owner_data) {
442 442
           $owner_location_type = $owner_data[P_LOCATION];
443 443
           $parent_id_list = array();
444 444
           // Выбираем родителей данного типа и соответствующие ИД текущего типа
@@ -452,14 +452,14 @@  discard block
 block discarded – undo
452 452
             true
453 453
           );
454 454
 
455
-          while($row = db_fetch($query)) {
455
+          while ($row = db_fetch($query)) {
456 456
             // Исключаем из списка родительских ИД уже заблокированные записи
457
-            if(!static::cache_lock_get($owner_location_type, $row['parent_id']))
457
+            if (!static::cache_lock_get($owner_location_type, $row['parent_id']))
458 458
               $parent_id_list[$row['parent_id']] = $row['parent_id'];
459 459
           }
460 460
 
461 461
           // Если все-таки какие-то записи еще не заблокированы - вынимаем текущие версии из базы
462
-          if($indexes_str = implode(',', $parent_id_list)) {
462
+          if ($indexes_str = implode(',', $parent_id_list)) {
463 463
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
464 464
             static::db_get_record_list($owner_location_type,
465 465
               $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
@@ -470,20 +470,20 @@  discard block
 block discarded – undo
470 470
       $query = static::db_query_select(
471 471
         "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . (($filter = trim($filter)) ? " WHERE {$filter}" : '')
472 472
       );
473
-      while($row = db_fetch($query)) {
473
+      while ($row = db_fetch($query)) {
474 474
         static::cache_set($location_type, $row[$id_field], $row);
475 475
         $query_cache[$row[$id_field]] = &static::$data[$location_type][$row[$id_field]];
476 476
       }
477 477
     }
478 478
 
479
-    if($no_return) {
479
+    if ($no_return) {
480 480
       return true;
481 481
     } else {
482 482
       $result = false;
483
-      if(is_array($query_cache)) {
484
-        foreach($query_cache as $key => $value) {
483
+      if (is_array($query_cache)) {
484
+        foreach ($query_cache as $key => $value) {
485 485
           $result[$key] = $value;
486
-          if($fetch) break;
486
+          if ($fetch) break;
487 487
         }
488 488
       }
489 489
       return $fetch ? (is_array($result) ? reset($result) : false) : $result;
@@ -491,14 +491,14 @@  discard block
 block discarded – undo
491 491
   }
492 492
 
493 493
   public static function db_upd_record_by_id($location_type, $record_id, $set) {
494
-    if(!($record_id = idval($record_id)) || !($set = trim($set))) return false;
494
+    if (!($record_id = idval($record_id)) || !($set = trim($set))) return false;
495 495
 
496 496
     $location_info = &static::$location_info[$location_type];
497 497
     $id_field = $location_info[P_ID];
498 498
     $table_name = $location_info[P_TABLE_NAME];
499
-    if($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
499
+    if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
500 500
     {
501
-      if(static::$db->db_affected_rows()) {
501
+      if (static::$db->db_affected_rows()) {
502 502
         // Обновляем данные только если ряд был затронут
503 503
         // TODO - переделать под работу со структурированными $set
504 504
 
@@ -513,14 +513,14 @@  discard block
 block discarded – undo
513 513
     return $result;
514 514
   }
515 515
   public static function db_upd_record_list($location_type, $condition, $set) {
516
-    if(!($set = trim($set))) return false;
516
+    if (!($set = trim($set))) return false;
517 517
 
518 518
     $condition = trim($condition);
519 519
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
520 520
 
521
-    if($result = static::db_query_update("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
521
+    if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
522 522
 
523
-      if(static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
523
+      if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
524 524
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
525 525
         // TODO - когда будет структурированный $condition и $set - перепаковывать данные
526 526
         static::cache_clear($location_type, true);
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
   public static function db_ins_record($location_type, $set) {
534 534
     $set = trim($set);
535 535
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
536
-    if($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
537
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
536
+    if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
537
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
538 538
       {
539 539
         $record_id = db_insert_id();
540 540
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
 
551 551
   public static function db_del_record_by_id($location_type, $safe_record_id)
552 552
   {
553
-    if(!($safe_record_id = idval($safe_record_id))) return false;
553
+    if (!($safe_record_id = idval($safe_record_id))) return false;
554 554
 
555 555
     $location_info = &static::$location_info[$location_type];
556 556
     $id_field = $location_info[P_ID];
557 557
     $table_name = $location_info[P_TABLE_NAME];
558
-    if($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}"))
558
+    if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}"))
559 559
     {
560
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
560
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
561 561
       {
562 562
         static::cache_unset($location_type, $safe_record_id);
563 563
       }
@@ -567,14 +567,14 @@  discard block
 block discarded – undo
567 567
   }
568 568
   public static function db_del_record_list($location_type, $condition)
569 569
   {
570
-    if(!($condition = trim($condition))) return false;
570
+    if (!($condition = trim($condition))) return false;
571 571
 
572 572
     $location_info = &static::$location_info[$location_type];
573 573
     $table_name = $location_info[P_TABLE_NAME];
574 574
 
575
-    if($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}"))
575
+    if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}"))
576 576
     {
577
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
577
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
578 578
       {
579 579
         // Обнуление кэша, потому что непонятно, что поменялось
580 580
         static::cache_clear($location_type);
@@ -620,21 +620,21 @@  discard block
 block discarded – undo
620 620
   public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false)
621 621
   {
622 622
     // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ?
623
-    if(!($username_unsafe = trim($username_unsafe))) return false;
623
+    if (!($username_unsafe = trim($username_unsafe))) return false;
624 624
 
625 625
     $user = null;
626
-    if(is_array(static::$data[LOC_USER]))
627
-    foreach(static::$data[LOC_USER] as $user_id => $user_data)
626
+    if (is_array(static::$data[LOC_USER]))
627
+    foreach (static::$data[LOC_USER] as $user_id => $user_data)
628 628
     {
629
-      if(is_array($user_data) && isset($user_data['username']))
629
+      if (is_array($user_data) && isset($user_data['username']))
630 630
       {
631 631
         // проверяем поле
632 632
         // TODO Возможно есть смысл всегда искать по strtolower - но может игрок захочет переименоваться с другим регистром? Проверить!
633
-        if((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe)))
633
+        if ((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe)))
634 634
         {
635 635
           // $user_as_ally = intval($user_data['user_as_ally']);
636 636
           $user_as_ally = idval($user_data['user_as_ally']);
637
-          if($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally))
637
+          if ($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally))
638 638
           {
639 639
             $user = $user_data;
640 640
             break;
@@ -643,13 +643,13 @@  discard block
 block discarded – undo
643 643
       }
644 644
     }
645 645
 
646
-    if($user === null)
646
+    if ($user === null)
647 647
     {
648 648
       // Вытаскиваем запись
649 649
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
650 650
 
651 651
       $user = static::db_query_select(
652
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '='). " '{$username_safe}'",
652
+        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'",
653 653
         true
654 654
       );
655 655
       static::cache_set(LOC_USER, $user['id'], $user); // В кэш-юзер так же заполнять индексы
@@ -659,14 +659,14 @@  discard block
 block discarded – undo
659 659
   }
660 660
   // UNUSED
661 661
   public static function db_get_user_by_email($email_unsafe, $use_both = false, $for_update = false, $fields = '*') {
662
-    if(!($email_unsafe = strtolower(trim($email_unsafe)))) return false;
662
+    if (!($email_unsafe = strtolower(trim($email_unsafe)))) return false;
663 663
 
664 664
     $user = null;
665
-    if(is_array(static::$data[LOC_USER])) {
666
-      foreach(static::$data[LOC_USER] as $user_id => $user_data) {
667
-        if(is_array($user_data) && isset($user_data['email_2'])) {
665
+    if (is_array(static::$data[LOC_USER])) {
666
+      foreach (static::$data[LOC_USER] as $user_id => $user_data) {
667
+        if (is_array($user_data) && isset($user_data['email_2'])) {
668 668
           // проверяем поле
669
-          if(strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) {
669
+          if (strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) {
670 670
             $user = $user_data;
671 671
             break;
672 672
           }
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
       }
675 675
     }
676 676
 
677
-    if($user === null) {
677
+    if ($user === null) {
678 678
       // Вытаскиваем запись
679 679
       $email_safe = db_escape($email_unsafe);
680 680
       $user = static::db_query_select(
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     $user = null;
692 692
     // TODO переделать на индексы
693 693
 
694
-    if($user === null && !empty($where_safe)) {
694
+    if ($user === null && !empty($where_safe)) {
695 695
       // Вытаскиваем запись
696 696
       $user = static::db_query_select(
697 697
         "SELECT * FROM {{users}} WHERE {$where_safe}",
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
   {
730 730
     // TODO запихивать в $data[LOC_LOCATION][$location_type][$location_id]
731 731
     $unit = static::db_get_record_by_id(LOC_UNIT, $unit_id, $for_update, $fields);
732
-    if(is_array($unit))
732
+    if (is_array($unit))
733 733
     {
734 734
       static::$locator[LOC_UNIT][$unit['unit_location_type']][$unit['unit_location_id']][$unit['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
735 735
     }
@@ -739,15 +739,15 @@  discard block
 block discarded – undo
739 739
 
740 740
   public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id)
741 741
   {
742
-    if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) return false;
742
+    if (!($location_type = idval($location_type)) || !($location_id = idval($location_id))) return false;
743 743
 
744 744
     $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id];
745
-    if(!isset($query_cache))
745
+    if (!isset($query_cache))
746 746
     {
747 747
       $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions());
748
-      if(is_array($got_data))
748
+      if (is_array($got_data))
749 749
       {
750
-        foreach($got_data as $unit_id => $unit_data)
750
+        foreach ($got_data as $unit_id => $unit_data)
751 751
         {
752 752
           // static::$data[LOC_LOCATION][$location_type][$location_id][$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
753 753
           $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
@@ -756,8 +756,8 @@  discard block
 block discarded – undo
756 756
     }
757 757
 
758 758
     $result = false;
759
-    if(is_array($query_cache)) {
760
-      foreach($query_cache as $key => $value) {
759
+    if (is_array($query_cache)) {
760
+      foreach ($query_cache as $key => $value) {
761 761
         $result[$key] = $value;
762 762
       }
763 763
     }
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
    */
796 796
   public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false)
797 797
   {
798
-    if(!$user_id)
798
+    if (!$user_id)
799 799
     {
800 800
       pdump(debug_backtrace());
801 801
       die('No user_id for que_get_que()');
@@ -805,14 +805,14 @@  discard block
 block discarded – undo
805 805
 
806 806
     $query = array();
807 807
 
808
-    if($user_id = idval($user_id))
808
+    if ($user_id = idval($user_id))
809 809
       $query[] = "`que_player_id` = {$user_id}";
810 810
 
811
-    if($que_type == QUE_RESEARCH || $planet_id === null)
811
+    if ($que_type == QUE_RESEARCH || $planet_id === null)
812 812
       $query[] = "`que_planet_id` IS NULL";
813
-    elseif($planet_id)
813
+    elseif ($planet_id)
814 814
       $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
815
-    if($que_type)
815
+    if ($que_type)
816 816
       $query[] = "`que_type` = {$que_type}";
817 817
 
818 818
     $ques['items'] = static::db_get_record_list(LOC_QUE, implode(' AND ', $query));
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
   }
937 937
 
938 938
 
939
-  public static function init_0_prepare () {
939
+  public static function init_0_prepare() {
940 940
     $dbsettings = array();
941 941
 
942 942
     require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
   }
974 974
 
975 975
   public static function init_debug_state() {
976
-    if($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) {
976
+    if ($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) {
977 977
       define('BE_DEBUG', true);
978 978
     }
979 979
     // define('DEBUG_SQL_ONLINE', true); // Полный дамп запросов в рил-тайме. Подойдет любое значение
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
     defined('DEBUG_SQL_ERROR') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false;
986 986
     defined('DEBUG_SQL_COMMENT_LONG') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false;
987 987
 
988
-    if(defined('BE_DEBUG') || static::$config->debug) {
988
+    if (defined('BE_DEBUG') || static::$config->debug) {
989 989
       @define('BE_DEBUG', true);
990 990
       @ini_set('display_errors', 1);
991 991
       @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
Please login to merge, or discard this patch.
classes/sn_module.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
     // Trying to load configuration from file
105 105
     $config_exists = false;
106 106
     // Конфигурация может лежать в config_path в манифеста или в корне модуля
107
-    if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
107
+    if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
108 108
       $config_exists = true;
109
-    } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) {
109
+    } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) {
110 110
       $config_exists = true;
111 111
     }
112 112
 
113
-    if($config_exists) {
113
+    if ($config_exists) {
114 114
       include($config_filename);
115 115
       $module_config_array = $class_module_name . '_config';
116 116
       $this->config = $$module_config_array;
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
   }
122 122
 
123 123
   protected function __patch_menu(&$sn_menu_extra, &$menu_patch) {
124
-    if(isset($menu_patch) && is_array($menu_patch) && !empty($menu_patch)) {
125
-      foreach($menu_patch as $menu_item_name => $menu_item_data) {
124
+    if (isset($menu_patch) && is_array($menu_patch) && !empty($menu_patch)) {
125
+      foreach ($menu_patch as $menu_item_name => $menu_item_data) {
126 126
         $sn_menu_extra[$menu_item_name] = $menu_item_data;
127 127
       }
128 128
     }
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
   public function initialize() {
133 133
     // Checking module status - is it installed and active
134 134
     $this->check_status();
135
-    if(!$this->manifest['active']) {
135
+    if (!$this->manifest['active']) {
136 136
       return;
137 137
     }
138 138
 
139 139
     // Setting constants - if any
140
-    if(isset($this->manifest['constants']) && is_array($this->manifest['constants']) && !empty($this->manifest['constants'])) {
141
-      foreach($this->manifest['constants'] as $constant_name => $constant_value) {
140
+    if (isset($this->manifest['constants']) && is_array($this->manifest['constants']) && !empty($this->manifest['constants'])) {
141
+      foreach ($this->manifest['constants'] as $constant_name => $constant_value) {
142 142
         defined($constant_name) or define($constant_name, $constant_value);
143 143
       }
144 144
     }
@@ -149,34 +149,34 @@  discard block
 block discarded – undo
149 149
     // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays)
150 150
     // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]'
151 151
     $this->manifest['vars'] = $this->__assign_vars();
152
-    if(!empty($this->manifest['vars'])) {
152
+    if (!empty($this->manifest['vars'])) {
153 153
       $vars_assigned = array();
154
-      foreach($this->manifest['vars'] as $var_name => $var_value) {
154
+      foreach ($this->manifest['vars'] as $var_name => $var_value) {
155 155
         $sub_vars = explode('[', str_replace(']', '', $var_name));
156 156
         $var_name = $sub_vars[0];
157 157
 
158
-        if(!isset($vars_assigned[$var_name])) {
158
+        if (!isset($vars_assigned[$var_name])) {
159 159
           $vars_assigned[$var_name] = true;
160 160
           global $$var_name;
161 161
         }
162 162
 
163 163
         $pointer = &$$var_name;
164
-        if(($n = count($sub_vars)) > 1) {
165
-          for($i = 1; $i < $n; $i++) {
166
-            if(defined($sub_vars[$i])) {
164
+        if (($n = count($sub_vars)) > 1) {
165
+          for ($i = 1; $i < $n; $i++) {
166
+            if (defined($sub_vars[$i])) {
167 167
               $sub_vars[$i] = constant($sub_vars[$i]);
168 168
             }
169 169
 
170
-            if(!isset($pointer[$sub_vars[$i]]) && $i != $n) {
170
+            if (!isset($pointer[$sub_vars[$i]]) && $i != $n) {
171 171
               $pointer[$sub_vars[$i]] = array();
172 172
             }
173 173
             $pointer = &$pointer[$sub_vars[$i]];
174 174
           }
175 175
         }
176 176
 
177
-        if(!isset($pointer) || !is_array($pointer)) {
177
+        if (!isset($pointer) || !is_array($pointer)) {
178 178
           $pointer = $var_value;
179
-        } elseif(is_array($$var_name)) {
179
+        } elseif (is_array($$var_name)) {
180 180
           $pointer = array_merge_recursive_numeric($pointer, $var_value);
181 181
         }
182 182
       }
@@ -192,50 +192,50 @@  discard block
 block discarded – undo
192 192
     isset($this->manifest['menu_admin']) and $this->__patch_menu($sn_menu_admin_extra, $this->manifest['menu_admin']);
193 193
 
194 194
     global $sn_mvc;
195
-    foreach($sn_mvc as $handler_type => &$handler_data) {
195
+    foreach ($sn_mvc as $handler_type => &$handler_data) {
196 196
       sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type);
197 197
     }
198 198
 
199
-    if(isset($this->manifest['i18n']) && is_array($this->manifest['i18n']) && !empty($this->manifest['i18n'])) {
200
-      foreach($this->manifest['i18n'] as $i18n_page_name => &$i18n_file_list) {
201
-        foreach($i18n_file_list as &$i18n_file_data) {
202
-          if(is_array($i18n_file_data) && !$i18n_file_data['path']) {
199
+    if (isset($this->manifest['i18n']) && is_array($this->manifest['i18n']) && !empty($this->manifest['i18n'])) {
200
+      foreach ($this->manifest['i18n'] as $i18n_page_name => &$i18n_file_list) {
201
+        foreach ($i18n_file_list as &$i18n_file_data) {
202
+          if (is_array($i18n_file_data) && !$i18n_file_data['path']) {
203 203
             $i18n_file_data['path'] = $this->manifest['root_relative'];
204 204
           }
205 205
         }
206
-        if(!isset($sn_mvc['i18n'][$i18n_page_name])) {
206
+        if (!isset($sn_mvc['i18n'][$i18n_page_name])) {
207 207
           $sn_mvc['i18n'][$i18n_page_name] = array();
208 208
         }
209 209
         $sn_mvc['i18n'][$i18n_page_name] += $i18n_file_list;
210 210
       }
211 211
     }
212 212
 
213
-    if(!empty($this->manifest['javascript']) && is_array($this->manifest['javascript'])) {
214
-      foreach($this->manifest['javascript'] as $javascript_page_name => &$javascript_list) {
213
+    if (!empty($this->manifest['javascript']) && is_array($this->manifest['javascript'])) {
214
+      foreach ($this->manifest['javascript'] as $javascript_page_name => &$javascript_list) {
215 215
         !isset($sn_mvc['javascript'][$javascript_page_name]) ? $sn_mvc['javascript'][$javascript_page_name] = array() : false;
216
-        foreach($javascript_list as $script_name => &$script_content) {
216
+        foreach ($javascript_list as $script_name => &$script_content) {
217 217
           $sn_mvc['javascript'][$javascript_page_name][$script_name] = $script_content;
218 218
         }
219 219
       }
220 220
     }
221 221
 
222
-    if(!empty($this->manifest['css']) && is_array($this->manifest['css'])) {
223
-      foreach($this->manifest['css'] as $javascript_page_name => &$javascript_list) {
222
+    if (!empty($this->manifest['css']) && is_array($this->manifest['css'])) {
223
+      foreach ($this->manifest['css'] as $javascript_page_name => &$javascript_list) {
224 224
         !isset($sn_mvc['css'][$javascript_page_name]) ? $sn_mvc['css'][$javascript_page_name] = array() : false;
225
-        foreach($javascript_list as $script_name => &$script_content) {
225
+        foreach ($javascript_list as $script_name => &$script_content) {
226 226
           $sn_mvc['css'][$javascript_page_name][$script_name] = $script_content;
227 227
         }
228 228
       }
229 229
     }
230 230
 
231
-    if(!empty($this->manifest['navbar_prefix_button']) && is_array($this->manifest['navbar_prefix_button'])) {
232
-      foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
231
+    if (!empty($this->manifest['navbar_prefix_button']) && is_array($this->manifest['navbar_prefix_button'])) {
232
+      foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
233 233
         $sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative;
234 234
       }
235 235
     }
236 236
 
237
-    if(!empty($this->manifest['navbar_main_button']) && is_array($this->manifest['navbar_main_button'])) {
238
-      foreach($this->manifest['navbar_main_button'] as $button_image => $button_url_relative) {
237
+    if (!empty($this->manifest['navbar_main_button']) && is_array($this->manifest['navbar_main_button'])) {
238
+      foreach ($this->manifest['navbar_main_button'] as $button_image => $button_url_relative) {
239 239
         $sn_mvc['navbar_main_button'][$button_image] = $button_url_relative;
240 240
       }
241 241
     }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
    */
252 252
   protected function __mvcRegisterPagesOld($pages) {
253 253
     !is_array($this->manifest['mvc']['pages']) ? $this->manifest['mvc']['pages'] = array() : false;
254
-    if(is_array($pages) && !empty($pages)) {
254
+    if (is_array($pages) && !empty($pages)) {
255 255
       $this->manifest['mvc']['pages'] = array_merge($this->manifest['mvc']['pages'], $pages);
256 256
     }
257 257
   }
Please login to merge, or discard this patch.
classes/AjaxController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     define('IN_AJAX', true);
23 23
 
24
-    if(!is_object($template)) {
24
+    if (!is_object($template)) {
25 25
       $template = gettemplate('_ajax', true);
26 26
     }
27 27
 
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
 
38 38
     $mode = sys_get_param_str('mode');
39 39
 
40
-    if(class_exists($className = 'Pages\\Page' . ucfirst($mode))) {
40
+    if (class_exists($className = 'Pages\\Page' . ucfirst($mode))) {
41 41
       /**
42 42
        * @var \Pages\IPage $page
43 43
        */
44 44
       $page = new $className();
45
-      if(method_exists($page, 'loadParams')) {
45
+      if (method_exists($page, 'loadParams')) {
46 46
         $page->loadParams();
47 47
       }
48 48
 
49
-      if(method_exists($page, $action = sys_get_param('action')) && $page->checkAction($action)) {
49
+      if (method_exists($page, $action = sys_get_param('action')) && $page->checkAction($action)) {
50 50
         $result = $page->$action();
51 51
         is_array($result) ? HelperArray::merge($template_result['AJAX'], $result) : false;
52 52
       }
Please login to merge, or discard this patch.
classes/PTLTag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
     $this->raw = $stringTag;
50 50
 
51 51
     // Separating params - so there are will be no false-positives for template's variable names
52
-    if(strpos($this->raw, '|') !== false) {
52
+    if (strpos($this->raw, '|') !== false) {
53 53
       $this->params = explode('|', $this->raw);
54 54
       $this->resolved = $this->params[0];
55 55
       unset($this->params[0]);
Please login to merge, or discard this patch.
classes/Pages/PageQuest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
       QUEST_STATUS_COMPLETE => '',
32 32
     );
33 33
 
34
-    if(!isset($statuses[$this->filterQuestStatus])) {
34
+    if (!isset($statuses[$this->filterQuestStatus])) {
35 35
       $this->filterQuestStatus = QUEST_STATUS_ALL;
36 36
     }
37 37
   }
Please login to merge, or discard this patch.
classes/TextModel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
       }
102 102
     }
103 103
 
104
-    if(!isset($next)) {
104
+    if (!isset($next)) {
105 105
       $next = new TextEntity();
106 106
     }
107 107
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
       $prev = $this->getById($currentText->prev);
120 120
     }
121 121
 
122
-    if(!isset($prev)) {
122
+    if (!isset($prev)) {
123 123
       $prev = new TextEntity();
124 124
     }
125 125
 
Please login to merge, or discard this patch.
classes/debug.php 1 patch
Spacing   +38 added lines, -39 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * que esperabas!!! soy newbie!!! D':<
25 25
 */
26 26
 
27
-if(!defined('INSIDE')) {
27
+if (!defined('INSIDE')) {
28 28
   die("attemp hacking");
29 29
 }
30 30
 
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
   function log_file($message, $ident_change = 0) {
38 38
     static $ident = 0;
39 39
 
40
-    if(!defined('SN_DEBUG_LOG')) {
40
+    if (!defined('SN_DEBUG_LOG')) {
41 41
       return;
42 42
     }
43 43
 
44
-    if($this->log_file_handler === null) {
44
+    if ($this->log_file_handler === null) {
45 45
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
46 46
       @fwrite($this->log_file_handler, "\r\n\r\n");
47 47
     }
48 48
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
49
-    if($this->log_file_handler) {
49
+    if ($this->log_file_handler) {
50 50
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
51 51
     }
52 52
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     $result = array();
82 82
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
83 83
     $result[] = "tID {$transaction_id}";
84
-    foreach($backtrace as $a_trace) {
85
-      if(in_array($a_trace['function'], $exclude_functions)) {
84
+    foreach ($backtrace as $a_trace) {
85
+      if (in_array($a_trace['function'], $exclude_functions)) {
86 86
         continue;
87 87
       }
88 88
       $function =
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
100 100
 
101
-      if(!$long_comment) {
101
+      if (!$long_comment) {
102 102
         break;
103 103
       }
104 104
     }
@@ -107,26 +107,26 @@  discard block
 block discarded – undo
107 107
   }
108 108
 
109 109
   function dump($dump = false, $force_base = false, $deadlock = false) {
110
-    if($dump === false) {
110
+    if ($dump === false) {
111 111
       return;
112 112
     }
113 113
 
114 114
     $error_backtrace = array();
115 115
     $base_dump = false;
116 116
 
117
-    if($force_base === true) {
117
+    if ($force_base === true) {
118 118
       $base_dump = true;
119 119
     }
120 120
 
121
-    if($dump === true) {
121
+    if ($dump === true) {
122 122
       $base_dump = true;
123 123
     } else {
124
-      if(!is_array($dump)) {
124
+      if (!is_array($dump)) {
125 125
         $dump = array('var' => $dump);
126 126
       }
127 127
 
128
-      foreach($dump as $dump_var_name => $dump_var) {
129
-        if($dump_var_name == 'base_dump') {
128
+      foreach ($dump as $dump_var_name => $dump_var) {
129
+        if ($dump_var_name == 'base_dump') {
130 130
           $base_dump = $dump_var;
131 131
         } else {
132 132
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -134,26 +134,25 @@  discard block
 block discarded – undo
134 134
       }
135 135
     }
136 136
 
137
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
137
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
138 138
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
139 139
       $error_backtrace['locks'] = classSupernova::$locks;
140 140
       $error_backtrace['cSN_data'] = classSupernova::$data;
141
-      foreach($error_backtrace['cSN_data'] as &$location) {
142
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
141
+      foreach ($error_backtrace['cSN_data'] as &$location) {
142
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
143 143
         {
144
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
145
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
144
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
146 145
         }
147 146
       }
148 147
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
149 148
     }
150 149
 
151
-    if($base_dump) {
152
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
150
+    if ($base_dump) {
151
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
153 152
         ;
154 153
       }
155 154
       {
156
-        foreach($this->log_array as $log) {
155
+        foreach ($this->log_array as $log) {
157 156
           $error_backtrace['queries'][] = $log;
158 157
         }
159 158
       }
@@ -184,14 +183,14 @@  discard block
 block discarded – undo
184 183
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
185 184
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
186 185
 
187
-    if(empty(classSupernova::$db->connected)) {
186
+    if (empty(classSupernova::$db->connected)) {
188 187
       // TODO - писать ошибку в файл
189 188
       die('SQL server currently unavailable. Please contact Administration...');
190 189
     }
191 190
 
192 191
     sn_db_transaction_rollback();
193 192
 
194
-    if(classSupernova::$config->debug == 1) {
193
+    if (classSupernova::$config->debug == 1) {
195 194
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
196 195
       echo "<table>{$this->log}</table>";
197 196
     }
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
     $error_text = db_escape($message);
202 201
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
203 202
 
204
-    if(!$sys_log_disabled) {
203
+    if (!$sys_log_disabled) {
205 204
       $query = "INSERT INTO `{{logs}}` SET
206 205
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($user['id']) . "',
207 206
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -219,7 +218,7 @@  discard block
 block discarded – undo
219 218
       ob_start();
220 219
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
221 220
 
222
-      foreach($error_backtrace as $name => $value) {
221
+      foreach ($error_backtrace as $name => $value) {
223 222
         print('<hr>');
224 223
         pdump($value, $name);
225 224
       }
@@ -231,14 +230,14 @@  discard block
 block discarded – undo
231 230
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
232 231
     global $user, $lang, $sys_log_disabled;
233 232
 
234
-    if(empty(classSupernova::$db->connected)) {
233
+    if (empty(classSupernova::$db->connected)) {
235 234
       // TODO - писать ошибку в файл
236 235
       die('SQL server currently unavailable. Please contact Administration...');
237 236
     }
238 237
 
239 238
     $error_backtrace = $this->dump($dump, false);
240 239
 
241
-    if(!$sys_log_disabled) {
240
+    if (!$sys_log_disabled) {
242 241
       $query = "INSERT INTO `{{logs}}` SET
243 242
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($user['id']) . "',
244 243
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -256,11 +255,11 @@  discard block
 block discarded – undo
256 255
 // Dump variables nicer then var_dump()
257 256
 
258 257
 function dump($value, $varname = null, $level = 0, $dumper = '') {
259
-  if(isset($varname)) {
258
+  if (isset($varname)) {
260 259
     $varname .= " = ";
261 260
   }
262 261
 
263
-  if($level == -1) {
262
+  if ($level == -1) {
264 263
     $trans[' '] = '&there4;';
265 264
     $trans["\t"] = '&rArr;';
266 265
     $trans["\n"] = '&para;;';
@@ -269,7 +268,7 @@  discard block
 block discarded – undo
269 268
 
270 269
     return strtr(htmlspecialchars($value), $trans);
271 270
   }
272
-  if($level == 0) {
271
+  if ($level == 0) {
273 272
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
274 273
     $dumper = mt_rand(10, 99) . '|' . $varname;
275 274
   }
@@ -277,22 +276,22 @@  discard block
 block discarded – undo
277 276
   $type = gettype($value);
278 277
   $dumper .= $type;
279 278
 
280
-  if($type == 'string') {
279
+  if ($type == 'string') {
281 280
     $dumper .= '(' . strlen($value) . ')';
282 281
     $value = dump($value, '', -1);
283
-  } elseif($type == 'boolean') {
282
+  } elseif ($type == 'boolean') {
284 283
     $value = ($value ? 'true' : 'false');
285
-  } elseif($type == 'object') {
284
+  } elseif ($type == 'object') {
286 285
     $props = get_class_vars(get_class($value));
287 286
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
288
-    foreach($props as $key => $val) {
287
+    foreach ($props as $key => $val) {
289 288
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
290 289
       $dumper .= dump($value->$key, '', $level + 1);
291 290
     }
292 291
     $value = '';
293
-  } elseif($type == 'array') {
292
+  } elseif ($type == 'array') {
294 293
     $dumper .= '(' . count($value) . ')';
295
-    foreach($value as $key => $val) {
294
+    foreach ($value as $key => $val) {
296 295
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
297 296
       $dumper .= dump($val, '', $level + 1);
298 297
     }
@@ -312,7 +311,7 @@  discard block
 block discarded – undo
312 311
 //  $backtrace = $backtrace[1];
313 312
 
314 313
   $caller = '';
315
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
314
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
316 315
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
317 316
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
318 317
       $backtrace[1]['function'] .
@@ -339,7 +338,7 @@  discard block
 block discarded – undo
339 338
 }
340 339
 
341 340
 function pr($prePrint = false) {
342
-  if($prePrint) {
341
+  if ($prePrint) {
343 342
     print("<br>");
344 343
   }
345 344
   print(mt_rand() . "<br>");
@@ -349,7 +348,7 @@  discard block
 block discarded – undo
349 348
   global $_PRINT_COUNT_VALUE;
350 349
   $_PRINT_COUNT_VALUE++;
351 350
 
352
-  if($prePrint) {
351
+  if ($prePrint) {
353 352
     print("<br>");
354 353
   }
355 354
   print($_PRINT_COUNT_VALUE . "<br>");
Please login to merge, or discard this patch.