@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public static function _init($group_name = '') { |
27 | 27 | parent::_init($group_name); |
28 | 28 | |
29 | - foreach(static::$_group_unit_id_list as $resource_id) { |
|
29 | + foreach (static::$_group_unit_id_list as $resource_id) { |
|
30 | 30 | static::$_group_pnames[$resource_id] = pname_resource_name($resource_id); |
31 | 31 | } |
32 | 32 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | !is_array($resource_array) ? $resource_array = array() : false; |
50 | 50 | |
51 | - foreach($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | - if(!$resource_actual_delta) { |
|
51 | + foreach ($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | + if (!$resource_actual_delta) { |
|
53 | 53 | // No delta - no changes |
54 | 54 | continue; |
55 | 55 | } |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | (!empty($where_safe) ? " WHERE {$where_safe}" : '') . |
38 | 38 | " FOR UPDATE;" |
39 | 39 | ); |
40 | - while($row = db_fetch($query)) { |
|
40 | + while ($row = db_fetch($query)) { |
|
41 | 41 | /** |
42 | 42 | * @var Fleet $fleet |
43 | 43 | */ |
44 | 44 | $fleet = $this->_createElement(); |
45 | 45 | $fleet->dbRowParse($row); |
46 | 46 | |
47 | - if(isset($this[$fleet->dbId])) { |
|
47 | + if (isset($this[$fleet->dbId])) { |
|
48 | 48 | // Нужно ли ???? |
49 | 49 | classSupernova::$debug->error('Fleet list already set'); |
50 | 50 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return static |
171 | 171 | */ |
172 | 172 | public static function dbGetFleetListAndMissileByCoordinates($coordinates, $for_phalanx = false) { |
173 | - if(empty($coordinates) || !is_array($coordinates)) { |
|
173 | + if (empty($coordinates) || !is_array($coordinates)) { |
|
174 | 174 | return array(); |
175 | 175 | } |
176 | 176 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @var Fleet[] $array_of_Fleet |
200 | 200 | */ |
201 | 201 | $array_of_Fleet = array(); |
202 | - if(!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
203 | - foreach($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
202 | + if (!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
203 | + foreach ($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
204 | 204 | $array_of_Fleet[$fleet_id] = $objFleet; |
205 | 205 | } |
206 | 206 | $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | "SELECT * FROM `{{iraks}}`" . |
250 | 250 | (!empty($where) ? " WHERE {$where}" : '') . |
251 | 251 | " FOR UPDATE;"); |
252 | - while($missile_db_row = db_fetch($query)) { |
|
252 | + while ($missile_db_row = db_fetch($query)) { |
|
253 | 253 | /** |
254 | 254 | * @var Fleet $objFleet |
255 | 255 | */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public static function dbGetFleetListAndMissileINCOMING($owner_id) { |
273 | 273 | $owner_id_safe = idval($owner_id); |
274 | - if(empty($owner_id_safe)) { |
|
274 | + if (empty($owner_id_safe)) { |
|
275 | 275 | return array(); |
276 | 276 | } |
277 | 277 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public static function fleet_count_flying($player_id, $mission_id = 0) { |
307 | 307 | $player_id_safe = idval($player_id); |
308 | - if(!empty($player_id_safe)) { |
|
308 | + if (!empty($player_id_safe)) { |
|
309 | 309 | $mission_id_safe = intval($mission_id); |
310 | 310 | $result = static::db_fleet_count( |
311 | 311 | "`fleet_owner` = {$player_id_safe}" . |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | |
123 | 123 | $update_cache = false; |
124 | 124 | |
125 | - if(!empty($this->to_write)) { |
|
126 | - foreach($this->to_write as $key => &$value) { |
|
125 | + if (!empty($this->to_write)) { |
|
126 | + foreach ($this->to_write as $key => &$value) { |
|
127 | 127 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
128 | 128 | $value = array($this->user_id, $key, $value); |
129 | 129 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | $update_cache = true; |
142 | 142 | } |
143 | 143 | |
144 | - if(!empty($this->to_delete)) { |
|
145 | - foreach($this->to_delete as $key => &$value) { |
|
146 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
144 | + if (!empty($this->to_delete)) { |
|
145 | + foreach ($this->to_delete as $key => &$value) { |
|
146 | + $value = is_string($key) ? "'" . db_escape($key) . "'" : $key; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | classSupernova::$db->doDeleteDanger( |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $update_cache = true; |
161 | 161 | } |
162 | 162 | |
163 | - if($update_cache) { |
|
163 | + if ($update_cache) { |
|
164 | 164 | $field_name = $this->cached_name(); |
165 | 165 | classSupernova::$cache->$field_name = $this->data; |
166 | 166 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | protected function load() { |
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 = classSupernova::$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 = classSupernova::$db->doSelect("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 | } |
@@ -290,14 +290,14 @@ discard block |
||
290 | 290 | // Если в массиве индекса только один элемент - значит это просто индекс |
291 | 291 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
292 | 292 | |
293 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
293 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
294 | 294 | $this->load(); |
295 | 295 | } |
296 | 296 | |
297 | - if(is_array($option_id)) { |
|
297 | + if (is_array($option_id)) { |
|
298 | 298 | $result = $this->data; |
299 | - foreach($option_id as $sub_key) { |
|
300 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
299 | + foreach ($option_id as $sub_key) { |
|
300 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
301 | 301 | $result = null; |
302 | 302 | break; |
303 | 303 | } |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | * @param null|mixed $value |
316 | 316 | */ |
317 | 317 | public function __set($option, $value = null) { |
318 | - if(empty($option) || !$this->user_id) { |
|
318 | + if (empty($option) || !$this->user_id) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Если в массиве индекса только один элемент - значит это просто индекс |
323 | - if(is_array($option) && count($option) == 1) { |
|
323 | + if (is_array($option) && count($option) == 1) { |
|
324 | 324 | // Разворачиваем его в индекс |
325 | 325 | $option = array(reset($option) => $value); |
326 | 326 | unset($value); |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | |
330 | 330 | $to_write = array(); |
331 | 331 | // Адресация многомерного массива через массив индексов в $option |
332 | - if(is_array($option) && isset($value)) { |
|
332 | + if (is_array($option) && isset($value)) { |
|
333 | 333 | $a_data = &$this->data; |
334 | - foreach($option as $option_id) { |
|
334 | + foreach ($option as $option_id) { |
|
335 | 335 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
336 | 336 | $a_data = &$a_data[$option_id]; |
337 | 337 | } |
338 | - if($a_data != $value) { |
|
338 | + if ($a_data != $value) { |
|
339 | 339 | $a_data = $value; |
340 | 340 | $to_write[reset($option)] = null; |
341 | 341 | } |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | // Пакетная запись из массива ключ -> значение |
344 | 344 | !is_array($option) ? $option = array($option => $value) : false; |
345 | 345 | |
346 | - foreach($option as $option_id => $option_value) { |
|
347 | - if($this->data[$option_id] !== $option_value) { |
|
346 | + foreach ($option as $option_id => $option_value) { |
|
347 | + if ($this->data[$option_id] !== $option_value) { |
|
348 | 348 | // TODO - вынести отдельно в обработчик |
349 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
349 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
350 | 350 | sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
351 | 351 | } |
352 | 352 | |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | - if(!empty($to_write)) { |
|
359 | + if (!empty($to_write)) { |
|
360 | 360 | $field_name = $this->cached_name(); |
361 | 361 | classSupernova::$cache->$field_name = $this->data; |
362 | 362 | |
363 | - foreach($to_write as $option_id => &$option_value) { |
|
363 | + foreach ($to_write as $option_id => &$option_value) { |
|
364 | 364 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
365 | 365 | $option_value = array($this->user_id, $option_id, $option_value); |
366 | 366 | } |
@@ -376,26 +376,26 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | protected function load() { |
379 | - if($this->loaded) { |
|
379 | + if ($this->loaded) { |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
383 | 383 | $this->data = $this->defaults; |
384 | 384 | |
385 | - if(!$this->user_id) { |
|
385 | + if (!$this->user_id) { |
|
386 | 386 | return; |
387 | 387 | } |
388 | 388 | |
389 | 389 | $field_name = $this->cached_name(); |
390 | 390 | $a_data = classSupernova::$cache->$field_name; |
391 | 391 | |
392 | - if(!empty($a_data)) { |
|
392 | + if (!empty($a_data)) { |
|
393 | 393 | $this->data = array_replace($this->data, $a_data); |
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | 397 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
398 | - while($row = db_fetch($query)) { |
|
398 | + while ($row = db_fetch($query)) { |
|
399 | 399 | // $this->data[$row['option_id']] = $row['value']; |
400 | 400 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
401 | 401 | } |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | return $this->__get($offset); |
412 | 412 | } |
413 | 413 | public function offsetSet($offset, $value) { |
414 | - if(!is_null($offset)) { |
|
414 | + if (!is_null($offset)) { |
|
415 | 415 | // $this->data[$offset] = $value; |
416 | 416 | $this->__set($offset, $value); |
417 | 417 | } else { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | public function compile_request($request) { |
449 | 449 | global $user; |
450 | 450 | |
451 | - if(!(classSupernova::$auth->account instanceof Account)) { |
|
451 | + if (!(classSupernova::$auth->account instanceof Account)) { |
|
452 | 452 | // TODO - throw new Exception(lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
453 | 453 | } |
454 | 454 | $this->account = classSupernova::$auth->account; |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
470 | 470 | $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency); |
471 | 471 | |
472 | - if(empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
472 | + if (empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
473 | 473 | $this->payment_external_currency = $this->config['currency']; |
474 | 474 | } |
475 | - if(empty($this->payment_external_currency)) { |
|
475 | + if (empty($this->payment_external_currency)) { |
|
476 | 476 | throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET); |
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency); |
480 | - if($this->payment_external_amount < 0.01) { |
|
480 | + if ($this->payment_external_amount < 0.01) { |
|
481 | 481 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
482 | 482 | } |
483 | 483 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | $this->generate_description(); |
487 | 487 | |
488 | 488 | $this->db_insert(); |
489 | - if(!$this->is_exists) { |
|
489 | + if (!$this->is_exists) { |
|
490 | 490 | throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE); |
491 | 491 | } |
492 | 492 | } |
@@ -498,24 +498,24 @@ discard block |
||
498 | 498 | * @throws Exception |
499 | 499 | */ |
500 | 500 | protected function payment_request_process($options = array()) { |
501 | - if(!$this->manifest['active']) { |
|
501 | + if (!$this->manifest['active']) { |
|
502 | 502 | throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED); |
503 | 503 | } |
504 | 504 | |
505 | 505 | // Если есть payment_id - загружаем под него данные |
506 | - if(!empty($this->payment_params['payment_id'])) { |
|
506 | + if (!empty($this->payment_params['payment_id'])) { |
|
507 | 507 | $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']); |
508 | - if(!$this->request_payment_id) { |
|
508 | + if (!$this->request_payment_id) { |
|
509 | 509 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
510 | 510 | } |
511 | 511 | |
512 | - if(!$this->db_get_by_id($this->request_payment_id)) { |
|
512 | + if (!$this->db_get_by_id($this->request_payment_id)) { |
|
513 | 513 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
514 | 514 | } |
515 | 515 | |
516 | 516 | // Проверяем - был ли этот платеж обработан? |
517 | 517 | // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed |
518 | - if($this->payment_status != PAYMENT_STATUS_NONE) { |
|
518 | + if ($this->payment_status != PAYMENT_STATUS_NONE) { |
|
519 | 519 | sn_db_transaction_rollback(); |
520 | 520 | sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id); |
521 | 521 | die(); |
@@ -525,89 +525,89 @@ discard block |
||
525 | 525 | // Пытаемся получить из запроса ИД аккаунта |
526 | 526 | $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0; |
527 | 527 | // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id |
528 | - if(empty($request_account_id) && !empty($this->payment_account_id)) { |
|
528 | + if (empty($request_account_id) && !empty($this->payment_account_id)) { |
|
529 | 529 | $request_account_id = $this->payment_account_id; |
530 | 530 | } |
531 | 531 | // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать |
532 | - if(empty($request_account_id)) { |
|
532 | + if (empty($request_account_id)) { |
|
533 | 533 | // TODO - аккаунт |
534 | 534 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
535 | 535 | } |
536 | 536 | // Если нет записи в таблице - тогда берем payment_account_id из запроса |
537 | - if(empty($this->payment_account_id)) { |
|
537 | + if (empty($this->payment_account_id)) { |
|
538 | 538 | $this->payment_account_id = $request_account_id; |
539 | 539 | } |
540 | 540 | // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать |
541 | - if($this->payment_account_id != $request_account_id) { |
|
541 | + if ($this->payment_account_id != $request_account_id) { |
|
542 | 542 | // TODO - Поменять сообщение об ошибке |
543 | 543 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
544 | 544 | } |
545 | 545 | // Проверяем существование аккаунта с данным ИД |
546 | - if(!$this->account->db_get_by_id($this->payment_account_id)) { |
|
546 | + if (!$this->account->db_get_by_id($this->payment_account_id)) { |
|
547 | 547 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
548 | 548 | } |
549 | 549 | |
550 | 550 | // TODO Проверка на сервер_ид - как бы и не нужна, наверное? |
551 | - if(!empty($this->payment_params['server_id'])) { |
|
551 | + if (!empty($this->payment_params['server_id'])) { |
|
552 | 552 | $this->request_server_id = sys_get_param_str($this->payment_params['server_id']); |
553 | - if(SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
553 | + if (SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
554 | 554 | throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
558 | 558 | // Сверка количества оплаченной ММ с учётом бонусов |
559 | - if(!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
559 | + if (!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
560 | 560 | $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']); |
561 | - if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
561 | + if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
562 | 562 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID); |
563 | 563 | } |
564 | 564 | empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false; |
565 | 565 | } |
566 | - if(empty($this->payment_dark_matter_paid)) { |
|
566 | + if (empty($this->payment_dark_matter_paid)) { |
|
567 | 567 | // TODO - обратный расчёт из gained |
568 | 568 | } |
569 | 569 | |
570 | 570 | // Проверка наличия внешнего ИД платежа |
571 | - if(!empty($this->payment_params['payment_external_id'])) { |
|
571 | + if (!empty($this->payment_params['payment_external_id'])) { |
|
572 | 572 | $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']); |
573 | - if(empty($request_payment_external_id)) { |
|
573 | + if (empty($request_payment_external_id)) { |
|
574 | 574 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
575 | - } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
575 | + } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
576 | 576 | // TODO - Может быть поменять сообщение |
577 | 577 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
578 | 578 | } |
579 | 579 | $this->payment_external_id = $request_payment_external_id; |
580 | 580 | } |
581 | 581 | // Сверка суммы, запрошенной СН к оплате |
582 | - if(!empty($this->payment_params['payment_external_money'])) { |
|
582 | + if (!empty($this->payment_params['payment_external_money'])) { |
|
583 | 583 | $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']); |
584 | - if($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
584 | + if ($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
585 | 585 | throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
586 | 586 | } |
587 | 587 | empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false; |
588 | 588 | } |
589 | 589 | // Заполняем поле валюты платёжной системы |
590 | - if(!empty($this->payment_params['payment_external_currency'])) { |
|
590 | + if (!empty($this->payment_params['payment_external_currency'])) { |
|
591 | 591 | $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']); |
592 | - if(empty($this->payment_external_currency)) { |
|
592 | + if (empty($this->payment_external_currency)) { |
|
593 | 593 | // TODO - поменять сообщение |
594 | 594 | throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
595 | 595 | } |
596 | 596 | } |
597 | - if(empty($this->payment_external_currency)) { |
|
597 | + if (empty($this->payment_external_currency)) { |
|
598 | 598 | $this->payment_external_currency = $this->config['currency']; |
599 | 599 | } |
600 | 600 | |
601 | 601 | // Заполнение внутренней суммы и валюты из внешних данных |
602 | - if(empty($this->payment_currency)) { |
|
602 | + if (empty($this->payment_currency)) { |
|
603 | 603 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
604 | 604 | } |
605 | - if(empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
605 | + if (empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
606 | 606 | $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency); |
607 | 607 | } |
608 | 608 | |
609 | 609 | // TODO - Тестовый режим |
610 | - if(!empty($this->payment_params['test'])) { |
|
610 | + if (!empty($this->payment_params['test'])) { |
|
611 | 611 | $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']); |
612 | 612 | } |
613 | 613 | |
@@ -634,12 +634,12 @@ discard block |
||
634 | 634 | sn_db_transaction_start(); |
635 | 635 | try { |
636 | 636 | $response = $this->payment_request_process(); |
637 | - } catch(Exception $e) { |
|
637 | + } catch (Exception $e) { |
|
638 | 638 | $response['result'] = $e->getCode(); |
639 | 639 | $response['message'] = $e->getMessage(); |
640 | 640 | } |
641 | 641 | |
642 | - if($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
642 | + if ($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
643 | 643 | sn_db_transaction_commit(); |
644 | 644 | classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT); |
645 | 645 | } else { |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | } |
649 | 649 | |
650 | 650 | // Переводим код результата из СН в код платежной системы |
651 | - if(is_array($this->result_translations) && !empty($this->result_translations)) { |
|
651 | + if (is_array($this->result_translations) && !empty($this->result_translations)) { |
|
652 | 652 | $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR]; |
653 | 653 | } |
654 | 654 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | $currency_from = strtolower($currency_from); |
672 | 672 | $currency_to = strtolower($currency_to); |
673 | 673 | |
674 | - if($currency_from != $currency_to) { |
|
674 | + if ($currency_from != $currency_to) { |
|
675 | 675 | $exchange_from = get_exchange_rate($currency_from); |
676 | 676 | $exchange_to = get_exchange_rate($currency_to); |
677 | 677 | |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) { |
696 | 696 | $bonus = 0; |
697 | 697 | $dark_matter_new = $dark_matter; |
698 | - if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
699 | - if($direct) { |
|
700 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
701 | - if($dm_for_bonus <= $dark_matter) { |
|
698 | + if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
699 | + if ($direct) { |
|
700 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
701 | + if ($dm_for_bonus <= $dark_matter) { |
|
702 | 702 | $dark_matter_new = $dark_matter * (1 + $multiplier); |
703 | 703 | $bonus = $multiplier; |
704 | 704 | } else { |
@@ -706,9 +706,9 @@ discard block |
||
706 | 706 | } |
707 | 707 | } |
708 | 708 | } else { |
709 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
709 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
710 | 710 | $temp = $dm_for_bonus * (1 + $multiplier); |
711 | - if($dark_matter >= $temp) { |
|
711 | + if ($dark_matter >= $temp) { |
|
712 | 712 | $dark_matter_new = round($dark_matter / (1 + $multiplier)); |
713 | 713 | $bonus = $multiplier; |
714 | 714 | } else { |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | 'payment_external_lots' => $this->payment_dark_matter_paid / get_mm_cost(), |
762 | 762 | ); |
763 | 763 | |
764 | - if($this->payment_id) { |
|
764 | + if ($this->payment_id) { |
|
765 | 765 | $payment['payment_id'] = $this->payment_id; |
766 | 766 | classSupernova::$gc->db->doReplaceSet('payment', $payment); |
767 | 767 | } else { |
@@ -773,12 +773,12 @@ discard block |
||
773 | 773 | |
774 | 774 | |
775 | 775 | public function payment_adjust_mm_new() { |
776 | - if(!$this->payment_test) { |
|
776 | + if (!$this->payment_test) { |
|
777 | 777 | // Not a test payment. Adding DM to account |
778 | 778 | $this->account = new Account($this->db); |
779 | 779 | $this->account->db_get_by_id($this->payment_account_id); |
780 | 780 | $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment); |
781 | - if(!$result) { |
|
781 | + if (!$result) { |
|
782 | 782 | throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
783 | 783 | } |
784 | 784 | } |
@@ -787,25 +787,25 @@ discard block |
||
787 | 787 | public function payment_cancel(&$payment) { |
788 | 788 | die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}'); |
789 | 789 | |
790 | - if(!isset($payment['payment_status'])) { |
|
790 | + if (!isset($payment['payment_status'])) { |
|
791 | 791 | throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND); |
792 | 792 | } |
793 | 793 | |
794 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
795 | - $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']; |
|
794 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
795 | + $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] . ' ' . $payment['payment_comment']; |
|
796 | 796 | |
797 | - if(!$payment['payment_test']) { |
|
797 | + if (!$payment['payment_test']) { |
|
798 | 798 | $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']); |
799 | - if(!$result) { |
|
799 | + if (!$result) { |
|
800 | 800 | throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
801 | 801 | } |
802 | 802 | } |
803 | 803 | $payment['payment_status'] = PAYMENT_STATUS_CANCELED; |
804 | 804 | db_payment_update($payment['payment_id'], $payment['payment_status'], $comment_unsafe); |
805 | 805 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK); |
806 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
806 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
807 | 807 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK); |
808 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
808 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
809 | 809 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE); |
810 | 810 | } |
811 | 811 | } |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | |
829 | 829 | protected function db_complete_payment() { |
830 | 830 | // TODO - поле payment_processed |
831 | - if($this->payment_status == PAYMENT_STATUS_NONE) { |
|
832 | - if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
831 | + if ($this->payment_status == PAYMENT_STATUS_NONE) { |
|
832 | + if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
833 | 833 | $this->payment_adjust_mm_new(); |
834 | 834 | $this->payment_status = PAYMENT_STATUS_COMPLETE; |
835 | 835 | } else { |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | protected function db_assign_payment($payment = null) { |
877 | 877 | $this->payment_reset(); |
878 | 878 | |
879 | - if(is_array($payment) && isset($payment['payment_id'])) { |
|
879 | + if (is_array($payment) && isset($payment['payment_id'])) { |
|
880 | 880 | $this->payment_id = $payment['payment_id']; |
881 | 881 | $this->payment_status = $payment['payment_status']; |
882 | 882 | $this->payment_date = $payment['payment_date']; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @return $this |
32 | 32 | */ |
33 | 33 | public function literal($value) { |
34 | - $this->literal = (string)$value; |
|
34 | + $this->literal = (string) $value; |
|
35 | 35 | |
36 | 36 | return $this; |
37 | 37 | } |
@@ -119,7 +119,7 @@ |
||
119 | 119 | if ($this->contains($object)) { |
120 | 120 | $this->indexUnset($object); |
121 | 121 | } |
122 | - if($this->indexSet($object, $data)) { |
|
122 | + if ($this->indexSet($object, $data)) { |
|
123 | 123 | // Attaches object only if index sets successfully |
124 | 124 | parent::attach($object, $data); |
125 | 125 | } |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | // $method = new \ReflectionMethod($callable[0], $callable[1]); |
71 | 71 | // $callable = $method->getClosure($callable[0]); |
72 | 72 | // } |
73 | - if(is_array($callable) && ($invoker = Invoker::build($callable))) { |
|
73 | + if (is_array($callable) && ($invoker = Invoker::build($callable))) { |
|
74 | 74 | $callable = $invoker; |
75 | 75 | } |
76 | 76 | |
77 | 77 | $functionName = $accessor . $varName; |
78 | 78 | $this->accessors[$functionName] = $callable; |
79 | - if($shared == ACCESSOR_SHARED) { |
|
79 | + if ($shared == ACCESSOR_SHARED) { |
|
80 | 80 | $this->shared[$functionName] = true; |
81 | 81 | } |
82 | 82 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | $functionName = $accessor . $varName; |
111 | - if(!isset($this->shared[$functionName]) || !array_key_exists($functionName, $this->executed)) { |
|
111 | + if (!isset($this->shared[$functionName]) || !array_key_exists($functionName, $this->executed)) { |
|
112 | 112 | $this->executed[$functionName] = call_user_func_array($this->accessors[$functionName], $params); |
113 | 113 | } |
114 | 114 |
@@ -68,8 +68,7 @@ |
||
68 | 68 | $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0; |
69 | 69 | $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0; |
70 | 70 | $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0; |
71 | - $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : |
|
72 | - (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
71 | + $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
73 | 72 | $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type; |
74 | 73 | |
75 | 74 | return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
210 | 210 | if (!empty($temp['unit_id'])) { |
211 | - $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
211 | + $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
212 | 212 | LOC_UNIT, |
213 | 213 | $temp['unit_id'], |
214 | 214 | array(), |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | } else { |
220 | 220 | $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id; |
221 | 221 | $unitType = get_unit_param($unit_id, P_UNIT_TYPE); |
222 | - $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record( |
|
222 | + $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record( |
|
223 | 223 | LOC_UNIT, |
224 | 224 | array( |
225 | 225 | 'unit_player_id' => $user['id'], |
226 | - 'unit_location_type' => (int)$unit_location, |
|
226 | + 'unit_location_type' => (int) $unit_location, |
|
227 | 227 | 'unit_location_id' => $locationIdRendered, |
228 | - 'unit_type' => (int)$unitType, |
|
229 | - 'unit_snid' => (int)$unit_id, |
|
230 | - 'unit_level' => (float)$unit_value, |
|
228 | + 'unit_type' => (int) $unitType, |
|
229 | + 'unit_snid' => (int) $unit_id, |
|
230 | + 'unit_level' => (float) $unit_value, |
|
231 | 231 | ) |
232 | 232 | ); |
233 | 233 | } |