Completed
Push — work-fleets ( 71ccb1...0d1d7f )
by SuperNova.WS
06:04
created
includes/vars_menu.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
     'LEVEL' => 'submenu',
105 105
     'TYPE'  => 'lang',
106 106
     'ITEM'  => 'tech[UNIT_STRUCTURES]',
107
-    'LINK'  => 'buildings.php?mode=' . QUE_STRUCTURES,
107
+    'LINK'  => 'buildings.php?mode='.QUE_STRUCTURES,
108 108
     'ICON'  => true,
109 109
   ),
110 110
   'menu_planet_shipyard'   => array(
111 111
     'LEVEL' => 'submenu',
112 112
     'TYPE'  => 'lang',
113 113
     'ITEM'  => 'Shipyard',
114
-    'LINK'  => 'buildings.php?mode=' . SUBQUE_FLEET,
114
+    'LINK'  => 'buildings.php?mode='.SUBQUE_FLEET,
115 115
     'ICON'  => true,
116 116
   ),
117 117
   'menu_planet_defense'    => array(
118 118
     'LEVEL' => 'submenu',
119 119
     'TYPE'  => 'lang',
120 120
     'ITEM'  => 'Defense',
121
-    'LINK'  => 'buildings.php?mode=' . SUBQUE_DEFENSE,
121
+    'LINK'  => 'buildings.php?mode='.SUBQUE_DEFENSE,
122 122
     'ICON'  => true,
123 123
   ),
124 124
   'menu_planet_resources'  => array(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     'LEVEL' => 'submenu',
148 148
     'TYPE'  => 'lang',
149 149
     'ITEM'  => 'Research',
150
-    'LINK'  => 'buildings.php?mode=' . QUE_RESEARCH,
150
+    'LINK'  => 'buildings.php?mode='.QUE_RESEARCH,
151 151
     'ICON'  => true,
152 152
   ),
153 153
   'menu_empire_techtree' => array(
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
     'LEVEL' => 'submenu',
234 234
     'TYPE'  => 'lang',
235 235
     'ITEM'  => 'tech[UNIT_MERCENARIES]',
236
-    'LINK'  => 'officer.php?mode=' . UNIT_MERCENARIES,
236
+    'LINK'  => 'officer.php?mode='.UNIT_MERCENARIES,
237 237
     'ICON'  => true,
238 238
   ),
239 239
   'menu_empire_schematics'  => array(
240 240
     'LEVEL' => 'submenu',
241 241
     'TYPE'  => 'lang',
242 242
     'ITEM'  => 'tech[UNIT_PLANS]',
243
-    'LINK'  => 'officer.php?mode=' . UNIT_PLANS,
243
+    'LINK'  => 'officer.php?mode='.UNIT_PLANS,
244 244
     'ICON'  => true,
245 245
   ),
246 246
   'menu_empire_artifacts'   => array(
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
     'LEVEL' => 'submenu',
271 271
     'TYPE'  => 'lang',
272 272
     'ITEM'  => 'Chat',
273
-    'LINK'  => 'index.php?page=chat&mode=' . CHAT_MODE_COMMON,
273
+    'LINK'  => 'index.php?page=chat&mode='.CHAT_MODE_COMMON,
274 274
     'ICON'  => true,
275 275
   ),
276 276
   'menu_ally_chat'     => array(
277 277
     'LEVEL'    => 'submenu',
278 278
     'TYPE'     => 'lang',
279 279
     'ITEM'     => 'AllyChat',
280
-    'LINK'     => 'index.php?page=chat&mode=' . CHAT_MODE_ALLY,
280
+    'LINK'     => 'index.php?page=chat&mode='.CHAT_MODE_ALLY,
281 281
     'ICON'     => true,
282 282
     'DISABLED' => classSupernova::$config->game_mode == GAME_BLITZ,
283 283
   ),
@@ -458,8 +458,8 @@  discard block
 block discarded – undo
458 458
   ),
459 459
   'menu_admin_version_info'  => array(
460 460
     'TYPE' => 'text',
461
-    'ITEM' => (classSupernova::$config->server_updater_check_last ? date(FMT_DATE, classSupernova::$config->server_updater_check_last) : '') . '<div class="' .
462
-      $sn_version_check_class[classSupernova::$config->server_updater_check_result] . '">' . classLocale::$lang['adm_opt_ver_response_short'][classSupernova::$config->server_updater_check_result] . '</div>',
461
+    'ITEM' => (classSupernova::$config->server_updater_check_last ? date(FMT_DATE, classSupernova::$config->server_updater_check_last) : '').'<div class="'.
462
+      $sn_version_check_class[classSupernova::$config->server_updater_check_result].'">'.classLocale::$lang['adm_opt_ver_response_short'][classSupernova::$config->server_updater_check_result].'</div>',
463 463
   ),
464 464
 
