Completed
Push — work-fleets ( 41da5d...c94fa6 )
by SuperNova.WS
06:35
created
includes/functions/rpg_points.php 1 patch
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -161,6 +161,9 @@  discard block
 block discarded – undo
161 161
   return $rows_affected;
162 162
 }
163 163
 
164
+/**
165
+ * @param integer $type
166
+ */
164 167
 function rpg_level_up(&$user, $type, $xp_to_add = 0)
165 168
 {
166 169
   $q = 1.03;
@@ -223,6 +226,10 @@  discard block
 block discarded – undo
223 226
   }
224 227
 }
225 228
 
229
+/**
230
+ * @param integer $b1
231
+ * @param double $q
232
+ */
226 233
 function rpg_xp_for_level($level, $b1, $q)
227 234
 {
228 235
   return floor($b1 * (pow($q, $level) - 1)/($q - 1));
@@ -233,6 +240,9 @@  discard block
 block discarded – undo
233 240
   return rpg_xp_for_level($level, 50, 1.03);
234 241
 }
235 242
 
243
+/**
244
+ * @param integer $level
245
+ */
236 246
 function RPG_get_raider_xp($level)
237 247
 {
238 248
   return rpg_xp_for_level($level, 10, 1.03);
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 1 patch
Doc Comments   +30 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, $fieldsAndValues, $where = array(), $isOneRecord = DB_RECORDS_ALL) {
423 435
     $tableSafe = $this->db_escape($table);
424 436
     $safeFieldsEqualValues = implode(',', $this->safeFieldsEqualValues($fieldsAndValues));
@@ -430,10 +442,16 @@  discard block
 block discarded – undo
430 442
     return $this->doExecute($query);
431 443
   }
432 444
 
445
+  /**
446
+   * @param string $table
447
+   */
433 448
   public function doUpdateRowWhere($table, $fieldsAndValues, $where) {
434 449
     return $this->doUpdateWhere($table, $fieldsAndValues, $where, DB_RECORD_ONE);
435 450
   }
436 451
 
452
+  /**
453
+   * @param string $table
454
+   */
437 455
   public function doUpdateTable($table, $fieldsAndValues, $where = array()) {
438 456
     return $this->doUpdateWhere($table, $fieldsAndValues, $where, DB_RECORDS_ALL);
439 457
   }
@@ -504,7 +522,7 @@  discard block
 block discarded – undo
504 522
    *
505 523
    * Usually used for mallformed $where conditions
506 524
    *
507
-   * @param $table
525
+   * @param string $table
508 526
    * @param $where
509 527
    *
510 528
    * @return array|bool|mysqli_result|null
@@ -642,6 +660,10 @@  discard block
 block discarded – undo
642 660
   }
643 661
 
644 662
   // TODO Заменить это на новый логгер
663
+
664
+  /**
665
+   * @param string $query
666
+   */
645 667
   protected function security_watch_user_queries($query) {
646 668
     global $user;
647 669
 
@@ -665,6 +687,9 @@  discard block
 block discarded – undo
665 687
   }
666 688
 
667 689
 
