Completed
Push — work-fleets ( 2bd11a...17dd3b )
by SuperNova.WS
06:36
created
includes/classes/auth_local.php 1 patch
Doc Comments   +7 added lines, -1 removed lines patch added patch discarded remove patch
@@ -134,7 +134,6 @@  discard block
 block discarded – undo
134 134
   /**
135 135
    * Попытка залогиниться с использованием метода $method
136 136
    *
137
-   * @param string $method_name
138 137
    */
139 138
   public function login() {
140 139
     // TODO Проверяем поддерживаемость метода
@@ -162,6 +161,10 @@  discard block
 block discarded – undo
162 161
    * @return array|bool|resource
163 162
    */
164 163
   // OK v4.5
164
+
165
+  /**
166
+   * @param string $salt_unsafe
167
+   */
165 168
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
166 169
     $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe);
167 170
     if($result) {
@@ -171,6 +174,9 @@  discard block
 block discarded – undo
171 174
     return $result;
172 175
   }
173 176
 
177
+  /**
178
+   * @param Account $account_to_impersonate
179
+   */
174 180
   public function impersonate($account_to_impersonate) {
175 181
     $this->cookie_set($account_to_impersonate);
176 182
   }
Please login to merge, or discard this patch.
includes/classes/classSupernova.php 4 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
   /**
201 201
    * Блокирует указанные таблицу/список таблиц
202 202
    *
203
-   * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
203
+   * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
204 204
    * <p>string - название таблицы для блокировки</p>
205 205
    * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p>
206 206
    */
@@ -377,6 +377,9 @@  discard block
 block discarded – undo
377 377
     return $result;
378 378
   }
379 379
 
380
+  /**
381
+   * @param integer $location_type
382
+   */
380 383
   public static function db_ins_field_set($location_type, $field_set, $serialize = false) {
381 384
     // TODO multiinsert
382 385
     !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false;
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 use Vector\Vector;
4
-
5 4
 use Common\GlobalContainer;
6 5
 
7 6
 class classSupernova {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -27 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
   public static function db_lock_tables($tables) {
208 208
     $tables = is_array($tables) ? $tables : array($tables => '');
209 209
     foreach ($tables as $table_name => $condition) {
210
-      self::$db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
210
+      self::$db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : ''));
211 211
     }
212 212
   }
213 213
 
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
           $query = static::$db->doSelect(
250 250
             "SELECT
251 251
               distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id
252
-            FROM {{{$location_info[P_TABLE_NAME]}}}" .
253
-            ($filter ? ' WHERE ' . $filter : '') .
252
+            FROM {{{$location_info[P_TABLE_NAME]}}}".
253
+            ($filter ? ' WHERE '.$filter : '').
254 254
             ($fetch ? ' LIMIT 1' : ''));
255 255
           while ($row = db_fetch($query)) {
256 256
             // Исключаем из списка родительских ИД уже заблокированные записи
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
           if ($indexes_str = implode(',', $parent_id_list)) {
264 264
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
265 265
             static::db_get_record_list($owner_location_type,
266
-              $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
266
+              $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
267 267
           }
268 268
         }
269 269
       }
270 270
 
271 271
       $query = static::$db->doSelect(
272
-        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" .
272
+        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}".
273 273
         (($filter = trim($filter)) ? " WHERE {$filter}" : '')
274 274
         . " FOR UPDATE"
275 275
       );
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
     $condition = trim($condition);
342 342
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
343 343
 
344
-    if ($result = static::$db->doUpdate("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
344
+    if ($result = static::$db->doUpdate("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) {
345 345
 
346 346
       if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
347 347
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
500 500
 
501 501
       $user = static::$db->doSelectFetch(
502
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"
502
+        "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"
503 503
         . " FOR UPDATE"
504 504
       );
505 505
       SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 
516 516
     if ($user === null && !empty($where_safe)) {
517 517
       // Вытаскиваем запись
518
-      $user = static::$db->doSelectFetch("SELECT * FROM {{users}} WHERE {$where_safe}" . " FOR UPDATE");
518
+      $user = static::$db->doSelectFetch("SELECT * FROM {{users}} WHERE {$where_safe}"." FOR UPDATE");
519 519
 
520 520
       SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы
521 521
     }
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
     }
558 558
 
559 559
     if (SnCache::isUnitLocatorNotSet($location_type, $location_id)) {
560
-      $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());
560
+      $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());
561 561
       if (!empty($got_data) && is_array($got_data)) {
562 562
         foreach ($got_data as $unit_id => $unit_data) {
563 563
           SnCache::setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
     if ($que_type == QUE_RESEARCH || $planet_id === null) {
617 617
       $query[] = "`que_planet_id` IS NULL";
618 618
     } elseif ($planet_id) {
619
-      $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
619
+      $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")";
620 620
     }
621 621
     if ($que_type) {
622 622
       $query[] = "`que_type` = {$que_type}";
@@ -730,13 +730,13 @@  discard block
 block discarded – undo
730 730
         $condition = "`{$field_name}` = ";
731 731
         $value = '';
732 732
         if ($field_data['delta']) {
733
-          $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
733
+          $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta'];
734 734
         } elseif ($field_data['set']) {
735 735
           $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
736 736
         }
737 737
 
738 738
         if ($value) {
739
-          $fields[] = $condition . $value;
739
+          $fields[] = $condition.$value;
740 740
         }
741 741
       }
742 742
       $conditions[P_FIELDS_STR] = implode(',', $fields);
@@ -750,9 +750,7 @@  discard block
 block discarded – undo
750 750
           // Простое условие - $field_id = $field_value
751 751
           if (is_string($field_id)) {
752 752
             $field_value =
753
-              $field_value === null ? 'NULL' :
754
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
755
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
753
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value));
756 754
             $the_conditions[] = "`{$field_id}` = {$field_value}";
757 755
           } else {
758 756
             die('Неподдерживаемый тип условия');
@@ -779,7 +777,7 @@  discard block
 block discarded – undo
779 777
         die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile');
780 778
     }
781 779
 
782
-    $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]);
780
+    $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]);
783 781
   }
