Completed
Push — work-fleets ( 5b06a4...37e31f )
by SuperNova.WS
04:49
created
includes/classes/template.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
       // Re-position template blocks
629 629
       for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--)
630 630
       {
631
-        $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1];
631
+        $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i - 1];
632 632
         $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i;
633 633
       }
634 634
 
@@ -710,13 +710,13 @@  discard block
 block discarded – undo
710 710
   */
711 711
   function assign_recursive($values, $name = '')
712 712
   {
713
-    if(isset($values['.']))
713
+    if (isset($values['.']))
714 714
     {
715 715
       $values_extra = $values['.'];
716 716
       unset($values['.']);
717 717
     }
718 718
 
719
-    if(!$name)
719
+    if (!$name)
720 720
     {
721 721
       $this->assign_vars($values);
722 722
     }
@@ -725,12 +725,12 @@  discard block
 block discarded – undo
725 725
       $this->assign_block_vars($name, $values);
726 726
     }
727 727
 
728
-    if(isset($values_extra))
728
+    if (isset($values_extra))
729 729
     {
730
-      foreach($values_extra as $sub_array_name => $sub_array)
730
+      foreach ($values_extra as $sub_array_name => $sub_array)
731 731
       {
732 732
         $new_name = $name . ($name ? '.' : '') . $sub_array_name;
733
-        foreach($sub_array as $sub_element)
733
+        foreach ($sub_array as $sub_element)
734 734
         {
735 735
           $this->assign_recursive($sub_element, $new_name);
736 736
         }
Please login to merge, or discard this patch.
includes/classes/auth_abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
    */
36 36
   // OK 4.9
37 37
   public function __construct($filename = __FILE__) {
38
-    if($this->provider_id == ACCOUNT_PROVIDER_NONE) {
38
+    if ($this->provider_id == ACCOUNT_PROVIDER_NONE) {
39 39
       die('У всех провайдеров должен быть $provider_id!');
40 40
     }
41 41
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
   // OK 4.6
134 134
   public function player_name_suggest() {
135 135
     $name = '';
136
-    if(is_object($this->account) && !empty($this->account->account_email)) {
136
+    if (is_object($this->account) && !empty($this->account->account_email)) {
137 137
       list($name) = explode('@', $this->account->account_email);
138 138
     }
139 139
 
Please login to merge, or discard this patch.
includes/classes/skin.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
    * Инициализация харнилища скинов
153 153
    */
154 154
   protected static function init() {
155
-    if(static::$is_init) {
155
+    if (static::$is_init) {
156 156
       return;
157 157
     }
158 158
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
     // Загружены ли уже данные по текущему скину?
167 167
 //pdump(static::$skin_list[$ini_path], 'static');
168
-    if(empty(static::$skin_list[$skin_path])) {
168
+    if (empty(static::$skin_list[$skin_path])) {
169 169
       // Прогружаем текущий скин
170 170
       static::$skin_list[$skin_path] = new skin($skin_path);
171 171
       static::$active = static::$skin_list[$skin_path];
@@ -201,22 +201,22 @@  discard block
 block discarded – undo
201 201
 
202 202
     $this->is_ini_present = false;
203 203
     // Проверка на корректность и существование пути
204
-    if(is_file($this->root_physical_absolute . 'skin.ini')) {
204
+    if (is_file($this->root_physical_absolute . 'skin.ini')) {
205 205
       // Пытаемся распарсить файл
206 206
 
207 207
       // По секциям? images и config? Что бы не копировать конфигурацию? Или просто unset(__inherit) а затем заново записать
208 208
       $this->config = parse_ini_file($this->root_physical_absolute . 'skin.ini');
209
-      if(!empty($this->config)) {
209
+      if (!empty($this->config)) {
210 210
 
211 211
         $this->is_ini_present = true;
212 212
 
213
-        if(!empty($this->config['_inherit'])) {
213
+        if (!empty($this->config['_inherit'])) {
214 214
           // Если скин наследует себя...
215
-          if($this->config['_inherit'] == $skin_path) {
215
+          if ($this->config['_inherit'] == $skin_path) {
216 216
             // TODO - определять более сложные случаи циклических ссылок в _inherit
217 217
             die('">circular skin inheritance!');
218 218
           }
219
-          if(empty(static::$skin_list[$this->config['_inherit']])) {
219
+          if (empty(static::$skin_list[$this->config['_inherit']])) {
220 220
             static::$skin_list[$this->config['_inherit']] = new skin($this->config['_inherit']);
221 221
           }
222 222
           $this->parent = static::$skin_list[$this->config['_inherit']];
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
     }
233 233
 
234 234
     // Пытаемся скомпилировать _no_image заранее
235
-    if(!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) {
235
+    if (!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) {
236 236
       $this->container[SKIN_IMAGE_MISSED_FIELD] = $this->compile_try_path(SKIN_IMAGE_MISSED_FIELD, $this->config[SKIN_IMAGE_MISSED_FIELD]);
237 237
     }
238 238
 
239 239
     // Если нет заглушки
240
-    if(empty($this->container[SKIN_IMAGE_MISSED_FIELD])) {
240
+    if (empty($this->container[SKIN_IMAGE_MISSED_FIELD])) {
241 241
       $this->container[SKIN_IMAGE_MISSED_FIELD] = empty($this->parent)
242 242
         // Если нет парента - берем хардкод
243 243
         ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL . SKIN_IMAGE_MISSED_FILE_PATH
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     $image_tag = $this->image_tag_parse($image_tag, $template);
268 268
 
269 269
     // Проверяем наличие ключа RIT в хранилища. В нём не может быть несуществующих файлов по построению
270
-    if(!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) {
270
+    if (!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) {
271 271
       return $this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]];
272 272
     }
273 273
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     // Нет - image ID не является путём к файлу. Пора обратиться к предкам за помощью...
286 286
     // Пытаемся вытащить путь из родителя и применить к нему свои параметры
287 287
     // Тащим по ID изображения, а не по ТЭГУ - мало ли что там делает с путём родитель и как преобразовывает его в строку?
288
-    if(empty($this->container[$image_id]) && !empty($this->parent)) {
288
+    if (empty($this->container[$image_id]) && !empty($this->parent)) {
289 289
       $this->container[$image_id] = $this->parent->compile_image($image_id, $template);
290 290
 
291 291
       // Если у родителя нет картинки - он вернет пустую строку. Тогда нам надо использовать заглушку - свою или родительскую
@@ -306,18 +306,18 @@  discard block
 block discarded – undo
306 306
   protected function image_tag_parse($image_tag, $template) {
307 307
     $image_tag_ptl_resolved = $image_tag;
308 308
     // Есть переменные из темплейта ?
309
-    if(strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) {
309
+    if (strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) {
310 310
       // Что бы лишний раз не запускать регексп
311 311
       // TODO - многоуровневые вложения ?! Надо ли и где их можно применить
312 312
       preg_match_all('#(\[.+?\])#', $image_tag_ptl_resolved, $matches);
313
-      foreach($matches[0] as &$match) {
313
+      foreach ($matches[0] as &$match) {
314 314
         $var_name = str_replace(array('[', ']'), '', $match);
315
-        if(strpos($var_name, '.') !== false) {
315
+        if (strpos($var_name, '.') !== false) {
316 316
           // Вложенная переменная темплейта - на текущем уровне
317 317
           // TODO Вложенная переменная из корня через "!"
318 318
           list($block_name, $block_var) = explode('.', $var_name);
319 319
           isset($template->_block_value[$block_name][$block_var]) ? $image_tag_ptl_resolved = str_replace($match, $template->_block_value[$block_name][$block_var], $image_tag_ptl_resolved) : false;
320
-        } elseif(strpos($var_name, '$') !== false) {
320
+        } elseif (strpos($var_name, '$') !== false) {
321 321
           // Корневой DEFINE
322 322
           $define_name = substr($var_name, 1);
323 323
           isset($template->_tpldata['DEFINE']['.'][$define_name]) ? $image_tag_ptl_resolved = str_replace($match, $template->_tpldata['DEFINE']['.'][$define_name], $image_tag_ptl_resolved) : false;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
       }
329 329
     }
330 330
 
331
-    if(strpos($image_tag_ptl_resolved, '|') !== false) {
331
+    if (strpos($image_tag_ptl_resolved, '|') !== false) {
332 332
       $params = explode('|', $image_tag_ptl_resolved);
333 333
       $image_id = $params[0];
334 334
       unset($params[0]);
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
     $image_string = $this->container[$image_tag];
393 393
 
394 394
     // Нет параметров - просто возвращаем значение по $image_name из контейнера
395
-    if(!empty($params) && is_array($params)) {
395
+    if (!empty($params) && is_array($params)) {
396 396
       // Здесь автоматически произойдёт упорядочивание параметров
397 397
 
398 398
       // Параметр 'html' - выводить изображение в виде HTML-тэга
399
-      if(in_array('html', $params)) {
399
+      if (in_array('html', $params)) {
400 400
         $image_tag = $image_tag . '|html';
401 401
         $image_string = '<img src="' . $image_string . '" />';
402 402
         $this->container[$image_tag] = $image_string;
Please login to merge, or discard this patch.
includes/update_old.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('IN_UPDATE') || IN_UPDATE !== true)
3
+if (!defined('IN_UPDATE') || IN_UPDATE !== true)
4 4
 {
5 5
   die('Hack attempt');
6 6
 }
7 7
 
8
-switch($new_version)
8
+switch ($new_version)
9 9
 {
10 10
   case 0:
11 11
   case 1:
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     );
35 35
     upd_drop_table('lunas');
36 36
 
37
-    if($update_tables['galaxy'])
37
+    if ($update_tables['galaxy'])
38 38
     {
39 39
       upd_do_query(
40 40
         'UPDATE `{{planets}}`
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     );
86 86
     upd_add_more_time();
87 87
 
88
-    if($update_tables['users']['rpg_points'])
88
+    if ($update_tables['users']['rpg_points'])
89 89
     {
90 90
       upd_do_query(
91 91
         "UPDATE {{users}} AS u
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
     upd_drop_table('update');
148 148
 
149
-    upd_check_key('fleet_speed', $config->fleet_speed/2500, $config->fleet_speed >= 2500);
149
+    upd_check_key('fleet_speed', $config->fleet_speed / 2500, $config->fleet_speed >= 2500);
150 150
     upd_check_key('game_counter', 0);
151 151
     upd_check_key('game_default_language', 'ru');
152 152
     upd_check_key('game_default_skin', 'skins/EpicBlue/');
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     upd_check_key('game_news_actual', 259200);
156 156
     upd_check_key('game_noob_factor', 5, !isset($config->game_noob_factor));
157 157
     upd_check_key('game_noob_points', 5000, !isset($config->game_noob_points));
158
-    upd_check_key('game_speed', $config->game_speed/2500, $config->game_speed >= 2500);
158
+    upd_check_key('game_speed', $config->game_speed / 2500, $config->game_speed >= 2500);
159 159
     upd_check_key('int_format_date', 'd.m.Y');
160 160
     upd_check_key('int_format_time', 'H:i:s', true);
161 161
     upd_check_key('int_banner_background', 'design/images/banner.png', true);
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
     upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']);
180 180
     upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']);
181 181
 
182
-    if($update_tables['planets']['b_building'])
182
+    if ($update_tables['planets']['b_building'])
183 183
     {
184 184
       $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;');
185 185
       $const_que_structures = QUE_STRUCTURES;
186
-      while($planet_data = db_fetch($planet_query))
186
+      while ($planet_data = db_fetch($planet_query))
187 187
       {
188 188
         $old_que = explode(';', $planet_data['b_building_id']);
189
-        foreach($old_que as $old_que_item_string)
189
+        foreach ($old_que as $old_que_item_string)
190 190
         {
191
-          if(!$old_que_item_string)
191
+          if (!$old_que_item_string)
192 192
           {
193 193
             continue;
194 194
           }
195 195
 
196 196
           $old_que_item = explode(',', $old_que_item_string);
197
-          if($old_que_item[4] == 'build')
197
+          if ($old_que_item[4] == 'build')
198 198
           {
199 199
             $old_que_item[4] = BUILD_CREATE;
200 200
           }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
231 231
     );
232 232
 
233
-    if($update_tables['users']['urlaubs_until'])
233
+    if ($update_tables['users']['urlaubs_until'])
234 234
     {
235 235
       upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']);
236 236
       upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;');
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
     ), !$update_tables['logs']['log_timestamp']);
282 282
     upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;');
283 283
 
284
-    if($update_tables['errors'])
284
+    if ($update_tables['errors'])
285 285
     {
286 286
       upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;');
287
-      if($update_tables['errors_backup'])
287
+      if ($update_tables['errors_backup'])
288 288
       {
289 289
         upd_drop_table('errors_backup');
290 290
       }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
     upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
352 352
 
353
-    if(!$update_tables['shortcut'])
353
+    if (!$update_tables['shortcut'])
354 354
     {
355 355
       upd_create_table('shortcut',
356 356
         "(
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
       $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON);
376 376
 
377 377
       $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';");
378
-      while($user_data = db_fetch($query))
378
+      while ($user_data = db_fetch($query))
379 379
       {
380 380
         $shortcuts = explode("\r\n", $user_data['fleet_shortcut']);
381
-        foreach($shortcuts as $shortcut)
381
+        foreach ($shortcuts as $shortcut)
382 382
         {
383
-          if(!$shortcut)
383
+          if (!$shortcut)
384 384
           {
385 385
             continue;
386 386
           }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
           $shortcut[3] = intval($shortcut[3]);
393 393
           $shortcut[4] = intval($shortcut[4]);
394 394
 
395
-          if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types))
395
+          if ($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types))
396 396
           {
397 397
             upd_do_query("INSERT INTO {$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true);
398 398
           }
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 
547 547
     upd_check_key('quest_total', 0, !isset($config->quest_total));
548 548
 
549
-    for($i = 0; $i < 25; $i++)
549
+    for ($i = 0; $i < 25; $i++)
550 550
     {
551 551
       upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]);
552 552
       upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]);
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
       "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist"
576 576
     ), !$update_tables['users']['msg_admin']);
577 577
 
578
-    if(!$update_foreigns['users']['FK_users_ally_id'])
578
+    if (!$update_foreigns['users']['FK_users_ally_id'])
579 579
     {
580 580
       upd_alter_table('users', array(
581 581
         'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL',
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
     ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED');
599 599
 
600 600
     $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);");
601
-    while($illegal_moon_row = db_fetch($illegal_moon_query))
601
+    while ($illegal_moon_row = db_fetch($illegal_moon_query))
602 602
     {
603 603
       upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true);
604 604
     }
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
     upd_log_version_update();
614 614
 
615 615
     upd_check_key('game_email_pm', 0, !isset($config->game_email_pm));
616
-    upd_check_key('player_vacation_time', 2*24*60*60, !isset($config->player_vacation_time));
617
-    upd_check_key('player_delete_time', 45*24*60*60, !isset($config->player_delete_time));
616
+    upd_check_key('player_vacation_time', 2 * 24 * 60 * 60, !isset($config->player_vacation_time));
617
+    upd_check_key('player_delete_time', 45 * 24 * 60 * 60, !isset($config->player_delete_time));
618 618
 
619 619
     upd_create_table('log_dark_matter',
620 620
       "(
@@ -636,18 +636,18 @@  discard block
 block discarded – undo
636 636
     upd_do_query('COMMIT;', true);
637 637
 
638 638
     $records = 1;
639
-    while($records)
639
+    while ($records)
640 640
     {
641 641
       upd_do_query('START TRANSACTION;', true);
642 642
       $query = upd_do_query("SELECT * FROM {{logs}} WHERE log_code = 102 order by log_id LIMIT 1000;");
643 643
       $records = db_num_rows($query);
644
-      while($row = db_fetch($query))
644
+      while ($row = db_fetch($query))
645 645
       {
646 646
         $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches);
647 647
 
648 648
         $reason = RPG_NONE;
649 649
         $comment = $matches[3];
650
-        switch($matches[3])
650
+        switch ($matches[3])
651 651
         {
652 652
           case 'Level Up For Structure Building':
653 653
             $reason = RPG_STRUCTURE;
@@ -664,21 +664,21 @@  discard block
 block discarded – undo
664 664
           break;
665 665
 
666 666
           default:
667
-            if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2))
667
+            if (preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2))
668 668
             {
669 669
               $reason = RPG_MARKET;
670 670
             }
671
-            elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2))
671
+            elseif (preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2))
672 672
             {
673 673
               $reason = RPG_MERCENARY;
674 674
               $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}";
675 675
             }
676
-            elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2))
676
+            elseif (preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2))
677 677
             {
678 678
               $reason = RPG_REFERRAL;
679 679
               $comment = "Incoming from referral ID {$matches[1]}";
680 680
             }
681
-            elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2))
681
+            elseif (preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2))
682 682
             {
683 683
               $reason = RPG_ADMIN;
684 684
               $comment = $matches2[1];
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
           break;
687 687
         }
688 688
 
689
-        if($matches[2])
689
+        if ($matches[2])
690 690
         {
691 691
           $row['log_username'] = db_escape($row['log_username']);
692 692
           $row['log_page'] = db_escape($row['log_page']);
@@ -706,14 +706,14 @@  discard block
 block discarded – undo
706 706
       upd_do_query('COMMIT;', true);
707 707
     }
708 708
 
709
-    foreach($update_tables as $table_name => $cork)
709
+    foreach ($update_tables as $table_name => $cork)
710 710
     {
711 711
       $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$config->db_prefix}{$table_name}';", true));
712
-      if($row['ENGINE'] != 'InnoDB')
712
+      if ($row['ENGINE'] != 'InnoDB')
713 713
       {
714 714
         upd_alter_table($table_name, 'ENGINE=InnoDB', true);
715 715
       }
716
-      if($row['TABLE_COLLATION'] != 'utf8_general_ci')
716
+      if ($row['TABLE_COLLATION'] != 'utf8_general_ci')
717 717
       {
718 718
         upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true);
719 719
       }
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
       "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0",
735 735
     ), !$update_tables['planets']['PLANET_GOVERNOR_ID']);
736 736
 
737
-    if($update_tables['users']['rpg_geologue'])
737
+    if ($update_tables['users']['rpg_geologue'])
738 738
     {
739 739
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;");
740 740
 
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
       ), $update_tables['users']['rpg_geologue']);
749 749
     }
750 750
 
751
-    if($update_tables['users']['rpg_bunker'])
751
+    if ($update_tables['users']['rpg_bunker'])
752 752
     {
753 753
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;");
754 754
 
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
     ), !isset($update_tables['alliance']['total_rank']));
800 800
     doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;");
801 801
 
802
-    if(!isset($update_tables['users']['ally_tag']))
802
+    if (!isset($update_tables['users']['ally_tag']))
803 803
     {
804 804
       upd_alter_table('users', array(
805 805
         "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
       "ADD COLUMN `player_artifact_list` TEXT",
816 816
     ), !isset($update_tables['users']['player_artifact_list']));
817 817
 
818
-    if(!isset($update_tables['users']['player_rpg_tech_xp']))
818
+    if (!isset($update_tables['users']['player_rpg_tech_xp']))
819 819
     {
820 820
       upd_check_key('eco_scale_storage', 1, !isset($config->eco_scale_storage));
821 821
 
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
       "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
847 847
     ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED');
848 848
 
849
-    if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
849
+    if (strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
850 850
     {
851 851
       upd_alter_table('alliance_diplomacy', array(
852 852
         "DROP FOREIGN KEY `FK_diplomacy_ally_id`",
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
       ), true);
863 863
     }
864 864
 
865
-    if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
865
+    if (strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
866 866
     {
867 867
       upd_alter_table('alliance_negotiation', array(
868 868
         "DROP FOREIGN KEY `FK_negotiation_ally_id`",
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
       ), true);
880 880
     }
881 881
 
882
-    if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED')
882
+    if (strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED')
883 883
     {
884 884
       upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
885 885
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
       ), true);
895 895
     }
896 896
 
897
-    if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED')
897
+    if (strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED')
898 898
     {
899 899
       upd_do_query('DELETE FROM {{annonce}} WHERE user NOT IN (SELECT username FROM {{users}});', true);
900 900
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
       ), true);
909 909
     }
910 910
 
911
-    if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
911
+    if (strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
912 912
     {
913 913
       upd_alter_table('bashing', array(
914 914
         "DROP FOREIGN KEY `FK_bashing_user_id`",
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
       ), true);
925 925
     }
926 926
 
927
-    if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED')
927
+    if (strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED')
928 928
     {
929 929
       upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR owner NOT IN (SELECT id FROM {{users}});', true);
930 930
 
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
       "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'",
964 964
     ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)');
965 965
 
966
-    if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED')
966
+    if (strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED')
967 967
     {
968 968
       upd_do_query('DELETE FROM {{iraks}} WHERE owner NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true);
969 969
 
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
       ), true);
989 989
     }
990 990
 
991
-    if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED')
991
+    if (strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED')
992 992
     {
993 993
       upd_do_query('DELETE FROM {{notes}} WHERE owner NOT IN (SELECT id FROM {{users}});', true);
994 994
 
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
       "DROP COLUMN `b_hangar_plus`",
1115 1115
     ), isset($update_tables['planets']['b_hangar_plus']));
1116 1116
 
1117
-    if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED')
1117
+    if (strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED')
1118 1118
     {
1119 1119
       upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true);
1120 1120
 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
       "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED",
1135 1135
     ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED');
1136 1136
 
1137
-    if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
1137
+    if (strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
1138 1138
     {
1139 1139
       upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true);
1140 1140
 
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
       ), true);
1151 1151
     }
1152 1152
 
1153
-    if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED')
1153
+    if (strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED')
1154 1154
     {
1155 1155
       upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
1156 1156
 
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
       "DROP COLUMN `settings_allylogo`",
1306 1306
     ), isset($update_tables['users']['settings_allylogo']));
1307 1307
 
1308
-    if(!isset($update_tables['powerup']))
1308
+    if (!isset($update_tables['powerup']))
1309 1309
     {
1310 1310
       upd_do_query("DROP TABLE IF EXISTS {$config->db_prefix}mercenaries;");
1311 1311
 
@@ -1336,13 +1336,13 @@  discard block
 block discarded – undo
1336 1336
 
1337 1337
       $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;";
1338 1338
       $user_list = upd_do_query("SELECT * FROM {{users}};");
1339
-      while($user_row = db_fetch($user_list))
1339
+      while ($user_row = db_fetch($user_list))
1340 1340
       {
1341 1341
         $update_query_str = '';
1342
-        foreach(sn_get_groups('mercenaries') as $mercenary_id)
1342
+        foreach (sn_get_groups('mercenaries') as $mercenary_id)
1343 1343
         {
1344 1344
           $mercenary_data_name = get_unit_param($mercenary_id, P_NAME);
1345
-          if($mercenary_level = $user_row[$mercenary_data_name])
1345
+          if ($mercenary_level = $user_row[$mercenary_data_name])
1346 1346
           {
1347 1347
             $update_query_str = ", `{$mercenary_data_name}` = 0";
1348 1348
             upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;");
@@ -1350,14 +1350,14 @@  discard block
 block discarded – undo
1350 1350
           }
1351 1351
         }
1352 1352
 
1353
-        if($update_query_str)
1353
+        if ($update_query_str)
1354 1354
         {
1355 1355
           upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id']));
1356 1356
         }
1357 1357
       }
1358 1358
     }
1359 1359
 
1360
-    if(!isset($update_tables['universe']))
1360
+    if (!isset($update_tables['universe']))
1361 1361
     {
1362 1362
       upd_create_table('universe',
1363 1363
         "(
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 
1382 1382
     // ------------------------------------------------------------------------
1383 1383
     // Modifying tables
1384
-    if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED')
1384
+    if (strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED')
1385 1385
     {
1386 1386
       upd_alter_table('users', array(
1387 1387
         "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL",
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
     // ------------------------------------------------------------------------
1404 1404
     // Creating players for allies
1405 1405
     $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;");
1406
-    while($ally_row = db_fetch($ally_row_list))
1406
+    while ($ally_row = db_fetch($ally_row_list))
1407 1407
     {
1408 1408
       $ally_user_name = db_escape("[{$ally_row['ally_tag']}]");
1409 1409
       doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};");
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
     // ------------------------------------------------------------------------
1419 1419
     // Creating planets for allies
1420 1420
     $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;");
1421
-    while($ally_user_row = db_fetch($ally_user_list))
1421
+    while ($ally_user_row = db_fetch($ally_user_list))
1422 1422
     {
1423 1423
       $ally_planet_name = db_escape($ally_user_row['username']);
1424 1424
       doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};");
@@ -1450,10 +1450,10 @@  discard block
 block discarded – undo
1450 1450
     // Adding db field
1451 1451
     upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']);
1452 1452
     // Converting old data to new one and dropping old fields
1453
-    if($update_tables['users']['b_tech_planet'])
1453
+    if ($update_tables['users']['b_tech_planet'])
1454 1454
     {
1455 1455
       $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;");
1456
-      while($planet_row = db_fetch($query))
1456
+      while ($planet_row = db_fetch($query))
1457 1457
       {
1458 1458
         $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH;
1459 1459
         doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;");
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
       upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']);
1468 1468
     }
1469 1469
 
1470
-    if(!$update_tables['powerup']['powerup_category'])
1470
+    if (!$update_tables['powerup']['powerup_category'])
1471 1471
     {
1472 1472
       upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']);
1473 1473
 
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
     upd_check_key('ali_bonus_brackets', 10, !isset($config->ali_bonus_brackets));
1490 1490
     upd_check_key('ali_bonus_brackets_divisor', 50, !isset($config->ali_bonus_brackets_divisor));
1491 1491
 
1492
-    if(!$config->db_loadItem('rpg_flt_explore'))
1492
+    if (!$config->db_loadItem('rpg_flt_explore'))
1493 1493
     {
1494 1494
       $inflation_rate = 1000;
1495 1495
 
@@ -1507,20 +1507,20 @@  discard block
 block discarded – undo
1507 1507
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};");
1508 1508
 
1509 1509
       $query = doquery("SELECT * FROM {{quest}}");
1510
-      while($row = db_fetch($query))
1510
+      while ($row = db_fetch($query))
1511 1511
       {
1512 1512
         $query_add = '';
1513 1513
         $quest_reward_list = explode(';', $row['quest_rewards']);
1514
-        foreach($quest_reward_list as &$quest_reward)
1514
+        foreach ($quest_reward_list as &$quest_reward)
1515 1515
         {
1516 1516
           list($reward_resource, $reward_amount) = explode(',', $quest_reward);
1517
-          if($reward_resource == RES_DARK_MATTER)
1517
+          if ($reward_resource == RES_DARK_MATTER)
1518 1518
           {
1519 1519
             $quest_reward = "{$reward_resource}," . $reward_amount * 1000;
1520 1520
           }
1521 1521
         }
1522 1522
         $new_rewards = implode(';', $quest_reward_list);
1523
-        if($new_rewards != $row['quest_rewards'])
1523
+        if ($new_rewards != $row['quest_rewards'])
1524 1524
         {
1525 1525
           doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;");
1526 1526
         }
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
     upd_check_key('user_birthday_range', 30, !isset($config->user_birthday_range));
1552 1552
     upd_check_key('user_birthday_celebrate', 0, !isset($config->user_birthday_celebrate));
1553 1553
 
1554
-    if(!isset($update_tables['payment']))
1554
+    if (!isset($update_tables['payment']))
1555 1555
     {
1556 1556
       upd_alter_table('users', array(
1557 1557
         "ADD KEY `I_user_id_name` (`id`, `username`)",
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
     ), !$update_tables['iraks']['fleet_start_type']);
1604 1604
 
1605 1605
 
1606
-    if(!$update_tables['payment']['payment_status'])
1606
+    if (!$update_tables['payment']['payment_status'])
1607 1607
     {
1608 1608
       upd_alter_table('payment', array(
1609 1609
         "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`",
@@ -1688,7 +1688,7 @@  discard block
 block discarded – undo
1688 1688
       "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)",
1689 1689
     ), !$update_indexes['notes']['I_owner_priority_time']);
1690 1690
 
1691
-    if(!$update_tables['buddy']['BUDDY_ID'])
1691
+    if (!$update_tables['buddy']['BUDDY_ID'])
1692 1692
     {
1693 1693
       upd_alter_table('buddy', array(
1694 1694
         "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'",
@@ -1710,10 +1710,10 @@  discard block
 block discarded – undo
1710 1710
 
1711 1711
       $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;");
1712 1712
       $found = $lost = array();
1713
-      while($row = db_fetch($query))
1713
+      while ($row = db_fetch($query))
1714 1714
       {
1715 1715
         $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1716
-        if(!isset($found[$index]))
1716
+        if (!isset($found[$index]))
1717 1717
         {
1718 1718
           $found[$index] = $row['BUDDY_ID'];
1719 1719
         }
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
         }
1724 1724
       }
1725 1725
       $lost = implode(',', $lost);
1726
-      if($lost)
1726
+      if ($lost)
1727 1727
       {
1728 1728
         upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})");
1729 1729
       }
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 
1746 1746
     upd_do_query("UPDATE {{users}} SET `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL");
1747 1747
 
1748
-    if(!$update_tables['ube_report'])
1748
+    if (!$update_tables['ube_report'])
1749 1749
     {
1750 1750
       upd_create_table('ube_report',
1751 1751
         "(
@@ -1787,7 +1787,7 @@  discard block
 block discarded – undo
1787 1787
       );
1788 1788
     }
1789 1789
 
1790
-    if(!$update_tables['ube_report_player'])
1790
+    if (!$update_tables['ube_report_player'])
1791 1791
     {
1792 1792
       upd_create_table('ube_report_player',
1793 1793
         "(
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
       );
1810 1810
     }
1811 1811
 
1812
-    if(!$update_tables['ube_report_fleet'])
1812
+    if (!$update_tables['ube_report_fleet'])
1813 1813
     {
1814 1814
       upd_create_table('ube_report_fleet',
1815 1815
         "(
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
       );
1841 1841
     }
1842 1842
 
1843
-    if(!$update_tables['ube_report_unit'])
1843
+    if (!$update_tables['ube_report_unit'])
1844 1844
     {
1845 1845
       // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках
1846 1846
       // Может сохранять имена удаленных кораблей долго?
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
       );
1879 1879
     }
1880 1880
 
1881
-    if(!$update_tables['ube_report_outcome_fleet'])
1881
+    if (!$update_tables['ube_report_outcome_fleet'])
1882 1882
     {
1883 1883
       upd_create_table('ube_report_outcome_fleet',
1884 1884
         "(
@@ -1908,7 +1908,7 @@  discard block
 block discarded – undo
1908 1908
       );
1909 1909
     }
1910 1910
 
1911
-    if(!$update_tables['ube_report_outcome_unit'])
1911
+    if (!$update_tables['ube_report_outcome_unit'])
1912 1912
     {
1913 1913
       upd_create_table('ube_report_outcome_unit',
1914 1914
         "(
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
       );
1931 1931
     }
1932 1932
 
1933
-    if(!$update_tables['unit'])
1933
+    if (!$update_tables['unit'])
1934 1934
     {
1935 1935
       upd_create_table('unit',
1936 1936
         "(
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
       );
1951 1951
     }
1952 1952
 
1953
-    if(!$update_tables['captain'])
1953
+    if (!$update_tables['captain'])
1954 1954
     {
1955 1955
       upd_create_table('captain',
1956 1956
         "(
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
       );
1972 1972
     }
1973 1973
 
1974
-    if(!$update_tables['fleets']['fleet_start_planet_id'])
1974
+    if (!$update_tables['fleets']['fleet_start_planet_id'])
1975 1975
     {
1976 1976
       upd_alter_table('fleets', array(
1977 1977
         "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`",
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
 
1995 1995
     upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']);
1996 1996
 
1997
-    if(!$update_tables['chat_player'])
1997
+    if (!$update_tables['chat_player'])
1998 1998
     {
1999 1999
       upd_create_table('chat_player',
2000 2000
         "(
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
       "DROP FOREIGN KEY `FK_payment_user`",
2058 2058
     ), $update_foreigns['payment']['FK_payment_user']);
2059 2059
 
2060
-    if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;')
2060
+    if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;')
2061 2061
     {
2062 2062
       upd_alter_table('chat', array(
2063 2063
         "DROP FOREIGN KEY `FK_chat_message_sender_user_id`",
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
       "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)",
2092 2092
     ), !$update_indexes['ube_report']['I_ube_report_time_combat']);
2093 2093
 
2094
-    if(!$update_tables['unit']['unit_time_start'])
2094
+    if (!$update_tables['unit']['unit_time_start'])
2095 2095
     {
2096 2096
       upd_alter_table('unit', array(
2097 2097
         "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'",
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
       );
2109 2109
     }
2110 2110
 
2111
-    if(!$update_tables['que'])
2111
+    if (!$update_tables['que'])
2112 2112
     {
2113 2113
       upd_create_table('que',
2114 2114
         "(
@@ -2141,15 +2141,15 @@  discard block
 block discarded – undo
2141 2141
     }
2142 2142
 
2143 2143
     // Конвертирум очередь исследований
2144
-    if($update_tables['users']['que'])
2144
+    if ($update_tables['users']['que'])
2145 2145
     {
2146 2146
       $que_lines = array();
2147 2147
       $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`");
2148
-      while($que_row = db_fetch($que_query))
2148
+      while ($que_row = db_fetch($que_query))
2149 2149
       {
2150 2150
         $que_data = explode(',', $que_row['que']);
2151 2151
 
2152
-        if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech')))
2152
+        if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech')))
2153 2153
         {
2154 2154
           continue;
2155 2155
         }
@@ -2157,14 +2157,14 @@  discard block
 block discarded – undo
2157 2157
         $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0;
2158 2158
         // Если планета пустая - ставим главку
2159 2159
         $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet'];
2160
-        if($que_data[QI_PLANET_ID])
2160
+        if ($que_data[QI_PLANET_ID])
2161 2161
         {
2162 2162
           $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2163
-          if(!$que_planet_check['id'])
2163
+          if (!$que_planet_check['id'])
2164 2164
           {
2165 2165
             $que_data[QI_PLANET_ID] = $que_row['id_planet'];
2166 2166
             $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2167
-            if(!$que_planet_check['id'])
2167
+            if (!$que_planet_check['id'])
2168 2168
             {
2169 2169
               $que_data[QI_PLANET_ID] = 'NULL';
2170 2170
             }
@@ -2181,9 +2181,9 @@  discard block
 block discarded – undo
2181 2181
         $price_increase = pow($unit_factor, $unit_level);
2182 2182
         $unit_level++;
2183 2183
         $unit_cost = array();
2184
-        foreach($unit_info[P_COST] as $resource_id => $resource_amount)
2184
+        foreach ($unit_info[P_COST] as $resource_id => $resource_amount)
2185 2185
         {
2186
-          if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase))
2186
+          if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase))
2187 2187
           {
2188 2188
             continue;
2189 2189
           }
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
           BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2196 2196
       }
2197 2197
 
2198
-      if(!empty($que_lines))
2198
+      if (!empty($que_lines))
2199 2199
       {
2200 2200
         upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines));
2201 2201
       }
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
 
2211 2211
 
2212 2212
     // Ковертируем технологии в таблицы
2213
-    if($update_tables['users']['graviton_tech'])
2213
+    if ($update_tables['users']['graviton_tech'])
2214 2214
     {
2215 2215
       upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES);
2216 2216
 
@@ -2218,18 +2218,18 @@  discard block
 block discarded – undo
2218 2218
       $user_query = upd_do_query("SELECT * FROM {{users}}");
2219 2219
       upd_add_more_time(300);
2220 2220
       $sn_group_tech = sn_get_groups('tech');
2221
-      while($user_row = db_fetch($user_query))
2221
+      while ($user_row = db_fetch($user_query))
2222 2222
       {
2223
-        foreach($sn_group_tech as $tech_id)
2223
+        foreach ($sn_group_tech as $tech_id)
2224 2224
         {
2225
-          if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)]))
2225
+          if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)]))
2226 2226
           {
2227 2227
             $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
2228 2228
           }
2229 2229
         }
2230 2230
       }
2231 2231
 
2232
-      if(!empty($que_lines))
2232
+      if (!empty($que_lines))
2233 2233
       {
2234 2234
         upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines));
2235 2235
       }
@@ -2239,30 +2239,30 @@  discard block
 block discarded – undo
2239 2239
       ), $update_tables['users']['graviton_tech']);
2240 2240
     }
2241 2241
 
2242
-    if(!$update_indexes['unit']['I_unit_record_search'])
2242
+    if (!$update_indexes['unit']['I_unit_record_search'])
2243 2243
     {
2244 2244
       upd_alter_table('unit', array(
2245 2245
         "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)",
2246 2246
       ), !$update_indexes['unit']['I_unit_record_search']);
2247 2247
 
2248
-      foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id)
2248
+      foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id)
2249 2249
       {
2250 2250
         $planet_units[get_unit_param($unit_id, P_NAME)] = 1;
2251 2251
       }
2252 2252
       $drop_index = array();
2253 2253
       $create_index = &$drop_index; // array();
2254
-      foreach($planet_units as $unit_name => $unit_create)
2254
+      foreach ($planet_units as $unit_name => $unit_create)
2255 2255
       {
2256
-        if($update_indexes['planets']['I_' . $unit_name])
2256
+        if ($update_indexes['planets']['I_' . $unit_name])
2257 2257
         {
2258 2258
           $drop_index[] = "DROP KEY I_{$unit_name}";
2259 2259
         }
2260
-        if($update_indexes['planets']['i_' . $unit_name])
2260
+        if ($update_indexes['planets']['i_' . $unit_name])
2261 2261
         {
2262 2262
           $drop_index[] = "DROP KEY i_{$unit_name}";
2263 2263
         }
2264 2264
 
2265
-        if($unit_create)
2265
+        if ($unit_create)
2266 2266
         {
2267 2267
           $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)";
2268 2268
         }
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
       "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`",
2275 2275
     ), !$update_tables['users']['user_time_utc_offset']);
2276 2276
 
2277
-    if(!$update_foreigns['alliance']['FK_alliance_owner'])
2277
+    if (!$update_foreigns['alliance']['FK_alliance_owner'])
2278 2278
     {
2279 2279
       upd_do_query("UPDATE {{alliance}} SET ally_owner = null WHERE ally_owner not in (select id from {{users}})");
2280 2280
 
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
 
2296 2296
     upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !$config->chat_highlight_developer);
2297 2297
 
2298
-    if(!$update_tables['player_name_history'])
2298
+    if (!$update_tables['player_name_history'])
2299 2299
     {
2300 2300
       upd_check_key('game_user_changename_cost', 100000, !$config->game_user_changename_cost);
2301 2301
       upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY);
@@ -2325,7 +2325,7 @@  discard block
 block discarded – undo
2325 2325
       "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'",
2326 2326
     ), !$update_tables['planets']['density_index']);
2327 2327
 
2328
-    if($update_tables['users']['player_artifact_list'])
2328
+    if ($update_tables['users']['player_artifact_list'])
2329 2329
     {
2330 2330
       upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']);
2331 2331
 
@@ -2336,17 +2336,17 @@  discard block
 block discarded – undo
2336 2336
       $db_changeset = array();
2337 2337
 
2338 2338
       $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE");
2339
-      while($row = db_fetch($query))
2339
+      while ($row = db_fetch($query))
2340 2340
       {
2341 2341
         $artifact_list = explode(';', $row['player_artifact_list']);
2342
-        if(!$row['player_artifact_list'] || empty($artifact_list))
2342
+        if (!$row['player_artifact_list'] || empty($artifact_list))
2343 2343
         {
2344 2344
           continue;
2345 2345
         }
2346
-        foreach($artifact_list as $key => &$value)
2346
+        foreach ($artifact_list as $key => &$value)
2347 2347
         {
2348 2348
           $value = explode(',', $value);
2349
-          if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]]))
2349
+          if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]]))
2350 2350
           {
2351 2351
             unset($artifact_list[$key]);
2352 2352
             continue;
@@ -2378,14 +2378,14 @@  discard block
 block discarded – undo
2378 2378
       "DROP COLUMN `colonisation_tech`",
2379 2379
     ), $update_tables['users']['spy_tech']);
2380 2380
 
2381
-    upd_check_key('payment_currency_exchange_dm_', 2500,             !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000);
2381
+    upd_check_key('payment_currency_exchange_dm_', 2500, !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000);
2382 2382
     upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !$config->payment_currency_exchange_eur);
2383
-    upd_check_key('payment_currency_exchange_rub', 4.0,              !$config->payment_currency_exchange_rub);
2384
-    upd_check_key('payment_currency_exchange_usd', 0.125,            !$config->payment_currency_exchange_usd);
2385
-    upd_check_key('payment_currency_exchange_wme', 0.0952380952381,  !$config->payment_currency_exchange_usd);
2386
-    upd_check_key('payment_currency_exchange_wmr', 4.1,              !$config->payment_currency_exchange_wmr);
2387
-    upd_check_key('payment_currency_exchange_wmu', 1.05,             !$config->payment_currency_exchange_wmu);
2388
-    upd_check_key('payment_currency_exchange_wmz', 0.126582278481,   !$config->payment_currency_exchange_wmz);
2383
+    upd_check_key('payment_currency_exchange_rub', 4.0, !$config->payment_currency_exchange_rub);
2384
+    upd_check_key('payment_currency_exchange_usd', 0.125, !$config->payment_currency_exchange_usd);
2385
+    upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !$config->payment_currency_exchange_usd);
2386
+    upd_check_key('payment_currency_exchange_wmr', 4.1, !$config->payment_currency_exchange_wmr);
2387
+    upd_check_key('payment_currency_exchange_wmu', 1.05, !$config->payment_currency_exchange_wmu);
2388
+    upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !$config->payment_currency_exchange_wmz);
2389 2389
 
2390 2390
     upd_do_query('COMMIT;', true);
2391 2391
     $new_version = 37;
Please login to merge, or discard this patch.
includes/pages/imperator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 //    $same_user = false;
54 54
 //  }
55 55
 
56
-  if(!$user_data) {
56
+  if (!$user_data) {
57 57
     message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10);
58 58
     die();
59 59
   }
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
   $stat_array = array();
65 65
   $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;");
66 66
   $stat_count = classSupernova::$db->db_affected_rows();
67
-  while($row = db_fetch($query)) {
68
-    foreach($stat_fields as $field_db_name => $field_template_name) {
67
+  while ($row = db_fetch($query)) {
68
+    foreach ($stat_fields as $field_db_name => $field_template_name) {
69 69
       // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS
70 70
       $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name];
71 71
     }
72 72
   }
73 73
 
74 74
   $stat_array_date = $stat_array['STAT_DATE'];
75
-  foreach($stat_array_date['DATA'] as $key => $value) {
75
+  foreach ($stat_array_date['DATA'] as $key => $value) {
76 76
     $template->assign_block_vars('stat_date', array(
77 77
       'ID' => $key,
78 78
       'VALUE' => $value,
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 
86 86
   unset($stat_array['STAT_DATE']);
87 87
   $template_data = array();
88
-  foreach($stat_array as $stat_type => &$stat_type_data) {
88
+  foreach ($stat_array as $stat_type => &$stat_type_data) {
89 89
     $reverse_min_max = strpos($stat_type, '_RANK') !== false;
90 90
     $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']);
91 91
     $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']);
92 92
     $stat_type_data['AVG'] = average($stat_type_data['DATA']);
93
-    foreach($stat_type_data['DATA'] as $key => $value) {
93
+    foreach ($stat_type_data['DATA'] as $key => $value) {
94 94
       // $stat_type_data['PERCENT'][$key] = $stat_type_data['MAX'] - $value ? ($stat_type_data['MAX'] - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $value) : 100;
95 95
       $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100;
96 96
       $template_data[$stat_type][$key]['ID'] = $key;
97 97
       $template_data[$stat_type][$key]['VALUE'] = $value;
98
-      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN']  - $value : $value - $stat_type_data['MAX']);
98
+      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']);
99 99
       $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key];
100 100
 
101 101
 //$template_data[$stat_type][$key]['PERCENT'] = $key ? $stat_type_data['PERCENT'][$key] : 50; // TODO DEBUG
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
   }
104 104
   // pdump($stat_array['RES_POINTS']);
105 105
 
106
-  foreach($template_data as $stat_type => $stat_type_data) {
106
+  foreach ($template_data as $stat_type => $stat_type_data) {
107 107
     $template->assign_block_vars('stat', array(
108 108
       'TYPE' => $stat_type,
109 109
       'TEXT' => $lang['imp_stat_types'][$stat_type],
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
       'MAX' => $stat_array[$stat_type]['MAX'],
112 112
       'AVG' => $stat_array[$stat_type]['AVG'],
113 113
     ));
114
-    foreach($stat_type_data as $stat_entry) {
114
+    foreach ($stat_type_data as $stat_entry) {
115 115
       $template->assign_block_vars('stat.entry', $stat_entry);
116 116
     }
117 117
   }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
   // pdump($template_data);
121 121
 
122
-  if($same_user) {
122
+  if ($same_user) {
123 123
     rpg_level_up($user, RPG_STRUCTURE);
124 124
     rpg_level_up($user, RPG_RAID);
125 125
     rpg_level_up($user, RPG_TECH);
@@ -153,29 +153,29 @@  discard block
 block discarded – undo
153 153
     'builder_xp'           => pretty_number($user_data['xpminier']),
154 154
     'builder_lvl'          => pretty_number($user_data['lvl_minier']),
155 155
     'builder_lvl_st'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])),
156
-    'builder_lvl_up'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)),
156
+    'builder_lvl_up'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)),
157 157
     'raid_xp'              => pretty_number($user_data['xpraid']),
158 158
     'raid_lvl'             => pretty_number($user_data['lvl_raid']),
159
-    'raid_lvl_up'          => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)),
159
+    'raid_lvl_up'          => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)),
160 160
     'raids'                => pretty_number($user_data['raids']),
161 161
     'raidswin'             => pretty_number($user_data['raidswin']),
162 162
     'raidsloose'           => pretty_number($user_data['raidsloose']),
163 163
     'tech_xp'              => pretty_number($user_data['player_rpg_tech_xp']),
164 164
     'tech_lvl'             => pretty_number($user_data['player_rpg_tech_level']),
165 165
     'tech_lvl_st'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])),
166
-    'tech_lvl_up'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)),
166
+    'tech_lvl_up'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)),
167 167
 
168 168
     'explore_xp'           => pretty_number($user_data['player_rpg_explore_xp']),
169 169
     'explore_lvl'          => pretty_number($user_data['player_rpg_explore_level']),
170 170
     'explore_lvl_st'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])),
171
-    'explore_lvl_up'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)),
172
-
173
-    'build_points'         => pretty_number( $StatRecord['build_points'] ),
174
-    'tech_points'          => pretty_number( $StatRecord['tech_points'] ),
175
-    'fleet_points'         => pretty_number( $StatRecord['fleet_points'] ),
176
-    'defs_points'          => pretty_number( $StatRecord['defs_points'] ),
177
-    'res_points'           => pretty_number( $StatRecord['res_points'] ),
178
-    'total_points'         => pretty_number( $StatRecord['total_points'] ),
171
+    'explore_lvl_up'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)),
172
+
173
+    'build_points'         => pretty_number($StatRecord['build_points']),
174
+    'tech_points'          => pretty_number($StatRecord['tech_points']),
175
+    'fleet_points'         => pretty_number($StatRecord['fleet_points']),
176
+    'defs_points'          => pretty_number($StatRecord['defs_points']),
177
+    'res_points'           => pretty_number($StatRecord['res_points']),
178
+    'total_points'         => pretty_number($StatRecord['total_points']),
179 179
     'user_rank'            => $StatRecord['total_rank'],
180 180
     'RANK_DIFF'            => $StatRecord['total_old_rank'] - $StatRecord['total_rank'],
181 181
 
Please login to merge, or discard this patch.
includes/pages/techtree.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
   global $lang, $user, $planetrow;
15 15
 
16 16
   $tech_tree = array();
17
-  foreach(get_unit_param('techtree') as $unit_group_id => $unit_list)
17
+  foreach (get_unit_param('techtree') as $unit_group_id => $unit_list)
18 18
   {
19 19
     $tech_tree[] = array(
20 20
       'NAME' => $lang['tech'][$unit_group_id],
21 21
       'GROUP_ID' => $unit_group_id,
22 22
     );
23 23
 
24
-    foreach($unit_list as $unit_id)
24
+    foreach ($unit_list as $unit_id)
25 25
     {
26 26
       $sn_data_unit = get_unit_param($unit_id);
27 27
       $level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true);
Please login to merge, or discard this patch.
includes/vars_structures.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
       'factor' => 1.5,
16 16
     ),
17 17
     P_UNIT_PRODUCTION => array(
18
-      RES_METAL     => function ($level, $production_factor, $user, $planet_row) {return  40 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
19
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
18
+      RES_METAL     => function($level, $production_factor, $user, $planet_row) {return  40 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
19
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
20 20
     ),
21 21
     P_MINING_IS_MANAGED => true,
22 22
   ),
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
       'factor' => 1.6,
34 34
     ),
35 35
     P_UNIT_PRODUCTION => array(
36
-      RES_CRYSTAL   => function ($level, $production_factor, $user, $planet_row) {return  32 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
37
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
36
+      RES_CRYSTAL   => function($level, $production_factor, $user, $planet_row) {return  32 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
37
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
38 38
     ),
39 39
     P_MINING_IS_MANAGED => true,
40 40
   ),
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
       'factor' => 1.5,
52 52
     ),
53 53
     P_UNIT_PRODUCTION => array(
54
-      RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return  10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);},
55
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
54
+      RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return  10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); },
55
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
56 56
     ),
57 57
     P_MINING_IS_MANAGED => true,
58 58
   ),
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
       'factor' => 1.5,
70 70
     ),
71 71
     P_UNIT_PRODUCTION => array(
72
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);},
72
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); },
73 73
     ),
