Completed
Push — work-fleets ( 3cd948...da4c88 )
by SuperNova.WS
07:01
created
includes/classes/_unused/DbSqlPrepare.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -128,6 +128,9 @@
 block discarded – undo
128 128
     }
129 129
   }
130 130
 
131
+  /**
132
+   * @param string $comment
133
+   */
131 134
   protected function commentAdd($comment) {
132 135
     if (empty($this->values[static::COMMENT_PLACEHOLDER])) {
133 136
       $this->query .= static::COMMENT_PLACEHOLDER;
Please login to merge, or discard this patch.
includes/classes/DBStaticUser.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         ->where('`user_as_ally` IS NULL')
21 21
         ->orderBy(array('`id` DESC'));
22 22
 
23
-    return (string)static::$dbStatic->doStmtSelectValue($query);
23
+    return (string) static::$dbStatic->doStmtSelectValue($query);
24 24
   }
25 25
 
26 26
   protected static function whereNotAlly() {
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
       static::buildDBQ()
50 50
         ->field('id')
51 51
         ->where("`user_as_ally` IS NULL")
52
-        ->where("`user_bot` = " . USER_BOT_PLAYER)
52
+        ->where("`user_bot` = ".USER_BOT_PLAYER)
53 53
         ->setForUpdate();
54 54
 
55 55
     return static::$dbStatic->doStmtSelectIterator($query);
56 56
   }
57 57
 
58 58
   public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) {
59
-    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) .
60
-      (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '')
59
+    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']).
60
+      (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '')
61 61
     . " FOR UPDATE"
62 62
     ;
63 63
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
    */
72 72
   public static function db_user_count($online = false) {
73 73
     return intval(static::$dbStatic->doQueryFetchValue(
74
-      'SELECT COUNT(`id`) AS `user_count` FROM `{{users}}` WHERE `user_as_ally` IS NULL' . ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
74
+      'SELECT COUNT(`id`) AS `user_count` FROM `{{users}}` WHERE `user_as_ally` IS NULL'.($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
75 75
     ));
76 76
   }
77 77
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
       ->fieldCount('r.id', 'referral_count')
94 94
       ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm')
95 95
       ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id')
96
-      ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
96
+      ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
97 97
       ->groupBy('u.id')
98 98
       ->orderBy("user_as_ally, {$sort} ASC")
99 99
     ;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
       ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)')
112 112
       ->where('`user_as_ally` IS NULL')
113 113
       ->having('`days_after_birthday` >= 0')
114
-      ->having('`days_after_birthday` < ' . intval($config_user_birthday_range))
114
+      ->having('`days_after_birthday` < '.intval($config_user_birthday_range))
115 115
       ->setForUpdate()
116 116
     ;
117 117
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
   }
195 195
 
196 196
   public static function db_user_list_set_mass_mail(&$owners_list, $set) {
197
-    return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : '', $set);
197
+    return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : '', $set);
198 198
   }
199 199
 
200 200
   public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) {
Please login to merge, or discard this patch.
includes/classes/classSupernova.php 1 patch
Spacing   +17 added lines, -19 removed lines patch added patch discarded remove patch
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
     if (!empty($error_msg)) {
225 225
       // TODO - Убрать позже
226
-      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>');
226
+      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>');
227 227
       $backtrace = debug_backtrace();
228 228
       array_shift($backtrace);
229 229
       pdump($backtrace);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
   public static function db_transaction_start($level = '') {
237 237
     static::db_transaction_check(null);
238 238
 
239
-    $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false;
239
+    $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false;
240 240
 
241 241
     static::$transaction_id++;
242 242
     doquery('START TRANSACTION');
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
   public static function db_lock_tables($tables) {
301 301
     $tables = is_array($tables) ? $tables : array($tables => '');
302 302
     foreach ($tables as $table_name => $condition) {
303
-      self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
303
+      self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : ''));
304 304
     }
305 305
   }
306 306
 
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
           $query = static::db_query(
361 361
             "SELECT
362 362
               distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id
363
-            FROM {{{$location_info[P_TABLE_NAME]}}}" .
364
-            ($filter ? ' WHERE ' . $filter : '') .
363
+            FROM {{{$location_info[P_TABLE_NAME]}}}".
364
+            ($filter ? ' WHERE '.$filter : '').
365 365
             ($fetch ? ' LIMIT 1' : ''), false, true);
366 366
 
367 367
           while ($row = db_fetch($query)) {
@@ -374,13 +374,13 @@  discard block
 block discarded – undo
374 374
           if ($indexes_str = implode(',', $parent_id_list)) {
375 375
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
376 376
             static::db_get_record_list($owner_location_type,
377
-              $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
377
+              $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
378 378
           }
379 379
         }
380 380
       }
381 381
 
382 382
       $query = static::db_query(
383
-        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" .
383
+        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}".
384 384
         (($filter = trim($filter)) ? " WHERE {$filter}" : '')
385 385
       );
