@@ -239,6 +239,9 @@ |
||
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | + /** |
|
| 243 | + * @param string $arrayName |
|
| 244 | + */ |
|
| 242 | 245 | protected function mergeArraySpecial($arrayName) { |
| 243 | 246 | global $sn_mvc; |
| 244 | 247 | |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | function loadModuleRootConfig() { |
| 76 | - require SN_ROOT_PHYSICAL . 'config.php'; |
|
| 76 | + require SN_ROOT_PHYSICAL.'config.php'; |
|
| 77 | 77 | |
| 78 | - $module_config_array = get_class($this) . '_config'; |
|
| 79 | - if(!empty($$module_config_array) && is_array($$module_config_array)) { |
|
| 78 | + $module_config_array = get_class($this).'_config'; |
|
| 79 | + if (!empty($$module_config_array) && is_array($$module_config_array)) { |
|
| 80 | 80 | $this->config = $$module_config_array; |
| 81 | 81 | |
| 82 | 82 | return true; |
@@ -94,17 +94,17 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | // TODO: Load configuration from DB. Manifest setting |
| 96 | 96 | // Trying to load configuration from file |
| 97 | - if(!$config_exists = $this->loadModuleRootConfig()) { |
|
| 97 | + if (!$config_exists = $this->loadModuleRootConfig()) { |
|
| 98 | 98 | // Конфигурация может лежать в config_path в манифеста или в корне модуля |
| 99 | - if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
| 99 | + if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'].'/config.php')) { |
|
| 100 | 100 | $config_exists = true; |
| 101 | - } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
| 101 | + } elseif (file_exists($config_filename = dirname($filename).'/config.php')) { |
|
| 102 | 102 | $config_exists = true; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if($config_exists) { |
|
| 105 | + if ($config_exists) { |
|
| 106 | 106 | include($config_filename); |
| 107 | - $module_config_array = $class_module_name . '_config'; |
|
| 107 | + $module_config_array = $class_module_name.'_config'; |
|
| 108 | 108 | $this->config = $$module_config_array; |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | // Checking module status - is it installed and active |
| 121 | 121 | $this->check_status(); |
| 122 | - if(!$this->manifest['active']) { |
|
| 122 | + if (!$this->manifest['active']) { |
|
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | protected function setSystemConstants() { |
| 141 | 141 | // Setting constants - if any |
| 142 | - if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
| 142 | + if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
| 143 | 143 | return; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - foreach($this->manifest['constants'] as $constant_name => $constant_value) { |
|
| 146 | + foreach ($this->manifest['constants'] as $constant_name => $constant_value) { |
|
| 147 | 147 | !defined($constant_name) ? define($constant_name, $constant_value) : false; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -155,48 +155,48 @@ discard block |
||
| 155 | 155 | // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays) |
| 156 | 156 | // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]' |
| 157 | 157 | $this->manifest['vars'] = $this->__assign_vars(); |
| 158 | - if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
| 158 | + if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $vars_assigned = array(); |
| 163 | - foreach($this->manifest['vars'] as $var_name => $var_value) { |
|
| 163 | + foreach ($this->manifest['vars'] as $var_name => $var_value) { |
|
| 164 | 164 | $sub_vars = explode('[', str_replace(']', '', $var_name)); |
| 165 | 165 | $var_name = $sub_vars[0]; |
| 166 | 166 | |
| 167 | - if(!isset($vars_assigned[$var_name])) { |
|
| 167 | + if (!isset($vars_assigned[$var_name])) { |
|
| 168 | 168 | $vars_assigned[$var_name] = true; |
| 169 | 169 | global $$var_name; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $pointer = &$$var_name; |
| 173 | - if(($n = count($sub_vars)) > 1) { |
|
| 174 | - for($i = 1; $i < $n; $i++) { |
|
| 175 | - if(defined($sub_vars[$i])) { |
|
| 173 | + if (($n = count($sub_vars)) > 1) { |
|
| 174 | + for ($i = 1; $i < $n; $i++) { |
|
| 175 | + if (defined($sub_vars[$i])) { |
|
| 176 | 176 | $sub_vars[$i] = constant($sub_vars[$i]); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if(!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
| 179 | + if (!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
| 180 | 180 | $pointer[$sub_vars[$i]] = array(); |
| 181 | 181 | } |
| 182 | 182 | $pointer = &$pointer[$sub_vars[$i]]; |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if(!isset($pointer) || !is_array($pointer)) { |
|
| 186 | + if (!isset($pointer) || !is_array($pointer)) { |
|
| 187 | 187 | $pointer = $var_value; |
| 188 | - } elseif(is_array($$var_name)) { |
|
| 188 | + } elseif (is_array($$var_name)) { |
|
| 189 | 189 | $pointer = array_merge_recursive_numeric($pointer, $var_value); |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | protected function mergeMenu(&$sn_menu_extra, &$menu_patch) { |
| 195 | - if(!is_array($menu_patch)) { |
|
| 195 | + if (!is_array($menu_patch)) { |
|
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - foreach($menu_patch as $menu_item_name => $menu_item_data) { |
|
| 199 | + foreach ($menu_patch as $menu_item_name => $menu_item_data) { |
|
| 200 | 200 | $sn_menu_extra[$menu_item_name] = $menu_item_data; |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -205,34 +205,34 @@ discard block |
||
| 205 | 205 | // Overriding function if any |
| 206 | 206 | sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this); |
| 207 | 207 | |
| 208 | - foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
| 208 | + foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
| 209 | 209 | sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type); |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | protected function mergeNavbarButton() { |
| 214 | - if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
| 214 | + if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
| 215 | 215 | return; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
| 218 | + foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
| 219 | 219 | classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative; |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | protected function mergeI18N() { |
| 224 | 224 | $arrayName = 'i18n'; |
| 225 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
| 225 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
| 226 | 226 | return; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
| 230 | - foreach($contentList as &$i18n_file_data) { |
|
| 231 | - if(is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
| 229 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
| 230 | + foreach ($contentList as &$i18n_file_data) { |
|
| 231 | + if (is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
| 232 | 232 | $i18n_file_data['path'] = $this->manifest['root_relative']; |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | - if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
| 235 | + if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
| 236 | 236 | classSupernova::$sn_mvc[$arrayName][$pageName] = array(); |
| 237 | 237 | } |
| 238 | 238 | classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList; |
@@ -240,13 +240,13 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | protected function mergeArraySpecial($arrayName) { |
| 243 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
| 243 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
| 244 | 244 | return; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
| 247 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
| 248 | 248 | !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false; |
| 249 | - foreach($contentList as $contentName => &$content) { |
|
| 249 | + foreach ($contentList as $contentName => &$content) { |
|
| 250 | 250 | classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -286,7 +286,6 @@ discard block |
||
| 286 | 286 | /** |
| 287 | 287 | * Функция пытается залогиниться по всем известным провайдерам |
| 288 | 288 | * |
| 289 | - * @param null $result |
|
| 290 | 289 | */ |
| 291 | 290 | public function login() { |
| 292 | 291 | if(empty(sn_module::$sn_module_list['auth'])) { |
@@ -823,10 +822,17 @@ discard block |
||
| 823 | 822 | |
| 824 | 823 | // OK v4.5 |
| 825 | 824 | // TODO - REMEMBER_ME |
| 825 | + |
|
| 826 | + /** |
|
| 827 | + * @param integer $period |
|
| 828 | + */ |
|
| 826 | 829 | protected static function cookie_set($value, $impersonate = false, $period = null) { |
| 827 | 830 | sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE); |
| 828 | 831 | } |
| 829 | 832 | |
| 833 | + /** |
|
| 834 | + * @param string $message |
|
| 835 | + */ |
|
| 830 | 836 | protected static function flog($message, $die = false) { |
| 831 | 837 | if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
| 832 | 838 | return; |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | // Проверить наличие такого имени в истории имён |
| 225 | 225 | do { |
| 226 | 226 | sn_db_transaction_rollback(); |
| 227 | - $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
| 227 | + $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
| 228 | 228 | sn_db_transaction_start(); |
| 229 | 229 | } while (db_player_name_exists($this->player_suggested_name)); |
| 230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | if ($player_name_submitted) { |
| 234 | 234 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
| 235 | 235 | if ($this->register_status == LOGIN_SUCCESS) { |
| 236 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
|
| 236 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); |
|
| 237 | 237 | } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
| 238 | 238 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
| 239 | 239 | } |
@@ -259,8 +259,8 @@ discard block |
||
| 259 | 259 | ); |
| 260 | 260 | |
| 261 | 261 | if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
| 262 | - $prohibited_characters = array_map(function ($value) { |
|
| 263 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
|
| 262 | + $prohibited_characters = array_map(function($value) { |
|
| 263 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; |
|
| 264 | 264 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
| 265 | 265 | $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters); |
| 266 | 266 | } |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | foreach ($this->providers as $provider_id => $provider) { |
| 309 | 309 | $login_status = $provider->login(); // OK v4.5 |
| 310 | - self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
| 310 | + self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
| 311 | 311 | if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
| 312 | 312 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
| 313 | 313 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | if (!$this->is_player_register) { |
| 348 | 348 | // Нет - отправляем на процесс регистрации |
| 349 | 349 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
| 350 | - sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
|
| 350 | + sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : '')); |
|
| 351 | 351 | } |
| 352 | 352 | } else { |
| 353 | 353 | // Да, есть доступные игроки, которые так же прописаны в базе |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if ($redirect === true) { |
| 410 | - sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
| 410 | + sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
| 411 | 411 | } elseif ($redirect !== false) { |
| 412 | 412 | sys_redirect($redirect); |
| 413 | 413 | } |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | $user['vacation'] = SN_TIME_NOW; |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
| 705 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
| 706 | 706 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
| 707 | 707 | |
| 708 | 708 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -710,9 +710,9 @@ discard block |
||
| 710 | 710 | |
| 711 | 711 | $proxy_safe = static::$db->db_escape(self::$device->ip_v4_proxy_chain); |
| 712 | 712 | |
| 713 | - DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = " . SN_TIME_NOW . ", |
|
| 714 | - `banaday` = " . static::$db->db_escape($user['banaday']) . ", `vacation` = " . static::$db->db_escape($user['vacation']) . ", |
|
| 715 | - `user_lastip` = '" . static::$db->db_escape($user['user_lastip']) . "', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = " . self::$device->browser_id |
|
| 713 | + DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = ".SN_TIME_NOW.", |
|
| 714 | + `banaday` = " . static::$db->db_escape($user['banaday']).", `vacation` = ".static::$db->db_escape($user['vacation']).", |
|
| 715 | + `user_lastip` = '" . static::$db->db_escape($user['user_lastip'])."', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = ".self::$device->browser_id |
|
| 716 | 716 | ); |
| 717 | 717 | } |
| 718 | 718 | |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | */ |
| 806 | 806 | // OK v4 |
| 807 | 807 | public static function password_encode($password, $salt) { |
| 808 | - return md5($password . $salt); |
|
| 808 | + return md5($password.$salt); |
|
| 809 | 809 | } |
| 810 | 810 | /** |
| 811 | 811 | * Генерирует соль |
@@ -831,10 +831,10 @@ discard block |
||
| 831 | 831 | } |
| 832 | 832 | list($called, $caller) = debug_backtrace(false); |
| 833 | 833 | $caller_name = |
| 834 | - (!empty($caller['class']) ? $caller['class'] : '') . |
|
| 835 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
| 836 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
| 837 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
| 834 | + (!empty($caller['class']) ? $caller['class'] : ''). |
|
| 835 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
| 836 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
| 837 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
| 838 | 838 | |
| 839 | 839 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
| 840 | 840 | |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | if ($die) { |
| 843 | 843 | // pdump($caller); |
| 844 | 844 | // pdump(debug_backtrace(false)); |
| 845 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
| 845 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
| 846 | 846 | } |
| 847 | 847 | } |
| 848 | 848 | |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) { |
| 23 | 23 | $unit_list = sn_get_groups($mode); |
| 24 | - if(empty($unit_list)) { |
|
| 24 | + if (empty($unit_list)) { |
|
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | $name_list = classLocale::$lang['tech']; |
| 28 | 28 | |
| 29 | - foreach($unit_list as $unit_id) { |
|
| 29 | + foreach ($unit_list as $unit_id) { |
|
| 30 | 30 | $template->assign_block_vars('unit', array( |
| 31 | 31 | 'ID' => $unit_id, |
| 32 | 32 | 'NAME' => $name_list[$unit_id], |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { return sn_function_call(__FUNCTION__, array($unit_id, $unit_amount, $mode)); } |
| 40 | 40 | |
| 41 | 41 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { |
| 42 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) { |
|
| 42 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) { |
|
| 43 | 43 | $unit_amount = round($unit_amount); |
| 44 | 44 | $unit_name = get_unit_param($unit_id, P_NAME); |
| 45 | 45 | $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))"; |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | $query = db_user_list("`authlevel` > 0 ORDER BY `authlevel` ASC"); |
| 17 | 17 | |
| 18 | 18 | // while($row = db_fetch($query)) |
| 19 | - foreach($query as $row) { |
|
| 19 | + foreach ($query as $row) { |
|
| 20 | 20 | $template_result['.']['contact'][] = array( |
| 21 | 21 | 'NAME' => $row['username'], |
| 22 | 22 | 'LEVEL' => classLocale::$lang['user_level'][$row['authlevel']], |
@@ -171,6 +171,10 @@ discard block |
||
| 171 | 171 | * @return bool |
| 172 | 172 | */ |
| 173 | 173 | // OK v4.5 |
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @param string $account_name_unsafe |
|
| 177 | + */ |
|
| 174 | 178 | public function db_get_by_name($account_name_unsafe) { |
| 175 | 179 | $this->reset(); |
| 176 | 180 | |
@@ -207,6 +211,11 @@ discard block |
||
| 207 | 211 | * |
| 208 | 212 | */ |
| 209 | 213 | // OK v4.5 |
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @param string $account_name_unsafe |
|
| 217 | + * @param string $email_unsafe |
|
| 218 | + */ |
|
| 210 | 219 | public function db_get_by_name_or_email($account_name_unsafe, $email_unsafe) { |
| 211 | 220 | $this->reset(); |
| 212 | 221 | |
@@ -223,6 +232,13 @@ discard block |
||
| 223 | 232 | * @throws Exception |
| 224 | 233 | */ |
| 225 | 234 | // OK v4.5 |
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * @param string $account_name_unsafe |
|
| 238 | + * @param string $password_raw |
|
| 239 | + * @param string $email_unsafe |
|
| 240 | + * @param string $language_unsafe |
|
| 241 | + */ |
|
| 226 | 242 | public function db_create($account_name_unsafe, $password_raw, $email_unsafe, $language_unsafe = null, $salt_unsafe = null) { |
| 227 | 243 | $this->reset(); |
| 228 | 244 | |
@@ -317,6 +333,11 @@ discard block |
||
| 317 | 333 | * @return int|string |
| 318 | 334 | */ |
| 319 | 335 | // OK 4.8 |
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * @param integer $change_type |
|
| 339 | + * @param double $metamatter |
|
| 340 | + */ |
|
| 320 | 341 | protected function db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe) { |
| 321 | 342 | $provider_id_safe = intval(core_auth::$main_provider->provider_id); |
| 322 | 343 | //$account_id_safe = $this->db->db_escape($this->account_id); |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | $this->reset(); |
| 80 | 80 | $this->db = is_object($db) ? $db : classSupernova::$db; |
| 81 | 81 | |
| 82 | - foreach($this->table_check as $table_name) { |
|
| 83 | - if(empty($this->db->table_list[$table_name])) { |
|
| 82 | + foreach ($this->table_check as $table_name) { |
|
| 83 | + if (empty($this->db->table_list[$table_name])) { |
|
| 84 | 84 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
| 85 | 85 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
| 86 | 86 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | // OK v4.6 |
| 106 | 106 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
| 107 | - if(!$this->password_check($old_password_unsafe)) { |
|
| 107 | + if (!$this->password_check($old_password_unsafe)) { |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | // OK v4.5 |
| 126 | 126 | public function assign_from_db_row($row) { |
| 127 | 127 | $this->reset(); |
| 128 | - if(empty($row) || !is_array($row)) { |
|
| 128 | + if (empty($row) || !is_array($row)) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | $this->account_id = $row['account_id']; |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | `account_email` = LOWER('{$email_safe}'), |
| 243 | 243 | `account_language` = '{$language_safe}'" |
| 244 | 244 | ); |
| 245 | - if(!$result) { |
|
| 245 | + if (!$result) { |
|
| 246 | 246 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if(!($account_id = $this->db->db_insert_id())) { |
|
| 249 | + if (!($account_id = $this->db->db_insert_id())) { |
|
| 250 | 250 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | WHERE `account_id` = '{$account_id_safe}'" |
| 277 | 277 | ) ? true : false; |
| 278 | 278 | |
| 279 | - if($result) { |
|
| 279 | + if ($result) { |
|
| 280 | 280 | $result = $this->db_get_by_id($this->account_id); |
| 281 | 281 | } |
| 282 | 282 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) { |
| 364 | 364 | global $mm_change_legit; |
| 365 | 365 | |
| 366 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 366 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 367 | 367 | classSupernova::$debug->error('Ошибка при попытке манипуляции с ММ'); |
| 368 | 368 | |
| 369 | 369 | return false; |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $mm_change_legit = true; |
| 375 | 375 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
| 376 | - if($already_changed) { |
|
| 376 | + if ($already_changed) { |
|
| 377 | 377 | $metamatter_total_delta = 0; |
| 378 | 378 | $result = -1; |
| 379 | 379 | } else { |
@@ -383,17 +383,17 @@ discard block |
||
| 383 | 383 | $result = $this->db->doquery( |
| 384 | 384 | "UPDATE {{account}} |
| 385 | 385 | SET |
| 386 | - `account_metamatter` = `account_metamatter` + '{$metamatter}'" . |
|
| 387 | - ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') . |
|
| 386 | + `account_metamatter` = `account_metamatter` + '{$metamatter}'". |
|
| 387 | + ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : ''). |
|
| 388 | 388 | " WHERE `account_id` = {$account_id_safe}" |
| 389 | 389 | ); |
| 390 | - if(!$result) { |
|
| 390 | + if (!$result) { |
|
| 391 | 391 | classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 392 | 392 | } |
| 393 | 393 | $result = classSupernova::$db->db_affected_rows(); |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if(empty(core_auth::$user['id'])) { |
|
| 396 | + if (empty(core_auth::$user['id'])) { |
|
| 397 | 397 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
| 398 | 398 | reset($user_list); |
| 399 | 399 | $user_id_unsafe = key($user_list); |
@@ -402,30 +402,30 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
| 404 | 404 | |
| 405 | - if(!$result) { |
|
| 405 | + if (!$result) { |
|
| 406 | 406 | classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if(!$already_changed) { |
|
| 409 | + if (!$already_changed) { |
|
| 410 | 410 | $this->account_metamatter += $metamatter; |
| 411 | 411 | $this->account_metamatter_total += $metamatter_total_delta; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if(is_array($comment)) { |
|
| 414 | + if (is_array($comment)) { |
|
| 415 | 415 | $comment = call_user_func_array('sprintf', $comment); |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
| 419 | 419 | |
| 420 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
| 420 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
| 421 | 421 | $old_referral = db_referral_get_by_id($user_id_safe); |
| 422 | - if($old_referral['id']) { |
|
| 422 | + if ($old_referral['id']) { |
|
| 423 | 423 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
| 424 | 424 | db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter); |
| 425 | 425 | $new_referral = db_referral_get_by_id($user_id_safe); |
| 426 | 426 | |
| 427 | 427 | $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0); |
| 428 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
| 428 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
| 429 | 429 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
| 430 | 430 | } |
| 431 | 431 | } |
@@ -188,6 +188,11 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | // OK v4 |
| 190 | 190 | // TODO - вынести в отдельный класс |
| 191 | +/** |
|
| 192 | + * @param string $db_id_field_name |
|
| 193 | + * @param string $db_table_name |
|
| 194 | + * @param string $db_value_field_name |
|
| 195 | + */ |
|
| 191 | 196 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
| 192 | 197 | $current_value_safe = db_escape($current_value_unsafe); |
| 193 | 198 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -220,7 +225,7 @@ discard block |
||
| 220 | 225 | |
| 221 | 226 | /** |
| 222 | 227 | * @param $user |
| 223 | - * @param $username_safe |
|
| 228 | + * @param string $username_safe |
|
| 224 | 229 | */ |
| 225 | 230 | function db_player_name_history_replace($user, $username_safe) { |
| 226 | 231 | doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user['id']}, `player_name` = '{$username_safe}'"); |
@@ -228,7 +233,7 @@ discard block |
||
| 228 | 233 | |
| 229 | 234 | |
| 230 | 235 | /** |
| 231 | - * @param $username_safe |
|
| 236 | + * @param string $username_safe |
|
| 232 | 237 | * |
| 233 | 238 | * @return array|bool|mysqli_result|null |
| 234 | 239 | */ |
@@ -485,12 +490,12 @@ discard block |
||
| 485 | 490 | |
| 486 | 491 | |
| 487 | 492 | /** |
| 488 | - * @param $user_id |
|
| 489 | - * @param $change_type |
|
| 493 | + * @param integer $user_id |
|
| 494 | + * @param integer $change_type |
|
| 490 | 495 | * @param $dark_matter |
| 491 | - * @param $comment |
|
| 496 | + * @param string $comment |
|
| 492 | 497 | * @param $row |
| 493 | - * @param $page_url |
|
| 498 | + * @param string $page_url |
|
| 494 | 499 | */ |
| 495 | 500 | function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment, $row, $page_url) { |
| 496 | 501 | doquery( |
@@ -506,7 +511,7 @@ discard block |
||
| 506 | 511 | /** |
| 507 | 512 | * @param $user_id_safe |
| 508 | 513 | * |
| 509 | - * @return array|bool|mysqli_result|null |
|
| 514 | + * @return integer |
|
| 510 | 515 | */ |
| 511 | 516 | function db_referral_get_by_id($user_id_safe) { |
| 512 | 517 | $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", true); |
@@ -534,9 +539,9 @@ discard block |
||
| 534 | 539 | |
| 535 | 540 | // Quests *********************************************************************************************************** |
| 536 | 541 | /** |
| 537 | - * @param $query_add_select |
|
| 542 | + * @param string $query_add_select |
|
| 538 | 543 | * @param $query_add_from |
| 539 | - * @param $query_add_where |
|
| 544 | + * @param string $query_add_where |
|
| 540 | 545 | * |
| 541 | 546 | * @return array|bool|mysqli_result|null |
| 542 | 547 | */ |
@@ -580,11 +585,11 @@ discard block |
||
| 580 | 585 | } |
| 581 | 586 | |
| 582 | 587 | /** |
| 583 | - * @param $quest_name |
|
| 584 | - * @param $quest_type |
|
| 585 | - * @param $quest_description |
|
| 588 | + * @param string $quest_name |
|
| 589 | + * @param integer $quest_type |
|
| 590 | + * @param string $quest_description |
|
| 586 | 591 | * @param $quest_conditions |
| 587 | - * @param $quest_rewards |
|
| 592 | + * @param string $quest_rewards |
|
| 588 | 593 | * @param $quest_id |
| 589 | 594 | */ |
| 590 | 595 | function db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id) { |
@@ -607,7 +612,7 @@ discard block |
||
| 607 | 612 | /** |
| 608 | 613 | * @param $banner |
| 609 | 614 | * @param $banned |
| 610 | - * @param $reason |
|
| 615 | + * @param string $reason |
|
| 611 | 616 | * @param $ban_until |
| 612 | 617 | */ |
| 613 | 618 | function db_ban_insert($banner, $banned, $reason, $ban_until) { |
@@ -630,7 +635,7 @@ discard block |
||
| 630 | 635 | /** |
| 631 | 636 | * @param $banner |
| 632 | 637 | * @param $banned |
| 633 | - * @param $reason |
|
| 638 | + * @param string $reason |
|
| 634 | 639 | */ |
| 635 | 640 | function db_ban_insert_unset($banner, $banned, $reason) { |
| 636 | 641 | doquery( |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
| 19 | 19 | return doquery( |
| 20 | - "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
|
| 20 | + "SELECT p.*, u.username".($table_parent_columns ? ', p1.name AS parent_name' : ''). |
|
| 21 | 21 | " FROM {{planets}} AS p |
| 22 | 22 | LEFT JOIN {{users}} AS u ON u.id = p.id_owner" . |
| 23 | - ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : '') . |
|
| 24 | - " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
| 23 | + ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : ''). |
|
| 24 | + " WHERE ".($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | function db_planet_list_search($searchtext) { |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | ORDER BY |
| 122 | 122 | sp.`{$Rank}_rank`, subject.{$source['id']} |
| 123 | 123 | LIMIT |
| 124 | - " . $start . ",100;"; |
|
| 124 | + ".$start.",100;"; |
|
| 125 | 125 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
| 126 | 126 | $query_str = |
| 127 | 127 | "SELECT |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | ORDER BY |
| 135 | 135 | subject.{$Rank} DESC, subject.{$source['id']} |
| 136 | 136 | LIMIT |
| 137 | - " . $start . ",100;"; |
|
| 137 | + ".$start.",100;"; |
|
| 138 | 138 | } |
| 139 | 139 | } else { |
| 140 | 140 | // TODO |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | ORDER BY |
| 152 | 152 | sp.`{$Rank}_rank`, subject.id |
| 153 | 153 | LIMIT |
| 154 | - " . $start . ",100;"; |
|
| 154 | + ".$start.",100;"; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return doquery($query_str); |
@@ -374,9 +374,9 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) { |
| 376 | 376 | $extra_conditions = |
| 377 | - ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') . |
|
| 378 | - ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') . |
|
| 379 | - ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') . |
|
| 377 | + ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : ''). |
|
| 378 | + ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : ''). |
|
| 379 | + ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : ''). |
|
| 380 | 380 | ($flt_module ? "AND payment_module_name = '{$flt_module}' " : ''); |
| 381 | 381 | $query = doquery("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;"); |
| 382 | 382 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | |
| 405 | 405 | // Log Online ************************************************************************************************************* |
| 406 | 406 | function db_log_online_insert() { |
| 407 | - doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . classSupernova::$config->var_online_user_count); |
|
| 407 | + doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = ".classSupernova::$config->var_online_user_count); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // Log ************************************************************************************************************* |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | `ban_user_id` = '{$banned['id']}', |
| 613 | 613 | `ban_user_name` = '{$banned['username']}', |
| 614 | 614 | `ban_reason` = '{$reason}', |
| 615 | - `ban_time` = " . SN_TIME_NOW . ", |
|
| 615 | + `ban_time` = ".SN_TIME_NOW.", |
|
| 616 | 616 | `ban_until` = {$ban_until}, |
| 617 | 617 | `ban_issuer_id` = '{$banner['id']}', |
| 618 | 618 | `ban_issuer_name` = '{$banner['username']}', |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | `ban_user_name` = '{$banned['username']}', |
| 635 | 635 | `ban_reason` = '{$reason}', |
| 636 | 636 | `ban_time` = 0, |
| 637 | - `ban_until` = " . SN_TIME_NOW . ", |
|
| 637 | + `ban_until` = ".SN_TIME_NOW.", |
|
| 638 | 638 | `ban_issuer_id` = '{$banner['id']}', |
| 639 | 639 | `ban_issuer_name` = '{$banner['username']}', |
| 640 | 640 | `ban_issuer_email` = '{$banner['email']}' |
@@ -693,9 +693,9 @@ discard block |
||
| 693 | 693 | function db_ube_report_get_best_battles() { |
| 694 | 694 | $query = doquery("SELECT * |
| 695 | 695 | FROM {{ube_report}} |
| 696 | - WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY)) |
|
| 696 | + WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY)) |
|
| 697 | 697 | ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC |
| 698 | - LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";"); |
|
| 698 | + LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";"); |
|
| 699 | 699 | |
| 700 | 700 | return $query; |
| 701 | 701 | } |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | 'factor' => 1.5, |
| 16 | 16 | ), |
| 17 | 17 | P_UNIT_PRODUCTION => array( |
| 18 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 19 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 18 | + RES_METAL => function($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 19 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 20 | 20 | ), |
| 21 | 21 | P_MINING_IS_MANAGED => true, |
| 22 | 22 | ), |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | 'factor' => 1.6, |
| 34 | 34 | ), |
| 35 | 35 | P_UNIT_PRODUCTION => array( |
| 36 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 37 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 36 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 37 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 38 | 38 | ), |
| 39 | 39 | P_MINING_IS_MANAGED => true, |
| 40 | 40 | ), |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | 'factor' => 1.5, |
| 52 | 52 | ), |
| 53 | 53 | P_UNIT_PRODUCTION => array( |
| 54 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);}, |
|
| 55 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 54 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
| 55 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 56 | 56 | ), |
| 57 | 57 | P_MINING_IS_MANAGED => true, |
| 58 | 58 | ), |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'factor' => 1.5, |
| 70 | 70 | ), |
| 71 | 71 | P_UNIT_PRODUCTION => array( |
| 72 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 72 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 73 | 73 | ), |
| 74 | 74 | P_MINING_IS_MANAGED => true, |
| 75 | 75 | ), |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | 'factor' => 1.8, |
| 88 | 88 | ), |
| 89 | 89 | P_UNIT_PRODUCTION => array( |
| 90 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 91 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor);}, |
|
| 90 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 91 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
| 92 | 92 | ), |
| 93 | 93 | P_MINING_IS_MANAGED => true, |
| 94 | 94 | ), |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'factor' => 2, |
| 106 | 106 | ), |
| 107 | 107 | 'storage' => array( |
| 108 | - RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
| 108 | + RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 109 | 109 | ), |
| 110 | 110 | ), |
| 111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | 'factor' => 2, |
| 122 | 122 | ), |
| 123 | 123 | 'storage' => array( |
| 124 | - RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
| 124 | + RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 125 | 125 | ), |
| 126 | 126 | ), |
| 127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | 'factor' => 2, |
| 138 | 138 | ), |
| 139 | 139 | 'storage' => array( |
| 140 | - RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
| 140 | + RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 141 | 141 | ), |
| 142 | 142 | ), |
| 143 | 143 | |
@@ -81,6 +81,10 @@ discard block |
||
| 81 | 81 | // ------------------------------------------------------------------------- |
| 82 | 82 | // Here comes low-level functions - those that directly works with cacher engines |
| 83 | 83 | // ------------------------------------------------------------------------- |
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @param string $name |
|
| 87 | + */ |
|
| 84 | 88 | public function __set($name, $value) { |
| 85 | 89 | switch ($name) { |
| 86 | 90 | case '_MODE': |
@@ -132,6 +136,9 @@ discard block |
||
| 132 | 136 | return null; |
| 133 | 137 | } |
| 134 | 138 | |
| 139 | + /** |
|
| 140 | + * @param string $name |
|
| 141 | + */ |
|
| 135 | 142 | public function __isset($name) { |
| 136 | 143 | switch (self::$mode) { |
| 137 | 144 | case CACHER_NO_CACHE: |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | default: |
| 99 | 99 | switch (self::$mode) { |
| 100 | 100 | case CACHER_NO_CACHE: |
| 101 | - self::$data[$this->prefix . $name] = $value; |
|
| 101 | + self::$data[$this->prefix.$name] = $value; |
|
| 102 | 102 | break; |
| 103 | 103 | |
| 104 | 104 | case CACHER_XCACHE: |
| 105 | - xcache_set($this->prefix . $name, $value); |
|
| 105 | + xcache_set($this->prefix.$name, $value); |
|
| 106 | 106 | break; |
| 107 | 107 | } |
| 108 | 108 | break; |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | default: |
| 123 | 123 | switch (self::$mode) { |
| 124 | 124 | case CACHER_NO_CACHE: |
| 125 | - return self::$data[$this->prefix . $name]; |
|
| 125 | + return self::$data[$this->prefix.$name]; |
|
| 126 | 126 | break; |
| 127 | 127 | |
| 128 | 128 | case CACHER_XCACHE: |
| 129 | - return xcache_get($this->prefix . $name); |
|
| 129 | + return xcache_get($this->prefix.$name); |
|
| 130 | 130 | break; |
| 131 | 131 | |
| 132 | 132 | } |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | public function __isset($name) { |
| 140 | 140 | switch (self::$mode) { |
| 141 | 141 | case CACHER_NO_CACHE: |
| 142 | - return isset(self::$data[$this->prefix . $name]); |
|
| 142 | + return isset(self::$data[$this->prefix.$name]); |
|
| 143 | 143 | break; |
| 144 | 144 | |
| 145 | 145 | case CACHER_XCACHE: |
| 146 | - return xcache_isset($this->prefix . $name) && ($this->__get($name) !== null); |
|
| 146 | + return xcache_isset($this->prefix.$name) && ($this->__get($name) !== null); |
|
| 147 | 147 | break; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,25 +153,25 @@ discard block |
||
| 153 | 153 | public function __unset($name) { |
| 154 | 154 | switch (self::$mode) { |
| 155 | 155 | case CACHER_NO_CACHE: |
| 156 | - unset(self::$data[$this->prefix . $name]); |
|
| 156 | + unset(self::$data[$this->prefix.$name]); |
|
| 157 | 157 | break; |
| 158 | 158 | |
| 159 | 159 | case CACHER_XCACHE: |
| 160 | - xcache_unset($this->prefix . $name); |
|
| 160 | + xcache_unset($this->prefix.$name); |
|
| 161 | 161 | break; |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function unset_by_prefix($prefix_unset = '') { |
| 166 | 166 | static $array_clear; |
| 167 | - !$array_clear ? $array_clear = function (&$v, $k, $p) { |
|
| 167 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
| 168 | 168 | strpos($k, $p) === 0 ? $v = null : false; |
| 169 | 169 | } : false; |
| 170 | 170 | |
| 171 | 171 | switch (self::$mode) { |
| 172 | 172 | case CACHER_NO_CACHE: |
| 173 | 173 | // array_walk(self::$data, create_function('&$v,$k,$p', 'if(strpos($k, $p) === 0)$v = NULL;'), $this->prefix.$prefix_unset); |
| 174 | - array_walk(self::$data, $array_clear, $this->prefix . $prefix_unset); |
|
| 174 | + array_walk(self::$data, $array_clear, $this->prefix.$prefix_unset); |
|
| 175 | 175 | |
| 176 | 176 | return true; |
| 177 | 177 | break; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - return xcache_unset_by_prefix($this->prefix . $prefix_unset); |
|
| 184 | + return xcache_unset_by_prefix($this->prefix.$prefix_unset); |
|
| 185 | 185 | break; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | if ($this->$name[0] === null) { |
| 220 | 220 | for ($i = count($name) - 1; $i > 0; $i--) { |
| 221 | 221 | $cName = "{$name[$i]}_COUNT"; |
| 222 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
| 222 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
| 223 | 223 | if ($this->$cName1 == null || $i == 1) { |
| 224 | 224 | $this->$cName++; |
| 225 | 225 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | for ($i = 1; $i < count($name); $i++) { |
| 266 | 266 | $cName = "{$name[$i]}_COUNT"; |
| 267 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
| 267 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
| 268 | 268 | |
| 269 | 269 | if ($i == 1 || $this->$cName1 === null) { |
| 270 | 270 | $this->$cName--; |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | $qry[] = "('{$item_name}', '{$item_value}')"; |
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | - doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
|
| 403 | + doquery("REPLACE INTO `{{".$this->table_name."}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES ".implode(',', $qry).";"); |
|
| 404 | 404 | |
| 405 | 405 | // И только после взятия блокировок - меняем значения в кэше |
| 406 | 406 | foreach ($item_list as $item_name => $item_value) { |
@@ -600,9 +600,9 @@ discard block |
||
| 600 | 600 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
| 601 | 601 | |
| 602 | 602 | // Alliance bonus calculations |
| 603 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
| 603 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
| 604 | 604 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
| 605 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
| 605 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
| 606 | 606 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
| 607 | 607 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
| 608 | 608 | |
@@ -633,25 +633,25 @@ discard block |
||
| 633 | 633 | 'deuterium_basic_income' => 0, |
| 634 | 634 | 'eco_scale_storage' => 1, |
| 635 | 635 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
| 636 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
| 636 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
| 637 | 637 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
| 638 | 638 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
| 639 | 639 | 'energy_basic_income' => 0, |
| 640 | 640 | |
| 641 | 641 | // Bashing protection settings |
| 642 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
| 643 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
| 644 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
| 645 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
| 646 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
| 642 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
| 643 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
| 644 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
| 645 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
| 646 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
| 647 | 647 | |
| 648 | 648 | 'Fleet_Cdr' => 30, |
| 649 | 649 | 'fleet_speed' => 1, |
| 650 | 650 | |
| 651 | 651 | 'fleet_update_interval' => 4, |
| 652 | 652 | |
| 653 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
| 654 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
| 653 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
| 654 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
| 655 | 655 | // Defaults |
| 656 | 656 | 'game_default_language' => 'ru', |
| 657 | 657 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -665,13 +665,13 @@ discard block |
||
| 665 | 665 | 'game_maxSystem' => 199, |
| 666 | 666 | 'game_maxPlanet' => 15, |
| 667 | 667 | // Game global settings |
| 668 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
| 668 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
| 669 | 669 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
| 670 | 670 | |
| 671 | 671 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
| 672 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
| 672 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
| 673 | 673 | // Noob protection |
| 674 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
| 674 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
| 675 | 675 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
| 676 | 676 | |
| 677 | 677 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -721,8 +721,8 @@ discard block |
||
| 721 | 721 | 'payment_currency_exchange_wmu' => 30, |
| 722 | 722 | 'payment_currency_exchange_wmz' => 1, |
| 723 | 723 | |
| 724 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
| 725 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
| 724 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
| 725 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
| 726 | 726 | |
| 727 | 727 | 'planet_teleport_cost' => 50000, // |
| 728 | 728 | 'planet_teleport_timeout' => 86400, // |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | 'resource_multiplier' => 1, |
| 741 | 741 | |
| 742 | 742 | //Roleplay system |
| 743 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
| 743 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
| 744 | 744 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
| 745 | 745 | |
| 746 | 746 | // Black Market - General |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | 'GROUP BY `unit_snid`' |
| 27 | 27 | ); |
| 28 | 28 | $result = array(); |
| 29 | - while($row = db_fetch($query)) { |
|
| 29 | + while ($row = db_fetch($query)) { |
|
| 30 | 30 | $result[$row['unit_snid']] = $row; |
| 31 | 31 | } |
| 32 | 32 | |