Completed
Push — work-fleets ( e0e753...5ee2f8 )
by SuperNova.WS
05:10
created
includes/classes/DBStaticRecord.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,8 +96,8 @@
 block discarded – undo
96 96
   }
97 97
 
98 98
   /**
99
-   * @param int|string $user_id
100
-   * @param array      $fieldList
99
+   * @param integer $user_id
100
+   * @param string[]      $fieldList
101 101
    * @param bool       $for_update
102 102
    *
103 103
    * @return array|null
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             $result[] = 'NULL';
30 30
           break;
31 31
           default:
32
-            $result[] = '`' . (string)$fieldName . '`';
32
+            $result[] = '`'.(string) $fieldName.'`';
33 33
         }
34 34
       }
35 35
     } else {
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
     if (!empty($fieldList)) {
58 58
       $user_record = doquery(
59 59
         (
60
-          "SELECT {$fieldList}" .
61
-          " FROM {{" . self::$_table . "}}" .
62
-          (!empty($where) ? " WHERE {$where}" : '') .
63
-          (!empty($for_update) ? " FOR UPDATE" : '') .
60
+          "SELECT {$fieldList}".
61
+          " FROM {{".self::$_table."}}".
62
+          (!empty($where) ? " WHERE {$where}" : '').
63
+          (!empty($for_update) ? " FOR UPDATE" : '').
64 64
           ($returnFirst ? ' LIMIT 1' : '')
65 65
         ),
66 66
         $returnFirst
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
    * @return int
91 91
    */
92 92
   public static function getMaxId() {
93
-    $maxId = classSupernova::$db->doquery("SELECT MAX(`" . static::$_idField . "`) AS `maxId` FROM `{{" . static::$_table . "}}`", true);
93
+    $maxId = classSupernova::$db->doquery("SELECT MAX(`".static::$_idField."`) AS `maxId` FROM `{{".static::$_table."}}`", true);
94 94
 
95 95
     return !empty($maxId['maxId']) ? $maxId['maxId'] : 0;
96 96
   }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
    * @return array|null
104 104
    */
105 105
   public static function getRecordById($user_id, $fieldList = array(), $for_update = false) {
106
-    return static::getRecord(static::$_idField . ' = ' . $user_id, $fieldList, $for_update);
106
+    return static::getRecord(static::$_idField.' = '.$user_id, $fieldList, $for_update);
107 107
   }
108 108
 
109 109
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
   public static function queryExistsIdInList($idList) {
116 116
     $query = null;
117 117
     if (!empty($idList)) {
118
-      $query = doquery("SELECT `" . static::$_idField . "` FROM `{{" . static::$_table . "}}` WHERE `" . static::$_idField . "` IN (" . implode(',', $idList) . ")");
118
+      $query = doquery("SELECT `".static::$_idField."` FROM `{{".static::$_table."}}` WHERE `".static::$_idField."` IN (".implode(',', $idList).")");
119 119
     }
120 120
 
121 121
     return !empty($query) ? $query : null;
Please login to merge, or discard this patch.
admin/ajax_maintenance.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
 
3 3
 define('IN_ADMIN', true);
4 4
 
5
-require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1));
5
+require('../includes/init.'.substr(strrchr(__FILE__, '.'), 1));
6 6
 
