@@ -51,7 +51,7 @@ |
||
51 | 51 | */ |
52 | 52 | public static function db_acs_insert($fleetid, $userId, $objFleet) { |
53 | 53 | classSupernova::$db->doInsertSet(TABLE_AKS, array( |
54 | - 'name' => classLocale::$lang['flt_acs_prefix'] . $fleetid, |
|
54 | + 'name' => classLocale::$lang['flt_acs_prefix'].$fleetid, |
|
55 | 55 | 'teilnehmer' => $userId, |
56 | 56 | 'flotten' => $fleetid, |
57 | 57 | 'ankunft' => $objFleet->time_arrive_to_target, |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | $allow_anonymous = true; |
12 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
12 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
13 | 13 | |
14 | 14 | nws_mark_read($user); |
15 | 15 | $template = gettemplate('announce', true); |
@@ -23,42 +23,42 @@ discard block |
||
23 | 23 | $mode = sys_get_param_str('mode'); |
24 | 24 | |
25 | 25 | $announce = array(); |
26 | -if($user['authlevel'] >= 3) { |
|
27 | - if(!empty($text)) { |
|
26 | +if ($user['authlevel'] >= 3) { |
|
27 | + if (!empty($text)) { |
|
28 | 28 | $announce_time = strtotime($announce_time, SN_TIME_NOW); |
29 | 29 | $announce_time = $announce_time ? $announce_time : SN_TIME_NOW; |
30 | 30 | |
31 | - if($mode == 'edit') { |
|
31 | + if ($mode == 'edit') { |
|
32 | 32 | DBStaticNews::db_news_update_set($announce_time, $text, $detail_url, $announce_id); |
33 | 33 | DBStaticSurvey::db_survey_delete_by_id($announce_id); |
34 | 34 | } else { |
35 | 35 | DBStaticNews::db_news_insert_set($announce_time, $text_unsafe, $detail_url_unsafe, $user['id'], $user['username']); |
36 | 36 | $announce_id = classSupernova::$db->db_insert_id(); |
37 | 37 | } |
38 | - if(($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) { |
|
38 | + if (($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) { |
|
39 | 39 | $survey_answers = explode("\r\n", $survey_answers); |
40 | 40 | $survey_until = strtotime($survey_until = sys_get_param_str('survey_until'), SN_TIME_NOW); |
41 | 41 | $survey_until = date(FMT_DATE_TIME_SQL, $survey_until ? $survey_until : SN_TIME_NOW + PERIOD_DAY * 1); |
42 | 42 | $survey_question_unsafe = sys_get_param_str_unsafe('survey_question'); |
43 | 43 | DBStaticSurvey::db_survey_insert($announce_id, $survey_question_unsafe, $survey_until); |
44 | 44 | $survey_id = classSupernova::$db->db_insert_id(); |
45 | - foreach($survey_answers as $survey_answer) { |
|
45 | + foreach ($survey_answers as $survey_answer) { |
|
46 | 46 | $survey_answer_unsafe = trim($survey_answer); |
47 | - if(empty($survey_answer_unsafe)) { |
|
47 | + if (empty($survey_answer_unsafe)) { |
|
48 | 48 | continue; |
49 | 49 | } |
50 | 50 | DBStaticSurveyAnswer::db_survey_answer_insert($survey_id, $survey_answer_unsafe); |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - if($announce_time <= SN_TIME_NOW) { |
|
55 | - if($announce_time > classSupernova::$config->var_news_last && $announce_time == SN_TIME_NOW) { |
|
54 | + if ($announce_time <= SN_TIME_NOW) { |
|
55 | + if ($announce_time > classSupernova::$config->var_news_last && $announce_time == SN_TIME_NOW) { |
|
56 | 56 | classSupernova::$config->db_saveItem('var_news_last', $announce_time); |
57 | 57 | } |
58 | 58 | |
59 | - if(sys_get_param_int('news_mass_mail')) { |
|
59 | + if (sys_get_param_int('news_mass_mail')) { |
|
60 | 60 | $lang_news_more = classLocale::$lang['news_more']; |
61 | - $text = sys_get_param('text') . ($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang_news_more}</span></a>" : ''); |
|
61 | + $text = sys_get_param('text').($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang_news_more}</span></a>" : ''); |
|
62 | 62 | DBStaticMessages::msgSendFromAdmin('*', classLocale::$lang['news_title'], $text); |
63 | 63 | } |
64 | 64 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | $survey_answers = ''; |
71 | - switch($mode) { |
|
71 | + switch ($mode) { |
|
72 | 72 | case 'del': |
73 | 73 | DBStaticNews::db_news_delete_by_id($announce_id); |
74 | 74 | $mode = ''; |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | $template->assign_var('ID', $announce_id); |
80 | 80 | case 'copy': |
81 | 81 | $announce = DBStaticNews::db_news_with_survey_select_by_id($announce_id); |
82 | - if($announce['survey_id']) { |
|
82 | + if ($announce['survey_id']) { |
|
83 | 83 | $query = DBStaticSurveyAnswer::db_survey_answer_text_select_by_news($announce); |
84 | - while($row = db_fetch($query)) { |
|
84 | + while ($row = db_fetch($query)) { |
|
85 | 85 | $survey_answers[] = $row['survey_answer_text']; |
86 | 86 | } |
87 | 87 | $survey_answers = implode("\r\n", $survey_answers); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | break; |
90 | 90 | } |
91 | 91 | } else { |
92 | - $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= ' . SN_TIME_NOW; |
|
92 | + $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= '.SN_TIME_NOW; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | nws_render($template, $annQuery, 20); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | use Vector\Vector; |
12 | 12 | |
13 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
13 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
14 | 14 | lng_include('notes'); |
15 | 15 | |
16 | 16 | global $user; |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | $template = gettemplate('notes', true); |
19 | 19 | |
20 | 20 | $result = array(); |
21 | -if(($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) { |
|
21 | +if (($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) { |
|
22 | 22 | $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => classLocale::$lang[$result_message]); |
23 | 23 | } |
24 | 24 | |
25 | 25 | $note_id_edit = sys_get_param_id('note_id_edit'); |
26 | 26 | $note_title_unsafe = sys_get_param_str_unsafe('note_title'); |
27 | 27 | $note_text_unsafe = sys_get_param_str_unsafe('note_text'); |
28 | -if(sys_get_param('note_delete')) { |
|
28 | +if (sys_get_param('note_delete')) { |
|
29 | 29 | try { |
30 | 30 | DBStaticNote::processDelete($user, $note_id_edit); |
31 | - } catch(Exception $e) { |
|
31 | + } catch (Exception $e) { |
|
32 | 32 | $note_id_edit = 0; |
33 | 33 | sn_db_transaction_rollback(); |
34 | 34 | $result[] = array( |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | 'MESSAGE' => classLocale::$lang[$e->getMessage()], |
37 | 37 | ); |
38 | 38 | } |
39 | -} elseif(($note_title_unsafe = sys_get_param_str_unsafe('note_title')) || ($note_text_unsafe = sys_get_param_str('note_text'))) { |
|
39 | +} elseif (($note_title_unsafe = sys_get_param_str_unsafe('note_title')) || ($note_text_unsafe = sys_get_param_str('note_text'))) { |
|
40 | 40 | $note_title_unsafe == classLocale::$lang['note_new_title'] ? $note_title_unsafe = '' : false; |
41 | 41 | $note_text_unsafe == classLocale::$lang['note_new_text'] ? $note_text_unsafe = '' : false; |
42 | 42 | try { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $note_system = max(0, min(sys_get_param_id('note_system'), Vector::$knownSystems)); |
45 | 45 | $note_planet = max(0, min(sys_get_param_id('note_planet'), Vector::$knownPlanets + 1)); |
46 | 46 | |
47 | - if(!$note_text_unsafe && !$note_title_unsafe && !$note_galaxy && !$note_system && !$note_planet) { |
|
47 | + if (!$note_text_unsafe && !$note_title_unsafe && !$note_galaxy && !$note_system && !$note_planet) { |
|
48 | 48 | throw new Exception('note_err_note_empty', ERR_WARNING); |
49 | 49 | } |
50 | 50 | |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0; |
54 | 54 | |
55 | 55 | sn_db_transaction_start(); |
56 | - if($note_id_edit) { |
|
56 | + if ($note_id_edit) { |
|
57 | 57 | $check_note_id = DBStaticNote::db_note_get_id_and_owner($note_id_edit); |
58 | - if(!$check_note_id) { |
|
58 | + if (!$check_note_id) { |
|
59 | 59 | throw new Exception('note_err_note_not_found', ERR_ERROR); |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - if($note_id_edit) { |
|
64 | - if($check_note_id['owner'] != $user['id']) { |
|
63 | + if ($note_id_edit) { |
|
64 | + if ($check_note_id['owner'] != $user['id']) { |
|
65 | 65 | throw new Exception('note_err_owner_wrong', ERR_ERROR); |
66 | 66 | } |
67 | 67 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | sn_db_transaction_commit(); |
74 | - sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
|
74 | + sys_redirect('notes.php?STATUS='.ERR_NONE.'&MESSAGE='.($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
|
75 | 75 | // throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
76 | - } catch(Exception $e) { |
|
76 | + } catch (Exception $e) { |
|
77 | 77 | $note_id_edit = 0; |
78 | 78 | sn_db_transaction_rollback(); |
79 | 79 | $result[] = array( |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | -if(!$note_id_edit) { |
|
86 | +if (!$note_id_edit) { |
|
87 | 87 | note_assign($template, array( |
88 | 88 | 'id' => 0, |
89 | 89 | 'time' => SN_TIME_NOW, |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | |
97 | 97 | $note_exist = false; |
98 | 98 | $notes_query = DBStaticNote::db_note_list_by_owner($user['id']); |
99 | -while($note_row = db_fetch($notes_query)) { |
|
99 | +while ($note_row = db_fetch($notes_query)) { |
|
100 | 100 | note_assign($template, $note_row); |
101 | 101 | $note_exist = $note_exist || $note_row['id'] == $note_id_edit; |
102 | 102 | } |
103 | 103 | $note_id_edit = $note_exist ? $note_id_edit : 0; |
104 | 104 | |
105 | -foreach($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
105 | +foreach ($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
106 | 106 | $template->assign_block_vars('note_priority', array( |
107 | 107 | 'ID' => $note_priority_id, |
108 | 108 | 'CLASS' => $note_priority_classes[$note_priority_id], |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | )); |
111 | 111 | } |
112 | 112 | |
113 | -foreach(classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
113 | +foreach (classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
114 | 114 | $template->assign_block_vars('planet_type', array( |
115 | 115 | 'ID' => $planet_type_id, |
116 | 116 | 'TEXT' => $planet_type_string, |
117 | 117 | )); |
118 | 118 | } |
119 | 119 | |
120 | -foreach($result as $result_data) { |
|
120 | +foreach ($result as $result_data) { |
|
121 | 121 | $template->assign_block_vars('result', $result_data); |
122 | 122 | } |
123 | 123 |
@@ -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,26 +498,26 @@ 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 | - sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id); |
|
520 | + sys_redirect(SN_ROOT_VIRTUAL.'metamatter.php?payment_id='.$this->payment_id); |
|
521 | 521 | die(); |
522 | 522 | } |
523 | 523 | } |
@@ -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)) { |
|
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)); |
|
546 | + if (!$this->account->db_get_by_id($this->payment_account_id)) { |
|
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) { |
|
554 | - throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
|
553 | + if (SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
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) { |
|
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); |
|
561 | + if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
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) { |
|
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); |
|
584 | + if ($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
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 | - throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
|
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,21 +634,21 @@ 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 | - classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT); |
|
644 | + classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Успешный платёж', LOG_INFO_PAYMENT); |
|
645 | 645 | } else { |
646 | 646 | sn_db_transaction_rollback(); |
647 | - classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Ошибка платежа', LOG_INFO_PAYMENT, true); |
|
647 | + classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Ошибка платежа', LOG_INFO_PAYMENT, true); |
|
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']; |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | protected function generate_description() { |
919 | 919 | // TODO - системная локализация |
920 | 920 | $this->description_generated = array( |
921 | - PAYMENT_DESCRIPTION_100 => substr("{$this->payment_dark_matter_gained} ММ аккаунт [{$this->account->account_name}] ID {$this->account->account_id} на " . SN_ROOT_VIRTUAL, 0, 100), |
|
922 | - PAYMENT_DESCRIPTION_250 => substr("Оплата {$this->payment_dark_matter_gained} ММ для аккаунта [{$this->payment_user_name}] ID {$this->payment_user_id} на сервере " . SN_ROOT_VIRTUAL, 0, 250), |
|
923 | - PAYMENT_DESCRIPTION_MAX => ($this->payment_test ? "ТЕСТОВЫЙ ПЛАТЕЖ! " : '') . |
|
924 | - "Платеж от аккаунта '{$this->payment_account_name}' ID {$this->payment_account_id} игрока '{$this->payment_user_name}' ID {$this->payment_user_id} на сервере " . SN_ROOT_VIRTUAL . |
|
925 | - " сумма {$this->payment_amount} {$this->payment_currency} за {$this->payment_dark_matter_paid} ММ (начислено {$this->payment_dark_matter_gained} ММ)" . |
|
921 | + PAYMENT_DESCRIPTION_100 => substr("{$this->payment_dark_matter_gained} ММ аккаунт [{$this->account->account_name}] ID {$this->account->account_id} на ".SN_ROOT_VIRTUAL, 0, 100), |
|
922 | + PAYMENT_DESCRIPTION_250 => substr("Оплата {$this->payment_dark_matter_gained} ММ для аккаунта [{$this->payment_user_name}] ID {$this->payment_user_id} на сервере ".SN_ROOT_VIRTUAL, 0, 250), |
|
923 | + PAYMENT_DESCRIPTION_MAX => ($this->payment_test ? "ТЕСТОВЫЙ ПЛАТЕЖ! " : ''). |
|
924 | + "Платеж от аккаунта '{$this->payment_account_name}' ID {$this->payment_account_id} игрока '{$this->payment_user_name}' ID {$this->payment_user_id} на сервере ".SN_ROOT_VIRTUAL. |
|
925 | + " сумма {$this->payment_amount} {$this->payment_currency} за {$this->payment_dark_matter_paid} ММ (начислено {$this->payment_dark_matter_gained} ММ)". |
|
926 | 926 | " через '{$this->manifest['name']}' сумма {$this->payment_external_amount} {$this->payment_external_currency}", |
927 | 927 | ); |
928 | 928 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | JOIN {{users}} AS u ON u.id = cp.chat_player_player_id |
13 | 13 | WHERE |
14 | 14 | `chat_player_refresh_last` >= '{$sql_date}' |
15 | - AND (`banaday` IS NULL OR `banaday` <= " . SN_TIME_NOW . ") |
|
15 | + AND (`banaday` IS NULL OR `banaday` <= ".SN_TIME_NOW.") |
|
16 | 16 | {$ally_add} |
17 | 17 | ORDER BY authlevel DESC, `username`"); |
18 | 18 | } |
@@ -1,23 +1,23 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | -if(!$user_can_send_mails) { |
|
7 | +if (!$user_can_send_mails) { |
|
8 | 8 | message(classLocale::$lang['Denied_access'], classLocale::$lang['Send_circular_mail']); |
9 | 9 | } |
10 | 10 | |
11 | 11 | $POST_text = sys_get_param_str('text'); |
12 | 12 | $internalAliSendTextUnsafe = sys_get_param_str_unsafe('text'); |
13 | -if($internalAliSendTextUnsafe) { |
|
14 | - message(classLocale::$lang['members_who_recived_message'] . DBStaticMessages::msg_ali_send($internalAliSendTextUnsafe, classLocale::$lang['ali_adm_msg_subject'], sys_get_param_int('r')), classLocale::$lang['Circular_sended'], "alliance.php", ''); |
|
13 | +if ($internalAliSendTextUnsafe) { |
|
14 | + message(classLocale::$lang['members_who_recived_message'].DBStaticMessages::msg_ali_send($internalAliSendTextUnsafe, classLocale::$lang['ali_adm_msg_subject'], sys_get_param_int('r')), classLocale::$lang['Circular_sended'], "alliance.php", ''); |
|
15 | 15 | } |
16 | 16 | |
17 | -$r_list = "<option value=\"-1\">" . classLocale::$lang['All_players'] . "</option>"; |
|
18 | -if($ranks) { |
|
19 | - foreach($ranks as $id => $array) { |
|
20 | - $r_list .= "<option value=\"" . $id . "\">" . $array['name'] . "</option>"; |
|
17 | +$r_list = "<option value=\"-1\">".classLocale::$lang['All_players']."</option>"; |
|
18 | +if ($ranks) { |
|
19 | + foreach ($ranks as $id => $array) { |
|
20 | + $r_list .= "<option value=\"".$id."\">".$array['name']."</option>"; |
|
21 | 21 | } |
22 | 22 | } |
23 | 23 |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param db_mysql|null $db |
87 | 87 | */ |
88 | 88 | public static function setDb($db = null) { |
89 | - if(empty($db) || !($db instanceof db_mysql)) { |
|
89 | + if (empty($db) || !($db instanceof db_mysql)) { |
|
90 | 90 | $db = null; |
91 | 91 | } |
92 | 92 | static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public function dbLoad($dbId, $lockSkip = false) { |
150 | 150 | $dbId = idval($dbId); |
151 | 151 | if ($dbId <= 0) { |
152 | - classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId); |
|
152 | + classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId); |
|
153 | 153 | |
154 | 154 | return; |
155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $this->dbGetLockById($this->_dbId); |
162 | 162 | } |
163 | 163 | |
164 | - $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;"); |
|
164 | + $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;"); |
|
165 | 165 | if (empty($db_row)) { |
166 | 166 | return; |
167 | 167 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($this->isNew()) { |
194 | 194 | // No DB_ID - new unit |
195 | 195 | if ($this->isEmpty()) { |
196 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave'); |
|
196 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave'); |
|
197 | 197 | } |
198 | 198 | $this->dbInsert(); |
199 | 199 | } else { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $this->dbDelete(); |
203 | 203 | } else { |
204 | 204 | if (!sn_db_transaction_check(false)) { |
205 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate'); |
|
205 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate'); |
|
206 | 206 | } |
207 | 207 | $this->dbUpdate(); |
208 | 208 | } |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | // TODO - protected |
231 | 231 | public function dbInsert() { |
232 | 232 | if (!$this->isNew()) { |
233 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert'); |
|
233 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | $fieldSet = $this->dbMakeFieldSet(false); |
237 | 237 | |
238 | 238 | if (!static::$db->doInsertSet(static::$_table, $fieldSet)) { |
239 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert'); |
|
239 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert'); |
|
240 | 240 | } |
241 | 241 | $this->_dbId = static::$db->db_insert_id(); |
242 | 242 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public function dbUpdate() { |
251 | 251 | // TODO - Update |
252 | 252 | if ($this->isNew()) { |
253 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate'); |
|
253 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate'); |
|
254 | 254 | } |
255 | 255 | $this->db_field_update($this->dbMakeFieldUpdate()); |
256 | 256 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // TODO - protected |
262 | 262 | public function dbDelete() { |
263 | 263 | if ($this->isNew()) { |
264 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete'); |
|
264 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete'); |
|
265 | 265 | } |
266 | 266 | classSupernova::$gc->db->doDeleteRowWhere(static::$_table, array(static::$_dbIdFieldName => $this->_dbId)); |
267 | 267 | $this->_dbId = 0; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
450 | - if(empty($set)) { |
|
450 | + if (empty($set)) { |
|
451 | 451 | $theResult = true; |
452 | 452 | } else { |
453 | 453 | $theResult = classSupernova::$db->doUpdateRowAdjust( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if((!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) && (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)) { |
|
3 | +if ((!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) && (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)) { |
|
4 | 4 | classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | |
27 | 27 | // $dm_db_name = pname_resource_name(RES_DARK_MATTER); |
28 | 28 | $exchangeTo = in_array($exchangeTo = sys_get_param_int('exchangeTo'), sn_get_groups('resources_trader')) ? $exchangeTo : 0; |
29 | - if($exchangeTo && is_array($tradeList = $_POST['spend'])) { |
|
29 | + if ($exchangeTo && is_array($tradeList = $_POST['spend'])) { |
|
30 | 30 | $value = 0; |
31 | 31 | |
32 | 32 | sn_db_transaction_start(); |
33 | - if($planetrow['id_owner']) { |
|
33 | + if ($planetrow['id_owner']) { |
|
34 | 34 | $global_data = sys_o_get_updated($user, $planetrow, SN_TIME_NOW); |
35 | 35 | $planetrow = $global_data['planet']; |
36 | 36 | } |
@@ -40,26 +40,26 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | $fields = array(); |
43 | - foreach(sn_get_groups('resources_trader') as $resource_id) { |
|
43 | + foreach (sn_get_groups('resources_trader') as $resource_id) { |
|
44 | 44 | $amount = floatval($tradeList[$resource_id]); |
45 | - if($amount < 0) { |
|
45 | + if ($amount < 0) { |
|
46 | 46 | classSupernova::$debug->error('Trying to supply negative resource amount on Black Market Page', 'Hack Attempt', 305); |
47 | 47 | } |
48 | 48 | |
49 | - if($resource_id == RES_DARK_MATTER && $exchangeTo == RES_DARK_MATTER) { |
|
49 | + if ($resource_id == RES_DARK_MATTER && $exchangeTo == RES_DARK_MATTER) { |
|
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $sign = '+'; |
54 | - if($exchangeTo == RES_DARK_MATTER) { |
|
54 | + if ($exchangeTo == RES_DARK_MATTER) { |
|
55 | 55 | $amount = floor($tradeList[RES_DARK_MATTER] / 3 * $rates[RES_DARK_MATTER] / $rates[$resource_id]); |
56 | 56 | $value += $amount; |
57 | 57 | } else { |
58 | 58 | $value += floor($amount * $rates[$resource_id] / $rates[$exchangeTo]); |
59 | - if($resource_id == RES_DARK_MATTER) { |
|
59 | + if ($resource_id == RES_DARK_MATTER) { |
|
60 | 60 | $amount = 0; |
61 | 61 | } else { |
62 | - if(mrc_get_level($user, $planetrow, $resource_id, true) < $amount) { |
|
62 | + if (mrc_get_level($user, $planetrow, $resource_id, true) < $amount) { |
|
63 | 63 | $intError = MARKET_NO_RESOURCES; |
64 | 64 | break; |
65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - if($amount) { |
|
71 | + if ($amount) { |
|
72 | 72 | $fields[pname_resource_name($resource_id)] = "{$sign} {$amount}"; |
73 | 73 | } |
74 | 74 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | $intError = $value <= 0 ? MARKET_ZERO_DEAL : $intError; |
79 | 79 | $intError = mrc_get_level($user, null, RES_DARK_MATTER) < $operation_cost ? MARKET_NO_DM : $intError; |
80 | 80 | |
81 | - if($intError == MARKET_DEAL) { |
|
82 | - if($exchangeTo != RES_DARK_MATTER) { |
|
81 | + if ($intError == MARKET_DEAL) { |
|
82 | + if ($exchangeTo != RES_DARK_MATTER) { |
|
83 | 83 | $amountExchangeTo = floor($value); |
84 | 84 | $fields[pname_resource_name($exchangeTo)] = $amountExchangeTo; |
85 | 85 | } |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | 'EXCHANGE_TO_RESOURCE_ID' => $exchangeTo, |
116 | 116 | )); |
117 | 117 | |
118 | - foreach(sn_get_groups('resources_trader') as $resource_id) { |
|
119 | - if($resource_id == RES_DARK_MATTER) { |
|
118 | + foreach (sn_get_groups('resources_trader') as $resource_id) { |
|
119 | + if ($resource_id == RES_DARK_MATTER) { |
|
120 | 120 | $amount = floor(mrc_get_level($user, null, RES_DARK_MATTER) - classSupernova::$config->rpg_cost_trader); |
121 | 121 | } else { |
122 | 122 | $amount = floor(mrc_get_level($user, $planetrow, $resource_id)); |
@@ -408,31 +408,31 @@ discard block |
||
408 | 408 | |
409 | 409 | return classSupernova::$db->doSelect( |
410 | 410 | // Блокировка самого флота |
411 | - "SELECT 1 FROM {{fleets}} AS f " . |
|
411 | + "SELECT 1 FROM {{fleets}} AS f ". |
|
412 | 412 | |
413 | 413 | // Блокировка всех юнитов, принадлежащих этому флоту |
414 | - "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " . |
|
414 | + "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ". |
|
415 | 415 | |
416 | 416 | // Блокировка всех прилетающих и улетающих флотов, если нужно |
417 | 417 | // TODO - lock fleets by COORDINATES |
418 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') . |
|
418 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : ''). |
|
419 | 419 | // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination |
420 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') . |
|
420 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : ''). |
|
421 | 421 | |
422 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') . |
|
422 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : ''). |
|
423 | 423 | // Блокировка всех юнитов, принадлежащих владельцу планеты-цели |
424 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') . |
|
424 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : ''). |
|
425 | 425 | // Блокировка планеты-цели |
426 | - ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') . |
|
426 | + ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : ''). |
|
427 | 427 | // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели |
428 | 428 | // ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') . |
429 | 429 | |
430 | 430 | |
431 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') . |
|
431 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : ''). |
|
432 | 432 | // Блокировка всех юнитов, принадлежащих владельцу флота |
433 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') . |
|
433 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : ''). |
|
434 | 434 | // Блокировка планеты отправления |
435 | - ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') . |
|
435 | + ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : ''). |
|
436 | 436 | // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота |
437 | 437 | // ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') . |
438 | 438 | |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | public function dbGetLockById($dbId) { |
450 | 450 | classSupernova::$db->doSelect( |
451 | 451 | // Блокировка самого флота |
452 | - "SELECT 1 FROM {{fleets}} AS FLEET0 " . |
|
452 | + "SELECT 1 FROM {{fleets}} AS FLEET0 ". |
|
453 | 453 | // Lock fleet owner |
454 | - "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " . |
|
454 | + "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ". |
|
455 | 455 | // Блокировка всех юнитов, принадлежащих этому флоту |
456 | - "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " . |
|
456 | + "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ". |
|
457 | 457 | |
458 | 458 | // Без предварительной выборки неизвестно - куда летит этот флот. |
459 | 459 | // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота. |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | FLEET1.fleet_end_planet = FLEET0.fleet_end_planet |
470 | 470 | " . |
471 | 471 | // Блокировка всех юнитов, принадлежащих этим флотам |
472 | - "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " . |
|
472 | + "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ". |
|
473 | 473 | // Lock fleet owner |
474 | - "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " . |
|
474 | + "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ". |
|
475 | 475 | |
476 | 476 | "LEFT JOIN {{fleets}} AS FLEET2 ON |
477 | 477 | FLEET2.fleet_mess = 1 AND FLEET0.fleet_mess = 0 AND |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | " . |
482 | 482 | // Блокировка всех юнитов, принадлежащих этим флотам |
483 | 483 | "LEFT JOIN {{unit}} as UNIT2 ON |
484 | - UNIT2.unit_location_type = " . LOC_FLEET . " AND |
|
484 | + UNIT2.unit_location_type = " . LOC_FLEET." AND |
|
485 | 485 | UNIT2.unit_location_id = FLEET2.fleet_id |
486 | 486 | " . |
487 | 487 | // Lock fleet owner |
@@ -498,11 +498,11 @@ discard block |
||
498 | 498 | " . |
499 | 499 | // Блокировка всех юнитов, принадлежащих этим флотам |
500 | 500 | "LEFT JOIN {{unit}} as UNIT3 ON |
501 | - UNIT3.unit_location_type = " . LOC_FLEET . " AND |
|
501 | + UNIT3.unit_location_type = " . LOC_FLEET." AND |
|
502 | 502 | UNIT3.unit_location_id = FLEET3.fleet_id |
503 | 503 | " . |
504 | 504 | // Lock fleet owner |
505 | - "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " . |
|
505 | + "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ". |
|
506 | 506 | |
507 | 507 | "LEFT JOIN {{fleets}} AS FLEET4 ON |
508 | 508 | FLEET4.fleet_mess = 1 AND FLEET0.fleet_mess = 1 AND |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | " . |
513 | 513 | // Блокировка всех юнитов, принадлежащих этим флотам |
514 | 514 | "LEFT JOIN {{unit}} as UNIT4 ON |
515 | - UNIT4.unit_location_type = " . LOC_FLEET . " AND |
|
515 | + UNIT4.unit_location_type = " . LOC_FLEET." AND |
|
516 | 516 | UNIT4.unit_location_id = FLEET4.fleet_id |
517 | 517 | " . |
518 | 518 | // Lock fleet owner |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | " . |
535 | 535 | // Блокировка всех юнитов, принадлежащих этой планете |
536 | 536 | "LEFT JOIN {{unit}} as UNIT5 ON |
537 | - UNIT5.unit_location_type = " . LOC_PLANET . " AND |
|
537 | + UNIT5.unit_location_type = " . LOC_PLANET." AND |
|
538 | 538 | UNIT5.unit_location_id = PLANETS5.id |
539 | 539 | " . |
540 | 540 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | " . |
553 | 553 | // Блокировка всех юнитов, принадлежащих этой планете |
554 | 554 | "LEFT JOIN {{unit}} as UNIT6 ON |
555 | - UNIT6.unit_location_type = " . LOC_PLANET . " AND |
|
555 | + UNIT6.unit_location_type = " . LOC_PLANET." AND |
|
556 | 556 | UNIT6.unit_location_id = PLANETS6.id |
557 | 557 | " . |
558 | 558 | "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE" |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | } elseif ($this->isResource($unit_id)) { |
672 | 672 | $this->resource_list[$unit_id] = $unit_count; |
673 | 673 | } else { |
674 | - throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG); |
|
674 | + throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG); |
|
675 | 675 | } |
676 | 676 | } |
677 | 677 | } |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | * @param int $unit_count |
806 | 806 | */ |
807 | 807 | public function shipSetCount($unit_id, $unit_count = 0) { |
808 | - pdump(__CLASS__ . '->' . __FUNCTION__); |
|
808 | + pdump(__CLASS__.'->'.__FUNCTION__); |
|
809 | 809 | $this->shipAdjustCount($unit_id, $unit_count, true); |
810 | 810 | } |
811 | 811 | |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | */ |
1006 | 1006 | public function resourcesSet($resource_list) { |
1007 | 1007 | if (!empty($this->propertiesAdjusted['resource_list'])) { |
1008 | - throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); |
|
1008 | + throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR); |
|
1009 | 1009 | } |
1010 | 1010 | $this->resourcesAdjust($resource_list, true); |
1011 | 1011 | } |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | // Check for negative unit value |
1040 | 1040 | if ($this->resource_list[$resource_id] < 0) { |
1041 | 1041 | // TODO |
1042 | - throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); |
|
1042 | + throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR); |
|
1043 | 1043 | } |
1044 | 1044 | } |
1045 | 1045 | } |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | |
1221 | 1221 | protected function printErrorIfNoShips() { |
1222 | 1222 | if ($this->unitList->unitsCount() <= 0) { |
1223 | - message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
|
1223 | + message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5); |
|
1224 | 1224 | } |
1225 | 1225 | } |
1226 | 1226 | |
@@ -1608,14 +1608,14 @@ discard block |
||
1608 | 1608 | if (FLIGHT_ALLOWED == $validateResult[$missionType]) { |
1609 | 1609 | $this->allowed_missions[$missionType] = $mission; |
1610 | 1610 | } else { |
1611 | - if($missionType == $this->mission_type) { |
|
1611 | + if ($missionType == $this->mission_type) { |
|
1612 | 1612 | } |
1613 | 1613 | unset($this->allowed_missions[$missionType]); |
1614 | 1614 | } |
1615 | 1615 | } |
1616 | 1616 | |
1617 | - if(empty($this->allowed_missions)) { |
|
1618 | - if($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) { |
|
1617 | + if (empty($this->allowed_missions)) { |
|
1618 | + if ($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) { |
|
1619 | 1619 | throw new ExceptionFleetInvalid($validateResult[$this->mission_type], $validateResult[$this->mission_type]); |
1620 | 1620 | } else { |
1621 | 1621 | throw new ExceptionFleetInvalid(FLIGHT_MISSION_IMPOSSIBLE, FLIGHT_MISSION_IMPOSSIBLE); |
@@ -1844,7 +1844,7 @@ discard block |
||
1844 | 1844 | $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob); |
1845 | 1845 | |
1846 | 1846 | $template_result += array( |
1847 | - 'mission' => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''), |
|
1847 | + 'mission' => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''), |
|
1848 | 1848 | 'dist' => pretty_number($this->travelData['distance']), |
1849 | 1849 | 'speed' => pretty_number($this->travelData['fleet_speed']), |
1850 | 1850 | 'deute_need' => pretty_number($this->travelData['consumption']), |