@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | define('IN_ADMIN', true); |
4 | 4 | |
5 | -require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
|
5 | +require('../includes/init.'.substr(strrchr(__FILE__, '.'), 1)); |
|
6 | 6 | |
7 | -if($user['authlevel'] < 3) |
|
7 | +if ($user['authlevel'] < 3) |
|
8 | 8 | { |
9 | 9 | message(classLocale::$lang['sys_noalloaw'], classLocale::$lang['sys_noaccess']); |
10 | 10 | die(); |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | // [#] info_best_battles 1b0 |
21 | 21 | $best_reports = array(); |
22 | 22 | |
23 | -if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
23 | +if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
24 | 24 | $query = db_ube_report_get_best_battles(); |
25 | - while($row = db_fetch($query)) { |
|
25 | + while ($row = db_fetch($query)) { |
|
26 | 26 | $best_reports[] = $row['ube_report_id']; |
27 | 27 | } |
28 | 28 | } |
29 | -$best_reports = !empty($best_reports) ? ' AND ube_report_id NOT IN (' . implode(',', $best_reports) . ')' : ''; |
|
29 | +$best_reports = !empty($best_reports) ? ' AND ube_report_id NOT IN ('.implode(',', $best_reports).')' : ''; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | $ques = array( |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | // Удаляем юниты без планет |
91 | 91 | 'DELETE un FROM {{unit}} AS un |
92 | 92 | LEFT JOIN {{planets}} AS pl ON pl.id = un.unit_location_id |
93 | - WHERE unit_location_type = ' . LOC_PLANET . ' AND pl.id IS NULL;', |
|
93 | + WHERE unit_location_type = ' . LOC_PLANET.' AND pl.id IS NULL;', |
|
94 | 94 | // Удаляем пустые юниты с 0 уровнем (кроме Капитана) |
95 | - 'DELETE FROM {{unit}} WHERE unit_location_type = ' . LOC_PLANET . ' AND unit_level = 0 AND unit_type <> ' . UNIT_CAPTAIN, |
|
95 | + 'DELETE FROM {{unit}} WHERE unit_location_type = '.LOC_PLANET.' AND unit_level = 0 AND unit_type <> '.UNIT_CAPTAIN, |
|
96 | 96 | // Удаляем очереди на ничьих планетах |
97 | 97 | 'DELETE q FROM {{que}} AS q |
98 | 98 | LEFT JOIN {{planets}} AS p ON p.id = q.que_planet_id |
99 | 99 | WHERE |
100 | - que_type IN (' . QUE_STRUCTURES . ', ' . QUE_HANGAR . ', ' . SUBQUE_FLEET . ', ' . SUBQUE_DEFENSE . ') |
|
100 | + que_type IN (' . QUE_STRUCTURES.', '.QUE_HANGAR.', '.SUBQUE_FLEET.', '.SUBQUE_DEFENSE.') |
|
101 | 101 | AND |
102 | 102 | (p.id_owner = 0 OR p.id_owner IS NULL);', |
103 | 103 | |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | // Удаляются сообщения, старше 4 недель, кроме личных и Альянсовских |
113 | 113 | 'DELETE FROM {{messages}} WHERE |
114 | 114 | UNIX_TIMESTAMP() - message_time > 4*7 * 24 * 60 * 60 AND |
115 | - message_type NOT IN (' . MSG_TYPE_PLAYER . ', ' . MSG_TYPE_ALLIANCE . ');', |
|
115 | + message_type NOT IN (' . MSG_TYPE_PLAYER.', '.MSG_TYPE_ALLIANCE.');', |
|
116 | 116 | // Удаляются сообщения у пользователей, которые неактивны больше 4 недель - кроме личных и Альянсовских |
117 | 117 | 'DELETE m FROM `{{users}}` AS u |
118 | 118 | JOIN {{messages}} AS m ON m.message_owner = u.id |
119 | 119 | WHERE |
120 | - message_type NOT IN (' . MSG_TYPE_PLAYER . ', ' . MSG_TYPE_ALLIANCE . ') AND |
|
120 | + message_type NOT IN (' . MSG_TYPE_PLAYER.', '.MSG_TYPE_ALLIANCE.') AND |
|
121 | 121 | authlevel = 0 AND user_as_ally IS NULL AND /* Не админы, Не Альянсы */ |
122 | 122 | UNIX_TIMESTAMP() - onlinetime > 4*7 *86400;', |
123 | 123 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | (log_dark_matter_timestamp, log_dark_matter_username, log_dark_matter_reason, log_dark_matter_amount, |
138 | 138 | log_dark_matter_comment, log_dark_matter_page, log_dark_matter_sender) |
139 | 139 | SELECT |
140 | - '{$pack_until}', IF(u.username IS NULL, ldm.log_dark_matter_username, u.username), " . RPG_CUMULATIVE . ", sum(ldm.log_dark_matter_amount), |
|
140 | + '{$pack_until}', IF(u.username IS NULL, ldm.log_dark_matter_username, u.username), ".RPG_CUMULATIVE.", sum(ldm.log_dark_matter_amount), |
|
141 | 141 | 'Баланс на {$pack_until}', 'admin/ajax_maintenance.php', ldm.log_dark_matter_sender |
142 | 142 | FROM |
143 | 143 | {{log_dark_matter}} AS ldm |
@@ -155,22 +155,22 @@ discard block |
||
155 | 155 | "REPLACE INTO `{{log_users_online}}` |
156 | 156 | (online_timestamp, online_count, online_aggregated) |
157 | 157 | SELECT |
158 | - FROM_UNIXTIME((UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10 . ") * (" . PERIOD_MINUTE_10 . ")), ceil(avg(online_count)), " . LOG_ONLIINE_AGGREGATE_PERIOD_MINUTE_10 . " |
|
158 | + FROM_UNIXTIME((UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10.") * (".PERIOD_MINUTE_10.")), ceil(avg(online_count)), ".LOG_ONLIINE_AGGREGATE_PERIOD_MINUTE_10." |
|
159 | 159 | FROM |
160 | 160 | `{{log_users_online}}` |
161 | 161 | WHERE |
162 | - online_timestamp < '{$pack_until}' AND online_aggregated = " . LOG_ONLIINE_AGGREGATE_NONE . " |
|
162 | + online_timestamp < '{$pack_until}' AND online_aggregated = ".LOG_ONLIINE_AGGREGATE_NONE." |
|
163 | 163 | GROUP BY |
164 | - (UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10 . ") * (" . PERIOD_MINUTE_10 . ");", |
|
164 | + (UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10.") * (".PERIOD_MINUTE_10.");", |
|
165 | 165 | |
166 | - "DELETE FROM {{log_users_online}} WHERE online_timestamp < '{$pack_until}' AND online_aggregated = " . LOG_ONLIINE_AGGREGATE_NONE, |
|
166 | + "DELETE FROM {{log_users_online}} WHERE online_timestamp < '{$pack_until}' AND online_aggregated = ".LOG_ONLIINE_AGGREGATE_NONE, |
|
167 | 167 | ), |
168 | 168 | |
169 | 169 | // Удаляем старые записи из логов |
170 | 170 | "DELETE FROM `{{logs}}` WHERE log_timestamp < '{$pack_until}';", |
171 | 171 | // Удаляем записи о маинтенансе, апдейте и пересчете статистики более чем недельной давности - они нам уже не нужны |
172 | 172 | 'DELETE FROM `{{logs}}` WHERE |
173 | - `log_code` IN (' . LOG_INFO_DB_CHANGE . ', ' . LOG_INFO_MAINTENANCE . ', ' . LOG_INFO_STAT_START . ', ' . LOG_INFO_STAT_PROCESS . ', ' . LOG_INFO_STAT_FINISH . ') |
|
173 | + `log_code` IN (' . LOG_INFO_DB_CHANGE.', '.LOG_INFO_MAINTENANCE.', '.LOG_INFO_STAT_START.', '.LOG_INFO_STAT_PROCESS.', '.LOG_INFO_STAT_FINISH.') |
|
174 | 174 | AND `log_timestamp` < DATE_SUB(NOW(),INTERVAL 7 DAY);', |
175 | 175 | |
176 | 176 | |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | $old_server_status == GAME_DISABLE_NONE ? classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false; |
190 | 190 | sn_db_transaction_commit(); |
191 | 191 | |
192 | -foreach($ques as $que_transaction) { |
|
192 | +foreach ($ques as $que_transaction) { |
|
193 | 193 | sn_db_transaction_start(); |
194 | 194 | |
195 | 195 | !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false; |
196 | - foreach($que_transaction as $que) { |
|
196 | + foreach ($que_transaction as $que) { |
|
197 | 197 | set_time_limit(120); |
198 | - if(is_callable($que)) { |
|
198 | + if (is_callable($que)) { |
|
199 | 199 | $QryResult = call_user_func($que); |
200 | 200 | } else { |
201 | 201 | $QryResult = doquery($que); |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | //$que = str_replace('}}', '', $que); |
207 | 207 | |
208 | 208 | $msg .= |
209 | - '<li>' . htmlspecialchars($que) . |
|
210 | - ' --- <span style="' . ($QryResult ? 'ok">OK' : 'error">FAILED!') . '</span> ' . |
|
211 | - classSupernova::$db->db_affected_rows() . ' ' . classLocale::$lang['adm_records'] . |
|
209 | + '<li>'.htmlspecialchars($que). |
|
210 | + ' --- <span style="'.($QryResult ? 'ok">OK' : 'error">FAILED!').'</span> '. |
|
211 | + classSupernova::$db->db_affected_rows().' '.classLocale::$lang['adm_records']. |
|
212 | 212 | "</li>"; |
213 | 213 | |
214 | - classSupernova::$debug->warning($que . ' --- ' . ($QryResult ? 'OK' : 'FAILED!') . ' ' . classSupernova::$db->db_affected_rows() . ' ' . classLocale::$lang['adm_records'], 'System maintenance', LOG_INFO_MAINTENANCE); |
|
214 | + classSupernova::$debug->warning($que.' --- '.($QryResult ? 'OK' : 'FAILED!').' '.classSupernova::$db->db_affected_rows().' '.classLocale::$lang['adm_records'], 'System maintenance', LOG_INFO_MAINTENANCE); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | sn_db_transaction_commit(); |
@@ -239,5 +239,5 @@ discard block |
||
239 | 239 | |
240 | 240 | $adm_stat_title = classLocale::$lang['adm_stat_title']; |
241 | 241 | $result = $result ? "<li>{$adm_stat_title} - {$result}</li>" : ''; |
242 | -$result = '<div align="left"><ul>' . $msg . $result . '</ul></div>'; |
|
243 | -echo json_encode($result . ' ' . $totaltime); |
|
242 | +$result = '<div align="left"><ul>'.$msg.$result.'</ul></div>'; |
|
243 | +echo json_encode($result.' '.$totaltime); |
@@ -12,24 +12,24 @@ discard block |
||
12 | 12 | global $template_result, $user; |
13 | 13 | |
14 | 14 | // Напоминание для Администрации, что игра отключена |
15 | -if($template_result[F_GAME_DISABLE]) { |
|
15 | +if ($template_result[F_GAME_DISABLE]) { |
|
16 | 16 | echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>'; |
17 | 17 | } |
18 | 18 | unset($disable_reason); |
19 | 19 | |
20 | 20 | |
21 | -if(defined('IN_ADMIN') && IN_ADMIN === true) { |
|
21 | +if (defined('IN_ADMIN') && IN_ADMIN === true) { |
|
22 | 22 | lng_include('admin'); |
23 | -} elseif($sys_user_logged_in) { |
|
23 | +} elseif ($sys_user_logged_in) { |
|
24 | 24 | sys_user_vacation($user); |
25 | 25 | |
26 | 26 | $planet_id = SetSelectedPlanet($user); |
27 | 27 | |
28 | 28 | // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!! |
29 | - if($user['ally_id']) { |
|
29 | + if ($user['ally_id']) { |
|
30 | 30 | sn_db_transaction_start(); |
31 | 31 | sn_ali_fill_user_ally($user); |
32 | - if(!$user['ally']['player']['id']) { |
|
32 | + if (!$user['ally']['player']['id']) { |
|
33 | 33 | // sn_sys_logout(false, true); |
34 | 34 | // core_auth::logout(false); |
35 | 35 | classSupernova::$auth->logout(false); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | // TODO UNCOMMENT |
39 | 39 | que_process($user['ally']['player']); |
40 | - DBStaticUser::db_user_set_by_id($user['ally']['player']['id'], '`onlinetime` = ' . SN_TIME_NOW); |
|
40 | + DBStaticUser::db_user_set_by_id($user['ally']['player']['id'], '`onlinetime` = '.SN_TIME_NOW); |
|
41 | 41 | sn_db_transaction_commit(); |
42 | 42 | } |
43 | 43 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
50 | 50 | $planetrow = $global_data['planet']; |
51 | - if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
51 | + if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
52 | 52 | // sn_sys_logout(false, true); |
53 | 53 | // core_auth::logout(false); |
54 | 54 | classSupernova::$auth->logout(false); |
@@ -3,22 +3,22 @@ discard block |
||
3 | 3 | define('INSIDE', true); |
4 | 4 | define('INSTALL', false); |
5 | 5 | define('IN_ADMIN', true); |
6 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
6 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
7 | 7 | |
8 | -if($user['authlevel'] < 3) { |
|
8 | +if ($user['authlevel'] < 3) { |
|
9 | 9 | AdminMessage(classLocale::$lang['adm_err_denied']); |
10 | 10 | } |
11 | 11 | |
12 | 12 | lng_include('admin'); |
13 | 13 | |
14 | 14 | $user_id = sys_get_param_id('uid'); |
15 | -if(!($user_row = DBStaticUser::db_user_by_id($user_id))) { |
|
15 | +if (!($user_row = DBStaticUser::db_user_by_id($user_id))) { |
|
16 | 16 | AdminMessage(sprintf(classLocale::$lang['adm_dm_user_none'], $user_id)); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $template = gettemplate('admin/admin_user', true); |
20 | 20 | |
21 | -if(!empty($user_row['user_last_browser_id'])) { |
|
21 | +if (!empty($user_row['user_last_browser_id'])) { |
|
22 | 22 | $user_row['browser_user_agent'] = db_browser_agent_get_by_id($user_row['user_last_browser_id']); |
23 | 23 | } |
24 | 24 | |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | 'raidsloose', |
55 | 55 | 'raidswin', |
56 | 56 | 'total_rank', |
57 | - 'total_points', ), |
|
57 | + 'total_points',), |
|
58 | 58 | ); |
59 | -foreach($formats as $callable => $field_list) { |
|
60 | - foreach($field_list as $field_name) { |
|
59 | +foreach ($formats as $callable => $field_list) { |
|
60 | + foreach ($field_list as $field_name) { |
|
61 | 61 | $user_row[$field_name] = call_user_func($callable, $user_row[$field_name]); |
62 | 62 | } |
63 | 63 | } |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | $announce_list = db_news_list_get_by_query($template, $query_where, $query_limit); |
12 | 12 | |
13 | 13 | $users = array(); |
14 | - while($announce = db_fetch($announce_list)) { |
|
15 | - if($announce['user_id'] && !isset($users[$announce['user_id']])) { |
|
14 | + while ($announce = db_fetch($announce_list)) { |
|
15 | + if ($announce['user_id'] && !isset($users[$announce['user_id']])) { |
|
16 | 16 | $users[$announce['user_id']] = DBStaticUser::db_user_by_id($announce['user_id']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $survey_vote = array('survey_vote_id' => 1); |
20 | 20 | $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW; |
21 | 21 | |
22 | - if($announce['survey_id'] && !empty($user['id'])) { |
|
22 | + if ($announce['survey_id'] && !empty($user['id'])) { |
|
23 | 23 | $survey_vote = !$survey_complete ? db_survey_get_vote($announce, $user) : array(); |
24 | 24 | } |
25 | 25 | |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | 'ANNOUNCE' => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])), |
32 | 32 | 'DETAIL_URL' => $announce['detail_url'], |
33 | 33 | 'USER_NAME' => |
34 | - isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : |
|
35 | - js_safe_string($announce['user_name']), |
|
34 | + isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']), |
|
36 | 35 | 'NEW' => $announce['unix_time'] + classSupernova::$config->game_news_actual >= SN_TIME_NOW, |
37 | 36 | 'FUTURE' => $announce['unix_time'] > SN_TIME_NOW, |
38 | 37 | 'SURVEY_ID' => $announce['survey_id'], |
@@ -42,25 +41,25 @@ discard block |
||
42 | 41 | 'SURVEY_UNTIL' => $announce['survey_until'], |
43 | 42 | )); |
44 | 43 | |
45 | - foreach($announce_exploded as $announce_paragraph) { |
|
44 | + foreach ($announce_exploded as $announce_paragraph) { |
|
46 | 45 | $template->assign_block_vars('announces.paragraph', array( |
47 | 46 | 'TEXT' => $announce_paragraph, |
48 | 47 | )); |
49 | 48 | } |
50 | 49 | |
51 | - if($announce['survey_id']) { |
|
50 | + if ($announce['survey_id']) { |
|
52 | 51 | $survey_query = db_survey_get_answer_texts($announce); |
53 | 52 | $survey_vote_result = array(); |
54 | 53 | $total_votes = 0; |
55 | - while($row = db_fetch($survey_query)) { |
|
54 | + while ($row = db_fetch($survey_query)) { |
|
56 | 55 | $survey_vote_result[] = $row; |
57 | 56 | $total_votes += $row['VOTES']; |
58 | 57 | } |
59 | 58 | |
60 | - if(empty($survey_vote) && !$survey_complete) { |
|
59 | + if (empty($survey_vote) && !$survey_complete) { |
|
61 | 60 | // Can vote |
62 | 61 | $survey_query = db_survey_answers_get_list_by_parent($announce); |
63 | - while($row = db_fetch($survey_query)) { |
|
62 | + while ($row = db_fetch($survey_query)) { |
|
64 | 63 | $template->assign_block_vars('announces.survey_answers', array( |
65 | 64 | 'ID' => $row['survey_answer_id'], |
66 | 65 | 'TEXT' => $row['survey_answer_text'], |
@@ -68,7 +67,7 @@ discard block |
||
68 | 67 | } |
69 | 68 | } else { |
70 | 69 | // Show result |
71 | - foreach($survey_vote_result as &$vote_result) { |
|
70 | + foreach ($survey_vote_result as &$vote_result) { |
|
72 | 71 | $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0; |
73 | 72 | $vote_result['PERCENT'] = $vote_percent; |
74 | 73 | $vote_result['PERCENT_TEXT'] = round($vote_percent, 1); |
@@ -85,8 +84,8 @@ discard block |
||
85 | 84 | } |
86 | 85 | |
87 | 86 | function nws_mark_read(&$user) { |
88 | - if(isset($user['id'])) { |
|
89 | - DBStaticUser::db_user_set_by_id($user['id'], '`news_lastread` = ' . SN_TIME_NOW); |
|
87 | + if (isset($user['id'])) { |
|
88 | + DBStaticUser::db_user_set_by_id($user['id'], '`news_lastread` = '.SN_TIME_NOW); |
|
90 | 89 | $user['news_lastread'] = SN_TIME_NOW; |
91 | 90 | } |
92 | 91 | |
@@ -94,17 +93,17 @@ discard block |
||
94 | 93 | } |
95 | 94 | |
96 | 95 | function survey_vote(&$user) { |
97 | - if(empty($user['id'])) { |
|
96 | + if (empty($user['id'])) { |
|
98 | 97 | return true; |
99 | 98 | } |
100 | 99 | |
101 | 100 | sn_db_transaction_start(); |
102 | 101 | $survey_id = sys_get_param_id('survey_id'); |
103 | 102 | $is_voted = db_survey_vote_get($user, $survey_id); |
104 | - if(empty($is_voted)) { |
|
103 | + if (empty($is_voted)) { |
|
105 | 104 | $survey_vote_id = sys_get_param_id('survey_vote'); |
106 | 105 | $is_answer_exists = db_survey_answer_get($survey_id, $survey_vote_id); |
107 | - if(!empty($is_answer_exists)) { |
|
106 | + if (!empty($is_answer_exists)) { |
|
108 | 107 | $user_name_safe = db_escape($user['username']); |
109 | 108 | db_survey_vote_insert($user, $survey_id, $survey_vote_id, $user_name_safe); |
110 | 109 | } |
@@ -2,31 +2,31 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | 9 | // Changing rank for single user |
10 | 10 | $id_user = sys_get_param_id('id_user'); |
11 | -if(isset($_GET['id_rank'])) { |
|
11 | +if (isset($_GET['id_rank'])) { |
|
12 | 12 | $id_rank = sys_get_param_int('id_rank'); |
13 | 13 | } |
14 | -if($id_user && isset($id_rank) && $user_admin) { |
|
14 | +if ($id_user && isset($id_rank) && $user_admin) { |
|
15 | 15 | DBStaticUser::db_user_set_by_id($id_user, "`ally_rank_id` = {$id_rank}"); |
16 | 16 | } |
17 | 17 | |
18 | 18 | $id_kick = sys_get_param_id('kick'); |
19 | 19 | |
20 | -if($id_kick && $user_can_kick) { |
|
20 | +if ($id_kick && $user_can_kick) { |
|
21 | 21 | $u = DBStaticUser::db_user_by_id($id_kick, true); |
22 | - if($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) { |
|
22 | + if ($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) { |
|
23 | 23 | DBStaticUser::db_user_set_by_id($id_kick, '`ally_id`= null, `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0'); |
24 | 24 | db_ally_update_member_decrease($ally); |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | 28 | $sort2 = sys_get_param_int('sort2'); |
29 | -if($sort2) { |
|
29 | +if ($sort2) { |
|
30 | 30 | $sort2s = "DESC"; |
31 | 31 | $sort2 = 0; |
32 | 32 | } else { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | $sort1 = sys_get_param_int('sort1'); |
38 | -if($sort1 > 5 || $sort1 < 0) { |
|
38 | +if ($sort1 > 5 || $sort1 < 0) { |
|
39 | 39 | $sort1 = 0; |
40 | 40 | } |
41 | 41 | $sort1s = array( |
@@ -49,28 +49,28 @@ discard block |
||
49 | 49 | |
50 | 50 | $template = gettemplate('ali_members', true); |
51 | 51 | |
52 | -$userList = DBStaticUser::db_user_list("`ally_id`= {$user['ally_id']} ORDER BY " . sprintf($sort1s[$sort1], $sort2s), false, |
|
52 | +$userList = DBStaticUser::db_user_list("`ally_id`= {$user['ally_id']} ORDER BY ".sprintf($sort1s[$sort1], $sort2s), false, |
|
53 | 53 | 'id, username, galaxy, system, planet, onlinetime, ally_rank_id, ally_register_time, total_points'); |
54 | 54 | |
55 | 55 | // while ($userRow = db_fetch($userList)) |
56 | -foreach($userList as $userRow) { |
|
56 | +foreach ($userList as $userRow) { |
|
57 | 57 | $i++; |
58 | - if(!isset($ranks[$userRow['ally_rank_id']])) { |
|
58 | + if (!isset($ranks[$userRow['ally_rank_id']])) { |
|
59 | 59 | $userRow['ally_rank_id'] = 0; |
60 | 60 | } |
61 | 61 | |
62 | - if($ally['ally_owner'] == $userRow['id']) { |
|
62 | + if ($ally['ally_owner'] == $userRow['id']) { |
|
63 | 63 | $ally_range = ($ally['ally_owner_range']) ? $ally['ally_owner_range'] : classLocale::$lang['Founder']; |
64 | 64 | } else { |
65 | - if($user_admin) { |
|
66 | - $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user=' . $userRow['id'] . '&id_rank=\' + this.value">'; |
|
65 | + if ($user_admin) { |
|
66 | + $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user='.$userRow['id'].'&id_rank=\' + this.value">'; |
|
67 | 67 | |
68 | - foreach($ranks as $rankID => $rankArray) { |
|
69 | - $ally_range .= '<option value="' . $rankID . '"'; |
|
70 | - if($rankID == $userRow['ally_rank_id']) { |
|
68 | + foreach ($ranks as $rankID => $rankArray) { |
|
69 | + $ally_range .= '<option value="'.$rankID.'"'; |
|
70 | + if ($rankID == $userRow['ally_rank_id']) { |
|
71 | 71 | $ally_range .= " selected"; |
72 | 72 | } |
73 | - $ally_range .= '>' . $rankArray['name']; |
|
73 | + $ally_range .= '>'.$rankArray['name']; |
|
74 | 74 | $ally_range .= '</option>'; |
75 | 75 | } |
76 | 76 | $ally_range .= '</select>'; |
@@ -80,20 +80,20 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | $last_active = time() - $userRow["onlinetime"]; |
83 | - if($user_admin) { |
|
84 | - if($last_active < 60) { |
|
83 | + if ($user_admin) { |
|
84 | + if ($last_active < 60) { |
|
85 | 85 | $tmp = "lime>{$classLocale['On']}"; |
86 | - } elseif($last_active < 60 * 60) { |
|
86 | + } elseif ($last_active < 60 * 60) { |
|
87 | 87 | $last_active = round($last_active / 60); |
88 | 88 | $tmp = "lime>{$last_active} {$classLocale['sys_min_short']}"; |
89 | - } elseif($last_active < 60 * 60 * 24) { |
|
89 | + } elseif ($last_active < 60 * 60 * 24) { |
|
90 | 90 | $last_active = round($last_active / (60 * 60)); |
91 | 91 | $tmp = "green>{$last_active} {$classLocale['sys_hrs_short']}"; |
92 | 92 | } else { |
93 | 93 | $last_active = round($last_active / (60 * 60 * 24)); |
94 | - if($last_active < 7) { |
|
94 | + if ($last_active < 7) { |
|
95 | 95 | $tmp = "yellow"; |
96 | - } elseif($last_active < 30) { |
|
96 | + } elseif ($last_active < 30) { |
|
97 | 97 | $tmp = "orange"; |
98 | 98 | } else { |
99 | 99 | $tmp = "red"; |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $tmp .= ">{$last_active} {$classLocale['sys_day_short']}"; |
102 | 102 | } |
103 | 103 | } else { |
104 | - if($user_onlinestatus) { |
|
105 | - if($last_active < 60 * 5) { |
|
104 | + if ($user_onlinestatus) { |
|
105 | + if ($last_active < 60 * 5) { |
|
106 | 106 | $tmp = "lime>{$classLocale['On']}"; |
107 | - } elseif($last_active < 60 * 15) { |
|
107 | + } elseif ($last_active < 60 * 15) { |
|
108 | 108 | $tmp = "yellow>{$classLocale['ali_lessThen15min']}"; |
109 | 109 | } else { |
110 | 110 | $tmp = "red>{$classLocale['Off']}"; |
@@ -124,21 +124,21 @@ discard block |
||
124 | 124 | 'SYSTEM' => $userRow['system'], |
125 | 125 | 'PLANET' => $userRow['planet'], |
126 | 126 | 'POINTS' => pretty_number($userRow['total_points']), |
127 | - 'ONLINE' => '<font color=' . $tmp . '</font>', |
|
127 | + 'ONLINE' => '<font color='.$tmp.'</font>', |
|
128 | 128 | 'RANK' => $ally_range, |
129 | 129 | 'REGISTER_TIME' => date(FMT_DATE_TIME, $userRow['ally_register_time']), |
130 | 130 | 'SHOW_KICK' => $user['id'] != $userRow['id'] && $ally['ally_owner'] != $userRow['id'], |
131 | 131 | )); |
132 | 132 | } |
133 | 133 | |
134 | -if($i != $ally['ally_members']) { |
|
134 | +if ($i != $ally['ally_members']) { |
|
135 | 135 | db_ally_update_member_set($i, $ally); |
136 | 136 | } |
137 | 137 | |
138 | 138 | $template->assign_vars(array( |
139 | - 'mode' => $mode . ($edit ? "&edit=" . $edit : ''), |
|
139 | + 'mode' => $mode.($edit ? "&edit=".$edit : ''), |
|
140 | 140 | 'ADMIN_MODE' => $user_can_kick, |
141 | - 'dpath' => SN_ROOT_VIRTUAL . $dpath, |
|
141 | + 'dpath' => SN_ROOT_VIRTUAL.$dpath, |
|
142 | 142 | 'onlineMessage' => $user_admin ? classLocale::$lang['ali_sys_lastActive'] : classLocale::$lang['Online'], |
143 | 143 | 'memberCount' => count($userList), |
144 | 144 | 'memberslist' => $page_list, |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | |
11 | 11 | $d = sys_get_param_id('d'); |
12 | 12 | |
13 | -if($d) { |
|
13 | +if ($d) { |
|
14 | 14 | db_ally_request_deny($d); |
15 | 15 | } |
16 | 16 | |
17 | 17 | $id_user = sys_get_param_id('id_user'); |
18 | 18 | |
19 | -if($id_user) { |
|
19 | +if ($id_user) { |
|
20 | 20 | $ally_name_safe = db_escape($ally['ally_name']); |
21 | 21 | $ally_tag_safe = db_escape($ally['ally_tag']); |
22 | - DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0"); |
|
22 | + DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = ".SN_TIME_NOW.", `ally_rank_id` = 0"); |
|
23 | 23 | db_ally_update_member_increase($ally); |
24 | 24 | db_ally_request_delete_by_user_id($id_user); |
25 | 25 | } |
@@ -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 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $debris_for_moon = $debris->debris_total(); |
72 | 72 | |
73 | - if(!$debris_for_moon) { |
|
73 | + if (!$debris_for_moon) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure |
79 | 79 | $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0; |
80 | 80 | $this->create_chance = $moon_chance; |
81 | - if($moon_chance) { |
|
82 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
81 | + if ($moon_chance) { |
|
82 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
83 | 83 | $this->status = UBE_MOON_CREATE_SUCCESS; |
84 | 84 | $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
85 | 85 | |
86 | - if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
86 | + if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
87 | 87 | $debris->_reset(); |
88 | 88 | } else { |
89 | 89 | $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function moon_destroy_try($reapers) { |
104 | 104 | // TODO: $is_simulator |
105 | - if($reapers <= 0) { |
|
105 | + if ($reapers <= 0) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @version 2016-02-25 23:42:45 41a4.68 |
121 | 121 | */ |
122 | 122 | public function calculate_moon(UBE $ube) { |
123 | - if(UBE_MOON_EXISTS == $this->status) { |
|
124 | - if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
123 | + if (UBE_MOON_EXISTS == $this->status) { |
|
124 | + if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
125 | 125 | $reapers = $ube->fleet_list->ube_calculate_attack_reapers(); |
126 | 126 | $this->moon_destroy_try($reapers); |
127 | 127 | } |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | public function report_generate_sql() { |
134 | - return "`ube_report_moon` = " . (int)$this->status . ", |
|
135 | - `ube_report_moon_chance` = " . (int)$this->create_chance . ", |
|
136 | - `ube_report_moon_size` = " . (float)$this->moon_diameter . ", |
|
137 | - `ube_report_moon_reapers` = " . (int)$this->reapers_status . ", |
|
138 | - `ube_report_moon_destroy_chance` = " . (int)$this->destroy_chance . ", |
|
139 | - `ube_report_moon_reapers_die_chance` = " . (int)$this->reaper_die_chance; |
|
134 | + return "`ube_report_moon` = ".(int) $this->status.", |
|
135 | + `ube_report_moon_chance` = " . (int) $this->create_chance.", |
|
136 | + `ube_report_moon_size` = " . (float) $this->moon_diameter.", |
|
137 | + `ube_report_moon_reapers` = " . (int) $this->reapers_status.", |
|
138 | + `ube_report_moon_destroy_chance` = " . (int) $this->destroy_chance.", |
|
139 | + `ube_report_moon_reapers_die_chance` = " . (int) $this->reaper_die_chance; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function report_render_moon() { |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | * @param $planet_id |
167 | 167 | */ |
168 | 168 | public function db_apply_result($planet_info, $destination_user_id) { |
169 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
169 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
170 | 170 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
171 | 171 | $this->moon_name = $moon_row['name']; |
172 | 172 | unset($moon_row); |
173 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
173 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
174 | 174 | DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]); |
175 | 175 | } |
176 | 176 | } |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | $classLocale = classLocale::$lang; |
180 | 180 | |
181 | 181 | $text_defender = ''; |
182 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
182 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
183 | 183 | $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />"; |
184 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
184 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
185 | 185 | $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
186 | 186 | } |
187 | 187 | |
188 | - if($ube->mission_type_id == MT_DESTROY) { |
|
189 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
188 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
189 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
190 | 190 | $text_defender .= classLocale::$lang['ube_report_moon_reapers_none']; |
191 | 191 | } else { |
192 | 192 | $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
193 | - $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />"; |
|
193 | + $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />"; |
|
194 | 194 | |
195 | 195 | $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. "; |
196 | 196 | $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died']; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @version 2016-02-25 23:42:45 41a4.68 |
216 | 216 | */ |
217 | 217 | public function ubeInitLoadStatis($destination_planet) { |
218 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
218 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
219 | 219 | $this->status = UBE_MOON_EXISTS; |
220 | 220 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
221 | 221 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | $possible_cores = array(); |
9 | 9 | $probability = 0; |
10 | - foreach($density_list as $possible_core_id => $core_data) { |
|
11 | - if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
10 | + foreach ($density_list as $possible_core_id => $core_data) { |
|
11 | + if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
12 | 12 | continue; |
13 | 13 | } |
14 | 14 | |
15 | - if( |
|
15 | + if ( |
|
16 | 16 | // Core type exists |
17 | 17 | in_array($possible_core_id, $position_data['core_types']) |
18 | 18 | // Limit core type with planet sector count |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | $random = mt_rand(1, $probability); |
35 | 35 | $selected_core = null; |
36 | - foreach($possible_cores as $core_type => $core_info) { |
|
37 | - if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
36 | + foreach ($possible_cores as $core_type => $core_info) { |
|
37 | + if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
38 | 38 | $selected_core = $core_info; |
39 | 39 | break; |
40 | 40 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) { |
58 | 58 | $Position = intval($Position); |
59 | 59 | |
60 | - if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
60 | + if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | |
67 | 67 | $planet_generator = sn_get_groups('planet_generator'); |
68 | 68 | |
69 | - if($HomeWorld) { |
|
69 | + if ($HomeWorld) { |
|
70 | 70 | $position_data = $planet_generator[0]; |
71 | 71 | } else { |
72 | 72 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
73 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
73 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
74 | 74 | // Корректируем температуру для планеты-странника |
75 | 75 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
76 | 76 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $planet_images = sn_get_groups('planet_images'); |
80 | 80 | $planet_image = $position_data['planet_images'][mt_rand(0, count($position_data['planet_images']) - 1)]; |
81 | - $planet_image .= 'planet' . $planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)]; |
|
81 | + $planet_image .= 'planet'.$planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)]; |
|
82 | 82 | |
83 | 83 | $t_max = sn_rand_gauss_range($position_data['t_max_min'], $position_data['t_max_max'], true, 1.3, true); |
84 | 84 | $t_min = $t_max - sn_rand_gauss_range($position_data['t_delta_min'], $position_data['t_delta_max'], true, 1.3, true); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $core_info = uni_create_planet_get_density($position_data, $user_row, $planet_sectors); |
91 | 91 | |
92 | - $planet_name_unsafe = $user_row['username'] . ' ' . ($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']); |
|
92 | + $planet_name_unsafe = $user_row['username'].' '.($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']); |
|
93 | 93 | |
94 | 94 | $planet['name'] = db_escape(strip_tags(trim($planet_name_unsafe))); |
95 | 95 | $planet['id_owner'] = $PlanetOwnerID; |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | $moon_name = ''; |
171 | 171 | $moon_row = array(); |
172 | 172 | $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
173 | - if(!$moon['id']) { |
|
173 | + if (!$moon['id']) { |
|
174 | 174 | $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
175 | 175 | |
176 | - if($moon_planet['id']) { |
|
176 | + if ($moon_planet['id']) { |
|
177 | 177 | $base_storage_size = BASE_STORAGE_SIZE; |
178 | 178 | |
179 | - if(!$moon_chance) { |
|
179 | + if (!$moon_chance) { |
|
180 | 180 | $size = mt_rand(1100, 8999); |
181 | - } elseif($moon_chance <= 100) { |
|
181 | + } elseif ($moon_chance <= 100) { |
|
182 | 182 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
183 | 183 | } else { |
184 | 184 | $size = $moon_chance; |
@@ -194,22 +194,22 @@ discard block |
||
194 | 194 | |
195 | 195 | $field_max = ceil($size / 1000); |
196 | 196 | |
197 | - if(isset($options['image']) && $options['image']) { |
|
197 | + if (isset($options['image']) && $options['image']) { |
|
198 | 198 | $moon_image = $options['image']; |
199 | 199 | } else { |
200 | 200 | $moon_image = 'mond'; |
201 | 201 | } |
202 | 202 | |
203 | 203 | $moon_row = classSupernova::db_ins_record(LOC_PLANET, |
204 | - "`id_owner` = '{$user_id}', `parent_planet` = '{$moon_planet['id']}', `name` = '{$moon_name_safe}', `last_update` = " . SN_TIME_NOW . ", `image` = '{$moon_image}', |
|
205 | - `galaxy` = '{$pos_galaxy}', `system` = '{$pos_system}', `planet` = '{$pos_planet}', `planet_type` = " . PT_MOON . ", |
|
204 | + "`id_owner` = '{$user_id}', `parent_planet` = '{$moon_planet['id']}', `name` = '{$moon_name_safe}', `last_update` = ".SN_TIME_NOW.", `image` = '{$moon_image}', |
|
205 | + `galaxy` = '{$pos_galaxy}', `system` = '{$pos_system}', `planet` = '{$pos_planet}', `planet_type` = ".PT_MOON.", |
|
206 | 206 | `diameter` = '{$size}', `field_max` = '{$field_max}', `density` = 2500, `density_index` = 2, `temp_min` = '{$temp_min}', `temp_max` = '{$temp_max}', |
207 | 207 | `metal` = '0', `metal_perhour` = '0', `metal_max` = '{$base_storage_size}', |
208 | 208 | `crystal` = '0', `crystal_perhour` = '0', `crystal_max` = '{$base_storage_size}', |
209 | 209 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
210 | 210 | ); |
211 | 211 | |
212 | - if($update_debris) { |
|
212 | + if ($update_debris) { |
|
213 | 213 | $debris_spent = $moon_chance * 1000000; |
214 | 214 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
215 | 215 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -244,28 +244,28 @@ discard block |
||
244 | 244 | $planet_row['id'] = $user['current_planet']; |
245 | 245 | |
246 | 246 | // Пытаемся переключить на новую планету |
247 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
247 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
248 | 248 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
249 | 249 | } else { |
250 | 250 | $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']); |
251 | 251 | } |
252 | 252 | |
253 | 253 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
254 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
254 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
255 | 255 | { |
256 | 256 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
257 | 257 | // Если текущей планеты не существует - выставляем Столицу |
258 | - if(!isset($planet_row['id'])) { |
|
258 | + if (!isset($planet_row['id'])) { |
|
259 | 259 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
260 | 260 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
261 | - if(!isset($planet_row['id'])) { |
|
261 | + if (!isset($planet_row['id'])) { |
|
262 | 262 | classSupernova::$debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Если производилось переключение планеты - делаем запись в юзере |
268 | - if($user['current_planet'] != $planet_row['id']) { |
|
268 | + if ($user['current_planet'] != $planet_row['id']) { |
|
269 | 269 | DBStaticUser::db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
270 | 270 | $user['current_planet'] = $planet_row['id']; |
271 | 271 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | // ---------------------------------------------------------------------------------------------------------------- |
284 | 284 | function uni_render_coordinates($from, $prefix = '') { |
285 | - return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]"; |
|
285 | + return "[{$from[$prefix.'galaxy']}:{$from[$prefix.'system']}:{$from[$prefix.'planet']}]"; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | function uni_render_planet($from) { |
@@ -290,17 +290,17 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
293 | - if(!$from['id']) { |
|
293 | + if (!$from['id']) { |
|
294 | 294 | $result = classLocale::$lang['sys_planet_expedition']; |
295 | 295 | } else { |
296 | 296 | $from_planet_id = $include_id ? ( |
297 | - 'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} ' |
|
297 | + 'ID {'.($from['id'] ? $from['id'] : ($from[$prefix.'planet_id'] ? $from[$prefix.'planet_id'] : 0)).'} ' |
|
298 | 298 | ) : ''; |
299 | 299 | |
300 | - $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix . 'type'] ? $from[$prefix . 'type'] : 0); |
|
301 | - $from_planet_type = ($from_planet_type ? ' ' . classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : ''); |
|
300 | + $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix.'type'] ? $from[$prefix.'type'] : 0); |
|
301 | + $from_planet_type = ($from_planet_type ? ' '.classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : ''); |
|
302 | 302 | |
303 | - $result = $from_planet_id . uni_render_coordinates($from, $prefix) . $from_planet_type . ($from['name'] ? ' ' . $from['name'] : ''); |
|
303 | + $result = $from_planet_id.uni_render_coordinates($from, $prefix).$from_planet_type.($from['name'] ? ' '.$from['name'] : ''); |
|
304 | 304 | $result = $html_safe ? str_replace(' ', ' ', htmlentities($result, ENT_COMPAT, 'UTF-8')) : $result; |
305 | 305 | } |
306 | 306 | |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') { |
311 | - return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}"; |
|
311 | + return $page.(strpos($page, '?') === false ? '?' : '&')."galaxy={$from[$prefix.'galaxy']}&system={$from[$prefix.'system']}&planet={$from[$prefix.'planet']}"; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') { |
315 | - return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>'; |
|
315 | + return '<a href="'.uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}").'"'.($fleet_type ? " {$fleet_type}" : '').'>'.uni_render_coordinates($from, $prefix).'</a>'; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | function uni_get_time_to_jump($moon_row) { |
@@ -340,30 +340,30 @@ discard block |
||
340 | 340 | $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]); |
341 | 341 | |
342 | 342 | return |
343 | - isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&& |
|
344 | - isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&& |
|
343 | + isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies && |
|
344 | + isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems && |
|
345 | 345 | isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets; |
346 | 346 | } |
347 | 347 | |
348 | 348 | function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) { |
349 | 349 | try { |
350 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
350 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
351 | 351 | throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR); |
352 | 352 | } |
353 | 353 | |
354 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
354 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
355 | 355 | throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
356 | 356 | } |
357 | 357 | |
358 | 358 | // TODO: Replace quick-check with using gathered flying fleet data |
359 | - if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
359 | + if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
360 | 360 | throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR); |
361 | 361 | } |
362 | 362 | |
363 | - if(is_array($new_coordinates)) { |
|
363 | + if (is_array($new_coordinates)) { |
|
364 | 364 | $new_coordinates['planet_type'] = PT_PLANET; |
365 | 365 | $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id'); |
366 | - if($incoming['id']) { |
|
366 | + if ($incoming['id']) { |
|
367 | 367 | throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
368 | 368 | } |
369 | 369 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | 'result' => ERR_NONE, |
373 | 373 | 'message' => '', |
374 | 374 | ); |
375 | - } catch(exception $e) { |
|
375 | + } catch (exception $e) { |
|
376 | 376 | $response = array( |
377 | 377 | 'result' => $e->getCode(), |
378 | 378 | 'message' => $e->getMessage(), |