Completed
Push — work-fleets ( 0f036f...867546 )
by SuperNova.WS
06:49
created
includes/classes/DBStaticMessages.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -467,6 +467,12 @@
 block discarded – undo
467 467
   {$StartRec}, 25;");
468 468
   }
469 469
 
470
+  /**
471
+   * @param integer $message_type
472
+   * @param string $from_unsafe
473
+   * @param string $subject_unsafe
474
+   * @param string $text_unsafe
475
+   */
470 476
   public static function db_message_insert_all($message_type, $from_unsafe, $subject_unsafe, $text_unsafe) {
471 477
     $message_type_safe = intval($message_type);
472 478
     $from_safe = db_escape($from_unsafe);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         sys_user_options_unpack($owner_row);
114 114
 
115 115
         if ($force || !$message_class['switchable'] || $owner_row["opt_{$message_class_name}"]) {
116
-          $insert_values[] = "('" . idval($owner) . "', '{$sender}', '{$timestamp}', '{$message_type}', '" . db_escape($from_unsafe) . "', '" . db_escape($subject_unsafe) . "', '" . db_escape($text_unsafe) . "')";
116
+          $insert_values[] = "('".idval($owner)."', '{$sender}', '{$timestamp}', '{$message_type}', '".db_escape($from_unsafe)."', '".db_escape($subject_unsafe)."', '".db_escape($text_unsafe)."')";
117 117
         }
118 118
 
119 119
         // TODO - allow sending HTML email only from admin
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         array(),
154 154
         array(
155 155
           // TODO DANGER
156
-          '`id` IN (' . implode(',', $owners) . ')',
156
+          '`id` IN ('.implode(',', $owners).')',
157 157
         )
158 158
       );
159 159
     }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     $sendList = array();
173 173
     $list = '';
174 174
     $query = DBStaticUser::db_user_list(
175
-      "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
175
+      "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
176 176
       false, 'id, username');
177 177
     foreach ($query as $u) {
178 178
       $sendList[] = $u['id'];
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
       $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix']));
262 262
       $re++;
263 263
     }
264
-    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false;
264
+    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false;
265 265
 
266 266
     $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default'];
267 267
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
     return classSupernova::$db->doSelect(
438 438
       "SELECT * FROM {{messages}}
439 439
         WHERE
440
-          `message_type` = '" . MSG_TYPE_PLAYER . "' AND
440
+          `message_type` = '" . MSG_TYPE_PLAYER."' AND
441 441
           ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}')
442 442
           OR
443 443
           (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;");
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 FROM
482 482
   {{messages}} AS m
483 483
   LEFT JOIN {{users}} AS u ON u.id = m.message_owner " .
484
-      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') .
484
+      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '').
485 485
       "ORDER BY
486 486
   `message_id` DESC
487 487
 LIMIT
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     $subject_safe = db_escape($subject_unsafe);
495 495
     $text_safe = db_escape($text_unsafe);
496 496
 
497
-    return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
497
+    return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '.
498 498
       "SELECT `id`, 0, unix_timestamp(now()), {$message_type_safe}, '{$from_safe}', '{$subject_safe}', '{$text_safe}' FROM {{users}}");
499 499
   }
500 500
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
    * @return array|bool|mysqli_result|null
505 505
    */
506 506
   public static function db_message_count_by_type($int_type_selected) {
507
-    $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
507
+    $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
508 508
 
509 509
     return $page_max;
510 510
   }
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
    */