7
-if($user['authlevel'] < 3)
7
+if ($user['authlevel'] < 3)
8 8
 {
9 9
   message(classLocale::$lang['sys_noalloaw'], classLocale::$lang['sys_noaccess']);
10 10
   die();
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 // [#] info_best_battles 1b0
21 21
 $best_reports = array();
22 22
 
23
-if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) {
23
+if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) {
24 24
   $query = db_ube_report_get_best_battles();
25
-  while($row = db_fetch($query)) {
25
+  while ($row = db_fetch($query)) {
26 26
     $best_reports[] = $row['ube_report_id'];
27 27
   }
28 28
 }
29
-$best_reports = !empty($best_reports) ? ' AND ube_report_id NOT IN (' . implode(',', $best_reports) . ')' : '';
29
+$best_reports = !empty($best_reports) ? ' AND ube_report_id NOT IN ('.implode(',', $best_reports).')' : '';
30 30
 
31 31
 
32 32
 $ques = array(
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
   // Удаляем юниты без планет
91 91
   'DELETE un FROM {{unit}} AS un
92 92
     LEFT JOIN {{planets}} AS pl ON pl.id = un.unit_location_id
93
-  WHERE unit_location_type = ' . LOC_PLANET . ' AND pl.id IS NULL;',
93
+  WHERE unit_location_type = ' . LOC_PLANET.' AND pl.id IS NULL;',
94 94
   // Удаляем пустые юниты с 0 уровнем (кроме Капитана)
95
-  'DELETE FROM {{unit}} WHERE unit_location_type = ' . LOC_PLANET . ' AND unit_level = 0 AND unit_type <> ' . UNIT_CAPTAIN,
95
+  'DELETE FROM {{unit}} WHERE unit_location_type = '.LOC_PLANET.' AND unit_level = 0 AND unit_type <> '.UNIT_CAPTAIN,
96 96
   // Удаляем очереди на ничьих планетах
97 97
   'DELETE q FROM {{que}} AS q
98 98
     LEFT JOIN {{planets}} AS p ON p.id = q.que_planet_id
99 99
   WHERE
100
-    que_type IN (' . QUE_STRUCTURES . ', ' . QUE_HANGAR . ', ' . SUBQUE_FLEET . ', ' . SUBQUE_DEFENSE . ')
100
+    que_type IN (' . QUE_STRUCTURES.', '.QUE_HANGAR.', '.SUBQUE_FLEET.', '.SUBQUE_DEFENSE.')
101 101
     AND
102 102
     (p.id_owner = 0 OR p.id_owner IS NULL);',
103 103
 
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
   // Удаляются сообщения, старше  4 недель, кроме личных и Альянсовских
113 113
   'DELETE FROM {{messages}} WHERE
114 114
     UNIX_TIMESTAMP() - message_time > 4*7 * 24 * 60 * 60 AND
115
-    message_type NOT IN (' . MSG_TYPE_PLAYER . ', ' . MSG_TYPE_ALLIANCE . ');',
115
+    message_type NOT IN (' . MSG_TYPE_PLAYER.', '.MSG_TYPE_ALLIANCE.');',
116 116
   // Удаляются сообщения у пользователей, которые неактивны больше 4 недель - кроме личных и Альянсовских
117 117
   'DELETE m FROM `{{users}}` AS u
118 118
   JOIN {{messages}} AS m ON m.message_owner = u.id
119 119
   WHERE
120
-    message_type NOT IN (' . MSG_TYPE_PLAYER . ', ' . MSG_TYPE_ALLIANCE . ') AND
120
+    message_type NOT IN (' . MSG_TYPE_PLAYER.', '.MSG_TYPE_ALLIANCE.') AND
121 121
     authlevel = 0 AND  user_as_ally IS NULL AND /* Не админы, Не Альянсы */
122 122
     UNIX_TIMESTAMP() - onlinetime > 4*7 *86400;',
123 123
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
       (log_dark_matter_timestamp, log_dark_matter_username, log_dark_matter_reason, log_dark_matter_amount,
138 138
       log_dark_matter_comment, log_dark_matter_page, log_dark_matter_sender)
139 139
     SELECT
140
-      '{$pack_until}', IF(u.username IS NULL, ldm.log_dark_matter_username, u.username), " . RPG_CUMULATIVE . ", sum(ldm.log_dark_matter_amount),
140
+      '{$pack_until}', IF(u.username IS NULL, ldm.log_dark_matter_username, u.username), ".RPG_CUMULATIVE.", sum(ldm.log_dark_matter_amount),
141 141
       'Баланс на {$pack_until}', 'admin/ajax_maintenance.php', ldm.log_dark_matter_sender
142 142
     FROM
143 143
       {{log_dark_matter}} AS ldm
@@ -155,22 +155,22 @@  discard block
 block discarded – undo
155 155
     "REPLACE INTO `{{log_users_online}}`
156 156
       (online_timestamp, online_count, online_aggregated)
157 157
     SELECT
158
-      FROM_UNIXTIME((UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10 . ") * (" . PERIOD_MINUTE_10 . ")), ceil(avg(online_count)), " . LOG_ONLIINE_AGGREGATE_PERIOD_MINUTE_10 . "
158
+      FROM_UNIXTIME((UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10.") * (".PERIOD_MINUTE_10.")), ceil(avg(online_count)), ".LOG_ONLIINE_AGGREGATE_PERIOD_MINUTE_10."
159 159
     FROM
160 160
       `{{log_users_online}}`
161 161
     WHERE
162
-      online_timestamp < '{$pack_until}' AND online_aggregated = " . LOG_ONLIINE_AGGREGATE_NONE . "
162
+      online_timestamp < '{$pack_until}' AND online_aggregated = ".LOG_ONLIINE_AGGREGATE_NONE."
163 163
     GROUP BY
164
-      (UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10 . ") * (" . PERIOD_MINUTE_10 . ");",
164
+      (UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10.") * (".PERIOD_MINUTE_10.");",
165 165
 
166
-    "DELETE FROM {{log_users_online}} WHERE online_timestamp < '{$pack_until}' AND online_aggregated = " . LOG_ONLIINE_AGGREGATE_NONE,
166
+    "DELETE FROM {{log_users_online}} WHERE online_timestamp < '{$pack_until}' AND online_aggregated = ".LOG_ONLIINE_AGGREGATE_NONE,
167 167
   ),
168 168
 
169 169
   // Удаляем старые записи из логов
170 170
   "DELETE FROM `{{logs}}` WHERE log_timestamp < '{$pack_until}';",
171 171
   // Удаляем записи о маинтенансе, апдейте и пересчете статистики более чем недельной давности - они нам уже не нужны
172 172
   'DELETE FROM `{{logs}}` WHERE
173
-    `log_code` IN (' . LOG_INFO_DB_CHANGE . ', ' . LOG_INFO_MAINTENANCE . ', ' . LOG_INFO_STAT_START . ', ' . LOG_INFO_STAT_PROCESS . ', ' . LOG_INFO_STAT_FINISH . ')
173
+    `log_code` IN (' . LOG_INFO_DB_CHANGE.', '.LOG_INFO_MAINTENANCE.', '.LOG_INFO_STAT_START.', '.LOG_INFO_STAT_PROCESS.', '.LOG_INFO_STAT_FINISH.')
174 174
     AND `log_timestamp` < DATE_SUB(NOW(),INTERVAL 7 DAY);',
175 175
 
176 176
 
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 $old_server_status == GAME_DISABLE_NONE ? classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false;
190 190
 sn_db_transaction_commit();
191 191
 
192
-foreach($ques as $que_transaction) {
192
+foreach ($ques as $que_transaction) {
193 193
   sn_db_transaction_start();
194 194
 
195 195
   !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false;
196
-  foreach($que_transaction as $que) {
196
+  foreach ($que_transaction as $que) {
197 197
     set_time_limit(120);
198
-    if(is_callable($que)) {
198
+    if (is_callable($que)) {
199 199
       $QryResult = call_user_func($que);
200 200
     } else {
201 201
       $QryResult = doquery($que);
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
     //$que = str_replace('}}', '', $que);
207 207
 
208 208
     $msg .=
209
-      '<li>' . htmlspecialchars($que) .
210
-        ' --- <span style="' . ($QryResult ? 'ok">OK' : 'error">FAILED!') . '</span> ' .
211
-      classSupernova::$db->db_affected_rows() . ' ' . classLocale::$lang['adm_records'] .
209
+      '<li>'.htmlspecialchars($que).
210
+        ' --- <span style="'.($QryResult ? 'ok">OK' : 'error">FAILED!').'</span> '.
211
+      classSupernova::$db->db_affected_rows().' '.classLocale::$lang['adm_records'].
212 212
       "</li>";
213 213
 
214
-    classSupernova::$debug->warning($que . ' --- ' . ($QryResult ? 'OK' : 'FAILED!') . ' ' . classSupernova::$db->db_affected_rows() . ' ' . classLocale::$lang['adm_records'], 'System maintenance', LOG_INFO_MAINTENANCE);
214
+    classSupernova::$debug->warning($que.' --- '.($QryResult ? 'OK' : 'FAILED!').' '.classSupernova::$db->db_affected_rows().' '.classLocale::$lang['adm_records'], 'System maintenance', LOG_INFO_MAINTENANCE);
215 215
   }
216 216
 
217 217
   sn_db_transaction_commit();
@@ -239,5 +239,5 @@  discard block
 block discarded – undo
239 239
 
240 240
 $adm_stat_title = classLocale::$lang['adm_stat_title'];
241 241
 $result = $result ? "<li>{$adm_stat_title} - {$result}</li>" : '';
242
-$result = '<div align="left"><ul>' . $msg . $result . '</ul></div>';
243
-echo json_encode($result . ' ' . $totaltime);
242
+$result = '<div align="left"><ul>'.$msg.$result.'</ul></div>';
243
+echo json_encode($result.' '.$totaltime);
Please login to merge, or discard this patch.
includes/db/db_queries_users.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 
45 45
 function db_user_list_set_mass_mail(&$owners_list, $set) {
46
-  return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : '', $set);
46
+  return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : '', $set);
47 47
 }
48 48
 
49 49
 function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 }
67 67
 
68 68
 function db_user_count($online = false) {
69
-  $result = doquery('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) : ''), true);
69
+  $result = doquery('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) : ''), true);
70 70
 
71 71
   return isset($result['user_count']) ? $result['user_count'] : 0;
72 72
 }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     "SELECT `id` AS `ID`, `username` AS `NAME`, `ally_name` AS `ALLY`, `total_points` AS `STAT_POINTS`,
93 93
       `onlinetime` AS `ACTIVITY`
94 94
     FROM `{{users}}`
95
-    WHERE `onlinetime` >= " . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) . " ORDER BY user_as_ally, `" . $TypeSort . "` ASC;");
95
+    WHERE `onlinetime` >= " . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout)." ORDER BY user_as_ally, `".$TypeSort."` ASC;");
96 96
 }
97 97
 
98 98
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
   return doquery("SELECT u.*, COUNT(r.id) AS referral_count, SUM(r.dark_matter) AS referral_dm FROM {{users}} as u
106 106
     LEFT JOIN {{referrals}} as r on r.id_partner = u.id
107 107
     WHERE" .
108
-    ($online ? " `onlinetime` >= " . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : ' user_as_ally IS NULL') .
108
+    ($online ? " `onlinetime` >= ".(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : ' user_as_ally IS NULL').
109 109
     " GROUP BY u.id
110 110
     ORDER BY user_as_ally, {$sort} ASC");
111 111
 }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
   !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false;
122 122
 
123 123
   $user_list = array();
124
-  foreach($user_id_list as $user_id_unsafe) {
124
+  foreach ($user_id_list as $user_id_unsafe) {
125 125
     $user = db_user_by_id($user_id_unsafe);
126 126
     !empty($user) ? $user_list[$user_id_unsafe] = $user : false;
127 127
   }
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
  * @return array|bool|mysqli_result|null
141 141
  */
142 142
 function db_user_list_non_bots() {
143
-  $query = doquery("SELECT `id` FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER . " FOR UPDATE;");
143
+  $query = doquery("SELECT `id` FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = ".USER_BOT_PLAYER." FOR UPDATE;");
144 144
 
145 145
   return $query;
146 146
 }
147 147
 
148 148
 function db_user_lock_with_target_owner_and_acs($user, $planet = array()) {
149
-  doquery("SELECT 1 FROM {{users}} WHERE `id` = " . idval($user['id']) .
150
-    (isset($planet['id_owner']) ? 'OR `id` = ' . idval($planet['id_owner']) . ' ' : '') .
149
+  doquery("SELECT 1 FROM {{users}} WHERE `id` = ".idval($user['id']).
150
+    (isset($planet['id_owner']) ? 'OR `id` = '.idval($planet['id_owner']).' ' : '').
151 151
   "FOR UPDATE;"
152 152
   );
153 153
 }
Please login to merge, or discard this patch.
tests/HelperArrayTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
    * @cover ::filter
53 53
    */
54 54
   public function testFilter() {
55
-    $callback = function ($value) {
55
+    $callback = function($value) {
56 56
       return !empty($value);
57 57
     };
58 58
 
Please login to merge, or discard this patch.