Completed
Push — work-fleets ( 98be23...4e14e1 )
by SuperNova.WS
05:25
created
includes/db/db_helpers.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 block discarded – undo
27 27
  */
28 28
 function db_set_make_safe_string($set, $delta = false) {
29 29
   $set_safe = array();
30
-  foreach($set as $field => $value) {
31
-    if(empty($field)) {
30
+  foreach ($set as $field => $value) {
31
+    if (empty($field)) {
32 32
       continue;
33 33
     }
34 34
 
35
-    $field = '`' . db_escape($field) . '`';
35
+    $field = '`'.db_escape($field).'`';
36 36
     $new_value = $value;
37
-    if($value === null) {
37
+    if ($value === null) {
38 38
       $new_value = 'NULL';
39
-    } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) {
39
+    } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) {
40 40
       // non-float
41
-      $new_value = '"' . db_escape($value) . '"';
42
-    } elseif($delta) {
41
+      $new_value = '"'.db_escape($value).'"';
42
+    } elseif ($delta) {
43 43
       // float and DELTA-set
44 44
       $new_value = "{$field} + ({$new_value})";
45 45
     }
Please login to merge, or discard this patch.
includes/init_secondary.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
6
-  include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX);
5
+if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
6
+  include(SN_ROOT_PHYSICAL.'ajax_version_check'.DOT_PHP_EX);
7 7
 }
8 8
 
9
-if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
10
-  require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX);
9
+if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
10
+  require_once(SN_ROOT_PHYSICAL."includes/includes/user_birthday_celebrate".DOT_PHP_EX);
11 11
   sn_user_birthday_celebrate();
12 12
 }
13 13
 
14
-if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
14
+if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
15 15
   classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true));
16 16
   classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW);
17
-  if(classSupernova::$config->server_log_online) {
17
+  if (classSupernova::$config->server_log_online) {
18 18
     db_log_online_insert();
19 19
   }
20 20
 }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
42 42
 //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die();
43 43
 
44
-if(!empty($user['id'])) {
44
+if (!empty($user['id'])) {
45 45
   classSupernova::$user_options->user_change($user['id']);
46 46
 }
47 47
 
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
     : false
55 55
   );
56 56
 
57
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
58
-  $prohibited_characters = array_map(function ($value) {
59
-    return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
57
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
58
+  $prohibited_characters = array_map(function($value) {
59
+    return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'";
60 60
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
61 61
   $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters);
62 62
 }
63 63
 
64 64
 
65
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
65
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
66 66
   pdump("Отключи отладку перед продакшном!");
67 67
 }
68 68
 
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
   ? define('INSTALL_MODE', GAME_DISABLE_INSTALL)
77 77
   : false;
78 78
 
79
-if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
79
+if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
80 80
   $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse(
81 81
     classSupernova::$config->game_disable == GAME_DISABLE_REASON
82 82
       ? classSupernova::$config->game_disable_reason
83 83
       : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable]
84 84
   );
