@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
18 | 18 | |
19 | -if($user['authlevel'] < 1) { |
|
19 | +if ($user['authlevel'] < 1) { |
|
20 | 20 | AdminMessage(classLocale::$lang['adm_err_denied']); |
21 | 21 | } |
22 | 22 | |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | $template = gettemplate("admin/admin_ban", true); |
29 | 29 | |
30 | 30 | $player_banned_row = db_user_by_username($name_unsafe); |
31 | -if($mode == 'banit' && $action) { |
|
32 | - if($player_banned_row) { |
|
31 | +if ($mode == 'banit' && $action) { |
|
32 | + if ($player_banned_row) { |
|
33 | 33 | $reas = $_POST['why']; |
34 | 34 | $days = $_POST['days']; |
35 | 35 | $hour = $_POST['hour']; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $adm_bn_thpl = classLocale::$lang['adm_bn_thpl']; |
50 | 50 | $DoneMessage = "{$adm_bn_thpl} {$name_output} {$adm_bn_isbn}"; |
51 | 51 | |
52 | - if($is_vacation) { |
|
52 | + if ($is_vacation) { |
|
53 | 53 | $DoneMessage .= classLocale::$lang['adm_bn_vctn']; |
54 | 54 | } |
55 | 55 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | AdminMessage($DoneMessage, classLocale::$lang['adm_ban_title']); |
62 | -} elseif($mode == 'unbanit' && $action) { |
|
62 | +} elseif ($mode == 'unbanit' && $action) { |
|
63 | 63 | sys_admin_player_ban_unset($user, $player_banned_row, ($reason = sys_get_param_str('why')) ? $reason : classLocale::$lang['sys_unbanned']); |
64 | 64 | |
65 | 65 | $DoneMessage = classLocale::$lang['adm_unbn_thpl'] . " " . $name_output . " " . classLocale::$lang['adm_unbn_isbn']; |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -define('INSIDE' , true); |
|
3 | -define('INSTALL' , false); |
|
2 | +define('INSIDE', true); |
|
3 | +define('INSTALL', false); |
|
4 | 4 | define('IN_ADMIN', true); |
5 | 5 | |
6 | 6 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
7 | 7 | |
8 | -if($user['authlevel'] < 3) |
|
8 | +if ($user['authlevel'] < 3) |
|
9 | 9 | { |
10 | 10 | AdminMessage(classLocale::$lang['adm_err_denied']); |
11 | 11 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $username_unsafe = sys_get_param_str_unsafe('username'); |
26 | 26 | $username = sys_get_param_escaped('username'); |
27 | 27 | |
28 | -if($galaxy_src) |
|
28 | +if ($galaxy_src) |
|
29 | 29 | { |
30 | 30 | sn_db_transaction_start(); |
31 | 31 | $errors = array(); |
@@ -35,41 +35,41 @@ discard block |
||
35 | 35 | $planet = sys_o_get_updated($owner, array('galaxy' => $galaxy_src, 'system' => $system_src, 'planet' => $planet_src, 'planet_type' => 1), SN_TIME_NOW); |
36 | 36 | $que = $planet['que']; |
37 | 37 | $planet = $planet['planet']; |
38 | - if(!$planet) |
|
38 | + if (!$planet) |
|
39 | 39 | { |
40 | 40 | $errors[] = classLocale::$lang['adm_pl_comp_err_0']; |
41 | 41 | } |
42 | 42 | |
43 | - if($planet['destruyed']) |
|
43 | + if ($planet['destruyed']) |
|
44 | 44 | { |
45 | 45 | $errors[] = classLocale::$lang['adm_pl_comp_err_1']; |
46 | 46 | } |
47 | 47 | |
48 | - if($planet['id_owner'] != $owner['id'] || !$username) |
|
48 | + if ($planet['id_owner'] != $owner['id'] || !$username) |
|
49 | 49 | { |
50 | 50 | $errors[] = classLocale::$lang['adm_pl_comp_err_4']; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $destination = sys_o_get_updated($owner, array('galaxy' => $galaxy_dst, 'system' => $system_dst, 'planet' => $planet_dst, 'planet_type' => 1), SN_TIME_NOW); |
54 | 54 | $destination = $destination['planet']; |
55 | - if(!$destination) |
|
55 | + if (!$destination) |
|
56 | 56 | { |
57 | 57 | $errors[] = classLocale::$lang['adm_pl_comp_err_2']; |
58 | 58 | } |
59 | 59 | |
60 | - if($planet['id'] == $destination['id']) |
|
60 | + if ($planet['id'] == $destination['id']) |
|
61 | 61 | { |
62 | 62 | $errors[] = classLocale::$lang['adm_pl_comp_err_5']; |
63 | 63 | } |
64 | 64 | |
65 | - if($planet['id_owner'] != $destination['id_owner']) |
|
65 | + if ($planet['id_owner'] != $destination['id_owner']) |
|
66 | 66 | { |
67 | 67 | $errors[] = classLocale::$lang['adm_pl_comp_err_3']; |
68 | 68 | } |
69 | 69 | |
70 | - if(!empty($errors)) |
|
70 | + if (!empty($errors)) |
|
71 | 71 | { |
72 | - foreach($errors as $error) |
|
72 | + foreach ($errors as $error) |
|
73 | 73 | { |
74 | 74 | $template->assign_block_vars('error', array( |
75 | 75 | 'TEXT' => $error, |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | killer_add_planet($planet); |
84 | 84 | |
85 | 85 | $moon = db_planet_by_gspt($galaxy_src, $system_src, $planet_src, PT_MOON, true); |
86 | - if($moon) |
|
86 | + if ($moon) |
|
87 | 87 | { |
88 | 88 | $moon = sys_o_get_updated($owner, $moon, SN_TIME_NOW); |
89 | 89 | $moon = $moon['planet']; |
90 | 90 | killer_add_planet($moon); |
91 | 91 | } |
92 | 92 | |
93 | - foreach(sn_get_groups('resources_loot') as $resource_id) |
|
93 | + foreach (sn_get_groups('resources_loot') as $resource_id) |
|
94 | 94 | { |
95 | 95 | $resource_name = pname_resource_name($resource_id); |
96 | 96 | $template->assign_var("{$resource_name}_cost", $final_cost[$resource_id]); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | $template->assign_var("{$resource_name}_bonus", $final_cost[$resource_id]); |
99 | 99 | } |
100 | 100 | |
101 | - if($_GET['btn_confirm']) |
|
101 | + if ($_GET['btn_confirm']) |
|
102 | 102 | { |
103 | 103 | $time = SN_TIME_NOW + PERIOD_DAY; |
104 | 104 | |
105 | 105 | db_unit_list_delete($planet['id_owner'], LOC_PLANET, $planet['id']); |
106 | 106 | db_planet_set_by_id($planet['id'], "id_owner = 0, destruyed = {$time}"); |
107 | - if($moon) |
|
107 | + if ($moon) |
|
108 | 108 | { |
109 | 109 | db_unit_list_delete($planet['id_owner'], LOC_PLANET, $moon['id']); |
110 | 110 | db_planet_set_by_id($moon['id'], "id_owner = 0, destruyed = {$time}"); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | 'username' => $username, |
132 | 132 | )); |
133 | 133 | |
134 | -display(parsetemplate($template), classLocale::$lang['adm_pl_comp_title'], false, '', true ); |
|
134 | +display(parsetemplate($template), classLocale::$lang['adm_pl_comp_title'], false, '', true); |
|
135 | 135 | |
136 | 136 | function killer_add_planet($planet) |
137 | 137 | { |
@@ -146,34 +146,34 @@ discard block |
||
146 | 146 | } |
147 | 147 | */ |
148 | 148 | |
149 | - foreach(sn_get_groups('structures') as $unit_id) |
|
149 | + foreach (sn_get_groups('structures') as $unit_id) |
|
150 | 150 | { |
151 | 151 | $build_level = mrc_get_level($user, $planet, $unit_id, true, true); |
152 | - if($build_level > 0) |
|
152 | + if ($build_level > 0) |
|
153 | 153 | { |
154 | 154 | $unit_cost = get_unit_param($unit_id, 'cost'); |
155 | 155 | $build_factor = $unit_cost['factor'] != 1 ? (1 - pow($unit_cost['factor'], $build_level)) / (1 - $unit_cost['factor']) : $unit_cost['factor']; |
156 | - foreach($sn_group_resources_loot as $resource_id) |
|
156 | + foreach ($sn_group_resources_loot as $resource_id) |
|
157 | 157 | { |
158 | 158 | $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $build_factor) : 0; |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - foreach(sn_get_groups(array('defense', 'fleet')) as $unit_id) |
|
163 | + foreach (sn_get_groups(array('defense', 'fleet')) as $unit_id) |
|
164 | 164 | { |
165 | 165 | $unit_count = mrc_get_level($user, $planet, $unit_id, true, true); |
166 | - if($unit_count > 0) |
|
166 | + if ($unit_count > 0) |
|
167 | 167 | { |
168 | 168 | $unit_cost = get_unit_param($unit_id, 'cost'); |
169 | - foreach($sn_group_resources_loot as $resource_id) |
|
169 | + foreach ($sn_group_resources_loot as $resource_id) |
|
170 | 170 | { |
171 | 171 | $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $unit_count) : 0; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - foreach($sn_group_resources_loot as $resource_id) |
|
176 | + foreach ($sn_group_resources_loot as $resource_id) |
|
177 | 177 | { |
178 | 178 | $final_cost[$resource_id] += floor(mrc_get_level($user, $planet, $resource_id, true, true)); |
179 | 179 | } |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | |
31 | 31 | static $need_keys = array('server', 'user', 'pass', 'name', 'prefix'); |
32 | 32 | |
33 | - if($this->connected) { |
|
33 | + if ($this->connected) { |
|
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | - if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
37 | + if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
38 | 38 | $debug->error_fatal('There is missconfiguration in your config.php. Check it again'); |
39 | 39 | } |
40 | 40 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | return mysqli_fetch_assoc($query); |
85 | 85 | } |
86 | 86 | function mysql_fetch_row(&$query) { |
87 | -if(is_bool($query)) { |
|
87 | +if (is_bool($query)) { |
|
88 | 88 | pdump(debug_backtrace()); |
89 | 89 | pdie(); |
90 | 90 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | return mysqli_real_escape_string($this->link, $unescaped_string); |
95 | 95 | } |
96 | 96 | function mysql_close_link() { |
97 | - if(is_object($this->link)) { |
|
97 | + if (is_object($this->link)) { |
|
98 | 98 | $this->link->close(); |
99 | 99 | $this->connected = false; |
100 | 100 | unset($this->link); |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); |
140 | 140 | $include_blocks = $matches[1]; |
141 | - if($include_blocks) |
|
141 | + if ($include_blocks) |
|
142 | 142 | { |
143 | - foreach($include_blocks as &$included_file) |
|
143 | + foreach ($include_blocks as &$included_file) |
|
144 | 144 | { |
145 | 145 | $included_file .= '.tpl.html'; |
146 | 146 | } |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | |
447 | 447 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
448 | 448 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
449 | - $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
450 | - $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
449 | + $tag_template_php .= '$_' . $tag_args . '_val = &' . $varref . '[$_' . $tag_args . '_i];'; |
|
450 | + $tag_template_php .= '$this->_block_value["' . $tag_args . '"] = &' . $varref . '[$_' . $tag_args . '_i];'; |
|
451 | 451 | |
452 | 452 | return $tag_template_php; |
453 | 453 | } |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | break; |
552 | 552 | |
553 | 553 | case 'is': |
554 | - $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; |
|
554 | + $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1; |
|
555 | 555 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
556 | 556 | |
557 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
557 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
558 | 558 | |
559 | 559 | array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); |
560 | 560 | |
@@ -814,11 +814,11 @@ discard block |
||
814 | 814 | } |
815 | 815 | else if ($include_last_iterator) |
816 | 816 | { |
817 | - return '$_'. $blocks[$blockcount] . '_val'; |
|
817 | + return '$_' . $blocks[$blockcount] . '_val'; |
|
818 | 818 | } |
819 | 819 | else |
820 | 820 | { |
821 | - return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
|
821 | + return '$_' . $blocks[$blockcount - 1] . '_val[\'' . $blocks[$blockcount] . '\']'; |
|
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | if ($fp = @fopen($filename, 'wb')) |
836 | 836 | { |
837 | 837 | @flock($fp, LOCK_EX); |
838 | - @fwrite ($fp, $data); |
|
838 | + @fwrite($fp, $data); |
|
839 | 839 | @flock($fp, LOCK_UN); |
840 | 840 | @fclose($fp); |
841 | 841 | |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | */ |
853 | 853 | private function minify($html) |
854 | 854 | { |
855 | - if(!classSupernova::$config->tpl_minifier) |
|
855 | + if (!classSupernova::$config->tpl_minifier) |
|
856 | 856 | { |
857 | 857 | return $html; |
858 | 858 | } |
@@ -862,14 +862,14 @@ discard block |
||
862 | 862 | $html = preg_replace('/(<script[^>]*?>.*?<\/script>)/si', '#pre#', $html); |
863 | 863 | $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags |
864 | 864 | $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space |
865 | - if(!empty($pre[0])) |
|
865 | + if (!empty($pre[0])) |
|
866 | 866 | { |
867 | - foreach($pre[0] as $tag) |
|
867 | + foreach ($pre[0] as $tag) |
|
868 | 868 | { |
869 | 869 | $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside |
870 | 870 | $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one |
871 | 871 | $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one |
872 | - $html = preg_replace('/#pre#/', $tag, $html,1); |
|
872 | + $html = preg_replace('/#pre#/', $tag, $html, 1); |
|
873 | 873 | } |
874 | 874 | } |
875 | 875 |
@@ -2,28 +2,28 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(SN_IN_FLEET !== true) { |
|
5 | +if (SN_IN_FLEET !== true) { |
|
6 | 6 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | 9 | $fleetid = sys_get_param_id('fleetid'); |
10 | 10 | |
11 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
11 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
12 | 12 | header("Location: fleet.php"); |
13 | 13 | exit(); |
14 | 14 | } |
15 | 15 | |
16 | 16 | $objFleet = new Fleet(); |
17 | 17 | $objFleet->dbLoad($fleetid); |
18 | -if(!$objFleet->dbId) { |
|
18 | +if (!$objFleet->dbId) { |
|
19 | 19 | message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']); |
20 | 20 | } |
21 | 21 | |
22 | -if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
22 | +if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
23 | 23 | message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']); |
24 | 24 | } |
25 | 25 | |
26 | -if($objFleet->playerOwnerId != $user['id']) { |
|
26 | +if ($objFleet->playerOwnerId != $user['id']) { |
|
27 | 27 | $debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
28 | 28 | message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']); |
29 | 29 | } |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | |
35 | 35 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
36 | 36 | |
37 | -if($userToAdd_unsafe) { |
|
37 | +if ($userToAdd_unsafe) { |
|
38 | 38 | $userToAdd = db_escape($userToAdd_unsafe); |
39 | 39 | $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true); |
40 | 40 | $userToAddID = $userToAddID['id']; |
41 | 41 | |
42 | - if($objFleet->target_owner_id == $userToAddID) { |
|
42 | + if ($objFleet->target_owner_id == $userToAddID) { |
|
43 | 43 | message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']); |
44 | 44 | } |
45 | 45 | |
46 | - if($userToAddID) { |
|
47 | - if(!$aks) { |
|
46 | + if ($userToAddID) { |
|
47 | + if (!$aks) { |
|
48 | 48 | // No AСS exists - making one |
49 | - if(!$objFleet->group_id) { |
|
49 | + if (!$objFleet->group_id) { |
|
50 | 50 | db_acs_insert($fleetid, $user, $objFleet); |
51 | 51 | |
52 | 52 | $aks = db_acs_get_by_fleet($fleetid); |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | |
62 | 62 | $isUserExists = false; |
63 | 63 | $invited_ar = explode(",", $aks['eingeladen']); |
64 | - foreach($invited_ar as $inv) { |
|
65 | - if($userToAddID == $inv) { |
|
64 | + foreach ($invited_ar as $inv) { |
|
65 | + if ($userToAddID == $inv) { |
|
66 | 66 | $isUserExists = true; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - if(count($invited_ar) >= 5) { |
|
70 | + if (count($invited_ar) >= 5) { |
|
71 | 71 | message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']); |
72 | 72 | } |
73 | 73 | |
74 | - if($isUserExists) { |
|
74 | + if ($isUserExists) { |
|
75 | 75 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false; |
76 | 76 | } else { |
77 | 77 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | 'MISSION_NAME' => classLocale::$lang['type_mission'][MT_AKS], |
94 | 94 | )); |
95 | 95 | |
96 | -if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | - foreach($members as $row) { |
|
96 | +if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | + foreach ($members as $row) { |
|
98 | 98 | $template->assign_block_vars('invited', array( |
99 | 99 | 'NAME' => $row['username'], |
100 | 100 | )); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
120 | 120 | |
121 | 121 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
122 | -foreach($fleet_data['ships'] as $ship_data) { |
|
122 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
123 | 123 | $template->assign_block_vars('fleets.ships', $ship_data); |
124 | 124 | } |
125 | 125 |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | )); |
48 | 48 | |
49 | 49 | $ActualProd = floor($Prod[$BuildID]); |
50 | - if($BuildID != STRUC_MINE_FUSION) { |
|
50 | + if ($BuildID != STRUC_MINE_FUSION) { |
|
51 | 51 | $ActualNeed = floor($Prod[STRUC_MINE_SOLAR]); |
52 | 52 | } else { |
53 | 53 | $ActualNeed = floor($Prod[STRUC_MINE_DEUTERIUM]); |
54 | 54 | } |
55 | 55 | |
56 | 56 | $BuildStartLvl = $CurrentBuildtLvl - 2; |
57 | - if($BuildStartLvl < 1) { |
|
57 | + if ($BuildStartLvl < 1) { |
|
58 | 58 | $BuildStartLvl = 1; |
59 | 59 | } |
60 | 60 | $Table = ''; |
61 | 61 | $ProdFirst = 0; |
62 | - for($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) { |
|
63 | - if($BuildID != STRUC_MOON_PHALANX) { |
|
62 | + for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) { |
|
63 | + if ($BuildID != STRUC_MOON_PHALANX) { |
|
64 | 64 | $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value( |
65 | 65 | $CurrentUser, |
66 | 66 | $CurrentPlanet, |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | )); |
88 | 88 | |
89 | 89 | $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; |
90 | - if($ProdFirst > 0) { |
|
91 | - if($BuildID != STRUC_MINE_FUSION) { |
|
90 | + if ($ProdFirst > 0) { |
|
91 | + if ($BuildID != STRUC_MINE_FUSION) { |
|
92 | 92 | $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[$BuildID] - $ProdFirst)) . ")</font>"; |
93 | 93 | } else { |
94 | 94 | $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ProdFirst)) . ")</font>"; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } else { |
97 | 97 | $bloc['build_gain'] = ''; |
98 | 98 | } |
99 | - if($BuildID != STRUC_MINE_FUSION) { |
|
99 | + if ($BuildID != STRUC_MINE_FUSION) { |
|
100 | 100 | $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID])); |
101 | 101 | $bloc['build_prod_diff'] = pretty_number(floor($Prod[$BuildID] - $ActualProd), true, true); |
102 | 102 | $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR]), true, true); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM]), true, true); |
108 | 108 | $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM] - $ActualNeed), true, true); |
109 | 109 | } |
110 | - if($ProdFirst == 0) { |
|
111 | - if($BuildID != STRUC_MINE_FUSION) { |
|
110 | + if ($ProdFirst == 0) { |
|
111 | + if ($BuildID != STRUC_MINE_FUSION) { |
|
112 | 112 | $ProdFirst = floor($Prod[$BuildID]); |
113 | 113 | } else { |
114 | 114 | $ProdFirst = floor($Prod[STRUC_MINE_SOLAR]); |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | |
134 | 134 | $str_rapid_from = ''; |
135 | 135 | $str_rapid_to = ''; |
136 | - foreach(sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) { |
|
136 | + foreach (sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) { |
|
137 | 137 | $enemy_data = get_unit_param($enemy_id); |
138 | 138 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
139 | 139 | |
140 | 140 | $rapid = floor($unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability); |
141 | - if($rapid >= 1) { |
|
141 | + if ($rapid >= 1) { |
|
142 | 142 | $str_rapid_to .= "{$classLocale['nfo_rf_again']} {$classLocale['tech'][$enemy_id]} <font color=\"#00ff00\">{$rapid}</font><br>"; |
143 | 143 | } |
144 | 144 | |
145 | 145 | $rapid = floor($enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability); |
146 | - if($rapid >= 1) { |
|
146 | + if ($rapid >= 1) { |
|
147 | 147 | $str_rapid_from .= "{$classLocale['tech'][$enemy_id]} {$classLocale['nfo_rf_from']} <font color=\"#ff0000\">{$rapid}</font><br>"; |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - if($str_rapid_to && $str_rapid_from) { |
|
151 | + if ($str_rapid_to && $str_rapid_from) { |
|
152 | 152 | $str_rapid_to .= '<hr>'; |
153 | 153 | } |
154 | 154 | |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | $unit_id = sys_get_param_id('gid'); |
159 | -if($unit_id == RES_DARK_MATTER) { |
|
159 | +if ($unit_id == RES_DARK_MATTER) { |
|
160 | 160 | sys_redirect('dark_matter.php'); |
161 | 161 | } |
162 | 162 | |
163 | -if($unit_id == RES_METAMATTER) { |
|
163 | +if ($unit_id == RES_METAMATTER) { |
|
164 | 164 | sys_redirect('metamatter.php'); |
165 | 165 | } |
166 | 166 | |
167 | 167 | lng_include('infos'); |
168 | -if(!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) { |
|
168 | +if (!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) { |
|
169 | 169 | sys_redirect('index.php?page=techtree'); |
170 | 170 | } |
171 | 171 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $unit_data = get_unit_param($unit_id); |
175 | 175 | $unit_type = $unit_data['type']; |
176 | 176 | |
177 | -if($unit_type == UNIT_SHIPS) { |
|
177 | +if ($unit_type == UNIT_SHIPS) { |
|
178 | 178 | $template_result['UNIT_IS_SHIP'] = true; |
179 | 179 | |
180 | 180 | $ship_data = get_ship_data($unit_id, $user); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | ); |
191 | 191 | |
192 | 192 | $engine_template_info = array(); |
193 | - foreach($unit_data['engine'] as $unit_engine_data) { |
|
193 | + foreach ($unit_data['engine'] as $unit_engine_data) { |
|
194 | 194 | $unit_engine_data = get_engine_data($user, $unit_engine_data); |
195 | 195 | |
196 | 196 | $engine_template_info[] = array( |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | |
211 | 211 | $sn_data_group_combat = sn_get_groups('combat'); |
212 | -if(in_array($unit_id, $sn_data_group_combat)) { |
|
212 | +if (in_array($unit_id, $sn_data_group_combat)) { |
|
213 | 213 | $template_result['UNIT_IS_COMBAT'] = true; |
214 | 214 | |
215 | 215 | $unit_durability = $unit_data['shield'] + $unit_data['armor']; |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | $volley_arr = $rapid_to = $rapid_from = array(); |
218 | 218 | $str_rapid_from = ''; |
219 | 219 | $str_rapid_to = ''; |
220 | - foreach($sn_data_group_combat as $enemy_id) { |
|
220 | + foreach ($sn_data_group_combat as $enemy_id) { |
|
221 | 221 | $enemy_data = get_unit_param($enemy_id); |
222 | 222 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
223 | 223 | |
224 | 224 | $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability; |
225 | - if($rapid >= 1) { |
|
225 | + if ($rapid >= 1) { |
|
226 | 226 | $volley_arr[$enemy_id]['TO'] = floor($rapid); |
227 | 227 | } |
228 | 228 | |
229 | 229 | $rapid = $enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability; |
230 | - if($rapid >= 1) { |
|
230 | + if ($rapid >= 1) { |
|
231 | 231 | $volley_arr[$enemy_id]['FROM'] = floor($rapid); |
232 | 232 | } |
233 | 233 | } |
234 | - foreach($volley_arr as $enemy_id => &$rapid) { |
|
234 | + foreach ($volley_arr as $enemy_id => &$rapid) { |
|
235 | 235 | $rapid['ENEMY_ID'] = $enemy_id; |
236 | 236 | $rapid['ENEMY_NAME'] = classLocale::$lang['tech'][$enemy_id]; |
237 | 237 | } |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | |
250 | 250 | } |
251 | 251 | |
252 | -if(classLocale::$lang['info'][$unit_id]['effect']) { |
|
252 | +if (classLocale::$lang['info'][$unit_id]['effect']) { |
|
253 | 253 | $template_result['UNIT_EFFECT'] = classLocale::$lang['info'][$unit_id]['effect']; |
254 | 254 | } |
255 | 255 | |
256 | -if($unit_data['bonus']) { |
|
256 | +if ($unit_data['bonus']) { |
|
257 | 257 | $unit_bonus = !$unit_data['bonus'] || $unit_data['bonus_type'] == BONUS_ABILITY ? '' : ( |
258 | 258 | ($unit_data['bonus'] >= 0 ? '+' : '') . $unit_data['bonus'] . ($unit_data['bonus_type'] == BONUS_PERCENT ? '%' : '') |
259 | 259 | ); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) |
|
5 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) |
|
6 | 6 | { |
7 | 7 | $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
8 | 8 | } |
@@ -17,50 +17,50 @@ discard block |
||
17 | 17 | )); |
18 | 18 | |
19 | 19 | $info_action = sys_get_param_int('action'); |
20 | -if($info_action) |
|
20 | +if ($info_action) |
|
21 | 21 | { |
22 | 22 | try |
23 | 23 | { |
24 | 24 | sn_db_transaction_start(); |
25 | 25 | |
26 | 26 | $user = db_user_by_id($user['id'], true); |
27 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $config->rpg_cost_info) |
|
27 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $config->rpg_cost_info) |
|
28 | 28 | { |
29 | 29 | throw new Exception(MARKET_NO_DM, ERR_ERROR); |
30 | 30 | } |
31 | 31 | |
32 | - switch($info_action) |
|
32 | + switch ($info_action) |
|
33 | 33 | { |
34 | 34 | case MARKET_INFO_PLAYER: |
35 | 35 | $user_info_name_unsafe = sys_get_param_str_unsafe('user_info_name'); |
36 | - if(!$user_info_name_unsafe) |
|
36 | + if (!$user_info_name_unsafe) |
|
37 | 37 | { |
38 | 38 | throw new Exception(MARKET_INFO_PLAYER_WRONG, ERR_ERROR); |
39 | 39 | } |
40 | 40 | |
41 | - if(is_id($user_info_name_unsafe)) |
|
41 | + if (is_id($user_info_name_unsafe)) |
|
42 | 42 | { |
43 | 43 | $user_info = db_user_by_id($user_info_name_unsafe, true, '`id`, `username`', true); |
44 | 44 | } |
45 | - if(!is_array($user_info)) |
|
45 | + if (!is_array($user_info)) |
|
46 | 46 | { |
47 | 47 | $user_info = db_user_by_username($user_info_name_unsafe, true, '`id`, `username`', true, true); |
48 | 48 | } |
49 | - if(!is_array($user_info)) |
|
49 | + if (!is_array($user_info)) |
|
50 | 50 | { |
51 | 51 | throw new Exception(MARKET_INFO_PLAYER_NOT_FOUND, ERR_ERROR); |
52 | 52 | } |
53 | - if($user_info['id'] == $user['id']) |
|
53 | + if ($user_info['id'] == $user['id']) |
|
54 | 54 | { |
55 | 55 | throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR); |
56 | 56 | } |
57 | 57 | |
58 | 58 | $msg_text = array(); |
59 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) |
|
59 | + foreach (sn_get_groups('mercenaries') as $mercenary_id) |
|
60 | 60 | { |
61 | 61 | $msg_text[] = "{$classLocale['tech'][$mercenary_id]} - " . (($mercenary_level = mrc_get_level($user_info, null, $mercenary_id)) ? "{$classLocale['sys_level']} {$mercenary_level}" : classLocale::$lang['eco_mrk_info_not_hired']); |
62 | 62 | } |
63 | - if($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM)) |
|
63 | + if ($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM)) |
|
64 | 64 | { |
65 | 65 | $msg_text[] = "{$classLocale['tech'][UNIT_PREMIUM]} - {$mercenary_level} {$classLocale['sys_level']}"; |
66 | 66 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | break; |
75 | 75 | } |
76 | 76 | |
77 | - if(!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}")) |
|
77 | + if (!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}")) |
|
78 | 78 | { |
79 | 79 | // TODO: throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR); |
80 | 80 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | 'factor' => 1.5, |
16 | 16 | ), |
17 | 17 | P_UNIT_PRODUCTION => array( |
18 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
19 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
18 | + RES_METAL => function($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
19 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | 20 | ), |
21 | 21 | P_MINING_IS_MANAGED => true, |
22 | 22 | ), |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | 'factor' => 1.6, |
34 | 34 | ), |
35 | 35 | P_UNIT_PRODUCTION => array( |
36 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
37 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
36 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
37 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | 38 | ), |
39 | 39 | P_MINING_IS_MANAGED => true, |
40 | 40 | ), |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | 'factor' => 1.5, |
52 | 52 | ), |
53 | 53 | P_UNIT_PRODUCTION => array( |
54 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);}, |
|
55 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
54 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
55 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
56 | 56 | ), |
57 | 57 | P_MINING_IS_MANAGED => true, |
58 | 58 | ), |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'factor' => 1.5, |
70 | 70 | ), |
71 | 71 | P_UNIT_PRODUCTION => array( |
72 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
72 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
73 | 73 | ), |
74 | 74 | P_MINING_IS_MANAGED => true, |
75 | 75 | ), |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'factor' => 1.8, |
88 | 88 | ), |
89 | 89 | P_UNIT_PRODUCTION => array( |
90 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
91 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor);}, |
|
90 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
91 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
92 | 92 | ), |
93 | 93 | P_MINING_IS_MANAGED => true, |
94 | 94 | ), |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'factor' => 2, |
106 | 106 | ), |
107 | 107 | 'storage' => array( |
108 | - RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
108 | + RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
109 | 109 | ), |
110 | 110 | ), |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'factor' => 2, |
122 | 122 | ), |
123 | 123 | 'storage' => array( |
124 | - RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
124 | + RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
125 | 125 | ), |
126 | 126 | ), |
127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'factor' => 2, |
138 | 138 | ), |
139 | 139 | 'storage' => array( |
140 | - RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
140 | + RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
141 | 141 | ), |
142 | 142 | ), |
143 | 143 |
@@ -14,24 +14,24 @@ discard block |
||
14 | 14 | function sn_function_call($func_name, $func_arg = array()) { |
15 | 15 | // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
16 | 16 | |
17 | - if(is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
17 | + if (is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
18 | 18 | // Chain-callable functions should be made as following: |
19 | 19 | // 1. Never use incomplete calls with parameters "by default" |
20 | 20 | // 2. Reserve last parameter for cumulative result |
21 | 21 | // 3. Use same format for original value and cumulative result (if there is original value) |
22 | 22 | // 4. Honor cumulative result |
23 | 23 | // 5. Return cumulative result |
24 | - foreach(classSupernova::$functions[$func_name] as $func_chain_name) { |
|
24 | + foreach (classSupernova::$functions[$func_name] as $func_chain_name) { |
|
25 | 25 | // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту |
26 | 26 | // Но для старых модулей... |
27 | - if(is_callable($func_chain_name)) { |
|
27 | + if (is_callable($func_chain_name)) { |
|
28 | 28 | $result = call_user_func_array($func_chain_name, $func_arg); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | } else { |
32 | 32 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
33 | 33 | $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_' . $func_name); |
34 | - if(is_callable($func_name)) { |
|
34 | + if (is_callable($func_name)) { |
|
35 | 35 | $result = call_user_func_array($func_name, $func_arg); |
36 | 36 | } |
37 | 37 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @param string $page_name - имя страницы, для которого должен был быть выполнен хук |
47 | 47 | */ |
48 | 48 | function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) { |
49 | - if(!empty($hook_list)) { |
|
50 | - foreach($hook_list as $hook) { |
|
51 | - if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
49 | + if (!empty($hook_list)) { |
|
50 | + foreach ($hook_list as $hook) { |
|
51 | + if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
52 | 52 | $template = call_user_func($hook_call, $template, $hook_type, $page_name); |
53 | 53 | } |
54 | 54 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | |
149 | 149 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) { |
150 | 150 | $n = floatval($n); |
151 | - if(is_int($floor)) { |
|
151 | + if (is_int($floor)) { |
|
152 | 152 | $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN |
153 | - } elseif($floor === true) { |
|
153 | + } elseif ($floor === true) { |
|
154 | 154 | $n = floor($n); |
155 | 155 | $floor = 0; |
156 | 156 | } else { |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | $ret = $n; |
161 | 161 | |
162 | 162 | $suffix = ''; |
163 | - if($limit) { |
|
164 | - if($ret > 0) { |
|
165 | - while($ret > $limit) { |
|
163 | + if ($limit) { |
|
164 | + if ($ret > 0) { |
|
165 | + while ($ret > $limit) { |
|
166 | 166 | $suffix .= 'k'; |
167 | 167 | $ret = round($ret / 1000); |
168 | 168 | } |
169 | 169 | } else { |
170 | - while($ret < -$limit) { |
|
170 | + while ($ret < -$limit) { |
|
171 | 171 | $suffix .= 'k'; |
172 | 172 | $ret = round($ret / 1000); |
173 | 173 | } |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | $ret = number_format($ret, $floor, ',', '.'); |
178 | 178 | $ret .= $suffix; |
179 | 179 | |
180 | - if($color !== false) { |
|
181 | - if($color === true) { |
|
180 | + if ($color !== false) { |
|
181 | + if ($color === true) { |
|
182 | 182 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
183 | - } elseif($color >= 0) { |
|
183 | + } elseif ($color >= 0) { |
|
184 | 184 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
185 | 185 | } else { |
186 | 186 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
187 | 187 | } |
188 | 188 | |
189 | - if(!isset($style)) { |
|
189 | + if (!isset($style)) { |
|
190 | 190 | $ret = "<span class='{$class}'>{$ret}</span>"; |
191 | 191 | } else { |
192 | 192 | $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class); |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | |
312 | 312 | function sys_get_param_phone($param_name, $default = '') { |
313 | 313 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = ''); |
314 | - if($phone_raw) { |
|
314 | + if ($phone_raw) { |
|
315 | 315 | $phone = $phone_raw[0] == '+' ? '+' : ''; |
316 | - for($i = 0; $i < strlen($phone_raw); $i++) { |
|
316 | + for ($i = 0; $i < strlen($phone_raw); $i++) { |
|
317 | 317 | $ord = ord($phone_raw[$i]); |
318 | - if($ord >= 48 && $ord <= 57) { |
|
318 | + if ($ord >= 48 && $ord <= 57) { |
|
319 | 319 | $phone .= $phone_raw[$i]; |
320 | 320 | } |
321 | 321 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | function CheckAbandonPlanetState(&$planet) { |
335 | - if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
335 | + if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
336 | 336 | db_planet_delete_by_id($planet['id']); |
337 | 337 | } |
338 | 338 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | global $config; |
342 | 342 | |
343 | 343 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
344 | - if(!$rate) { |
|
344 | + if (!$rate) { |
|
345 | 345 | $sn_group_resources_all = sn_get_groups('resources_all'); |
346 | 346 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
347 | 347 | |
@@ -351,19 +351,19 @@ discard block |
||
351 | 351 | } |
352 | 352 | |
353 | 353 | $unit_cost_data = get_unit_param($unit_id, 'cost'); |
354 | - if(!is_array($unit_cost_data)) { |
|
354 | + if (!is_array($unit_cost_data)) { |
|
355 | 355 | return array('total' => 0); |
356 | 356 | } |
357 | 357 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1; |
358 | 358 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0); |
359 | 359 | $unit_level = $unit_level > 0 ? $unit_level : 0; |
360 | - foreach($unit_cost_data as $resource_id => $resource_amount) { |
|
361 | - if(!in_array($resource_id, $sn_group_resources_all)) { |
|
360 | + foreach ($unit_cost_data as $resource_id => $resource_amount) { |
|
361 | + if (!in_array($resource_id, $sn_group_resources_all)) { |
|
362 | 362 | continue; |
363 | 363 | } |
364 | 364 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1))); |
365 | 365 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor)))); |
366 | - if(in_array($resource_id, $sn_group_resources_loot)) { |
|
366 | + if (in_array($resource_id, $sn_group_resources_loot)) { |
|
367 | 367 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id]; |
368 | 368 | } |
369 | 369 | } |
@@ -447,19 +447,19 @@ discard block |
||
447 | 447 | $mercenary_level = 0; |
448 | 448 | $unit_db_name = pname_resource_name($unit_id); |
449 | 449 | |
450 | - if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
450 | + if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
451 | 451 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id); |
452 | 452 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
453 | - } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
453 | + } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
454 | 454 | $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id); |
455 | 455 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
456 | - } elseif(in_array($unit_id, sn_get_groups('governors'))) { |
|
456 | + } elseif (in_array($unit_id, sn_get_groups('governors'))) { |
|
457 | 457 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0; |
458 | - } elseif($unit_id == RES_DARK_MATTER) { |
|
458 | + } elseif ($unit_id == RES_DARK_MATTER) { |
|
459 | 459 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter); |
460 | - } elseif($unit_id == RES_METAMATTER) { |
|
460 | + } elseif ($unit_id == RES_METAMATTER) { |
|
461 | 461 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name]; |
462 | - } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
462 | + } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
463 | 463 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name]; |
464 | 464 | } |
465 | 465 | |
@@ -469,19 +469,19 @@ discard block |
||
469 | 469 | function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) { return sn_function_call(__FUNCTION__, array(&$user, $planet, $mercenaries, $value)); } |
470 | 470 | |
471 | 471 | function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) { |
472 | - if(!is_array($mercenaries)) { |
|
472 | + if (!is_array($mercenaries)) { |
|
473 | 473 | $mercenaries = array($mercenaries); |
474 | 474 | } |
475 | 475 | |
476 | 476 | $base_value = isset($base_value) ? $base_value : $value; |
477 | 477 | |
478 | - foreach($mercenaries as $mercenary_id) { |
|
478 | + foreach ($mercenaries as $mercenary_id) { |
|
479 | 479 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id); |
480 | 480 | |
481 | 481 | $mercenary = get_unit_param($mercenary_id); |
482 | 482 | $mercenary_bonus = $mercenary['bonus']; |
483 | 483 | |
484 | - switch($mercenary['bonus_type']) { |
|
484 | + switch ($mercenary['bonus_type']) { |
|
485 | 485 | case BONUS_PERCENT_CUMULATIVE: |
486 | 486 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100; |
487 | 487 | break; |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $allowed_length = strlen($allowed_chars); |
513 | 513 | |
514 | 514 | $random_string = ''; |
515 | - for($i = 0; $i < $length; $i++) { |
|
515 | + for ($i = 0; $i < $length; $i++) { |
|
516 | 516 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)]; |
517 | 517 | } |
518 | 518 | |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | |
533 | 533 | $options = ''; |
534 | 534 | $option_list = array(); |
535 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
535 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
536 | 536 | $option_list[$option_group_id] = array(); |
537 | - foreach($option_group as $option_name => $option_value) { |
|
538 | - if(!isset($user[$option_name])) { |
|
537 | + foreach ($option_group as $option_name => $option_value) { |
|
538 | + if (!isset($user[$option_name])) { |
|
539 | 539 | $user[$option_name] = $option_value; |
540 | - } elseif($user[$option_name] == '') { |
|
540 | + } elseif ($user[$option_name] == '') { |
|
541 | 541 | $user[$option_name] = 0; |
542 | 542 | } |
543 | 543 | $options .= "{$option_name}^{$user[$option_name]}|"; |
@@ -557,16 +557,16 @@ discard block |
||
557 | 557 | $option_list = array(); |
558 | 558 | $option_string_list = explode('|', $user['options']); |
559 | 559 | |
560 | - foreach($option_string_list as $option_string) { |
|
560 | + foreach ($option_string_list as $option_string) { |
|
561 | 561 | list($option_name, $option_value) = explode('^', $option_string); |
562 | 562 | $option_list[$option_name] = $option_value; |
563 | 563 | } |
564 | 564 | |
565 | 565 | $final_list = array(); |
566 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
566 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
567 | 567 | $final_list[$option_group_id] = array(); |
568 | - foreach($option_group as $option_name => $option_value) { |
|
569 | - if(!isset($option_list[$option_name])) { |
|
568 | + foreach ($option_group as $option_name => $option_value) { |
|
569 | + if (!isset($option_list[$option_name])) { |
|
570 | 570 | $option_list[$option_name] = $option_value; |
571 | 571 | } |
572 | 572 | $user[$option_name] = $final_list[$option_group_id][$option_name] = $option_list[$option_name]; |
@@ -580,12 +580,12 @@ discard block |
||
580 | 580 | |
581 | 581 | function sys_unit_str2arr($fleet_string) { |
582 | 582 | $fleet_array = array(); |
583 | - if(!empty($fleet_string)) { |
|
583 | + if (!empty($fleet_string)) { |
|
584 | 584 | $arrTemp = explode(';', $fleet_string); |
585 | - foreach($arrTemp as $temp) { |
|
586 | - if($temp) { |
|
585 | + foreach ($arrTemp as $temp) { |
|
586 | + if ($temp) { |
|
587 | 587 | $temp = explode(',', $temp); |
588 | - if(!empty($temp[0]) && !empty($temp[1])) { |
|
588 | + if (!empty($temp[0]) && !empty($temp[1])) { |
|
589 | 589 | $fleet_array[$temp[0]] += $temp[1]; |
590 | 590 | } |
591 | 591 | } |
@@ -597,13 +597,13 @@ discard block |
||
597 | 597 | |
598 | 598 | function sys_unit_arr2str($unit_list) { |
599 | 599 | $fleet_string = array(); |
600 | - if(isset($unit_list)) { |
|
601 | - if(!is_array($unit_list)) { |
|
600 | + if (isset($unit_list)) { |
|
601 | + if (!is_array($unit_list)) { |
|
602 | 602 | $unit_list = array($unit_list => 1); |
603 | 603 | } |
604 | 604 | |
605 | - foreach($unit_list as $unit_id => $unit_count) { |
|
606 | - if($unit_id && $unit_count) { |
|
605 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
606 | + if ($unit_id && $unit_count) { |
|
607 | 607 | $fleet_string[] = "{$unit_id},{$unit_count}"; |
608 | 608 | } |
609 | 609 | } |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | $body = str_replace("\r\n", "\n", $body); |
631 | 631 | $body = str_replace("\n", "\r\n", $body); |
632 | 632 | |
633 | - if($html) { |
|
633 | + if ($html) { |
|
634 | 634 | $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>'; |
635 | 635 | } |
636 | 636 | |
@@ -674,21 +674,21 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | function sn_ali_fill_user_ally(&$user) { |
677 | - if(!$user['ally_id']) { |
|
677 | + if (!$user['ally_id']) { |
|
678 | 678 | return; |
679 | 679 | } |
680 | 680 | |
681 | - if(!isset($user['ally'])) { |
|
681 | + if (!isset($user['ally'])) { |
|
682 | 682 | $user['ally'] = db_ally_get_by_id($user['ally_id']); |
683 | 683 | } |
684 | 684 | |
685 | - if(!isset($user['ally']['player'])) { |
|
685 | + if (!isset($user['ally']['player'])) { |
|
686 | 686 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false); |
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | 690 | function sn_get_url_contents($url) { |
691 | - if(function_exists('curl_init')) { |
|
691 | + if (function_exists('curl_init')) { |
|
692 | 692 | $crl = curl_init(); |
693 | 693 | $timeout = 5; |
694 | 694 | curl_setopt($crl, CURLOPT_URL, $url); |
@@ -723,10 +723,10 @@ discard block |
||
723 | 723 | |
724 | 724 | function get_ship_data($ship_id, $user) { |
725 | 725 | $ship_data = array(); |
726 | - if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
727 | - foreach(get_unit_param($ship_id, 'engine') as $engine_info) { |
|
726 | + if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
727 | + foreach (get_unit_param($ship_id, 'engine') as $engine_info) { |
|
728 | 728 | $tech_level = intval(mrc_get_level($user, null, $engine_info['tech'])); |
729 | - if(empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
729 | + if (empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
730 | 730 | $ship_data = $engine_info; |
731 | 731 | $ship_data['tech_level'] = $tech_level; |
732 | 732 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | return $ship_data; |
739 | 739 | } |
740 | 740 | |
741 | -if(!function_exists('strptime')) { |
|
741 | +if (!function_exists('strptime')) { |
|
742 | 742 | function strptime($date, $format) { |
743 | 743 | $masks = array( |
744 | 744 | '%d' => '(?P<d>[0-9]{2})', |
@@ -751,12 +751,12 @@ discard block |
||
751 | 751 | ); |
752 | 752 | |
753 | 753 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
754 | - if(preg_match($rexep, $date, $out)) { |
|
754 | + if (preg_match($rexep, $date, $out)) { |
|
755 | 755 | $ret = array( |
756 | - "tm_sec" => (int)$out['S'], |
|
757 | - "tm_min" => (int)$out['M'], |
|
758 | - "tm_hour" => (int)$out['H'], |
|
759 | - "tm_mday" => (int)$out['d'], |
|
756 | + "tm_sec" => (int) $out['S'], |
|
757 | + "tm_min" => (int) $out['M'], |
|
758 | + "tm_hour" => (int) $out['H'], |
|
759 | + "tm_mday" => (int) $out['d'], |
|
760 | 760 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
761 | 761 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
762 | 762 | ); |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | function sn_sys_sector_buy($redirect = 'overview.php') { |
772 | 772 | global $user, $planetrow; |
773 | 773 | |
774 | - if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
774 | + if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
775 | 775 | return; |
776 | 776 | } |
777 | 777 | |
@@ -784,9 +784,9 @@ discard block |
||
784 | 784 | // $planetrow = $planetrow['planet']; |
785 | 785 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); |
786 | 786 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
787 | - if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
787 | + if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
788 | 788 | $planet_name_text = uni_render_planet($planetrow); |
789 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'], |
|
789 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'], |
|
790 | 790 | $user['username'], $user['id'], $planet_name_text, classLocale::$lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost) |
791 | 791 | )) { |
792 | 792 | $sector_db_name = pname_resource_name(UNIT_SECTOR); |
@@ -801,30 +801,30 @@ discard block |
||
801 | 801 | } |
802 | 802 | |
803 | 803 | function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') { |
804 | - if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
805 | - foreach($handler_list as $function_name => $function_data) { |
|
806 | - if(is_string($function_data)) { |
|
804 | + if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
805 | + foreach ($handler_list as $function_name => $function_data) { |
|
806 | + if (is_string($function_data)) { |
|
807 | 807 | $override_with = &$function_data; |
808 | - } elseif(isset($function_data['callable'])) { |
|
808 | + } elseif (isset($function_data['callable'])) { |
|
809 | 809 | $override_with = &$function_data['callable']; |
810 | 810 | } |
811 | 811 | |
812 | 812 | $overwrite = $override_with[0] == '*'; |
813 | - if($overwrite) { |
|
813 | + if ($overwrite) { |
|
814 | 814 | $override_with = substr($override_with, 1); |
815 | 815 | } |
816 | 816 | |
817 | - if(($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
817 | + if (($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
818 | 818 | $override_with = array($class_module_name, $override_with); |
819 | - } elseif($point_position == 0) { |
|
819 | + } elseif ($point_position == 0) { |
|
820 | 820 | $override_with = substr($override_with, 1); |
821 | - } elseif($point_position > 0) { |
|
821 | + } elseif ($point_position > 0) { |
|
822 | 822 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
823 | 823 | } |
824 | 824 | |
825 | - if($overwrite) { |
|
825 | + if ($overwrite) { |
|
826 | 826 | $functions[$function_name] = array(); |
827 | - } elseif(!isset($functions[$function_name])) { |
|
827 | + } elseif (!isset($functions[$function_name])) { |
|
828 | 828 | $functions[$function_name] = array(); |
829 | 829 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
830 | 830 | $functions[$function_name][] = $sn_function_name; |
@@ -840,15 +840,15 @@ discard block |
||
840 | 840 | function player_nick_render_to_html($result, $options = false) { |
841 | 841 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
842 | 842 | |
843 | - if(is_string($result) && strpos($result, ':{i:')) { |
|
843 | + if (is_string($result) && strpos($result, ':{i:')) { |
|
844 | 844 | $result = player_nick_uncompact($result); |
845 | 845 | } |
846 | 846 | |
847 | - if(is_array($result)) { |
|
848 | - if(isset($result['id'])) { |
|
847 | + if (is_array($result)) { |
|
848 | + if (isset($result['id'])) { |
|
849 | 849 | $result = player_nick_render_current_to_array($result, $options); |
850 | 850 | } |
851 | - if(!isset($result[NICK_HTML])) { |
|
851 | + if (!isset($result[NICK_HTML])) { |
|
852 | 852 | $result = player_nick_render_array_to_html($result); |
853 | 853 | } |
854 | 854 | unset($result[NICK_HTML]); |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | try { |
872 | 872 | $result = unserialize($nick_string); |
873 | 873 | // ksort($result); // Всегда ksort-ый в player_nick_compact() |
874 | - } catch(exception $e) { |
|
874 | + } catch (exception $e) { |
|
875 | 875 | $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example |
876 | 876 | } |
877 | 877 | |
@@ -884,20 +884,20 @@ discard block |
||
884 | 884 | global $config, $user; |
885 | 885 | |
886 | 886 | // ALL STRING ARE UNSAFE!!! |
887 | - if(isset($nick_array[NICK_BIRTHSDAY])) { |
|
887 | + if (isset($nick_array[NICK_BIRTHSDAY])) { |
|
888 | 888 | $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />'; |
889 | 889 | } |
890 | 890 | |
891 | - if(isset($nick_array[NICK_VACATION])) { |
|
891 | + if (isset($nick_array[NICK_VACATION])) { |
|
892 | 892 | $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />'; |
893 | 893 | } |
894 | 894 | |
895 | - if(isset($nick_array[NICK_GENDER])) { |
|
895 | + if (isset($nick_array[NICK_GENDER])) { |
|
896 | 896 | $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />'; |
897 | 897 | } |
898 | 898 | |
899 | - if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
900 | - switch($nick_array[NICK_AUTH_LEVEL]) { |
|
899 | + if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
900 | + switch ($nick_array[NICK_AUTH_LEVEL]) { |
|
901 | 901 | case 4: |
902 | 902 | $highlight = $config->chat_highlight_developer; |
903 | 903 | break; |
@@ -918,20 +918,20 @@ discard block |
||
918 | 918 | $highlight = isset($nick_array[NICK_PREMIUM]) ? $config->chat_highlight_premium : ''; |
919 | 919 | } |
920 | 920 | |
921 | - if($highlight) { |
|
921 | + if ($highlight) { |
|
922 | 922 | list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); |
923 | 923 | } |
924 | 924 | // $result = preg_replace("#(.+)#", $highlight, $result); |
925 | 925 | } |
926 | 926 | |
927 | - if(isset($nick_array[NICK_CLASS])) { |
|
927 | + if (isset($nick_array[NICK_CLASS])) { |
|
928 | 928 | $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>'; |
929 | 929 | $result[NICK_CLASS_END] = '</span>'; |
930 | 930 | } |
931 | 931 | |
932 | 932 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]); |
933 | 933 | |
934 | - if(isset($nick_array[NICK_ALLY])) { |
|
934 | + if (isset($nick_array[NICK_ALLY])) { |
|
935 | 935 | $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']'; |
936 | 936 | } |
937 | 937 | |
@@ -955,32 +955,32 @@ discard block |
||
955 | 955 | */ |
956 | 956 | |
957 | 957 | |
958 | - if($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
958 | + if ($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
959 | 959 | $result[NICK_BIRTHSDAY] = ''; |
960 | 960 | } |
961 | 961 | |
962 | - if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
962 | + if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
963 | 963 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male'); |
964 | 964 | } |
965 | 965 | |
966 | - if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
966 | + if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
967 | 967 | $result[NICK_VACATION] = $render_user['vacation']; |
968 | 968 | } |
969 | 969 | |
970 | - if($options === true || (isset($options['color']) && $options['color'])) { |
|
971 | - if($user_auth_level = $render_user['authlevel']) { |
|
970 | + if ($options === true || (isset($options['color']) && $options['color'])) { |
|
971 | + if ($user_auth_level = $render_user['authlevel']) { |
|
972 | 972 | $result[NICK_AUTH_LEVEL] = $user_auth_level; |
973 | 973 | } |
974 | - if($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) { |
|
974 | + if ($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) { |
|
975 | 975 | $result[NICK_PREMIUM] = $user_premium; |
976 | 976 | } |
977 | 977 | } |
978 | 978 | |
979 | - if((isset($options['class']) && $options['class'])) { |
|
979 | + if ((isset($options['class']) && $options['class'])) { |
|
980 | 980 | $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class']; |
981 | 981 | } |
982 | 982 | |
983 | - if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
983 | + if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
984 | 984 | $result[NICK_ALLY] = $render_user['ally_tag']; |
985 | 985 | } |
986 | 986 | |
@@ -998,25 +998,25 @@ discard block |
||
998 | 998 | |
999 | 999 | $user_skip_list = array(); |
1000 | 1000 | |
1001 | - if($config->stats_hide_admins) { |
|
1001 | + if ($config->stats_hide_admins) { |
|
1002 | 1002 | $user_skip_list[] = '`authlevel` > 0'; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | - if($config->stats_hide_player_list) { |
|
1005 | + if ($config->stats_hide_player_list) { |
|
1006 | 1006 | $temp = explode(',', $config->stats_hide_player_list); |
1007 | - foreach($temp as $user_id) { |
|
1007 | + foreach ($temp as $user_id) { |
|
1008 | 1008 | $user_id = floatval($user_id); |
1009 | - if($user_id) { |
|
1009 | + if ($user_id) { |
|
1010 | 1010 | $user_skip_list[] = '`id` = ' . $user_id; |
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - if(!empty($user_skip_list)) { |
|
1015 | + if (!empty($user_skip_list)) { |
|
1016 | 1016 | $user_skip_list = implode(' OR ', $user_skip_list); |
1017 | 1017 | $user_skip_query = db_user_list($user_skip_list); |
1018 | - if(!empty($user_skip_query)) { |
|
1019 | - foreach($user_skip_query as $user_skip_row) { |
|
1018 | + if (!empty($user_skip_query)) { |
|
1019 | + foreach ($user_skip_query as $user_skip_row) { |
|
1020 | 1020 | $result[$user_skip_row['id']] = $user_skip_row['id']; |
1021 | 1021 | } |
1022 | 1022 | } |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | |
1048 | 1048 | function sn_sn_get_groups($groups, &$result) { |
1049 | 1049 | $result = is_array($result) ? $result : array(); |
1050 | - foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
1050 | + foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
1051 | 1051 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array(); |
1052 | 1052 | } |
1053 | 1053 | |
@@ -1075,8 +1075,8 @@ discard block |
||
1075 | 1075 | $sn_data_unit = get_unit_param($unit_id); |
1076 | 1076 | |
1077 | 1077 | $result = is_array($result) ? $result : array(); |
1078 | - if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && $config->empire_mercenary_temporary)) { |
|
1079 | - foreach($sn_data_unit[$field] as $require_id => $require_level) { |
|
1078 | + if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && $config->empire_mercenary_temporary)) { |
|
1079 | + foreach ($sn_data_unit[$field] as $require_id => $require_level) { |
|
1080 | 1080 | $level_got = mrc_get_level($user, $planetrow, $require_id); |
1081 | 1081 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true); |
1082 | 1082 | $result[] = array( |
@@ -1100,16 +1100,16 @@ discard block |
||
1100 | 1100 | |
1101 | 1101 | $ranks = array(); |
1102 | 1102 | |
1103 | - if($ally['ranklist']) { |
|
1103 | + if ($ally['ranklist']) { |
|
1104 | 1104 | $str_ranks = explode(';', $ally['ranklist']); |
1105 | - foreach($str_ranks as $str_rank) { |
|
1106 | - if(!$str_rank) { |
|
1105 | + foreach ($str_ranks as $str_rank) { |
|
1106 | + if (!$str_rank) { |
|
1107 | 1107 | continue; |
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | $tmp = explode(',', $str_rank); |
1111 | 1111 | $rank_id = count($ranks); |
1112 | - foreach($ally_rights as $key => $value) { |
|
1112 | + foreach ($ally_rights as $key => $value) { |
|
1113 | 1113 | $ranks[$rank_id][$value] = $tmp[$key]; |
1114 | 1114 | } |
1115 | 1115 | } |
@@ -1125,8 +1125,8 @@ discard block |
||
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | function array_merge_recursive_numeric($array1, $array2) { |
1128 | - if(!empty($array2) && is_array($array2)) { |
|
1129 | - foreach($array2 as $key => $value) { |
|
1128 | + if (!empty($array2) && is_array($array2)) { |
|
1129 | + foreach ($array2 as $key => $value) { |
|
1130 | 1130 | // if(!isset($array1[$key]) || !is_array($array1[$key])) { |
1131 | 1131 | // $array1[$key] = $value; |
1132 | 1132 | // } else { |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | |
1142 | 1142 | function sn_sys_array_cumulative_sum(&$array) { |
1143 | 1143 | $accum = 0; |
1144 | - foreach($array as &$value) { |
|
1144 | + foreach ($array as &$value) { |
|
1145 | 1145 | $accum += $value; |
1146 | 1146 | $value = $accum; |
1147 | 1147 | } |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | $sn_data_density = sn_get_groups('planet_density'); |
1152 | 1152 | $density_price_chart = array(); |
1153 | 1153 | |
1154 | - foreach($sn_data_density as $density_id => $density_data) { |
|
1154 | + foreach ($sn_data_density as $density_id => $density_data) { |
|
1155 | 1155 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра |
1156 | 1156 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false; |
1157 | 1157 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | $total_rarity = array_sum($density_price_chart); |
1161 | 1161 | |
1162 | - foreach($density_price_chart as &$density_data) { |
|
1162 | + foreach ($density_price_chart as &$density_data) { |
|
1163 | 1163 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE); |
1164 | 1164 | } |
1165 | 1165 | |
@@ -1167,16 +1167,16 @@ discard block |
||
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | function sn_sys_planet_core_transmute(&$user, &$planetrow) { |
1170 | - if(!sys_get_param_str('transmute')) { |
|
1170 | + if (!sys_get_param_str('transmute')) { |
|
1171 | 1171 | return array(); |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | try { |
1175 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
1175 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
1176 | 1176 | throw new exception(classLocale::$lang['ov_core_err_not_a_planet'], ERR_ERROR); |
1177 | 1177 | } |
1178 | 1178 | |
1179 | - if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
1179 | + if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
1180 | 1180 | throw new exception(classLocale::$lang['ov_core_err_same_density'], ERR_WARNING); |
1181 | 1181 | } |
1182 | 1182 | |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | $planet_density_index = $planetrow['density_index']; |
1191 | 1191 | |
1192 | 1192 | $density_price_chart = planet_density_price_chart($planetrow); |
1193 | - if(!isset($density_price_chart[$new_density_index])) { |
|
1193 | + if (!isset($density_price_chart[$new_density_index])) { |
|
1194 | 1194 | // Hack attempt |
1195 | 1195 | throw new exception(classLocale::$lang['ov_core_err_denisty_type_wrong'], ERR_ERROR); |
1196 | 1196 | } |
@@ -1199,13 +1199,13 @@ discard block |
||
1199 | 1199 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost'); |
1200 | 1200 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index]; |
1201 | 1201 | $transmute_cost = $density_price_chart[$new_density_index]; |
1202 | - if($user_dark_matter < $transmute_cost) { |
|
1202 | + if ($user_dark_matter < $transmute_cost) { |
|
1203 | 1203 | throw new exception(classLocale::$lang['ov_core_err_no_dark_matter'], ERR_ERROR); |
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | $sn_data_planet_density = sn_get_groups('planet_density'); |
1207 | - foreach($sn_data_planet_density as $key => $value) { |
|
1208 | - if($key == $new_density_index) { |
|
1207 | + foreach ($sn_data_planet_density as $key => $value) { |
|
1208 | + if ($key == $new_density_index) { |
|
1209 | 1209 | break; |
1210 | 1210 | } |
1211 | 1211 | $prev_density_index = $key; |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | 'STATUS' => ERR_NONE, |
1237 | 1237 | 'MESSAGE' => sprintf(classLocale::$lang['ov_core_err_none'], classLocale::$lang['uni_planet_density_types'][$planet_density_index], classLocale::$lang['uni_planet_density_types'][$new_density_index], $new_density), |
1238 | 1238 | ); |
1239 | - } catch(exception $e) { |
|
1239 | + } catch (exception $e) { |
|
1240 | 1240 | sn_db_transaction_rollback(); |
1241 | 1241 | $result = array( |
1242 | 1242 | 'STATUS' => $e->getCode(), |
@@ -1249,8 +1249,8 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | function sn_module_get_active_count($group = '*') { |
1251 | 1251 | $active_modules = 0; |
1252 | - if(isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
1253 | - foreach(sn_module::$sn_module_list[$group] as $payment_module) { |
|
1252 | + if (isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
1253 | + foreach (sn_module::$sn_module_list[$group] as $payment_module) { |
|
1254 | 1254 | $active_modules += $payment_module->manifest['active']; |
1255 | 1255 | } |
1256 | 1256 | } |
@@ -1261,7 +1261,7 @@ discard block |
||
1261 | 1261 | function get_resource_exchange() { |
1262 | 1262 | static $rates; |
1263 | 1263 | |
1264 | - if(!$rates) { |
|
1264 | + if (!$rates) { |
|
1265 | 1265 | global $config; |
1266 | 1266 | |
1267 | 1267 | $rates = array( |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | RES_DARK_MATTER => 'rpg_exchange_darkMatter', |
1272 | 1272 | ); |
1273 | 1273 | |
1274 | - foreach($rates as &$rate) { |
|
1274 | + foreach ($rates as &$rate) { |
|
1275 | 1275 | $rate = $config->$rate; |
1276 | 1276 | } |
1277 | 1277 | } |
@@ -1282,12 +1282,12 @@ discard block |
||
1282 | 1282 | function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { |
1283 | 1283 | static $rates; |
1284 | 1284 | |
1285 | - if(!$rates) { |
|
1285 | + if (!$rates) { |
|
1286 | 1286 | $rates = get_resource_exchange(); |
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | $metal_cost = 0; |
1290 | - foreach($cost as $resource_id => $resource_value) { |
|
1290 | + foreach ($cost as $resource_id => $resource_value) { |
|
1291 | 1291 | $metal_cost += $rates[$resource_id] * $resource_value; |
1292 | 1292 | } |
1293 | 1293 | |
@@ -1297,8 +1297,8 @@ discard block |
||
1297 | 1297 | function get_player_max_expeditons(&$user, $astrotech = -1) { return sn_function_call(__FUNCTION__, array(&$user, $astrotech, &$result)); } |
1298 | 1298 | |
1299 | 1299 | function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) { |
1300 | - if($astrotech == -1) { |
|
1301 | - if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
1300 | + if ($astrotech == -1) { |
|
1301 | + if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
1302 | 1302 | $astrotech = mrc_get_level($user, null, TECH_ASTROTECH); |
1303 | 1303 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0; |
1304 | 1304 | } |
@@ -1316,8 +1316,8 @@ discard block |
||
1316 | 1316 | function get_player_max_colonies(&$user, $astrotech = -1) { |
1317 | 1317 | global $config; |
1318 | 1318 | |
1319 | - if($astrotech == -1) { |
|
1320 | - if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
1319 | + if ($astrotech == -1) { |
|
1320 | + if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
1321 | 1321 | |
1322 | 1322 | $expeditions = get_player_max_expeditons($user); |
1323 | 1323 | $astrotech = mrc_get_level($user, null, TECH_ASTROTECH); |
@@ -1362,10 +1362,10 @@ discard block |
||
1362 | 1362 | |
1363 | 1363 | // pdump($powerup_unit, '$powerup_unit'); |
1364 | 1364 | $level_current = $term_original = $time_left = 0; |
1365 | - if($is_upgrade) { |
|
1365 | + if ($is_upgrade) { |
|
1366 | 1366 | $time_finish = strtotime($powerup_unit['unit_time_finish']); |
1367 | 1367 | $time_left = max(0, $time_finish - SN_TIME_NOW); |
1368 | - if($time_left > 0) { |
|
1368 | + if ($time_left > 0) { |
|
1369 | 1369 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']); |
1370 | 1370 | $level_current = $powerup_unit['unit_level']; |
1371 | 1371 | } |
@@ -1373,22 +1373,22 @@ discard block |
||
1373 | 1373 | |
1374 | 1374 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK]; |
1375 | 1375 | $original_cost = 0; |
1376 | - for($i = 1; $i <= $level_max; $i++) { |
|
1376 | + for ($i = 1; $i <= $level_max; $i++) { |
|
1377 | 1377 | $base_cost = eco_get_total_cost($powerup_id, $i); |
1378 | 1378 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER]; |
1379 | - foreach($sn_powerup_buy_discounts as $period => $discount) { |
|
1379 | + foreach ($sn_powerup_buy_discounts as $period => $discount) { |
|
1380 | 1380 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH); |
1381 | 1381 | $result[$i][$period] = $upgrade_price; |
1382 | 1382 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost; |
1383 | 1383 | } |
1384 | 1384 | } |
1385 | 1385 | |
1386 | - if($is_upgrade && $time_left) { |
|
1386 | + if ($is_upgrade && $time_left) { |
|
1387 | 1387 | $term_original = round($term_original / PERIOD_DAY); |
1388 | 1388 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
1389 | 1389 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
1390 | 1390 | |
1391 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
1391 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
1392 | 1392 | $value -= $cost_left; |
1393 | 1393 | }); |
1394 | 1394 | } |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | |
1447 | 1447 | function print_rr($var, $capture = false) { |
1448 | 1448 | $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>'; |
1449 | - if($capture) { |
|
1449 | + if ($capture) { |
|
1450 | 1450 | return $print; |
1451 | 1451 | } else { |
1452 | 1452 | print($print); |