@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use \Core\SnBootstrap; |
| 4 | 4 | |
| 5 | 5 | // Защита от двойного инита |
| 6 | -if(defined('INIT')) { |
|
| 6 | +if (defined('INIT')) { |
|
| 7 | 7 | return; |
| 8 | 8 | } |
| 9 | 9 | |
@@ -116,18 +116,18 @@ discard block |
||
| 116 | 116 | // Но нужно, пока у нас есть не MVC-страницы |
| 117 | 117 | $sn_page_data = $sn_mvc['pages'][$sn_page_name]; |
| 118 | 118 | $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
| 119 | -if($sn_page_name) { |
|
| 119 | +if ($sn_page_name) { |
|
| 120 | 120 | // Merging page options to global option pull |
| 121 | - if(is_array($sn_page_data['options'])) { |
|
| 121 | + if (is_array($sn_page_data['options'])) { |
|
| 122 | 122 | classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if(isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
| 125 | + if (isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
| 126 | 126 | require_once($sn_page_name_file); |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -if((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) { |
|
| 130 | +if ((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) { |
|
| 131 | 131 | classSupernova::$options['fleet_update_skip'] = true; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | $load_order = array(); |
| 142 | 142 | $sn_req = array(); |
| 143 | 143 | |
| 144 | -foreach($sn_module as $loaded_module_name => $module_data) { |
|
| 144 | +foreach ($sn_module as $loaded_module_name => $module_data) { |
|
| 145 | 145 | $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000; |
| 146 | - if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
| 147 | - foreach($module_data->manifest['require'] as $require_name) { |
|
| 146 | + if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
| 147 | + foreach ($module_data->manifest['require'] as $require_name) { |
|
| 148 | 148 | $sn_req[$loaded_module_name][$require_name] = 0; |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | do { |
| 156 | 156 | $prev_order = $load_order; |
| 157 | 157 | |
| 158 | - foreach($sn_req as $loaded_module_name => &$req_data) { |
|
| 158 | + foreach ($sn_req as $loaded_module_name => &$req_data) { |
|
| 159 | 159 | $level = 1; |
| 160 | - foreach($req_data as $req_name => &$req_level) { |
|
| 161 | - if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
| 160 | + foreach ($req_data as $req_name => &$req_level) { |
|
| 161 | + if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
| 162 | 162 | $level = $req_level = -1; |
| 163 | 163 | break; |
| 164 | 164 | } else { |
@@ -166,21 +166,21 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | $req_level = $load_order[$req_name]; |
| 168 | 168 | } |
| 169 | - if($level > $load_order[$loaded_module_name] || $level == -1) { |
|
| 169 | + if ($level > $load_order[$loaded_module_name] || $level == -1) { |
|
| 170 | 170 | $load_order[$loaded_module_name] = $level; |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | -while($prev_order != $load_order); |
|
| 174 | +while ($prev_order != $load_order); |
|
| 175 | 175 | |
| 176 | 176 | asort($load_order); |
| 177 | 177 | |
| 178 | 178 | // Инициализируем модули |
| 179 | 179 | // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти |
| 180 | -foreach($load_order as $loaded_module_name => $load_order_order) { |
|
| 181 | - if($load_order_order >= 0) { |
|
| 180 | +foreach ($load_order as $loaded_module_name => $load_order_order) { |
|
| 181 | + if ($load_order_order >= 0) { |
|
| 182 | 182 | $sn_module[$loaded_module_name]->check_status(); |
| 183 | - if(!$sn_module[$loaded_module_name]->manifest['active']) { |
|
| 183 | + if (!$sn_module[$loaded_module_name]->manifest['active']) { |
|
| 184 | 184 | unset($sn_module[$loaded_module_name]); |
| 185 | 185 | continue; |
| 186 | 186 | } |
@@ -198,29 +198,29 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
| 200 | 200 | // TODO - костыль, что бы работали старые модули. Убрать! |
| 201 | -if(is_array($sn_data['pages'])) { |
|
| 201 | +if (is_array($sn_data['pages'])) { |
|
| 202 | 202 | $sn_mvc['pages'] = array_merge($sn_mvc['pages'], $sn_data['pages']); |
| 203 | 203 | } |
| 204 | -if(!isset($sn_mvc['pages'][$sn_page_name])) { |
|
| 204 | +if (!isset($sn_mvc['pages'][$sn_page_name])) { |
|
| 205 | 205 | $sn_page_name = ''; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | $lang->lng_switch(sys_get_param_str('lang')); |
| 209 | 209 | |
| 210 | 210 | |
| 211 | -if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
| 211 | +if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
| 212 | 212 | \Tools\VersionCheckerDeprecated::performCheckVersion(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | -if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
| 215 | +if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
| 216 | 216 | require_once(SN_ROOT_PHYSICAL . 'includes/includes/user_birthday_celebrate.php'); |
| 217 | 217 | sn_user_birthday_celebrate(); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | -if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
| 220 | +if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
| 221 | 221 | classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true)); |
| 222 | 222 | classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW); |
| 223 | - if(classSupernova::$config->server_log_online) { |
|
| 223 | + if (classSupernova::$config->server_log_online) { |
|
| 224 | 224 | doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . classSupernova::$config->var_online_user_count . ";"); |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id']; |
| 245 | 245 | |
| 246 | -if(!empty($user['id'])) { |
|
| 246 | +if (!empty($user['id'])) { |
|
| 247 | 247 | classSupernova::$user_options->user_change($user['id']); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | : false |
| 257 | 257 | ); |
| 258 | 258 | |
| 259 | -if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 259 | +if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 260 | 260 | $prohibited_characters = array_map(function($value) { |
| 261 | 261 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
| 262 | 262 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
| 267 | -if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
| 267 | +if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
| 268 | 268 | pdump('Отключи отладку перед продакшном!'); |
| 269 | 269 | } |
| 270 | 270 | |
@@ -278,17 +278,17 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | StatUpdateLauncher::unlock(); |
| 280 | 280 | |
| 281 | -if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
| 281 | +if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
| 282 | 282 | $template_result[F_GAME_DISABLE_REASON] = HelperString::nl2br( |
| 283 | 283 | classSupernova::$config->game_disable == GAME_DISABLE_REASON |
| 284 | 284 | ? classSupernova::$config->game_disable_reason |
| 285 | 285 | : $lang['sys_game_disable_reason'][classSupernova::$config->game_disable] |
| 286 | 286 | ); |
| 287 | - if(defined('IN_API')) { |
|
| 287 | + if (defined('IN_API')) { |
|
| 288 | 288 | return; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if( |
|
| 291 | + if ( |
|
| 292 | 292 | ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN)) |
| 293 | 293 | && |
| 294 | 294 | !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT')) |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | // TODO ban |
| 303 | 303 | // TODO $skip_ban_check |
| 304 | -if($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
| 305 | - if(defined('IN_API')) { |
|
| 304 | +if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
| 305 | + if (defined('IN_API')) { |
|
| 306 | 306 | return; |
| 307 | 307 | } |
| 308 | 308 | |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | $allow_anonymous = $allow_anonymous || (isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous']); |
| 317 | 317 | |
| 318 | 318 | |
| 319 | -if($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
| 319 | +if ($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
| 320 | 320 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
| 321 | -} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
| 322 | -} elseif(!$allow_anonymous && !$sys_user_logged_in) { |
|
| 321 | +} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
| 322 | +} elseif (!$allow_anonymous && !$sys_user_logged_in) { |
|
| 323 | 323 | sys_redirect(SN_ROOT_VIRTUAL . 'login.php'); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | 'fleet_update_last', |
| 344 | 344 | classSupernova::$config->fleet_update_interval, |
| 345 | 345 | // Promise |
| 346 | - function () {classSupernova::$gc->fleetDispatcher->dispatch();}, |
|
| 346 | + function() {classSupernova::$gc->fleetDispatcher->dispatch(); }, |
|
| 347 | 347 | WATCHDOG_TIME_SQL, |
| 348 | 348 | false |
| 349 | 349 | ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | if (!defined('IN_PHPBB')) |
| 18 | 18 | { |
| 19 | - exit; |
|
| 19 | + exit; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -24,227 +24,227 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | class phpbb_hook |
| 26 | 26 | { |
| 27 | - /** |
|
| 28 | - * Registered hooks |
|
| 29 | - */ |
|
| 30 | - var $hooks = array(); |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Results returned by functions called |
|
| 34 | - */ |
|
| 35 | - var $hook_result = array(); |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * internal pointer |
|
| 39 | - */ |
|
| 40 | - var $current_hook = NULL; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Initialize hook class. |
|
| 44 | - * |
|
| 45 | - * @param array $valid_hooks array containing the hookable functions/methods |
|
| 46 | - */ |
|
| 47 | - function phpbb_hook($valid_hooks) |
|
| 48 | - { |
|
| 49 | - foreach ($valid_hooks as $_null => $method) |
|
| 50 | - { |
|
| 51 | - $this->add_hook($method); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if (function_exists('phpbb_hook_register')) |
|
| 55 | - { |
|
| 56 | - phpbb_hook_register($this); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Register function/method to be called within hook |
|
| 62 | - * This function is normally called by the modification/application to attach/register the functions. |
|
| 63 | - * |
|
| 64 | - * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 65 | - * @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition |
|
| 66 | - * @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain. |
|
| 67 | - */ |
|
| 68 | - function register($definition, $hook, $mode = 'normal') |
|
| 69 | - { |
|
| 70 | - $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 71 | - $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 72 | - |
|
| 73 | - // Method able to be hooked? |
|
| 74 | - if (isset($this->hooks[$class][$function])) |
|
| 75 | - { |
|
| 76 | - switch ($mode) |
|
| 77 | - { |
|
| 78 | - case 'standalone': |
|
| 79 | - if (!isset($this->hooks[$class][$function]['standalone'])) |
|
| 80 | - { |
|
| 81 | - $this->hooks[$class][$function] = array('standalone' => $hook); |
|
| 82 | - } |
|
| 83 | - else |
|
| 84 | - { |
|
| 85 | - trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE); |
|
| 86 | - } |
|
| 87 | - break; |
|
| 88 | - |
|
| 89 | - case 'first': |
|
| 90 | - case 'last': |
|
| 91 | - $this->hooks[$class][$function][$mode][] = $hook; |
|
| 92 | - break; |
|
| 93 | - |
|
| 94 | - case 'normal': |
|
| 95 | - default: |
|
| 96 | - $this->hooks[$class][$function]['normal'][] = $hook; |
|
| 97 | - break; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Calling all functions/methods attached to a specified hook. |
|
| 104 | - * Called by the function allowing hooks... |
|
| 105 | - * |
|
| 106 | - * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 107 | - * @return bool False if no hook got executed, true otherwise |
|
| 108 | - */ |
|
| 109 | - function call_hook($definition) |
|
| 110 | - { |
|
| 111 | - $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 112 | - $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 113 | - |
|
| 114 | - if (!empty($this->hooks[$class][$function])) |
|
| 115 | - { |
|
| 116 | - // Developer tries to call a hooked function within the hooked function... |
|
| 117 | - if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function) |
|
| 118 | - { |
|
| 119 | - return false; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // Call the hook with the arguments attached and store result |
|
| 123 | - $arguments = func_get_args(); |
|
| 124 | - $this->current_hook = array('class' => $class, 'function' => $function); |
|
| 125 | - $arguments[0] = &$this; |
|
| 126 | - |
|
| 127 | - // Call the hook chain... |
|
| 128 | - if (isset($this->hooks[$class][$function]['standalone'])) |
|
| 129 | - { |
|
| 130 | - $this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments); |
|
| 131 | - } |
|
| 132 | - else |
|
| 133 | - { |
|
| 134 | - foreach (array('first', 'normal', 'last') as $mode) |
|
| 135 | - { |
|
| 136 | - if (!isset($this->hooks[$class][$function][$mode])) |
|
| 137 | - { |
|
| 138 | - continue; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - foreach ($this->hooks[$class][$function][$mode] as $hook) |
|
| 142 | - { |
|
| 143 | - $this->hook_result[$class][$function] = call_user_func_array($hook, $arguments); |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - $this->current_hook = NULL; |
|
| 149 | - return true; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - $this->current_hook = NULL; |
|
| 153 | - return false; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Get result from previously called functions/methods for the same hook |
|
| 158 | - * |
|
| 159 | - * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 160 | - * @return mixed False if nothing returned if there is no result, else array('result' => ... ) |
|
| 161 | - */ |
|
| 162 | - function previous_hook_result($definition) |
|
| 163 | - { |
|
| 164 | - $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 165 | - $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 166 | - |
|
| 167 | - if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function])) |
|
| 168 | - { |
|
| 169 | - return array('result' => $this->hook_result[$class][$function]); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - return false; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Check if the called functions/methods returned something. |
|
| 177 | - * |
|
| 178 | - * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 179 | - * @return bool True if results are there, false if not |
|
| 180 | - */ |
|
| 181 | - function hook_return($definition) |
|
| 182 | - { |
|
| 183 | - $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 184 | - $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 185 | - |
|
| 186 | - if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function])) |
|
| 187 | - { |
|
| 188 | - return true; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - return false; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Give actual result from called functions/methods back. |
|
| 196 | - * |
|
| 197 | - * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 198 | - * @return mixed The result |
|
| 199 | - */ |
|
| 200 | - function hook_return_result($definition) |
|
| 201 | - { |
|
| 202 | - $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 203 | - $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 204 | - |
|
| 205 | - if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function])) |
|
| 206 | - { |
|
| 207 | - $result = $this->hook_result[$class][$function]; |
|
| 208 | - unset($this->hook_result[$class][$function]); |
|
| 209 | - return $result; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - return; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Add new function to the allowed hooks. |
|
| 217 | - * |
|
| 218 | - * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 219 | - */ |
|
| 220 | - function add_hook($definition) |
|
| 221 | - { |
|
| 222 | - if (!is_array($definition)) |
|
| 223 | - { |
|
| 224 | - $definition = array('__global', $definition); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $this->hooks[$definition[0]][$definition[1]] = array(); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Remove function from the allowed hooks. |
|
| 232 | - * |
|
| 233 | - * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 234 | - */ |
|
| 235 | - function remove_hook($definition) |
|
| 236 | - { |
|
| 237 | - $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 238 | - $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 239 | - |
|
| 240 | - if (isset($this->hooks[$class][$function])) |
|
| 241 | - { |
|
| 242 | - unset($this->hooks[$class][$function]); |
|
| 243 | - |
|
| 244 | - if (isset($this->hook_result[$class][$function])) |
|
| 245 | - { |
|
| 246 | - unset($this->hook_result[$class][$function]); |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } |
|
| 27 | + /** |
|
| 28 | + * Registered hooks |
|
| 29 | + */ |
|
| 30 | + var $hooks = array(); |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Results returned by functions called |
|
| 34 | + */ |
|
| 35 | + var $hook_result = array(); |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * internal pointer |
|
| 39 | + */ |
|
| 40 | + var $current_hook = NULL; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Initialize hook class. |
|
| 44 | + * |
|
| 45 | + * @param array $valid_hooks array containing the hookable functions/methods |
|
| 46 | + */ |
|
| 47 | + function phpbb_hook($valid_hooks) |
|
| 48 | + { |
|
| 49 | + foreach ($valid_hooks as $_null => $method) |
|
| 50 | + { |
|
| 51 | + $this->add_hook($method); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if (function_exists('phpbb_hook_register')) |
|
| 55 | + { |
|
| 56 | + phpbb_hook_register($this); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Register function/method to be called within hook |
|
| 62 | + * This function is normally called by the modification/application to attach/register the functions. |
|
| 63 | + * |
|
| 64 | + * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 65 | + * @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition |
|
| 66 | + * @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain. |
|
| 67 | + */ |
|
| 68 | + function register($definition, $hook, $mode = 'normal') |
|
| 69 | + { |
|
| 70 | + $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 71 | + $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 72 | + |
|
| 73 | + // Method able to be hooked? |
|
| 74 | + if (isset($this->hooks[$class][$function])) |
|
| 75 | + { |
|
| 76 | + switch ($mode) |
|
| 77 | + { |
|
| 78 | + case 'standalone': |
|
| 79 | + if (!isset($this->hooks[$class][$function]['standalone'])) |
|
| 80 | + { |
|
| 81 | + $this->hooks[$class][$function] = array('standalone' => $hook); |
|
| 82 | + } |
|
| 83 | + else |
|
| 84 | + { |
|
| 85 | + trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE); |
|
| 86 | + } |
|
| 87 | + break; |
|
| 88 | + |
|
| 89 | + case 'first': |
|
| 90 | + case 'last': |
|
| 91 | + $this->hooks[$class][$function][$mode][] = $hook; |
|
| 92 | + break; |
|
| 93 | + |
|
| 94 | + case 'normal': |
|
| 95 | + default: |
|
| 96 | + $this->hooks[$class][$function]['normal'][] = $hook; |
|
| 97 | + break; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Calling all functions/methods attached to a specified hook. |
|
| 104 | + * Called by the function allowing hooks... |
|
| 105 | + * |
|
| 106 | + * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 107 | + * @return bool False if no hook got executed, true otherwise |
|
| 108 | + */ |
|
| 109 | + function call_hook($definition) |
|
| 110 | + { |
|
| 111 | + $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 112 | + $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 113 | + |
|
| 114 | + if (!empty($this->hooks[$class][$function])) |
|
| 115 | + { |
|
| 116 | + // Developer tries to call a hooked function within the hooked function... |
|
| 117 | + if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function) |
|
| 118 | + { |
|
| 119 | + return false; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // Call the hook with the arguments attached and store result |
|
| 123 | + $arguments = func_get_args(); |
|
| 124 | + $this->current_hook = array('class' => $class, 'function' => $function); |
|
| 125 | + $arguments[0] = &$this; |
|
| 126 | + |
|
| 127 | + // Call the hook chain... |
|
| 128 | + if (isset($this->hooks[$class][$function]['standalone'])) |
|
| 129 | + { |
|
| 130 | + $this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments); |
|
| 131 | + } |
|
| 132 | + else |
|
| 133 | + { |
|
| 134 | + foreach (array('first', 'normal', 'last') as $mode) |
|
| 135 | + { |
|
| 136 | + if (!isset($this->hooks[$class][$function][$mode])) |
|
| 137 | + { |
|
| 138 | + continue; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + foreach ($this->hooks[$class][$function][$mode] as $hook) |
|
| 142 | + { |
|
| 143 | + $this->hook_result[$class][$function] = call_user_func_array($hook, $arguments); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + $this->current_hook = NULL; |
|
| 149 | + return true; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + $this->current_hook = NULL; |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Get result from previously called functions/methods for the same hook |
|
| 158 | + * |
|
| 159 | + * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 160 | + * @return mixed False if nothing returned if there is no result, else array('result' => ... ) |
|
| 161 | + */ |
|
| 162 | + function previous_hook_result($definition) |
|
| 163 | + { |
|
| 164 | + $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 165 | + $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 166 | + |
|
| 167 | + if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function])) |
|
| 168 | + { |
|
| 169 | + return array('result' => $this->hook_result[$class][$function]); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + return false; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Check if the called functions/methods returned something. |
|
| 177 | + * |
|
| 178 | + * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 179 | + * @return bool True if results are there, false if not |
|
| 180 | + */ |
|
| 181 | + function hook_return($definition) |
|
| 182 | + { |
|
| 183 | + $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 184 | + $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 185 | + |
|
| 186 | + if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function])) |
|
| 187 | + { |
|
| 188 | + return true; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + return false; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Give actual result from called functions/methods back. |
|
| 196 | + * |
|
| 197 | + * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 198 | + * @return mixed The result |
|
| 199 | + */ |
|
| 200 | + function hook_return_result($definition) |
|
| 201 | + { |
|
| 202 | + $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 203 | + $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 204 | + |
|
| 205 | + if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function])) |
|
| 206 | + { |
|
| 207 | + $result = $this->hook_result[$class][$function]; |
|
| 208 | + unset($this->hook_result[$class][$function]); |
|
| 209 | + return $result; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + return; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Add new function to the allowed hooks. |
|
| 217 | + * |
|
| 218 | + * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 219 | + */ |
|
| 220 | + function add_hook($definition) |
|
| 221 | + { |
|
| 222 | + if (!is_array($definition)) |
|
| 223 | + { |
|
| 224 | + $definition = array('__global', $definition); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $this->hooks[$definition[0]][$definition[1]] = array(); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Remove function from the allowed hooks. |
|
| 232 | + * |
|
| 233 | + * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
|
| 234 | + */ |
|
| 235 | + function remove_hook($definition) |
|
| 236 | + { |
|
| 237 | + $class = (!is_array($definition)) ? '__global' : $definition[0]; |
|
| 238 | + $function = (!is_array($definition)) ? $definition : $definition[1]; |
|
| 239 | + |
|
| 240 | + if (isset($this->hooks[$class][$function])) |
|
| 241 | + { |
|
| 242 | + unset($this->hooks[$class][$function]); |
|
| 243 | + |
|
| 244 | + if (isset($this->hook_result[$class][$function])) |
|
| 245 | + { |
|
| 246 | + unset($this->hook_result[$class][$function]); |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | 250 | } |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * phpBB Hook Class |
| 24 | 24 | */ |
| 25 | -class phpbb_hook |
|
| 26 | -{ |
|
| 25 | +class phpbb_hook { |
|
| 27 | 26 | /** |
| 28 | 27 | * Registered hooks |
| 29 | 28 | */ |
@@ -44,8 +43,7 @@ discard block |
||
| 44 | 43 | * |
| 45 | 44 | * @param array $valid_hooks array containing the hookable functions/methods |
| 46 | 45 | */ |
| 47 | - function phpbb_hook($valid_hooks) |
|
| 48 | - { |
|
| 46 | + function phpbb_hook($valid_hooks) { |
|
| 49 | 47 | foreach ($valid_hooks as $_null => $method) |
| 50 | 48 | { |
| 51 | 49 | $this->add_hook($method); |
@@ -65,8 +63,7 @@ discard block |
||
| 65 | 63 | * @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition |
| 66 | 64 | * @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain. |
| 67 | 65 | */ |
| 68 | - function register($definition, $hook, $mode = 'normal') |
|
| 69 | - { |
|
| 66 | + function register($definition, $hook, $mode = 'normal') { |
|
| 70 | 67 | $class = (!is_array($definition)) ? '__global' : $definition[0]; |
| 71 | 68 | $function = (!is_array($definition)) ? $definition : $definition[1]; |
| 72 | 69 | |
@@ -79,8 +76,7 @@ discard block |
||
| 79 | 76 | if (!isset($this->hooks[$class][$function]['standalone'])) |
| 80 | 77 | { |
| 81 | 78 | $this->hooks[$class][$function] = array('standalone' => $hook); |
| 82 | - } |
|
| 83 | - else |
|
| 79 | + } else |
|
| 84 | 80 | { |
| 85 | 81 | trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE); |
| 86 | 82 | } |
@@ -106,8 +102,7 @@ discard block |
||
| 106 | 102 | * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
| 107 | 103 | * @return bool False if no hook got executed, true otherwise |
| 108 | 104 | */ |
| 109 | - function call_hook($definition) |
|
| 110 | - { |
|
| 105 | + function call_hook($definition) { |
|
| 111 | 106 | $class = (!is_array($definition)) ? '__global' : $definition[0]; |
| 112 | 107 | $function = (!is_array($definition)) ? $definition : $definition[1]; |
| 113 | 108 | |
@@ -128,8 +123,7 @@ discard block |
||
| 128 | 123 | if (isset($this->hooks[$class][$function]['standalone'])) |
| 129 | 124 | { |
| 130 | 125 | $this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments); |
| 131 | - } |
|
| 132 | - else |
|
| 126 | + } else |
|
| 133 | 127 | { |
| 134 | 128 | foreach (array('first', 'normal', 'last') as $mode) |
| 135 | 129 | { |
@@ -159,8 +153,7 @@ discard block |
||
| 159 | 153 | * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
| 160 | 154 | * @return mixed False if nothing returned if there is no result, else array('result' => ... ) |
| 161 | 155 | */ |
| 162 | - function previous_hook_result($definition) |
|
| 163 | - { |
|
| 156 | + function previous_hook_result($definition) { |
|
| 164 | 157 | $class = (!is_array($definition)) ? '__global' : $definition[0]; |
| 165 | 158 | $function = (!is_array($definition)) ? $definition : $definition[1]; |
| 166 | 159 | |
@@ -178,8 +171,7 @@ discard block |
||
| 178 | 171 | * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
| 179 | 172 | * @return bool True if results are there, false if not |
| 180 | 173 | */ |
| 181 | - function hook_return($definition) |
|
| 182 | - { |
|
| 174 | + function hook_return($definition) { |
|
| 183 | 175 | $class = (!is_array($definition)) ? '__global' : $definition[0]; |
| 184 | 176 | $function = (!is_array($definition)) ? $definition : $definition[1]; |
| 185 | 177 | |
@@ -197,8 +189,7 @@ discard block |
||
| 197 | 189 | * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
| 198 | 190 | * @return mixed The result |
| 199 | 191 | */ |
| 200 | - function hook_return_result($definition) |
|
| 201 | - { |
|
| 192 | + function hook_return_result($definition) { |
|
| 202 | 193 | $class = (!is_array($definition)) ? '__global' : $definition[0]; |
| 203 | 194 | $function = (!is_array($definition)) ? $definition : $definition[1]; |
| 204 | 195 | |
@@ -217,8 +208,7 @@ discard block |
||
| 217 | 208 | * |
| 218 | 209 | * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
| 219 | 210 | */ |
| 220 | - function add_hook($definition) |
|
| 221 | - { |
|
| 211 | + function add_hook($definition) { |
|
| 222 | 212 | if (!is_array($definition)) |
| 223 | 213 | { |
| 224 | 214 | $definition = array('__global', $definition); |
@@ -232,8 +222,7 @@ discard block |
||
| 232 | 222 | * |
| 233 | 223 | * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__) |
| 234 | 224 | */ |
| 235 | - function remove_hook($definition) |
|
| 236 | - { |
|
| 225 | + function remove_hook($definition) { |
|
| 237 | 226 | $class = (!is_array($definition)) ? '__global' : $definition[0]; |
| 238 | 227 | $function = (!is_array($definition)) ? $definition : $definition[1]; |
| 239 | 228 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * internal pointer |
| 39 | 39 | */ |
| 40 | - var $current_hook = NULL; |
|
| 40 | + var $current_hook = null; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Initialize hook class. |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | if (!empty($this->hooks[$class][$function])) |
| 115 | 115 | { |
| 116 | 116 | // Developer tries to call a hooked function within the hooked function... |
| 117 | - if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function) |
|
| 117 | + if ($this->current_hook !== null && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function) |
|
| 118 | 118 | { |
| 119 | 119 | return false; |
| 120 | 120 | } |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $this->current_hook = NULL; |
|
| 148 | + $this->current_hook = null; |
|
| 149 | 149 | return true; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $this->current_hook = NULL; |
|
| 152 | + $this->current_hook = null; |
|
| 153 | 153 | return false; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | $constants = get_defined_constants(true); |
| 17 | 17 | $rpgConstants = array(); |
| 18 | -foreach($constants['user'] as $constantName => $constantValue) { |
|
| 19 | - if(substr($constantName, 0, 4) == 'RPG_') { |
|
| 18 | +foreach ($constants['user'] as $constantName => $constantValue) { |
|
| 19 | + if (substr($constantName, 0, 4) == 'RPG_') { |
|
| 20 | 20 | $rpgConstants[$constantValue] = $constantName; |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | GROUP BY log_dark_matter_reason, IF(sign((log_dark_matter_amount)) > 0, 1, -1) ORDER BY sum(log_dark_matter_amount) DESC; |
| 34 | 34 | "); |
| 35 | 35 | |
| 36 | -while($row = classSupernova::$db->db_fetch($result)) { |
|
| 36 | +while ($row = classSupernova::$db->db_fetch($result)) { |
|
| 37 | 37 | $row['CONSTANT'] = $rpgConstants[$row['REASON']]; |
| 38 | 38 | |
| 39 | 39 | $row['DM_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['DM_AMOUNT']); |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | GROUP BY reason, if(sign((amount)) > 0, 1, -1) ORDER BY sum(amount) DESC; |
| 56 | 56 | "); |
| 57 | 57 | |
| 58 | -while($row = classSupernova::$db->db_fetch($result)) { |
|
| 59 | - if(empty($spent[$row['BALANCE']])) { |
|
| 58 | +while ($row = classSupernova::$db->db_fetch($result)) { |
|
| 59 | + if (empty($spent[$row['BALANCE']])) { |
|
| 60 | 60 | $spent[$row['BALANCE']] = array(); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -66,16 +66,15 @@ discard block |
||
| 66 | 66 | $spent[$row['BALANCE']] = array_merge_recursive_numeric($spent[$row['BALANCE']], $row); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | -foreach($spent as &$row) { |
|
| 69 | +foreach ($spent as &$row) { |
|
| 70 | 70 | @$row['TOTAL_COUNT'] = $row['MM_COUNT'] + $row['DM_COUNT']; |
| 71 | 71 | @$row['TOTAL_AMOUNT'] = $row['MM_AMOUNT'] + $row['DM_AMOUNT']; |
| 72 | 72 | @$row['TOTAL_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_AMOUNT']); |
| 73 | 73 | @$row['TOTAL_COUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_COUNT']); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -usort($spent, function ($a, $b) { |
|
| 77 | - return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : |
|
| 78 | - ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0); |
|
| 76 | +usort($spent, function($a, $b) { |
|
| 77 | + return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0); |
|
| 79 | 78 | }); |
| 80 | 79 | |
| 81 | 80 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));} |
|
| 3 | +function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) {return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list)); } |
|
| 4 | 4 | function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) |
| 5 | 5 | { |
| 6 | 6 | global $lang; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | return $mode; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -function admin_planet_edit_template(&$template, $edit_planet_row, $mode){return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode));} |
|
| 22 | +function admin_planet_edit_template(&$template, $edit_planet_row, $mode) {return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode)); } |
|
| 23 | 23 | /** |
| 24 | 24 | * @param template $template |
| 25 | 25 | * @param $edit_planet_row |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | global $lang; |
| 31 | 31 | |
| 32 | 32 | $unit_list = sn_get_groups($mode); |
| 33 | - if(empty($unit_list)) |
|
| 33 | + if (empty($unit_list)) |
|
| 34 | 34 | { |
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | $name_list = $lang['tech']; |
| 38 | 38 | |
| 39 | - foreach($unit_list as $unit_id) |
|
| 39 | + foreach ($unit_list as $unit_id) |
|
| 40 | 40 | { |
| 41 | 41 | $template->assign_block_vars('unit', array( |
| 42 | 42 | 'ID' => $unit_id, |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | -function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));} |
|
| 50 | +function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode)); } |
|
| 51 | 51 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) |
| 52 | 52 | { |
| 53 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
| 53 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
| 54 | 54 | { |
| 55 | 55 | $unit_amount = round($unit_amount); |
| 56 | 56 | $unit_name = get_unit_param($unit_id, P_NAME); |
@@ -1,8 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));} |
| 4 | -function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) |
|
| 5 | -{ |
|
| 4 | +function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) { |
|
| 6 | 5 | global $lang; |
| 7 | 6 | |
| 8 | 7 | $admin_planet_edit_mode_list = array_merge(isset($admin_planet_edit_mode_list) ? $admin_planet_edit_mode_list : array(), array( |
@@ -25,8 +24,7 @@ discard block |
||
| 25 | 24 | * @param $edit_planet_row |
| 26 | 25 | * @param $mode |
| 27 | 26 | */ |
| 28 | -function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) |
|
| 29 | -{ |
|
| 27 | +function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) { |
|
| 30 | 28 | global $lang; |
| 31 | 29 | |
| 32 | 30 | $unit_list = sn_get_groups($mode); |
@@ -48,15 +46,13 @@ discard block |
||
| 48 | 46 | } |
| 49 | 47 | |
| 50 | 48 | function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));} |
| 51 | -function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) |
|
| 52 | -{ |
|
| 49 | +function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { |
|
| 53 | 50 | if($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
| 54 | 51 | { |
| 55 | 52 | $unit_amount = round($unit_amount); |
| 56 | 53 | $unit_name = get_unit_param($unit_id, P_NAME); |
| 57 | 54 | $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))"; |
| 58 | - } |
|
| 59 | - else |
|
| 55 | + } else |
|
| 60 | 56 | { |
| 61 | 57 | $result = ''; |
| 62 | 58 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | { |
| 5 | 5 | global $lang; |
| 6 | 6 | |
| 7 | - if(!in_array($unit_id, sn_get_groups('artifacts'))) |
|
| 7 | + if (!in_array($unit_id, sn_get_groups('artifacts'))) |
|
| 8 | 8 | { |
| 9 | 9 | return; |
| 10 | 10 | } |
@@ -13,24 +13,24 @@ discard block |
||
| 13 | 13 | $user = db_user_by_id($user['id'], true); |
| 14 | 14 | |
| 15 | 15 | $unit_level = $artifact_level_old = mrc_get_level($user, array(), $unit_id, true); |
| 16 | - if($unit_level > 0) |
|
| 16 | + if ($unit_level > 0) |
|
| 17 | 17 | { |
| 18 | 18 | $db_changeset = array(); |
| 19 | - switch($unit_id) |
|
| 19 | + switch ($unit_id) |
|
| 20 | 20 | { |
| 21 | 21 | case ART_LHC: |
| 22 | 22 | case ART_HOOK_SMALL: |
| 23 | 23 | case ART_HOOK_MEDIUM: |
| 24 | 24 | case ART_HOOK_LARGE: |
| 25 | 25 | $has_moon = DBStaticPlanet::db_planet_by_parent($planetrow['id'], true, '`id`'); |
| 26 | - if($planetrow['planet_type'] == PT_PLANET && !$has_moon['id']) |
|
| 26 | + if ($planetrow['planet_type'] == PT_PLANET && !$has_moon['id']) |
|
| 27 | 27 | { |
| 28 | 28 | $unit_level--; |
| 29 | 29 | $moon_chance = $unit_id == ART_LHC ? uni_calculate_moon_chance($planetrow['debris_metal'] + $planetrow['debris_crystal']) : ( |
| 30 | 30 | $unit_id == ART_HOOK_MEDIUM ? mt_rand(1100, 8999) : ($unit_id == ART_HOOK_SMALL ? 1100 : 8999) |
| 31 | 31 | ); |
| 32 | 32 | $random = $unit_id == ART_LHC ? mt_rand(1, 100) : $moon_chance; |
| 33 | - if($random <= $moon_chance) |
|
| 33 | + if ($random <= $moon_chance) |
|
| 34 | 34 | { |
| 35 | 35 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moon_chance); |
| 36 | 36 | $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moon_chance)); |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | case ART_RCD_MEDIUM: |
| 52 | 52 | case ART_RCD_LARGE: |
| 53 | 53 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
| 54 | - if($planetrow['planet_type'] != PT_PLANET) |
|
| 54 | + if ($planetrow['planet_type'] != PT_PLANET) |
|
| 55 | 55 | { |
| 56 | 56 | $message = $lang['art_rcd_err_moon']; |
| 57 | 57 | break; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, false); |
| 61 | - if(!empty($que['items'])) |
|
| 61 | + if (!empty($que['items'])) |
|
| 62 | 62 | { |
| 63 | 63 | $message = $lang['art_rcd_err_que']; |
| 64 | 64 | break; |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | $artifact_deploy = get_unit_param($unit_id, P_DEPLOY); |
| 68 | 68 | |
| 69 | 69 | $sectors_used = 0; |
| 70 | - foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
|
| 70 | + foreach ($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
|
| 71 | 71 | { |
| 72 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
| 72 | + if (!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
| 73 | 73 | continue; |
| 74 | 74 | $sectors_used += $levels_deployed; |
| 75 | 75 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if($sectors_used == 0) |
|
| 78 | + if ($sectors_used == 0) |
|
| 79 | 79 | { |
| 80 | 80 | $message = $lang['art_rcd_err_no_sense']; |
| 81 | 81 | break; |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | $que_item = null; |
| 91 | 91 | $que = que_get($user['id'], $planetrow['id'], QUE_RESEARCH, true); |
| 92 | 92 | $current_que = &$que['ques'][QUE_RESEARCH][$user['id']][0]; |
| 93 | - if(!empty($current_que)) |
|
| 93 | + if (!empty($current_que)) |
|
| 94 | 94 | { |
| 95 | 95 | reset($current_que); |
| 96 | 96 | $que_item = &$que['ques'][QUE_RESEARCH][$user['id']][0][key($current_que)]; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if(!empty($que_item) && $que_item['que_time_left'] > 60) |
|
| 99 | + if (!empty($que_item) && $que_item['que_time_left'] > 60) |
|
| 100 | 100 | { |
| 101 | 101 | $unit_level--; |
| 102 | 102 | $old_time = $que_item['que_time_left']; |
@@ -117,13 +117,13 @@ discard block |
||
| 117 | 117 | $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, true); |
| 118 | 118 | $current_que = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']]; |
| 119 | 119 | // $que_item = &$que['que'][QUE_STRUCTURES][0]; |
| 120 | - if(!empty($current_que)) |
|
| 120 | + if (!empty($current_que)) |
|
| 121 | 121 | { |
| 122 | 122 | reset($current_que); |
| 123 | 123 | $que_item = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']][key($current_que)]; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if(isset($que_item) && $que_item['que_time_left'] > 60) |
|
| 126 | + if (isset($que_item) && $que_item['que_time_left'] > 60) |
|
| 127 | 127 | { |
| 128 | 128 | $unit_level--; |
| 129 | 129 | $old_time = $que_item['que_time_left']; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | break; |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | - if($unit_level != $artifact_level_old) |
|
| 144 | + if ($unit_level != $artifact_level_old) |
|
| 145 | 145 | { |
| 146 | 146 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user); |
| 147 | 147 | OldDbChangeSet::db_changeset_apply($db_changeset); |
@@ -1,7 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function art_use(&$user, &$planetrow, $unit_id) |
|
| 4 | -{ |
|
| 3 | +function art_use(&$user, &$planetrow, $unit_id) { |
|
| 5 | 4 | global $lang; |
| 6 | 5 | |
| 7 | 6 | if(!in_array($unit_id, sn_get_groups('artifacts'))) |
@@ -34,14 +33,12 @@ discard block |
||
| 34 | 33 | { |
| 35 | 34 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moon_chance); |
| 36 | 35 | $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moon_chance)); |
| 37 | - } |
|
| 38 | - else |
|
| 36 | + } else |
|
| 39 | 37 | { |
| 40 | 38 | $message = $lang['art_lhc_moon_fail']; |
| 41 | 39 | } |
| 42 | 40 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_ADMIN, $lang['art_lhc_from'], $lang['art_lhc_subj'], $message); |
| 43 | - } |
|
| 44 | - else |
|
| 41 | + } else |
|
| 45 | 42 | { |
| 46 | 43 | $message = $lang['art_moon_exists']; |
| 47 | 44 | } |
@@ -69,8 +66,9 @@ discard block |
||
| 69 | 66 | $sectors_used = 0; |
| 70 | 67 | foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
| 71 | 68 | { |
| 72 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
| 73 | - continue; |
|
| 69 | + if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 74 | 72 | $sectors_used += $levels_deployed; |
| 75 | 73 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']); |
| 76 | 74 | } |
@@ -104,8 +102,7 @@ discard block |
||
| 104 | 102 | DBStaticQue::db_que_set_time_left_by_id($que_item['que_id'], $que_item['que_time_left']); |
| 105 | 103 | $message = sprintf($lang['art_heurestic_chip_ok'], $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], sys_time_human($old_time - $que_item['que_time_left'])); |
| 106 | 104 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_heurestic_chip_subj'], $lang['art_heurestic_chip_subj'], $message); |
| 107 | - } |
|
| 108 | - else |
|
| 105 | + } else |
|
| 109 | 106 | { |
| 110 | 107 | $message = $lang['art_heurestic_chip_no_research']; |
| 111 | 108 | } |
@@ -133,8 +130,7 @@ discard block |
||
| 133 | 130 | $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], $planetrow['name'], uni_render_coordinates($planetrow), sys_time_human($old_time - $que_item['que_time_left']) |
| 134 | 131 | ); |
| 135 | 132 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_nano_builder_subj'], $lang['art_nano_builder_subj'], $message); |
| 136 | - } |
|
| 137 | - else |
|
| 133 | + } else |
|
| 138 | 134 | { |
| 139 | 135 | $message = $lang['art_nano_builder_no_que']; |
| 140 | 136 | } |
@@ -146,8 +142,7 @@ discard block |
||
| 146 | 142 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user); |
| 147 | 143 | OldDbChangeSet::db_changeset_apply($db_changeset); |
| 148 | 144 | } |
| 149 | - } |
|
| 150 | - else |
|
| 145 | + } else |
|
| 151 | 146 | { |
| 152 | 147 | $message = $lang['art_err_no_artifact']; |
| 153 | 148 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
| 3 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
| 4 | 4 | $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | 'rpg_cost' => $rpg_cost, |
| 13 | 13 | )); |
| 14 | 14 | |
| 15 | -if(is_array($shipList)) { |
|
| 16 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
| 15 | +if (is_array($shipList)) { |
|
| 16 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
| 17 | 17 | $intError = MARKET_NO_DM; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -30,30 +30,30 @@ discard block |
||
| 30 | 30 | $qry = array(); |
| 31 | 31 | $total = array(); |
| 32 | 32 | $db_changeset = array(); |
| 33 | - foreach($shipList as $shipID => &$shipCount) { |
|
| 33 | + foreach ($shipList as $shipID => &$shipCount) { |
|
| 34 | 34 | $shipCount = ceil(floatval($shipCount)); |
| 35 | - if(!$shipCount) { |
|
| 35 | + if (!$shipCount) { |
|
| 36 | 36 | continue; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if($shipCount < 0) { |
|
| 39 | + if ($shipCount < 0) { |
|
| 40 | 40 | $debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
| 41 | 41 | $intError = MARKET_NEGATIVE_SHIPS; |
| 42 | 42 | break; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if($mode == MARKET_SCRAPPER) { |
|
| 45 | + if ($mode == MARKET_SCRAPPER) { |
|
| 46 | 46 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
| 47 | - } elseif($mode == MARKET_STOCKMAN) { |
|
| 47 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
| 48 | 48 | $amount = $stock[$shipID]; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if($amount < $shipCount) { |
|
| 51 | + if ($amount < $shipCount) { |
|
| 52 | 52 | $intError = $error_no_stock; |
| 53 | 53 | break; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if(!in_array($shipID, sn_get_groups('fleet'))) { |
|
| 56 | + if (!in_array($shipID, sn_get_groups('fleet'))) { |
|
| 57 | 57 | $debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
| 58 | 58 | $intError = MARKET_NOT_A_SHIP; |
| 59 | 59 | break; |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
| 70 | 70 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
| 71 | 71 | |
| 72 | - foreach($resTemp as $resID => $resCount) { |
|
| 72 | + foreach ($resTemp as $resID => $resCount) { |
|
| 73 | 73 | $total[$resID] += $resCount; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $message .= "<li>{$lang['tech'][$shipID]}: " . HelperString::numberFloorAndFormat($shipCount); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
| 80 | - foreach($total as $resID => $resCount) { |
|
| 81 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
| 79 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
| 80 | + foreach ($total as $resID => $resCount) { |
|
| 81 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
| 82 | 82 | $intError = MARKET_NO_RESOURCES; |
| 83 | 83 | $debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
| 84 | 84 | break; |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
| 90 | 90 | |
| 91 | - if($intError == MARKET_DEAL) { |
|
| 91 | + if ($intError == MARKET_DEAL) { |
|
| 92 | 92 | $message .= '</ul>' . $lang["eco_mrk_{$submode}_res"] . '<ul>'; |
| 93 | - foreach($total as $resID => $resCount) { |
|
| 94 | - if(!$resCount) { |
|
| 93 | + foreach ($total as $resID => $resCount) { |
|
| 94 | + if (!$resCount) { |
|
| 95 | 95 | continue; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -125,38 +125,38 @@ discard block |
||
| 125 | 125 | 'MESSAGE' => $lang['eco_mrk_errors'][$intError], |
| 126 | 126 | )); |
| 127 | 127 | |
| 128 | - foreach($shipList as $shipID => $shipCount) { |
|
| 128 | + foreach ($shipList as $shipID => $shipCount) { |
|
| 129 | 129 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | $message = ''; |
| 134 | 134 | |
| 135 | -if(!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) { |
|
| 136 | - $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet')))); |
|
| 135 | +if (!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) { |
|
| 136 | + $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet')))); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | tpl_set_resource_info($template, $planetrow, array()); |
| 140 | 140 | |
| 141 | -if(!$array) { |
|
| 141 | +if (!$array) { |
|
| 142 | 142 | $array = array(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $group_fleet = sn_get_groups('fleet'); |
| 146 | -foreach($array as $key => $value) { |
|
| 147 | - if($mode == MARKET_SCRAPPER) { |
|
| 146 | +foreach ($array as $key => $value) { |
|
| 147 | + if ($mode == MARKET_SCRAPPER) { |
|
| 148 | 148 | $shipID = $value; |
| 149 | 149 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
| 150 | - } elseif($mode == MARKET_STOCKMAN) { |
|
| 150 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
| 151 | 151 | $shipID = $key; |
| 152 | 152 | $amount = $value; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if(!in_array($shipID, $group_fleet)) { |
|
| 155 | + if (!in_array($shipID, $group_fleet)) { |
|
| 156 | 156 | continue; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if($amount > 0) { |
|
| 159 | + if ($amount > 0) { |
|
| 160 | 160 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
| 161 | 161 | $template->assign_block_vars('ships', array( |
| 162 | 162 | 'ID' => $shipID, |
@@ -3,9 +3,9 @@ discard block |
||
| 3 | 3 | // Compare function to sort fleet in time order |
| 4 | 4 | function tpl_assign_fleet_compare($a, $b) |
| 5 | 5 | { |
| 6 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) |
|
| 6 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) |
|
| 7 | 7 | { |
| 8 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) |
|
| 8 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) |
|
| 9 | 9 | { |
| 10 | 10 | return 0; |
| 11 | 11 | } |
@@ -19,20 +19,20 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') |
| 21 | 21 | { |
| 22 | - if(!$fleets) |
|
| 22 | + if (!$fleets) |
|
| 23 | 23 | { |
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | usort($fleets, 'tpl_assign_fleet_compare'); |
| 28 | 28 | |
| 29 | - foreach($fleets as $fleet_data) |
|
| 29 | + foreach ($fleets as $fleet_data) |
|
| 30 | 30 | { |
| 31 | 31 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
| 32 | 32 | |
| 33 | - if($fleet_data['ships']) |
|
| 33 | + if ($fleet_data['ships']) |
|
| 34 | 34 | { |
| 35 | - foreach($fleet_data['ships'] as $ship_data) |
|
| 35 | + foreach ($fleet_data['ships'] as $ship_data) |
|
| 36 | 36 | { |
| 37 | 37 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
| 38 | 38 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | foreach ($fleet as $ship_id => $ship_amount) |
| 59 | 59 | { |
| 60 | - if(in_array($ship_id, sn_get_groups('fleet'))) |
|
| 60 | + if (in_array($ship_id, sn_get_groups('fleet'))) |
|
| 61 | 61 | { |
| 62 | 62 | $single_ship_data = get_ship_data($ship_id, $user_data); |
| 63 | 63 | $return['ships'][$ship_id] = array( |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @return mixed |
| 83 | 83 | */ |
| 84 | -function tpl_parse_fleet_db($fleet, $index, $user_data = false){return sn_function_call('tpl_parse_fleet_db', array($fleet, $index, $user_data, &$result));} |
|
| 84 | +function tpl_parse_fleet_db($fleet, $index, $user_data = false) {return sn_function_call('tpl_parse_fleet_db', array($fleet, $index, $user_data, &$result)); } |
|
| 85 | 85 | /** |
| 86 | 86 | * @param array $fleet |
| 87 | 87 | * @param int $index |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | function sn_tpl_parse_fleet_db($fleet, $index, $user_data = false, &$result) { |
| 94 | 94 | global $lang, $user; |
| 95 | 95 | |
| 96 | - if(!$user_data) { |
|
| 96 | + if (!$user_data) { |
|
| 97 | 97 | $user_data = $user; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_AKS) { |
|
| 100 | + if ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_AKS) { |
|
| 101 | 101 | $aks = doquery("SELECT * FROM {{aks}} WHERE id={$fleet['fleet_group']} LIMIT 1;", true); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | $ship_list = explode(';', $fleet['fleet_array']); |
| 149 | 149 | |
| 150 | 150 | $ship_id = 0; |
| 151 | - if($spy_level >= 6) { |
|
| 152 | - foreach($ship_list as $ship_record) { |
|
| 153 | - if($ship_record) { |
|
| 151 | + if ($spy_level >= 6) { |
|
| 152 | + foreach ($ship_list as $ship_record) { |
|
| 153 | + if ($ship_record) { |
|
| 154 | 154 | $ship_data = explode(',', $ship_record); |
| 155 | - if($spy_level >= 10) { |
|
| 155 | + if ($spy_level >= 10) { |
|
| 156 | 156 | $single_ship_data = get_ship_data($ship_data[0], $user_data); |
| 157 | 157 | $result['ships'][$ship_data[0]] = array( |
| 158 | 158 | 'ID' => $ship_data[0], |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | $hangar_que = array(); |
| 188 | 188 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
| 189 | - if(!empty($que_hangar)) |
|
| 189 | + if (!empty($que_hangar)) |
|
| 190 | 190 | { |
| 191 | - foreach($que_hangar as $que_item) |
|
| 191 | + foreach ($que_hangar as $que_item) |
|
| 192 | 192 | { |
| 193 | 193 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
| 194 | 194 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | $fleets[$planet['id']] = tpl_parse_fleet_sn($fleet_list['own']['total'], $result['PLANET_FLEET_ID']); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) |
|
| 258 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) |
|
| 259 | 259 | { |
| 260 | 260 | $result['building_que'] = array(); |
| 261 | 261 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
| 262 | - foreach($building_que as $que_element) |
|
| 262 | + foreach ($building_que as $que_element) |
|
| 263 | 263 | { |
| 264 | 264 | $result['building_que'][] = que_tpl_parse_element($que_element); |
| 265 | 265 | } |
@@ -270,23 +270,23 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | function flt_get_fleets_to_planet($planet, $fleet_db_list = 0) |
| 272 | 272 | { |
| 273 | - if(!($planet && $planet['id']) && !$fleet_db_list) |
|
| 273 | + if (!($planet && $planet['id']) && !$fleet_db_list) |
|
| 274 | 274 | { |
| 275 | 275 | return $planet; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | global $user; |
| 279 | 279 | |
| 280 | - if($fleet_db_list === 0) |
|
| 280 | + if ($fleet_db_list === 0) |
|
| 281 | 281 | { |
| 282 | 282 | $fleet_db_list = fleet_and_missiles_list_by_coordinates($planet); |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - foreach($fleet_db_list as $fleet) |
|
| 285 | + foreach ($fleet_db_list as $fleet) |
|
| 286 | 286 | { |
| 287 | - if($fleet['fleet_owner'] == $user['id']) |
|
| 287 | + if ($fleet['fleet_owner'] == $user['id']) |
|
| 288 | 288 | { |
| 289 | - if($fleet['fleet_mission'] == MT_MISSILE) |
|
| 289 | + if ($fleet['fleet_mission'] == MT_MISSILE) |
|
| 290 | 290 | { |
| 291 | 291 | continue; |
| 292 | 292 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | else |
| 296 | 296 | { |
| 297 | - switch($fleet['fleet_mission']) |
|
| 297 | + switch ($fleet['fleet_mission']) |
|
| 298 | 298 | { |
| 299 | 299 | case MT_ATTACK: |
| 300 | 300 | case MT_AKS: |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | $fleet_list[$fleet_ownage]['fleets'][$fleet['fleet_id']] = $fleet; |
| 314 | 314 | |
| 315 | - if($fleet['fleet_mess'] == 1 || ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_RELOCATE) || ($fleet['fleet_target_owner'] != $user['id'])) |
|
| 315 | + if ($fleet['fleet_mess'] == 1 || ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_RELOCATE) || ($fleet['fleet_target_owner'] != $user['id'])) |
|
| 316 | 316 | { |
| 317 | 317 | // $fleet_sn = flt_expand($fleet); |
| 318 | 318 | $fleet_sn = sys_unit_str2arr($fleet['fleet_array']); |
| 319 | - foreach($fleet_sn as $ship_id => $ship_amount) |
|
| 319 | + foreach ($fleet_sn as $ship_id => $ship_amount) |
|
| 320 | 320 | { |
| 321 | - if(in_array($ship_id, sn_get_groups('fleet'))) |
|
| 321 | + if (in_array($ship_id, sn_get_groups('fleet'))) |
|
| 322 | 322 | { |
| 323 | 323 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship_amount; |
| 324 | 324 | } |
@@ -352,14 +352,14 @@ discard block |
||
| 352 | 352 | 'ENERGY_MAX_NUMBER_TEXT_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow['energy_max']), |
| 353 | 353 | 'ENERGY_MAX_NUMBER_TEXT' => Tools::numberPercentSpan($planetrow['energy_max'], $planetrow['energy_used']), |
| 354 | 354 | 'ENERGY_MAX' => prettyNumberStyledCompare($planetrow['energy_max'], -$planetrow['energy_used']), |
| 355 | - 'ENERGY_FILL' => round(($planetrow["energy_used"]/($planetrow["energy_max"]+1))*100,0), |
|
| 355 | + 'ENERGY_FILL' => round(($planetrow["energy_used"] / ($planetrow["energy_max"] + 1)) * 100, 0), |
|
| 356 | 356 | |
| 357 | 357 | 'PLANET_METAL' => floor($planetrow["metal"]), |
| 358 | 358 | 'PLANET_METAL_TEXT' => prettyNumberStyledCompare($planetrow["metal"], $planetrow["metal_max"]), |
| 359 | 359 | 'PLANET_METAL_MAX' => floor($planetrow["metal_max"]), |
| 360 | 360 | 'PLANET_METAL_MAX_TEXT' => Tools::numberPercentSpan($planetrow["metal_max"], $planetrow["metal"]), |
| 361 | 361 | 'PLANET_METAL_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["metal_max"]), |
| 362 | - 'PLANET_METAL_FILL' => round(($planetrow["metal"]/($planetrow["metal_max"]+1))*100,0), |
|
| 362 | + 'PLANET_METAL_FILL' => round(($planetrow["metal"] / ($planetrow["metal_max"] + 1)) * 100, 0), |
|
| 363 | 363 | 'PLANET_METAL_PERHOUR' => round($planetrow["metal_perhour"], 5), |
| 364 | 364 | 'PLANET_METAL_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['METAL']), |
| 365 | 365 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | 'PLANET_CRYSTAL_MAX' => floor($planetrow["crystal_max"]), |
| 369 | 369 | 'PLANET_CRYSTAL_MAX_TEXT' => Tools::numberPercentSpan($planetrow["crystal_max"], $planetrow["crystal"]), |
| 370 | 370 | 'PLANET_CRYSTAL_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["crystal_max"]), |
| 371 | - 'PLANET_CRYSTAL_FILL' => round(($planetrow["crystal"]/($planetrow["crystal_max"]+1))*100,0), |
|
| 371 | + 'PLANET_CRYSTAL_FILL' => round(($planetrow["crystal"] / ($planetrow["crystal_max"] + 1)) * 100, 0), |
|
| 372 | 372 | 'PLANET_CRYSTAL_PERHOUR' => round($planetrow["crystal_perhour"], 5), |
| 373 | 373 | 'PLANET_CRYSTAL_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['CRYSTAL']), |
| 374 | 374 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | 'PLANET_DEUTERIUM_MAX' => floor($planetrow["deuterium_max"]), |
| 378 | 378 | 'PLANET_DEUTERIUM_MAX_TEXT' => Tools::numberPercentSpan($planetrow["deuterium_max"], $planetrow["deuterium"]), |
| 379 | 379 | 'PLANET_DEUTERIUM_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["deuterium_max"]), |
| 380 | - 'PLANET_DEUTERIUM_FILL' => round(($planetrow["deuterium"]/($planetrow["deuterium_max"]+1))*100,0), |
|
| 380 | + 'PLANET_DEUTERIUM_FILL' => round(($planetrow["deuterium"] / ($planetrow["deuterium_max"] + 1)) * 100, 0), |
|
| 381 | 381 | 'PLANET_DEUTERIUM_PERHOUR' => round($planetrow["deuterium_perhour"], 5), |
| 382 | 382 | 'PLANET_DEUTERIUM_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['DEUTERIUM']), |
| 383 | 383 | )); |
@@ -1,8 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Compare function to sort fleet in time order |
| 4 | -function tpl_assign_fleet_compare($a, $b) |
|
| 5 | -{ |
|
| 4 | +function tpl_assign_fleet_compare($a, $b) { |
|
| 6 | 5 | if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) |
| 7 | 6 | { |
| 8 | 7 | if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) |
@@ -10,15 +9,13 @@ discard block |
||
| 10 | 9 | return 0; |
| 11 | 10 | } |
| 12 | 11 | return ($a['fleet']['OV_LEFT'] < $b['fleet']['OV_LEFT']) ? -1 : 1; |
| 13 | - } |
|
| 14 | - else |
|
| 12 | + } else |
|
| 15 | 13 | { |
| 16 | 14 | return $a['fleet']['OV_THIS_PLANET'] ? -1 : 1; |
| 17 | 15 | } |
| 18 | 16 | } |
| 19 | 17 | |
| 20 | -function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') |
|
| 21 | -{ |
|
| 18 | +function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
|
| 22 | 19 | if(!$fleets) |
| 23 | 20 | { |
| 24 | 21 | return; |
@@ -41,8 +38,7 @@ discard block |
||
| 41 | 38 | } |
| 42 | 39 | |
| 43 | 40 | // function that parses internal fleet representation (as array(id => count)) |
| 44 | -function tpl_parse_fleet_sn($fleet, $fleet_id) |
|
| 45 | -{ |
|
| 41 | +function tpl_parse_fleet_sn($fleet, $fleet_id) { |
|
| 46 | 42 | global $lang, $user; |
| 47 | 43 | |
| 48 | 44 | $user_data = &$user; |
@@ -182,8 +178,7 @@ discard block |
||
| 182 | 178 | return $result; |
| 183 | 179 | } |
| 184 | 180 | |
| 185 | -function tpl_parse_planet_que($que, $planet, $que_id) |
|
| 186 | -{ |
|
| 181 | +function tpl_parse_planet_que($que, $planet, $que_id) { |
|
| 187 | 182 | $hangar_que = array(); |
| 188 | 183 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
| 189 | 184 | if(!empty($que_hangar)) |
@@ -198,8 +193,7 @@ discard block |
||
| 198 | 193 | return $hangar_que; |
| 199 | 194 | } |
| 200 | 195 | |
| 201 | -function tpl_parse_planet($planet, &$fleets) |
|
| 202 | -{ |
|
| 196 | +function tpl_parse_planet($planet, &$fleets) { |
|
| 203 | 197 | global $lang; |
| 204 | 198 | |
| 205 | 199 | $que = que_get($planet['id_owner'], $planet['id'], false); |
@@ -268,8 +262,7 @@ discard block |
||
| 268 | 262 | return $result; |
| 269 | 263 | } |
| 270 | 264 | |
| 271 | -function flt_get_fleets_to_planet($planet, $fleet_db_list = 0) |
|
| 272 | -{ |
|
| 265 | +function flt_get_fleets_to_planet($planet, $fleet_db_list = 0) { |
|
| 273 | 266 | if(!($planet && $planet['id']) && !$fleet_db_list) |
| 274 | 267 | { |
| 275 | 268 | return $planet; |
@@ -291,8 +284,7 @@ discard block |
||
| 291 | 284 | continue; |
| 292 | 285 | } |
| 293 | 286 | $fleet_ownage = 'own'; |
| 294 | - } |
|
| 295 | - else |
|
| 287 | + } else |
|
| 296 | 288 | { |
| 297 | 289 | switch($fleet['fleet_mission']) |
| 298 | 290 | { |
@@ -340,8 +332,7 @@ discard block |
||
| 340 | 332 | * @param array $planetrow |
| 341 | 333 | * @param array $fleets_to_planet |
| 342 | 334 | */ |
| 343 | -function tpl_set_resource_info(&$template, $planetrow, $fleets_to_planet = array()) |
|
| 344 | -{ |
|
| 335 | +function tpl_set_resource_info(&$template, $planetrow, $fleets_to_planet = array()) { |
|
| 345 | 336 | $template->assign_vars(array( |
| 346 | 337 | 'RESOURCE_ROUNDING' => 0, |
| 347 | 338 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | function getSkinPathTemplate($userSkinPath) { |
| 15 | 15 | static $template_names = array(); |
| 16 | 16 | |
| 17 | - if(!isset($template_names[$userSkinPath])) { |
|
| 17 | + if (!isset($template_names[$userSkinPath])) { |
|
| 18 | 18 | $template_names[$userSkinPath] = file_exists(SN_ROOT_PHYSICAL . $userSkinPath . '_template.ini') ? sys_file_read(SN_ROOT_PHYSICAL . $userSkinPath . '_template.ini') : TEMPLATE_NAME; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | function messageBoxAdminAccessDenied($level = AUTH_LEVEL_ADMINISTRATOR) { |
| 64 | 64 | global $user, $lang; |
| 65 | 65 | |
| 66 | - if($user['authlevel'] < $level) { |
|
| 66 | + if ($user['authlevel'] < $level) { |
|
| 67 | 67 | messageBoxAdmin($lang['adm_err_denied'], $lang['admin_title_access_denied'], SN_ROOT_VIRTUAL . 'overview.php'); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * @param $extra |
| 74 | 74 | */ |
| 75 | 75 | function tpl_menu_merge_extra(&$menu, &$extra) { |
| 76 | - if(empty($menu) || empty($extra)) { |
|
| 76 | + if (empty($menu) || empty($extra)) { |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - foreach($extra as $menu_item_id => $menu_item) { |
|
| 81 | - if(empty($menu_item['LOCATION'])) { |
|
| 80 | + foreach ($extra as $menu_item_id => $menu_item) { |
|
| 81 | + if (empty($menu_item['LOCATION'])) { |
|
| 82 | 82 | $menu[$menu_item_id] = $menu_item; |
| 83 | 83 | continue; |
| 84 | 84 | } |
@@ -87,16 +87,16 @@ discard block |
||
| 87 | 87 | unset($menu_item['LOCATION']); |
| 88 | 88 | |
| 89 | 89 | $is_positioned = $item_location[0]; |
| 90 | - if($is_positioned == '+' || $is_positioned == '-') { |
|
| 90 | + if ($is_positioned == '+' || $is_positioned == '-') { |
|
| 91 | 91 | $item_location = substr($item_location, 1); |
| 92 | 92 | } else { |
| 93 | 93 | $is_positioned = ''; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if($item_location) { |
|
| 96 | + if ($item_location) { |
|
| 97 | 97 | $menu_keys = array_keys($menu); |
| 98 | 98 | $insert_position = array_search($item_location, $menu_keys); |
| 99 | - if($insert_position === false) { |
|
| 99 | + if ($insert_position === false) { |
|
| 100 | 100 | $insert_position = count($menu) - 1; |
| 101 | 101 | $is_positioned = '+'; |
| 102 | 102 | $item_location = ''; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $spliced = array_splice($menu, $insert_position, count($menu) - $insert_position); |
| 110 | 110 | $menu[$menu_item_id] = $menu_item; |
| 111 | 111 | |
| 112 | - if(!$is_positioned && $item_location) { |
|
| 112 | + if (!$is_positioned && $item_location) { |
|
| 113 | 113 | unset($spliced[$item_location]); |
| 114 | 114 | } |
| 115 | 115 | $menu = array_merge($menu, $spliced); |
@@ -125,24 +125,24 @@ discard block |
||
| 125 | 125 | function tpl_menu_assign_to_template(&$sn_menu, &$template) { |
| 126 | 126 | global $lang; |
| 127 | 127 | |
| 128 | - if(empty($sn_menu) || !is_array($sn_menu)) { |
|
| 128 | + if (empty($sn_menu) || !is_array($sn_menu)) { |
|
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - foreach($sn_menu as $menu_item_id => $menu_item) { |
|
| 133 | - if(!$menu_item) { |
|
| 132 | + foreach ($sn_menu as $menu_item_id => $menu_item) { |
|
| 133 | + if (!$menu_item) { |
|
| 134 | 134 | continue; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if(is_string($menu_item_id)) { |
|
| 137 | + if (is_string($menu_item_id)) { |
|
| 138 | 138 | $menu_item['ID'] = $menu_item_id; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if($menu_item['TYPE'] == 'lang') { |
|
| 141 | + if ($menu_item['TYPE'] == 'lang') { |
|
| 142 | 142 | $lang_string = &$lang; |
| 143 | - if(preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
|
| 144 | - for($i = 1; $i < count($matches); $i++) { |
|
| 145 | - if(defined($matches[$i])) { |
|
| 143 | + if (preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
|
| 144 | + for ($i = 1; $i < count($matches); $i++) { |
|
| 145 | + if (defined($matches[$i])) { |
|
| 146 | 146 | $matches[$i] = constant($matches[$i]); |
| 147 | 147 | } |
| 148 | 148 | $lang_string = &$lang_string[$matches[$i]]; |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | $menu_item['ALT'] = htmlentities($menu_item['ALT']); |
| 155 | 155 | $menu_item['TITLE'] = htmlentities($menu_item['TITLE']); |
| 156 | 156 | |
| 157 | - if(!empty($menu_item['ICON'])) { |
|
| 158 | - if(is_string($menu_item['ICON'])) { |
|
| 157 | + if (!empty($menu_item['ICON'])) { |
|
| 158 | + if (is_string($menu_item['ICON'])) { |
|
| 159 | 159 | $menu_item['ICON_PATH'] = $menu_item['ICON']; |
| 160 | 160 | } else { |
| 161 | 161 | $menu_item['ICON'] = $menu_item_id; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | 'MENU_START_HIDE' => !empty($_COOKIE[SN_COOKIE . '_menu_hidden']) || defined('SN_GOOGLE'), |
| 188 | 188 | )); |
| 189 | 189 | |
| 190 | - if(isset($template_result['MENU_CUSTOMIZE'])) { |
|
| 190 | + if (isset($template_result['MENU_CUSTOMIZE'])) { |
|
| 191 | 191 | $template->assign_vars(array( |
| 192 | 192 | 'PLAYER_OPTION_MENU_SHOW_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON], |
| 193 | 193 | 'PLAYER_OPTION_MENU_HIDE_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON], |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | )); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if(defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
|
| 204 | + if (defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
|
| 205 | 205 | tpl_menu_merge_extra($sn_menu_admin, $sn_menu_admin_extra); |
| 206 | 206 | tpl_menu_assign_to_template($sn_menu_admin, $template); |
| 207 | 207 | } else { |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @return mixed |
| 224 | 224 | */ |
| 225 | 225 | function display($page, $title = '') { |
| 226 | - if(!defined('SN_TIME_RENDER_START')) { |
|
| 226 | + if (!defined('SN_TIME_RENDER_START')) { |
|
| 227 | 227 | define('SN_TIME_RENDER_START', microtime(true)); |
| 228 | 228 | } |
| 229 | 229 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $exitStatus = true; |
| 248 | 248 | $template_result['LOGIN_LOGOUT'] = $inLoginLogout = defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true; |
| 249 | 249 | |
| 250 | - if(is_object($page)) { |
|
| 250 | + if (is_object($page)) { |
|
| 251 | 251 | isset($page->_rootref['PAGE_TITLE']) && empty($title) ? $title = $page->_rootref['PAGE_TITLE'] : false; |
| 252 | 252 | !$title && !empty($page->_rootref['PAGE_HEADER']) ? $title = $page->_rootref['PAGE_HEADER'] : false; |
| 253 | 253 | !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false; |
@@ -256,18 +256,18 @@ discard block |
||
| 256 | 256 | $isRenderGlobal = is_object($page) && isset($template_result['GLOBAL_DISPLAY_HEADER']) ? $template_result['GLOBAL_DISPLAY_HEADER'] : true; |
| 257 | 257 | |
| 258 | 258 | // Global header |
| 259 | - if($isRenderGlobal) { |
|
| 259 | + if ($isRenderGlobal) { |
|
| 260 | 260 | renderHeader($page, $title, $template_result, $inLoginLogout, $user, $config, $lang, $planetrow); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // Page content |
| 264 | 264 | !is_array($page) ? $page = array($page) : false; |
| 265 | 265 | $result_added = false; |
| 266 | - foreach($page as $page_item) { |
|
| 266 | + foreach ($page as $page_item) { |
|
| 267 | 267 | /** |
| 268 | 268 | * @var template $page_item |
| 269 | 269 | */ |
| 270 | - if(!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
|
| 270 | + if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
|
| 271 | 271 | $resultTemplate = gettemplate('_result_message'); |
| 272 | 272 | $resultTemplate->_tpldata = $page_item->_tpldata; |
| 273 | 273 | displayP($resultTemplate); |
@@ -284,11 +284,11 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Global footer |
| 287 | - if($isRenderGlobal) { |
|
| 287 | + if ($isRenderGlobal) { |
|
| 288 | 288 | renderFooter(); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;; |
|
| 291 | + $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false; ; |
|
| 292 | 292 | |
| 293 | 293 | sn_db_disconnect(); |
| 294 | 294 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param $planetrow |
| 307 | 307 | */ |
| 308 | 308 | function renderHeader($page, $title, &$template_result, $inLoginLogout, &$user, $config, $lang, $planetrow) { |
| 309 | - if(classSupernova::$headerRendered) { |
|
| 309 | + if (classSupernova::$headerRendered) { |
|
| 310 | 310 | return; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -465,10 +465,10 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function cssAddFileName($cssFileName, &$cssArray) { |
| 467 | 467 | $result = false; |
| 468 | - if(file_exists(SN_ROOT_PHYSICAL . $cssFileName . '.min.css')) { |
|
| 468 | + if (file_exists(SN_ROOT_PHYSICAL . $cssFileName . '.min.css')) { |
|
| 469 | 469 | $cssArray[$cssFileName . '.min.css'] = ''; |
| 470 | 470 | $result = true; |
| 471 | - } elseif(file_exists(SN_ROOT_PHYSICAL . $cssFileName . '.css')) { |
|
| 471 | + } elseif (file_exists(SN_ROOT_PHYSICAL . $cssFileName . '.css')) { |
|
| 472 | 472 | $cssArray[$cssFileName . '.css'] = ''; |
| 473 | 473 | $result = true; |
| 474 | 474 | } |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | * @param string $type |
| 561 | 561 | */ |
| 562 | 562 | function tpl_topnav_event_build(&$template, $fleet_flying_list, $type = 'fleet') { |
| 563 | - if(empty($fleet_flying_list)) { |
|
| 563 | + if (empty($fleet_flying_list)) { |
|
| 564 | 564 | return; |
| 565 | 565 | } |
| 566 | 566 | |
@@ -569,19 +569,19 @@ discard block |
||
| 569 | 569 | $fleet_event_count = 0; |
| 570 | 570 | $fleet_flying_sorter = array(); |
| 571 | 571 | $fleet_flying_events = array(); |
| 572 | - foreach($fleet_flying_list as &$fleet_flying_row) { |
|
| 572 | + foreach ($fleet_flying_list as &$fleet_flying_row) { |
|
| 573 | 573 | $will_return = true; |
| 574 | - if($fleet_flying_row['fleet_mess'] == 0) { |
|
| 574 | + if ($fleet_flying_row['fleet_mess'] == 0) { |
|
| 575 | 575 | // cut fleets on Hold and Expedition |
| 576 | - if($fleet_flying_row['fleet_start_time'] >= SN_TIME_NOW) { |
|
| 576 | + if ($fleet_flying_row['fleet_start_time'] >= SN_TIME_NOW) { |
|
| 577 | 577 | $fleet_flying_row['fleet_mission'] == MT_RELOCATE ? $will_return = false : false; |
| 578 | 578 | tpl_topnav_event_build_helper($fleet_flying_row['fleet_start_time'], EVENT_FLEET_ARRIVE, $lang['sys_event_arrive'], 'fleet_end_', !$will_return, $fleet_flying_row, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
| 579 | 579 | } |
| 580 | - if($fleet_flying_row['fleet_end_stay']) { |
|
| 580 | + if ($fleet_flying_row['fleet_end_stay']) { |
|
| 581 | 581 | tpl_topnav_event_build_helper($fleet_flying_row['fleet_end_stay'], EVENT_FLEET_STAY, $lang['sys_event_stay'], 'fleet_end_', false, $fleet_flying_row, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
| 582 | 582 | } |
| 583 | 583 | } |
| 584 | - if($will_return) { |
|
| 584 | + if ($will_return) { |
|
| 585 | 585 | tpl_topnav_event_build_helper($fleet_flying_row['fleet_end_time'], EVENT_FLEET_RETURN, $lang['sys_event_return'], 'fleet_start_', true, $fleet_flying_row, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
| 586 | 586 | } |
| 587 | 587 | } |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | asort($fleet_flying_sorter); |
| 590 | 590 | |
| 591 | 591 | $fleet_flying_count = count($fleet_flying_list); |
| 592 | - foreach($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
|
| 592 | + foreach ($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
|
| 593 | 593 | $fleet_event = &$fleet_flying_events[$fleet_event_id]; |
| 594 | 594 | $template->assign_block_vars("flying_{$type}s", array( |
| 595 | 595 | 'TIME' => max(0, $fleet_time - SN_TIME_NOW), |
@@ -619,15 +619,15 @@ discard block |
||
| 619 | 619 | function sn_tpl_render_topnav(&$user, $planetrow, $template) { |
| 620 | 620 | global $lang, $config, $sn_module_list, $template_result, $sn_mvc; |
| 621 | 621 | |
| 622 | - if(!is_array($user)) { |
|
| 622 | + if (!is_array($user)) { |
|
| 623 | 623 | return ''; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | $GET_mode = sys_get_param_str('mode'); |
| 627 | 627 | |
| 628 | 628 | $ThisUsersPlanets = DBStaticPlanet::db_planet_list_sorted($user); |
| 629 | - foreach($ThisUsersPlanets as $CurPlanet) { |
|
| 630 | - if($CurPlanet['destruyed']) { |
|
| 629 | + foreach ($ThisUsersPlanets as $CurPlanet) { |
|
| 630 | + if ($CurPlanet['destruyed']) { |
|
| 631 | 631 | continue; |
| 632 | 632 | } |
| 633 | 633 | |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | 'QUE_ID' => QUE_RESEARCH, |
| 672 | 672 | 'QUE_HTML' => 'topnav', |
| 673 | 673 | |
| 674 | - 'RESEARCH_ONGOING' => (boolean)$user['que'], |
|
| 674 | + 'RESEARCH_ONGOING' => (boolean) $user['que'], |
|
| 675 | 675 | |
| 676 | 676 | 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], |
| 677 | 677 | $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds'] |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | 'QUE_STRUCTURES' => QUE_STRUCTURES, |
| 754 | 754 | )); |
| 755 | 755 | |
| 756 | - if((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
|
| 756 | + if ((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
|
| 757 | 757 | tpl_set_resource_info($template, $planetrow); |
| 758 | 758 | $template->assign_vars(array( |
| 759 | 759 | 'SN_RENDER_NAVBAR_PLANET' => true, |
@@ -848,12 +848,12 @@ discard block |
||
| 848 | 848 | * @param template|string $template |
| 849 | 849 | */ |
| 850 | 850 | function displayP($template) { |
| 851 | - if(is_object($template)) { |
|
| 852 | - if(empty($template->parsed)) { |
|
| 851 | + if (is_object($template)) { |
|
| 852 | + if (empty($template->parsed)) { |
|
| 853 | 853 | parsetemplate($template); |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - foreach($template->files as $section => $filename) { |
|
| 856 | + foreach ($template->files as $section => $filename) { |
|
| 857 | 857 | $template->display($section); |
| 858 | 858 | } |
| 859 | 859 | } else { |
@@ -870,8 +870,8 @@ discard block |
||
| 870 | 870 | function templateObjectParse($template, $array = false) { |
| 871 | 871 | global $user; |
| 872 | 872 | |
| 873 | - if(!empty($array) && is_array($array)) { |
|
| 874 | - foreach($array as $key => $data) { |
|
| 873 | + if (!empty($array) && is_array($array)) { |
|
| 874 | + foreach ($array as $key => $data) { |
|
| 875 | 875 | $template->assign_var($key, $data); |
| 876 | 876 | } |
| 877 | 877 | } |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | * @return mixed |
| 895 | 895 | */ |
| 896 | 896 | function parsetemplate($template, $array = false) { |
| 897 | - if(is_object($template)) { |
|
| 897 | + if (is_object($template)) { |
|
| 898 | 898 | return templateObjectParse($template, $array); |
| 899 | 899 | } else { |
| 900 | 900 | $search[] = '#\{L_([a-z0-9\-_]*?)\[([a-z0-9\-_]*?)\]\}#Ssie'; |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | !empty($sn_mvc['i18n']['']) ? lng_load_i18n($sn_mvc['i18n']['']) : false; |
| 940 | 940 | $sn_page_name ? lng_load_i18n($sn_mvc['i18n'][$sn_page_name]) : false; |
| 941 | 941 | |
| 942 | - foreach($files as &$filename) { |
|
| 942 | + foreach ($files as &$filename) { |
|
| 943 | 943 | $filename = $filename . $template_ex; |
| 944 | 944 | } |
| 945 | 945 | |
@@ -964,13 +964,13 @@ discard block |
||
| 964 | 964 | 'LANG' => $language ? $language : '', |
| 965 | 965 | 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', |
| 966 | 966 | |
| 967 | - 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
| 967 | + 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
| 968 | 968 | 'FILENAME' => basename($_SERVER['PHP_SELF']), |
| 969 | 969 | )); |
| 970 | 970 | |
| 971 | - foreach(lng_get_list() as $lng_id => $lng_data) { |
|
| 972 | - if(isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
|
| 973 | - foreach($lng_data['LANG_VARIANTS'] as $lang_variant) { |
|
| 971 | + foreach (lng_get_list() as $lng_id => $lng_data) { |
|
| 972 | + if (isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
|
| 973 | + foreach ($lng_data['LANG_VARIANTS'] as $lang_variant) { |
|
| 974 | 974 | $lng_data1 = $lng_data; |
| 975 | 975 | $lng_data1 = array_merge($lng_data1, $lang_variant); |
| 976 | 976 | $template->assign_block_vars('language', $lng_data1); |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | $fleet_flying_list = array(); |
| 991 | 991 | |
| 992 | 992 | $fleet_flying_list[0] = fleet_list_by_owner_id($user['id']); |
| 993 | - foreach($fleet_flying_list[0] as $fleet_id => $fleet_flying_row) { |
|
| 993 | + foreach ($fleet_flying_list[0] as $fleet_id => $fleet_flying_row) { |
|
| 994 | 994 | $fleet_flying_list[$fleet_flying_row['fleet_mission']][$fleet_id] = &$fleet_flying_list[0][$fleet_id]; |
| 995 | 995 | } |
| 996 | 996 | |
@@ -1009,8 +1009,8 @@ discard block |
||
| 1009 | 1009 | $que = $que['ques'][$que_type][$planet['id_owner']][$planet['id']]; |
| 1010 | 1010 | |
| 1011 | 1011 | $que_length = 0; |
| 1012 | - if(!empty($que)) { |
|
| 1013 | - foreach($que as $que_item) { |
|
| 1012 | + if (!empty($que)) { |
|
| 1013 | + foreach ($que as $que_item) { |
|
| 1014 | 1014 | $template->assign_block_vars('que', que_tpl_parse_element($que_item)); |
| 1015 | 1015 | } |
| 1016 | 1016 | $que_length = count($que); |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter) { |
| 1028 | 1028 | global $lang; |
| 1029 | 1029 | |
| 1030 | - foreach($density_price_chart as $density_price_index => &$density_price_data) { |
|
| 1030 | + foreach ($density_price_chart as $density_price_index => &$density_price_data) { |
|
| 1031 | 1031 | $density_cost = $density_price_data; |
| 1032 | 1032 | $density_price_data = array( |
| 1033 | 1033 | 'COST' => $density_cost, |
@@ -1049,7 +1049,7 @@ discard block |
||
| 1049 | 1049 | function tpl_assign_select(&$template, $name, $values) { |
| 1050 | 1050 | !is_array($values) ? $values = array($values => $values) : false; |
| 1051 | 1051 | |
| 1052 | - foreach($values as $key => $value) { |
|
| 1052 | + foreach ($values as $key => $value) { |
|
| 1053 | 1053 | $template->assign_block_vars($name, array( |
| 1054 | 1054 | 'KEY' => htmlentities($key, ENT_COMPAT, 'UTF-8'), |
| 1055 | 1055 | 'VALUE' => htmlentities($value, ENT_COMPAT, 'UTF-8'), |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | // $same_user = false; |
| 48 | 48 | // } |
| 49 | 49 | |
| 50 | - if(!$user_data) { |
|
| 50 | + if (!$user_data) { |
|
| 51 | 51 | messageBox($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10); |
| 52 | 52 | die(); |
| 53 | 53 | } |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | $stat_array = array(); |
| 59 | 59 | $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;"); |
| 60 | 60 | $stat_count = classSupernova::$db->db_affected_rows(); |
| 61 | - while($row = db_fetch($query)) { |
|
| 62 | - foreach($stat_fields as $field_db_name => $field_template_name) { |
|
| 61 | + while ($row = db_fetch($query)) { |
|
| 62 | + foreach ($stat_fields as $field_db_name => $field_template_name) { |
|
| 63 | 63 | // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS |
| 64 | 64 | $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name]; |
| 65 | 65 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | $stat_array_date = $stat_array['STAT_DATE']; |
| 69 | 69 | empty($stat_array_date['DATA']) ? $stat_array_date['DATA'] = array() : false; |
| 70 | - foreach($stat_array_date['DATA'] as $key => $value) { |
|
| 70 | + foreach ($stat_array_date['DATA'] as $key => $value) { |
|
| 71 | 71 | $template->assign_block_vars('stat_date', array( |
| 72 | 72 | 'ID' => $key, |
| 73 | 73 | 'VALUE' => $value, |
@@ -77,21 +77,21 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | unset($stat_array['STAT_DATE']); |
| 79 | 79 | $template_data = array(); |
| 80 | - foreach($stat_array as $stat_type => &$stat_type_data) { |
|
| 80 | + foreach ($stat_array as $stat_type => &$stat_type_data) { |
|
| 81 | 81 | $reverse_min_max = strpos($stat_type, '_RANK') !== false; |
| 82 | 82 | $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']); |
| 83 | 83 | $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']); |
| 84 | 84 | $stat_type_data['AVG'] = average($stat_type_data['DATA']); |
| 85 | - foreach($stat_type_data['DATA'] as $key => $value) { |
|
| 85 | + foreach ($stat_type_data['DATA'] as $key => $value) { |
|
| 86 | 86 | $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100; |
| 87 | 87 | $template_data[$stat_type][$key]['ID'] = $key; |
| 88 | 88 | $template_data[$stat_type][$key]['VALUE'] = $value; |
| 89 | - $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
| 89 | + $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
| 90 | 90 | $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key]; |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - foreach($template_data as $stat_type => $stat_type_data) { |
|
| 94 | + foreach ($template_data as $stat_type => $stat_type_data) { |
|
| 95 | 95 | $template->assign_block_vars('stat', array( |
| 96 | 96 | 'TYPE' => $stat_type, |
| 97 | 97 | 'TEXT' => $lang['imp_stat_types'][$stat_type], |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | 'MAX' => $stat_array[$stat_type]['MAX'], |
| 100 | 100 | 'AVG' => $stat_array[$stat_type]['AVG'], |
| 101 | 101 | )); |
| 102 | - foreach($stat_type_data as $stat_entry) { |
|
| 102 | + foreach ($stat_type_data as $stat_entry) { |
|
| 103 | 103 | $template->assign_block_vars('stat.entry', $stat_entry); |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
| 108 | - if($same_user) { |
|
| 108 | + if ($same_user) { |
|
| 109 | 109 | rpg_level_up($user, RPG_STRUCTURE); |
| 110 | 110 | rpg_level_up($user, RPG_RAID); |
| 111 | 111 | rpg_level_up($user, RPG_TECH); |
@@ -139,29 +139,29 @@ discard block |
||
| 139 | 139 | 'builder_xp' => HelperString::numberFloorAndFormat($user_data['xpminier']), |
| 140 | 140 | 'builder_lvl' => HelperString::numberFloorAndFormat($user_data['lvl_minier']), |
| 141 | 141 | 'builder_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'])), |
| 142 | - 'builder_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier']+1)), |
|
| 142 | + 'builder_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), |
|
| 143 | 143 | 'raid_xp' => HelperString::numberFloorAndFormat($user_data['xpraid']), |
| 144 | 144 | 'raid_lvl' => HelperString::numberFloorAndFormat($user_data['lvl_raid']), |
| 145 | - 'raid_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid']+1)), |
|
| 145 | + 'raid_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), |
|
| 146 | 146 | 'raids' => HelperString::numberFloorAndFormat($user_data['raids']), |
| 147 | 147 | 'raidswin' => HelperString::numberFloorAndFormat($user_data['raidswin']), |
| 148 | 148 | 'raidsloose' => HelperString::numberFloorAndFormat($user_data['raidsloose']), |
| 149 | 149 | 'tech_xp' => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_xp']), |
| 150 | 150 | 'tech_lvl' => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_level']), |
| 151 | 151 | 'tech_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), |
| 152 | - 'tech_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)), |
|
| 152 | + 'tech_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), |
|
| 153 | 153 | |
| 154 | 154 | 'explore_xp' => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_xp']), |
| 155 | 155 | 'explore_lvl' => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_level']), |
| 156 | 156 | 'explore_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), |
| 157 | - 'explore_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)), |
|
| 158 | - |
|
| 159 | - 'build_points' => HelperString::numberFloorAndFormat( $StatRecord['build_points'] ), |
|
| 160 | - 'tech_points' => HelperString::numberFloorAndFormat( $StatRecord['tech_points'] ), |
|
| 161 | - 'fleet_points' => HelperString::numberFloorAndFormat( $StatRecord['fleet_points'] ), |
|
| 162 | - 'defs_points' => HelperString::numberFloorAndFormat( $StatRecord['defs_points'] ), |
|
| 163 | - 'res_points' => HelperString::numberFloorAndFormat( $StatRecord['res_points'] ), |
|
| 164 | - 'total_points' => HelperString::numberFloorAndFormat( $StatRecord['total_points'] ), |
|
| 157 | + 'explore_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), |
|
| 158 | + |
|
| 159 | + 'build_points' => HelperString::numberFloorAndFormat($StatRecord['build_points']), |
|
| 160 | + 'tech_points' => HelperString::numberFloorAndFormat($StatRecord['tech_points']), |
|
| 161 | + 'fleet_points' => HelperString::numberFloorAndFormat($StatRecord['fleet_points']), |
|
| 162 | + 'defs_points' => HelperString::numberFloorAndFormat($StatRecord['defs_points']), |
|
| 163 | + 'res_points' => HelperString::numberFloorAndFormat($StatRecord['res_points']), |
|
| 164 | + 'total_points' => HelperString::numberFloorAndFormat($StatRecord['total_points']), |
|
| 165 | 165 | 'user_rank' => $StatRecord['total_rank'], |
| 166 | 166 | 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], |
| 167 | 167 | |