85
-  if(defined('IN_API')) {
85
+  if (defined('IN_API')) {
86 86
     return;
87 87
   }
88 88
 
89
-  if(
89
+  if (
90 90
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
91 91
     &&
92 92
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 
101 101
 // TODO ban
102 102
 // TODO $skip_ban_check
103
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
-  if(defined('IN_API')) {
103
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
+  if (defined('IN_API')) {
105 105
     return;
106 106
   }
107 107
 
@@ -119,15 +119,15 @@  discard block
 block discarded – undo
119 119
 // pdump($allow_anonymous, '$allow_anonymous');
120 120
 // pdump($sys_user_logged_in, '$sys_user_logged_in');
121 121
 
122
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
123
-  sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
124
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
122
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
123
+  sys_redirect(SN_ROOT_VIRTUAL.'overview.php');
124
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
125 125
 //  pdump($sn_page_name);
126 126
 //  pdump(INITIAL_PAGE);
127 127
 //  die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}');
128
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
128
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
129 129
   // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
130
-  sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
130
+  sys_redirect(SN_ROOT_VIRTUAL.'login.php');
131 131
 }
132 132
 
133 133
 $user_time_diff = playerTimeDiff::user_time_diff_get();
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
 
147 147
 global $skip_fleet_update;
148 148
 $skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN');
149
-if(
149
+if (
150 150
   !$skip_fleet_update
151 151
   && !(defined('IN_AJAX') && IN_AJAX === true)
152 152
   && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval
153 153
 ) {
154
-  require_once(SN_ROOT_PHYSICAL . "includes/includes/flt_flying_fleet_handler2" . DOT_PHP_EX);
154
+  require_once(SN_ROOT_PHYSICAL."includes/includes/flt_flying_fleet_handler2".DOT_PHP_EX);
155 155
   flt_flying_fleet_handler($skip_fleet_update);
156 156
 }
157 157
 
158
-if(!defined('IN_AJAX')) {
158
+if (!defined('IN_AJAX')) {
159 159
   print("Scheduled processes is disabled<br />");
160 160
 }
161 161
 // scheduler_process();
Please login to merge, or discard this patch.
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/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/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.
includes/includes/sys_stat.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
 
40 40
   $sta_update_msg = db_escape($sta_update_msg);
41 41
 
42
-  if($next_step) {
42
+  if ($next_step) {
43 43
     $sta_update_step++;
44 44
   }
45 45
   $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}.";
46 46
 
47 47
   classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg);
48
-  if($next_step) {
48
+  if ($next_step) {
49 49
     classSupernova::$debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS);
50 50
   }
51 51
 }
52 52
 
53 53
 function sys_stat_calculate_flush(&$data, $force = false) {
54
-  if(count($data) < 25 && !$force) {
54
+  if (count($data) < 25 && !$force) {
55 55
     return;
56 56
   }
57 57
 
58
-  if(!empty($data)) {
58
+  if (!empty($data)) {
59 59
     doquery('REPLACE INTO {{statpoints}}
60 60
       (`id_owner`, `id_ally`, `stat_type`, `stat_code`, `tech_points`, `tech_count`, `build_points`, `build_count`,
61 61
        `defs_points`, `defs_count`, `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`,
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
   $user_list = db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id');
96 96
   $row_num = count($user_list);
97 97
   // while($player = db_fetch($query))
98
-  foreach($user_list as $player) {
99
-    if($i++ % 100 == 0) {
98
+  foreach ($user_list as $player) {
99
+    if ($i++ % 100 == 0) {
100 100
       sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false);
101 101
     }
102
-    if(array_key_exists($user_id = $player['id'], $user_skip_list)) {
102
+    if (array_key_exists($user_id = $player['id'], $user_skip_list)) {
103 103
       continue;
104 104
     }
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     // $points[$user_id][UNIT_RESOURCES] += $resources;
110 110
 
111 111
     // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что
112
-    if(!isset($user_skip_list[$user_id])) {
112
+    if (!isset($user_skip_list[$user_id])) {
113 113
       $user_allies[$user_id] = $player['ally_id'];
114 114
     }
115 115
   }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
   $i = 0;
124 124
   $query = db_planet_list_resources_by_owner();
125 125
   $row_num = db_num_rows($query);
126
-  while($planet = db_fetch($query)) {
127
-    if($i++ % 100 == 0) {
126
+  while ($planet = db_fetch($query)) {
127
+    if ($i++ % 100 == 0) {
128 128
       sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false);
129 129
     }
130
-    if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
130
+    if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
131 131
       continue;
132 132
     }
133 133
 
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
   $i = 0;
143 143
   $query = FleetList::dbQueryAllId();
144 144
   $row_num = db_num_rows($query);
145
-  while($fleet_row = db_fetch($query)) {
146
-    if($i++ % 100 == 0) {
145
+  while ($fleet_row = db_fetch($query)) {
146
+    if ($i++ % 100 == 0) {
147 147
       sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false);
148 148
     }
149 149
     $objFleet = new Fleet();
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
     // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными
152 152
     // $objFleet->_reset();
153 153
     $objFleet->dbRowParse($fleet_row);
154
-    if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
154
+    if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
155 155
       continue;
156 156
     }
157 157
 
158 158
     $fleet = $objFleet->shipsGetArray();
159
-    foreach($fleet as $unit_id => $unit_amount) {
159
+    foreach ($fleet as $unit_id => $unit_amount) {
160 160
       $counts[$user_id][UNIT_SHIPS] += $unit_amount;
161 161
 
162
-      if(!isset($unit_cost_cache[$unit_id][0])) {
162
+      if (!isset($unit_cost_cache[$unit_id][0])) {
163 163
         $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST);
164 164
       }
165 165
       $unit_cost_data = &$unit_cost_cache[$unit_id][0];
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
   $i = 0;
180 180
   $query = db_unit_list_stat_calculate();
181 181
   $row_num = db_num_rows($query);
182
-  while($unit = db_fetch($query)) {
183
-    if($i++ % 100 == 0) {
182
+  while ($unit = db_fetch($query)) {
183
+    if ($i++ % 100 == 0) {
184 184
       sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false);
185 185
     }
186
-    if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
186
+    if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
187 187
       continue;
188 188
     }
189 189
 
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
   $i = 0;
198 198
   $query = db_que_list_stat();
199 199
   $row_num = db_num_rows($query);
200
-  while($que_item = db_fetch($query)) {
201
-    if($i++ % 100 == 0) {
200
+  while ($que_item = db_fetch($query)) {
201
+    if ($i++ % 100 == 0) {
202 202
       sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false);
203 203
     }
204
-    if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
204
+    if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
205 205
       continue;
206 206
     }
207 207
     $que_unit_amount = $que_item['que_unit_amount'];
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 
221 221
   sta_set_time_limit('posting new user stats to DB');
222 222
   $data = array();
223
-  foreach($user_allies as $user_id => $ally_id) {
223
+  foreach ($user_allies as $user_id => $ally_id) {
224 224
     // $counts[UNIT_RESOURCES] дублирует $points[UNIT_RESOURCES], поэтому $points не заполняем, а берем $counts и делим на 1000
225 225
     $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000;
226 226
     $points[$user_id] = array_map('floor', $points[$user_id]);
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
     $user_points = array_sum($points[$user_id]);
233 233
     $user_counts = array_sum($counts[$user_id]);
234 234
 
235
-    $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}'," .
236
-      "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}'," .
237
-      "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}'," .
238
-      "{$user_points},{$user_counts}," . SN_TIME_NOW . ")";
235
+    $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}',".
236
+      "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}',".
237
+      "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}',".
238
+      "{$user_points},{$user_counts},".SN_TIME_NOW.")";
239 239
 
240 240
     sys_stat_calculate_flush($data);
241 241
   }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         SUM(u.`tech_points`)+aus.`tech_points`, SUM(u.`tech_count`)+aus.`tech_count`, SUM(u.`build_points`)+aus.`build_points`, SUM(u.`build_count`)+aus.`build_count`,
256 256
         SUM(u.`defs_points`)+aus.`defs_points`, SUM(u.`defs_count`)+aus.`defs_count`, SUM(u.`fleet_points`)+aus.`fleet_points`, SUM(u.`fleet_count`)+aus.`fleet_count`,
257 257
         SUM(u.`res_points`)+aus.`res_points`, SUM(u.`res_count`)+aus.`res_count`, SUM(u.`total_points`)+aus.`total_points`, SUM(u.`total_count`)+aus.`total_count`,
258
-        " . SN_TIME_NOW . ", NULL, u.`id_ally`, 2, 1,
258
+        " . SN_TIME_NOW.", NULL, u.`id_ally`, 2, 1,
259 259
         a.tech_rank, a.build_rank, a.defs_rank, a.fleet_rank, a.res_rank, a.total_rank
260 260
       FROM {{statpoints}} AS u
261 261
         JOIN {{alliance}} AS al ON al.id = u.id_ally
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
   // Updating player's ranks
278 278
   sta_set_time_limit("updating ranks for players");
279
-  foreach($rankNames as $rankName) {
279
+  foreach ($rankNames as $rankName) {
280 280
     sta_set_time_limit("updating player rank '{$rankName}'", false);
281 281
     doquery($qryResetRowNum);
282 282
     doquery(sprintf($qryFormat, $rankName, 1));
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
   sta_set_time_limit("updating ranks for Alliances");
286 286
   // --- Updating Allie's ranks
287
-  foreach($rankNames as $rankName) {
287
+  foreach ($rankNames as $rankName) {
288 288
     sta_set_time_limit("updating Alliances rank '{$rankName}'", false);
289 289
     doquery($qryResetRowNum);
290 290
     doquery(sprintf($qryFormat, $rankName, 2));
Please login to merge, or discard this patch.