Completed
Push — work-fleets ( 874fb8...41da5d )
by SuperNova.WS
06:44
created
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/db_mysql.php 2 patches
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
   public function load_db_settings($configFile = '') {
97 97
     $dbsettings = array();
98 98
 
99
-    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false;
99
+    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false;
100 100
 
101 101
     require $configFile;
102 102
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     }
117 117
 
118 118
     if (empty($this->dbsettings)) {
119
-      $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
119
+      $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
120 120
     }
121 121
 
122 122
     // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     $sql = $query;
169 169
     if (strpos($sql, '{{') !== false) {
170 170
       foreach ($this->table_list as $tableName) {
171
-        $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
171
+        $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql);
172 172
       }
173 173
     }
174 174
 
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 
242 242
     $queryResult = null;
243 243
     try {
244
-      $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace));
244
+      $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace));
245 245
       if (!$queryResult) {
246 246
         throw new Exception();
247 247
       }
248 248
     } catch (Exception $e) {
249
-      classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error');
249
+      classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error');
250 250
     }
251 251
 
252 252
     return $queryResult;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     $safeFieldsAndValues = implode(',', $this->safeFieldsEqualValues($fieldsAndValues));
316 316
 //    $command = $replace == DB_INSERT_REPLACE ? 'REPLACE' : 'INSERT';
317 317
 //    $command .= $replace == DB_INSERT_IGNORE ? ' IGNORE' : '';
