@@ -104,21 +104,21 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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( |
@@ -1,7 +1,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -4,7 +4,7 @@ |
||
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 | /** |
@@ -27,9 +27,9 @@ discard block |
||
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 |
||
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 | } |
@@ -20,14 +20,14 @@ discard block |
||
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 |
||
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); |
@@ -2,28 +2,28 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -39,23 +39,23 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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)); |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
5 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | -$page_title .= ' - ' . classLocale::$lang["eco_mrk_{$submode}"]; |
|
9 | +$page_title .= ' - '.classLocale::$lang["eco_mrk_{$submode}"]; |
|
10 | 10 | |
11 | 11 | $template = gettemplate('market_fleet', true); |
12 | 12 | $template->assign_vars(array( |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | 'rpg_cost' => $rpg_cost, |
15 | 15 | )); |
16 | 16 | |
17 | -if(is_array($shipList)) { |
|
18 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
17 | +if (is_array($shipList)) { |
|
18 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
19 | 19 | $intError = MARKET_NO_DM; |
20 | 20 | } |
21 | 21 | |
@@ -28,34 +28,34 @@ discard block |
||
28 | 28 | // Блокируем запись о запасах кораблей у трейдера |
29 | 29 | db_config_get_stockman_fleet(); |
30 | 30 | |
31 | - $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>'; |
|
31 | + $message .= classLocale::$lang["eco_mrk_{$submode}_ships"].'<ul>'; |
|
32 | 32 | $qry = array(); |
33 | 33 | $total = array(); |
34 | 34 | $db_changeset = array(); |
35 | - foreach($shipList as $shipID => &$shipCount) { |
|
35 | + foreach ($shipList as $shipID => &$shipCount) { |
|
36 | 36 | $shipCount = ceil(floatval($shipCount)); |
37 | - if(!$shipCount) { |
|
37 | + if (!$shipCount) { |
|
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | - if($shipCount < 0) { |
|
41 | + if ($shipCount < 0) { |
|
42 | 42 | classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
43 | 43 | $intError = MARKET_NEGATIVE_SHIPS; |
44 | 44 | break; |
45 | 45 | } |
46 | 46 | |
47 | - if($mode == MARKET_SCRAPPER) { |
|
47 | + if ($mode == MARKET_SCRAPPER) { |
|
48 | 48 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
49 | - } elseif($mode == MARKET_STOCKMAN) { |
|
49 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
50 | 50 | $amount = $stock[$shipID]; |
51 | 51 | } |
52 | 52 | |
53 | - if($amount < $shipCount) { |
|
53 | + if ($amount < $shipCount) { |
|
54 | 54 | $intError = $error_no_stock; |
55 | 55 | break; |
56 | 56 | } |
57 | 57 | |
58 | - if(!in_array($shipID, sn_get_groups('fleet'))) { |
|
58 | + if (!in_array($shipID, sn_get_groups('fleet'))) { |
|
59 | 59 | classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
60 | 60 | $intError = MARKET_NOT_A_SHIP; |
61 | 61 | break; |
@@ -71,16 +71,16 @@ discard block |
||
71 | 71 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
72 | 72 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
73 | 73 | |
74 | - foreach($resTemp as $resID => $resCount) { |
|
74 | + foreach ($resTemp as $resID => $resCount) { |
|
75 | 75 | $total[$resID] += $resCount; |
76 | 76 | } |
77 | 77 | |
78 | - $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount); |
|
78 | + $message .= "<li>{$classLocale['tech'][$shipID]}: ".pretty_number($shipCount); |
|
79 | 79 | } |
80 | 80 | |
81 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
82 | - foreach($total as $resID => $resCount) { |
|
83 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
81 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
82 | + foreach ($total as $resID => $resCount) { |
|
83 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
84 | 84 | $intError = MARKET_NO_RESOURCES; |
85 | 85 | classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
86 | 86 | break; |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | |
91 | 91 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
92 | 92 | |
93 | - if($intError == MARKET_DEAL) { |
|
94 | - $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>'; |
|
95 | - foreach($total as $resID => $resCount) { |
|
96 | - if(!$resCount) { |
|
93 | + if ($intError == MARKET_DEAL) { |
|
94 | + $message .= '</ul>'.classLocale::$lang["eco_mrk_{$submode}_res"].'<ul>'; |
|
95 | + foreach ($total as $resID => $resCount) { |
|
96 | + if (!$resCount) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // $newrow[$resID] = $planetrow[$resID] + $resCount * (-$multiplier); |
102 | 102 | $qry[] = "`{$resource_name}` = `{$resource_name}` + ({$resCount})"; |
103 | 103 | |
104 | - $message .= "<li>" . classLocale::$lang['sys_' . $resource_name] . ": " . pretty_number(abs($resCount)); |
|
104 | + $message .= "<li>".classLocale::$lang['sys_'.$resource_name].": ".pretty_number(abs($resCount)); |
|
105 | 105 | } |
106 | 106 | $message .= "</ul>"; |
107 | 107 | |
@@ -127,38 +127,38 @@ discard block |
||
127 | 127 | 'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError], |
128 | 128 | )); |
129 | 129 | |
130 | - foreach($shipList as $shipID => $shipCount) { |
|
130 | + foreach ($shipList as $shipID => $shipCount) { |
|
131 | 131 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | $message = ''; |
136 | 136 | |
137 | -if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
138 | - classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet')))); |
|
137 | +if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
138 | + classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet')))); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | tpl_set_resource_info($template, $planetrow, array()); |
142 | 142 | |
143 | -if(!$array) { |
|
143 | +if (!$array) { |
|
144 | 144 | $array = array(); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $group_fleet = sn_get_groups('fleet'); |
148 | -foreach($array as $key => $value) { |
|
149 | - if($mode == MARKET_SCRAPPER) { |
|
148 | +foreach ($array as $key => $value) { |
|
149 | + if ($mode == MARKET_SCRAPPER) { |
|
150 | 150 | $shipID = $value; |
151 | 151 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
152 | - } elseif($mode == MARKET_STOCKMAN) { |
|
152 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
153 | 153 | $shipID = $key; |
154 | 154 | $amount = $value; |
155 | 155 | } |
156 | 156 | |
157 | - if(!in_array($shipID, $group_fleet)) { |
|
157 | + if (!in_array($shipID, $group_fleet)) { |
|
158 | 158 | continue; |
159 | 159 | } |
160 | 160 | |
161 | - if($amount > 0) { |
|
161 | + if ($amount > 0) { |
|
162 | 162 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
163 | 163 | $template->assign_block_vars('ships', array( |
164 | 164 | 'ID' => $shipID, |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | $destination_planet = &$mission_data->dst_planet; |
16 | 16 | |
17 | - if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
17 | + if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
18 | 18 | $objFleet->markReturnedAndSave(); |
19 | 19 | |
20 | 20 | return CACHE_FLEET; |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | $fleet_resources[RES_METAL], classLocale::$lang['Metal'], |
28 | 28 | $fleet_resources[RES_CRYSTAL], classLocale::$lang['Crystal'], |
29 | 29 | $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium'] |
30 | - ) . '<br />' . classLocale::$lang['sys_relocate_mess_user']; |
|
30 | + ).'<br />'.classLocale::$lang['sys_relocate_mess_user']; |
|
31 | 31 | $fleet_real_array = $objFleet->shipsGetArray(); |
32 | - foreach($fleet_real_array as $ship_id => $ship_count) { |
|
33 | - $Message .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; |
|
32 | + foreach ($fleet_real_array as $ship_id => $ship_count) { |
|
33 | + $Message .= classLocale::$lang['tech'][$ship_id].' - '.$ship_count.'<br />'; |
|
34 | 34 | } |
35 | 35 | msg_send_simple_message( |
36 | 36 | $objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, |