386 386
       while ($row = db_fetch($query)) {
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
     $condition = trim($condition);
452 452
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
453 453
 
454
-    if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
454
+    if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) {
455 455
 
456 456
       if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
457 457
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
610 610
 
611 611
       $user = static::db_query(
612
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"
612
+        "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"
613 613
         , true);
614 614
       SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы
615 615
     }
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
     }
667 667
 
668 668
     if (SnCache::isUnitLocatorNotSet($location_type, $location_id)) {
669
-      $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());
669
+      $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());
670 670
       if (!empty($got_data) && is_array($got_data)) {
671 671
         foreach ($got_data as $unit_id => $unit_data) {
672 672
           SnCache::setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data);
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
     if ($que_type == QUE_RESEARCH || $planet_id === null) {
726 726
       $query[] = "`que_planet_id` IS NULL";
727 727
     } elseif ($planet_id) {
728
-      $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
728
+      $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")";
729 729
     }
730 730
     if ($que_type) {
731 731
       $query[] = "`que_type` = {$que_type}";
@@ -839,13 +839,13 @@  discard block
 block discarded – undo
839 839
         $condition = "`{$field_name}` = ";
840 840
         $value = '';
841 841
         if ($field_data['delta']) {
842
-          $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
842
+          $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta'];
843 843
         } elseif ($field_data['set']) {
844 844
           $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
845 845
         }
846 846
 
847 847
         if ($value) {
848
-          $fields[] = $condition . $value;
848
+          $fields[] = $condition.$value;
849 849
         }
850 850
       }
851 851
       $conditions[P_FIELDS_STR] = implode(',', $fields);
@@ -859,9 +859,7 @@  discard block
 block discarded – undo
859 859
           // Простое условие - $field_id = $field_value
860 860
           if (is_string($field_id)) {
861 861
             $field_value =
862
-              $field_value === null ? 'NULL' :
863
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
864
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
862
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value));
865 863
             $the_conditions[] = "`{$field_id}` = {$field_value}";
866 864
           } else {
867 865
             die('Неподдерживаемый тип условия');
@@ -888,7 +886,7 @@  discard block
 block discarded – undo
888 886
         die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile');
889 887
     }
890 888
 
891
-    $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]);
889
+    $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]);
892 890
   }
893 891
 