540 540
   public static function db_message_list_delete_by_date($delete_date, $int_type_selected) {
541 541
     $where = array();
542
-    if($int_type_selected >= 0) {
542
+    if ($int_type_selected >= 0) {
543 543
       $where['message_type'] = $int_type_selected;
544 544
     }
545 545
     classSupernova::$db->doDeleteDanger(
Please login to merge, or discard this patch.
includes/db/db_queries.php 2 patches
Doc Comments   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -169,6 +169,11 @@  discard block
 block discarded – undo
169 169
  */
170 170
 // OK v4
171 171
 // TODO - вынести в отдельный класс
172
+/**
173
+ * @param string $db_id_field_name
174
+ * @param string $db_table_name
175
+ * @param string $db_value_field_name
176
+ */
172 177
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
173 178
   $current_value_safe = db_escape($current_value_unsafe);
174 179
   $value_id = classSupernova::$db->doSelectFetch("SELECT `{$db_id_field_name}` FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE");
@@ -487,8 +492,8 @@  discard block
 block discarded – undo
487 492
 
488 493
 
489 494
 /**
490
- * @param $user_id
491
- * @param $change_type
495
+ * @param integer $user_id
496
+ * @param integer $change_type
492 497
  * @param $dark_matter
493 498
  * @param $comment_unsafe
494 499
  * @param $rowUserNameUnsafe
@@ -509,7 +514,7 @@  discard block
 block discarded – undo
509 514
 /**
510 515
  * @param $user_id_safe
511 516
  *
512
- * @return array|bool|mysqli_result|null
517
+ * @return integer
513 518
  */
514 519
 function db_referral_get_by_id($user_id_safe) {
515 520
   $old_referral = classSupernova::$db->doSelectFetch("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;");
@@ -540,9 +545,9 @@  discard block
 block discarded – undo
540 545
 
541 546
 // Quests ***********************************************************************************************************
542 547
 /**
543
- * @param $query_add_select
548
+ * @param string $query_add_select
544 549
  * @param $query_add_from
545
- * @param $query_add_where
550
+ * @param string $query_add_where
546 551
  *
547 552
  * @return array|bool|mysqli_result|null
548 553
  */
@@ -586,11 +591,11 @@  discard block
 block discarded – undo
586 591
 }
587 592
 
588 593
 /**
589
- * @param $quest_name_unsafe
590
- * @param $quest_type
591
- * @param $quest_description_unsafe
594
+ * @param string $quest_name_unsafe
595
+ * @param integer $quest_type
596
+ * @param string $quest_description_unsafe
592 597
  * @param $quest_conditions
593
- * @param $quest_rewards
598
+ * @param string $quest_rewards
594 599
  * @param $quest_id
595 600
  */
596 601
 function db_quest_update($quest_name_unsafe, $quest_type, $quest_description_unsafe, $quest_conditions, $quest_rewards, $quest_id) {
@@ -674,7 +679,7 @@  discard block
 block discarded – undo
674 679
 
675 680
 /**
676 681
  * @param $payment_id
677
- * @param $payment_status
682
+ * @param integer $payment_status
678 683
  * @param $comment_unsafe
679 684
  */
680 685
 function db_payment_update($payment_id, $payment_status, $comment_unsafe) {
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 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);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
 
146 146
 function db_stat_list_update_ally_stats() {
147
-  return ;
147
+  return;
148 148
 }
149 149
 
150 150
 function db_stat_list_delete_ally_player() {
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
  */
395 395
 function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) {
396 396
   $extra_conditions =
397
-    ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') .
398
-    ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') .
399
-    ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') .
397
+    ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '').
398
+    ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '').
399
+    ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '').
400 400
     ($flt_module ? "AND payment_module_name = '{$flt_module}' " : '');
401 401
   $query = classSupernova::$db->doSelect("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;");
402 402
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 // Log Online *************************************************************************************************************
426 426
 function db_log_online_insert() {
427 427
   classSupernova::$db->doInsertSet(TABLE_LOG_USERS_ONLINE, array(
428
-    'online_count' => (int)classSupernova::$config->var_online_user_count,
428
+    'online_count' => (int) classSupernova::$config->var_online_user_count,
429 429
   ), DB_INSERT_IGNORE);
430 430
 }
431 431
 
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
 function db_log_delete_update_and_stat_calc() {
451 451
   classSupernova::$db->doDeleteSimple(
452 452
     'DELETE FROM `{{logs}}` WHERE `log_code` IN ('
453
-    . LOG_INFO_DB_CHANGE . ', '
454
-    . LOG_INFO_MAINTENANCE . ', '
455
-    . LOG_INFO_STAT_PROCESS .
453
+    . LOG_INFO_DB_CHANGE.', '
454
+    . LOG_INFO_MAINTENANCE.', '
455
+    . LOG_INFO_STAT_PROCESS.
456 456
     ')'
457 457
   );
458 458
 }
@@ -521,10 +521,10 @@  discard block
 block discarded – undo
521 521
 function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment_unsafe, $rowUserNameUnsafe, $page_url_unsafe) {
522 522
   return classSupernova::$db->doInsertSet(TABLE_LOG_DARK_MATTER, array(
523 523
     'log_dark_matter_username' => $rowUserNameUnsafe,
524
-    'log_dark_matter_reason'   => (int)$change_type,
525
-    'log_dark_matter_amount'   => (float)$dark_matter,
526
-    'log_dark_matter_comment'  => (string)$comment_unsafe,
527
-    'log_dark_matter_page'     => (string)$page_url_unsafe,
524
+    'log_dark_matter_reason'   => (int) $change_type,
525
+    'log_dark_matter_amount'   => (float) $dark_matter,
526
+    'log_dark_matter_comment'  => (string) $comment_unsafe,
527
+    'log_dark_matter_page'     => (string) $page_url_unsafe,
528 528
     'log_dark_matter_sender'   => $user_id,
529 529
   ));
530 530
 }
@@ -693,9 +693,9 @@  discard block
 block discarded – undo
693 693
 function db_ube_report_get_best_battles() {
694 694
   $query = classSupernova::$db->doSelect("SELECT *
695 695
       FROM `{{ube_report}}`
696
-      WHERE `ube_report_time_process` <  DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY))
696
+      WHERE `ube_report_time_process` <  DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY))
697 697
       ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC
698
-      LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";");
698
+      LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";");
699 699
 
700 700
   return $query;
701 701
 }
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_mail.inc 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
4 4
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
5 5
 }
6 6
 
7
-if(!$user_can_send_mails) {
7
+if (!$user_can_send_mails) {
8 8
   message(classLocale::$lang['Denied_access'], classLocale::$lang['Send_circular_mail']);
9 9
 }
10 10
 
11 11
 $POST_text = sys_get_param_str('text');
12 12
 $internalAliSendTextUnsafe = sys_get_param_str_unsafe('text');
13
-if($internalAliSendTextUnsafe) {
14
-  message(classLocale::$lang['members_who_recived_message'] . DBStaticMessages::msg_ali_send($internalAliSendTextUnsafe, classLocale::$lang['ali_adm_msg_subject'], sys_get_param_int('r')), classLocale::$lang['Circular_sended'], "alliance.php", '');
13
+if ($internalAliSendTextUnsafe) {
14
+  message(classLocale::$lang['members_who_recived_message'].DBStaticMessages::msg_ali_send($internalAliSendTextUnsafe, classLocale::$lang['ali_adm_msg_subject'], sys_get_param_int('r')), classLocale::$lang['Circular_sended'], "alliance.php", '');
15 15
 }
16 16
 
17
-$r_list = "<option value=\"-1\">" . classLocale::$lang['All_players'] . "</option>";
18
-if($ranks) {
19
-  foreach($ranks as $id => $array) {
20
-    $r_list .= "<option value=\"" . $id . "\">" . $array['name'] . "</option>";
17
+$r_list = "<option value=\"-1\">".classLocale::$lang['All_players']."</option>";
18
+if ($ranks) {
19
+  foreach ($ranks as $id => $array) {
20
+    $r_list .= "<option value=\"".$id."\">".$array['name']."</option>";
21 21
   }
22 22
 }
23 23
 
Please login to merge, or discard this patch.
includes/classes/DBRow.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
    * @param db_mysql|null $db
87 87
    */
88 88
   public static function setDb($db = null) {
89
-    if(empty($db) || !($db instanceof db_mysql)) {
89
+    if (empty($db) || !($db instanceof db_mysql)) {
90 90
       $db = null;
91 91
     }
92 92
     static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
   public function dbLoad($dbId, $lockSkip = false) {
150 150
     $dbId = idval($dbId);
151 151
     if ($dbId <= 0) {
152
-      classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId);
152
+      classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId);
153 153
 
154 154
       return;
155 155
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
       $this->dbGetLockById($this->_dbId);
162 162
     }
163 163
 
164
-    $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;");
164
+    $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;");
165 165
     if (empty($db_row)) {
166 166
       return;
167 167
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     if ($this->isNew()) {
194 194
       // No DB_ID - new unit
195 195
       if ($this->isEmpty()) {
196
-        classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave');
196
+        classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave');
197 197
       }
198 198
       $this->dbInsert();
199 199
     } else {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         $this->dbDelete();
203 203
       } else {
204 204
         if (!sn_db_transaction_check(false)) {
205
-          classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate');
205
+          classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate');
206 206
         }
207 207
         $this->dbUpdate();
208 208
       }
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
   // TODO - protected
231 231
   public function dbInsert() {
232 232
     if (!$this->isNew()) {
233
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert');
233
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert');
234 234
     }
235 235
 
236 236
     $fieldSet = $this->dbMakeFieldSet(false);
237 237
 
238 238
     if (!static::$db->doInsertSet(static::$_table, $fieldSet)) {
239
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert');
239
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert');
240 240
     }
241 241
     $this->_dbId = static::$db->db_insert_id();
242 242
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
   public function dbUpdate() {
251 251
     // TODO - Update
252 252
     if ($this->isNew()) {
253
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate');
253
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate');
254 254
     }
255 255
     $this->db_field_update($this->dbMakeFieldUpdate());
256 256
   }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
   // TODO - protected
262 262
   public function dbDelete() {
263 263
     if ($this->isNew()) {
264
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete');
264
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete');
265 265
     }
266 266
     classSupernova::$gc->db->doDeleteRowWhere(static::$_table, array(static::$_dbIdFieldName => $this->_dbId));
267 267
     $this->_dbId = 0;
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
       }
448 448
     }
449 449
 
450
-    if(empty($set)) {
450
+    if (empty($set)) {
451 451
       $theResult = true;
452 452
     } else {
453 453
       $theResult = classSupernova::$db->doUpdateRowAdjust(
Please login to merge, or discard this patch.
includes/classes/DBStaticUnit.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -118,6 +118,9 @@
 block discarded – undo
118 118
     return classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, $set);
119 119
   }
120 120
 
121
+  /**
122
+   * @param integer $unit_location_type
123
+   */
121 124
   public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) {
122 125
     $where = array('unit_location_type' => $unit_location_type);
123 126
     ($unit_location_id = idval($unit_location_id)) ? $where['unit_location_id'] = $unit_location_id : false;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
     if (classSupernova::$gc->snCache->isUnitLocatorNotSet($location_type, $location_id)) {
27
-      $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions());
27
+      $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions());
28 28
       if (!empty($got_data) && is_array($got_data)) {
29 29
         foreach ($got_data as $unit_id => $unit_data) {
30 30
           classSupernova::$gc->snCache->setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data);
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
   public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) {
61 61
     $query = classSupernova::$db->doSelect(
62
-      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} " .
63
-      ($unit_type ? "AND `unit_type` = {$unit_type} " : '') .
64
-      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') .
62
+      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} ".
63
+      ($unit_type ? "AND `unit_type` = {$unit_type} " : '').
64
+      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '').
65 65
       'GROUP BY `unit_snid`'
66 66
     );
67 67
     $result = array();
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     WHERE
82 82
       f.fleet_owner = {$user_id} AND
83 83
       (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id})
84
-      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() .
85
-      " LIMIT 1" .
84
+      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions().
85
+      " LIMIT 1".
86 86
       ($for_update ? ' FOR UPDATE' : ''));
87 87
   }
88 88
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
   public static function db_unit_list_laboratories($user_id) {
91 91
     return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id`
92 92
     FROM {{unit}}
93
-    WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");");
93
+    WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");");
94 94
   }
95 95
 
96 96
   /**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     return classSupernova::$db->doSelect(
137 137
       "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount
138 138
     FROM `{{unit}}`
139
-    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() .
139
+    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions().
140 140
       " GROUP BY unit_player_id, unit_type, unit_snid, unit_level"
141 141
     );
142 142
   }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
       ),
165 165
       array(
166 166
         'unit_time_finish IS NOT NULL',
167
-        "unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ")",
167
+        "unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.")",
168 168
       )
169 169
     );
170 170
   }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
     $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
205 205
     if (!empty($temp['unit_id'])) {
206
-      $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_by_id(
206
+      $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_by_id(
207 207
         LOC_UNIT,
208 208
         $temp['unit_id'],
209 209
         array(),
@@ -214,15 +214,15 @@  discard block
 block discarded – undo
214 214
     } else {
215 215
       $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id;
216 216
       $unitType = get_unit_param($unit_id, P_UNIT_TYPE);
217
-      $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record(
217
+      $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record(
218 218
         LOC_UNIT,
219 219
         array(
220 220
           'unit_player_id'     => $user['id'],
221
-          'unit_location_type' => (int)$unit_location,
221
+          'unit_location_type' => (int) $unit_location,
222 222
           'unit_location_id'   => $locationIdRendered,
223
-          'unit_type'          => (int)$unitType,
224
-          'unit_snid'          => (int)$unit_id,
225
-          'unit_level'         => (float)$unit_value,
223
+          'unit_type'          => (int) $unitType,
224
+          'unit_snid'          => (int) $unit_id,
225
+          'unit_level'         => (float) $unit_value,
226 226
         )
227 227
       );
228 228
     }
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -2,28 +2,28 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(SN_IN_FLEET !== true) {
5
+if (SN_IN_FLEET !== true) {
6 6
   classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
7 7
 }
8 8
 
9 9
 $fleetid = sys_get_param_id('fleetid');
10 10
 
11
-if(!is_numeric($fleetid) || empty($fleetid)) {
11
+if (!is_numeric($fleetid) || empty($fleetid)) {
12 12
   header("Location: fleet.php");
13 13
   exit();
14 14
 }
15 15
 
16 16
 $objFleet = new Fleet();
17 17
 $objFleet->dbLoad($fleetid);
18
-if(!$objFleet->dbId) {
18
+if (!$objFleet->dbId) {
19 19
   message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']);
20 20
 }
21 21
 
22
-if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
22
+if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
23 23
   message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']);
24 24
 }
25 25
 
26
-if($objFleet->playerOwnerId != $user['id']) {
26
+if ($objFleet->playerOwnerId != $user['id']) {
27 27
   classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
28 28
   message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']);
29 29
 }
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 
35 35
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
36 36
 
37
-if($userToAdd_unsafe) {
37
+if ($userToAdd_unsafe) {
38 38
   $userToAdd = db_escape($userToAdd_unsafe);
39 39
   $userToAddID = DBStaticUser::db_user_by_username($userToAdd_unsafe, false, 'id', true, true);
40 40
   $userToAddID = $userToAddID['id'];
41 41
 
42
-  if($objFleet->target_owner_id == $userToAddID) {
42
+  if ($objFleet->target_owner_id == $userToAddID) {
43 43
     message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']);
44 44
   }
45 45
 
46
-  if($userToAddID) {
47
-    if(!$aks) {
46
+  if ($userToAddID) {
47
+    if (!$aks) {
48 48
       // No AСS exists - making one
49
-      if(!$objFleet->group_id) {
49
+      if (!$objFleet->group_id) {
50 50
         DBStaticFleetACS::db_acs_insert($fleetid, $user['id'], $objFleet);
51 51
 
52 52
         $aks = DBStaticFleetACS::db_acs_get_by_fleet($fleetid);
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
 
62 62
     $isUserExists = false;
63 63
     $invited_ar = explode(",", $aks['eingeladen']);
64
-    foreach($invited_ar as $inv) {
65
-      if($userToAddID == $inv) {
64
+    foreach ($invited_ar as $inv) {
65
+      if ($userToAddID == $inv) {
66 66
         $isUserExists = true;
67 67
       }
68 68
     }
69 69
 
70
-    if(count($invited_ar) >= 5) {
70
+    if (count($invited_ar) >= 5) {
71 71
       message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']);
72 72
     }
73 73
 
74
-    if($isUserExists) {
74
+    if ($isUserExists) {
75 75
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false;
76 76
     } else {
77 77
       $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd);
78
-      if(!(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid))) {
78
+      if (!(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid))) {
79 79
         die(sprintf(classLocale::$lang['fl_aks_adding_error'], classSupernova::$db->db_error()));
80 80
       }
81
-      $aks['eingeladen'] .= ',' . $userToAddID;
81
+      $aks['eingeladen'] .= ','.$userToAddID;
82 82
     }
83 83
     DBStaticMessages::msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username']));
84 84
   } else {
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
   'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS],
95 95
 ));
96 96
 
97
-if($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
98
-  foreach($members as $row) {
97
+if ($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
98
+  foreach ($members as $row) {
99 99
     $template->assign_block_vars('invited', array(
100 100
       'NAME' => $row['username'],
101 101
     ));
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 $fleet_data = tplParseFleetObject($objFleet, $i, $user);
121 121
 
122 122
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
123
-foreach($fleet_data['ships'] as $ship_data) {
123
+foreach ($fleet_data['ships'] as $ship_data) {
124 124
   $template->assign_block_vars('fleets.ships', $ship_data);
125 125
 }
126 126
 
Please login to merge, or discard this patch.
includes/classes/DBStaticUser.php 2 patches
Doc Comments   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -104,6 +104,9 @@  discard block
 block discarded – undo
104 104
     return $result;
105 105
   }
106 106
 
107
+  /**
108
+   * @param integer $config_user_birthday_range
109
+   */
107 110
   public static function db_user_list_to_celebrate($config_user_birthday_range) {
108 111
     $query = static::buildDBQ()
109 112
       ->field('id', 'username', 'user_birthday', 'user_birthday_celebrated')
@@ -193,6 +196,9 @@  discard block
 block discarded – undo
193 196
   }
194 197
 
195 198
 
199
+  /**
200
+   * @param string $username_unsafe
201
+   */
196 202
   public static function db_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) {
197 203
     // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ?
198 204
     if (!($username_unsafe = trim($username_unsafe))) {
@@ -247,7 +253,6 @@  discard block
 block discarded – undo
247 253
 
248 254
   /**
249 255
    * @param $user_id
250
-   * @param array $set
251 256
    * @param array $adjust
252 257
    *
253 258
    * @return array|bool|mysqli_result|null
@@ -264,8 +269,8 @@  discard block
 block discarded – undo
264 269
    *    <p>array - запись пользователя с установленным полем ['id']</p>
265 270
    * @param bool      $for_update @deprecated
266 271
    * @param string    $fields @deprecated список полей или '*'/'' для всех полей
267
-   * @param null      $player
268
-   * @param bool|null $player Признак выбора записи пользователь типа "игрок"
272
+   * @param boolean      $player
273
+   * @param boolean $player Признак выбора записи пользователь типа "игрок"
269 274
    *    <p>null - Можно выбрать запись любого типа</p>
270 275
    *    <p>true - Выбирается только запись типа "игрок"</p>
271 276
    *    <p>false - Выбирается только запись типа "альянс"</p>
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         ->where('`user_as_ally` IS NULL')
24 24
         ->orderBy(array('`id` DESC'));
25 25
 
26
-    return (string)$query->selectValue();
26
+    return (string) $query->selectValue();
27 27
   }
28 28
 
29 29
   /**
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
       static::buildDBQ()
49 49
         ->field('id')
50 50
         ->where("`user_as_ally` IS NULL")
51
-        ->where("`user_bot` = " . USER_BOT_PLAYER)
51
+        ->where("`user_bot` = ".USER_BOT_PLAYER)
52 52
         ->setForUpdate();
53 53
 
54 54
     return $query->selectIterator();
55 55
   }
56 56
 
57 57
   public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) {
58
-    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) .
59
-      (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '')
58
+    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']).
59
+      (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '')
60 60
       . " FOR UPDATE";
61 61
 
62 62
     static::getDb()->doSelect($query);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
       FROM `{{users}}` 
74 74
       WHERE 
75 75
         `user_as_ally` IS NULL" .
76
-        ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
76
+        ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
77 77
     ));
78 78
   }
79 79
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
       ->fieldCount('r.id', 'referral_count')
96 96
       ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm')
97 97
       ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id')
98
-      ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
98
+      ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
99 99
       ->groupBy('u.id')
100 100
       ->orderBy("user_as_ally, {$sort} ASC");
101 101
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
       ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)')
114 114
       ->where('`user_as_ally` IS NULL')
115 115
       ->having('`days_after_birthday` >= 0')
116
-      ->having('`days_after_birthday` < ' . intval($config_user_birthday_range))
116
+      ->having('`days_after_birthday` < '.intval($config_user_birthday_range))
117 117
       ->setForUpdate();
118 118
 
119 119
     $result = $query->selectIterator();
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
223 223
 
224 224
       $user = classSupernova::$db->doSelectFetch(
225
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"
225
+        "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"
226 226
         . " FOR UPDATE"
227 227
       );
228 228
       classSupernova::$gc->snCache->cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
    * @param array $playerArray
314 314
    */
315 315
   public static function renderNameAndCoordinates($playerArray) {
316
-    return "{$playerArray['username']} " . uni_render_coordinates($playerArray);
316
+    return "{$playerArray['username']} ".uni_render_coordinates($playerArray);
317 317
   }
318 318
 
319 319
   /**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
     foreach ($playerRowFieldChanges as $resourceId => $value) {
348 348
       $fields[pname_resource_name($resourceId)] = $value;
349 349
     }
350
-    if(!empty($fields)) {
350
+    if (!empty($fields)) {
351 351
       classSupernova::$gc->db->doUpdateRowAdjust(
352 352
         TABLE_USERS,
353 353
         array(),
Please login to merge, or discard this patch.
includes/db.php 2 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@  discard block
 block discarded – undo
16 16
  * @param       $user
17 17
  * @param       $planet
18 18
  * @param array $unit_list
19
- * @param null  $query
20 19
  */
21 20
 function db_change_resources(&$user, &$planet, $unit_list) {
22 21
   $group = sn_get_groups('resources_loot');
@@ -56,6 +55,9 @@  discard block
 block discarded – undo
56 55
 
57 56
 }
58 57
 
58
+/**
59
+ * @param boolean $transaction_should_be_started
60
+ */
59 61
 function sn_db_transaction_check($transaction_should_be_started = null) {
60 62
   return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started);
61 63
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,22 +24,22 @@
 block discarded – undo
24 24
   $locationType = sys_get_unit_location($user, $planet, key($unit_list));
25 25
 
26 26
   $resourcesChange = array();
27
-  foreach($unit_list as $unit_id => $unit_amount) {
28
-    if(!in_array($unit_id, $group)) {
27
+  foreach ($unit_list as $unit_id => $unit_amount) {
28
+    if (!in_array($unit_id, $group)) {
29 29
       // TODO - remove later
30 30
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_resources() вызван для не-ресурсов!</h1>');
31 31
       pdump(debug_backtrace());
32 32
       die('db_change_resources() вызван для не-ресурсов!');
33 33
     }
34 34
 
35
-    if(empty($unit_amount)) {
35
+    if (empty($unit_amount)) {
36 36
       continue;
37 37
     }
38 38
 
39 39
     $resourcesChange[pname_resource_name($unit_id)] += $unit_amount;
40 40
   }
41 41
 
42
-  if($locationType == LOC_USER) {
42
+  if ($locationType == LOC_USER) {
43 43
     $locationId = $user['id'];
44 44
   } else {
45 45
     $locationId = $planet['id'];
Please login to merge, or discard this patch.
resources.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *
23 23
  **/
24 24
 
25
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
25
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
26 26
 
27 27
 /**
28 28
  * @param          $resource_id
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
   $storage_fill = $caps_real['total_storage'][$resource_id] ? floor(mrc_get_level($user, $planetrow, $resource_id) / $caps_real['total_storage'][$resource_id] * 100) : 0;
37 37
 
38 38
   $template->assign_block_vars('resources', array(
39
-    'NAME' => classLocale::$lang["sys_" . pname_resource_name($resource_id)],
39
+    'NAME' => classLocale::$lang["sys_".pname_resource_name($resource_id)],
40 40
 
41 41
     'HOURLY'  => pretty_number($totalProduction, true, true),
42 42
     'WEEKLY'  => pretty_number($totalProduction * 24 * 7, true, true),
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
       $planetrow[$field_name] = $percent;
77 77
       $SubQry[$field_name] = $percent;
78 78
     } else {
79
-      classSupernova::$debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301);
79
+      classSupernova::$debug->warning('Supplying wrong ID in production array - attempt to change some field - ID'.$prod_id, 'Resource Page', 301);
80 80
       continue;
81 81
     }
82 82
   }
83 83
 
84
-  if(!empty($SubQry)) {
84
+  if (!empty($SubQry)) {
85 85
     DBStaticPlanet::db_planet_update_set_by_id(
86 86
       $planetrow['id'],
87 87
       $SubQry
Please login to merge, or discard this patch.