690
+  /**
691
+   * @param string $query
692
+   */
668 693
   public function security_query_check_bad_words($query) {
669 694
     if ($this->skipQueryCheck) {
670 695
       return;
Please login to merge, or discard this patch.
jumpgate.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@  discard block
 block discarded – undo
10 10
  * @copyright 2008 By Chlorel for XNova
11 11
  */
12 12
 
13
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
13
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
14 14
 
15 15
 lng_include('fleet');
16 16
 
17
-if($TargetPlanet = sys_get_param_id('jmpto'))
17
+if ($TargetPlanet = sys_get_param_id('jmpto'))
18 18
 {
19 19
   sn_db_transaction_start();
20 20
   DBStaticUser::db_user_by_id($user['id'], true, 'id');
21 21
   $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
22
-  if(!($NextJumpTime = uni_get_time_to_jump($planetrow)))
22
+  if (!($NextJumpTime = uni_get_time_to_jump($planetrow)))
23 23
   {
24 24
     $TargetGate = DBStaticPlanet::db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`');
25
-    if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0)
25
+    if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0)
26 26
     {
27
-      $NextDestTime = uni_get_time_to_jump ( $TargetGate );
28
-      if(!$NextDestTime)
27
+      $NextDestTime = uni_get_time_to_jump($TargetGate);
28
+      if (!$NextDestTime)
29 29
       {
30 30
         $ship_list = sys_get_param('ships');
31 31
         $jumpMade = false;
32
-        foreach($ship_list as $ship_id => $ship_count)
32
+        foreach ($ship_list as $ship_id => $ship_count)
33 33
         {
34
-          if(!in_array($ship_id, Fleet::$snGroupFleet))
34
+          if (!in_array($ship_id, Fleet::$snGroupFleet))
35 35
           {
36 36
             continue;
37 37
           }
38 38
 
39 39
           $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id)));
40
-          if($ship_count)
40
+          if ($ship_count)
41 41
           {
42 42
             $jumpMade = true;
43 43
             DBStaticUnit::dbUpdateOrInsertUnit($ship_id, -$ship_count, $user, $planetrow['id']);
@@ -45,39 +45,39 @@  discard block
 block discarded – undo
45 45
           }
46 46
         }
47 47
         // Dit monsieur, y avait quelque chose a envoyer ???
48
-        if($jumpMade)
48
+        if ($jumpMade)
49 49
         {
50
-          DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($TargetGate['id'], "`last_jump_time` = " . SN_TIME_NOW . "");
51
-          DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($planetrow['id'], "`last_jump_time` = " . SN_TIME_NOW . "");
50
+          DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($TargetGate['id'], "`last_jump_time` = ".SN_TIME_NOW."");
51
+          DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($planetrow['id'], "`last_jump_time` = ".SN_TIME_NOW."");
52 52
 
53 53
           DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], "`current_planet` = '{$TargetGate['id']}'");
54 54
 
55 55
           $planetrow['last_jump_time'] = SN_TIME_NOW;
56
-          $RetMessage = classLocale::$lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow));
56
+          $RetMessage = classLocale::$lang['gate_jump_done']." - ".pretty_time(uni_get_time_to_jump($planetrow));
57 57
         } else {
58 58
           $RetMessage = classLocale::$lang['gate_wait_data'];
59 59
         }
60 60
       } else {
61
-        $RetMessage = classLocale::$lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime);
61
+        $RetMessage = classLocale::$lang['gate_wait_dest']." - ".pretty_time($NextDestTime);
62 62
       }
63 63
     } else {
64 64
       $RetMessage = classLocale::$lang['gate_no_dest_g'];
65 65
     }
66 66
   } else {
67
-    $RetMessage = classLocale::$lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime);
67
+    $RetMessage = classLocale::$lang['gate_wait_star']." - ".pretty_time($NextJumpTime);
68 68
   }
69 69
   sn_db_transaction_commit();
70 70
   message($RetMessage, classLocale::$lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10);
71 71
 } else {
72 72
   $template = gettemplate('jumpgate', true);
73
-  if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0)
73
+  if (mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0)
74 74
   {
75 75
     $Combo = '';
76 76
     $MoonList = DBStaticPlanet::db_planet_list_moon_other($user['id'], $planetrow['id']);
77 77
     // while($CurMoon = db_fetch($MoonList))
78
-    foreach($MoonList as $CurMoon)
78
+    foreach ($MoonList as $CurMoon)
79 79
     {
80
-      if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1)
80
+      if (mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1)
81 81
       {
82 82
         $NextJumpTime = uni_get_time_to_jump($CurMoon);
83 83
         $template->assign_block_vars('moon', array(
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
       }
92 92
     }
93 93
 
94
-    foreach(Fleet::$snGroupFleet as $Ship)
94
+    foreach (Fleet::$snGroupFleet as $Ship)
95 95
     {
96
-      if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0)
96
+      if (($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0)
97 97
       {
98 98
         continue;
99 99
       }
Please login to merge, or discard this patch.
includes/classes/DBStaticUnit.php 1 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
   }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
   public static function db_unit_list_admin_delete_mercenaries_finished() {
160 160
     return classSupernova::$db->doDeleteDeprecated(TABLE_UNIT, array(
161 161
       'unit_time_finish IS NOT NULL',
162
-      "unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ")",
162
+      "unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.")",
163 163
       'unit_type' => UNIT_MERCENARIES,
164 164
     ));
165 165
   }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
     $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
200 200
     if (!empty($temp['unit_id'])) {
201
-      $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_list_NEW(
201
+      $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_list_NEW(
202 202
         LOC_UNIT,
203 203
         array(),
204 204
         array(
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
     } else {
212 212
       $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id;
213 213
       $unitType = get_unit_param($unit_id, P_UNIT_TYPE);
214
-      $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, array(
214
+      $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, array(
215 215
         'unit_player_id'     => $user['id'],
216
-        'unit_location_type' => (int)$unit_location,
216
+        'unit_location_type' => (int) $unit_location,
217 217
         'unit_location_id'   => $locationIdRendered,
218
-        'unit_type'          => (int)$unitType,
219
-        'unit_snid'          => (int)$unit_id,
220
-        'unit_level'         => (float)$unit_value,
218
+        'unit_type'          => (int) $unitType,
219
+        'unit_snid'          => (int) $unit_id,
220
+        'unit_level'         => (float) $unit_value,
221 221
       ));
222 222
     }
223 223
 
Please login to merge, or discard this patch.
includes/classes/core_auth.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
       // Проверить наличие такого имени в истории имён
223 223
       do {
224 224
         sn_db_transaction_rollback();
225
-        $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
225
+        $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000);
226 226
         sn_db_transaction_start();
227 227
       } while (db_player_name_exists($this->player_suggested_name));
228 228
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     if ($player_name_submitted) {
232 232
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
233 233
       if ($this->register_status == LOGIN_SUCCESS) {
234
-        sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
234
+        sys_redirect(SN_ROOT_VIRTUAL.'overview.php');
235 235
       } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
236 236
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
237 237
       }
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
       );
258 258
 
259 259
     if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
260
-      $prohibited_characters = array_map(function ($value) {
261
-        return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
260
+      $prohibited_characters = array_map(function($value) {
261
+        return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'";
262 262
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
263 263
       $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters);
264 264
     }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
     foreach ($this->providers as $provider_id => $provider) {
307 307
       $login_status = $provider->login(); // OK v4.5
308
-      self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
308
+      self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
309 309
       if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
310 310
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
311 311
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         if (!$this->is_player_register) {
346 346
           // Нет - отправляем на процесс регистрации
347 347
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
348
-          sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
348
+          sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : ''));
349 349
         }
350 350
       } else {
351 351
         // Да, есть доступные игроки, которые так же прописаны в базе
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
     }
406 406
 
407 407
     if ($redirect === true) {
408
-      sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
408
+      sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
409 409
     } elseif ($redirect !== false) {
410 410
       sys_redirect($redirect);
411 411
     }
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
         $user['vacation'] = SN_TIME_NOW;
694 694
       }
695 695
 
696
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
696
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
697 697
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
698 698
 
699 699
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -701,9 +701,9 @@  discard block
 block discarded – undo
701 701
 
702 702
       $proxy_safe = static::$db->db_escape(self::$device->ip_v4_proxy_chain);
703 703
 
704
-      DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], "`onlinetime` = " . SN_TIME_NOW . ",
705
-      `banaday` = " . static::$db->db_escape($user['banaday']) . ", `vacation` = " . static::$db->db_escape($user['vacation']) . ",
706
-      `user_lastip` = '" . static::$db->db_escape($user['user_lastip']) . "', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = " . self::$device->browser_id
704
+      DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], "`onlinetime` = ".SN_TIME_NOW.",
705
+      `banaday` = " . static::$db->db_escape($user['banaday']).", `vacation` = ".static::$db->db_escape($user['vacation']).",
706
+      `user_lastip` = '" . static::$db->db_escape($user['user_lastip'])."', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = ".self::$device->browser_id
707 707
       );
708 708
     }
709 709
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
    */
797 797
   // OK v4
798 798
   public static function password_encode($password, $salt) {
799
-    return md5($password . $salt);
799
+    return md5($password.$salt);
800 800
   }
801 801
   /**
802 802
    * Генерирует соль
@@ -822,10 +822,10 @@  discard block
 block discarded – undo
822 822
     }
823 823
     list($called, $caller) = debug_backtrace(false);
824 824
     $caller_name =
825
-      (!empty($caller['class']) ? $caller['class'] : '') .
826
-      (!empty($caller['type']) ? $caller['type'] : '') .
827
-      (!empty($caller['function']) ? $caller['function'] : '') .
828
-      (!empty($called['line']) ? ':' . $called['line'] : '');
825
+      (!empty($caller['class']) ? $caller['class'] : '').
826
+      (!empty($caller['type']) ? $caller['type'] : '').
827
+      (!empty($caller['function']) ? $caller['function'] : '').
828
+      (!empty($called['line']) ? ':'.$called['line'] : '');
829 829
 
830 830
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
831 831
 
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
     if ($die) {
834 834
       // pdump($caller);
835 835
       // pdump(debug_backtrace(false));
836
-      $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
836
+      $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
837 837
     }
838 838
   }
839 839
 
Please login to merge, or discard this patch.
includes/classes/DBStaticAlly.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -72,12 +72,12 @@
 block discarded – undo
72 72
    */
73 73
   public static function db_ally_insert($ally_name_unsafe, $ally_tag_unsafe, $userId) {
74 74
     $ally = classSupernova::$db->doInsertSet(TABLE_ALLIANCE, array(
75
-      'ally_name'          => (string)$ally_name_unsafe,
76
-      'ally_tag'           => (string)$ally_tag_unsafe,
75
+      'ally_name'          => (string) $ally_name_unsafe,
76
+      'ally_tag'           => (string) $ally_tag_unsafe,
77 77
       'ally_owner'         => $userId,
78
-      'ally_owner_range'   => (string)classLocale::$lang['ali_leaderRank'],
79
-      'ally_members'       => (int)1,
80
-      'ranklist'           => (string)(classLocale::$lang['ali_defaultRankName'] . ",0,0,0,0,0"),
78
+      'ally_owner_range'   => (string) classLocale::$lang['ali_leaderRank'],
79
+      'ally_members'       => (int) 1,
80
+      'ranklist'           => (string) (classLocale::$lang['ali_defaultRankName'].",0,0,0,0,0"),
81 81
       'ally_register_time' => SN_TIME_NOW,
82 82
     ));
83 83
 
Please login to merge, or discard this patch.
includes/classes/DBStaticUser.php 1 patch
Spacing   +11 added lines, -11 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();
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
218 218
 
219 219
       $user = classSupernova::$db->doSelectFetch(
220
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"
220
+        "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"
221 221
         . " FOR UPDATE"
222 222
       );
223 223
       classSupernova::$gc->snCache->cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     return classSupernova::$gc->cacheOperator->db_upd_record_list(
278 278
       LOC_USER,
279 279
       $set,
280
-      !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : ''
280
+      !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : ''
281 281
     );
282 282
   }
283 283
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
    * @param array $playerArray
316 316
    */
317 317
   public static function renderNameAndCoordinates($playerArray) {
318
-    return "{$playerArray['username']} " . uni_render_coordinates($playerArray);
318
+    return "{$playerArray['username']} ".uni_render_coordinates($playerArray);
319 319
   }
320 320
 
321 321
   /**
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
     foreach ($playerRowFieldChanges as $resourceId => $value) {
350 350
       $fields[pname_resource_name($resourceId)] = $value;
351 351
     }
352
-    if(!empty($fields)) {
352
+    if (!empty($fields)) {
353 353
       classSupernova::$gc->db->doUpdateRowAdjust(
354 354
         TABLE_USERS,
355 355
         array(),
Please login to merge, or discard this patch.
includes/classes/DBStaticPlanet.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,11 +55,10 @@  discard block
 block discarded – undo
55 55
   }
56 56
 
57 57
   public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') {
58
-    $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
59
-    $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
60
-    $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
61
-    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
62
-      (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
58
+    $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0;
59
+    $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0;
60
+    $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0;
61
+    $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0);
63 62
     $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
64 63
 
65 64
     return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
@@ -85,7 +84,7 @@  discard block
 block discarded – undo
85 84
     }
86 85
 
87 86
     return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET,
88
-      "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true);
87
+      "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true);
89 88
   }
90 89
 
91 90
   public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') {
@@ -106,7 +105,7 @@  discard block
 block discarded – undo
106 105
     }
107 106
 
108 107
     return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET,
109
-      "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}");
108
+      "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}");
110 109
   }
111 110
 
112 111
   public static function db_planet_list_in_system($galaxy, $system) {
@@ -132,7 +131,7 @@  discard block
 block discarded – undo
132 131
     );
133 132
     $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT];
134 133
     empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false;
135
-    $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC');
134
+    $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC');
136 135
 
137 136
     // Compilating query
138 137
     return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET,
@@ -160,7 +159,7 @@  discard block
 block discarded – undo
160 159
     foreach ($planetRowFieldChanges as $resourceId => $value) {
161 160
       $fields[pname_resource_name($resourceId)] = $value;
162 161
     }
163
-    if(!empty($fields)) {
162
+    if (!empty($fields)) {
164 163
       classSupernova::$gc->db->doUpdateRowAdjust(
165 164
         TABLE_PLANETS,
166 165
         array(),
Please login to merge, or discard this patch.
includes/functions/_news.php 1 patch
Spacing   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
   $announce_list = DBStaticNews::db_news_list_get_by_query($template, $query_where, $query_limit);
12 12
 
13 13
   $users = array();
14
-  while($announce = db_fetch($announce_list)) {
15
-    if($announce['user_id'] && !isset($users[$announce['user_id']])) {
14
+  while ($announce = db_fetch($announce_list)) {
15
+    if ($announce['user_id'] && !isset($users[$announce['user_id']])) {
16 16
       $users[$announce['user_id']] = DBStaticUser::db_user_by_id($announce['user_id']);
17 17
     }
18 18
 
19 19
     $survey_vote = array('survey_vote_id' => 1);
20 20
     $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW;
21 21
 
22
-    if($announce['survey_id'] && !empty($user['id'])) {
22
+    if ($announce['survey_id'] && !empty($user['id'])) {
23 23
       $survey_vote = !$survey_complete ? DBStaticSurveyVote::db_survey_get_vote($announce, $user) : array();
24 24
     }
25 25
 
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
       'ANNOUNCE'        => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])),
32 32
       'DETAIL_URL'      => $announce['detail_url'],
33 33
       'USER_NAME'       =>
34
-        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) :
35
-          js_safe_string($announce['user_name']),
34
+        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']),
36 35
       'NEW'             => $announce['unix_time'] + classSupernova::$config->game_news_actual >= SN_TIME_NOW,
37 36
       'FUTURE'          => $announce['unix_time'] > SN_TIME_NOW,
38 37
       'SURVEY_ID'       => $announce['survey_id'],
@@ -42,25 +41,25 @@  discard block
 block discarded – undo
42 41
       'SURVEY_UNTIL'    => $announce['survey_until'],
43 42
     ));
44 43
 
45
-    foreach($announce_exploded as $announce_paragraph) {
44
+    foreach ($announce_exploded as $announce_paragraph) {
46 45
       $template->assign_block_vars('announces.paragraph', array(
47 46
         'TEXT' => $announce_paragraph,
48 47
       ));
49 48
     }
50 49
 
51
-    if($announce['survey_id']) {
50
+    if ($announce['survey_id']) {
52 51
       $survey_query = DBStaticSurveyAnswer::db_survey_get_answer_texts($announce);
53 52
       $survey_vote_result = array();
54 53
       $total_votes = 0;
55
-      while($row = db_fetch($survey_query)) {
54
+      while ($row = db_fetch($survey_query)) {
56 55
         $survey_vote_result[] = $row;
57 56
         $total_votes += $row['VOTES'];
58 57
       }
59 58
 
60
-      if(empty($survey_vote) && !$survey_complete) {
59
+      if (empty($survey_vote) && !$survey_complete) {
61 60
         // Can vote
62 61
         $survey_query = DBStaticSurveyAnswer::db_survey_answers_get_list_by_parent($announce);
63
-        while($row = db_fetch($survey_query)) {
62
+        while ($row = db_fetch($survey_query)) {
64 63
           $template->assign_block_vars('announces.survey_answers', array(
65 64
             'ID'   => $row['survey_answer_id'],
66 65
             'TEXT' => $row['survey_answer_text'],
@@ -68,7 +67,7 @@  discard block
 block discarded – undo
68 67
         }
69 68
       } else {
70 69
         // Show result
71
-        foreach($survey_vote_result as &$vote_result) {
70
+        foreach ($survey_vote_result as &$vote_result) {
72 71
           $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0;
73 72
           $vote_result['PERCENT'] = $vote_percent;
74 73
           $vote_result['PERCENT_TEXT'] = round($vote_percent, 1);
@@ -85,8 +84,8 @@  discard block
 block discarded – undo
85 84
 }
86 85
 
87 86
 function nws_mark_read(&$user) {
88
-  if(isset($user['id'])) {
89
-    DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], '`news_lastread` = ' . SN_TIME_NOW);
87
+  if (isset($user['id'])) {
88
+    DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], '`news_lastread` = '.SN_TIME_NOW);
90 89
     $user['news_lastread'] = SN_TIME_NOW;
91 90
   }
92 91
 
@@ -94,17 +93,17 @@  discard block
 block discarded – undo
94 93
 }
95 94
 
96 95
 function survey_vote(&$user) {
97
-  if(empty($user['id'])) {
96
+  if (empty($user['id'])) {
98 97
     return true;
99 98
   }
100 99
 
101 100
   sn_db_transaction_start();
102 101
   $survey_id = sys_get_param_id('survey_id');
103 102
   $is_voted = DBStaticSurveyVote::db_survey_vote_get($user, $survey_id);
104
-  if(empty($is_voted)) {
103
+  if (empty($is_voted)) {
105 104
     $survey_vote_id = sys_get_param_id('survey_vote');
106 105
     $is_answer_exists = DBStaticSurveyAnswer::db_survey_answer_get($survey_id, $survey_vote_id);
107
-    if(!empty($is_answer_exists)) {
106
+    if (!empty($is_answer_exists)) {
108 107
       DBStaticSurveyVote::db_survey_vote_insert($survey_id, $survey_vote_id, $user['id'], $user['username']);
109 108
     }
110 109
   }
Please login to merge, or discard this patch.