894 892
   public static function db_changeset_apply($db_changeset, $flush_delayed = false) {
@@ -976,7 +974,7 @@  discard block
 block discarded – undo
976 974
     ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false;
977 975
     if (@get_magic_quotes_gpc()) {
978 976
       $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
979
-      array_walk_recursive($gpcr, function (&$value, $key) {
977
+      array_walk_recursive($gpcr, function(&$value, $key) {
980 978
         $value = stripslashes($value);
981 979
       });
982 980
     }
@@ -990,7 +988,7 @@  discard block
 block discarded – undo
990 988
   public static function init_3_load_config_file() {
991 989
     $dbsettings = array();
992 990
 
993
-    require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
991
+    require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
994 992
     self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix'];
995 993
     self::$db_name = $dbsettings['name'];
996 994
     self::$sn_secret_word = $dbsettings['secretword'];
Please login to merge, or discard this patch.
includes/classes/DBStaticRecord.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
     $stmt =
53 53
       static::buildDBQ()
54 54
         ->fields($fieldList)
55
-        ->where(static::$_idField . '=' . $recordId);
55
+        ->where(static::$_idField.'='.$recordId);
56 56
 
57
-    if($forUpdate) {
57
+    if ($forUpdate) {
58 58
       $stmt->setForUpdate();
59 59
     }
60 60
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
       $query = static::$dbStatic->doStmtSelectIterator(
74 74
         static::buildDBQ()
75 75
           ->fields(static::$_idField)
76
-          ->where(array("`" . static::$_idField . "` IN (" . implode(',', $idList) . ")"))
76
+          ->where(array("`".static::$_idField."` IN (".implode(',', $idList).")"))
77 77
       );
78 78
     } else {
79 79
       $query = new DbEmptyIterator();
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
     $result = array();
98 98
     if (!empty($idList)) {
99
-      foreach(static::queryExistsIdInList($idList) as $row) {
99
+      foreach (static::queryExistsIdInList($idList) as $row) {
100 100
         $result[] = $row[static::$_idField];
101 101
       }
102 102
     }
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
   public function load_db_settings() {
66 66
     $dbsettings = array();
67 67
 
68
-    require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
68
+    require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
69 69
 
70 70
     $this->dbsettings = $dbsettings;
71 71
   }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     $sql = $query;
131 131
     if (strpos($sql, '{{') !== false) {
132 132
       foreach ($this->table_list as $tableName) {
133
-        $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
133
+        $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql);
134 134
       }
135 135
     }
136 136
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     $arr = debug_backtrace();
151 151
     $file = end(explode('/', $arr[0]['file']));
152 152
     $line = $arr[0]['line'];
153
-    classSupernova::$debug->add("<tr><th>Query {$this->queryCount}: </th><th>$query</th><th>{$file} @ {$line}</th><th>&nbsp;</th><th> " . ($fetch ? '+' : '&nbsp;') . " </th></tr>");
153
+    classSupernova::$debug->add("<tr><th>Query {$this->queryCount}: </th><th>$query</th><th>{$file} @ {$line}</th><th>&nbsp;</th><th> ".($fetch ? '+' : '&nbsp;')." </th></tr>");
154 154
   }
155 155
 
156 156
 
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
 
211 211
     $queryResult = null;
212 212
     try {
213
-      $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace));
213
+      $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace));
214 214
       if (!$queryResult) {
215 215
         throw new Exception();
216 216
       }
217 217
     } catch (Exception $e) {
218
-      classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error');
218
+      classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error');
219 219
     }
220 220
 
221 221
     if ($fetch) {
@@ -336,10 +336,10 @@  discard block
 block discarded – undo
336 336
       $this->isWatching = true;
337 337
       $msg = "\$query = \"{$query}\"\n\r";
338 338
       if (!empty($_POST)) {
339
-        $msg .= "\n\r" . dump($_POST, '$_POST');
339
+        $msg .= "\n\r".dump($_POST, '$_POST');
340 340
       }
341 341
       if (!empty($_GET)) {
342
-        $msg .= "\n\r" . dump($_GET, '$_GET');
342
+        $msg .= "\n\r".dump($_GET, '$_GET');
343 343
       }
344 344
       classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
345 345
       $this->isWatching = false;
@@ -365,37 +365,37 @@  discard block
 block discarded – undo
365 365
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
366 366
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
367 367
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
368
-        $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
368
+        $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
369 369
         $report .= ">Database Inforamation\n";
370
-        $report .= "\tID - " . $user['id'] . "\n";
371
-        $report .= "\tUser - " . $user['username'] . "\n";
372
-        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
373
-        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
374
-        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
375
-        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
376
-        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
377
-        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
378
-        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
379
-        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
370
+        $report .= "\tID - ".$user['id']."\n";
371
+        $report .= "\tUser - ".$user['username']."\n";
372
+        $report .= "\tAuth level - ".$user['authlevel']."\n";
373
+        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
374
+        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
375
+        $report .= "\tUser IP - ".$user['user_lastip']."\n";
376
+        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
377
+        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
378
+        $report .= "\tCurrent Page - ".$user['current_page']."\n";
379
+        $report .= "\tRegister Time - ".$user['register_time']."\n";
380 380
         $report .= "\n";
381 381
 
382 382
         $report .= ">Query Information\n";
383
-        $report .= "\tQuery - " . $query . "\n";
383
+        $report .= "\tQuery - ".$query."\n";
384 384
         $report .= "\n";
385 385
 
386 386
         $report .= ">\$_SERVER Information\n";
387
-        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
388
-        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
389
-        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
390
-        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
391
-        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
392
-        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
393
-        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
394
-        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
387
+        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
388
+        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
389
+        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
390
+        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
391
+        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
392
+        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
393
+        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
394
+        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
395 395
 
396 396
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
397 397
 
398
-        $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a');
398
+        $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a');
399 399
         fwrite($fp, $report);
400 400
         fclose($fp);
401 401
 
Please login to merge, or discard this patch.