465 465
   'USER_AUTHLEVEL_NAME'      => array(
@@ -547,13 +547,13 @@  discard block
 block discarded – undo
547 547
   'menu_admin_planet_list_planets' => array(
548 548
     'TYPE'       => 'lang',
549 549
     'ITEM'       => 'adm_pltlst',
550
-    'LINK'       => 'admin/adm_planet_list.php?planet_type=' . PT_PLANET,
550
+    'LINK'       => 'admin/adm_planet_list.php?planet_type='.PT_PLANET,
551 551
     'AUTH_LEVEL' => 3,
552 552
   ),
553 553
   'menu_admin_planet_list_moons'   => array(
554 554
     'TYPE'       => 'lang',
555 555
     'ITEM'       => 'adm_moonlst',
556
-    'LINK'       => 'admin/adm_planet_list.php?planet_type=' . PT_MOON,
556
+    'LINK'       => 'admin/adm_planet_list.php?planet_type='.PT_MOON,
557 557
     'AUTH_LEVEL' => 3,
558 558
   ),
559 559
   'menu_admin_planet_moon_add'     => array(
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Защита от двойного инита
4
-if(defined('INIT')) {
4
+if (defined('INIT')) {
5 5
   return;
6 6
 }
7 7
 
@@ -20,22 +20,22 @@  discard block
 block discarded – undo
20 20
 version_compare(PHP_VERSION, '5.3.2') < 0 ? die('FATAL ERROR: SuperNova REQUIRE PHP version > 5.3.2') : false;
21 21
 
22 22
 // Бенчмарк
23
-register_shutdown_function(function () {
24
-  if(defined('IN_AJAX')) {
23
+register_shutdown_function(function() {
24
+  if (defined('IN_AJAX')) {
25 25
     return;
26 26
   }
27 27
 
28 28
   global $user, $locale_cache_statistic;
29 29
 
30
-  print('<hr><div class="benchmark">Benchmark ' . (microtime(true) - SN_TIME_MICRO) . 's, memory: ' . number_format(memory_get_usage() - SN_MEM_START) .
31
-    (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') .
32
-    (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') .
30
+  print('<hr><div class="benchmark">Benchmark '.(microtime(true) - SN_TIME_MICRO).'s, memory: '.number_format(memory_get_usage() - SN_MEM_START).
31
+    (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '').
32
+    (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: '.classSupernova::$db->time_mysql_total.'ms' : '').
33 33
     '</div>');
34
-  if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
34
+  if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL.'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL.'badqrys.txt') > 0) {
35 35
     echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>';
36 36
   }
37 37
 
38
-  if(!empty($locale_cache_statistic['misses'])) {
38
+  if (!empty($locale_cache_statistic['misses'])) {
39 39
     print('<!--');
40 40
     pdump($locale_cache_statistic);
41 41
     print('-->');
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW));
57 57
 
58
-if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
58
+if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
59 59
   define('SN_GOOGLE', true);
60 60
 }
61 61
 
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 $sn_root_relative = str_replace($sn_root_relative, '', $_SERVER['SCRIPT_NAME']);
75 75
 define('SN_ROOT_RELATIVE', $sn_root_relative);
76 76
 
77
-define('SN_ROOT_VIRTUAL', 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . SN_ROOT_RELATIVE);
77
+define('SN_ROOT_VIRTUAL', 'http'.(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '').'://'.$_SERVER['HTTP_HOST'].SN_ROOT_RELATIVE);
78 78
 define('SN_ROOT_VIRTUAL_PARENT', str_replace('//google.', '//', SN_ROOT_VIRTUAL));
79 79
 
80 80
 $phpEx = strpos($phpEx = substr(strrchr(__FILE__, '.'), 1), '/') === false ? $phpEx : '';
81 81
 define('PHP_EX', $phpEx); // PHP extension on this server
82
-define('DOT_PHP_EX', '.' . PHP_EX); // PHP extension on this server
82
+define('DOT_PHP_EX', '.'.PHP_EX); // PHP extension on this server
83 83
 
84 84
 
85 85
 require_once('constants.php');
@@ -100,22 +100,22 @@  discard block
 block discarded – undo
100 100
 
101 101
 // required for db.php
102 102
 // Initializing global 'debug' object
103
-require_once(SN_ROOT_PHYSICAL . "includes/debug.class" . DOT_PHP_EX);
103
+require_once(SN_ROOT_PHYSICAL."includes/debug.class".DOT_PHP_EX);
104 104
 classSupernova::$debug = new debug();
105 105
 
106
-spl_autoload_register(function ($class) {
107
-  if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) {
108
-    require_once SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php';
106
+spl_autoload_register(function($class) {
107
+  if (file_exists(SN_ROOT_PHYSICAL.'includes/classes/'.$class.'.php')) {
108
+    require_once SN_ROOT_PHYSICAL.'includes/classes/'.$class.'.php';
109 109
   }
110 110
 });
111 111
 
112
-spl_autoload_register(function ($class) {
113
-  if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) {
114
-    require_once SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php';
112
+spl_autoload_register(function($class) {
113
+  if (file_exists(SN_ROOT_PHYSICAL.'includes/classes/UBE/'.$class.'.php')) {
114
+    require_once SN_ROOT_PHYSICAL.'includes/classes/UBE/'.$class.'.php';
115 115
   }
116 116
 });
117 117
 
118
-require_once(SN_ROOT_PHYSICAL . "includes/db" . DOT_PHP_EX);
118
+require_once(SN_ROOT_PHYSICAL."includes/db".DOT_PHP_EX);
119 119
 require_once('classes/db_mysql_v4.php');
120 120
 require_once('classes/db_mysql_v5.php');
121 121
 require_once('classes/db_mysql.php');
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 require_once('classes/module.php');
129 129
 
130 130
 require_once('classes/user_options.php');
131
-require_once(SN_ROOT_PHYSICAL . "includes/init/init_functions" . DOT_PHP_EX);
131
+require_once(SN_ROOT_PHYSICAL."includes/init/init_functions".DOT_PHP_EX);
132 132
 
133 133
 /**
134 134
  * @var classConfig    $config
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 // define('BE_DEBUG', true); // Отладка боевого движка
143 143
 classSupernova::init_debug_state();
144 144
 
145
-require_once(SN_ROOT_PHYSICAL . "includes/vars" . DOT_PHP_EX);
146
-require_once(SN_ROOT_PHYSICAL . "includes/general" . DOT_PHP_EX);
145
+require_once(SN_ROOT_PHYSICAL."includes/vars".DOT_PHP_EX);
146
+require_once(SN_ROOT_PHYSICAL."includes/general".DOT_PHP_EX);
147 147
 
148 148
 init_update();
149 149
 
@@ -152,34 +152,34 @@  discard block
 block discarded – undo
152 152
   ? trim(strip_tags($_GET['page']))
153 153
   : str_replace(DOT_PHP_EX, '', str_replace(SN_ROOT_RELATIVE, '', str_replace('\\', '/', $_SERVER['SCRIPT_NAME'])));
154 154
 define('INITIAL_PAGE', $sn_page_name_original);
155
-define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova') . (defined('SN_GOOGLE') ? '_G' : ''));
156
-define('SN_COOKIE_I', SN_COOKIE . AUTH_COOKIE_IMPERSONATE_SUFFIX);
157
-define('SN_COOKIE_D', SN_COOKIE . '_D');
158
-define('SN_COOKIE_T', SN_COOKIE . '_T'); // Time measure cookie
159
-define('SN_COOKIE_F', SN_COOKIE . '_F'); // Font size cookie
160
-define('SN_COOKIE_U', SN_COOKIE . '_U'); // Current user cookie aka user ID
161
-define('SN_COOKIE_U_I', SN_COOKIE_U . AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID
155
+define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova').(defined('SN_GOOGLE') ? '_G' : ''));
156
+define('SN_COOKIE_I', SN_COOKIE.AUTH_COOKIE_IMPERSONATE_SUFFIX);
157
+define('SN_COOKIE_D', SN_COOKIE.'_D');
158
+define('SN_COOKIE_T', SN_COOKIE.'_T'); // Time measure cookie
159
+define('SN_COOKIE_F', SN_COOKIE.'_F'); // Font size cookie
160
+define('SN_COOKIE_U', SN_COOKIE.'_U'); // Current user cookie aka user ID
161
+define('SN_COOKIE_U_I', SN_COOKIE_U.AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID
162 162
 define('TEMPLATE_NAME', classSupernova::$config->game_default_template ? classSupernova::$config->game_default_template : 'OpenGame');
163
-define('TEMPLATE_PATH', 'design/templates/' . TEMPLATE_NAME);
164
-define('TEMPLATE_DIR', SN_ROOT_PHYSICAL . TEMPLATE_PATH);
163
+define('TEMPLATE_PATH', 'design/templates/'.TEMPLATE_NAME);
164
+define('TEMPLATE_DIR', SN_ROOT_PHYSICAL.TEMPLATE_PATH);
165 165
 define('DEFAULT_SKINPATH', classSupernova::$config->game_default_skin ? classSupernova::$config->game_default_skin : 'skins/EpicBlue/');
166 166
 define('DEFAULT_LANG', classSupernova::$config->game_default_language ? classSupernova::$config->game_default_language : 'ru');
167 167
 define('FMT_DATE', classSupernova::$config->int_format_date ? classSupernova::$config->int_format_date : 'd.m.Y');
168 168
 define('FMT_TIME', classSupernova::$config->int_format_time ? classSupernova::$config->int_format_time : 'H:i:s');
169
-define('FMT_DATE_TIME', FMT_DATE . ' ' . FMT_TIME);
169
+define('FMT_DATE_TIME', FMT_DATE.' '.FMT_TIME);
170 170
 
171 171
 $HTTP_ACCEPT_LANGUAGE = DEFAULT_LANG;
172 172
 
173
-require_once(SN_ROOT_PHYSICAL . "includes/template" . DOT_PHP_EX);
173
+require_once(SN_ROOT_PHYSICAL."includes/template".DOT_PHP_EX);
174 174
 $template_result = array('.' => array('result' => array()));
175 175
 
176
-sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX);
176
+sn_sys_load_php_files(SN_ROOT_PHYSICAL."includes/functions/", PHP_EX);
177 177
 
178
-spl_autoload_register(function ($class) {
179
-  if(file_exists('includes/classes/' . $class . '.php')) {
180
-    require_once 'includes/classes/' . $class . '.php';
181
-  } elseif(file_exists('includes/classes/UBE/' . $class . '.php')) {
182
-    require_once 'includes/classes/UBE/' . $class . '.php';
178
+spl_autoload_register(function($class) {
179
+  if (file_exists('includes/classes/'.$class.'.php')) {
180
+    require_once 'includes/classes/'.$class.'.php';
181
+  } elseif (file_exists('includes/classes/UBE/'.$class.'.php')) {
182
+    require_once 'includes/classes/UBE/'.$class.'.php';
183 183
   } else {
184 184
 //    die("Can't find {$class} class");
185 185
   }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 // Конфиг - часть манифеста?
194 194
 classSupernova::$auth = new core_auth();
195 195
 
196
-sn_sys_load_php_files(SN_ROOT_PHYSICAL . "modules/", PHP_EX, true);
196
+sn_sys_load_php_files(SN_ROOT_PHYSICAL."modules/", PHP_EX, true);
197 197
 // Здесь - потому что core_auth модуль лежит в другом каталоге и его нужно инициализировать отдельно
198 198
 
199 199
 // Подключаем дефолтную страницу
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
 // Сейчас мы делаем это здесь только для того, что бы содержание дефолтной страницы оказалось вверху. Что не факт, что нужно всегда
202 202
 // Но нужно, пока у нас есть не MVC-страницы
203 203
 $sn_page_data = $sn_data['pages'][$sn_page_name];
204
-$sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
205
-if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
204
+$sn_page_name_file = 'includes/pages/'.$sn_page_data['filename'].DOT_PHP_EX;
205
+if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
206 206
   require_once($sn_page_name_file);
207
-  if(is_array($sn_page_data['options'])) {
207
+  if (is_array($sn_page_data['options'])) {
208 208
     $supernova->options = array_merge($supernova->options, $sn_page_data['options']);
209 209
   }
210 210
 }
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 $load_order = array();
220 220
 $sn_req = array();
221 221
 
222
-foreach(sn_module::$sn_module as $loaded_module_name => $module_data) {
222
+foreach (sn_module::$sn_module as $loaded_module_name => $module_data) {
223 223
   $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000;
224
-  if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
225
-    foreach($module_data->manifest['require'] as $require_name) {
224
+  if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
225
+    foreach ($module_data->manifest['require'] as $require_name) {
226 226
       $sn_req[$loaded_module_name][$require_name] = 0;
227 227
     }
228 228
   }
@@ -235,10 +235,10 @@  discard block
 block discarded – undo
235 235
 do {
236 236
   $prev_order = $load_order;
237 237
 
238
-  foreach($sn_req as $loaded_module_name => &$req_data) {
238
+  foreach ($sn_req as $loaded_module_name => &$req_data) {
239 239
     $level = 1;
240
-    foreach($req_data as $req_name => &$req_level) {
241
-      if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
240
+    foreach ($req_data as $req_name => &$req_level) {
241
+      if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
242 242
         $level = $req_level = -1;
243 243
         break;
244 244
       } else {
@@ -246,20 +246,20 @@  discard block
 block discarded – undo
246 246
       }
247 247
       $req_level = $load_order[$req_name];
248 248
     }
249
-    if($level > $load_order[$loaded_module_name] || $level == -1) {
249
+    if ($level > $load_order[$loaded_module_name] || $level == -1) {
250 250
       $load_order[$loaded_module_name] = $level;
251 251
     }
252 252
   }
253
-} while($prev_order != $load_order);
253
+} while ($prev_order != $load_order);
254 254
 
255 255
 asort($load_order);
256 256
 
257 257
 // Инициализируем модули
258 258
 // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти
259
-foreach($load_order as $loaded_module_name => $load_order_order) {
260
-  if($load_order_order >= 0) {
259
+foreach ($load_order as $loaded_module_name => $load_order_order) {
260
+  if ($load_order_order >= 0) {
261 261
     sn_module::$sn_module[$loaded_module_name]->check_status();
262
-    if(!sn_module::$sn_module[$loaded_module_name]->manifest['active']) {
262
+    if (!sn_module::$sn_module[$loaded_module_name]->manifest['active']) {
263 263
       unset(sn_module::$sn_module[$loaded_module_name]);
264 264
       continue;
265 265
     }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 unset($sn_req);
277 277
 
278 278
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
279
-if(!isset($sn_data['pages'][$sn_page_name])) {
279
+if (!isset($sn_data['pages'][$sn_page_name])) {
280 280
   $sn_page_name = '';
281 281
 }
282 282
 
@@ -284,6 +284,6 @@  discard block
 block discarded – undo
284 284
 classLocale::$lang = $lang = new classLocale(classSupernova::$config->server_locale_log_usage);
285 285
 classLocale::$lang->lng_switch(sys_get_param_str('lang'));
286 286
 
287
-if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
287
+if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
288 288
   require_once "init_secondary.php";
289 289
 }
Please login to merge, or discard this patch.
includes/update_old.php 1 patch
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  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
   die('Hack attempt');
5 5
 }
6 6
 
7
-switch($new_version) {
7
+switch ($new_version) {
8 8
   case 0:
9 9
   case 1:
10 10
   case 2:
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     );
33 33
     upd_drop_table('lunas');
34 34
 
35
-    if($update_tables['galaxy']) {
35
+    if ($update_tables['galaxy']) {
36 36
       upd_do_query(
37 37
         'UPDATE `{{planets}}`
38 38
           LEFT JOIN `{{galaxy}}` ON {{galaxy}}.id_planet = {{planets}}.id
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
     );
83 83
     upd_add_more_time();
84 84
 
85
-    if($update_tables['users']['rpg_points']) {
85
+    if ($update_tables['users']['rpg_points']) {
86 86
       upd_do_query(
87 87
         "UPDATE {{users}} AS u
88 88
           RIGHT JOIN {{referrals}} AS r
89
-            ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor . "
90
-        SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor . ");"
89
+            ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor."
90
+        SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor.");"
91 91
       );
92 92
     }
93 93
 
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
     upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']);
176 176
     upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']);
177 177
 
178
-    if($update_tables['planets']['b_building']) {
178
+    if ($update_tables['planets']['b_building']) {
179 179
       $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;');
180 180
       $const_que_structures = QUE_STRUCTURES;
181
-      while($planet_data = db_fetch($planet_query)) {
181
+      while ($planet_data = db_fetch($planet_query)) {
182 182
         $old_que = explode(';', $planet_data['b_building_id']);
183
-        foreach($old_que as $old_que_item_string) {
184
-          if(!$old_que_item_string) {
183
+        foreach ($old_que as $old_que_item_string) {
184
+          if (!$old_que_item_string) {
185 185
             continue;
186 186
           }
187 187
 
188 188
           $old_que_item = explode(',', $old_que_item_string);
189
-          if($old_que_item[4] == 'build') {
189
+          if ($old_que_item[4] == 'build') {
190 190
             $old_que_item[4] = BUILD_CREATE;
191 191
           } else {
192 192
             $old_que_item[4] = BUILD_DESTROY;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
220 220
     );
221 221
 
222
-    if($update_tables['users']['urlaubs_until']) {
222
+    if ($update_tables['users']['urlaubs_until']) {
223 223
       upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']);
224 224
       upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;');
225 225
       upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']);
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
     ), !$update_tables['logs']['log_timestamp']);
270 270
     upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;');
271 271
 
272
-    if($update_tables['errors']) {
272
+    if ($update_tables['errors']) {
273 273
       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}}`;');
274
-      if($update_tables['errors_backup']) {
274
+      if ($update_tables['errors_backup']) {
275 275
         upd_drop_table('errors_backup');
276 276
       }
277
-      upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup');
277
+      upd_alter_table('errors', ' RENAME TO '.classSupernova::$config->db_prefix.'errors_backup');
278 278
 
279 279
       upd_drop_table('errors');
280 280
     }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
     upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
334 334
 
335
-    if(!$update_tables['shortcut']) {
335
+    if (!$update_tables['shortcut']) {
336 336
       upd_create_table('shortcut',
337 337
         "(
338 338
           `shortcut_id` SERIAL,
@@ -356,10 +356,10 @@  discard block
 block discarded – undo
356 356
       $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON);
357 357
 
358 358
       $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';");
359
-      while($user_data = db_fetch($query)) {
359
+      while ($user_data = db_fetch($query)) {
360 360
         $shortcuts = explode("\r\n", $user_data['fleet_shortcut']);
361
-        foreach($shortcuts as $shortcut) {
362
-          if(!$shortcut) {
361
+        foreach ($shortcuts as $shortcut) {
362
+          if (!$shortcut) {
363 363
             continue;
364 364
           }
365 365
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
           $shortcut[3] = intval($shortcut[3]);
371 371
           $shortcut[4] = intval($shortcut[4]);
372 372
 
373
-          if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) {
373
+          if ($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) {
374 374
             upd_do_query("INSERT INTO {classSupernova::$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);
375 375
           }
376 376
         }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 
523 523
     upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total));
524 524
 
525
-    for($i = 0; $i < 25; $i++) {
525
+    for ($i = 0; $i < 25; $i++) {
526 526
       upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]);
527 527
       upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]);
528 528
       upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]);
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
       "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist"
551 551
     ), !$update_tables['users']['msg_admin']);
552 552
 
553
-    if(!$update_foreigns['users']['FK_users_ally_id']) {
553
+    if (!$update_foreigns['users']['FK_users_ally_id']) {
554 554
       upd_alter_table('users', array(
555 555
         'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL',
556 556
         'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL',
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
     ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED');
573 573
 
574 574
     $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);");
575
-    while($illegal_moon_row = db_fetch($illegal_moon_query)) {
575
+    while ($illegal_moon_row = db_fetch($illegal_moon_query)) {
576 576
       upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true);
577 577
     }
578 578
 
@@ -609,16 +609,16 @@  discard block
 block discarded – undo
609 609
     upd_do_query('COMMIT;', true);
610 610
 
611 611
     $records = 1;
612
-    while($records) {
612
+    while ($records) {
613 613
       upd_do_query('START TRANSACTION;', true);
614 614
       $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;");
615 615
       $records = db_num_rows($query);
616
-      while($row = db_fetch($query)) {
616
+      while ($row = db_fetch($query)) {
617 617
         $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches);
618 618
 
619 619
         $reason = RPG_NONE;
620 620
         $comment = $matches[3];
621
-        switch($matches[3]) {
621
+        switch ($matches[3]) {
622 622
           case 'Level Up For Structure Building':
623 623
             $reason = RPG_STRUCTURE;
624 624
           break;
@@ -634,22 +634,22 @@  discard block
 block discarded – undo
634 634
           break;
635 635
 
636 636
           default:
637
-            if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) {
637
+            if (preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) {
638 638
               $reason = RPG_MARKET;
639
-            } elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) {
639
+            } elseif (preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) {
640 640
               $reason = RPG_MERCENARY;
641 641
               $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}";
642
-            } elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) {
642
+            } elseif (preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) {
643 643
               $reason = RPG_REFERRAL;
644 644
               $comment = "Incoming from referral ID {$matches[1]}";
645
-            } elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) {
645
+            } elseif (preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) {
646 646
               $reason = RPG_ADMIN;
647 647
               $comment = $matches2[1];
648 648
             }
649 649
           break;
650 650
         }
651 651
 
652
-        if($matches[2]) {
652
+        if ($matches[2]) {
653 653
           $row['log_username'] = db_escape($row['log_username']);
654 654
           $row['log_page'] = db_escape($row['log_page']);
655 655
           $comment = db_escape($comment);
@@ -668,12 +668,12 @@  discard block
 block discarded – undo
668 668
       upd_do_query('COMMIT;', true);
669 669
     }
670 670
 
671
-    foreach($update_tables as $table_name => $cork) {
672
-      $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '" . classSupernova::$config->db_prefix . "{$table_name}';", true));
673
-      if($row['ENGINE'] != 'InnoDB') {
671
+    foreach ($update_tables as $table_name => $cork) {
672
+      $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '".classSupernova::$config->db_prefix."{$table_name}';", true));
673
+      if ($row['ENGINE'] != 'InnoDB') {
674 674
         upd_alter_table($table_name, 'ENGINE=InnoDB', true);
675 675
       }
676
-      if($row['TABLE_COLLATION'] != 'utf8_general_ci') {
676
+      if ($row['TABLE_COLLATION'] != 'utf8_general_ci') {
677 677
         upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true);
678 678
       }
679 679
     }
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
       "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0",
694 694
     ), !$update_tables['planets']['PLANET_GOVERNOR_ID']);
695 695
 
696
-    if($update_tables['users']['rpg_geologue']) {
696
+    if ($update_tables['users']['rpg_geologue']) {
697 697
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;");
698 698
 
699 699
       upd_alter_table('users', array(
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
       ), $update_tables['users']['rpg_geologue']);
707 707
     }
708 708
 
709
-    if($update_tables['users']['rpg_bunker']) {
709
+    if ($update_tables['users']['rpg_bunker']) {
710 710
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;");
711 711
 
712 712
       upd_alter_table('users', array(
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
     ), !isset($update_tables['alliance']['total_rank']));
757 757
     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;");
758 758
 
759
-    if(!isset($update_tables['users']['ally_tag'])) {
759
+    if (!isset($update_tables['users']['ally_tag'])) {
760 760
       upd_alter_table('users', array(
761 761
         "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
762 762
       ), !isset($update_tables['users']['ally_tag']));
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
       "ADD COLUMN `player_artifact_list` TEXT",
772 772
     ), !isset($update_tables['users']['player_artifact_list']));
773 773
 
774
-    if(!isset($update_tables['users']['player_rpg_tech_xp'])) {
774
+    if (!isset($update_tables['users']['player_rpg_tech_xp'])) {
775 775
       upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage));
776 776
 
777 777
       upd_alter_table('users', array(
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
       "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
802 802
     ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED');
803 803
 
804
-    if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
804
+    if (strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
805 805
       upd_alter_table('alliance_diplomacy', array(
806 806
         "DROP FOREIGN KEY `FK_diplomacy_ally_id`",
807 807
         "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`"
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
       ), true);
817 817
     }
818 818
 
819
-    if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
819
+    if (strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
820 820
       upd_alter_table('alliance_negotiation', array(
821 821
         "DROP FOREIGN KEY `FK_negotiation_ally_id`",
822 822
         "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`"
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
       ), true);
833 833
     }
834 834
 
835
-    if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') {
835
+    if (strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') {
836 836
       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);
837 837
 
838 838
       upd_alter_table('alliance_requests', array(
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
       ), true);
847 847
     }
848 848
 
849
-    if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
849
+    if (strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
850 850
       upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true);
851 851
 
852 852
       upd_alter_table('annonce', array(
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
       ), true);
860 860
     }
861 861
 
862
-    if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
862
+    if (strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
863 863
       upd_alter_table('bashing', array(
864 864
         "DROP FOREIGN KEY `FK_bashing_user_id`",
865 865
         "DROP FOREIGN KEY `FK_bashing_planet_id`",
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
       ), true);
875 875
     }
876 876
 
877
-    if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
877
+    if (strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
878 878
       upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true);
879 879
 
880 880
       upd_alter_table('buddy', array(
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
       "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'",
913 913
     ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)');
914 914
 
915
-    if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
915
+    if (strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
916 916
       upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true);
917 917
 
918 918
       upd_alter_table('iraks', array(
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
       ), true);
937 937
     }
938 938
 
939
-    if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') {
939
+    if (strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') {
940 940
       upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true);
941 941
 
942 942
       upd_alter_table('notes', array(
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
       "DROP COLUMN `b_hangar_plus`",
1062 1062
     ), isset($update_tables['planets']['b_hangar_plus']));
1063 1063
 
1064
-    if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') {
1064
+    if (strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') {
1065 1065
       upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true);
1066 1066
 
1067 1067
       upd_alter_table('referrals', array(
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
       "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED",
1081 1081
     ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED');
1082 1082
 
1083
-    if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
1083
+    if (strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
1084 1084
       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);
1085 1085
 
1086 1086
       upd_alter_table('shortcut', array(
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
       ), true);
1096 1096
     }
1097 1097
 
1098
-    if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
1098
+    if (strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
1099 1099
       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);
1100 1100
 
1101 1101
       upd_alter_table('statpoints', array(
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
       "DROP COLUMN `settings_allylogo`",
1250 1250
     ), isset($update_tables['users']['settings_allylogo']));
1251 1251
 
1252
-    if(!isset($update_tables['powerup'])) {
1252
+    if (!isset($update_tables['powerup'])) {
1253 1253
       upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};");
1254 1254
 
1255 1255
       upd_create_table('powerup',
@@ -1279,24 +1279,24 @@  discard block
 block discarded – undo
1279 1279
 
1280 1280
       $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;";
1281 1281
       $user_list = upd_do_query("SELECT * FROM {{users}};");
1282
-      while($user_row = db_fetch($user_list)) {
1282
+      while ($user_row = db_fetch($user_list)) {
1283 1283
         $update_query_str = '';
1284
-        foreach(sn_get_groups('mercenaries') as $mercenary_id) {
1284
+        foreach (sn_get_groups('mercenaries') as $mercenary_id) {
1285 1285
           $mercenary_data_name = get_unit_param($mercenary_id, P_NAME);
1286
-          if($mercenary_level = $user_row[$mercenary_data_name]) {
1286
+          if ($mercenary_level = $user_row[$mercenary_data_name]) {
1287 1287
             $update_query_str = ", `{$mercenary_data_name}` = 0";
1288 1288
             upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;");
1289 1289
             upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};");
1290 1290
           }
1291 1291
         }
1292 1292
 
1293
-        if($update_query_str) {
1293
+        if ($update_query_str) {
1294 1294
           upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id']));
1295 1295
         }
1296 1296
       }
1297 1297
     }
1298 1298
 
1299
-    if(!isset($update_tables['universe'])) {
1299
+    if (!isset($update_tables['universe'])) {
1300 1300
       upd_create_table('universe',
1301 1301
         "(
1302 1302
           `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0',
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 
1320 1320
     // ------------------------------------------------------------------------
1321 1321
     // Modifying tables
1322
-    if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') {
1322
+    if (strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') {
1323 1323
       upd_alter_table('users', array(
1324 1324
         "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL",
1325 1325
 
@@ -1340,23 +1340,23 @@  discard block
 block discarded – undo
1340 1340
     // ------------------------------------------------------------------------
1341 1341
     // Creating players for allies
1342 1342
     $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;");
1343
-    while($ally_row = db_fetch($ally_row_list)) {
1343
+    while ($ally_row = db_fetch($ally_row_list)) {
1344 1344
       $ally_user_name = db_escape("[{$ally_row['ally_tag']}]");
1345
-      doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};");
1345
+      doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = ".SN_TIME_NOW.", `user_as_ally` = {$ally_row['id']};");
1346 1346
       $ally_user_id = db_insert_id();
1347 1347
       doquery("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;");
1348 1348
     }
1349 1349
     // Renaming old ally players TODO: Remove on release
1350 1350
     upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.user_as_ally = a.id SET u.username = CONCAT('[', a.ally_tag, ']') WHERE u.user_as_ally IS NOT NULL AND u.username = '';");
1351 1351
     // Setting last online time to old ally players TODO: Remove on release
1352
-    upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;");
1352
+    upd_do_query("UPDATE {{users}} SET `onlinetime` = ".SN_TIME_NOW." WHERE onlinetime = 0;");
1353 1353
 
1354 1354
     // ------------------------------------------------------------------------
1355 1355
     // Creating planets for allies
1356 1356
     $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;");
1357
-    while($ally_user_row = db_fetch($ally_user_list)) {
1357
+    while ($ally_user_row = db_fetch($ally_user_list)) {
1358 1358
       $ally_planet_name = db_escape($ally_user_row['username']);
1359
-      doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};");
1359
+      doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = ".SN_TIME_NOW.", `id_owner` = {$ally_user_row['id']};");
1360 1360
       $ally_planet_id = db_insert_id();
1361 1361
       doquery("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;");
1362 1362
     }
@@ -1385,10 +1385,10 @@  discard block
 block discarded – undo
1385 1385
     // Adding db field
1386 1386
     upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']);
1387 1387
     // Converting old data to new one and dropping old fields
1388
-    if($update_tables['users']['b_tech_planet']) {
1388
+    if ($update_tables['users']['b_tech_planet']) {
1389 1389
       $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;");
1390
-      while($planet_row = db_fetch($query)) {
1391
-        $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH;
1390
+      while ($planet_row = db_fetch($query)) {
1391
+        $que_item_string = "{$planet_row['b_tech_id']},1,".max(0, $planet_row['b_tech'] - SN_TIME_NOW).",".BUILD_CREATE.",".QUE_RESEARCH;
1392 1392
         doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;");
1393 1393
       }
1394 1394
 
@@ -1400,10 +1400,10 @@  discard block
 block discarded – undo
1400 1400
       upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']);
1401 1401
     }
1402 1402
 
1403
-    if(!$update_tables['powerup']['powerup_category']) {
1403
+    if (!$update_tables['powerup']['powerup_category']) {
1404 1404
       upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']);
1405 1405
 
1406
-      doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY);
1406
+      doquery("UPDATE {{powerup}} SET powerup_category = ".BONUS_MERCENARY);
1407 1407
     }
1408 1408
 
1409 1409
     upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info));
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
     upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets));
1422 1422
     upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor));
1423 1423
 
1424
-    if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) {
1424
+    if (!classSupernova::$config->db_loadItem('rpg_flt_explore')) {
1425 1425
       $inflation_rate = 1000;
1426 1426
 
1427 1427
       classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate);
@@ -1438,17 +1438,17 @@  discard block
 block discarded – undo
1438 1438
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};");
1439 1439
 
1440 1440
       $query = doquery("SELECT * FROM {{quest}}");
1441
-      while($row = db_fetch($query)) {
1441
+      while ($row = db_fetch($query)) {
1442 1442
         $query_add = '';
1443 1443
         $quest_reward_list = explode(';', $row['quest_rewards']);
1444
-        foreach($quest_reward_list as &$quest_reward) {
1444
+        foreach ($quest_reward_list as &$quest_reward) {
1445 1445
           list($reward_resource, $reward_amount) = explode(',', $quest_reward);
1446
-          if($reward_resource == RES_DARK_MATTER) {
1447
-            $quest_reward = "{$reward_resource}," . $reward_amount * 1000;
1446
+          if ($reward_resource == RES_DARK_MATTER) {
1447
+            $quest_reward = "{$reward_resource},".$reward_amount * 1000;
1448 1448
           }
1449 1449
         }
1450 1450
         $new_rewards = implode(';', $quest_reward_list);
1451
-        if($new_rewards != $row['quest_rewards']) {
1451
+        if ($new_rewards != $row['quest_rewards']) {
1452 1452
           doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;");
1453 1453
         }
1454 1454
       }
@@ -1478,7 +1478,7 @@  discard block
 block discarded – undo
1478 1478
     upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range));
1479 1479
     upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate));
1480 1480
 
1481
-    if(!isset($update_tables['payment'])) {
1481
+    if (!isset($update_tables['payment'])) {
1482 1482
       upd_alter_table('users', array(
1483 1483
         "ADD KEY `I_user_id_name` (`id`, `username`)",
1484 1484
       ), !$update_indexes['users']['I_user_id_name']);
@@ -1512,15 +1512,15 @@  discard block
 block discarded – undo
1512 1512
     upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price));
1513 1513
 
1514 1514
     // Updating category for Mercenaries
1515
-    upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1515
+    upd_do_query("UPDATE {{powerup}} SET powerup_category = ".UNIT_MERCENARIES." WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1516 1516
 
1517 1517
     // Convert Destructor to Death Star schematic
1518 1518
     upd_do_query("UPDATE {{powerup}}
1519
-      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . "
1519
+      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_DEATH_STAR."
1520 1520
       WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;");
1521 1521
     // Convert Assasin to SuperNova schematic
1522 1522
     upd_do_query("UPDATE {{powerup}}
1523
-      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . "
1523
+      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_SUPERNOVA."
1524 1524
       WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;");
1525 1525
 
1526 1526
     upd_alter_table('iraks', array(
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
     ), !$update_tables['iraks']['fleet_start_type']);
1530 1530
 
1531 1531
 
1532
-    if(!$update_tables['payment']['payment_status']) {
1532
+    if (!$update_tables['payment']['payment_status']) {
1533 1533
       upd_alter_table('payment', array(
1534 1534
         "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`",
1535 1535
 
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
       ), !$update_tables['payment']['payment_status']);
1545 1545
     }
1546 1546
 
1547
-    upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";");
1547
+    upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = ".UNIT_PLANS.";");
1548 1548
 
1549 1549
     upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date));
1550 1550
     upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures));
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
 
1557 1557
     upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium));
1558 1558
 
1559
-    upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = " . MRC_ENGINEER . " AND `PLANET_GOVERNOR_LEVEL` > 8;");
1559
+    upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = ".MRC_ENGINEER." AND `PLANET_GOVERNOR_LEVEL` > 8;");
1560 1560
 
1561 1561
 
1562 1562
     upd_do_query('COMMIT;', true);
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
       "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)",
1614 1614
     ), !$update_indexes['notes']['I_owner_priority_time']);
1615 1615
 
1616
-    if(!$update_tables['buddy']['BUDDY_ID']) {
1616
+    if (!$update_tables['buddy']['BUDDY_ID']) {
1617 1617
       upd_alter_table('buddy', array(
1618 1618
         "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'",
1619 1619
         "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'",
@@ -1634,16 +1634,16 @@  discard block
 block discarded – undo
1634 1634
 
1635 1635
       $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;");
1636 1636
       $found = $lost = array();
1637
-      while($row = db_fetch($query)) {
1638
-        $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1639
-        if(!isset($found[$index])) {
1637
+      while ($row = db_fetch($query)) {
1638
+        $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']).';'.max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1639
+        if (!isset($found[$index])) {
1640 1640
           $found[$index] = $row['BUDDY_ID'];
1641 1641
         } else {
1642 1642
           $lost[] = $row['BUDDY_ID'];
1643 1643
         }
1644 1644
       }
1645 1645
       $lost = implode(',', $lost);
1646
-      if($lost) {
1646
+      if ($lost) {
1647 1647
         upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})");
1648 1648
       }
1649 1649
 
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
 
1665 1665
     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");
1666 1666
 
1667
-    if(!$update_tables['ube_report']) {
1667
+    if (!$update_tables['ube_report']) {
1668 1668
       upd_create_table('ube_report',
1669 1669
         "(
1670 1670
           `ube_report_id` SERIAL COMMENT 'Report ID',
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
       );
1706 1706
     }
1707 1707
 
1708
-    if(!$update_tables['ube_report_player']) {
1708
+    if (!$update_tables['ube_report_player']) {
1709 1709
       upd_create_table('ube_report_player',
1710 1710
         "(
1711 1711
           `ube_report_player_id` SERIAL COMMENT 'Record ID',
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
       );
1727 1727
     }
1728 1728
 
1729
-    if(!$update_tables['ube_report_fleet']) {
1729
+    if (!$update_tables['ube_report_fleet']) {
1730 1730
       upd_create_table('ube_report_fleet',
1731 1731
         "(
1732 1732
           `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID',
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
       );
1757 1757
     }
1758 1758
 
1759
-    if(!$update_tables['ube_report_unit']) {
1759
+    if (!$update_tables['ube_report_unit']) {
1760 1760
       // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках
1761 1761
       // Может сохранять имена удаленных кораблей долго?
1762 1762
 
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
       );
1794 1794
     }
1795 1795
 
1796
-    if(!$update_tables['ube_report_outcome_fleet']) {
1796
+    if (!$update_tables['ube_report_outcome_fleet']) {
1797 1797
       upd_create_table('ube_report_outcome_fleet',
1798 1798
         "(
1799 1799
           `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID',
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
       );
1823 1823
     }
1824 1824
 
1825
-    if(!$update_tables['ube_report_outcome_unit']) {
1825
+    if (!$update_tables['ube_report_outcome_unit']) {
1826 1826
       upd_create_table('ube_report_outcome_unit',
1827 1827
         "(
1828 1828
           `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID',
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
       );
1844 1844
     }
1845 1845
 
1846
-    if(!$update_tables['unit']) {
1846
+    if (!$update_tables['unit']) {
1847 1847
       upd_create_table('unit',
1848 1848
         "(
1849 1849
           `unit_id` SERIAL COMMENT 'Record ID',
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
       );
1863 1863
     }
1864 1864
 
1865
-    if(!$update_tables['captain']) {
1865
+    if (!$update_tables['captain']) {
1866 1866
       upd_create_table('captain',
1867 1867
         "(
1868 1868
           `captain_id` SERIAL COMMENT 'Record ID',
@@ -1882,7 +1882,7 @@  discard block
 block discarded – undo
1882 1882
       );
1883 1883
     }
1884 1884
 
1885
-    if(!$update_tables['fleets']['fleet_start_planet_id']) {
1885
+    if (!$update_tables['fleets']['fleet_start_planet_id']) {
1886 1886
       upd_alter_table('fleets', array(
1887 1887
         "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`",
1888 1888
         "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`",
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 
1905 1905
     upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']);
1906 1906
 
1907
-    if(!$update_tables['chat_player']) {
1907
+    if (!$update_tables['chat_player']) {
1908 1908
       upd_create_table('chat_player',
1909 1909
         "(
1910 1910
           `chat_player_id` SERIAL COMMENT 'Record ID',
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
       "DROP FOREIGN KEY `FK_payment_user`",
1967 1967
     ), $update_foreigns['payment']['FK_payment_user']);
1968 1968
 
1969
-    if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') {
1969
+    if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') {
1970 1970
       upd_alter_table('chat', array(
1971 1971
         "DROP FOREIGN KEY `FK_chat_message_sender_user_id`",
1972 1972
         "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`",
@@ -1999,7 +1999,7 @@  discard block
 block discarded – undo
1999 1999
       "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)",
2000 2000
     ), !$update_indexes['ube_report']['I_ube_report_time_combat']);
2001 2001
 
2002
-    if(!$update_tables['unit']['unit_time_start']) {
2002
+    if (!$update_tables['unit']['unit_time_start']) {
2003 2003
       upd_alter_table('unit', array(
2004 2004
         "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'",
2005 2005
         "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'",
@@ -2009,13 +2009,13 @@  discard block
 block discarded – undo
2009 2009
         "INSERT INTO {{unit}}
2010 2010
           (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish)
2011 2011
         SELECT
2012
-          `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level`
2012
+          `powerup_user_id`, " . LOC_USER.", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level`
2013 2013
           , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL)
2014 2014
         FROM {{powerup}}"
2015 2015
       );
2016 2016
     }
2017 2017
 
2018
-    if(!$update_tables['que']) {
2018
+    if (!$update_tables['que']) {
2019 2019
       upd_create_table('que',
2020 2020
         "(
2021 2021
           `que_id` SERIAL COMMENT 'Internal que id',
@@ -2047,25 +2047,25 @@  discard block
 block discarded – undo
2047 2047
     }
2048 2048
 
2049 2049
     // Конвертирум очередь исследований
2050
-    if($update_tables['users']['que']) {
2050
+    if ($update_tables['users']['que']) {
2051 2051
       $que_lines = array();
2052 2052
       $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`");
2053
-      while($que_row = db_fetch($que_query)) {
2053
+      while ($que_row = db_fetch($que_query)) {
2054 2054
         $que_data = explode(',', $que_row['que']);
2055 2055
 
2056
-        if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) {
2056
+        if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) {
2057 2057
           continue;
2058 2058
         }
2059 2059
 
2060 2060
         $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0;
2061 2061
         // Если планета пустая - ставим главку
2062 2062
         $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet'];
2063
-        if($que_data[QI_PLANET_ID]) {
2063
+        if ($que_data[QI_PLANET_ID]) {
2064 2064
           $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2065
-          if(!$que_planet_check['id']) {
2065
+          if (!$que_planet_check['id']) {
2066 2066
             $que_data[QI_PLANET_ID] = $que_row['id_planet'];
2067 2067
             $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2068
-            if(!$que_planet_check['id']) {
2068
+            if (!$que_planet_check['id']) {
2069 2069
               $que_data[QI_PLANET_ID] = 'NULL';
2070 2070
             }
2071 2071
           }
@@ -2079,20 +2079,20 @@  discard block
 block discarded – undo
2079 2079
         $price_increase = pow($unit_factor, $unit_level);
2080 2080
         $unit_level++;
2081 2081
         $unit_cost = array();
2082
-        foreach($unit_info[P_COST] as $resource_id => $resource_amount) {
2083
-          if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) {
2082
+        foreach ($unit_info[P_COST] as $resource_id => $resource_amount) {
2083
+          if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) {
2084 2084
             continue;
2085 2085
           }
2086
-          $unit_cost[] = $resource_id . ',' . floor($resource_cost);
2086
+          $unit_cost[] = $resource_id.','.floor($resource_cost);
2087 2087
         }
2088 2088
         $unit_cost = implode(';', $unit_cost);
2089 2089
 
2090
-        $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," .
2091
-          BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2090
+        $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]},".QUE_RESEARCH.",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1,".
2091
+          BUILD_CREATE.",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2092 2092
       }
2093 2093
 
2094
-      if(!empty($que_lines)) {
2095
-        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));
2094
+      if (!empty($que_lines)) {
2095
+        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));
2096 2096
       }
2097 2097
 
2098 2098
       upd_alter_table('users', array(
@@ -2105,23 +2105,23 @@  discard block
 block discarded – undo
2105 2105
 
2106 2106
 
2107 2107
     // Ковертируем технологии в таблицы
2108
-    if($update_tables['users']['graviton_tech']) {
2109
-      upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES);
2108
+    if ($update_tables['users']['graviton_tech']) {
2109
+      upd_do_query("DELETE FROM {{unit}} WHERE unit_type = ".UNIT_TECHNOLOGIES);
2110 2110
 
2111 2111
       $que_lines = array();
2112 2112
       $user_query = upd_do_query("SELECT * FROM {{users}}");
2113 2113
       upd_add_more_time(300);
2114 2114
       $sn_group_tech = sn_get_groups('tech');
2115
-      while($user_row = db_fetch($user_query)) {
2116
-        foreach($sn_group_tech as $tech_id) {
2117
-          if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) {
2118
-            $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
2115
+      while ($user_row = db_fetch($user_query)) {
2116
+        foreach ($sn_group_tech as $tech_id) {
2117
+          if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) {
2118
+            $que_lines[] = "({$user_row['id']},".LOC_USER.",{$user_row['id']},".UNIT_TECHNOLOGIES.",{$tech_id},{$tech_level})";
2119 2119
           }
2120 2120
         }
2121 2121
       }
2122 2122
 
2123
-      if(!empty($que_lines)) {
2124
-        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));
2123
+      if (!empty($que_lines)) {
2124
+        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));
2125 2125
       }
2126 2126
 
2127 2127
       upd_alter_table('users', array(
@@ -2129,25 +2129,25 @@  discard block
 block discarded – undo
2129 2129
       ), $update_tables['users']['graviton_tech']);
2130 2130
     }
2131 2131
 
2132
-    if(!$update_indexes['unit']['I_unit_record_search']) {
2132
+    if (!$update_indexes['unit']['I_unit_record_search']) {
2133 2133
       upd_alter_table('unit', array(
2134 2134
         "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)",
2135 2135
       ), !$update_indexes['unit']['I_unit_record_search']);
2136 2136
 
2137
-      foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) {
2137
+      foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) {
2138 2138
         $planet_units[get_unit_param($unit_id, P_NAME)] = 1;
2139 2139
       }
2140 2140
       $drop_index = array();
2141 2141
       $create_index = &$drop_index; // array();
2142
-      foreach($planet_units as $unit_name => $unit_create) {
2143
-        if($update_indexes['planets']['I_' . $unit_name]) {
2142
+      foreach ($planet_units as $unit_name => $unit_create) {
2143
+        if ($update_indexes['planets']['I_'.$unit_name]) {
2144 2144
           $drop_index[] = "DROP KEY I_{$unit_name}";
2145 2145
         }
2146
-        if($update_indexes['planets']['i_' . $unit_name]) {
2146
+        if ($update_indexes['planets']['i_'.$unit_name]) {
2147 2147
           $drop_index[] = "DROP KEY i_{$unit_name}";
2148 2148
         }
2149 2149
 
2150
-        if($unit_create) {
2150
+        if ($unit_create) {
2151 2151
           $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)";
2152 2152
         }
2153 2153
       }
@@ -2158,7 +2158,7 @@  discard block
 block discarded – undo
2158 2158
       "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`",
2159 2159
     ), !$update_tables['users']['user_time_utc_offset']);
2160 2160
 
2161
-    if(!$update_foreigns['alliance']['FK_alliance_owner']) {
2161
+    if (!$update_foreigns['alliance']['FK_alliance_owner']) {
2162 2162
       upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})");
2163 2163
 
2164 2164
       upd_alter_table('alliance', array(
@@ -2178,7 +2178,7 @@  discard block
 block discarded – undo
2178 2178
 
2179 2179
     upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer);
2180 2180
 
2181
-    if(!$update_tables['player_name_history']) {
2181
+    if (!$update_tables['player_name_history']) {
2182 2182
       upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost);
2183 2183
       upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY);
2184 2184
 
@@ -2204,10 +2204,10 @@  discard block
 block discarded – undo
2204 2204
 
2205 2205
     upd_alter_table('planets', array(
2206 2206
       "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'",
2207
-      "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'",
2207
+      "ADD `density_index` TINYINT NOT NULL DEFAULT ".PLANET_DENSITY_STANDARD." COMMENT 'Planet cached density index'",
2208 2208
     ), !$update_tables['planets']['density_index']);
2209 2209
 
2210
-    if($update_tables['users']['player_artifact_list']) {
2210
+    if ($update_tables['users']['player_artifact_list']) {
2211 2211
       upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']);
2212 2212
 
2213 2213
       upd_alter_table('unit', "ADD KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`)", !$update_indexes['unit']['I_unit_player_location_snid']);
@@ -2217,14 +2217,14 @@  discard block
 block discarded – undo
2217 2217
       $db_changeset = array();
2218 2218
 
2219 2219
       $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE");
2220
-      while($row = db_fetch($query)) {
2220
+      while ($row = db_fetch($query)) {
2221 2221
         $artifact_list = explode(';', $row['player_artifact_list']);
2222
-        if(!$row['player_artifact_list'] || empty($artifact_list)) {
2222
+        if (!$row['player_artifact_list'] || empty($artifact_list)) {
2223 2223
           continue;
2224 2224
         }
2225
-        foreach($artifact_list as $key => &$value) {
2225
+        foreach ($artifact_list as $key => &$value) {
2226 2226
           $value = explode(',', $value);
2227
-          if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) {
2227
+          if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) {
2228 2228
             unset($artifact_list[$key]);
2229 2229
             continue;
2230 2230
           }
Please login to merge, or discard this patch.
includes/general_pname.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 function pname_factory_production_field_name($factory_unit_id)
6 6
 {
7
-  return get_unit_param($factory_unit_id, P_NAME) . '_porcent';
7
+  return get_unit_param($factory_unit_id, P_NAME).'_porcent';
8 8
 }
9 9
 
10 10
 /**
Please login to merge, or discard this patch.
includes/includes/flt_mission_explore.php 1 patch
Spacing   +34 added lines, -35 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 function flt_mission_explore(&$mission_data) {
21 21
   static $ship_data, $rates;
22 22
 
23
-  if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) {
23
+  if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) {
24 24
     return CACHE_NONE;
25 25
   }
26 26
 
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
   $outcome_value = &$result['$outcome_value'];
46 46
   $outcome_list = &$result['$outcome_list'];
47 47
 
48
-  if(!$ship_data) {
49
-    foreach(sn_get_groups('fleet') as $unit_id) {
48
+  if (!$ship_data) {
49
+    foreach (sn_get_groups('fleet') as $unit_id) {
50 50
       $unit_info = get_unit_param($unit_id);
51
-      if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
51
+      if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
52 52
         continue;
53 53
       }
54 54
       $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
   $max_metal_cost = 0;
60 60
   $fleet_real_array = $objFleet->shipsGetArray();
61
-  foreach($fleet_real_array as $ship_id => $ship_amount) {
61
+  foreach ($fleet_real_array as $ship_id => $ship_amount) {
62 62
     $ship_cost_in_metal = $ship_amount * $ship_data[$ship_id][P_COST_METAL];
63 63
     $result['$fleet_metal_points'] += $ship_amount * $ship_data[$ship_id][P_COST_METAL];
64 64
     // Рассчитываем стоимость самого дорого корабля в металле
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
   $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7));
73 73
 
74 74
   $chance_max = 0;
75
-  foreach($outcome_list as $key => &$value) {
76
-    if(!$value['chance']) {
75
+  foreach ($outcome_list as $key => &$value) {
76
+    if (!$value['chance']) {
77 77
       unset($outcome_list[$key]);
78 78
       continue;
79 79
     }
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
   }
82 82
   $outcome_value = mt_rand(0, $chance_max);
83 83
   $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE];
84
-  foreach($outcome_list as $key => &$value) {
85
-    if(!$value['chance']) {
84
+  foreach ($outcome_list as $key => &$value) {
85
+    if (!$value['chance']) {
86 86
       continue;
87 87
     }
88 88
     $mission_outcome = $key;
89 89
     $outcome_description = $value;
90
-    if($outcome_value <= $outcome_description['value']) {
90
+    if ($outcome_value <= $outcome_description['value']) {
91 91
       break;
92 92
     }
93 93
   }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 //  $outcome_mission_sub = -1;
105 105
 
106 106
   $fleet_found = array();
107
-  switch($mission_outcome) {
107
+  switch ($mission_outcome) {
108 108
     case FLT_EXPEDITION_OUTCOME_LOST_FLEET:
109 109
       $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000);
110 110
     break;
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 
126 126
       // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля
127 127
       $can_be_found = array();
128
-      foreach($ship_data as $ship_id => $ship_info) {
129
-        if($ship_info['metal_cost'] < $max_metal_cost) {
128
+      foreach ($ship_data as $ship_id => $ship_info) {
129
+        if ($ship_info['metal_cost'] < $max_metal_cost) {
130 130
           $can_be_found[$ship_id] = $ship_info['metal_cost'];
131 131
         }
132 132
       }
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
       unset($can_be_found[SHIP_COLONIZER]);
135 135
       unset($can_be_found[SHIP_SPY]);
136 136
 
137
-      while(count($can_be_found) && $found_in_metal >= max($can_be_found)) {
137
+      while (count($can_be_found) && $found_in_metal >= max($can_be_found)) {
138 138
         $found_index = mt_rand(1, count($can_be_found)) - 1;
139 139
         $found_ship = array_slice($can_be_found, $found_index, 1, true);
140 140
         $found_ship_cost = reset($found_ship);
141 141
         $found_ship_id = key($found_ship);
142 142
 
143
-        if($found_ship_cost > $found_in_metal) {
143
+        if ($found_ship_cost > $found_in_metal) {
144 144
           unset($can_be_found[$found_ship_id]);
145 145
         } else {
146 146
           $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost));
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
         }
150 150
       }
151 151
 
152
-      if(empty($fleet_found)) {
152
+      if (empty($fleet_found)) {
153 153
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
154 154
       } else {
155
-        foreach($fleet_found as $unit_id => $unit_amount) {
155
+        foreach ($fleet_found as $unit_id => $unit_amount) {
156 156
           $objFleet->shipAdjustCount($unit_id, $unit_amount);
157 157
         }
158 158
       }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
       $objFleet->resourcesAdjust($resources_found);
178 178
 
179
-      if(array_sum($resources_found) == 0) {
179
+      if (array_sum($resources_found) == 0) {
180 180
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
181 181
       }
182 182
     break;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
       // Рассчитываем количество найденной ТМ
188 188
       $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000);
189 189
 
190
-      if(!$found_dark_matter) {
190
+      if (!$found_dark_matter) {
191 191
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
192 192
       }
193 193
     break;
@@ -201,46 +201,45 @@  discard block
 block discarded – undo
201 201
 
202 202
   mission_expedition_result_adjust($result, $objFleet);
203 203
 
204
-  if($found_dark_matter) {
204
+  if ($found_dark_matter) {
205 205
     rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus');
206 206
     $msg_text_addon = sprintf(classLocale::$lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter);
207 207
   }
208 208
 
209
-  if(!empty($fleet_lost)) {
209
+  if (!empty($fleet_lost)) {
210 210
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['lost_fleet'];
211
-    foreach($fleet_lost as $ship_id => $ship_amount) {
212
-      $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
211
+    foreach ($fleet_lost as $ship_id => $ship_amount) {
212
+      $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n";
213 213
     }
214 214
   }
215 215
 
216
-  if(!empty($fleet_found)) {
216
+  if (!empty($fleet_found)) {
217 217
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_fleet'];
218
-    foreach($fleet_found as $ship_id => $ship_amount) {
219
-      $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
218
+    foreach ($fleet_found as $ship_id => $ship_amount) {
219
+      $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n";
220 220
     }
221 221
   }
222 222
 
223
-  if(!empty($resources_found) && array_sum($resources_found) > 0) {
223
+  if (!empty($resources_found) && array_sum($resources_found) > 0) {
224 224
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_resources'];
225
-    foreach($resources_found as $resource_id => $resource_amount) {
226
-      $msg_text_addon .= classLocale::$lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n";
225
+    foreach ($resources_found as $resource_id => $resource_amount) {
226
+      $msg_text_addon .= classLocale::$lang['tech'][$resource_id].' - '.$resource_amount."\r\n";
227 227
     }
228 228
   }
229 229
 
230
-  if(!$msg_text) {
230
+  if (!$msg_text) {
231 231
     $messages = &classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages'];
232
-    if($outcome_mission_sub >= 0 && is_array($messages)) {
232
+    if ($outcome_mission_sub >= 0 && is_array($messages)) {
233 233
       $messages = &$messages[$outcome_mission_sub];
234 234
     }
235 235
 
236
-    $msg_text = is_string($messages) ? $messages :
237
-      (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
236
+    $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
238 237
   }
239 238
 
240 239
   $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type();
241 240
 
242
-  $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)) .
243
-    ($msg_text_addon ? "\r\n" . $msg_text_addon : '');
241
+  $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)).
242
+    ($msg_text_addon ? "\r\n".$msg_text_addon : '');
244 243
 
245 244
   msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_mission_job_complete, MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text);
246 245
 
Please login to merge, or discard this patch.
includes/includes/flt_mission_spy.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  */
12 12
 // ----------------------------------------------------------------------------------------------------------------
13 13
 function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) {
14
-  foreach($unit_group as $unit_id) {
15
-    if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
14
+  foreach ($unit_group as $unit_id) {
15
+    if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
16 16
       $compress_data[$unit_id] = $unit_count;
17 17
     }
18 18
   }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
   $classLocale = classLocale::$lang;
23 23
 
24 24
   $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>";
25
-  foreach(sn_get_groups($group_name) as $unit_id) {
26
-    if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
25
+  foreach (sn_get_groups($group_name) as $unit_id) {
26
+    if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
27 27
       $result .= "<tr><td align=\"left\" colspan=\"3\">{$classLocale['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>";
28 28
     }
29 29
 
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 
56 56
   $objFleet = $mission_data->fleet;
57 57
 
58
-  if(empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) {
58
+  if (empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) {
59 59
     $objFleet->markReturnedAndSave();
60 60
 
61 61
     return $result;
62 62
   }
63 63
 
64 64
   $spy_probes = $objFleet->shipsGetTotalById(SHIP_SPY);
65
-  if($spy_probes > 0) {
65
+  if ($spy_probes > 0) {
66 66
     $TargetSpyLvl = GetSpyLevel($target_user_row);
67 67
     $CurrentSpyLvl = GetSpyLevel($spying_user_row);
68 68
     $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl;
@@ -80,26 +80,26 @@  discard block
 block discarded – undo
80 80
     $spy_message .= " ({$classLocale['Player_']} '{$target_user_row['username']}') {$classLocale['On_']} ";
81 81
     $spy_message .= date(FMT_DATE_TIME, $objFleet->time_arrive_to_target);
82 82
     $spy_message .= "</td></tr><tr>";
83
-    $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>";
84
-    $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>";
83
+    $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>".pretty_number($target_planet_row['metal'])."</td>";
84
+    $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>".pretty_number($target_planet_row['crystal'])."</td>";
85 85
     $spy_message .= "</tr><tr>";
86
-    $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>";
87
-    $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>";
86
+    $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>".pretty_number($target_planet_row['deuterium'])."</td>";
87
+    $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>".pretty_number($target_planet_row['energy_max'])."</td>";
88 88
     $spy_message .= "</tr>";
89
-    if($spy_diff >= 2) {
90
-      $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>";
89
+    if ($spy_diff >= 2) {
90
+      $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row)."</div>";
91 91
       coe_compress_add_units(sn_get_groups('fleet'), $target_planet_row, $combat_pack[0]);
92 92
     }
93
-    if($spy_diff >= 3) {
94
-      $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>";
93
+    if ($spy_diff >= 3) {
94
+      $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row)."</div>";
95 95
       coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]);
96 96
     }
97
-    if($spy_diff >= 5) {
98
-      $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>";
97
+    if ($spy_diff >= 5) {
98
+      $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row)."</div>";
99 99
     }
100 100
 
101
-    if($spy_diff_empire >= 0) {
102
-      $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>";
101
+    if ($spy_diff_empire >= 0) {
102
+      $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row)."</div>";
103 103
       coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row);
104 104
     }
105 105
     // TODO: Наемники, губернаторы, артефакты и прочее имперское
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D');
108 108
 
109 109
     $target_unit_list = 0;
110
-    foreach(sn_get_groups('fleet') as $unit_id) {
110
+    foreach (sn_get_groups('fleet') as $unit_id) {
111 111
       $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true));
112 112
     }
113 113
 
114 114
     $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl);
115 115
 
116
-    if(mt_rand(0, 99) > $spy_detected) {
116
+    if (mt_rand(0, 99) > $spy_detected) {
117 117
       $spy_outcome_str = sprintf(classLocale::$lang['sys_mess_spy_detect_chance'], $spy_detected);
118 118
       $spy_detected = false;
119 119
     } else {
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 
131 131
     msg_send_simple_message($spying_user_row['id'], '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_mess_spy_report'], $spy_message);
132 132
 
133
-    $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3);
134
-    $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row);
133
+    $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} ".uni_render_coordinates_href($spying_planet_row, '', 3);
134
+    $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} ".uni_render_coordinates($target_planet_row);
135 135
 
136
-    if($spy_detected) {
136
+    if ($spy_detected) {
137 137
       $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet'];
138 138
 
139 139
       $spy_cost = get_unit_param(SHIP_SPY, P_COST);
140 140
 
141 141
       db_planet_set_by_id($debris_planet_id,
142
-        "`debris_metal` = `debris_metal` + " . floor($spy_probes * $spy_cost[RES_METAL] * 0.3) . ", `debris_crystal` = `debris_crystal` + " . floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3));
142
+        "`debris_metal` = `debris_metal` + ".floor($spy_probes * $spy_cost[RES_METAL] * 0.3).", `debris_crystal` = `debris_crystal` + ".floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3));
143 143
 
144 144
       $target_message .= "<br />{$classLocale['sys_mess_spy_destroyed_enemy']}";
145 145
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_spy_control'], classLocale::$lang['sys_mess_spy_activity'], $target_message);
151 151
   }
152 152
 
153
-  if($spy_detected) {
153
+  if ($spy_detected) {
154 154
     $objFleet->dbDelete();
155 155
   } else {
156 156
     $objFleet->markReturnedAndSave();
Please login to merge, or discard this patch.
includes/includes/ube_zi_helpers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
   print($round);
28 28
   print('<table border=1>');
29 29
   print('<tr align="left">');
30
-  foreach($header as $key => $value)
30
+  foreach ($header as $key => $value)
31 31
   {
32
-    if(is_array($value))
32
+    if (is_array($value))
33 33
     {
34 34
       continue;
35 35
     }
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
   );
62 62
 
63 63
   print('<tr align="right">');
64
-  foreach($unit_crossfire_result as $key => $value)
64
+  foreach ($unit_crossfire_result as $key => $value)
65 65
   {
66
-    if(is_array($value))
66
+    if (is_array($value))
67 67
     {
68 68
       continue;
69 69
     }
Please login to merge, or discard this patch.
includes/includes/flt_mission_colonize.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
   $TargetAddress = sprintf(classLocale::$lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']);
21 21
 
22 22
   $TheMessage = classLocale::$lang['sys_colo_no_colonizer'];
23
-  if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
23
+  if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
24 24
     $TheMessage = classLocale::$lang['sys_colo_notfree'];
25
-    if(empty($mission_data->dst_planet)) {
25
+    if (empty($mission_data->dst_planet)) {
26 26
       $iPlanetCount = get_player_current_colonies($src_user_row);
27 27
 
28 28
       // Can we colonize more planets?
29 29
       $TheMessage = classLocale::$lang['sys_colo_maxcolo'];
30
-      if($iPlanetCount < get_player_max_colonies($src_user_row)) {
30
+      if ($iPlanetCount < get_player_max_colonies($src_user_row)) {
31 31
         // Yes, we can colonize
32 32
         $TheMessage = classLocale::$lang['sys_colo_badpos'];
33 33
 
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
           $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'],
36 36
           $objFleet->playerOwnerId, "{$classLocale['sys_colo_defaultname']} {$iPlanetCount}", false,
37 37
           array('user_row' => $src_user_row));
38
-        if($NewOwnerPlanet) {
39
-          $TheMessage = classLocale::$lang['sys_colo_arrival'] . $TargetAddress . classLocale::$lang['sys_colo_allisok'];
38
+        if ($NewOwnerPlanet) {
39
+          $TheMessage = classLocale::$lang['sys_colo_arrival'].$TargetAddress.classLocale::$lang['sys_colo_allisok'];
40 40
           msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_colo_mess_from'], classLocale::$lang['sys_colo_mess_report'], $TheMessage);
41 41
 
42 42
           $objFleet->shipAdjustCount(SHIP_COLONIZER, -1);
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -2,28 +2,28 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(SN_IN_FLEET !== true) {
5
+if (SN_IN_FLEET !== true) {
6 6
   classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
7 7
 }
8 8
 
9 9
 $fleetid = sys_get_param_id('fleetid');
10 10
 
11
-if(!is_numeric($fleetid) || empty($fleetid)) {
11
+if (!is_numeric($fleetid) || empty($fleetid)) {
12 12
   header("Location: fleet.php");
13 13
   exit();
14 14
 }
15 15
 
16 16
 $objFleet = new Fleet();
17 17
 $objFleet->dbLoad($fleetid);
18
-if(!$objFleet->dbId) {
18
+if (!$objFleet->dbId) {
19 19
   message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']);
20 20
 }
21 21
 
22
-if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
22
+if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
23 23
   message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']);
24 24
 }
25 25
 
26
-if($objFleet->playerOwnerId != $user['id']) {
26
+if ($objFleet->playerOwnerId != $user['id']) {
27 27
   classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
28 28
   message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']);
29 29
 }
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 
35 35
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
36 36
 
37
-if($userToAdd_unsafe) {
37
+if ($userToAdd_unsafe) {
38 38
   $userToAdd = db_escape($userToAdd_unsafe);
39 39
   $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true);
40 40
   $userToAddID = $userToAddID['id'];
41 41
 
42
-  if($objFleet->target_owner_id == $userToAddID) {
42
+  if ($objFleet->target_owner_id == $userToAddID) {
43 43
     message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']);
44 44
   }
45 45
 
46
-  if($userToAddID) {
47
-    if(!$aks) {
46
+  if ($userToAddID) {
47
+    if (!$aks) {
48 48
       // No AСS exists - making one
49
-      if(!$objFleet->group_id) {
49
+      if (!$objFleet->group_id) {
50 50
         db_acs_insert($fleetid, $user, $objFleet);
51 51
 
52 52
         $aks = db_acs_get_by_fleet($fleetid);
@@ -61,22 +61,22 @@  discard block
 block discarded – undo
61 61
 
62 62
     $isUserExists = false;
63 63
     $invited_ar = explode(",", $aks['eingeladen']);
64
-    foreach($invited_ar as $inv) {
65
-      if($userToAddID == $inv) {
64
+    foreach ($invited_ar as $inv) {
65
+      if ($userToAddID == $inv) {
66 66
         $isUserExists = true;
67 67
       }
68 68
     }
69 69
 
70
-    if(count($invited_ar) >= 5) {
70
+    if (count($invited_ar) >= 5) {
71 71
       message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']);
72 72
     }
73 73
 
74
-    if($isUserExists) {
74
+    if ($isUserExists) {
75 75
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false;
76 76
     } else {
77 77
       $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd);
78 78
       !(db_acs_update($userToAddID, $fleetid)) ? die(sprintf(classLocale::$lang['fl_aks_adding_error'], db_error())) : false;
79
-      $aks['eingeladen'] .= ',' . $userToAddID;
79
+      $aks['eingeladen'] .= ','.$userToAddID;
80 80
     }
81 81
     msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
82 82
       classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username']));
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
   'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS],
94 94
 ));
95 95
 
96
-if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
97
-  foreach($members as $row) {
96
+if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
97
+  foreach ($members as $row) {
98 98
     $template->assign_block_vars('invited', array(
99 99
       'NAME' => $row['username'],
100 100
     ));
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 $fleet_data = tplParseFleetObject($objFleet, $i, $user);
120 120
 
121 121
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
122
-foreach($fleet_data['ships'] as $ship_data) {
122
+foreach ($fleet_data['ships'] as $ship_data) {
123 123
   $template->assign_block_vars('fleets.ships', $ship_data);
124 124
 }
125 125
 
Please login to merge, or discard this patch.