Completed
Push — work-fleets ( 006942...3604bd )
by SuperNova.WS
06:54
created
classes/db_mysql.php 1 patch
Doc Comments   +22 added lines, -4 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
   /**
165 165
    * @param string $query
166 166
    *
167
-   * @return mixed|string
167
+   * @return string
168 168
    */
169 169
   public function replaceTablePlaceholders($query) {
170 170
     $sql = $query;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
   }
179 179
 
180 180
   /**
181
-   * @param $query
181
+   * @param string $query
182 182
    */
183 183
   protected function logQuery($query) {
184 184
     if (!classSupernova::$config->debug) {
@@ -290,6 +290,7 @@  discard block
 block discarded – undo
290 290
    * @param array  $fields
291 291
    * @param array  $where
292 292
    * @param bool   $isOneRecord
293
+   * @param boolean $forUpdate
293 294
    *
294 295
    * @return array|bool|mysqli_result|null
295 296
    *
@@ -332,6 +333,10 @@  discard block
 block discarded – undo
332 333
 
333 334
   //
334 335
   // INSERT/REPLACE ----------------------------------------------------------------------------------------------------
336
+
337
+  /**
338
+   * @param string $query
339
+   */
335 340
   public function doInsertComplex($query) {
336 341
     return $this->doSql($query);
337 342
   }
@@ -408,7 +413,7 @@  discard block
 block discarded – undo
408 413
    * Self-contained - means no params used
409 414
    * Such queries usually used to make large amount of in-base calculations
410 415
    *
411
-   * @param $query
416
+   * @param string $query
412 417
    *
413 418
    * @return array|bool|mysqli_result|null
414 419
    */
@@ -425,13 +430,16 @@  discard block
 block discarded – undo
425 430
   }
426 431
 
427 432
   /**
428
-   * @param $DbQuery DbQuery
433
+   * @param DbQuery $DbQuery DbQuery
429 434
    */
430 435
   public function doUpdateDbQueryAdjust($DbQuery) {
431 436
     return $this->doUpdateDbQuery($DbQuery);
432 437
   }
433 438
 
434 439
 
440
+  /**
441
+   * @param boolean $isOneRecord
442
+   */
435 443
   protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL, $whereDanger = array()) {
436 444
     $query = DbQuery::build($this)
437 445
       ->setTable($table)
@@ -450,6 +458,9 @@  discard block
 block discarded – undo
450 458
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE);
451 459
   }
452 460
 
461
+  /**
462
+   * @param string $table
463
+   */
453 464
   public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) {
454 465
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL);
455 466
   }
@@ -559,6 +570,10 @@  discard block
 block discarded – undo
559 570
   //
560 571
   // OTHER FUNCTIONS ----------------------------------------------------------------------------------------------------------
561 572
   // TODO Заменить это на новый логгер
573
+
574
+  /**
575
+   * @param string $query
576
+   */
562 577
   protected function security_watch_user_queries($query) {
563 578
     global $user;
564 579
 
@@ -582,6 +597,9 @@  discard block
 block discarded – undo
582 597
   }
583 598
 
584 599
 
600
+  /**
601
+   * @param string $query
602
+   */
585 603
   public function security_query_check_bad_words($query) {
586 604
     if ($this->skipQueryCheck) {
587 605
       return;
Please login to merge, or discard this patch.
includes/includes/sys_stat.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -43,23 +43,23 @@  discard block
 block discarded – undo
43 43
 
44 44
   $sta_update_msg = db_escape($sta_update_msg);
45 45
 
46
-  if($next_step) {
46
+  if ($next_step) {
47 47
     $sta_update_step++;
48 48
   }
49 49
   $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}.";
50 50
 
51 51
   classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg);
52
-  if($next_step) {
52
+  if ($next_step) {
53 53
     classSupernova::$debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS);
54 54
   }
55 55
 }
56 56
 