318
-    switch($replace) {
318
+    switch ($replace) {
319 319
       case DB_INSERT_IGNORE:
320 320
         $command = 'INSERT IGNORE';
321 321
       break;
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 
425 425
     $safeFields = array();
426 426
     // Adjusts overwritten by Sets
427
-    if($safeAdjust = implode(',', $this->safeFieldsAdjust($fieldsAdjust))) {
427
+    if ($safeAdjust = implode(',', $this->safeFieldsAdjust($fieldsAdjust))) {
428 428
       $safeFields[] = &$safeAdjust;
429 429
     }
430
-    if($safeFieldsEqualValues = implode(',', $this->safeFieldsEqualValues($fieldsSet))) {
430
+    if ($safeFieldsEqualValues = implode(',', $this->safeFieldsEqualValues($fieldsSet))) {
431 431
       $safeFields[] = &$safeFieldsEqualValues;
432 432
     }
433 433
     $safeFieldsString = implode(',', $safeFields);
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 
539 539
 
540 540
   protected function castAsDbValue($value) {
541
-    switch(gettype($value)) {
541
+    switch (gettype($value)) {
542 542
       case TYPE_INTEGER:
543 543
       case TYPE_DOUBLE:
544 544
         // do nothing
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
       case TYPE_EMPTY:
562 562
         // No-type defaults to string
563 563
       default:
564
-        $value = "'" . $this->db_escape((string)$value) . "'";
564
+        $value = "'".$this->db_escape((string) $value)."'";
565 565
       break;
566 566
     }
567 567
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
       if (is_int($fieldName)) {
590 590
         $result[$fieldName] = $fieldValue;
591 591
       } else {
592
-        $result[$fieldName] = "`{$fieldName}` = " . $this->castAsDbValue($fieldValue);
592
+        $result[$fieldName] = "`{$fieldName}` = ".$this->castAsDbValue($fieldValue);
593 593
       }
594 594
     }
595 595
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
       if (is_int($fieldName)) {
619 619
         $result[$fieldName] = $fieldValue;
620 620
       } else {
621
-        $result[$fieldName] = "`{$fieldName}` = `{$fieldName}` + (" . $this->castAsDbValue($fieldValue) . ")";
621
+        $result[$fieldName] = "`{$fieldName}` = `{$fieldName}` + (".$this->castAsDbValue($fieldValue).")";
622 622
       }
623 623
     }
624 624
 
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
     }
650 650
 
651 651
     foreach ($fields as $key => $value) {
652
-      $result[$key] = "`" . $this->db_escape($value) . "`";
652
+      $result[$key] = "`".$this->db_escape($value)."`";
653 653
     }
654 654
 
655 655
     return $result;
@@ -705,10 +705,10 @@  discard block
 block discarded – undo
705 705
       $this->isWatching = true;
706 706
       $msg = "\$query = \"{$query}\"\n\r";
707 707
       if (!empty($_POST)) {
708
-        $msg .= "\n\r" . dump($_POST, '$_POST');
708
+        $msg .= "\n\r".dump($_POST, '$_POST');
709 709
       }
710 710
       if (!empty($_GET)) {
711
-        $msg .= "\n\r" . dump($_GET, '$_GET');
711
+        $msg .= "\n\r".dump($_GET, '$_GET');
712 712
       }
713 713
       classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
714 714
       $this->isWatching = false;
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 
724 724
     global $user, $dm_change_legit, $mm_change_legit;
725 725
 
726
-    switch(true) {
726
+    switch (true) {
727 727
       case stripos($query, 'RUNCATE TABL') != false:
728 728
       case stripos($query, 'ROP TABL') != false:
729 729
       case stripos($query, 'ENAME TABL') != false:
@@ -734,37 +734,37 @@  discard block
 block discarded – undo
734 734
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
735 735
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
736 736
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
737
-        $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
737
+        $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
738 738
         $report .= ">Database Inforamation\n";
739
-        $report .= "\tID - " . $user['id'] . "\n";
740
-        $report .= "\tUser - " . $user['username'] . "\n";
741
-        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
742
-        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
743
-        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
744
-        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
745
-        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
746
-        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
747
-        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
748
-        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
739
+        $report .= "\tID - ".$user['id']."\n";
740
+        $report .= "\tUser - ".$user['username']."\n";
741
+        $report .= "\tAuth level - ".$user['authlevel']."\n";
742
+        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
743
+        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
744
+        $report .= "\tUser IP - ".$user['user_lastip']."\n";
745
+        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
746
+        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
747
+        $report .= "\tCurrent Page - ".$user['current_page']."\n";
748
+        $report .= "\tRegister Time - ".$user['register_time']."\n";
749 749
         $report .= "\n";
750 750
 
751 751
         $report .= ">Query Information\n";
752
-        $report .= "\tQuery - " . $query . "\n";
752
+        $report .= "\tQuery - ".$query."\n";
753 753
         $report .= "\n";
754 754
 
755 755
         $report .= ">\$_SERVER Information\n";
756
-        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
757
-        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
758
-        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
759
-        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
760
-        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
761
-        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
762
-        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
763
-        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
756
+        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
757
+        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
758
+        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
759
+        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
760
+        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
761
+        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
762
+        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
763
+        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
764 764
 
765 765
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
766 766
 
767
-        $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a');
767
+        $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a');
768 768
         fwrite($fp, $report);
769 769
         fclose($fp);
770 770
 
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
     $prefix_length = strlen($this->db_prefix);
786 786
 
787 787
     $tl = array();
788
-    while($row = $this->db_fetch($query)) {
788
+    while ($row = $this->db_fetch($query)) {
789 789
       foreach ($row as $table_name) {
790 790
         if (strpos($table_name, $this->db_prefix) === 0) {
791 791
           $table_name = substr($table_name, $prefix_length);
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
     if (is_bool($query)) {
917 917
       throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?');
918 918
     }
919
-    while($row = db_fetch($query)) {
919
+    while ($row = db_fetch($query)) {
920 920
       $result[$row['Variable_name']] = $row['Value'];
921 921
     }
922 922
 
Please login to merge, or discard this patch.
Doc Comments   +33 added lines, -5 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
   /**
163 163
    * @param string $query
164 164
    *
165
-   * @return mixed|string
165
+   * @return string
166 166
    */
167 167
   public function replaceTablePlaceholders($query) {
168 168
     $sql = $query;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
   }
177 177
 
178 178
   /**
179
-   * @param $query
179
+   * @param string $query
180 180
    */
181 181
   protected function logQuery($query) {
182 182
     if (!classSupernova::$config->debug) {
@@ -306,10 +306,16 @@  discard block
 block discarded – undo
306 306
   }
307 307
 
308 308
 
309
+  /**
310
+   * @param string $query
311
+   */
309 312
   public function doInsertComplex($query) {
310 313
     return $this->doExecute($query);
311 314
   }
312 315
 
316
+  /**
317
+   * @param integer $replace
318
+   */
313 319
   protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) {
314 320
     $tableSafe = $this->db_escape($table);
315 321
     $safeFieldsAndValues = implode(',', $this->safeFieldsEqualValues($fieldsAndValues));
@@ -342,6 +348,9 @@  discard block
 block discarded – undo
342 348
     return $this->doSet($table, $fieldsAndValues, $replace);
343 349
   }
344 350
 
351
+  /**
352
+   * @param string $table
353
+   */
345 354
   public function doReplaceSet($table, $fieldsAndValues) {
346 355
     return $this->doSet($table, $fieldsAndValues, DB_INSERT_REPLACE);
347 356
   }
@@ -376,7 +385,7 @@  discard block
 block discarded – undo
376 385
    * Values should be passed as-is
377 386
    *
378 387
    * @param string   $table
379
-   * @param array    $fields
388
+   * @param string[]    $fields
380 389
    * @param string[] $values
381 390
    *
382 391
    * @return array|bool|mysqli_result|null
@@ -411,7 +420,7 @@  discard block
 block discarded – undo
411 420
    * Self-contained - means no params used
412 421
    * Such queries usually used to make large amount of in-base calculations
413 422
    *
414
-   * @param $query
423
+   * @param string $query
415 424
    *
416 425
    * @return array|bool|mysqli_result|null
417 426
    */
@@ -419,6 +428,9 @@  discard block
 block discarded – undo
419 428
     return $this->doExecute($query);
420 429
   }
421 430
 
431
+  /**
432
+   * @param boolean $isOneRecord
433
+   */
422 434
   protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL) {
423 435
     $tableSafe = $this->db_escape($table);
424 436
 
@@ -442,10 +454,16 @@  discard block
 block discarded – undo
442 454
     return $this->doExecute($query);
443 455
   }
444 456
 
457
+  /**
458
+   * @param string $table
459
+   */
445 460
   public function doUpdateRowSet($table, $fieldsAndValues, $where) {
446 461
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE);
447 462
   }
448 463
 
464
+  /**
465
+   * @param string $table
466
+   */
449 467
   public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) {
450 468
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL);
451 469
   }
@@ -454,6 +472,9 @@  discard block
 block discarded – undo
454 472
     return $this->doUpdateWhere($table, $fieldsSet, $fieldsAdjust, $where, DB_RECORD_ONE);
455 473
   }
456 474
 
475
+  /**
476
+   * @param string $table
477
+   */
457 478
   public function doUpdateTableAdjust($table, $fieldsSet, $fieldsAdjust, $where) {
458 479
     return $this->doUpdateWhere($table, $fieldsSet, $fieldsAdjust, $where, DB_RECORDS_ALL);
459 480
   }
@@ -526,7 +547,7 @@  discard block
 block discarded – undo
526 547
    *
527 548
    * Usually used for mallformed $where conditions
528 549
    *
529
-   * @param $table
550
+   * @param string $table
530 551
    * @param $where
531 552
    *
532 553
    * @return array|bool|mysqli_result|null
@@ -693,6 +714,10 @@  discard block
 block discarded – undo
693 714
   }
694 715
 
695 716
   // TODO Заменить это на новый логгер
717
+
718
+  /**
719
+   * @param string $query
720
+   */
696 721
   protected function security_watch_user_queries($query) {
697 722
     global $user;
698 723
 
@@ -716,6 +741,9 @@  discard block
 block discarded – undo
716 741
   }
717 742
 
718 743
 
744
+  /**
745
+   * @param string $query
746
+   */
719 747
   public function security_query_check_bad_words($query) {
720 748
     if ($this->skipQueryCheck) {
721 749
       return;
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_request.inc 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 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
 
@@ -8,16 +8,16 @@  discard block
 block discarded – undo
8 8
   message(classLocale::$lang['Denied_access'], classLocale::$lang['requests_admin']);
9 9
 }
10 10
 
11
-if($d = sys_get_param_id('d')) {
11
+if ($d = sys_get_param_id('d')) {
12 12
   DBStaticAlly::db_ally_request_deny($d);
13 13
 }
14 14
 
15 15
 $id_user = sys_get_param_id('id_user');
16 16
 
17
-if($id_user) {
17
+if ($id_user) {
18 18
   $ally_name_safe = db_escape($ally['ally_name']);
19 19
   $ally_tag_safe = db_escape($ally['ally_tag']);
20
-  DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0");
20
+  DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = ".SN_TIME_NOW.", `ally_rank_id` = 0");
21 21
   classSupernova::$db->doUpdateRowAdjust(
22 22
     TABLE_ALLIANCE,
23 23
     array(),
Please login to merge, or discard this patch.
includes/db.php 2 patches
Doc Comments   +7 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 /**
13 13
  * @param $adjust
14
- * @param $location
14
+ * @param integer $location
15 15
  * @param $object_id
16 16
  */
17 17
 function db_change_units_perform($adjust, $location, $object_id) {
@@ -32,7 +32,6 @@  discard block
 block discarded – undo
32 32
  * @param       $user
33 33
  * @param       $planet
34 34
  * @param array $unit_list
35
- * @param null  $query
36 35
  */
37 36
 function db_change_units(&$user, &$planet, $unit_list) {
38 37
   $query = array(
@@ -74,6 +73,9 @@  discard block
 block discarded – undo
74 73
   db_change_units_perform($query[LOC_USER], LOC_USER, $user['id']);
75 74
   db_change_units_perform($query[LOC_PLANET], LOC_PLANET, $planet['id']);
76 75
 }
76
+/**
77
+ * @param string $table
78
+ */
77 79
 function sn_db_perform($table, $values, $type = 'insert', $options = false) {
78 80
   $field_set = '';
79 81
 
@@ -163,6 +165,9 @@  discard block
 block discarded – undo
163 165
 
164 166
 
165 167
 
168
+/**
169
+ * @param boolean $transaction_should_be_started
170
+ */
166 171
 function sn_db_transaction_check($transaction_should_be_started = null) {
167 172
   return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started);
168 173
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 
43 43
   $group = sn_get_groups('resources_loot');
44 44
 
45
-  foreach($unit_list as $unit_id => $unit_amount) {
46
-    if(!in_array($unit_id, $group)) {
45
+  foreach ($unit_list as $unit_id => $unit_amount) {
46
+    if (!in_array($unit_id, $group)) {
47 47
       // TODO - remove later
48 48
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>');
49 49
       pdump(debug_backtrace());
50 50
       die('db_change_units() вызван для не-ресурсов!');
51 51
     }
52 52
 
53
-    if(empty($unit_amount)) {
53
+    if (empty($unit_amount)) {
54 54
       continue;
55 55
     }
56 56
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     $unit_location = sys_get_unit_location($user, $planet, $unit_id);
60 60
 
61 61
     // Changing value in object
62
-    switch($unit_location) {
62
+    switch ($unit_location) {
63 63
       case LOC_USER:
64 64
         $user[$unit_db_name] += $unit_amount;
65 65
         break;
@@ -77,30 +77,30 @@  discard block
 block discarded – undo
77 77
 function sn_db_perform($table, $values, $type = 'insert', $options = false) {
78 78
   $field_set = '';
79 79
 
80
-  switch($type) {
80
+  switch ($type) {
81 81
     case 'delete':
82 82
       $query = 'DELETE FROM';
83 83
       break;
84 84
 
85 85
     case 'insert':
86 86
       $query = 'INSERT INTO';
87
-      if(isset($options['__multi'])) {
87
+      if (isset($options['__multi'])) {
88 88
         // Here we generate mass-insert set
89 89
         break;
90 90
       }
91 91
     case 'update':
92
-      if(!$query) {
92
+      if (!$query) {
93 93
         $query = 'UPDATE';
94 94
       }
95 95
 
96
-      foreach($values as $field => &$value) {
96
+      foreach ($values as $field => &$value) {
97 97
         $value_type = gettype($value);
98 98
         if ($value_type == TYPE_STRING) {
99
-          $value = "'" . db_escape($value) . "'";
99
+          $value = "'".db_escape($value)."'";
100 100
         }
101 101
         $value = "`{$field}` = {$value}";
102 102
       }
103
-      $field_set = 'SET ' . implode(', ', $values);
103
+      $field_set = 'SET '.implode(', ', $values);
104 104
       break;
105 105
 
106 106
   };
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
   $field_set['__IS_SAFE'] = true;
122 122
 }
123 123
 function sn_db_field_set_make_safe($field_set, $serialize = false) {
124
-  if(!is_array($field_set)) {
124
+  if (!is_array($field_set)) {
125 125
     die('$field_set is not an array!');
126 126
   }
127 127
 
128 128
   $result = array();
129
-  foreach($field_set as $field => $value) {
129
+  foreach ($field_set as $field => $value) {
130 130
     $field = db_escape(trim($field));
131 131
     switch (true) {
132 132
       case is_int($value):
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $serialize ? $value = serialize($value) : die('$value is object or array with no $serialize');
143 143
 
144 144
       case is_string($value):
145
-        $value = '"' . db_escape($value) . '"';
145
+        $value = '"'.db_escape($value).'"';
146 146
         break;
147 147
 
148 148
       case is_null($value):
Please login to merge, or discard this patch.