@@ -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 | - 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 | + 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 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | return doquery( |
6 | 6 | "SELECT * FROM {{messages}} |
7 | 7 | WHERE |
8 | - `message_type` = '" . MSG_TYPE_PLAYER . "' AND |
|
8 | + `message_type` = '" . MSG_TYPE_PLAYER."' AND |
|
9 | 9 | ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}') |
10 | 10 | OR |
11 | 11 | (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;"); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | FROM |
52 | 52 | {{messages}} AS m |
53 | 53 | LEFT JOIN {{users}} AS u ON u.id = m.message_owner " . |
54 | - ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') . |
|
54 | + ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : ''). |
|
55 | 55 | "ORDER BY |
56 | 56 | `message_id` DESC |
57 | 57 | LIMIT |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | function db_message_insert_all($message_type, $from, $subject, $text) { |
62 | - return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
62 | + return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
63 | 63 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
64 | 64 | } |
65 | 65 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return array|bool|mysqli_result|null |
70 | 70 | */ |
71 | 71 | function db_message_count_by_type($int_type_selected) { |
72 | - $page_max = doquery('SELECT COUNT(*) AS `max` FROM {{messages}}' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''), true); |
|
72 | + $page_max = doquery('SELECT COUNT(*) AS `max` FROM {{messages}}'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''), true); |
|
73 | 73 | |
74 | 74 | return $page_max; |
75 | 75 | } |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * @param $int_type_selected |
87 | 87 | */ |
88 | 88 | function db_message_list_delete_by_date($delete_date, $int_type_selected) { |
89 | - doquery("DELETE FROM {{messages}} WHERE message_time <= UNIX_TIMESTAMP('{$delete_date}')" . ($int_type_selected >= 0 ? " AND `message_type` = {$int_type_selected}" : '')); |
|
89 | + doquery("DELETE FROM {{messages}} WHERE message_time <= UNIX_TIMESTAMP('{$delete_date}')".($int_type_selected >= 0 ? " AND `message_type` = {$int_type_selected}" : '')); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @param $insert_values |
94 | 94 | */ |
95 | 95 | function db_message_insert($insert_values) { |
96 | - doquery('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
97 | - 'VALUES ' . implode(',', $insert_values)); |
|
96 | + doquery('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
97 | + 'VALUES '.implode(',', $insert_values)); |
|
98 | 98 | } |
@@ -27,19 +27,19 @@ |
||
27 | 27 | */ |
28 | 28 | function db_set_make_safe_string($set, $delta = false) { |
29 | 29 | $set_safe = array(); |
30 | - foreach($set as $field => $value) { |
|
31 | - if(empty($field)) { |
|
30 | + foreach ($set as $field => $value) { |
|
31 | + if (empty($field)) { |
|
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | - $field = '`' . db_escape($field) . '`'; |
|
35 | + $field = '`'.db_escape($field).'`'; |
|
36 | 36 | $new_value = $value; |
37 | - if($value === null) { |
|
37 | + if ($value === null) { |
|
38 | 38 | $new_value = 'NULL'; |
39 | - } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) { |
|
39 | + } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) { |
|
40 | 40 | // non-float |
41 | - $new_value = '"' . db_escape($value) . '"'; |
|
42 | - } elseif($delta) { |
|
41 | + $new_value = '"'.db_escape($value).'"'; |
|
42 | + } elseif ($delta) { |
|
43 | 43 | // float and DELTA-set |
44 | 44 | $new_value = "{$field} + ({$new_value})"; |
45 | 45 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param $note_id_edit |
35 | 35 | */ |
36 | 36 | function db_note_update_by_id($note_priority, $note_title, $note_text, $note_galaxy, $note_system, $note_planet, $note_planet_type, $note_sticky, $note_id_edit) { |
37 | - doquery("UPDATE {{notes}} SET `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
37 | + doquery("UPDATE {{notes}} SET `time` = ".SN_TIME_NOW.", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
38 | 38 | `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky} |
39 | 39 | WHERE `id` = {$note_id_edit} LIMIT 1;"); |
40 | 40 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param $note_sticky |
52 | 52 | */ |
53 | 53 | function db_note_insert($user, $note_priority, $note_title, $note_text, $note_galaxy, $note_system, $note_planet, $note_planet_type, $note_sticky) { |
54 | - doquery("INSERT INTO {{notes}} SET `owner` = {$user['id']}, `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
54 | + doquery("INSERT INTO {{notes}} SET `owner` = {$user['id']}, `time` = ".SN_TIME_NOW.", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
55 | 55 | `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky};"); |
56 | 56 | } |
57 | 57 |
@@ -2,19 +2,19 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
6 | - include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX); |
|
5 | +if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
6 | + include(SN_ROOT_PHYSICAL.'ajax_version_check'.DOT_PHP_EX); |
|
7 | 7 | } |
8 | 8 | |
9 | -if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
10 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX); |
|
9 | +if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
10 | + require_once(SN_ROOT_PHYSICAL."includes/includes/user_birthday_celebrate".DOT_PHP_EX); |
|
11 | 11 | sn_user_birthday_celebrate(); |
12 | 12 | } |
13 | 13 | |
14 | -if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
14 | +if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
15 | 15 | classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true)); |
16 | 16 | classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW); |
17 | - if(classSupernova::$config->server_log_online) { |
|
17 | + if (classSupernova::$config->server_log_online) { |
|
18 | 18 | db_log_online_insert(); |
19 | 19 | } |
20 | 20 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id']; |
42 | 42 | //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die(); |
43 | 43 | |
44 | -if(!empty($user['id'])) { |
|
44 | +if (!empty($user['id'])) { |
|
45 | 45 | classSupernova::$user_options->user_change($user['id']); |
46 | 46 | } |
47 | 47 | |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | : false |
55 | 55 | ); |
56 | 56 | |
57 | -if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
58 | - $prohibited_characters = array_map(function ($value) { |
|
59 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
|
57 | +if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
58 | + $prohibited_characters = array_map(function($value) { |
|
59 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; |
|
60 | 60 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
61 | 61 | $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters); |
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | -if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
65 | +if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
66 | 66 | pdump("Отключи отладку перед продакшном!"); |
67 | 67 | } |
68 | 68 | |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | ? define('INSTALL_MODE', GAME_DISABLE_INSTALL) |
77 | 77 | : false; |
78 | 78 | |
79 | -if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
79 | +if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
80 | 80 | $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse( |
81 | 81 | classSupernova::$config->game_disable == GAME_DISABLE_REASON |
82 | 82 | ? classSupernova::$config->game_disable_reason |
83 | 83 | : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable] |
84 | 84 | ); |
85 | - if(defined('IN_API')) { |
|
85 | + if (defined('IN_API')) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | |
89 | - if( |
|
89 | + if ( |
|
90 | 90 | ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN)) |
91 | 91 | && |
92 | 92 | !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT')) |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | |
101 | 101 | // TODO ban |
102 | 102 | // TODO $skip_ban_check |
103 | -if($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
104 | - if(defined('IN_API')) { |
|
103 | +if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
104 | + if (defined('IN_API')) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
@@ -119,15 +119,15 @@ discard block |
||
119 | 119 | // pdump($allow_anonymous, '$allow_anonymous'); |
120 | 120 | // pdump($sys_user_logged_in, '$sys_user_logged_in'); |
121 | 121 | |
122 | -if($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
123 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
|
124 | -} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
122 | +if ($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
123 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); |
|
124 | +} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
125 | 125 | // pdump($sn_page_name); |
126 | 126 | // pdump(INITIAL_PAGE); |
127 | 127 | // die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}'); |
128 | -} elseif(!$allow_anonymous && !$sys_user_logged_in) { |
|
128 | +} elseif (!$allow_anonymous && !$sys_user_logged_in) { |
|
129 | 129 | // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
130 | - sys_redirect(SN_ROOT_VIRTUAL . 'login.php'); |
|
130 | + sys_redirect(SN_ROOT_VIRTUAL.'login.php'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
@@ -146,16 +146,16 @@ discard block |
||
146 | 146 | |
147 | 147 | global $skip_fleet_update; |
148 | 148 | $skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN'); |
149 | -if( |
|
149 | +if ( |
|
150 | 150 | !$skip_fleet_update |
151 | 151 | && !(defined('IN_AJAX') && IN_AJAX === true) |
152 | 152 | && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval |
153 | 153 | ) { |
154 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/flt_flying_fleet_handler2" . DOT_PHP_EX); |
|
154 | + require_once(SN_ROOT_PHYSICAL."includes/includes/flt_flying_fleet_handler2".DOT_PHP_EX); |
|
155 | 155 | flt_flying_fleet_handler($skip_fleet_update); |
156 | 156 | } |
157 | 157 | |
158 | -if(!defined('IN_AJAX')) { |
|
158 | +if (!defined('IN_AJAX')) { |
|
159 | 159 | print("Scheduled processes is disabled<br />"); |
160 | 160 | } |
161 | 161 | // scheduler_process(); |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | 'LEVEL' => 'submenu', |
105 | 105 | 'TYPE' => 'lang', |
106 | 106 | 'ITEM' => 'tech[UNIT_STRUCTURES]', |
107 | - 'LINK' => 'buildings.php?mode=' . QUE_STRUCTURES, |
|
107 | + 'LINK' => 'buildings.php?mode='.QUE_STRUCTURES, |
|
108 | 108 | 'ICON' => true, |
109 | 109 | ), |
110 | 110 | 'menu_planet_shipyard' => array( |
111 | 111 | 'LEVEL' => 'submenu', |
112 | 112 | 'TYPE' => 'lang', |
113 | 113 | 'ITEM' => 'Shipyard', |
114 | - 'LINK' => 'buildings.php?mode=' . SUBQUE_FLEET, |
|
114 | + 'LINK' => 'buildings.php?mode='.SUBQUE_FLEET, |
|
115 | 115 | 'ICON' => true, |
116 | 116 | ), |
117 | 117 | 'menu_planet_defense' => array( |
118 | 118 | 'LEVEL' => 'submenu', |
119 | 119 | 'TYPE' => 'lang', |
120 | 120 | 'ITEM' => 'Defense', |
121 | - 'LINK' => 'buildings.php?mode=' . SUBQUE_DEFENSE, |
|
121 | + 'LINK' => 'buildings.php?mode='.SUBQUE_DEFENSE, |
|
122 | 122 | 'ICON' => true, |
123 | 123 | ), |
124 | 124 | 'menu_planet_resources' => array( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | 'LEVEL' => 'submenu', |
148 | 148 | 'TYPE' => 'lang', |
149 | 149 | 'ITEM' => 'Research', |
150 | - 'LINK' => 'buildings.php?mode=' . QUE_RESEARCH, |
|
150 | + 'LINK' => 'buildings.php?mode='.QUE_RESEARCH, |
|
151 | 151 | 'ICON' => true, |
152 | 152 | ), |
153 | 153 | 'menu_empire_techtree' => array( |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | 'LEVEL' => 'submenu', |
234 | 234 | 'TYPE' => 'lang', |
235 | 235 | 'ITEM' => 'tech[UNIT_MERCENARIES]', |
236 | - 'LINK' => 'officer.php?mode=' . UNIT_MERCENARIES, |
|
236 | + 'LINK' => 'officer.php?mode='.UNIT_MERCENARIES, |
|
237 | 237 | 'ICON' => true, |
238 | 238 | ), |
239 | 239 | 'menu_empire_schematics' => array( |
240 | 240 | 'LEVEL' => 'submenu', |
241 | 241 | 'TYPE' => 'lang', |
242 | 242 | 'ITEM' => 'tech[UNIT_PLANS]', |
243 | - 'LINK' => 'officer.php?mode=' . UNIT_PLANS, |
|
243 | + 'LINK' => 'officer.php?mode='.UNIT_PLANS, |
|
244 | 244 | 'ICON' => true, |
245 | 245 | ), |
246 | 246 | 'menu_empire_artifacts' => array( |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | 'LEVEL' => 'submenu', |
271 | 271 | 'TYPE' => 'lang', |
272 | 272 | 'ITEM' => 'Chat', |
273 | - 'LINK' => 'index.php?page=chat&mode=' . CHAT_MODE_COMMON, |
|
273 | + 'LINK' => 'index.php?page=chat&mode='.CHAT_MODE_COMMON, |
|
274 | 274 | 'ICON' => true, |
275 | 275 | ), |
276 | 276 | 'menu_ally_chat' => array( |
277 | 277 | 'LEVEL' => 'submenu', |
278 | 278 | 'TYPE' => 'lang', |
279 | 279 | 'ITEM' => 'AllyChat', |
280 | - 'LINK' => 'index.php?page=chat&mode=' . CHAT_MODE_ALLY, |
|
280 | + 'LINK' => 'index.php?page=chat&mode='.CHAT_MODE_ALLY, |
|
281 | 281 | 'ICON' => true, |
282 | 282 | 'DISABLED' => classSupernova::$config->game_mode == GAME_BLITZ, |
283 | 283 | ), |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | ), |
459 | 459 | 'menu_admin_version_info' => array( |
460 | 460 | 'TYPE' => 'text', |
461 | - 'ITEM' => (classSupernova::$config->server_updater_check_last ? date(FMT_DATE, classSupernova::$config->server_updater_check_last) : '') . '<div class="' . |
|
462 | - $sn_version_check_class[classSupernova::$config->server_updater_check_result] . '">' . classLocale::$lang['adm_opt_ver_response_short'][classSupernova::$config->server_updater_check_result] . '</div>', |
|
461 | + 'ITEM' => (classSupernova::$config->server_updater_check_last ? date(FMT_DATE, classSupernova::$config->server_updater_check_last) : '').'<div class="'. |
|
462 | + $sn_version_check_class[classSupernova::$config->server_updater_check_result].'">'.classLocale::$lang['adm_opt_ver_response_short'][classSupernova::$config->server_updater_check_result].'</div>', |
|
463 | 463 | ), |
464 | 464 | |
465 | 465 | 'USER_AUTHLEVEL_NAME' => array( |
@@ -547,13 +547,13 @@ discard block |
||
547 | 547 | 'menu_admin_planet_list_planets' => array( |
548 | 548 | 'TYPE' => 'lang', |
549 | 549 | 'ITEM' => 'adm_pltlst', |
550 | - 'LINK' => 'admin/adm_planet_list.php?planet_type=' . PT_PLANET, |
|
550 | + 'LINK' => 'admin/adm_planet_list.php?planet_type='.PT_PLANET, |
|
551 | 551 | 'AUTH_LEVEL' => 3, |
552 | 552 | ), |
553 | 553 | 'menu_admin_planet_list_moons' => array( |
554 | 554 | 'TYPE' => 'lang', |
555 | 555 | 'ITEM' => 'adm_moonlst', |
556 | - 'LINK' => 'admin/adm_planet_list.php?planet_type=' . PT_MOON, |
|
556 | + 'LINK' => 'admin/adm_planet_list.php?planet_type='.PT_MOON, |
|
557 | 557 | 'AUTH_LEVEL' => 3, |
558 | 558 | ), |
559 | 559 | 'menu_admin_planet_moon_add' => array( |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Защита от двойного инита |
4 | -if(defined('INIT')) { |
|
4 | +if (defined('INIT')) { |
|
5 | 5 | return; |
6 | 6 | } |
7 | 7 | |
@@ -20,22 +20,22 @@ discard block |
||
20 | 20 | version_compare(PHP_VERSION, '5.3.2') < 0 ? die('FATAL ERROR: SuperNova REQUIRE PHP version > 5.3.2') : false; |
21 | 21 | |
22 | 22 | // Бенчмарк |
23 | -register_shutdown_function(function () { |
|
24 | - if(defined('IN_AJAX')) { |
|
23 | +register_shutdown_function(function() { |
|
24 | + if (defined('IN_AJAX')) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
28 | 28 | global $user, $locale_cache_statistic; |
29 | 29 | |
30 | - print('<hr><div class="benchmark">Benchmark ' . (microtime(true) - SN_TIME_MICRO) . 's, memory: ' . number_format(memory_get_usage() - SN_MEM_START) . |
|
31 | - (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') . |
|
32 | - (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') . |
|
30 | + print('<hr><div class="benchmark">Benchmark '.(microtime(true) - SN_TIME_MICRO).'s, memory: '.number_format(memory_get_usage() - SN_MEM_START). |
|
31 | + (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : ''). |
|
32 | + (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: '.classSupernova::$db->time_mysql_total.'ms' : ''). |
|
33 | 33 | '</div>'); |
34 | - if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
34 | + if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL.'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL.'badqrys.txt') > 0) { |
|
35 | 35 | echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>'; |
36 | 36 | } |
37 | 37 | |
38 | - if(!empty($locale_cache_statistic['misses'])) { |
|
38 | + if (!empty($locale_cache_statistic['misses'])) { |
|
39 | 39 | print('<!--'); |
40 | 40 | pdump($locale_cache_statistic); |
41 | 41 | print('-->'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW)); |
57 | 57 | |
58 | -if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
58 | +if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
59 | 59 | define('SN_GOOGLE', true); |
60 | 60 | } |
61 | 61 | |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | $sn_root_relative = str_replace($sn_root_relative, '', $_SERVER['SCRIPT_NAME']); |
75 | 75 | define('SN_ROOT_RELATIVE', $sn_root_relative); |
76 | 76 | |
77 | -define('SN_ROOT_VIRTUAL', 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . SN_ROOT_RELATIVE); |
|
77 | +define('SN_ROOT_VIRTUAL', 'http'.(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '').'://'.$_SERVER['HTTP_HOST'].SN_ROOT_RELATIVE); |
|
78 | 78 | define('SN_ROOT_VIRTUAL_PARENT', str_replace('//google.', '//', SN_ROOT_VIRTUAL)); |
79 | 79 | |
80 | 80 | $phpEx = strpos($phpEx = substr(strrchr(__FILE__, '.'), 1), '/') === false ? $phpEx : ''; |
81 | 81 | define('PHP_EX', $phpEx); // PHP extension on this server |
82 | -define('DOT_PHP_EX', '.' . PHP_EX); // PHP extension on this server |
|
82 | +define('DOT_PHP_EX', '.'.PHP_EX); // PHP extension on this server |
|
83 | 83 | |
84 | 84 | |
85 | 85 | require_once('constants.php'); |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | |
101 | 101 | // required for db.php |
102 | 102 | // Initializing global 'debug' object |
103 | -require_once(SN_ROOT_PHYSICAL . "includes/debug.class" . DOT_PHP_EX); |
|
103 | +require_once(SN_ROOT_PHYSICAL."includes/debug.class".DOT_PHP_EX); |
|
104 | 104 | classSupernova::$debug = new debug(); |
105 | 105 | |
106 | -spl_autoload_register(function ($class) { |
|
107 | - if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) { |
|
108 | - require_once SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php'; |
|
106 | +spl_autoload_register(function($class) { |
|
107 | + if (file_exists(SN_ROOT_PHYSICAL.'includes/classes/'.$class.'.php')) { |
|
108 | + require_once SN_ROOT_PHYSICAL.'includes/classes/'.$class.'.php'; |
|
109 | 109 | } |
110 | 110 | }); |
111 | 111 | |
112 | -spl_autoload_register(function ($class) { |
|
113 | - if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) { |
|
114 | - require_once SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php'; |
|
112 | +spl_autoload_register(function($class) { |
|
113 | + if (file_exists(SN_ROOT_PHYSICAL.'includes/classes/UBE/'.$class.'.php')) { |
|
114 | + require_once SN_ROOT_PHYSICAL.'includes/classes/UBE/'.$class.'.php'; |
|
115 | 115 | } |
116 | 116 | }); |
117 | 117 | |
118 | -require_once(SN_ROOT_PHYSICAL . "includes/db" . DOT_PHP_EX); |
|
118 | +require_once(SN_ROOT_PHYSICAL."includes/db".DOT_PHP_EX); |
|
119 | 119 | require_once('classes/db_mysql_v4.php'); |
120 | 120 | require_once('classes/db_mysql_v5.php'); |
121 | 121 | require_once('classes/db_mysql.php'); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | require_once('classes/module.php'); |
129 | 129 | |
130 | 130 | require_once('classes/user_options.php'); |
131 | -require_once(SN_ROOT_PHYSICAL . "includes/init/init_functions" . DOT_PHP_EX); |
|
131 | +require_once(SN_ROOT_PHYSICAL."includes/init/init_functions".DOT_PHP_EX); |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @var classConfig $config |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | // define('BE_DEBUG', true); // Отладка боевого движка |
143 | 143 | classSupernova::init_debug_state(); |
144 | 144 | |
145 | -require_once(SN_ROOT_PHYSICAL . "includes/vars" . DOT_PHP_EX); |
|
146 | -require_once(SN_ROOT_PHYSICAL . "includes/general" . DOT_PHP_EX); |
|
145 | +require_once(SN_ROOT_PHYSICAL."includes/vars".DOT_PHP_EX); |
|
146 | +require_once(SN_ROOT_PHYSICAL."includes/general".DOT_PHP_EX); |
|
147 | 147 | |
148 | 148 | init_update(); |
149 | 149 | |
@@ -152,34 +152,34 @@ discard block |
||
152 | 152 | ? trim(strip_tags($_GET['page'])) |
153 | 153 | : str_replace(DOT_PHP_EX, '', str_replace(SN_ROOT_RELATIVE, '', str_replace('\\', '/', $_SERVER['SCRIPT_NAME']))); |
154 | 154 | define('INITIAL_PAGE', $sn_page_name_original); |
155 | -define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova') . (defined('SN_GOOGLE') ? '_G' : '')); |
|
156 | -define('SN_COOKIE_I', SN_COOKIE . AUTH_COOKIE_IMPERSONATE_SUFFIX); |
|
157 | -define('SN_COOKIE_D', SN_COOKIE . '_D'); |
|
158 | -define('SN_COOKIE_T', SN_COOKIE . '_T'); // Time measure cookie |
|
159 | -define('SN_COOKIE_F', SN_COOKIE . '_F'); // Font size cookie |
|
160 | -define('SN_COOKIE_U', SN_COOKIE . '_U'); // Current user cookie aka user ID |
|
161 | -define('SN_COOKIE_U_I', SN_COOKIE_U . AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID |
|
155 | +define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova').(defined('SN_GOOGLE') ? '_G' : '')); |
|
156 | +define('SN_COOKIE_I', SN_COOKIE.AUTH_COOKIE_IMPERSONATE_SUFFIX); |
|
157 | +define('SN_COOKIE_D', SN_COOKIE.'_D'); |
|
158 | +define('SN_COOKIE_T', SN_COOKIE.'_T'); // Time measure cookie |
|
159 | +define('SN_COOKIE_F', SN_COOKIE.'_F'); // Font size cookie |
|
160 | +define('SN_COOKIE_U', SN_COOKIE.'_U'); // Current user cookie aka user ID |
|
161 | +define('SN_COOKIE_U_I', SN_COOKIE_U.AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID |
|
162 | 162 | define('TEMPLATE_NAME', classSupernova::$config->game_default_template ? classSupernova::$config->game_default_template : 'OpenGame'); |
163 | -define('TEMPLATE_PATH', 'design/templates/' . TEMPLATE_NAME); |
|
164 | -define('TEMPLATE_DIR', SN_ROOT_PHYSICAL . TEMPLATE_PATH); |
|
163 | +define('TEMPLATE_PATH', 'design/templates/'.TEMPLATE_NAME); |
|
164 | +define('TEMPLATE_DIR', SN_ROOT_PHYSICAL.TEMPLATE_PATH); |
|
165 | 165 | define('DEFAULT_SKINPATH', classSupernova::$config->game_default_skin ? classSupernova::$config->game_default_skin : 'skins/EpicBlue/'); |
166 | 166 | define('DEFAULT_LANG', classSupernova::$config->game_default_language ? classSupernova::$config->game_default_language : 'ru'); |
167 | 167 | define('FMT_DATE', classSupernova::$config->int_format_date ? classSupernova::$config->int_format_date : 'd.m.Y'); |
168 | 168 | define('FMT_TIME', classSupernova::$config->int_format_time ? classSupernova::$config->int_format_time : 'H:i:s'); |
169 | -define('FMT_DATE_TIME', FMT_DATE . ' ' . FMT_TIME); |
|
169 | +define('FMT_DATE_TIME', FMT_DATE.' '.FMT_TIME); |
|
170 | 170 | |
171 | 171 | $HTTP_ACCEPT_LANGUAGE = DEFAULT_LANG; |
172 | 172 | |
173 | -require_once(SN_ROOT_PHYSICAL . "includes/template" . DOT_PHP_EX); |
|
173 | +require_once(SN_ROOT_PHYSICAL."includes/template".DOT_PHP_EX); |
|
174 | 174 | $template_result = array('.' => array('result' => array())); |
175 | 175 | |
176 | -sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX); |
|
176 | +sn_sys_load_php_files(SN_ROOT_PHYSICAL."includes/functions/", PHP_EX); |
|
177 | 177 | |
178 | -spl_autoload_register(function ($class) { |
|
179 | - if(file_exists('includes/classes/' . $class . '.php')) { |
|
180 | - require_once 'includes/classes/' . $class . '.php'; |
|
181 | - } elseif(file_exists('includes/classes/UBE/' . $class . '.php')) { |
|
182 | - require_once 'includes/classes/UBE/' . $class . '.php'; |
|
178 | +spl_autoload_register(function($class) { |
|
179 | + if (file_exists('includes/classes/'.$class.'.php')) { |
|
180 | + require_once 'includes/classes/'.$class.'.php'; |
|
181 | + } elseif (file_exists('includes/classes/UBE/'.$class.'.php')) { |
|
182 | + require_once 'includes/classes/UBE/'.$class.'.php'; |
|
183 | 183 | } else { |
184 | 184 | // die("Can't find {$class} class"); |
185 | 185 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | // Конфиг - часть манифеста? |
194 | 194 | classSupernova::$auth = new core_auth(); |
195 | 195 | |
196 | -sn_sys_load_php_files(SN_ROOT_PHYSICAL . "modules/", PHP_EX, true); |
|
196 | +sn_sys_load_php_files(SN_ROOT_PHYSICAL."modules/", PHP_EX, true); |
|
197 | 197 | // Здесь - потому что core_auth модуль лежит в другом каталоге и его нужно инициализировать отдельно |
198 | 198 | |
199 | 199 | // Подключаем дефолтную страницу |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | // Сейчас мы делаем это здесь только для того, что бы содержание дефолтной страницы оказалось вверху. Что не факт, что нужно всегда |
202 | 202 | // Но нужно, пока у нас есть не MVC-страницы |
203 | 203 | $sn_page_data = $sn_data['pages'][$sn_page_name]; |
204 | -$sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
|
205 | -if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
204 | +$sn_page_name_file = 'includes/pages/'.$sn_page_data['filename'].DOT_PHP_EX; |
|
205 | +if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
206 | 206 | require_once($sn_page_name_file); |
207 | - if(is_array($sn_page_data['options'])) { |
|
207 | + if (is_array($sn_page_data['options'])) { |
|
208 | 208 | $supernova->options = array_merge($supernova->options, $sn_page_data['options']); |
209 | 209 | } |
210 | 210 | } |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | $load_order = array(); |
220 | 220 | $sn_req = array(); |
221 | 221 | |
222 | -foreach(sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
222 | +foreach (sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
223 | 223 | $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000; |
224 | - if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
225 | - foreach($module_data->manifest['require'] as $require_name) { |
|
224 | + if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
225 | + foreach ($module_data->manifest['require'] as $require_name) { |
|
226 | 226 | $sn_req[$loaded_module_name][$require_name] = 0; |
227 | 227 | } |
228 | 228 | } |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | do { |
236 | 236 | $prev_order = $load_order; |
237 | 237 | |
238 | - foreach($sn_req as $loaded_module_name => &$req_data) { |
|
238 | + foreach ($sn_req as $loaded_module_name => &$req_data) { |
|
239 | 239 | $level = 1; |
240 | - foreach($req_data as $req_name => &$req_level) { |
|
241 | - if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
240 | + foreach ($req_data as $req_name => &$req_level) { |
|
241 | + if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
242 | 242 | $level = $req_level = -1; |
243 | 243 | break; |
244 | 244 | } else { |
@@ -246,20 +246,20 @@ discard block |
||
246 | 246 | } |
247 | 247 | $req_level = $load_order[$req_name]; |
248 | 248 | } |
249 | - if($level > $load_order[$loaded_module_name] || $level == -1) { |
|
249 | + if ($level > $load_order[$loaded_module_name] || $level == -1) { |
|
250 | 250 | $load_order[$loaded_module_name] = $level; |
251 | 251 | } |
252 | 252 | } |
253 | -} while($prev_order != $load_order); |
|
253 | +} while ($prev_order != $load_order); |
|
254 | 254 | |
255 | 255 | asort($load_order); |
256 | 256 | |
257 | 257 | // Инициализируем модули |
258 | 258 | // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти |
259 | -foreach($load_order as $loaded_module_name => $load_order_order) { |
|
260 | - if($load_order_order >= 0) { |
|
259 | +foreach ($load_order as $loaded_module_name => $load_order_order) { |
|
260 | + if ($load_order_order >= 0) { |
|
261 | 261 | sn_module::$sn_module[$loaded_module_name]->check_status(); |
262 | - if(!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
262 | + if (!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
263 | 263 | unset(sn_module::$sn_module[$loaded_module_name]); |
264 | 264 | continue; |
265 | 265 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | unset($sn_req); |
277 | 277 | |
278 | 278 | // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
279 | -if(!isset($sn_data['pages'][$sn_page_name])) { |
|
279 | +if (!isset($sn_data['pages'][$sn_page_name])) { |
|
280 | 280 | $sn_page_name = ''; |
281 | 281 | } |
282 | 282 | |
@@ -284,6 +284,6 @@ discard block |
||
284 | 284 | classLocale::$lang = $lang = new classLocale(classSupernova::$config->server_locale_log_usage); |
285 | 285 | classLocale::$lang->lng_switch(sys_get_param_str('lang')); |
286 | 286 | |
287 | -if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
287 | +if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
288 | 288 | require_once "init_secondary.php"; |
289 | 289 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | function pname_factory_production_field_name($factory_unit_id) |
6 | 6 | { |
7 | - return get_unit_param($factory_unit_id, P_NAME) . '_porcent'; |
|
7 | + return get_unit_param($factory_unit_id, P_NAME).'_porcent'; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | global $template_result; |
20 | 20 | $classLocale = classLocale::$lang; |
21 | 21 | |
22 | - if($ally_id = sys_get_param_id('ally_id')) { |
|
22 | + if ($ally_id = sys_get_param_id('ally_id')) { |
|
23 | 23 | define('SN_IN_ALLY', true); |
24 | 24 | $ranks = ally_get_ranks($auser['ally']); |
25 | - if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
25 | + if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
26 | 26 | $user = &$auser['ally']['player']; |
27 | 27 | $planet = array( |
28 | 28 | 'metal' => $user['metal'], |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - if(!$user) { |
|
35 | + if (!$user) { |
|
36 | 36 | $user = &$auser; |
37 | 37 | } |
38 | 38 | |
39 | - switch($action = sys_get_param_escaped('action')) { |
|
39 | + switch ($action = sys_get_param_escaped('action')) { |
|
40 | 40 | case 'create': // Add unit to que for build |
41 | 41 | case 'create_autoconvert': // Add unit to que for build |
42 | 42 | case 'destroy': // Add unit to que for remove |
@@ -53,28 +53,28 @@ discard block |
||
53 | 53 | |
54 | 54 | $group_missile = sn_get_groups('missile'); |
55 | 55 | $silo_capacity_free = 0; |
56 | - if($que_type == QUE_STRUCTURES) { |
|
56 | + if ($que_type == QUE_STRUCTURES) { |
|
57 | 57 | $build_unit_list = sn_get_groups('build_allow'); |
58 | 58 | $build_unit_list = $build_unit_list[$planet['planet_type']]; |
59 | 59 | $artifact_id = ART_NANO_BUILDER; |
60 | 60 | $page_header = classLocale::$lang['tech'][UNIT_STRUCTURES]; |
61 | - } elseif($que_type == QUE_RESEARCH) { |
|
62 | - if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
61 | + } elseif ($que_type == QUE_RESEARCH) { |
|
62 | + if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
63 | 63 | message(classLocale::$lang['no_laboratory'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]); |
64 | 64 | } |
65 | 65 | |
66 | - if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
66 | + if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
67 | 67 | message(classLocale::$lang['eco_bld_msg_err_laboratory_upgrading'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]); |
68 | 68 | } |
69 | 69 | $build_unit_list = sn_get_groups('tech'); |
70 | 70 | $artifact_id = ART_HEURISTIC_CHIP; |
71 | - $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
72 | - } elseif($que_type == QUE_MERCENARY) { |
|
71 | + $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES].($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
72 | + } elseif ($que_type == QUE_MERCENARY) { |
|
73 | 73 | $build_unit_list = sn_get_groups('mercenaries'); |
74 | 74 | $artifact_id = 0; |
75 | - $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
75 | + $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES].($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
76 | 76 | } else { |
77 | - if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
77 | + if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
78 | 78 | message(classLocale::$lang['need_hangar'], classLocale::$lang['tech'][STRUC_FACTORY_HANGAR]); |
79 | 79 | } |
80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $artifact_id = 0; |
84 | 84 | |
85 | 85 | $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY); |
86 | - foreach($group_missile as $unit_id) { |
|
86 | + foreach ($group_missile as $unit_id) { |
|
87 | 87 | $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE); |
88 | 88 | } |
89 | 89 | $silo_capacity_free = max(0, $silo_capacity_free); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $config_resource_multiplier_plain = game_resource_multiplier(true); |
95 | 95 | |
96 | 96 | $template = gettemplate('buildings_builds', true); |
97 | - if(!empty($operation_result)) { |
|
97 | + if (!empty($operation_result)) { |
|
98 | 98 | $template_result['.']['result'][] = $operation_result; |
99 | 99 | } |
100 | 100 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $record_index = 0; |
126 | 126 | |
127 | - foreach($build_unit_list as $unit_id) { |
|
127 | + foreach ($build_unit_list as $unit_id) { |
|
128 | 128 | $level_base = mrc_get_level($user, $planet, $unit_id, false, true); |
129 | 129 | $level_effective = mrc_get_level($user, $planet, $unit_id); |
130 | 130 | $level_in_que = $in_que[$unit_id]; |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE]; |
148 | 148 | // Restricting $can_build by free silo capacity |
149 | 149 | $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build; |
150 | - if(!$can_build) { |
|
151 | - if(!$build_data['CAN'][BUILD_CREATE]) { |
|
150 | + if (!$can_build) { |
|
151 | + if (!$build_data['CAN'][BUILD_CREATE]) { |
|
152 | 152 | $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES; |
153 | - } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
153 | + } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
154 | 154 | $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL; |
155 | - } elseif($unit_info[P_MAX_STACK]) { |
|
155 | + } elseif ($unit_info[P_MAX_STACK]) { |
|
156 | 156 | $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED; |
157 | 157 | } |
158 | 158 | } |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | 'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]), |
220 | 220 | ); |
221 | 221 | |
222 | - if($unit_stackable) { |
|
222 | + if ($unit_stackable) { |
|
223 | 223 | $level_production_base = array( |
224 | 224 | 'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])), |
225 | 225 | 'ACTUAL_ARMOR' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])), |
226 | 226 | 'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])), |
227 | 227 | ); |
228 | 228 | |
229 | - if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
229 | + if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
230 | 230 | $ship_data = get_ship_data($unit_id, $user); |
231 | 231 | |
232 | 232 | $level_production_base += array( |
@@ -236,23 +236,23 @@ discard block |
||
236 | 236 | ); |
237 | 237 | } |
238 | 238 | |
239 | - if($unit_info[P_UNIT_PRODUCTION]) { |
|
240 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
241 | - if($resource_income = |
|
239 | + if ($unit_info[P_UNIT_PRODUCTION]) { |
|
240 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
241 | + if ($resource_income = |
|
242 | 242 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet) |
243 | 243 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
244 | 244 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
245 | 245 | ) { |
246 | - $level_production_base['R' . $resource_id] = $resource_income; |
|
246 | + $level_production_base['R'.$resource_id] = $resource_income; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | 250 | $production['.']['resource'][] = $level_production_base; |
251 | - } elseif($unit_info[P_UNIT_PRODUCTION]) { |
|
251 | + } elseif ($unit_info[P_UNIT_PRODUCTION]) { |
|
252 | 252 | $level_production_base = array(); |
253 | 253 | $element_level_start = $level_effective + $in_que[$unit_id]; |
254 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
255 | - if($resource_income = |
|
254 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
255 | + if ($resource_income = |
|
256 | 256 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet) |
257 | 257 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
258 | 258 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -262,21 +262,21 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
265 | - for($i = 0; $i < 6; $i++) { |
|
265 | + for ($i = 0; $i < 6; $i++) { |
|
266 | 266 | $level_production = array('LEVEL' => $level_start + $i); |
267 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | - if( |
|
267 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | + if ( |
|
269 | 269 | $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet) |
270 | 270 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
271 | 271 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
272 | 272 | ) { |
273 | - $level_production['R' . $resource_id] = $resource_income; |
|
274 | - $level_production['D' . $resource_id] = $resource_income - $level_production_base[$resource_id]; |
|
273 | + $level_production['R'.$resource_id] = $resource_income; |
|
274 | + $level_production['D'.$resource_id] = $resource_income - $level_production_base[$resource_id]; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | $production['.']['resource'][] = $level_production; |
278 | 278 | } |
279 | - } elseif($unit_id == TECH_ASTROTECH) { |
|
279 | + } elseif ($unit_id == TECH_ASTROTECH) { |
|
280 | 280 | $element_level_start = $level_effective + $in_que[$unit_id]; |
281 | 281 | $level_production_base = array( |
282 | 282 | UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start), |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | ); |
285 | 285 | |
286 | 286 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
287 | - for($i = 0; $i < 6; $i++) { |
|
287 | + for ($i = 0; $i < 6; $i++) { |
|
288 | 288 | $level_production = array('LEVEL' => $level_start + $i); |
289 | - $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
|
290 | - $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
|
291 | - $level_production['R' . UNIT_PLAYER_COLONIES_MAX] = get_player_max_colonies($user, $level_start + $i); |
|
292 | - $level_production['D' . UNIT_PLAYER_COLONIES_MAX] = $level_production['R' . UNIT_PLAYER_COLONIES_MAX] - $level_production_base[UNIT_PLAYER_COLONIES_MAX]; |
|
289 | + $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
|
290 | + $level_production['D'.UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
|
291 | + $level_production['R'.UNIT_PLAYER_COLONIES_MAX] = get_player_max_colonies($user, $level_start + $i); |
|
292 | + $level_production['D'.UNIT_PLAYER_COLONIES_MAX] = $level_production['R'.UNIT_PLAYER_COLONIES_MAX] - $level_production_base[UNIT_PLAYER_COLONIES_MAX]; |
|
293 | 293 | $production['.']['resource'][] = $level_production; |
294 | 294 | |
295 | 295 | $level_production_base = array( |
296 | - UNIT_PLAYER_EXPEDITIONS_MAX => $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX], |
|
297 | - UNIT_PLAYER_COLONIES_MAX => $level_production['R' . UNIT_PLAYER_COLONIES_MAX], |
|
296 | + UNIT_PLAYER_EXPEDITIONS_MAX => $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX], |
|
297 | + UNIT_PLAYER_COLONIES_MAX => $level_production['R'.UNIT_PLAYER_COLONIES_MAX], |
|
298 | 298 | ); |
299 | 299 | } |
300 | 300 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $template_result['.']['production'][] = $production; |
306 | 306 | } |
307 | 307 | |
308 | - foreach(classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
308 | + foreach (classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
309 | 309 | $template->assign_block_vars('sort_values', array( |
310 | 310 | 'VALUE' => $sort_id, |
311 | 311 | 'TEXT' => $sort_text, |