74 74
     P_MINING_IS_MANAGED => true,
75 75
   ),
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
       'factor' => 1.8,
88 88
     ),
89 89
     P_UNIT_PRODUCTION => array(
90
-      RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
91
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return  30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor);},
90
+      RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
91
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return  30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); },
92 92
     ),
93 93
     P_MINING_IS_MANAGED => true,
94 94
   ),
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
       'factor' => 2,
106 106
     ),
107 107
     'storage' => array(
108
-      RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);},
108
+      RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); },
109 109
     ),
110 110
   ),
111 111
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
       'factor' => 2,
122 122
     ),
123 123
     'storage' => array(
124
-      RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);},
124
+      RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); },
125 125
     ),
126 126
   ),
127 127
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
       'factor' => 2,
138 138
     ),
139 139
     'storage' => array(
140
-      RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);},
140
+      RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); },
141 141
     ),
142 142
   ),
143 143
 
Please login to merge, or discard this patch.
includes/init/init_functions.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@  discard block
 block discarded – undo
2 2
 
3 3
 // ------------------------------------------------------------------------------------------------------------------------------
4 4
 function sn_sys_load_php_files($dir_name, $load_extension = 'php', $modules = false) {
5
-  if(file_exists($dir_name)) {
5
+  if (file_exists($dir_name)) {
6 6
     $dir = opendir($dir_name);
7
-    while(($file = readdir($dir)) !== false) {
8
-      if($file == '..' || $file == '.') {
7
+    while (($file = readdir($dir)) !== false) {
8
+      if ($file == '..' || $file == '.') {
9 9
         continue;
10 10
       }
11 11
 
12 12
       $full_filename = $dir_name . $file;
13
-      if($modules && is_dir($full_filename)) {
14
-        if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) {
13
+      if ($modules && is_dir($full_filename)) {
14
+        if (file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) {
15 15
           require_once($full_filename);
16 16
           // Registering module
17
-          if(class_exists($file)) {
17
+          if (class_exists($file)) {
18 18
             new $file($full_filename);
19 19
           }
20 20
         }
21 21
       } else {
22 22
         $extension = substr($full_filename, -strlen($load_extension));
23
-        if($extension == $load_extension) {
23
+        if ($extension == $load_extension) {
24 24
           require_once($full_filename);
25 25
         }
26 26
       }
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function init_update(&$config) {
41 41
   $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX;
42
-  if(file_exists($update_file)) {
43
-    if(filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) {
44
-      if(defined('IN_ADMIN')) {
42
+  if (file_exists($update_file)) {
43
+    if (filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) {
44
+      if (defined('IN_ADMIN')) {
45 45
         sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована
46
-        if(SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) {
46
+        if (SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) {
47 47
           $config->db_saveItem('var_db_update_end', SN_TIME_NOW + ($config->upd_lock_time ? $config->upd_lock_time : 300));
48 48
           sn_db_transaction_commit();
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
           $current_time = time();
54 54
           $config->db_saveItem('var_db_update', $current_time);
55 55
           $config->db_saveItem('var_db_update_end', $current_time);
56
-        } elseif(filemtime($update_file) > $config->var_db_update) {
56
+        } elseif (filemtime($update_file) > $config->var_db_update) {
57 57
           $timeout = $config->var_db_update_end - SN_TIME_NOW;
58 58
           die(
59 59
             "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br />
Please login to merge, or discard this patch.
includes/functions/eco_planet_update.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 
15 15
   $no_data = array('user' => false, 'planet' => false, 'que' => false);
16 16
 
17
-  if(!$planet) {
17
+  if (!$planet) {
18 18
     return $no_data;
19 19
   }
20 20
 
21
-  if(!$no_user_update) {
21
+  if (!$no_user_update) {
22 22
     $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user);
23
-    if(!$user) {
23
+    if (!$user) {
24 24
       // TODO - Убрать позже
25 25
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>');
26 26
       $backtrace = debug_backtrace();
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
     $user = db_user_by_id($user, !$simulation, '*', true);
33 33
   }
34 34
 
35
-  if(empty($user['id'])) {
35
+  if (empty($user['id'])) {
36 36
     return $no_data;
37 37
   }
38 38
 
39
-  if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
39
+  if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
40 40
     $planet = db_planet_by_vector($planet, '', !$simulation);
41 41
   } else {
42 42
     $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet);
43 43
     $planet = db_planet_by_id($planet, !$simulation);
44 44
   }
45
-  if(!is_array($planet) || !isset($planet['id'])) {
45
+  if (!is_array($planet) || !isset($planet['id'])) {
46 46
     return $no_data;
47 47
   }
48 48
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
     RES_DEUTERIUM => 0,
66 66
   );
67 67
 
68
-  switch($planet['planet_type']) {
68
+  switch ($planet['planet_type']) {
69 69
     case PT_PLANET:
70
-      foreach($resources_increase as $resource_id => &$increment) {
70
+      foreach ($resources_increase as $resource_id => &$increment) {
71 71
         $resource_name = pname_resource_name($resource_id);
72 72
         $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600;
73 73
         $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name];
74 74
         $increment = min($increment, max(0, $store_free));
75 75
 
76
-        if($planet[$resource_name] + $increment < 0 && !$simulation) {
76
+        if ($planet[$resource_name] + $increment < 0 && !$simulation) {
77 77
           global $debug;
78 78
           $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501);
79 79
         }
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
   // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора
96 96
   $planet['field_current'] = 0;
97 97
   $sn_group_build_allow = sn_get_groups('build_allow');
98
-  if(is_array($sn_group_build_allow[$planet['planet_type']])) {
99
-    foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) {
98
+  if (is_array($sn_group_build_allow[$planet['planet_type']])) {
99
+    foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) {
100 100
       $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true);
101 101
     }
102 102
   }
103 103
 
104
-  if($simulation) {
104
+  if ($simulation) {
105 105
     return array('user' => $user, 'planet' => $planet, 'que' => $que);
106 106
   }
107 107
 
Please login to merge, or discard this patch.