784 782
 
785 783
   public static function db_changeset_apply($db_changeset, $flush_delayed = false) {
@@ -866,7 +864,7 @@  discard block
 block discarded – undo
866 864
     ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false;
867 865
     if (@get_magic_quotes_gpc()) {
868 866
       $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
869
-      array_walk_recursive($gpcr, function (&$value, $key) {
867
+      array_walk_recursive($gpcr, function(&$value, $key) {
870 868
         $value = stripslashes($value);
871 869
       });
872 870
     }
@@ -882,43 +880,43 @@  discard block
 block discarded – undo
882 880
     $gc = static::$gc;
883 881
 
884 882
     // Default db
885
-    $gc->db = function ($c) {
883
+    $gc->db = function($c) {
886 884
       $db = new db_mysql($c);
887 885
       $db->sn_db_connect();
888 886
 
889 887
       return $db;
890 888
     };
891 889
 
892
-    $gc->debug = function ($c) {
890
+    $gc->debug = function($c) {
893 891
       return new debug();
894 892
     };
895 893
 
896
-    $gc->cache = function ($c) {
894
+    $gc->cache = function($c) {
897 895
       return new classCache(classSupernova::$cache_prefix);
898 896
     };
899 897
 
900
-    $gc->config = function ($c) {
898
+    $gc->config = function($c) {
901 899
       return new classConfig(classSupernova::$cache_prefix);
902 900
     };
903 901
 
904
-    $gc->localePlayer = function (GlobalContainer $c) {
902
+    $gc->localePlayer = function(GlobalContainer $c) {
905 903
       return new classLocale($c->config->server_locale_log_usage);
906 904
     };
907 905
 
908
-    $gc->dbRowOperator = function ($c) {
906
+    $gc->dbRowOperator = function($c) {
909 907
       return new DbRowDirectOperator($c);
910 908
     };
911 909
 
912 910
     $gc->buddyClass = 'Buddy\BuddyModel';
913
-    $gc->buddy = $gc->factory(function (GlobalContainer $c) {
911
+    $gc->buddy = $gc->factory(function(GlobalContainer $c) {
914 912
       return new $c->buddyClass($c);
915 913
     });
916 914
 
917
-    $gc->query = $gc->factory(function (GlobalContainer $c) {
915
+    $gc->query = $gc->factory(function(GlobalContainer $c) {
918 916
       return new DbQueryConstructor($c->db);
919 917
     });
920 918
 
921
-    $gc->unit = $gc->factory(function (GlobalContainer $c) {
919
+    $gc->unit = $gc->factory(function(GlobalContainer $c) {
922 920
       return new \V2Unit\V2UnitModel($c);
923 921
     });
924 922
 
@@ -931,7 +929,7 @@  discard block
 block discarded – undo
931 929
   public static function init_3_load_config_file() {
932 930
     $dbsettings = array();
933 931
 
934
-    require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
932
+    require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
935 933
     self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix'];
936 934
     self::$db_name = $dbsettings['name'];
937 935
     self::$sn_secret_word = $dbsettings['secretword'];
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -363,9 +363,11 @@
 block discarded – undo
363 363
     $set = trim($set);
364 364
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
365 365
     if ($result = static::$db->doInsert("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
366
-      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
366
+      if (static::$db->db_affected_rows()) {
367
+        // Обновляем данные только если ряд был затронут
367 368
       {
368 369
         $record_id = classSupernova::$db->db_insert_id();
370
+      }
369 371
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
370 372
         $result = static::db_get_record_by_id($location_type, $record_id);
371 373
         // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 2 patches
Doc Comments   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
   /**
150 150
    * @param string $query
151 151
    *
152
-   * @return mixed|string
152
+   * @return string
153 153
    */
154 154
   public function replaceTablePlaceholders($query) {
155 155
     $sql = $query;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
   }
164 164
 
165 165
   /**
166
-   * @param $query
166
+   * @param string $query
167 167
    */
168 168
   protected function logQuery($query) {
169 169
     if (!classSupernova::$config->debug) {
@@ -352,6 +352,10 @@  discard block
 block discarded – undo
352 352
   }
353 353
 
354 354
   // TODO Заменить это на новый логгер
355
+
356
+  /**
357
+   * @param string $query
358
+   */
355 359
   protected function security_watch_user_queries($query) {
356 360
     global $user;
357 361
 
@@ -375,6 +379,9 @@  discard block
 block discarded – undo
375 379
   }
376 380
 
377 381
 
382
+  /**
383
+   * @param string $query
384
+   */
378 385
   public function security_query_check_bad_words($query) {
379 386
     if ($this->skipQueryCheck) {
380 387
       return;
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
   public function load_db_settings($configFile = '') {
84 84
     $dbsettings = array();
85 85
 
86
-    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false;
86
+    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false;
87 87
 
88 88
     require $configFile;
89 89
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
     if (empty($this->dbsettings)) {
106
-      $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
106
+      $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
107 107
     }
108 108
 
109 109
     // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     $sql = $query;
156 156
     if (strpos($sql, '{{') !== false) {
157 157
       foreach ($this->table_list as $tableName) {
158
-        $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
158
+        $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql);
159 159
       }
160 160
     }
161 161
 
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
 
229 229
     $queryResult = null;
230 230
     try {
231
-      $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace));
231
+      $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace));
232 232
       if (!$queryResult) {
233 233
         throw new Exception();
234 234
       }
235 235
     } catch (Exception $e) {
236
-      classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error');
236
+      classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error');
237 237
     }
238 238
 
239 239
     return $queryResult;
@@ -364,10 +364,10 @@  discard block
 block discarded – undo
364 364
       $this->isWatching = true;
365 365
       $msg = "\$query = \"{$query}\"\n\r";
366 366
       if (!empty($_POST)) {
367
-        $msg .= "\n\r" . dump($_POST, '$_POST');
367
+        $msg .= "\n\r".dump($_POST, '$_POST');
368 368
       }
369 369
       if (!empty($_GET)) {
370
-        $msg .= "\n\r" . dump($_GET, '$_GET');
370
+        $msg .= "\n\r".dump($_GET, '$_GET');
371 371
       }
372 372
       classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
373 373
       $this->isWatching = false;
@@ -393,37 +393,37 @@  discard block
 block discarded – undo
393 393
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
394 394
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
395 395
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
396
-        $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
396
+        $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
397 397
         $report .= ">Database Inforamation\n";
398
-        $report .= "\tID - " . $user['id'] . "\n";
399
-        $report .= "\tUser - " . $user['username'] . "\n";
400
-        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
401
-        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
402
-        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
403
-        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
404
-        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
405
-        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
406
-        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
407
-        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
398
+        $report .= "\tID - ".$user['id']."\n";
399
+        $report .= "\tUser - ".$user['username']."\n";
400
+        $report .= "\tAuth level - ".$user['authlevel']."\n";
401
+        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
402
+        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
403
+        $report .= "\tUser IP - ".$user['user_lastip']."\n";
404
+        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
405
+        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
406
+        $report .= "\tCurrent Page - ".$user['current_page']."\n";
407
+        $report .= "\tRegister Time - ".$user['register_time']."\n";
408 408
         $report .= "\n";
409 409
 
410 410
         $report .= ">Query Information\n";
411
-        $report .= "\tQuery - " . $query . "\n";
411
+        $report .= "\tQuery - ".$query."\n";
412 412
         $report .= "\n";
413 413
 
414 414
         $report .= ">\$_SERVER Information\n";
415
-        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
416
-        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
417
-        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
418
-        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
419
-        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
420
-        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
421
-        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
422
-        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
415
+        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
416
+        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
417
+        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
418
+        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
419
+        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
420
+        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
421
+        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
422
+        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
423 423
 
424 424
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
425 425
 
426
-        $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a');
426
+        $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a');
427 427
         fwrite($fp, $report);
428 428
         fclose($fp);
429 429
 
Please login to merge, or discard this patch.
includes/classes/DBAL/DbTransaction.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
    *   <p>true - транзакция должна быть запущена - для совместимости с $for_update</p>
40 40
    *   <p>false - всё равно - для совместимости с $for_update</p>
41 41
    *
42
-   * @return bool Текущий статус транзакции
42
+   * @return null|boolean Текущий статус транзакции
43 43
    */
44 44
   public function check($status = null) {
45 45
     $error_msg = false;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
     if (!empty($error_msg)) {
53 53
       // TODO - Убрать позже
54
-      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>');
54
+      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>');
55 55
       $backtrace = debug_backtrace();
56 56
       array_shift($backtrace);
57 57
       pdump($backtrace);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
   public function start($level = '') {
65 65
     $this->check(null);
66 66
 
67
-    $level ? $this->db->doExecute('SET TRANSACTION ISOLATION LEVEL ' . $level) : false;
67
+    $level ? $this->db->doExecute('SET TRANSACTION ISOLATION LEVEL '.$level) : false;
68 68
 
69 69
     $this->transaction_id++;
70 70
     $this->db->doExecute('START TRANSACTION');
Please login to merge, or discard this patch.
includes/classes/DbQueryConstructor.php 1 patch
Doc Comments   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -155,10 +155,17 @@  discard block
 block discarded – undo
155 155
     return $this->field(DbSqlLiteral::build($this->db)->literal($field));
156 156
   }
157 157
 
158
+  /**
159
+   * @param string $functionName
160
+   * @param string $alias
161
+   */
158 162
   public function fieldSingleFunction($functionName, $field = '*', $alias = DbSqlLiteral::SQL_LITERAL_ALIAS_NONE) {
159 163
     return $this->field(DbSqlLiteral::build($this->db)->buildSingleArgument($functionName, $field, $alias));
160 164
   }
161 165
 
166
+  /**
167
+   * @param string $alias
168
+   */
162 169
   public function fieldCount($field = '*', $alias = DbSqlLiteral::SQL_LITERAL_ALIAS_NONE) {
163 170
     return $this->field(DbSqlLiteral::build($this->db)->count($field, $alias));
164 171
   }
@@ -240,7 +247,7 @@  discard block
 block discarded – undo
240 247
 
241 248
   /**
242 249
    * @param db_mysql|null $db
243
-   * @param string|object|DBStaticRecord|DbSqlAware $className
250
+   * @param string $className
244 251
    *
245 252
    * @return static
246 253
    */
@@ -435,7 +442,6 @@  discard block
 block discarded – undo
435 442
   }
436 443
 
437 444
   /**
438
-   * @param bool $skip_query_check
439 445
    *
440 446
    * @return DbEmptyIterator|DbMysqliResultIterator
441 447
    */
@@ -444,7 +450,6 @@  discard block
 block discarded – undo
444 450
   }
445 451
 
446 452
   /**
447
-   * @param bool $skip_query_check
448 453
    *
449 454
    * @return array
450 455
    */
@@ -455,7 +460,6 @@  discard block
 block discarded – undo
455 460
   }
456 461
 
457 462
   /**
458
-   * @param bool $skip_query_check
459 463
    *
460 464
    * @return mixed|null
461 465
    */
Please login to merge, or discard this patch.
includes/classes/DBStaticMessages.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -477,6 +477,9 @@
 block discarded – undo
477 477
   {$StartRec}, 25;");
478 478
   }
479 479
 
480
+  /**
481
+   * @param integer $message_type
482
+   */
480 483
   public static function db_message_insert_all($message_type, $from, $subject, $text) {
481 484
     return classSupernova::$db->doInsert('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
482 485
       "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}");
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
       $owners = array();
115 115
     } else {
116 116
       $insert_values = array();
117
-      $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')");
117
+      $insert_template = "('%u',".str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')");
118 118
 
119 119
       foreach ($owners as $owner) {
120 120
         if ($user['id'] != $owner) {
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     $sendList = array();
156 156
     $list = '';
157 157
     $query = DBStaticUser::db_user_list(
158
-      "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
158
+      "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
159 159
       false, 'id, username');
160 160
     foreach ($query as $u) {
161 161
       $sendList[] = $u['id'];
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
       $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix']));
254 254
       $re++;
255 255
     }
256
-    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false;
256
+    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false;
257 257
 
258 258
     $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default'];
259 259
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
     return classSupernova::$db->doSelect(
423 423
       "SELECT * FROM {{messages}}
424 424
         WHERE
425
-          `message_type` = '" . MSG_TYPE_PLAYER . "' AND
425
+          `message_type` = '" . MSG_TYPE_PLAYER."' AND
426 426
           ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}')
427 427
           OR
428 428
           (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;");
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 FROM
471 471
   {{messages}} AS m
472 472
   LEFT JOIN {{users}} AS u ON u.id = m.message_owner " .
473
-      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') .
473
+      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '').
474 474
       "ORDER BY
475 475
   `message_id` DESC
476 476
 LIMIT
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
   }
479 479
 
480 480
   public static function db_message_insert_all($message_type, $from, $subject, $text) {
481
-    return classSupernova::$db->doInsert('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
481
+    return classSupernova::$db->doInsert('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '.
482 482
       "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}");
483 483
   }
484 484
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
    * @return array|bool|mysqli_result|null
489 489
    */
490 490
   public static function db_message_count_by_type($int_type_selected) {
491
-    $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM {{messages}}' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
491
+    $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM {{messages}}'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
492 492
 
493 493
     return $page_max;
494 494
   }
@@ -505,15 +505,15 @@  discard block
 block discarded – undo
505 505
    * @param $int_type_selected
506 506
    */
507 507
   public static function db_message_list_delete_by_date($delete_date, $int_type_selected) {
508
-    classSupernova::$db->doDelete("DELETE FROM {{messages}} WHERE message_time <= UNIX_TIMESTAMP('{$delete_date}')" . ($int_type_selected >= 0 ? " AND `message_type` = {$int_type_selected}" : ''));
508
+    classSupernova::$db->doDelete("DELETE FROM {{messages}} WHERE message_time <= UNIX_TIMESTAMP('{$delete_date}')".($int_type_selected >= 0 ? " AND `message_type` = {$int_type_selected}" : ''));
509 509
   }
510 510
 
511 511
   /**
512 512
    * @param $insert_values
513 513
    */
514 514
   public static function db_message_insert($insert_values) {
515
-    classSupernova::$db->doInsert('INSERT INTO `{{messages}}` (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
516
-      'VALUES ' . implode(',', $insert_values));
515
+    classSupernova::$db->doInsert('INSERT INTO `{{messages}}` (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '.
516
+      'VALUES '.implode(',', $insert_values));
517 517
   }
518 518
 
519 519
 }
Please login to merge, or discard this patch.
includes/classes/debug.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -187,6 +187,9 @@
 block discarded – undo
187 187
     return $error_backtrace;
188 188
   }
189 189
 
190
+  /**
191
+   * @param string $die_message
192
+   */
190 193
   public function error_fatal($die_message, $details = 'There is a fatal error on page') {
191 194
     // TODO - Записывать детали ошибки в лог-файл
192 195
     die($die_message);
Please login to merge, or discard this patch.
Spacing   +75 added lines, -76 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
 defined('INSIDE') || die();
34 34
 
35
-if(php_sapi_name() == "cli") {
35
+if (php_sapi_name() == "cli") {
36 36
   // In cli-mode
37 37
   define('__DEBUG_CRLF', "\r\n");
38
-  define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF);
38
+  define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF);
39 39
 } else {
40 40
   // Not in cli-mode
41 41
   define('__DEBUG_CRLF', '<br />');
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
   public function log_file($message, $ident_change = 0) {
53 53
     static $ident = 0;
54 54
 
55
-    if(!defined('SN_DEBUG_LOG')) {
55
+    if (!defined('SN_DEBUG_LOG')) {
56 56
       return;
57 57
     }
58 58
 
59
-    if($this->log_file_handler === null) {
60
-      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
59
+    if ($this->log_file_handler === null) {
60
+      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+');
61 61
       @fwrite($this->log_file_handler, "\r\n\r\n");
62 62
     }
63 63
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
64
-    if($this->log_file_handler) {
65
-      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
64
+    if ($this->log_file_handler) {
65
+      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n");
66 66
     }
67 67
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
68 68
   }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
   }
83 83
 
84 84
   public function echo_log() {
85
-    echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
85
+    echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
86 86
     die();
87 87
   }
88 88
 
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
     $result = array();
93 93
     $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId();
94 94
     $result[] = "tID {$transaction_id}";
95
-    foreach($backtrace as $a_trace) {
96
-      if(in_array($a_trace['function'], $exclude_functions)) {
95
+    foreach ($backtrace as $a_trace) {
96
+      if (in_array($a_trace['function'], $exclude_functions)) {
97 97
         continue;
98 98
       }
99 99
       $function =
100 100
         ($a_trace['type']
101 101
           ? ($a_trace['type'] == '->'
102
-            ? "({$a_trace['class']})" . get_class($a_trace['object'])
102
+            ? "({$a_trace['class']})".get_class($a_trace['object'])
103 103
             : $a_trace['class']
104
-          ) . $a_trace['type']
104
+          ).$a_trace['type']
105 105
           : ''
106
-        ) . $a_trace['function'] . '()';
106
+        ).$a_trace['function'].'()';
107 107
 
108 108
       $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file']));
109 109
 
110 110
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
111 111
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
112 112
 
113
-      if(!$long_comment) {
113
+      if (!$long_comment) {
114 114
         break;
115 115
       }
116 116
     }
@@ -124,26 +124,26 @@  discard block
 block discarded – undo
124 124
   public function dump($dump = false, $force_base = false, $deadlock = false) {
125 125
     global $user, $planetrow;
126 126
 
127
-    if($dump === false) {
127
+    if ($dump === false) {
128 128
       return;
129 129
     }
130 130
 
131 131
     $error_backtrace = array();
132 132
     $base_dump = false;
133 133
 
134
-    if($force_base === true) {
134
+    if ($force_base === true) {
135 135
       $base_dump = true;
136 136
     }
137 137
 
138
-    if($dump === true) {
138
+    if ($dump === true) {
139 139
       $base_dump = true;
140 140
     } else {
141
-      if(!is_array($dump)) {
141
+      if (!is_array($dump)) {
142 142
         $dump = array('var' => $dump);
143 143
       }
144 144
 
145
-      foreach($dump as $dump_var_name => $dump_var) {
146
-        if($dump_var_name == 'base_dump') {
145
+      foreach ($dump as $dump_var_name => $dump_var) {
146
+        if ($dump_var_name == 'base_dump') {
147 147
           $base_dump = $dump_var;
148 148
         } else {
149 149
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -151,22 +151,21 @@  discard block
 block discarded – undo
151 151
       }
152 152
     }
153 153
 
154
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
154
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
155 155
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
156 156
       $error_backtrace['locks'] = SnCache::getLocks();
157 157
       $error_backtrace['cSN_data'] = SnCache::getData();
158
-      foreach($error_backtrace['cSN_data'] as &$location) {
159
-        foreach($location as $location_id => &$location_data) {
160
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
161
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
158
+      foreach ($error_backtrace['cSN_data'] as &$location) {
159
+        foreach ($location as $location_id => &$location_data) {
160
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
162 161
         }
163 162
       }
164 163
       $error_backtrace['cSN_queries'] = SnCache::getQueries();
165 164
     }
166 165
 
167
-    if($base_dump) {
168
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
169
-        foreach($this->log_array as $log) {
166
+    if ($base_dump) {
167
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
168
+        foreach ($this->log_array as $log) {
170 169
           $error_backtrace['queries'][] = $log;
171 170
         }
172 171
       }
@@ -195,14 +194,14 @@  discard block
 block discarded – undo
195 194
   public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
196 195
     global $sys_stop_log_hit, $sys_log_disabled, $user;
197 196
 
198
-    if(empty(classSupernova::$db->connected)) {
197
+    if (empty(classSupernova::$db->connected)) {
199 198
       // TODO - писать ошибку в файл
200 199
       die('SQL server currently unavailable. Please contact Administration...');
201 200
     }
202 201
 
203 202
     sn_db_transaction_rollback();
204 203
 
205
-    if(classSupernova::$config->debug == 1) {
204
+    if (classSupernova::$config->debug == 1) {
206 205
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
207 206
       echo "<table>{$this->log}</table>";
208 207
     }
@@ -214,16 +213,16 @@  discard block
 block discarded – undo
214 213
 
215 214
     $userId = empty($user['id']) ? 0 : $user['id'];
216 215
 
217
-    if(!$sys_log_disabled) {
216
+    if (!$sys_log_disabled) {
218 217
       $query = "INSERT INTO `{{logs}}` SET
219
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "',
220
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
221
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
218
+        `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."',
219
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
220
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
222 221
 //        ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";";
223
-      ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
224
-      classSupernova::$db->doExecute($query, true) or die($fatal_error . classSupernova::$db->db_error());
222
+      ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
223
+      classSupernova::$db->doExecute($query, true) or die($fatal_error.classSupernova::$db->db_error());
225 224
 
226
-      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>";
225
+      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>";
227 226
 
228 227
       $sys_stop_log_hit = true;
229 228
       $sys_log_disabled = true;
@@ -233,7 +232,7 @@  discard block
 block discarded – undo
233 232
       ob_start();
234 233
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
235 234
 
236
-      foreach($error_backtrace as $name => $value) {
235
+      foreach ($error_backtrace as $name => $value) {
237 236
         print(__DEBUG_LINE);
238 237
         pdump($value, $name);
239 238
       }
@@ -245,7 +244,7 @@  discard block
 block discarded – undo
245 244
   public function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
246 245
     global $user, $sys_log_disabled;
247 246
 
248
-    if(empty(classSupernova::$db->connected)) {
247
+    if (empty(classSupernova::$db->connected)) {
249 248
       // TODO - писать ошибку в файл
250 249
       die('SQL server currently unavailable. Please contact Administration...');
251 250
     }
@@ -254,12 +253,12 @@  discard block
 block discarded – undo
254 253
 
255 254
     $userId = empty($user['id']) ? 0 : $user['id'];
256 255
 
257
-    if(!$sys_log_disabled) {
256
+    if (!$sys_log_disabled) {
258 257
       $query = "INSERT INTO `{{logs}}` SET
259
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "',
260
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
261
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
262
-        ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
258
+        `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."',
259
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
260
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
261
+        ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
263 262
       classSupernova::$db->doExecute($query, true);
264 263
     } else {
265 264
 //        // TODO Здесь надо писать в файло
@@ -272,11 +271,11 @@  discard block
 block discarded – undo
272 271
 // Dump variables nicer then var_dump()
273 272
 
274 273
 function dump($value, $varname = null, $level = 0, $dumper = '') {
275
-  if(isset($varname)) {
274
+  if (isset($varname)) {
276 275
     $varname .= " = ";
277 276
   }
278 277
 
279
-  if($level == -1) {
278
+  if ($level == -1) {
280 279
     $trans[' '] = '&there4;';
281 280
     $trans["\t"] = '&rArr;';
282 281
     $trans["\n"] = '&para;;';
@@ -285,31 +284,31 @@  discard block
 block discarded – undo
285 284
 
286 285
     return strtr(htmlspecialchars($value), $trans);
287 286
   }
288
-  if($level == 0) {
287
+  if ($level == 0) {
289 288
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
290
-    $dumper = mt_rand(10, 99) . '|' . $varname;
289
+    $dumper = mt_rand(10, 99).'|'.$varname;
291 290
   }
292 291
 
293 292
   $type = gettype($value);
294 293
   $dumper .= $type;
295 294
 
296
-  if($type == TYPE_STRING) {
297
-    $dumper .= '(' . strlen($value) . ')';
295
+  if ($type == TYPE_STRING) {
296
+    $dumper .= '('.strlen($value).')';
298 297
     $value = dump($value, '', -1);
299
-  } elseif($type == TYPE_BOOLEAN) {
298
+  } elseif ($type == TYPE_BOOLEAN) {
300 299
     $value = ($value ? 'true' : 'false');
301
-  } elseif($type == 'object') {
300
+  } elseif ($type == 'object') {
302 301
     $props = get_class_vars(get_class($value));
303
-    $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
304
-    foreach($props as $key => $val) {
305
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
302
+    $dumper .= '('.count($props).') <u>'.get_class($value).'</u>';
303
+    foreach ($props as $key => $val) {
304
+      $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => ';
306 305
       $dumper .= dump($value->$key, '', $level + 1);
307 306
     }
308 307
     $value = '';
309
-  } elseif($type == TYPE_ARRAY) {
310
-    $dumper .= '(' . count($value) . ')';
311
-    foreach($value as $key => $val) {
312
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
308
+  } elseif ($type == TYPE_ARRAY) {
309
+    $dumper .= '('.count($value).')';
310
+    foreach ($value as $key => $val) {
311
+      $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => ';
313 312
       $dumper .= dump($val, '', $level + 1);
314 313
     }
315 314
     $value = '';
@@ -328,24 +327,24 @@  discard block
 block discarded – undo
328 327
 //  $backtrace = $backtrace[1];
329 328
 
330 329
   $caller = '';
331
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
332
-    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
333
-      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
334
-      $backtrace[1]['function'] .
330
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
331
+    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '').
332
+      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '').
333
+      $backtrace[1]['function'].
335 334
       (!empty($backtrace[0]['file'])
336 335
         ? (
337
-          ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) .
338
-          (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') .
336
+          ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN).
337
+          (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : '').
339 338
           ')'
340 339
         )
341 340
         : ''
342 341
       );
343
-    $caller = "\r\n" . $caller;
342
+    $caller = "\r\n".$caller;
344 343
   }
345 344
 
346
-  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' .
347
-    dump($value, $varname) .
348
-    $caller .
345
+  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'.
346
+    dump($value, $varname).
347
+    $caller.
349 348
     '</pre>'
350 349
   );
351 350
 }
@@ -355,24 +354,24 @@  discard block
 block discarded – undo
355 354
 }
356 355
 
357 356
 function pr($prePrint = false) {
358
-  if($prePrint) {
357
+  if ($prePrint) {
359 358
     print(__DEBUG_CRLF);
360 359
   }
361
-  print(mt_rand() . __DEBUG_CRLF);
360
+  print(mt_rand().__DEBUG_CRLF);
362 361
 }
363 362
 
364 363
 function pc($prePrint = false) {
365 364
   global $_PRINT_COUNT_VALUE;
366 365
   $_PRINT_COUNT_VALUE++;
367 366
 
368
-  if($prePrint) {
367
+  if ($prePrint) {
369 368
     print(__DEBUG_CRLF);
370 369
   }
371
-  print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
370
+  print($_PRINT_COUNT_VALUE.__DEBUG_CRLF);
372 371
 }
373 372
 
374 373
 function prep($message) {
375
-  print('<pre>' . $message . '</pre>');
374
+  print('<pre>'.$message.'</pre>');
376 375
 }
377 376
 
378 377
 function backtrace_no_arg() {
@@ -396,9 +395,9 @@  discard block
 block discarded – undo
396 395
  */
397 396
 function pdie($message = '', $level = 0) {
398 397
   $backtrace = debug_backtrace();
399
-  for($i = 0; $i < $level; $i++) {
398
+  for ($i = 0; $i < $level; $i++) {
400 399
     array_pop($backtrace);
401 400
   }
402 401
 
403
-  die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']);
402
+  die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']);
404 403
 }
Please login to merge, or discard this patch.
includes/db.php 1 patch
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -9,6 +9,9 @@  discard block
 block discarded – undo
9 9
 
10 10
 require_once('db/db_queries.php');
11 11
 
12
+/**
13
+ * @param string $tablename
14
+ */
12 15
 function db_change_units_perform($query, $tablename, $object_id) {
13 16
   $query = implode(',', $query);
14 17
   if($query && $object_id) {
@@ -60,6 +63,9 @@  discard block
 block discarded – undo
60 63
   db_change_units_perform($query[LOC_USER], 'users', $user['id']);
61 64
   db_change_units_perform($query[LOC_PLANET], 'planets', $planet['id']);
62 65
 }
66
+/**
67
+ * @param string $table
68
+ */
63 69
 function sn_db_perform($table, $values, $type = 'insert', $options = false) {
64 70
   $field_set = '';
65 71
 
@@ -153,6 +159,9 @@  discard block
 block discarded – undo
153 159
 
154 160
 
155 161
 
162
+/**
163
+ * @param boolean $transaction_should_be_started
164
+ */
156 165
 function sn_db_transaction_check($transaction_should_be_started = null) {
157 166
   return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started);
158 167
 }
Please login to merge, or discard this patch.
includes/db/db_queries.php 2 patches
Doc Comments   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -173,6 +173,11 @@  discard block
 block discarded – undo
173 173
  */
174 174
 // OK v4
175 175
 // TODO - вынести в отдельный класс
176
+/**
177
+ * @param string $db_id_field_name
178
+ * @param string $db_table_name
179
+ * @param string $db_value_field_name
180
+ */
176 181
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
177 182
   $current_value_safe = db_escape($current_value_unsafe);
178 183
   $value_id = classSupernova::$db->doSelectFetch("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE");
@@ -474,8 +479,8 @@  discard block
 block discarded – undo
474 479
 
475 480
 
476 481
 /**
477
- * @param $user_id
478
- * @param $change_type
482
+ * @param integer $user_id
483
+ * @param integer $change_type
479 484
  * @param $dark_matter
480 485
  * @param $comment
481 486
  * @param $row
@@ -495,7 +500,7 @@  discard block
 block discarded – undo
495 500
 /**
496 501
  * @param $user_id_safe
497 502
  *
498
- * @return array|bool|mysqli_result|null
503
+ * @return integer
499 504
  */
500 505
 function db_referral_get_by_id($user_id_safe) {
501 506
   $old_referral = classSupernova::$db->doSelectFetch("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;");
@@ -523,9 +528,9 @@  discard block
 block discarded – undo
523 528
 
524 529
 // Quests ***********************************************************************************************************
525 530
 /**
526
- * @param $query_add_select
531
+ * @param string $query_add_select
527 532
  * @param $query_add_from
528
- * @param $query_add_where
533
+ * @param string $query_add_where
529 534
  *
530 535
  * @return array|bool|mysqli_result|null
531 536
  */
@@ -570,10 +575,10 @@  discard block
 block discarded – undo
570 575
 
571 576
 /**
572 577
  * @param $quest_name
573
- * @param $quest_type
578
+ * @param integer $quest_type
574 579
  * @param $quest_description
575 580
  * @param $quest_conditions
576
- * @param $quest_rewards
581
+ * @param string $quest_rewards
577 582
  * @param $quest_id
578 583
  */
579 584
 function db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id) {
@@ -592,7 +597,7 @@  discard block
 block discarded – undo
592 597
 /**
593 598
  * @param $banner
594 599
  * @param $banned
595
- * @param $reason
600
+ * @param string $reason
596 601
  * @param $ban_until
597 602
  */
598 603
 function db_ban_insert($banner, $banned, $reason, $ban_until) {
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
 
5 5
 function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) {
6 6
   return classSupernova::$db->doSelect(
7
-    "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') .
7
+    "SELECT p.*, u.username".($table_parent_columns ? ', p1.name AS parent_name' : '').
8 8
     " FROM {{planets}} AS p
9 9
       LEFT JOIN {{users}} AS u ON u.id = p.id_owner" .
10
-    ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : '') .
11
-    " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}"));
10
+    ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : '').
11
+    " WHERE ".($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}"));
12 12
 }
13 13
 
14 14
 function db_planet_list_search($searchtext) {
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     ORDER BY
107 107
       sp.`{$Rank}_rank`, subject.{$source['id']}
108 108
     LIMIT
109
-      " . $start . ",100;";
109
+      ".$start.",100;";
110 110
     } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
111 111
       $query_str =
112 112
         "SELECT
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     ORDER BY
120 120
       subject.{$Rank} DESC, subject.{$source['id']}
121 121
     LIMIT
122
-      " . $start . ",100;";
122
+      ".$start.",100;";
123 123
     }
124 124
   } else {
125 125
     // TODO
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
   ORDER BY
137 137
     sp.`{$Rank}_rank`, subject.id
138 138
   LIMIT
139
-    " . $start . ",100;";
139
+    ".$start.",100;";
140 140
   }
141 141
 
142 142
   return classSupernova::$db->doSelect($query_str);
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
  */
366 366
 function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) {
367 367
   $extra_conditions =
368
-    ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') .
369
-    ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') .
370
-    ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') .
368
+    ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '').
369
+    ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '').
370
+    ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '').
371 371
     ($flt_module ? "AND payment_module_name = '{$flt_module}' " : '');
372 372
   $query = classSupernova::$db->doSelect("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;");
373 373
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 
396 396
 // Log Online *************************************************************************************************************
397 397
 function db_log_online_insert() {
398
-  classSupernova::$db->doInsert("INSERT IGNORE INTO `{{log_users_online}}` SET online_count = " . classSupernova::$config->var_online_user_count);
398
+  classSupernova::$db->doInsert("INSERT IGNORE INTO `{{log_users_online}}` SET online_count = ".classSupernova::$config->var_online_user_count);
399 399
 }
400 400
 
401 401
 // Log *************************************************************************************************************
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
       `ban_user_id` = '{$banned['id']}',
604 604
       `ban_user_name` = '{$banned['username']}',
605 605
       `ban_reason` = '{$reason}',
606
-      `ban_time` = " . SN_TIME_NOW . ",
606
+      `ban_time` = ".SN_TIME_NOW.",
607 607
       `ban_until` = {$ban_until},
608 608
       `ban_issuer_id` = '{$banner['id']}',
609 609
       `ban_issuer_name` = '{$banner['username']}',
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
       `ban_user_name` = '{$banned['username']}',
626 626
       `ban_reason` = '{$reason}',
627 627
       `ban_time` = 0,
628
-      `ban_until` = " . SN_TIME_NOW . ",
628
+      `ban_until` = ".SN_TIME_NOW.",
629 629
       `ban_issuer_id` = '{$banner['id']}',
630 630
       `ban_issuer_name` = '{$banner['username']}',
631 631
       `ban_issuer_email` = '{$banner['email']}'
@@ -684,9 +684,9 @@  discard block
 block discarded – undo
684 684
 function db_ube_report_get_best_battles() {
685 685
   $query = classSupernova::$db->doSelect("SELECT *
686 686
       FROM `{{ube_report}}`
687
-      WHERE `ube_report_time_process` <  DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY))
687
+      WHERE `ube_report_time_process` <  DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY))
688 688
       ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC
689
-      LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";");
689
+      LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";");
690 690
 
691 691
   return $query;
692 692
 }
Please login to merge, or discard this patch.