@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
10 | 10 | |
11 | -if(!sn_module::sn_module_get_active_count('payment')) { |
|
11 | +if (!sn_module::sn_module_get_active_count('payment')) { |
|
12 | 12 | sys_redirect('dark_matter.php'); |
13 | 13 | die(); |
14 | 14 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | // $player_currency_default = player_load_option($user, PLAYER_OPTION_CURRENCY_DEFAULT); |
24 | 24 | $player_currency_default = classSupernova::$user_options[PLAYER_OPTION_CURRENCY_DEFAULT]; |
25 | 25 | $player_currency = sys_get_param_str('player_currency', $player_currency_default); |
26 | -empty(classSupernova::$lang['pay_currency_list'][$player_currency]) ? ($player_currency = $player_currency_default ? $player_currency_default : classSupernova::$config->payment_currency_default) : false; |
|
26 | +empty(classSupernova::$lang['pay_currency_list'][$player_currency]) ? ($player_currency = $player_currency_default ? $player_currency_default : classSupernova::$config->payment_currency_default) : false; |
|
27 | 27 | // $player_currency_default != $player_currency ? player_save_option($user, PLAYER_OPTION_CURRENCY_DEFAULT, $player_currency) : false; |
28 | 28 | $player_currency_default != $player_currency ? classSupernova::$user_options[PLAYER_OPTION_CURRENCY_DEFAULT] = $player_currency : false; |
29 | 29 | |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | |
66 | 66 | // Таблица скидок |
67 | 67 | $prev_discount = 0; |
68 | -if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
|
69 | - foreach(sn_module_payment::$bonus_table as $sum => $discount) { |
|
70 | - if($discount && $discount != $prev_discount) { |
|
68 | +if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
|
69 | + foreach (sn_module_payment::$bonus_table as $sum => $discount) { |
|
70 | + if ($discount && $discount != $prev_discount) { |
|
71 | 71 | $template->assign_block_vars('discount', array( |
72 | 72 | 'SUM' => $sum, |
73 | 73 | 'DISCOUNT' => $discount * 100, |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | // Результат платежа |
83 | -if($payment_id = sys_get_param_id('payment_id')) { |
|
83 | +if ($payment_id = sys_get_param_id('payment_id')) { |
|
84 | 84 | $payment = doquery("SELECT * FROM {{payment}} WHERE `payment_id` = {$payment_id} LIMIT 1;", true); |
85 | - if($payment && $payment['payment_user_id'] == $user['id']) { |
|
86 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
85 | + if ($payment && $payment['payment_user_id'] == $user['id']) { |
|
86 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
87 | 87 | $template->assign_block_vars('result', array('MESSAGE' => sprintf(classSupernova::$lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained']))); |
88 | 88 | } |
89 | - if($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
89 | + if ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
90 | 90 | $template->assign_block_vars('result', array( |
91 | 91 | 'MESSAGE' => sprintf(classSupernova::$lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']), |
92 | 92 | 'STATUS' => 1, |
93 | 93 | )); |
94 | 94 | } |
95 | - if($payment['payment_test']) { |
|
95 | + if ($payment['payment_test']) { |
|
96 | 96 | $template->assign_block_vars('result', array( |
97 | 97 | 'MESSAGE' => sprintf(classSupernova::$lang['pay_msg_mm_purchase_test']), |
98 | 98 | 'STATUS' => -1, |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'metamatter' => sys_get_param_float('metamatter'), |
108 | 108 | ); |
109 | 109 | |
110 | -if(!$request['metamatter']) { |
|
110 | +if (!$request['metamatter']) { |
|
111 | 111 | unset($_POST); |
112 | 112 | } |
113 | 113 | |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | |
119 | 119 | $payment_module_valid = false; |
120 | 120 | $payment_module = sys_get_param_str('payment_module'); |
121 | -foreach($sn_module_list['payment'] as $module_name => $module) { |
|
122 | - if(!is_object($module) || !$module->manifest['active']) { |
|
121 | +foreach ($sn_module_list['payment'] as $module_name => $module) { |
|
122 | + if (!is_object($module) || !$module->manifest['active']) { |
|
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
126 | 126 | lng_include($module_name, $module->manifest['root_relative']); |
127 | 127 | |
128 | - foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
129 | - foreach($available_methods as $payment_method => $payment_currency) { |
|
130 | - if(isset($module->manifest['payment_method'][$payment_method])) { |
|
128 | + foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
129 | + foreach ($available_methods as $payment_method => $payment_currency) { |
|
130 | + if (isset($module->manifest['payment_method'][$payment_method])) { |
|
131 | 131 | $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method]; |
132 | 132 | } |
133 | 133 | } |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | |
139 | 139 | global $template_result; |
140 | 140 | // Доступные платежные методы |
141 | -foreach($payment_methods_available as $payment_type_id => $payment_methods) { |
|
142 | - if(empty($payment_methods)) continue; |
|
141 | +foreach ($payment_methods_available as $payment_type_id => $payment_methods) { |
|
142 | + if (empty($payment_methods)) continue; |
|
143 | 143 | |
144 | - $template_result['.']['payment'][$payment_type_id] =array( |
|
144 | + $template_result['.']['payment'][$payment_type_id] = array( |
|
145 | 145 | 'ID' => $payment_type_id, |
146 | 146 | 'NAME' => classSupernova::$lang['pay_methods'][$payment_type_id], |
147 | 147 | ); |
148 | - foreach($payment_methods as $payment_method_id => $module_list) { |
|
149 | - if(empty($module_list)) { |
|
148 | + foreach ($payment_methods as $payment_method_id => $module_list) { |
|
149 | + if (empty($module_list)) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array( |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | 'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']), |
158 | 158 | 'BUTTON' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']), |
159 | 159 | ); |
160 | - foreach($module_list as $payment_module_name => $payment_module_method_details) { |
|
160 | + foreach ($module_list as $payment_module_name => $payment_module_method_details) { |
|
161 | 161 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array( |
162 | 162 | 'MODULE' => $payment_module_name, |
163 | 163 | ); |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - if(empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
167 | + if (empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
168 | 168 | unset($template_result['.']['payment'][$payment_type_id]); |
169 | 169 | } |
170 | 170 | } |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name])); |
178 | 178 | |
179 | 179 | // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it |
180 | -if($payment_module_valid) { |
|
180 | +if ($payment_module_valid) { |
|
181 | 181 | // $payment_module = $payment_module; // Really - do nothing |
182 | -} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
182 | +} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
183 | 183 | reset($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
184 | 184 | $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
185 | -} elseif(count($sn_module_list['payment']) == 1) { |
|
185 | +} elseif (count($sn_module_list['payment']) == 1) { |
|
186 | 186 | $payment_module = $module_name; |
187 | 187 | } else { |
188 | 188 | $payment_module = ''; |
189 | 189 | } |
190 | 190 | |
191 | -if($payment_type_selected && $payment_method_selected) { |
|
192 | - foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
191 | +if ($payment_type_selected && $payment_method_selected) { |
|
192 | + foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
193 | 193 | $template->assign_block_vars('payment_module', array( |
194 | 194 | 'ID' => $module_name, |
195 | 195 | 'NAME' => classSupernova::$lang["module_{$module_name}_name"], |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | -foreach(classSupernova::$lang['pay_currency_list'] as $key => $value) { |
|
201 | +foreach (classSupernova::$lang['pay_currency_list'] as $key => $value) { |
|
202 | 202 | $course = get_exchange_rate($key); |
203 | - if(!$course) { |
|
203 | + if (!$course) { |
|
204 | 204 | continue; |
205 | 205 | } |
206 | 206 | $template->assign_block_vars('exchange', array( |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | )); |
215 | 215 | } |
216 | 216 | |
217 | -if($request['metamatter'] && $payment_module) { |
|
217 | +if ($request['metamatter'] && $payment_module) { |
|
218 | 218 | try { |
219 | 219 | // Any possible errors about generating paylink should be raised in module! |
220 | 220 | $pay_link = $sn_module[$payment_module]->compile_request($request); |
221 | 221 | |
222 | 222 | // Поддержка дополнительной информации |
223 | - if(is_array($pay_link['RENDER'])) { |
|
224 | - foreach($pay_link['RENDER'] as $html_data) { |
|
223 | + if (is_array($pay_link['RENDER'])) { |
|
224 | + foreach ($pay_link['RENDER'] as $html_data) { |
|
225 | 225 | $template->assign_block_vars('render', $html_data); |
226 | - if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
227 | - foreach($html_data['VALUE'] as $value_id => $value_value) { |
|
226 | + if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
227 | + foreach ($html_data['VALUE'] as $value_id => $value_value) { |
|
228 | 228 | $template->assign_block_vars('render.value', array( |
229 | 229 | 'FIELD' => $value_id, |
230 | 230 | 'VALUE' => $value_value, |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | // Поддержка передачи данных для многошаговых платежных систем |
238 | - if(is_array($pay_link['DATA'])) { |
|
239 | - foreach($pay_link['DATA'] as $key => $value) { |
|
238 | + if (is_array($pay_link['DATA'])) { |
|
239 | + foreach ($pay_link['DATA'] as $key => $value) { |
|
240 | 240 | $template->assign_block_vars('pay_link_data', array( |
241 | 241 | 'FIELD' => $key, |
242 | 242 | 'VALUE' => $value, |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
247 | + if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
248 | 248 | // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте |
249 | 249 | $template->assign_vars(array( |
250 | 250 | 'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'], |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | } else { |
254 | 254 | throw new exception(classSupernova::$lang['pay_msg_request_paylink_unsupported'], ERR_ERROR); |
255 | 255 | } |
256 | - } catch(exception $e) { |
|
256 | + } catch (exception $e) { |
|
257 | 257 | $template->assign_block_vars('result', $response = array( |
258 | 258 | 'STATUS' => $e->getCode(), |
259 | 259 | 'MESSAGE' => $e->getMessage(), |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | // Прегенерированные пакеты |
266 | -foreach($unit_available_amount_list as $unit_amount => $discount) { |
|
266 | +foreach ($unit_available_amount_list as $unit_amount => $discount) { |
|
267 | 267 | $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency); |
268 | 268 | $template->assign_block_vars('mm_amount', array( |
269 | 269 | 'VALUE' => $unit_amount, |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | 'PLAYER_CURRENCY' => $player_currency, |
299 | 299 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
300 | 300 | |
301 | - 'UNIT_AMOUNT' => (float)$request['metamatter'], |
|
301 | + 'UNIT_AMOUNT' => (float) $request['metamatter'], |
|
302 | 302 | 'UNIT_AMOUNT_TEXT' => HelperString::numberFloorAndFormat($request['metamatter']), |
303 | 303 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
304 | 304 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |
@@ -12,24 +12,24 @@ discard block |
||
12 | 12 | global $debug, $template_result, $user, $lang, $planetrow; |
13 | 13 | |
14 | 14 | // Напоминание для Администрации, что игра отключена |
15 | -if($template_result[F_GAME_DISABLE]) { |
|
15 | +if ($template_result[F_GAME_DISABLE]) { |
|
16 | 16 | echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>'; |
17 | 17 | } |
18 | 18 | unset($disable_reason); |
19 | 19 | |
20 | 20 | |
21 | -if(defined('IN_ADMIN') && IN_ADMIN === true) { |
|
21 | +if (defined('IN_ADMIN') && IN_ADMIN === true) { |
|
22 | 22 | lng_include('admin'); |
23 | -} elseif($sys_user_logged_in) { |
|
23 | +} elseif ($sys_user_logged_in) { |
|
24 | 24 | sys_user_vacation($user); |
25 | 25 | |
26 | 26 | $planet_id = SetSelectedPlanet($user); |
27 | 27 | |
28 | 28 | // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!! |
29 | - if($user['ally_id']) { |
|
29 | + if ($user['ally_id']) { |
|
30 | 30 | sn_db_transaction_start(); |
31 | 31 | \Alliance\Alliance::sn_ali_fill_user_ally($user); |
32 | - if(!$user['ally']['player']['id']) { |
|
32 | + if (!$user['ally']['player']['id']) { |
|
33 | 33 | // sn_sys_logout(false, true); |
34 | 34 | // core_auth::logout(false); |
35 | 35 | classSupernova::$auth->logout(false); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
50 | 50 | $planetrow = $global_data['planet']; |
51 | - if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
51 | + if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
52 | 52 | // sn_sys_logout(false, true); |
53 | 53 | // core_auth::logout(false); |
54 | 54 | classSupernova::$auth->logout(false); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | sys_user_options_unpack($user); |
64 | 64 | |
65 | 65 | global $sn_page_name, $sn_mvc; |
66 | -if(!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) { |
|
66 | +if (!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) { |
|
67 | 67 | $title = !empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE]) ? $sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE] : ''; |
68 | 68 | renderHeader($page, $title, $template_result, false, $user, classSupernova::$config, $lang, $planetrow); |
69 | 69 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | |
18 | 18 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
19 | 19 | |
20 | -if(!sn_module::sn_module_get_active_count('payment')) { |
|
20 | +if (!sn_module::sn_module_get_active_count('payment')) { |
|
21 | 21 | sys_redirect(SN_ROOT_VIRTUAL . 'admin/overview.php'); |
22 | 22 | } |
23 | 23 |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if(sn_module::sn_module_get_active_count('payment') && !defined('SN_GOOGLE')) { |
|
5 | +if (sn_module::sn_module_get_active_count('payment') && !defined('SN_GOOGLE')) { |
|
6 | 6 | sys_redirect('metamatter.php'); |
7 | 7 | } |
8 | 8 |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | public function __construct(GlobalContainer $services = null) { |
77 | 77 | parent::__construct($services); |
78 | 78 | |
79 | - if(empty(static::$shipInfo)) { |
|
80 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
79 | + if (empty(static::$shipInfo)) { |
|
80 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
81 | 81 | static::$shipInfo[$unit_id] = get_unit_param($unit_id); |
82 | 82 | static::$shipInfo[$unit_id][P_COST_METAL] = get_unit_cost_in(static::$shipInfo[$unit_id][P_COST]); |
83 | 83 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @inheritdoc |
104 | 104 | */ |
105 | 105 | public function update() { |
106 | - if($this->getShipCount() < 1) { |
|
106 | + if ($this->getShipCount() < 1) { |
|
107 | 107 | return $this->delete(); |
108 | 108 | } |
109 | 109 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getCostInMetal() { |
129 | 129 | $result = 0; |
130 | - foreach($this->shipList as $shipId => $amount) { |
|
130 | + foreach ($this->shipList as $shipId => $amount) { |
|
131 | 131 | $result += $amount * $this->getShipCostInMetal($shipId); |
132 | 132 | } |
133 | 133 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function getCapacity() { |
150 | 150 | $result = 0; |
151 | - foreach($this->shipList as $shipId => $amount) { |
|
151 | + foreach ($this->shipList as $shipId => $amount) { |
|
152 | 152 | $result += $amount * $this->getShipCapacity($shipId); |
153 | 153 | } |
154 | 154 | |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function changeShipCount($shipSnId, $shipCount) { |
167 | 167 | !isset($this->shipList[$shipSnId]) ? $this->shipList[$shipSnId] = 0 : false; |
168 | - if($this->shipList[$shipSnId] + $shipCount < 0) { |
|
168 | + if ($this->shipList[$shipSnId] + $shipCount < 0) { |
|
169 | 169 | throw new \Exception("Trying to deduct more ships [{$shipSnId}] '{$shipCount}' then fleet has {$this->shipList[$shipSnId]}"); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $this->shipList[$shipSnId] += $shipCount; |
173 | - if($this->shipList[$shipSnId] <= 0) { |
|
173 | + if ($this->shipList[$shipSnId] <= 0) { |
|
174 | 174 | unset($this->shipList[$shipSnId]); |
175 | 175 | } |
176 | 176 | |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | * @throws \Exception |
186 | 186 | */ |
187 | 187 | public function changeResource($resourceId, $resourceCount) { |
188 | - if(!array_key_exists($resourceId, $this->resources)) { |
|
188 | + if (!array_key_exists($resourceId, $this->resources)) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | - if($this->resources[$resourceId] + $resourceCount < 0) { |
|
192 | + if ($this->resources[$resourceId] + $resourceCount < 0) { |
|
193 | 193 | throw new \Exception("Trying to deduct more resources [{$resourceId}] '{$resourceCount}' then fleet has {$this->resources[$resourceId]}"); |
194 | 194 | } |
195 | 195 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @var int[] $shipsToRemove |
35 | 35 | */ |
36 | - protected $shipsToRemove = [SHIP_COLONIZER, SHIP_SPY,]; |
|
36 | + protected $shipsToRemove = [SHIP_COLONIZER, SHIP_SPY, ]; |
|
37 | 37 | |
38 | 38 | // ------------------------------------------------------------------------------------------------------------------- |
39 | 39 | /** |
@@ -278,8 +278,7 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | // Adding outcome message to the front of other info |
281 | - array_unshift($this->message, is_string($messages) ? $messages : |
|
282 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '')); |
|
281 | + array_unshift($this->message, is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '')); |
|
283 | 282 | } |
284 | 283 | |
285 | 284 | /** |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | |
134 | 134 | $update_cache = false; |
135 | 135 | |
136 | - if(!empty($this->to_write)) { |
|
137 | - foreach($this->to_write as $key => $cork) { |
|
136 | + if (!empty($this->to_write)) { |
|
137 | + foreach ($this->to_write as $key => $cork) { |
|
138 | 138 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
139 | 139 | $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')"; |
140 | 140 | } |
@@ -145,18 +145,18 @@ discard block |
||
145 | 145 | $update_cache = true; |
146 | 146 | } |
147 | 147 | |
148 | - if(!empty($this->to_delete)) { |
|
149 | - foreach($this->to_delete as $key => &$value) { |
|
150 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
148 | + if (!empty($this->to_delete)) { |
|
149 | + foreach ($this->to_delete as $key => &$value) { |
|
150 | + $value = is_string($key) ? "'" . db_escape($key) . "'" : $key; |
|
151 | 151 | } |
152 | 152 | |
153 | - doquery("DELETE FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") "); |
|
153 | + doquery("DELETE FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} AND `option_id` IN (" . implode(',', $this->to_delete) . ") "); |
|
154 | 154 | |
155 | 155 | $this->to_delete = array(); |
156 | 156 | $update_cache = true; |
157 | 157 | } |
158 | 158 | |
159 | - if($update_cache) { |
|
159 | + if ($update_cache) { |
|
160 | 160 | global $sn_cache; |
161 | 161 | |
162 | 162 | $field_name = $this->cached_name(); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | protected function load() { |
184 | 184 | global $sn_cache; |
185 | 185 | |
186 | - if($this->loaded) { |
|
186 | + if ($this->loaded) { |
|
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $this->to_write = array(); |
192 | 192 | $this->to_delete = array(); |
193 | 193 | |
194 | - if(!$this->user_id) { |
|
194 | + if (!$this->user_id) { |
|
195 | 195 | $this->loaded = true; |
196 | 196 | return; |
197 | 197 | } |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | $field_name = $this->cached_name(); |
200 | 200 | $a_data = $sn_cache->$field_name; |
201 | 201 | |
202 | - if(!empty($a_data)) { |
|
202 | + if (!empty($a_data)) { |
|
203 | 203 | $this->data = array_replace_recursive($this->data, $a_data); |
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
208 | - while($row = db_fetch($query)) { |
|
208 | + while ($row = db_fetch($query)) { |
|
209 | 209 | // $this->data[$row['option_id']] = $row['value']; |
210 | 210 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
211 | 211 | } |
@@ -58,8 +58,8 @@ |
||
58 | 58 | protected function bonusSort(BonusAtom $a, BonusAtom $b) { |
59 | 59 | static $bonusOrder = [BonusAtom::class, BonusAtomAbility::class, BonusAtomAdd::class, BonusAtomPercent::class, BonusAtomMultiply::class]; |
60 | 60 | |
61 | - $indexA = (int)array_search(get_class($a), $bonusOrder); |
|
62 | - $indexB = (int)array_search(get_class($b), $bonusOrder); |
|
61 | + $indexA = (int) array_search(get_class($a), $bonusOrder); |
|
62 | + $indexB = (int) array_search(get_class($b), $bonusOrder); |
|
63 | 63 | |
64 | 64 | return $indexA == $indexB ? 0 : ($indexA > $indexB ? +1 : -1); |
65 | 65 | } |
@@ -564,9 +564,9 @@ discard block |
||
564 | 564 | 2 => 0.01, |
565 | 565 | ), |
566 | 566 | P_MISSION_EXPEDITION_OUTCOME_SECONDARY => array( |
567 | - 90 => [P_MULTIPLIER => 0.01, P_MESSAGE_ID => 2,], |
|
568 | - 99 => [P_MULTIPLIER => 0.02, P_MESSAGE_ID => 1,], |
|
569 | - 100 => [P_MULTIPLIER => 0.10, P_MESSAGE_ID => 0,], |
|
567 | + 90 => [P_MULTIPLIER => 0.01, P_MESSAGE_ID => 2, ], |
|
568 | + 99 => [P_MULTIPLIER => 0.02, P_MESSAGE_ID => 1, ], |
|
569 | + 100 => [P_MULTIPLIER => 0.10, P_MESSAGE_ID => 0, ], |
|
570 | 570 | ), |
571 | 571 | ), |
572 | 572 | FLT_EXPEDITION_OUTCOME_FOUND_RESOURCES => array( |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | 2 => 0.025, |
579 | 579 | ), |
580 | 580 | P_MISSION_EXPEDITION_OUTCOME_SECONDARY => array( |
581 | - 90 => [P_MULTIPLIER => 0.025, P_MESSAGE_ID => 2,], |
|
582 | - 99 => [P_MULTIPLIER => 0.050, P_MESSAGE_ID => 1,], |
|
583 | - 100 => [P_MULTIPLIER => 0.100, P_MESSAGE_ID => 0,], |
|
581 | + 90 => [P_MULTIPLIER => 0.025, P_MESSAGE_ID => 2, ], |
|
582 | + 99 => [P_MULTIPLIER => 0.050, P_MESSAGE_ID => 1, ], |
|
583 | + 100 => [P_MULTIPLIER => 0.100, P_MESSAGE_ID => 0, ], |
|
584 | 584 | ), |
585 | 585 | ), |
586 | 586 | FLT_EXPEDITION_OUTCOME_FOUND_DM => array( |