@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * @return mixed |
| 14 | 14 | * @deprecated |
| 15 | 15 | */ |
| 16 | -function RestoreFleetToPlanet(&$fleet_row, $start = true, $only_resources = false, $safe_fleet = false){return sn_function_call('RestoreFleetToPlanet', array(&$fleet_row, $start, $only_resources, $safe_fleet, &$result));} |
|
| 16 | +function RestoreFleetToPlanet(&$fleet_row, $start = true, $only_resources = false, $safe_fleet = false) {return sn_function_call('RestoreFleetToPlanet', array(&$fleet_row, $start, $only_resources, $safe_fleet, &$result)); } |
|
| 17 | 17 | /** |
| 18 | 18 | * @param array $fleet_row |
| 19 | 19 | * @param bool $start |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -function sn_chat_model() |
|
| 8 | -{ |
|
| 7 | +function sn_chat_model() { |
|
| 9 | 8 | global $config, $user, $template_result, $lang; |
| 10 | 9 | |
| 11 | 10 | $config->array_set('users', $user['id'], 'chat_last_activity', SN_TIME_MICRO); |
@@ -44,15 +43,13 @@ discard block |
||
| 44 | 43 | |
| 45 | 44 | $template_result['PAGE_HEADER'] = $page_title; |
| 46 | 45 | } |
| 47 | -function sn_chat_view($template = null) |
|
| 48 | -{ |
|
| 46 | +function sn_chat_view($template = null) { |
|
| 49 | 47 | $template = gettemplate('chat_body', $template); |
| 50 | 48 | |
| 51 | 49 | return $template; |
| 52 | 50 | } |
| 53 | 51 | |
| 54 | -function sn_chat_add_model() |
|
| 55 | -{ |
|
| 52 | +function sn_chat_add_model() { |
|
| 56 | 53 | global $config, $user; |
| 57 | 54 | |
| 58 | 55 | define('IN_AJAX', true); |
@@ -76,8 +73,7 @@ discard block |
||
| 76 | 73 | |
| 77 | 74 | die(); |
| 78 | 75 | } |
| 79 | -function sn_chat_msg_view($template = null) |
|
| 80 | -{ |
|
| 76 | +function sn_chat_msg_view($template = null) { |
|
| 81 | 77 | global $config, $user, $lang; |
| 82 | 78 | |
| 83 | 79 | define('IN_AJAX', true); |
@@ -99,8 +95,7 @@ discard block |
||
| 99 | 95 | 'TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), |
| 100 | 96 | 'DISABLE' => true, |
| 101 | 97 | ); |
| 102 | - } |
|
| 103 | - else |
|
| 98 | + } else |
|
| 104 | 99 | { |
| 105 | 100 | $alliance = sys_get_param_str('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
| 106 | 101 | |
@@ -121,8 +116,7 @@ discard block |
||
| 121 | 116 | } |
| 122 | 117 | |
| 123 | 118 | $page = min($page_count, max(0, sys_get_param_int('sheet'))); |
| 124 | - } |
|
| 125 | - else |
|
| 119 | + } else |
|
| 126 | 120 | { |
| 127 | 121 | $last_message = sys_get_param_id('last_message'); |
| 128 | 122 | $where_add = $last_message ? "AND `messageid` > {$last_message}" : ''; |
@@ -171,8 +165,7 @@ discard block |
||
| 171 | 165 | { |
| 172 | 166 | $pageTitle = "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}"; |
| 173 | 167 | display($template, $pageTitle); |
| 174 | - } |
|
| 175 | - else |
|
| 168 | + } else |
|
| 176 | 169 | { |
| 177 | 170 | $result['last_message'] = $last_message; |
| 178 | 171 | $result['html'] = templateRenderToHtml($template); |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; |
| 15 | 15 | |
| 16 | 16 | $mode = sys_get_param_int('mode'); |
| 17 | - switch($mode) |
|
| 17 | + switch ($mode) |
|
| 18 | 18 | { |
| 19 | 19 | case CHAT_MODE_ALLY: |
| 20 | 20 | $template_result['ALLY'] = intval($user['ally_id']); |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $template_result['.']['smiles'] = array(); |
| 31 | - foreach(SN::$gc->design->getSmilesList() as $auth_level => $replaces) { |
|
| 32 | - if($auth_level > $user_auth_level) { |
|
| 31 | + foreach (SN::$gc->design->getSmilesList() as $auth_level => $replaces) { |
|
| 32 | + if ($auth_level > $user_auth_level) { |
|
| 33 | 33 | continue; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - foreach($replaces as $bbcode => $filename) |
|
| 36 | + foreach ($replaces as $bbcode => $filename) |
|
| 37 | 37 | { |
| 38 | 38 | $template_result['.']['smiles'][] = array( |
| 39 | 39 | 'BBCODE' => $bbcode, |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | define('IN_AJAX', true); |
| 59 | 59 | |
| 60 | - if($config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
| 60 | + if ($config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
| 61 | 61 | { |
| 62 | 62 | die(); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if(($message = sys_get_param_str('message')) && $user['username']) |
|
| 65 | + if (($message = sys_get_param_str('message')) && $user['username']) |
|
| 66 | 66 | { |
| 67 | 67 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
| 68 | 68 | $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id)))); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | define('IN_AJAX', true); |
| 88 | 88 | |
| 89 | 89 | $history = sys_get_param_str('history'); |
| 90 | - if(!$history) |
|
| 90 | + if (!$history) |
|
| 91 | 91 | { |
| 92 | 92 | $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
| 93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $last_message = ''; |
| 97 | 97 | $alliance = 0; |
| 98 | 98 | $template_result['.']['chat'] = array(); |
| 99 | - if(!$history && $config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
| 99 | + if (!$history && $config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
| 100 | 100 | { |
| 101 | 101 | $result['disable'] = true; |
| 102 | 102 | $template_result['.']['chat'][] = array( |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $where_add = ''; |
| 114 | 114 | $last_message = 0; |
| 115 | - if($history) |
|
| 115 | + if ($history) |
|
| 116 | 116 | { |
| 117 | 117 | $rows = doquery("SELECT count(1) AS CNT FROM {{chat}} WHERE ally_id = '{$alliance}';", true); |
| 118 | 118 | $page_count = ceil($rows['CNT'] / $page_limit); |
| 119 | 119 | |
| 120 | - for($i = 0; $i < $page_count; $i++) |
|
| 120 | + for ($i = 0; $i < $page_count; $i++) |
|
| 121 | 121 | { |
| 122 | 122 | $template_result['.']['page'][] = array( |
| 123 | 123 | 'NUMBER' => $i |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | {{chat}} AS c |
| 140 | 140 | LEFT JOIN {{users}} AS u ON u.id = c.chat_message_sender_id |
| 141 | 141 | WHERE c.chat_message_recipient_id IS NULL AND c.ally_id = '{$alliance}' {$where_add} ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};"); |
| 142 | - while($chat_row = db_fetch($query)) |
|
| 142 | + while ($chat_row = db_fetch($query)) |
|
| 143 | 143 | { |
| 144 | 144 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
| 145 | 145 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $template = gettemplate('chat_messages', $template); |
| 169 | 169 | $template->assign_recursive($template_result); |
| 170 | 170 | |
| 171 | - if($history) |
|
| 171 | + if ($history) |
|
| 172 | 172 | { |
| 173 | 173 | $pageTitle = "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}"; |
| 174 | 174 | display($template, $pageTitle); |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @return array |
| 241 | 241 | */ |
| 242 | 242 | public static function parseParamStrings($array, $delimiter = '=') { |
| 243 | - !is_array($array) ? $array = array((string)$array) : false; |
|
| 243 | + !is_array($array) ? $array = array((string) $array) : false; |
|
| 244 | 244 | |
| 245 | 245 | $result = array(); |
| 246 | 246 | foreach ($array as $param) { |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | * @return float|null |
| 263 | 263 | */ |
| 264 | 264 | public static function maxValueByField(&$array, $fieldName) { |
| 265 | - return array_reduce($array, function ($carry, $item) use ($fieldName) { |
|
| 266 | - if(is_array($item) && isset($item[$fieldName]) && (!isset($carry) || $carry < $item[$fieldName])) { |
|
| 265 | + return array_reduce($array, function($carry, $item) use ($fieldName) { |
|
| 266 | + if (is_array($item) && isset($item[$fieldName]) && (!isset($carry) || $carry < $item[$fieldName])) { |
|
| 267 | 267 | $carry = $item[$fieldName]; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | return |
| 282 | 282 | array_reduce($array, |
| 283 | - function ($carry, $item) use (&$fieldName, $maxValue) { |
|
| 284 | - if(is_array($item) && isset($item[$fieldName]) && $item[$fieldName] == $maxValue) { |
|
| 283 | + function($carry, $item) use (&$fieldName, $maxValue) { |
|
| 284 | + if (is_array($item) && isset($item[$fieldName]) && $item[$fieldName] == $maxValue) { |
|
| 285 | 285 | $carry[] = $item; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | public static function intersectByKeys(array &$array1, array &$array2) { |
| 295 | - return array_uintersect_assoc($array1, $array2, function ($a, $b) {return 0;}); |
|
| 295 | + return array_uintersect_assoc($array1, $array2, function($a, $b) {return 0; }); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | } |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $prefix_length = strlen($this->db->db_prefix); |
| 54 | 54 | |
| 55 | - while($row = $this->db->db_fetch($query)) { |
|
| 56 | - foreach($row as $table_name) { |
|
| 55 | + while ($row = $this->db->db_fetch($query)) { |
|
| 56 | + foreach ($row as $table_name) { |
|
| 57 | 57 | $this->tablesAll[$table_name] = $table_name; |
| 58 | 58 | |
| 59 | - if(strpos($table_name, $this->db->db_prefix) === 0) { |
|
| 59 | + if (strpos($table_name, $this->db->db_prefix) === 0) { |
|
| 60 | 60 | $table_name_sn = substr($table_name, $prefix_length); |
| 61 | 61 | $this->tablesSn[$table_name_sn] = $table_name_sn; |
| 62 | 62 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @return \string[] |
| 71 | 71 | */ |
| 72 | 72 | public function getAllTables() { |
| 73 | - if(!isset($this->tablesAll)) { |
|
| 73 | + if (!isset($this->tablesAll)) { |
|
| 74 | 74 | $this->loadTableNamesFromDb(); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return string[] |
| 84 | 84 | */ |
| 85 | 85 | public function getSnTables() { |
| 86 | - if(!isset($this->tablesSn)) { |
|
| 86 | + if (!isset($this->tablesSn)) { |
|
| 87 | 87 | $this->loadTableNamesFromDb(); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @return TableSchema |
| 108 | 108 | */ |
| 109 | 109 | public function getTableSchema($tableName) { |
| 110 | - if(empty($this->tableSchemas[$tableName])) { |
|
| 110 | + if (empty($this->tableSchemas[$tableName])) { |
|
| 111 | 111 | $this->tableSchemas[$tableName] = new TableSchema($tableName, $this); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | protected $_repository; |
| 31 | 31 | |
| 32 | - /** |
|
| 32 | + /** |
|
| 33 | 33 | * @var ContainerPlus $_oldRepo |
| 34 | 34 | */ |
| 35 | 35 | protected $_oldRepo; |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | |
| 87 | 87 | public function get($entityClass, $id) { |
| 88 | 88 | $entityIndex = get_class($entityClass) . '\\' . $id; |
| 89 | - if(!isset($this->_repository[$entityIndex])) { |
|
| 89 | + if (!isset($this->_repository[$entityIndex])) { |
|
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | $config->pass()->game_disable = GAME_DISABLE_STAT; |
| 59 | 59 | |
| 60 | 60 | $statMinimalInterval = intval($config->pass()->stats_minimal_interval); |
| 61 | - $config->pass()->var_stat_update_end= date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
| 61 | + $config->pass()->var_stat_update_end = date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
| 62 | 62 | $config->pass()->var_stat_update_msg = 'Update started'; |
| 63 | 63 | sn_db_transaction_commit(); |
| 64 | 64 | |
@@ -22,11 +22,11 @@ |
||
| 22 | 22 | |
| 23 | 23 | define('IN_AJAX', true); |
| 24 | 24 | |
| 25 | -if(($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) { |
|
| 25 | +if (($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) { |
|
| 26 | 26 | $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); |
| 27 | 27 | print(json_encode($result)); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -if(!defined('IN_ADMIN')) { |
|
| 30 | +if (!defined('IN_ADMIN')) { |
|
| 31 | 31 | die(); |
| 32 | 32 | } |
@@ -75,11 +75,11 @@ |
||
| 75 | 75 | * @return float[] - [int resourceId] -> [float ratesNormalizedToResourceCost] |
| 76 | 76 | */ |
| 77 | 77 | public function getResourceExchangeIn($resourceId) { |
| 78 | - if(empty($this->resourceExchangeRates[$resourceId])) { |
|
| 78 | + if (empty($this->resourceExchangeRates[$resourceId])) { |
|
| 79 | 79 | $defaultRates = $this->getResourcesExchange(); |
| 80 | 80 | |
| 81 | 81 | $this->resourceExchangeRates[$resourceId] = []; |
| 82 | - foreach($defaultRates as $defaultResourceId => $defaultRate) { |
|
| 82 | + foreach ($defaultRates as $defaultResourceId => $defaultRate) { |
|
| 83 | 83 | $this->resourceExchangeRates[$resourceId][$defaultResourceId] = $defaultRate / $defaultRates[$resourceId]; |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -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 | } |