57 57
 function sys_stat_calculate_flush(&$data, $force = false) {
58
-  if(count($data) < 25 && !$force) {
58
+  if (count($data) < 25 && !$force) {
59 59
     return;
60 60
   }
61 61
 
62
-  if(!empty($data)) {
62
+  if (!empty($data)) {
63 63
     classSupernova::$gc->db->doInsertBatch(
64 64
       TABLE_STAT_POINTS, $data, array(
65 65
       'id_owner',
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
   classSupernova::$gc->cacheOperator->db_lock_tables('users');
115 115
   $user_list = DBStaticUser::db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id');
116 116
   $row_num = count($user_list);
117
-  foreach($user_list as $player) {
118
-    if($i++ % 100 == 0) {
117
+  foreach ($user_list as $player) {
118
+    if ($i++ % 100 == 0) {
119 119
       sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false);
120 120
     }
121
-    if(array_key_exists($user_id = $player['id'], $user_skip_list)) {
121
+    if (array_key_exists($user_id = $player['id'], $user_skip_list)) {
122 122
       continue;
123 123
     }
124 124
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     $counts[$user_id][UNIT_RESOURCES] += $resources;
128 128
 
129 129
     // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что
130
-    if(!isset($user_skip_list[$user_id])) {
130
+    if (!isset($user_skip_list[$user_id])) {
131 131
       $user_allies[$user_id] = $player['ally_id'];
132 132
     }
133 133
   }
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
   $i = 0;
140 140
   $query = DBStaticPlanet::db_planet_list_resources_by_owner();
141 141
   $row_num = classSupernova::$db->db_num_rows($query);
142
-  while($planet = db_fetch($query)) {
143
-    if($i++ % 100 == 0) {
142
+  while ($planet = db_fetch($query)) {
143
+    if ($i++ % 100 == 0) {
144 144
       sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false);
145 145
     }
146
-    if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
146
+    if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
147 147
       continue;
148 148
     }
149 149
 
@@ -157,22 +157,22 @@  discard block
 block discarded – undo
157 157
   $i = 0;
158 158
   $query = FleetList::dbQueryAllId();
159 159
   $row_num = classSupernova::$db->db_num_rows($query);
160
-  while($fleet_row = db_fetch($query)) {
161
-    if($i++ % 100 == 0) {
160
+  while ($fleet_row = db_fetch($query)) {
161
+    if ($i++ % 100 == 0) {
162 162
       sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false);
163 163
     }
164 164
     $objFleet = new Fleet();
165 165
     // TODO - без дополнительной инициализации и перераспределений памяти на каждый new Fleet()/unset($fleet)
166 166
     // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными
167 167
     $objFleet->dbRowParse($fleet_row);
168
-    if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
168
+    if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
169 169
       continue;
170 170
     }
171 171
 
172
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
172
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
173 173
       $counts[$user_id][UNIT_SHIPS] += $unit->count;
174 174
 
175
-      if(!isset($unit_cost_cache[$unit_id][0])) {
175
+      if (!isset($unit_cost_cache[$unit_id][0])) {
176 176
         $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST);
177 177
       }
178 178
       $unit_cost_data = &$unit_cost_cache[$unit_id][0];
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
   $i = 0;
192 192
   $query = DBStaticUnit::db_unit_list_stat_calculate();
193 193
   $row_num = classSupernova::$db->db_num_rows($query);
194
-  while($unit = db_fetch($query)) {
195
-    if($i++ % 100 == 0) {
194
+  while ($unit = db_fetch($query)) {
195
+    if ($i++ % 100 == 0) {
196 196
       sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false);
197 197
     }
198
-    if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
198
+    if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
199 199
       continue;
200 200
     }
201 201
 
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
   $i = 0;
210 210
   $query = DBStaticQue::db_que_list_stat();
211 211
   $row_num = classSupernova::$db->db_num_rows($query);
212
-  while($que_item = db_fetch($query)) {
213
-    if($i++ % 100 == 0) {
212
+  while ($que_item = db_fetch($query)) {
213
+    if ($i++ % 100 == 0) {
214 214
       sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false);
215 215
     }
216
-    if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
216
+    if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
217 217
       continue;
218 218
     }
219 219
     $que_unit_amount = $que_item['que_unit_amount'];
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
   sta_set_time_limit('posting new user stats to DB');
242 242
   $data = array();
243
-  foreach($user_allies as $user_id => $ally_id) {
243
+  foreach ($user_allies as $user_id => $ally_id) {
244 244
     $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000;
245 245
     $points[$user_id] = array_map('floor', $points[$user_id]);
246 246
     $counts[$user_id] = array_map('floor', $counts[$user_id]);
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         SUM(u.`tech_points`)+aus.`tech_points`, SUM(u.`tech_count`)+aus.`tech_count`, SUM(u.`build_points`)+aus.`build_points`, SUM(u.`build_count`)+aus.`build_count`,
294 294
         SUM(u.`defs_points`)+aus.`defs_points`, SUM(u.`defs_count`)+aus.`defs_count`, SUM(u.`fleet_points`)+aus.`fleet_points`, SUM(u.`fleet_count`)+aus.`fleet_count`,
295 295
         SUM(u.`res_points`)+aus.`res_points`, SUM(u.`res_count`)+aus.`res_count`, SUM(u.`total_points`)+aus.`total_points`, SUM(u.`total_count`)+aus.`total_count`,
296
-        " . SN_TIME_NOW . ", NULL, u.`id_ally`, 2, 1,
296
+        " . SN_TIME_NOW.", NULL, u.`id_ally`, 2, 1,
297 297
         a.tech_rank, a.build_rank, a.defs_rank, a.fleet_rank, a.res_rank, a.total_rank
298 298
       FROM `{{statpoints}}` AS u
299 299
         JOIN `{{alliance}}` AS al ON al.id = u.id_ally
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
   // Updating player's ranks
316 316
   sta_set_time_limit("updating ranks for players");
317
-  foreach($rankNames as $rankName) {
317
+  foreach ($rankNames as $rankName) {
318 318
     sta_set_time_limit("updating player rank '{$rankName}'", false);
319 319
     classSupernova::$db->doSql($qryResetRowNum);
320 320
     classSupernova::$db->doUpdateReallyComplex(sprintf($qryFormat, $rankName, 1));
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 
323 323
   sta_set_time_limit("updating ranks for Alliances");
324 324
   // Updating Allie's ranks
325
-  foreach($rankNames as $rankName) {
325
+  foreach ($rankNames as $rankName) {
326 326
     sta_set_time_limit("updating Alliances rank '{$rankName}'", false);
327 327
     classSupernova::$db->doSql($qryResetRowNum);
328 328
     classSupernova::$db->doUpdateReallyComplex(sprintf($qryFormat, $rankName, 2));
Please login to merge, or discard this patch.
classes/DBStatic/DBStaticMessages.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         array(),
158 158
         array(
159 159
           // TODO DANGER
160
-          '`id` IN (' . implode(',', $owners) . ')',
160
+          '`id` IN ('.implode(',', $owners).')',
161 161
         )
162 162
       );
163 163
     }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     $sendList = array();
177 177
     $list = '';
178 178
     $query = DBStaticUser::db_user_list(
179
-      "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
179
+      "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
180 180
       false, 'id, username');
181 181
     foreach ($query as $u) {
182 182
       $sendList[] = $u['id'];
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
       $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix']));
266 266
       $re++;
267 267
     }
268
-    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false;
268
+    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false;
269 269
 
270 270
     $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default'];
271 271
 
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
     return classSupernova::$db->doSelect(
442 442
       "SELECT * FROM {{messages}}
443 443
         WHERE
444
-          `message_type` = '" . MSG_TYPE_PLAYER . "' AND
444
+          `message_type` = '" . MSG_TYPE_PLAYER."' AND
445 445
           ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}')
446 446
           OR
447 447
           (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;");
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 FROM
486 486
   {{messages}} AS m
487 487
   LEFT JOIN {{users}} AS u ON u.id = m.message_owner " .
488
-      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') .
488
+      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '').
489 489
       "ORDER BY
490 490
   `message_id` DESC
491 491
 LIMIT
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     $subject_safe = db_escape($subject_unsafe);
499 499
     $text_safe = db_escape($text_unsafe);
500 500
 
501
-    return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
501
+    return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '.
502 502
       "SELECT `id`, 0, unix_timestamp(now()), {$message_type_safe}, '{$from_safe}', '{$subject_safe}', '{$text_safe}' FROM {{users}}");
503 503
   }
504 504
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
    * @return array|bool|mysqli_result|null
509 509
    */
510 510
   public static function db_message_count_by_type($int_type_selected) {
511
-    $page_max = classSupernova::$db->doSelectFetchArray('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
511
+    $page_max = classSupernova::$db->doSelectFetchArray('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
512 512
 
513 513
     return $page_max;
514 514
   }
Please login to merge, or discard this patch.
classes/classLocale.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 
36 36
     $this->container = array();
37 37
 
38
-    if(classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) {
38
+    if (classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) {
39 39
       $this->cache = classSupernova::$cache;
40 40
       classSupernova::log_file('locale.__constructor: Cache is present');
41 41
 //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug!
42 42
     }
43 43
 
44
-    if($enable_stat_usage && empty($this->stat_usage)) {
44
+    if ($enable_stat_usage && empty($this->stat_usage)) {
45 45
       $this->enable_stat_usage = $enable_stat_usage;
46 46
       $this->usage_stat_load();
47 47
       // TODO shutdown function
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
     unset($fallback[$this->active]);
68 68
 
69 69
     // Проходим по оставшимся локалям
70
-    foreach($fallback as $try_language) {
70
+    foreach ($fallback as $try_language) {
71 71
       // Если нет такой строки - пытаемся вытащить из кэша
72
-      if(!isset($this->container[$try_language][$offset]) && $this->cache) {
73
-        $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset);
72
+      if (!isset($this->container[$try_language][$offset]) && $this->cache) {
73
+        $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix.$try_language.'_'.$offset);
74 74
 // Записываем результат работы кэша
75 75
 $locale_cache_statistic['queries']++;
76 76
 isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['hits']++ : $locale_cache_statistic['misses']++;
77
-!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix . $try_language . '_' . $offset : false;
77
+!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix.$try_language.'_'.$offset : false;
78 78
       }
79 79
 
80 80
       // Если мы как-то где-то нашли строку...
81
-      if(isset($this->container[$try_language][$offset])) {
81
+      if (isset($this->container[$try_language][$offset])) {
82 82
         // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер
83 83
         $this[$offset] = $this->container[$try_language][$offset];
84 84
         $locale_cache_statistic['fallbacks']++;
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
       $this->container[$this->active][] = $value;
95 95
     } else {
96 96
       $this->container[$this->active][$offset] = $value;
97
-      if($this->cache) {
98
-        $this->cache->__set($this->cache_prefix_lang . $offset, $value);
97
+      if ($this->cache) {
98
+        $this->cache->__set($this->cache_prefix_lang.$offset, $value);
99 99
       }
100 100
     }
101 101
   }
102 102
   public function offsetExists($offset) {
103 103
     // Шорткат если у нас уже есть строка в памяти PHP
104
-    if(!isset($this->container[$this->active][$offset])) {
104
+    if (!isset($this->container[$this->active][$offset])) {
105 105
 //        pdump($this->cache_prefix_lang . $offset);
106
-      if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) {
106
+      if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang.$offset))) {
107 107
 //        pdump($this->cache_prefix_lang . $offset);
108 108
         // Если нету такой строки - делаем фоллбэк
109 109
         $this->locale_string_fallback($offset);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
   }
120 120
   public function offsetGet($offset) {
121 121
     $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null;
122
-    if($this->enable_stat_usage) {
122
+    if ($this->enable_stat_usage) {
123 123
       $this->usage_stat_log($offset, $value);
124 124
     }
125 125
     return $value;
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
   public function usage_stat_load() {
137
-    $this->stat_usage = classSupernova::$cache->lng_stat_usage  = array();
138
-    if(empty($this->stat_usage)) {
137
+    $this->stat_usage = classSupernova::$cache->lng_stat_usage = array();
138
+    if (empty($this->stat_usage)) {
139 139
       $query = classSupernova::$db->doSelect("SELECT * FROM `{{lng_usage_stat}}`");
140
-      while($row = db_fetch($query)) {
141
-        $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty'];
140
+      while ($row = db_fetch($query)) {
141
+        $this->stat_usage[$row['lang_code'].':'.$row['string_id'].':'.$row['file'].':'.$row['line']] = $row['is_empty'];
142 142
       }
143 143
     }
144 144
   }
145 145
   public function usage_stat_save() {
146
-    if(!empty($this->stat_usage_new)) {
146
+    if (!empty($this->stat_usage_new)) {
147 147
       classSupernova::$cache->lng_stat_usage = $this->stat_usage;
148 148
       classSupernova::$db->doSelect("SELECT 1 FROM `{{lng_usage_stat}}` LIMIT 1");
149 149
 //      foreach($this->stat_usage_new as &$value) {
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 
172 172
     $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1));
173 173
 
174
-    $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line'];
175
-    if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) {
174
+    $string_id = $this->active.':'.$offset.':'.$file.':'.$trace[1]['line'];
175
+    if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) {
176 176
       $this->stat_usage[$string_id] = empty($value);
177 177
       $this->stat_usage_new[] = array(
178 178
         'lang_code' => $this->active,
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
         'file' => $file,
181 181
         'line' => $trace[1]['line'],
182 182
         'is_empty' => intval(empty($value)),
183
-        'locale' => '' . $value,
183
+        'locale' => ''.$value,
184 184
       );
185 185
     }
186 186
   }
187 187
 
188 188
 
189 189
   protected function lng_try_filepath($path, $file_path_relative) {
190
-    $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative;
190
+    $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative;
191 191
     return file_exists($file_path) ? $file_path : false;
192 192
   }
193 193
 
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 
210 210
     classSupernova::log_file("locale.include: Loading data from domain '{$filename}'", 1);
211 211
 
212
-    $cache_file_key = $this->cache_prefix_lang . '__' . $filename;
212
+    $cache_file_key = $this->cache_prefix_lang.'__'.$filename;
213 213
 
214 214
     // Подключен ли внешний кэш?
215
-    if($this->cache) {
215
+    if ($this->cache) {
216 216
       // Загружен ли уже данный файл?
217 217
       $cache_file_status = $this->cache->__get($cache_file_key);
218
-      classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0);
219
-      if($cache_file_status) {
218
+      classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is ".($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0);
219
+      if ($cache_file_status) {
220 220
         // Если да - повторять загрузку нет смысла
221 221
         return null;
222 222
       }
@@ -230,47 +230,47 @@  discard block
 block discarded – undo
230 230
     $this->make_fallback($language);
231 231
 
232 232
     $file_path = '';
233
-    foreach($this->fallback as $lang_try) {
234
-      if(!$lang_try /* || isset($language_tried[$lang_try]) */) {
233
+    foreach ($this->fallback as $lang_try) {
234
+      if (!$lang_try /* || isset($language_tried[$lang_try]) */) {
235 235
         continue;
236 236
       }
237 237
 
238
-      if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) {
238
+      if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) {
239 239
         break;
240 240
       }
241 241
 
242
-      if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) {
242
+      if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) {
243 243
         break;
244 244
       }
245 245
 
246 246
       $file_path = '';
247 247
     }
248 248
 
249
-    if($file_path) {
249
+    if ($file_path) {
250 250
       $a_lang_array = array();
251 251
       include($file_path);
252 252
 
253
-      if(!empty($a_lang_array)) {
253
+      if (!empty($a_lang_array)) {
254 254
         $this->merge($a_lang_array);
255 255
 
256 256
         // Загрузка данных из файла в кэш
257
-        if($this->cache) {
257
+        if ($this->cache) {
258 258
           classSupernova::log_file("Locale: loading '{$filename}' into cache");
259
-          foreach($a_lang_array as $key => $value) {
260
-            $value_cache_key = $this->cache_prefix_lang . $key;
261
-            if($this->cache->__isset($value_cache_key)) {
262
-              if(is_array($value)) {
259
+          foreach ($a_lang_array as $key => $value) {
260
+            $value_cache_key = $this->cache_prefix_lang.$key;
261
+            if ($this->cache->__isset($value_cache_key)) {
262
+              if (is_array($value)) {
263 263
                 $alt_value = $this->cache->__get($value_cache_key);
264 264
                 $value = array_replace_recursive($alt_value, $value);
265 265
                 // pdump($alt_value, $alt_value);
266 266
               }
267 267
             }
268
-            $this->cache->__set($this->cache_prefix_lang . $key, $value);
268
+            $this->cache->__set($this->cache_prefix_lang.$key, $value);
269 269
           }
270 270
         }
271 271
       }
272 272
 
273
-      if($this->cache) {
273
+      if ($this->cache) {
274 274
         $this->cache->__set($cache_file_key, true);
275 275
       }
276 276
 
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
   }
284 284
 
285 285
   public function lng_load_i18n($i18n) {
286
-    if(!isset($i18n)) {
286
+    if (!isset($i18n)) {
287 287
       return;
288 288
     }
289 289
 
290
-    foreach($i18n as $i18n_data) {
291
-      if(is_string($i18n_data)) {
290
+    foreach ($i18n as $i18n_data) {
291
+      if (is_string($i18n_data)) {
292 292
         $this->lng_include($i18n_data);
293
-      } elseif(is_array($i18n_data)) {
293
+      } elseif (is_array($i18n_data)) {
294 294
         $this->lng_include($i18n_data['file'], $i18n_data['path']);
295 295
       }
296 296
     }
@@ -308,27 +308,27 @@  discard block
 block discarded – undo
308 308
 
309 309
     classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'");
310 310
 
311
-    if($language_new == $this->active) {
311
+    if ($language_new == $this->active) {
312 312
       classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1);
313 313
       return false;
314 314
     }
315 315
 
316 316
     $this->active = $language = $language_new;
317
-    $this->cache_prefix_lang = $this->cache_prefix . $this->active . '_';
317
+    $this->cache_prefix_lang = $this->cache_prefix.$this->active.'_';
318 318
 
319 319
     $this['LANG_INFO'] = $this->lng_get_info($this->active);
320 320
     $this->make_fallback($this->active);
321 321
 
322
-    if($this->cache) {
323
-      $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT');
324
-      classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0);
325
-      if($cache_lang_init_status) {
322
+    if ($this->cache) {
323
+      $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang.'__INIT');
324
+      classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is ".($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0);
325
+      if ($cache_lang_init_status) {
326 326
         return false;
327 327
       }
328 328
 
329 329
       // Чистим текущие локализации из кэша. Достаточно почистить только флаги инициализации языкового кэша и загрузки файлов - они начинаются с '__'
330 330
       classSupernova::log_file("locale.switch: Cache - invalidating data");
331
-      $this->cache->unset_by_prefix($this->cache_prefix_lang . '__');
331
+      $this->cache->unset_by_prefix($this->cache_prefix_lang.'__');
332 332
     }
333 333
 
334 334
     $this->lng_include('system');
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
     // Loading global language files
339 339
     $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']);
340 340
 
341
-    if($this->cache) {
342
-      classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT');
343
-      $this->cache->__set($this->cache_prefix_lang . '__INIT', true);
341
+    if ($this->cache) {
342
+      classSupernova::log_file("locale.switch: Cache - setting flag ".$this->cache_prefix_lang.'__INIT');
343
+      $this->cache->__set($this->cache_prefix_lang.'__INIT', true);
344 344
     }
345 345
 
346 346
     classSupernova::log_file("locale.switch: Complete - EXIT");
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
 
351 351
 
352 352
   public function lng_get_info($entry) {
353
-    $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php';
353
+    $file_name = SN_ROOT_PHYSICAL.'language/'.$entry.'/language.mo.php';
354 354
     $lang_info = array();
355
-    if(file_exists($file_name)) {
355
+    if (file_exists($file_name)) {
356 356
       include($file_name);
357 357
     }
358 358
 
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
   }
361 361
 
362 362
   public function lng_get_list() {
363
-    if(empty($this->lang_list)) {
363
+    if (empty($this->lang_list)) {
364 364
       $this->lang_list = array();
365 365
 
366
-      $path = SN_ROOT_PHYSICAL . 'language/';
366
+      $path = SN_ROOT_PHYSICAL.'language/';
367 367
       $dir = dir($path);
368
-      while(false !== ($entry = $dir->read())) {
369
-        if(is_dir($path . $entry) && $entry[0] != '.') {
368
+      while (false !== ($entry = $dir->read())) {
369
+        if (is_dir($path.$entry) && $entry[0] != '.') {
370 370
           $lang_info = $this->lng_get_info($entry);
371
-          if($lang_info['LANG_NAME_ISO2'] == $entry) {
371
+          if ($lang_info['LANG_NAME_ISO2'] == $entry) {
372 372
             $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info;
373 373
           }
374 374
         }
Please login to merge, or discard this patch.
classes/SnDbCachedOperator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
       if (!empty($filter)) {
200 200
         foreach ($filter as $key => $value) {
201 201
           if (!is_int($key)) {
202
-            $value = "`$key` = '" . $this->db->db_escape($value) . "'";
202
+            $value = "`$key` = '".$this->db->db_escape($value)."'";
203 203
           }
204 204
           $filterString[$key] = $value;
205 205
         }
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
             $query = $this->db->doSelect(
239 239
               "SELECT
240 240
               distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id
241
-            FROM {{{$location_info[P_TABLE_NAME]}}}" .
242
-              ($filter ? ' WHERE ' . $filter : '') .
241
+            FROM {{{$location_info[P_TABLE_NAME]}}}".
242
+              ($filter ? ' WHERE '.$filter : '').
243 243
               ($fetch ? ' LIMIT 1' : ''));
244 244
           }
245
-          while($row = db_fetch($query)) {
245
+          while ($row = db_fetch($query)) {
246 246
             // Исключаем из списка родительских ИД уже заблокированные записи
247 247
             if (!$this->snCache->cache_lock_get($owner_location_type, $row['parent_id'])) {
248 248
               $parent_id_list[$row['parent_id']] = $row['parent_id'];
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
             $indexes_str = implode(',', $parent_id_list);
255 255
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
256 256
             $this->db_get_record_list($owner_location_type,
257
-              $parent_id_field . (
257
+              $parent_id_field.(
258 258
               count($parent_id_list) > 1
259 259
                 ? " IN ({$indexes_str})"
260 260
                 : " = {$indexes_str}"
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
         );
278 278
       } else {
279 279
         $query = $this->db->doSelect(
280
-          "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" .
280
+          "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}".
281 281
           (($filter = trim($filter)) ? " WHERE {$filter}" : '')
282 282
           . " FOR UPDATE"
283 283
         );
284 284
       }
285
-      while($row = db_fetch($query)) {
285
+      while ($row = db_fetch($query)) {
286 286
         // Caching record in row cache
287 287
         $this->snCache->cache_set($location_type, $row);
288 288
         // Making ref to cached record in query cache
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
   public function db_lock_tables($tables) {
458 458
     $tables = is_array($tables) ? $tables : array($tables => '');
459 459
     foreach ($tables as $table_name => $condition) {
460
-      $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
460
+      $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : ''));
461 461
     }
462 462
   }
463 463
 }
Please login to merge, or discard this patch.
classes/DBAL/DbQuery.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
     $this->buildCommand(static::SELECT);
108 108
     $this->build[] = ' *';
109
-    $this->build[] = " FROM " . $this->quoteTable($this->table);
109
+    $this->build[] = " FROM ".$this->quoteTable($this->table);
110 110
     $this->buildWhere();
111 111
     $this->buildLimit();
112 112
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
    * @return string
141 141
    */
142 142
   protected function setInsertCommand($replace) {
143
-    switch($replace) {
143
+    switch ($replace) {
144 144
       case DB_INSERT_IGNORE:
145 145
         $result = static::INSERT_IGNORE;
146 146
       break;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     $this->build = array();
161 161
     $this->buildCommand($this->setInsertCommand($replace));
162 162
 
163
-    if(!$forceSingleInsert && is_array($this->fields) && !empty($this->fields)) {
163
+    if (!$forceSingleInsert && is_array($this->fields) && !empty($this->fields)) {
164 164
       // If there are fields - it's batch insert... unless it forced single insert
165 165
       $this->build[] = " (";
166 166
       $this->buildFieldNames(); // used $this->fields
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
    * @return string
311 311
    */
312 312
   protected function stringValue($value) {
313
-    return "'" . $this->escape((string)$value) . "'";
313
+    return "'".$this->escape((string) $value)."'";
314 314
   }
315 315
 
316 316
   /**
@@ -321,20 +321,20 @@  discard block
 block discarded – undo
321 321
    * @return string
322 322
    */
323 323
   public function quote($fieldName) {
324
-    return "`" . $this->escape((string)$fieldName) . "`";
324
+    return "`".$this->escape((string) $fieldName)."`";
325 325
   }
326 326
 
327 327
   public function makeAdjustString($fieldValue, $fieldName) {
328 328
     return is_int($fieldName)
329 329
       ? $fieldValue
330
-      : (($fieldNameQuoted = $this->quote($fieldName)) . " = " .
331
-        $fieldNameQuoted . " + (" . $this->castAsDbValue($fieldValue) . ")");
330
+      : (($fieldNameQuoted = $this->quote($fieldName))." = ".
331
+        $fieldNameQuoted." + (".$this->castAsDbValue($fieldValue).")");
332 332
   }
333 333
 
334 334
   public function makeFieldEqualValue($fieldValue, $fieldName) {
335 335
     return is_int($fieldName)
336 336
       ? $fieldValue
337
-      : ($this->quote($fieldName) . " = " . $this->castAsDbValue($fieldValue));
337
+      : ($this->quote($fieldName)." = ".$this->castAsDbValue($fieldValue));
338 338
   }
339 339
 
340 340
   /**
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
    * @return string
346 346
    */
347 347
   protected function quoteTable($tableName) {
348
-    return "`{{" . $this->escape((string)$tableName) . "}}`";
348
+    return "`{{".$this->escape((string) $tableName)."}}`";
349 349
   }
350 350
 
351 351
   public function castAsDbValue($value) {
352
-    switch(gettype($value)) {
352
+    switch (gettype($value)) {
353 353
       case TYPE_INTEGER:
354 354
       case TYPE_DOUBLE:
355 355
         // do nothing
@@ -380,19 +380,19 @@  discard block
 block discarded – undo
380 380
 
381 381
 
382 382
   protected function buildCommand($command) {
383
-    switch($this->command = $command) {
383
+    switch ($this->command = $command) {
384 384
       case static::UPDATE:
385
-        $this->build[] = $this->command . " " . $this->quoteTable($this->table);
385
+        $this->build[] = $this->command." ".$this->quoteTable($this->table);
386 386
       break;
387 387
 
388 388
       case static::DELETE:
389
-        $this->build[] = $this->command . " FROM " . $this->quoteTable($this->table);
389
+        $this->build[] = $this->command." FROM ".$this->quoteTable($this->table);
390 390
       break;
391 391
 
392 392
       case static::REPLACE:
393 393
       case static::INSERT_IGNORE:
394 394
       case static::INSERT:
395
-        $this->build[] = $this->command . " INTO " . $this->quoteTable($this->table);
395
+        $this->build[] = $this->command." INTO ".$this->quoteTable($this->table);
396 396
       break;
397 397
 
398 398
       case static::SELECT:
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     }
443 443
 
444 444
     foreach ($this->values as $valuesVector) {
445
-      $compiled[] = '(' . implode(',', HelperArray::map($valuesVector, array($this, 'castAsDbValue'))) . ')';
445
+      $compiled[] = '('.implode(',', HelperArray::map($valuesVector, array($this, 'castAsDbValue'))).')';
446 446
     }
447 447
 
448 448
     $this->build[] = implode(',', $compiled);
Please login to merge, or discard this patch.
classes/userOptions.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 
123 123
     $update_cache = false;
124 124
 
125
-    if(!empty($this->to_write)) {
126
-      foreach($this->to_write as $key => &$value) {
125
+    if (!empty($this->to_write)) {
126
+      foreach ($this->to_write as $key => &$value) {
127 127
         $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД
128 128
         $value = array($this->user_id, $key, $value);
129 129
       }
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
       $update_cache = true;
142 142
     }
143 143
 
144
-    if(!empty($this->to_delete)) {
145
-      foreach($this->to_delete as $key => &$value) {
146
-        $value = is_string($key) ? "'". db_escape($key) . "'" : $key;
144
+    if (!empty($this->to_delete)) {
145
+      foreach ($this->to_delete as $key => &$value) {
146
+        $value = is_string($key) ? "'".db_escape($key)."'" : $key;
147 147
       }
148 148
 
149 149
       classSupernova::$db->doDeleteDanger(
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
           'player_id' => $this->user_id,
153 153
         ),
154 154
         array(
155
-          "`option_id` IN (" . implode(',', $this->to_delete) . ")",
155
+          "`option_id` IN (".implode(',', $this->to_delete).")",
156 156
         )
157 157
       );
158 158
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
       $update_cache = true;
161 161
     }
162 162
 
163
-    if($update_cache) {
163
+    if ($update_cache) {
164 164
       $field_name = $this->cached_name();
165 165
       classSupernova::$cache->$field_name = $this->data;
166 166
     }
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
     $this->load();
180 180
   }
181 181
   protected function cached_name() {
182
-    return 'options_' . $this->user_id;
182
+    return 'options_'.$this->user_id;
183 183
   }
184 184
 
185 185
   protected function load() {
186
-    if($this->loaded) {
186
+    if ($this->loaded) {
187 187
       return;
188 188
     }
189 189
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     $this->to_write = array();
192 192
     $this->to_delete = array();
193 193
 
194
-    if(!$this->user_id) {
194
+    if (!$this->user_id) {
195 195
       $this->loaded = true;
196 196
       return;
197 197
     }
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
     $field_name = $this->cached_name();
200 200
     $a_data = classSupernova::$cache->$field_name;
201 201
 
202
-    if(!empty($a_data)) {
202
+    if (!empty($a_data)) {
203 203
       $this->data = array_replace_recursive($this->data, $a_data);
204 204
       return;
205 205
     }
206 206
 
207 207
     $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
208
-    while($row = db_fetch($query)) {
208
+    while ($row = db_fetch($query)) {
209 209
       // $this->data[$row['option_id']] = $row['value'];
210 210
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
211 211
     }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
   }
283 283
 
284 284
   protected function cached_name() {
285
-    return 'options_' . $this->user_id;
285
+    return 'options_'.$this->user_id;
286 286
   }
287 287
 
288 288
   // TODO - serialize/unserialize options
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
     // Если в массиве индекса только один элемент - значит это просто индекс
291 291
     is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false;
292 292
 
293
-    if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
293
+    if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
294 294
       $this->load();
295 295
     }
296 296
 
297
-    if(is_array($option_id)) {
297
+    if (is_array($option_id)) {
298 298
       $result = $this->data;
299
-      foreach($option_id as $sub_key) {
300
-        if(!isset($result) || !isset($result[$sub_key])) {
299
+      foreach ($option_id as $sub_key) {
300
+        if (!isset($result) || !isset($result[$sub_key])) {
301 301
           $result = null;
302 302
           break;
303 303
         }
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
    * @param null|mixed $value
316 316
    */
317 317
   public function __set($option, $value = null) {
318
-    if(empty($option) || !$this->user_id) {
318
+    if (empty($option) || !$this->user_id) {
319 319
       return;
320 320
     }
321 321
 
322 322
     // Если в массиве индекса только один элемент - значит это просто индекс
323
-    if(is_array($option) && count($option) == 1) {
323
+    if (is_array($option) && count($option) == 1) {
324 324
       // Разворачиваем его в индекс
325 325
       $option = array(reset($option) => $value);
326 326
       unset($value);
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
 
330 330
     $to_write = array();
331 331
     // Адресация многомерного массива через массив индексов в $option
332
-    if(is_array($option) && isset($value)) {
332
+    if (is_array($option) && isset($value)) {
333 333
       $a_data = &$this->data;
334
-      foreach($option as $option_id) {
334
+      foreach ($option as $option_id) {
335 335
         !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false;
336 336
         $a_data = &$a_data[$option_id];
337 337
       }
338
-      if($a_data != $value) {
338
+      if ($a_data != $value) {
339 339
         $a_data = $value;
340 340
         $to_write[reset($option)] = null;
341 341
       }
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
       // Пакетная запись из массива ключ -> значение
344 344
       !is_array($option) ? $option = array($option => $value) : false;
345 345
 
346
-      foreach($option as $option_id => $option_value) {
347
-        if($this->data[$option_id] !== $option_value) {
346
+      foreach ($option as $option_id => $option_value) {
347
+        if ($this->data[$option_id] !== $option_value) {
348 348
           // TODO - вынести отдельно в обработчик
349
-          if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON &&  $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
350
-            sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
349
+          if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
350
+            sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
351 351
           }
352 352
 
353 353
           $this->data[$option_id] = $option_value;
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
       }
357 357
     }
358 358
 
359
-    if(!empty($to_write)) {
359
+    if (!empty($to_write)) {
360 360
       $field_name = $this->cached_name();
361 361
       classSupernova::$cache->$field_name = $this->data;
362 362
 
363
-      foreach($to_write as $option_id => &$option_value) {
363
+      foreach ($to_write as $option_id => &$option_value) {
364 364
         $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД
365 365
         $option_value = array($this->user_id, $option_id, $option_value);
366 366
       }
@@ -376,26 +376,26 @@  discard block
 block discarded – undo
376 376
   }
377 377
 
378 378
   protected function load() {
379
-    if($this->loaded) {
379
+    if ($this->loaded) {
380 380
       return;
381 381
     }
382 382
 
383 383
     $this->data = $this->defaults;
384 384
 
385
-    if(!$this->user_id) {
385
+    if (!$this->user_id) {
386 386
       return;
387 387
     }
388 388
 
389 389
     $field_name = $this->cached_name();
390 390
     $a_data = classSupernova::$cache->$field_name;
391 391
 
392
-    if(!empty($a_data)) {
392
+    if (!empty($a_data)) {
393 393
       $this->data = array_replace($this->data, $a_data);
394 394
       return;
395 395
     }
396 396
 
397 397
     $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
398
-    while($row = db_fetch($query)) {
398
+    while ($row = db_fetch($query)) {
399 399
       // $this->data[$row['option_id']] = $row['value'];
400 400
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
401 401
     }
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
     return $this->__get($offset);
412 412
   }
413 413
   public function offsetSet($offset, $value) {
414
-    if(!is_null($offset)) {
414
+    if (!is_null($offset)) {
415 415
       // $this->data[$offset] = $value;
416 416
       $this->__set($offset, $value);
417 417
     } else {
Please login to merge, or discard this patch.
classes/UBE/UBEReport.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
    */
14 14
   public function sn_ube_report_save($ube) {
15 15
     // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
16
-    if($ube->get_cypher()) {
16
+    if ($ube->get_cypher()) {
17 17
       return false;
18 18
     }
19 19
 
20 20
     // Генерируем уникальный секретный ключ и проверяем наличие в базе
21 21
     do {
22 22
       $ube->report_cypher = sys_random_string(32);
23
-    } while(classSupernova::$db->doSelectFetchArray("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE"));
23
+    } while (classSupernova::$db->doSelectFetchArray("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE"));
24 24
 
25 25
     // Инициализация таблицы для пакетной вставки информации
26 26
     $sql_perform = array(
@@ -106,21 +106,21 @@  discard block
 block discarded – undo
106 106
 
107 107
     // Сохраняем общую информацию о бое
108 108
     classSupernova::$db->doInsertSet(TABLE_UBE_REPORT, array(
109
-        'ube_report_cypher'             => (string)$ube->report_cypher,
110
-        'ube_report_time_combat'        => (string)date(FMT_DATE_TIME_SQL, $ube->combat_timestamp),
111
-        'ube_report_time_spent'         => (float)$ube->time_spent,
112
-        'ube_report_combat_admin'       => (int)$ube->is_admin_in_combat,
113
-        'ube_report_mission_type'       => (int)$ube->mission_type_id,
114
-        'ube_report_combat_result'      => (int)$ube->combat_result,
115
-        'ube_report_combat_sfr'         => (int)$ube->is_small_fleet_recce,
116
-        'ube_report_planet_id'          => (int)$ube->ube_planet_info[PLANET_ID],
117
-        'ube_report_planet_name'        => (string)$ube->ube_planet_info[PLANET_NAME],
118
-        'ube_report_planet_size'        => (int)$ube->ube_planet_info[PLANET_SIZE],
119
-        'ube_report_planet_galaxy'      => (int)$ube->ube_planet_info[PLANET_GALAXY],
120
-        'ube_report_planet_system'      => (int)$ube->ube_planet_info[PLANET_SYSTEM],
121
-        'ube_report_planet_planet'      => (int)$ube->ube_planet_info[PLANET_PLANET],
122
-        'ube_report_planet_planet_type' => (int)$ube->ube_planet_info[PLANET_TYPE],
123
-        'ube_report_capture_result'     => (int)$ube->capture_result,
109
+        'ube_report_cypher'             => (string) $ube->report_cypher,
110
+        'ube_report_time_combat'        => (string) date(FMT_DATE_TIME_SQL, $ube->combat_timestamp),
111
+        'ube_report_time_spent'         => (float) $ube->time_spent,
112
+        'ube_report_combat_admin'       => (int) $ube->is_admin_in_combat,
113
+        'ube_report_mission_type'       => (int) $ube->mission_type_id,
114
+        'ube_report_combat_result'      => (int) $ube->combat_result,
115
+        'ube_report_combat_sfr'         => (int) $ube->is_small_fleet_recce,
116
+        'ube_report_planet_id'          => (int) $ube->ube_planet_info[PLANET_ID],
117
+        'ube_report_planet_name'        => (string) $ube->ube_planet_info[PLANET_NAME],
118
+        'ube_report_planet_size'        => (int) $ube->ube_planet_info[PLANET_SIZE],
119
+        'ube_report_planet_galaxy'      => (int) $ube->ube_planet_info[PLANET_GALAXY],
120
+        'ube_report_planet_system'      => (int) $ube->ube_planet_info[PLANET_SYSTEM],
121
+        'ube_report_planet_planet'      => (int) $ube->ube_planet_info[PLANET_PLANET],
122
+        'ube_report_planet_planet_type' => (int) $ube->ube_planet_info[PLANET_TYPE],
123
+        'ube_report_capture_result'     => (int) $ube->capture_result,
124 124
       )
125 125
       + $ube->debris->report_generate_array()
126 126
       + $ube->moon_calculator->report_generate_array()
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 
130 130
     // Сохраняем общую информацию по игрокам
131 131
     $player_sides = $ube->players->get_player_sides();
132
-    foreach($player_sides as $player_id => $player_side) {
132
+    foreach ($player_sides as $player_id => $player_side) {
133 133
       $sql_perform['ube_report_player'][] = array(
134 134
         $ube_report_id,
135 135
         $player_id,
136 136
 
137
-        "'" . db_escape($ube->players[$player_id]->name) . "'",
137
+        "'".db_escape($ube->players[$player_id]->name)."'",
138 138
         $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0,
139 139
 
140
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
141
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
142
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
140
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
141
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
142
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
143 143
       );
144 144
     }
145 145
 
146 146
     // Всякая информация по флотам
147
-    foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
147
+    foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
148 148
       // Сохраняем общую информацию по флотам
149 149
       $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id);
150 150
 
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 
161 161
     // Пакетная вставка данных
162 162
     // First row is a list of field names
163
-    foreach($sql_perform as $table_name => &$table_data) {
163
+    foreach ($sql_perform as $table_name => &$table_data) {
164 164
       // If only field names in this table - doing nothing
165
-      if(count($table_data) < 2) {
165
+      if (count($table_data) < 2) {
166 166
         continue;
167 167
       }
168 168
       // Picking up field names
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     $report_cypher = db_escape($report_cypher);
186 186
 
187 187
     $report_row = classSupernova::$db->doSelectFetchArray("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1");
188
-    if(!$report_row) {
188
+    if (!$report_row) {
189 189
       return UBE_REPORT_NOT_FOUND;
190 190
     }
191 191
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
    * @param     $template_result
202 202
    */
203 203
   public function sn_ube_report_generate(UBE $ube, &$template_result) {
204
-    if(!is_object($ube)) {
204
+    if (!is_object($ube)) {
205 205
       return;
206 206
     }
207 207
 
@@ -216,15 +216,15 @@  discard block
 block discarded – undo
216 216
 
217 217
     // Координаты, тип и название планеты - если есть
218 218
 //R  $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER];
219
-    if(isset($ube->ube_planet_info)) {
219
+    if (isset($ube->ube_planet_info)) {
220 220
       $template_result += $ube->ube_planet_info;
221 221
       $template_result[PLANET_NAME] = str_replace(' ', '&nbsp;', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8'));
222 222
     }
223 223
 
224 224
     // Обломки
225 225
     $debris = array();
226
-    foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) {
227
-      if($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
226
+    foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) {
227
+      if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
228 228
         $debris[] = array(
229 229
           'NAME'   => classLocale::$lang['tech'][$resource_id],
230 230
           'AMOUNT' => pretty_number($resource_amount),
Please login to merge, or discard this patch.
classes/UBE/UBE.php 1 patch
Spacing   +47 added lines, -48 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER);
151 151
 
152 152
     $player_db_row = $this->players[$player_id]->getDbRow();
153
-    if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
153
+    if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
154 154
       $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level);
155 155
     }
156 156
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     $this->rounds[0] = new UBERound(0);
182 182
     $this->rounds[0]->make_snapshot($this->fleet_list);
183 183
 
184
-    for($round = 1; $round <= 10; $round++) {
184
+    for ($round = 1; $round <= 10; $round++) {
185 185
       // Проводим раунд
186 186
       defined('DEBUG_UBE') ? print("Round {$round}<br>") : false;
187 187
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
       // Анализируем итоги текущего раунда и готовим данные для следующего
196 196
       $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round);
197
-      if($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
197
+      if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
198 198
         break;
199 199
       }
200 200
 
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
     // Генерируем результат боя
224 224
     $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates);
225 225
 
226
-    if(!$this->is_ube_loaded) {
226
+    if (!$this->is_ube_loaded) {
227 227
       $this->moon_calculator->calculate_moon($this);
228 228
 
229 229
       // Лутаем ресурсы - если аттакер выиграл
230
-      if($this->combat_result == UBE_COMBAT_RESULT_WIN) {
230
+      if ($this->combat_result == UBE_COMBAT_RESULT_WIN) {
231 231
         $this->sn_ube_combat_analyze_loot();
232 232
       }
233 233
     }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
       RES_DEUTERIUM => 0,
248 248
     );
249 249
 
250
-    if(
250
+    if (
251 251
       (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0)
252 252
       &&
253 253
       (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0)
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
       $planet_lootable_percent = $planet_lootable / $planet_resource_total;
260 260
 
261 261
       // Вычисляем сколько ресурсов вывезено
262
-      foreach($this->fleet_list->_container as $fleet_id => $fleet) {
262
+      foreach ($this->fleet_list->_container as $fleet_id => $fleet) {
263 263
         $looted_in_metal = 0;
264
-        foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
264
+        foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
265 265
           // Вычисляем какой процент общей емкости трюмов атакующих будет задействован
266 266
           $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity;
267 267
           $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent);
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
     $destination_user_id = $this->fleet_list[0]->owner_id;
327 327
 
328 328
     // Обновляем поле обломков на планете
329
-    if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
329
+    if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
330 330
       DBStaticPlanet::db_planet_update_by_gspt(
331 331
         $this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET,
332 332
         array(),
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
       );
338 338
     }
339 339
 
340
-    foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) {
340
+    foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) {
341 341
       $ship_count_lost = $UBEFleet->unit_list->unitCountLost();
342 342
 
343
-      if($fleet_id) {
343
+      if ($fleet_id) {
344 344
         // Флот
345 345
         $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status());
346 346
       } else {
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 
349 349
         // Сохраняем изменения ресурсов - если они есть
350 350
         $resource_delta = $UBEFleet->ube_combat_result_calculate_resources();
351
-        if(!empty($resource_delta)) {
351
+        if (!empty($resource_delta)) {
352 352
           $temp = array();
353
-          foreach($resource_delta as $resource_id => $resource_amount) {
353
+          foreach ($resource_delta as $resource_id => $resource_amount) {
354 354
             $resource_db_name = pname_resource_name($resource_id);
355 355
             $temp[$resource_db_name] = $resource_amount;
356 356
           }
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
           );
361 361
         }
362 362
 
363
-        if($ship_count_lost) {
363
+        if ($ship_count_lost) {
364 364
           $planet_row_cache = $this->players[$destination_user_id]->getDbRow();
365
-          foreach($UBEFleet->unit_list->_container as $UBEUnit) {
365
+          foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
366 366
             DBStaticUnit::dbUpdateOrInsertUnit($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]);
367 367
           }
368 368
         }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL
373 373
     // Для САБов
374 374
     $fleet_group_id_list = $this->fleet_list->ube_get_groups();
375
-    if(!empty($fleet_group_id_list)) {
375
+    if (!empty($fleet_group_id_list)) {
376 376
       $fleet_group_id_list = implode(',', $fleet_group_id_list);
377 377
       DBStaticFleetACS::db_acs_delete_by_list($fleet_group_id_list);
378 378
     }
@@ -380,14 +380,14 @@  discard block
 block discarded – undo
380 380
     $this->moon_calculator->db_apply_result($this->ube_planet_info, $destination_user_id);
381 381
 
382 382
     $bashing_list = array();
383
-    foreach($this->players->get_player_sides() as $player_id => $player_side) {
384
-      if($player_side != UBE_PLAYER_IS_ATTACKER) {
383
+    foreach ($this->players->get_player_sides() as $player_id => $player_side) {
384
+      if ($player_side != UBE_PLAYER_IS_ATTACKER) {
385 385
         continue;
386 386
       }
387
-      if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
387
+      if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
388 388
         $bashing_list[] = array($player_id, $this->ube_planet_info[PLANET_ID], $this->combat_timestamp);
389 389
       }
390
-      if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
390
+      if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
391 391
         $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose';
392 392
         DBStaticUser::db_user_adjust_by_id(
393 393
           $player_id,
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         );
400 400
       }
401 401
     }
402
-    if(!empty($bashing_list)) {
402
+    if (!empty($bashing_list)) {
403 403
       DBStaticFleetBashing::db_bashing_insert($bashing_list);
404 404
     }
405 405
 
@@ -425,20 +425,19 @@  discard block
 block discarded – undo
425 425
       $planet_info[PLANET_SYSTEM],
426 426
       $planet_info[PLANET_PLANET],
427 427
       htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'),
428
-      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' :
429
-        ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
428
+      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
430 429
     );
431 430
 
432 431
     $text_defender = '';
433 432
     $debris = $this->debris->get_debris();
434
-    foreach($debris as $resource_id => $resource_amount) {
435
-      if($resource_id == RES_DEUTERIUM) {
433
+    foreach ($debris as $resource_id => $resource_amount) {
434
+      if ($resource_id == RES_DEUTERIUM) {
436 435
         continue;
437 436
       }
438 437
 
439
-      $text_defender .= "{$classLocale['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />';
438
+      $text_defender .= "{$classLocale['tech'][$resource_id]}: ".pretty_number($resource_amount).'<br />';
440 439
     }
441
-    if($text_defender) {
440
+    if ($text_defender) {
442 441
       $text_defender = "{$classLocale['ube_report_msg_body_debris']}{$text_defender}<br />";
443 442
     }
444 443
 
@@ -448,8 +447,8 @@  discard block
 block discarded – undo
448 447
 
449 448
     // TODO: Оптимизировать отсылку сообщений - отсылать пакетами
450 449
     $player_sides = $this->players->get_player_sides();
451
-    foreach($player_sides as $player_id => $player_side) {
452
-      $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
450
+    foreach ($player_sides as $player_id => $player_side) {
451
+      $message = $text_common.($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
453 452
       DBStaticMessages::msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message);
454 453
     }
455 454
 
@@ -484,11 +483,11 @@  discard block
 block discarded – undo
484 483
     $player_id = $player_id == -1 ? $this->players->count() : $player_id;
485 484
     $fleet_id = $player_id; // FOR SIMULATOR!
486 485
 
487
-    if(empty($this->players[$player_id])) {
486
+    if (empty($this->players[$player_id])) {
488 487
       $this->players[$player_id] = new UBEPlayer();
489 488
     }
490 489
 
491
-    foreach($side_info as $fleet_data) {
490
+    foreach ($side_info as $fleet_data) {
492 491
       $this->players[$player_id]->name = $player_id;
493 492
       $this->players[$player_id]->setSide($attacker);
494 493
 
@@ -496,32 +495,32 @@  discard block
 block discarded – undo
496 495
       $this->fleet_list[$fleet_id] = $objFleet;
497 496
 
498 497
       $this->fleet_list[$fleet_id]->owner_id = $player_id;
499
-      foreach($fleet_data as $unit_id => $unit_count) {
500
-        if(!$unit_count) {
498
+      foreach ($fleet_data as $unit_id => $unit_count) {
499
+        if (!$unit_count) {
501 500
           continue;
502 501
         }
503 502
 
504 503
         $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
505 504
 
506
-        if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
505
+        if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
507 506
           $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count);
508
-        } elseif($unit_type == UNIT_RESOURCES) {
507
+        } elseif ($unit_type == UNIT_RESOURCES) {
509 508
           $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count;
510
-        } elseif($unit_type == UNIT_TECHNOLOGIES) {
511
-          if($unit_id == TECH_WEAPON) {
509
+        } elseif ($unit_type == UNIT_TECHNOLOGIES) {
510
+          if ($unit_id == TECH_WEAPON) {
512 511
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count);
513
-          } elseif($unit_id == TECH_SHIELD) {
512
+          } elseif ($unit_id == TECH_SHIELD) {
514 513
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count);
515
-          } elseif($unit_id == TECH_ARMOR) {
514
+          } elseif ($unit_id == TECH_ARMOR) {
516 515
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count);
517 516
           }
518
-        } elseif($unit_type == UNIT_GOVERNORS) {
519
-          if($unit_id == MRC_FORTIFIER) {
517
+        } elseif ($unit_type == UNIT_GOVERNORS) {
518
+          if ($unit_id == MRC_FORTIFIER) {
520 519
             // Фортифаер даёт бонус ко всему
521 520
             $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count);
522 521
           }
523
-        } elseif($unit_type == UNIT_MERCENARIES) {
524
-          if($unit_id == MRC_ADMIRAL) {
522
+        } elseif ($unit_type == UNIT_MERCENARIES) {
523
+          if ($unit_id == MRC_ADMIRAL) {
525 524
             $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count);
526 525
           }
527 526
         }
@@ -575,7 +574,7 @@  discard block
 block discarded – undo
575 574
 
576 575
     $ube->sn_ube_message_send();
577 576
 
578
-    defined('DEBUG_UBE') ? die('DIE at ' . __FILE__ . ' ' . __LINE__) : false;
577
+    defined('DEBUG_UBE') ? die('DIE at '.__FILE__.' '.__LINE__) : false;
579 578
 
580 579
     return false;
581 580
   }
@@ -590,7 +589,7 @@  discard block
 block discarded – undo
590 589
 
591 590
     $ube_report = new UBEReport();
592 591
     $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher'));
593
-    if($ube != UBE_REPORT_NOT_FOUND) {
592
+    if ($ube != UBE_REPORT_NOT_FOUND) {
594 593
       $ube_report->sn_ube_report_generate($ube, $template_result);
595 594
 
596 595
       $template = gettemplate('ube_combat_report', $template);
@@ -618,9 +617,9 @@  discard block
 block discarded – undo
618 617
     $ube->sn_ube_combat();
619 618
     $ube_report = new UBEReport();
620 619
 
621
-    if(sys_get_param_str('reload')) {
620
+    if (sys_get_param_str('reload')) {
622 621
       $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]);
623
-      if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
622
+      if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
624 623
         $ube = $ube_new;
625 624
       }
626 625
     }
@@ -668,7 +667,7 @@  discard block
 block discarded – undo
668 667
     $this->debris->load_from_report_row($report_row);
669 668
 
670 669
     $query = classSupernova::$db->doSelect("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
671
-    while($player_row = db_fetch($query)) {
670
+    while ($player_row = db_fetch($query)) {
672 671
       $this->players->init_player_from_report_info($player_row);
673 672
     }
674 673
 
Please login to merge, or discard this patch.