These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * resources.php |
||
5 | * |
||
6 | * Planet resource interface page |
||
7 | * |
||
8 | * 2.2 - copyright (ñ) 2010 by Gorlum for http://supernova.ws |
||
9 | * [~] - more optimization to utilize PTE |
||
10 | * [~] - code formatting according to PCG |
||
11 | * [~] - content of BuildRessourcePage.php moved to resource.php |
||
12 | * 2.1 - copyright 2010 by Gorlum for http://supernova.ws |
||
13 | * [~] - Security checked for SQL-injection |
||
14 | * 2.0 - copyright 2010 by Gorlum for http://supernova.ws |
||
15 | * [+] - almost fully rewrote and optimized |
||
16 | * 1.0 [BuildRessourcePage.php] copyright 2008 by ShadoV for XNova |
||
17 | * [+] - Mise en module initiale (creation) |
||
18 | * 1.1 - copyright 2010 by Gorlum for http://supernova.ws |
||
19 | * [%] - Security checks & tests by Gorlum for http://supernova.ws |
||
20 | * 1.0 copyright (ñ) 2008 by Chlorel for XNova |
||
21 | * [!] - Passage en fonction pour utilisation XNova |
||
22 | * |
||
23 | **/ |
||
24 | |||
25 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
26 | |||
27 | function int_calc_storage_bar($resource_id) |
||
28 | { |
||
29 | global $template, $caps_real, $planetrow, $user; |
||
30 | |||
31 | $totalProduction = $caps_real['total'][$resource_id]; |
||
32 | $storage_fill = $caps_real['total_storage'][$resource_id] ? floor(mrc_get_level($user, $planetrow, $resource_id) / $caps_real['total_storage'][$resource_id] * 100) : 0; |
||
33 | |||
34 | $template->assign_block_vars('resources', array( |
||
35 | 'NAME' => classLocale::$lang["sys_" . pname_resource_name($resource_id)], |
||
36 | |||
37 | // 'BASIC_INCOME'=> $config->$resource_income_name * game_resource_multiplier(), |
||
38 | |||
39 | 'HOURLY' => pretty_number($totalProduction, true, true), |
||
40 | 'WEEKLY' => pretty_number($totalProduction * 24 * 7, true, true), |
||
41 | 'DAILY' => pretty_number($totalProduction * 24, true, true), |
||
42 | 'MONTHLY' => pretty_number($totalProduction * 24 * 30, true, true), |
||
43 | |||
44 | 'STORAGE' => intval($storage_fill), |
||
45 | 'BAR' => min($storage_fill, 100), |
||
46 | )); |
||
47 | }; |
||
48 | |||
49 | $ValidList['percent'] = array ( 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ); |
||
50 | $template = gettemplate('resources', true); |
||
51 | |||
52 | $transmutation_result = sn_sys_planet_core_transmute($user, $planetrow); |
||
53 | if(!empty($transmutation_result)) |
||
54 | { |
||
55 | $template->assign_block_vars('result', $transmutation_result); // array('STATUS' => $transmutation_result['STATUS'], 'MESSAGE' => $transmutation_result['MESSAGE'])); |
||
56 | } |
||
57 | |||
58 | $sn_group_factories = sn_get_groups('factories'); |
||
59 | $production = $_POST['production']; |
||
60 | //$SubQry = ''; |
||
61 | $SubQry = array(); |
||
62 | if(is_array($production)) { |
||
63 | foreach($production as $prod_id => $percent) { |
||
64 | if($percent > 100 || $percent < 0) { |
||
65 | $debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true)); |
||
66 | die(); |
||
67 | } |
||
68 | |||
69 | $prod_id = intval($prod_id); |
||
70 | if(in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) { |
||
71 | $field_name = pname_factory_production_field_name($prod_id); |
||
72 | $percent = floor($percent / 10); |
||
73 | $planetrow[$field_name] = $percent; |
||
74 | //$SubQry .= "`{$field_name}` = '{$percent}',"; |
||
75 | $SubQry[] = "`{$field_name}` = '{$percent}'"; |
||
76 | } else { |
||
77 | $debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301); |
||
78 | continue; |
||
79 | } |
||
80 | } |
||
81 | |||
82 | // $SubQry = substr($SubQry, 0, -1); |
||
83 | // if($SubQry) { |
||
84 | // db_planet_set_by_id($planetrow['id'], $SubQry); |
||
85 | // } |
||
86 | !empty($SubQry) ? db_planet_set_by_id($planetrow['id'], implode(',', $SubQry)) : false; |
||
87 | } |
||
88 | |||
89 | // ------------------------------------------------------------------------------------------------------- |
||
90 | // $BuildTemp = $planetrow[ 'temp_max' ]; |
||
91 | // $BuildEnergyTech = $user['energy_tech']; |
||
92 | |||
93 | for ($Option = 10; $Option >= 0; $Option--) |
||
94 | { |
||
95 | $template->assign_block_vars('option', array( |
||
96 | 'VALUE' => $Option * 10, |
||
97 | )); |
||
98 | } |
||
99 | |||
100 | $caps_real = eco_get_planet_caps($user, $planetrow, 3600); |
||
101 | |||
102 | $template->assign_block_vars('production', array( |
||
103 | 'TYPE' => classLocale::$lang['res_basic_income'], |
||
104 | |||
105 | 'METAL_TYPE' => pretty_number($caps_real['production'][RES_METAL][0], true, true), |
||
106 | 'CRYSTAL_TYPE' => pretty_number($caps_real['production'][RES_CRYSTAL][0], true, true), |
||
107 | 'DEUTERIUM_TYPE' => pretty_number($caps_real['production'][RES_DEUTERIUM][0], true, true), |
||
108 | 'ENERGY_TYPE' => pretty_number($caps_real['production'][RES_ENERGY][0], true, true), |
||
109 | )); |
||
110 | |||
111 | foreach($sn_group_factories as $unit_id) |
||
112 | { |
||
113 | if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) |
||
114 | { |
||
115 | $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true); |
||
116 | $template->assign_block_vars('production', array( |
||
117 | 'ID' => $unit_id, |
||
118 | // 'NAME' => $resource_db_name, |
||
119 | 'PERCENT' => $planetrow[pname_factory_production_field_name($unit_id)] * 10, |
||
120 | 'TYPE' => classLocale::$lang['tech'][$unit_id], |
||
121 | 'LEVEL' => $level_plain, |
||
122 | 'LEVEL_BONUS' => mrc_get_level($user, $planetrow, $unit_id) - $level_plain, |
||
123 | 'LEVEL_TYPE' => ($unit_id > 200) ? classLocale::$lang['quantity'] : classLocale::$lang['level'], |
||
124 | |||
125 | 'METAL_TYPE' => pretty_number($caps_real['production'][RES_METAL][$unit_id], true, true), |
||
126 | 'CRYSTAL_TYPE' => pretty_number($caps_real['production'][RES_CRYSTAL][$unit_id], true, true), |
||
127 | 'DEUTERIUM_TYPE' => pretty_number($caps_real['production'][RES_DEUTERIUM][$unit_id], true, true), |
||
128 | 'ENERGY_TYPE' => pretty_number($caps_real['production'][RES_ENERGY][$unit_id], true, true), |
||
129 | |||
130 | 'METAL_FULL' => pretty_number($caps_real['production_full'][RES_METAL][$unit_id], true, true), |
||
131 | 'CRYSTAL_FULL' => pretty_number($caps_real['production_full'][RES_CRYSTAL][$unit_id], true, true), |
||
132 | 'DEUTERIUM_FULL' => pretty_number($caps_real['production_full'][RES_DEUTERIUM][$unit_id], true, true), |
||
133 | 'ENERGY_FULL' => pretty_number($caps_real['production_full'][RES_ENERGY][$unit_id], true, true), |
||
134 | |||
135 | 'SELECT' => $row_select, |
||
136 | 'P_MINING_IS_MANAGED' => get_unit_param($unit_id, P_MINING_IS_MANAGED), |
||
137 | |||
138 | )); |
||
139 | } |
||
140 | } |
||
141 | |||
142 | $user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER); |
||
0 ignored issues
–
show
|
|||
143 | $planet_density_index = $planetrow['density_index']; |
||
144 | $density_price_chart = planet_density_price_chart($planetrow); |
||
145 | tpl_planet_density_info($template, $density_price_chart, $user_dark_matter); |
||
146 | |||
147 | $template->assign_block_vars('production', array( |
||
148 | 'TYPE' => classLocale::$lang['res_total'], |
||
149 | |||
150 | 'METAL_TYPE' => pretty_number($caps_real['total'][RES_METAL], true, true), |
||
151 | 'CRYSTAL_TYPE' => pretty_number($caps_real['total'][RES_CRYSTAL], true, true), |
||
152 | 'DEUTERIUM_TYPE' => pretty_number($caps_real['total'][RES_DEUTERIUM], true, true), |
||
153 | 'ENERGY_TYPE' => pretty_number($caps_real['total'][RES_ENERGY], true, true), |
||
154 | |||
155 | 'METAL_FULL' => pretty_number($caps_real['total_production_full'][RES_METAL], true, true), |
||
156 | 'CRYSTAL_FULL' => pretty_number($caps_real['total_production_full'][RES_CRYSTAL], true, true), |
||
157 | 'DEUTERIUM_FULL' => pretty_number($caps_real['total_production_full'][RES_DEUTERIUM], true, true), |
||
158 | 'ENERGY_FULL' => pretty_number($caps_real['total_production_full'][RES_ENERGY], true, true), |
||
159 | )); |
||
160 | |||
161 | int_calc_storage_bar(RES_METAL); |
||
162 | int_calc_storage_bar(RES_CRYSTAL); |
||
163 | int_calc_storage_bar(RES_DEUTERIUM); |
||
164 | |||
165 | $template->assign_vars(array( |
||
166 | 'PLANET_NAME' => $planetrow['name'], |
||
167 | 'PLANET_TYPE' => $planetrow['planet_type'], |
||
168 | 'PLANET_DENSITY_INDEX' => $planet_density_index, |
||
169 | 'PLANET_CORE_TEXT' => classLocale::$lang['uni_planet_density_types'][$planet_density_index], |
||
170 | |||
171 | 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), |
||
172 | |||
173 | 'PAGE_HINT' => classLocale::$lang['res_hint'], |
||
174 | )); |
||
175 | |||
176 | display($template, classLocale::$lang['res_planet_production']); |
||
177 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: