@@ -25,8 +25,7 @@ |
||
| 25 | 25 | if($user_request['id_user']) |
| 26 | 26 | { |
| 27 | 27 | require('includes/alliance/ali_external_request.inc'); |
| 28 | - } |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | switch($mode) |
| 32 | 31 | { |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 4 | 4 | |
| 5 | -if(classSupernova::$config->game_mode == GAME_BLITZ) { |
|
| 5 | +if (classSupernova::$config->game_mode == GAME_BLITZ) { |
|
| 6 | 6 | messageBox($lang['sys_blitz_page_disabled'], $lang['sys_error'], 'overview.php', 10); |
| 7 | 7 | die(); |
| 8 | 8 | } |
@@ -14,21 +14,21 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $mode = sys_get_param_str('mode'); |
| 16 | 16 | |
| 17 | -if($mode == 'ainfo') |
|
| 17 | +if ($mode == 'ainfo') |
|
| 18 | 18 | { |
| 19 | 19 | include('includes/alliance/ali_info.inc'); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -if(!$user['ally_id']) |
|
| 22 | +if (!$user['ally_id']) |
|
| 23 | 23 | { |
| 24 | 24 | $user_request = doquery("SELECT * FROM {{alliance_requests}} WHERE `id_user` ='{$user['id']}' LIMIT 1;", '', true); |
| 25 | - if($user_request['id_user']) |
|
| 25 | + if ($user_request['id_user']) |
|
| 26 | 26 | { |
| 27 | 27 | require('includes/alliance/ali_external_request.inc'); |
| 28 | 28 | } |
| 29 | 29 | else |
| 30 | 30 | { |
| 31 | - switch($mode) |
|
| 31 | + switch ($mode) |
|
| 32 | 32 | { |
| 33 | 33 | case 'search': |
| 34 | 34 | require('includes/alliance/ali_external_search.inc'); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | sn_ali_fill_user_ally($user); |
| 54 | 54 | //$ally = doquery("SELECT * FROM {{alliance}} WHERE `id` ='{$user['ally_id']}'", '', true); |
| 55 | -if(!isset($user['ally'])) |
|
| 55 | +if (!isset($user['ally'])) |
|
| 56 | 56 | { |
| 57 | 57 | db_user_set_by_id($user['id'], "`ally_id` = null, `ally_name` = null, `ally_register_time` = 0, `ally_rank_id` = 0"); |
| 58 | 58 | messageBox($lang['ali_sys_notFound'], $lang['your_alliance'], 'alliance.php'); |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | // This piece converting old ally data to new one |
| 83 | 83 | // unset($ally['ranklist']); |
| 84 | -if(!$ally['ranklist'] && $ally['ally_ranks']) |
|
| 84 | +if (!$ally['ranklist'] && $ally['ally_ranks']) |
|
| 85 | 85 | { |
| 86 | 86 | $ally_ranks = unserialize($ally['ally_ranks']); |
| 87 | 87 | $i = 0; |
| 88 | - foreach($ally_ranks as $rank_id => $rank) |
|
| 88 | + foreach ($ally_ranks as $rank_id => $rank) |
|
| 89 | 89 | { |
| 90 | - foreach($ally_rights as $key => $value) |
|
| 90 | + foreach ($ally_rights as $key => $value) |
|
| 91 | 91 | { |
| 92 | 92 | $ranks[$i][$value] = $rank[$rights_old[$key]]; |
| 93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $i++; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if(!empty($ranks)) |
|
| 98 | + if (!empty($ranks)) |
|
| 99 | 99 | { |
| 100 | 100 | ali_rank_list_save($ranks); |
| 101 | 101 | } |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $edit = sys_get_param_str('edit'); |
| 116 | 116 | ally_pre_call(); |
| 117 | -switch($mode) |
|
| 117 | +switch ($mode) |
|
| 118 | 118 | { |
| 119 | 119 | case 'admin': |
| 120 | - if(!array_key_exists($edit , $sn_ali_admin_internal)) |
|
| 120 | + if (!array_key_exists($edit, $sn_ali_admin_internal)) |
|
| 121 | 121 | { |
| 122 | 122 | $edit = 'default'; |
| 123 | 123 | } |
| 124 | - if($sn_ali_admin_internal[$edit]['include']) |
|
| 124 | + if ($sn_ali_admin_internal[$edit]['include']) |
|
| 125 | 125 | { |
| 126 | 126 | require("includes/{$sn_ali_admin_internal[$edit]['include']}"); |
| 127 | 127 | } |
| 128 | - if(isset($sn_ali_admin_internal[$edit]['function']) && is_callable($sn_ali_admin_internal[$edit]['function'])) |
|
| 128 | + if (isset($sn_ali_admin_internal[$edit]['function']) && is_callable($sn_ali_admin_internal[$edit]['function'])) |
|
| 129 | 129 | { |
| 130 | 130 | call_user_func($sn_ali_admin_internal[$edit]['function']); |
| 131 | 131 | } |
@@ -136,6 +136,6 @@ discard block |
||
| 136 | 136 | default: require('includes/alliance/ali_info.inc'); break; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | -function ally_pre_call(){$func_args = func_get_args();return sn_function_call('ally_pre_call', $func_args);} |
|
| 139 | +function ally_pre_call() {$func_args = func_get_args(); return sn_function_call('ally_pre_call', $func_args); } |
|
| 140 | 140 | |
| 141 | 141 | ?> |
@@ -41,12 +41,10 @@ |
||
| 41 | 41 | if(!$check_result) |
| 42 | 42 | { |
| 43 | 43 | $version_check = SNC_VER_ERROR_CONNECT; |
| 44 | -} |
|
| 45 | -elseif(($version_check = intval($check_result)) && $version_check == $check_result) |
|
| 44 | +} elseif(($version_check = intval($check_result)) && $version_check == $check_result) |
|
| 46 | 45 | { |
| 47 | 46 | $version_check = $check_result; |
| 48 | -} |
|
| 49 | -else |
|
| 47 | +} else |
|
| 50 | 48 | { |
| 51 | 49 | // JSON decode if string |
| 52 | 50 | $check_result = json_decode($check_result, true); |
@@ -22,19 +22,19 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | switch($mode) |
| 24 | 24 | { |
| 25 | - case SNC_MODE_REGISTER: |
|
| 26 | - if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) |
|
| 27 | - { |
|
| 28 | - if($ajax) |
|
| 25 | + case SNC_MODE_REGISTER: |
|
| 26 | + if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) |
|
| 29 | 27 | { |
| 30 | - print(SNC_VER_REGISTER_ERROR_REGISTERED); |
|
| 28 | + if($ajax) |
|
| 29 | + { |
|
| 30 | + print(SNC_VER_REGISTER_ERROR_REGISTERED); |
|
| 31 | + } |
|
| 32 | + die(); |
|
| 31 | 33 | } |
| 32 | - die(); |
|
| 33 | - } |
|
| 34 | - $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); |
|
| 35 | -//TODO REMOVE DEBUG!!! |
|
| 36 | -//$url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode('http://supernova.ws/'); |
|
| 37 | - break; |
|
| 34 | + $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); |
|
| 35 | + //TODO REMOVE DEBUG!!! |
|
| 36 | + //$url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode('http://supernova.ws/'); |
|
| 37 | + break; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $check_result = sn_get_url_contents($url); |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | . '&key=' . urlencode(classSupernova::$config->server_updater_key) |
| 21 | 21 | . '&id=' . urlencode(classSupernova::$config->server_updater_id); |
| 22 | 22 | */ |
| 23 | -switch($mode) |
|
| 23 | +switch ($mode) |
|
| 24 | 24 | { |
| 25 | 25 | case SNC_MODE_REGISTER: |
| 26 | - if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) |
|
| 26 | + if (classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) |
|
| 27 | 27 | { |
| 28 | - if($ajax) |
|
| 28 | + if ($ajax) |
|
| 29 | 29 | { |
| 30 | 30 | print(SNC_VER_REGISTER_ERROR_REGISTERED); |
| 31 | 31 | } |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $check_result = sn_get_url_contents($url); |
| 41 | -if(!$check_result) |
|
| 41 | +if (!$check_result) |
|
| 42 | 42 | { |
| 43 | 43 | $version_check = SNC_VER_ERROR_CONNECT; |
| 44 | 44 | } |
| 45 | -elseif(($version_check = intval($check_result)) && $version_check == $check_result) |
|
| 45 | +elseif (($version_check = intval($check_result)) && $version_check == $check_result) |
|
| 46 | 46 | { |
| 47 | 47 | $version_check = $check_result; |
| 48 | 48 | } |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | $check_result = json_decode($check_result, true); |
| 53 | 53 | $version_check = $check_result === null ? SNC_VER_UNKNOWN_RESPONSE : $check_result['version_check']; |
| 54 | 54 | |
| 55 | - switch($mode) |
|
| 55 | + switch ($mode) |
|
| 56 | 56 | { |
| 57 | 57 | case SNC_MODE_REGISTER: |
| 58 | - if($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) |
|
| 58 | + if ($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) |
|
| 59 | 59 | { |
| 60 | 60 | classSupernova::$config->db_saveItem('server_updater_key', $check_result['site']['site_key']); |
| 61 | 61 | classSupernova::$config->db_saveItem('server_updater_id', $check_result['site']['site_id']); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | classSupernova::$config->db_saveItem('server_updater_check_last', SN_TIME_NOW); |
| 70 | 70 | classSupernova::$config->db_saveItem('server_updater_check_result', $version_check); |
| 71 | 71 | |
| 72 | -if($ajax) |
|
| 72 | +if ($ajax) |
|
| 73 | 73 | { |
| 74 | 74 | define('IN_AJAX', true); |
| 75 | 75 | print($version_check); |
@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
| 57 | 57 | sn_db_transaction_commit(); |
| 58 | 58 | throw new exception('buddy_err_accept_none', ERR_NONE); |
| 59 | - } |
|
| 60 | - else |
|
| 59 | + } else |
|
| 61 | 60 | { |
| 62 | 61 | throw new exception('buddy_err_accept_internal', ERR_ERROR); |
| 63 | 62 | } |
@@ -69,9 +68,11 @@ discard block |
||
| 69 | 68 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
| 70 | 69 | } |
| 71 | 70 | |
| 72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 71 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
| 72 | + // Existing friendship |
|
| 73 | 73 | { |
| 74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
| 77 | 78 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -79,17 +80,19 @@ discard block |
||
| 79 | 80 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 80 | 81 | sn_db_transaction_commit(); |
| 81 | 82 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
| 82 | - } |
|
| 83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 83 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
| 84 | + // Player's outcoming request - either denied or waiting |
|
| 84 | 85 | { |
| 85 | 86 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 87 | + } |
|
| 86 | 88 | sn_db_transaction_commit(); |
| 87 | 89 | throw new exception('buddy_err_delete_own', ERR_NONE); |
| 88 | - } |
|
| 89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 90 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
| 91 | + // Deny incoming request |
|
| 90 | 92 | { |
| 91 | 93 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
| 92 | 94 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
| 95 | + } |
|
| 93 | 96 | |
| 94 | 97 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_DENIED . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 95 | 98 | sn_db_transaction_commit(); |
@@ -104,8 +107,7 @@ discard block |
||
| 104 | 107 | if($new_friend_id = sys_get_param_id('request_user_id')) |
| 105 | 108 | { |
| 106 | 109 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
| 107 | - } |
|
| 108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 110 | + } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 109 | 111 | { |
| 110 | 112 | $new_friend_row = db_user_by_username($new_friend_name, true, '`id`, `username`'); |
| 111 | 113 | $new_friend_name = db_escape($new_friend_name); |
@@ -138,8 +140,7 @@ discard block |
||
| 138 | 140 | sn_db_transaction_commit(); |
| 139 | 141 | throw new exception('buddy_err_adding_none', ERR_NONE); |
| 140 | 142 | } |
| 141 | -} |
|
| 142 | -catch(exception $e) |
|
| 143 | +} catch(exception $e) |
|
| 143 | 144 | { |
| 144 | 145 | $result[] = array( |
| 145 | 146 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -18,39 +18,39 @@ discard block |
||
| 18 | 18 | { |
| 19 | 19 | sn_db_transaction_start(); |
| 20 | 20 | |
| 21 | - if($buddy_id = sys_get_param_id('buddy_id')) |
|
| 21 | + if ($buddy_id = sys_get_param_id('buddy_id')) |
|
| 22 | 22 | { |
| 23 | 23 | $buddy_row = doquery("SELECT BUDDY_SENDER_ID, BUDDY_OWNER_ID, BUDDY_STATUS FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1 FOR UPDATE;", true); |
| 24 | - if(!is_array($buddy_row)) |
|
| 24 | + if (!is_array($buddy_row)) |
|
| 25 | 25 | { |
| 26 | 26 | throw new exception('buddy_err_not_exist', ERR_ERROR); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - switch($mode = sys_get_param_str('mode')) |
|
| 29 | + switch ($mode = sys_get_param_str('mode')) |
|
| 30 | 30 | { |
| 31 | 31 | case 'accept': |
| 32 | - if($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
| 32 | + if ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
| 33 | 33 | { |
| 34 | 34 | throw new exception('buddy_err_accept_own', ERR_ERROR); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 37 | + if ($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 38 | 38 | { |
| 39 | 39 | throw new exception('buddy_err_accept_alien', ERR_ERROR); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
| 42 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
| 43 | 43 | { |
| 44 | 44 | throw new exception('buddy_err_accept_already', ERR_WARNING); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
| 47 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
| 48 | 48 | { |
| 49 | 49 | throw new exception('buddy_err_accept_denied', ERR_ERROR); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_ACTIVE . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 53 | - if(classSupernova::$db->db_affected_rows()) |
|
| 53 | + if (classSupernova::$db->db_affected_rows()) |
|
| 54 | 54 | { |
| 55 | 55 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_accept_title'], |
| 56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | break; |
| 65 | 65 | |
| 66 | 66 | case 'delete': |
| 67 | - if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 67 | + if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 68 | 68 | { |
| 69 | 69 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 72 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 73 | 73 | { |
| 74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
| 75 | 75 | |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | sn_db_transaction_commit(); |
| 81 | 81 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
| 82 | 82 | } |
| 83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 83 | + elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 84 | 84 | { |
| 85 | 85 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 86 | 86 | sn_db_transaction_commit(); |
| 87 | 87 | throw new exception('buddy_err_delete_own', ERR_NONE); |
| 88 | 88 | } |
| 89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 89 | + elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 90 | 90 | { |
| 91 | 91 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
| 92 | 92 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
@@ -101,24 +101,24 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | // New request? |
| 103 | 103 | // Checking for user ID - in case if it was request from outside buddy system |
| 104 | - if($new_friend_id = sys_get_param_id('request_user_id')) |
|
| 104 | + if ($new_friend_id = sys_get_param_id('request_user_id')) |
|
| 105 | 105 | { |
| 106 | 106 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
| 107 | 107 | } |
| 108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 108 | + elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 109 | 109 | { |
| 110 | 110 | $new_friend_row = db_user_by_username($new_friend_name, true, '`id`, `username`'); |
| 111 | 111 | $new_friend_name = db_escape($new_friend_name); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if($new_friend_row['id'] == $user['id']) |
|
| 114 | + if ($new_friend_row['id'] == $user['id']) |
|
| 115 | 115 | { |
| 116 | 116 | unset($new_friend_row); |
| 117 | 117 | throw new exception('buddy_err_adding_self', ERR_ERROR); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Checking for user name & request text - in case if it was request to adding new request |
| 121 | - if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
| 121 | + if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
| 122 | 122 | { |
| 123 | 123 | $check_relation = doquery("SELECT `BUDDY_ID` FROM {{buddy}} WHERE |
| 124 | 124 | (`BUDDY_SENDER_ID` = {$user['id']} AND `BUDDY_OWNER_ID` = {$new_friend_row['id']}) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | (`BUDDY_SENDER_ID` = {$new_friend_row['id']} AND `BUDDY_OWNER_ID` = {$user['id']}) |
| 127 | 127 | LIMIT 1 FOR UPDATE;" |
| 128 | 128 | , true); |
| 129 | - if(isset($check_relation['BUDDY_ID'])) |
|
| 129 | + if (isset($check_relation['BUDDY_ID'])) |
|
| 130 | 130 | { |
| 131 | 131 | throw new exception('buddy_err_adding_exists', ERR_WARNING); |
| 132 | 132 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | throw new exception('buddy_err_adding_none', ERR_NONE); |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | -catch(exception $e) |
|
| 142 | +catch (exception $e) |
|
| 143 | 143 | { |
| 144 | 144 | $result[] = array( |
| 145 | 145 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | sn_db_transaction_rollback(); |
| 151 | 151 | |
| 152 | 152 | $query = db_buddy_list_by_user($user['id']); |
| 153 | -while($row = db_fetch($query)) |
|
| 153 | +while ($row = db_fetch($query)) |
|
| 154 | 154 | { |
| 155 | 155 | $row['BUDDY_REQUEST'] = HelperString::nl2br($row['BUDDY_REQUEST']); |
| 156 | 156 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 4 | 4 | |
| 5 | -if(sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG')) |
|
| 5 | +if (sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG')) |
|
| 6 | 6 | { |
| 7 | 7 | define('BE_DEBUG', true); |
| 8 | 8 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $sym_defender = $_POST['defender'] ? $_POST['defender'] : array(); |
| 16 | 16 | $sym_attacker = $_POST['attacker'] ? $_POST['attacker'] : array(); |
| 17 | 17 | |
| 18 | -if($replay) |
|
| 18 | +if ($replay) |
|
| 19 | 19 | { |
| 20 | 20 | $unpacked = sn_ube_simulator_decode_replay($replay); |
| 21 | 21 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $sym_attacker = array(1 => $sym_attacker); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -if($_POST['submit'] || $execute) |
|
| 31 | +if ($_POST['submit'] || $execute) |
|
| 32 | 32 | { |
| 33 | 33 | $replay = sn_ube_simulator_encode_replay($sym_defender, 'D'); |
| 34 | 34 | $replay .= sn_ube_simulator_encode_replay($sym_attacker, 'A'); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | // sn_ube_report_save($combat_data); |
| 43 | 43 | // } |
| 44 | 44 | |
| 45 | - if(sys_get_param_str('reload')) |
|
| 45 | + if (sys_get_param_str('reload')) |
|
| 46 | 46 | { |
| 47 | 47 | $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); |
| 48 | 48 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | $template = gettemplate('simulator', true); |
| 63 | 63 | $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL); |
| 64 | 64 | |
| 65 | - foreach($techs_and_officers as $tech_id) |
|
| 65 | + foreach ($techs_and_officers as $tech_id) |
|
| 66 | 66 | { |
| 67 | - if(!$sym_attacker[1][$tech_id]) |
|
| 67 | + if (!$sym_attacker[1][$tech_id]) |
|
| 68 | 68 | { |
| 69 | 69 | $sym_attacker[1][$tech_id] = mrc_get_level($user, false, $tech_id); |
| 70 | 70 | } |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | UNIT_GOVERNORS => array(MRC_FORTIFIER), |
| 79 | 79 | UNIT_DEFENCE => sn_get_groups('defense_active'), |
| 80 | 80 | ); |
| 81 | - foreach($show_groups as $unit_group_id => $unit_group) |
|
| 81 | + foreach ($show_groups as $unit_group_id => $unit_group) |
|
| 82 | 82 | { |
| 83 | 83 | $template->assign_block_vars('simulator', array( |
| 84 | 84 | 'GROUP' => $unit_group_id, |
| 85 | 85 | 'NAME' => $lang['tech'][$unit_group_id], |
| 86 | 86 | )); |
| 87 | 87 | |
| 88 | - foreach($unit_group as $unit_id) |
|
| 88 | + foreach ($unit_group as $unit_id) |
|
| 89 | 89 | { |
| 90 | 90 | $tab++; |
| 91 | 91 | |
@@ -21,8 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $sym_defender = $unpacked['D']; |
| 23 | 23 | $sym_attacker = $unpacked['A']; |
| 24 | -} |
|
| 25 | -else |
|
| 24 | +} else |
|
| 26 | 25 | { |
| 27 | 26 | $sym_defender = array(0 => $sym_defender); |
| 28 | 27 | $sym_attacker = array(1 => $sym_attacker); |
@@ -62,8 +61,7 @@ discard block |
||
| 62 | 61 | )); |
| 63 | 62 | |
| 64 | 63 | display($template); |
| 65 | -} |
|
| 66 | -else |
|
| 64 | +} else |
|
| 67 | 65 | { |
| 68 | 66 | $template = gettemplate('simulator', true); |
| 69 | 67 | $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL); |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | include('includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
| 17 | 17 | // die(); |
| 18 | -if($template_result[F_USER_IS_AUTHORIZED]) { |
|
| 18 | +if ($template_result[F_USER_IS_AUTHORIZED]) { |
|
| 19 | 19 | sys_redirect('index' . DOT_PHP_EX); |
| 20 | 20 | } |
| 21 | 21 | lng_include('login'); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $newstock = $stock; |
| 27 | 27 | $intError = MARKET_DEAL; |
| 28 | 28 | |
| 29 | -switch($mode) |
|
| 29 | +switch ($mode) |
|
| 30 | 30 | { |
| 31 | 31 | case MARKET_RESOURCES: // Resource trader |
| 32 | 32 | require('includes/includes/market_trader.inc'); |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $message_id = sys_get_param_int('message'); |
| 85 | -if($message_id != MARKET_NOTHING) |
|
| 85 | +if ($message_id != MARKET_NOTHING) |
|
| 86 | 86 | { |
| 87 | 87 | $template->assign_block_vars('result', array('MESSAGE' => $lang['eco_mrk_errors'][$message_id])); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | -if($message) |
|
| 90 | +if ($message) |
|
| 91 | 91 | { |
| 92 | 92 | $template->assign_block_vars('result', array('MESSAGE' => $message)); |
| 93 | 93 | } |
@@ -140,7 +140,9 @@ |
||
| 140 | 140 | global $template_result; |
| 141 | 141 | // Доступные платежные методы |
| 142 | 142 | foreach($payment_methods_available as $payment_type_id => $payment_methods) { |
| 143 | - if(empty($payment_methods)) continue; |
|
| 143 | + if(empty($payment_methods)) { |
|
| 144 | + continue; |
|
| 145 | + } |
|
| 144 | 146 | |
| 145 | 147 | $template_result['.']['payment'][$payment_type_id] =array( |
| 146 | 148 | 'ID' => $payment_type_id, |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 10 | 10 | |
| 11 | -if(!sn_module_get_active_count('payment')) { |
|
| 11 | +if (!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($lang['pay_currency_list'][$player_currency]) ? ($player_currency = $player_currency_default ? $player_currency_default : classSupernova::$config->payment_currency_default) : false; |
|
| 26 | +empty($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($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($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($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' => $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' => $lang["module_{$module_name}_name"], |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | -foreach($lang['pay_currency_list'] as $key => $value) { |
|
| 201 | +foreach ($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($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' => pretty_number($request['metamatter']), |
| 303 | 303 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
| 304 | 304 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |
@@ -18,6 +18,11 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
| 20 | 20 | // TODO - OK 4.6 |
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @param integer $confirmation_type_safe |
|
| 24 | + * @param string $email_unsafe |
|
| 25 | + */ |
|
| 21 | 26 | public function db_confirmation_get_latest_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
| 22 | 27 | $email_safe = $this->db->db_escape($email_unsafe); |
| 23 | 28 | |
@@ -26,12 +31,21 @@ discard block |
||
| 26 | 31 | `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}' ORDER BY create_time DESC LIMIT 1;", true); |
| 27 | 32 | } |
| 28 | 33 | // TODO - OK 4.6 |
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @param integer $confirmation_type_safe |
|
| 37 | + */ |
|
| 29 | 38 | public function db_confirmation_delete_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
| 30 | 39 | $email_safe = $this->db->db_escape($email_unsafe); |
| 31 | 40 | |
| 32 | 41 | return $this->db->doquery("DELETE FROM {{confirmations}} WHERE `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}'"); |
| 33 | 42 | } |
| 34 | 43 | // TODO - OK 4.6 |
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @param integer $confirmation_type_safe |
|
| 47 | + * @param string $email_unsafe |
|
| 48 | + */ |
|
| 35 | 49 | public function db_confirmation_get_unique_code_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
| 36 | 50 | $email_safe = $this->db->db_escape($email_unsafe); |
| 37 | 51 | |
@@ -50,6 +64,11 @@ discard block |
||
| 50 | 64 | return $confirm_code_unsafe; |
| 51 | 65 | } |
| 52 | 66 | // TODO - OK 4.6 |
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @param integer $confirmation_type_safe |
|
| 70 | + * @param string $confirmation_code_unsafe |
|
| 71 | + */ |
|
| 53 | 72 | public function db_confirmation_get_by_type_and_code($confirmation_type_safe, $confirmation_code_unsafe) { |
| 54 | 73 | $confirmation_code_safe = $this->db->db_escape($confirmation_code_unsafe); |
| 55 | 74 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | // $query = static::$db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' AND `type` = {$confirmation_type_safe} FOR UPDATE", true); |
| 42 | 42 | // Тип не нужен для проверки - код подтверждения должен быть уникален от слова "совсем" |
| 43 | 43 | $query = $this->db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE", true); |
| 44 | - } while($query); |
|
| 44 | + } while ($query); |
|
| 45 | 45 | |
| 46 | 46 | $this->db->doquery( |
| 47 | 47 | "REPLACE INTO {{confirmations}} |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | * Рассчёт бонуса ММ |
| 703 | 703 | * |
| 704 | 704 | * @param $dark_matter |
| 705 | - * @param bool|true $direct |
|
| 705 | + * @param boolean $direct |
|
| 706 | 706 | * @param bool|false $return_bonus |
| 707 | 707 | * |
| 708 | 708 | * @return float|int |
@@ -738,6 +738,12 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | // Дополнительная ре-трансляция адреса, если в каком-то случае платежная система ожидает нелогичный ответ |
| 740 | 740 | // Пример: иксолла при неправильно заданном пользователе в ордере ожидает НЕПРАВИЛЬНЫЙ_ОРДЕР, а не НЕПРАВИЛЬНЫЙ_ПОЛЬЗОВАТЕЛЬ |
| 741 | + |
|
| 742 | + /** |
|
| 743 | + * @param integer $error_code |
|
| 744 | + * |
|
| 745 | + * @return integer|null |
|
| 746 | + */ |
|
| 741 | 747 | function retranslate_error($error_code, $options = array()) { |
| 742 | 748 | return isset($options['retranslate_error'][$error_code]) ? $options['retranslate_error'][$error_code] : $error_code; |
| 743 | 749 | } |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | public function compile_request($request) { |
| 451 | 451 | global $config, $lang, $user; |
| 452 | 452 | |
| 453 | - if(!(classSupernova::$auth->account instanceof Account)) { |
|
| 453 | + if (!(classSupernova::$auth->account instanceof Account)) { |
|
| 454 | 454 | // TODO - throw new Exception($lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
| 455 | 455 | } |
| 456 | 456 | $this->account = classSupernova::$auth->account; |
@@ -471,15 +471,15 @@ discard block |
||
| 471 | 471 | $this->payment_currency = $config->payment_currency_default; |
| 472 | 472 | $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency); |
| 473 | 473 | |
| 474 | - if(empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
| 474 | + if (empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
| 475 | 475 | $this->payment_external_currency = $this->config['currency']; |
| 476 | 476 | } |
| 477 | - if(empty($this->payment_external_currency)) { |
|
| 477 | + if (empty($this->payment_external_currency)) { |
|
| 478 | 478 | throw new Exception($lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET); |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency); |
| 482 | - if($this->payment_external_amount < 0.01) { |
|
| 482 | + if ($this->payment_external_amount < 0.01) { |
|
| 483 | 483 | throw new Exception($lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
| 484 | 484 | } |
| 485 | 485 | |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $this->generate_description(); |
| 489 | 489 | |
| 490 | 490 | $this->db_insert(); |
| 491 | - if(!$this->is_exists) { |
|
| 491 | + if (!$this->is_exists) { |
|
| 492 | 492 | throw new Exception($lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE); |
| 493 | 493 | } |
| 494 | 494 | } |
@@ -503,24 +503,24 @@ discard block |
||
| 503 | 503 | protected function payment_request_process($options = array()) { |
| 504 | 504 | global $lang, $config; |
| 505 | 505 | |
| 506 | - if(!$this->manifest['active']) { |
|
| 506 | + if (!$this->manifest['active']) { |
|
| 507 | 507 | throw new Exception($lang['pay_msg_module_disabled'], SN_MODULE_DISABLED); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | // Если есть payment_id - загружаем под него данные |
| 511 | - if(!empty($this->payment_params['payment_id'])) { |
|
| 511 | + if (!empty($this->payment_params['payment_id'])) { |
|
| 512 | 512 | $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']); |
| 513 | - if(!$this->request_payment_id) { |
|
| 513 | + if (!$this->request_payment_id) { |
|
| 514 | 514 | throw new Exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if(!$this->db_get_by_id($this->request_payment_id)) { |
|
| 517 | + if (!$this->db_get_by_id($this->request_payment_id)) { |
|
| 518 | 518 | throw new Exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | // Проверяем - был ли этот платеж обработан? |
| 522 | 522 | // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed |
| 523 | - if($this->payment_status != PAYMENT_STATUS_NONE) { |
|
| 523 | + if ($this->payment_status != PAYMENT_STATUS_NONE) { |
|
| 524 | 524 | sn_db_transaction_rollback(); |
| 525 | 525 | sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id); |
| 526 | 526 | die(); |
@@ -530,89 +530,89 @@ discard block |
||
| 530 | 530 | // Пытаемся получить из запроса ИД аккаунта |
| 531 | 531 | $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0; |
| 532 | 532 | // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id |
| 533 | - if(empty($request_account_id) && !empty($this->payment_account_id)) { |
|
| 533 | + if (empty($request_account_id) && !empty($this->payment_account_id)) { |
|
| 534 | 534 | $request_account_id = $this->payment_account_id; |
| 535 | 535 | } |
| 536 | 536 | // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать |
| 537 | - if(empty($request_account_id)) { |
|
| 537 | + if (empty($request_account_id)) { |
|
| 538 | 538 | // TODO - аккаунт |
| 539 | 539 | throw new Exception($lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 540 | 540 | } |
| 541 | 541 | // Если нет записи в таблице - тогда берем payment_account_id из запроса |
| 542 | - if(empty($this->payment_account_id)) { |
|
| 542 | + if (empty($this->payment_account_id)) { |
|
| 543 | 543 | $this->payment_account_id = $request_account_id; |
| 544 | 544 | } |
| 545 | 545 | // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать |
| 546 | - if($this->payment_account_id != $request_account_id) { |
|
| 546 | + if ($this->payment_account_id != $request_account_id) { |
|
| 547 | 547 | // TODO - Поменять сообщение об ошибке |
| 548 | 548 | throw new Exception($lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 549 | 549 | } |
| 550 | 550 | // Проверяем существование аккаунта с данным ИД |
| 551 | - if(!$this->account->db_get_by_id($this->payment_account_id)) { |
|
| 551 | + if (!$this->account->db_get_by_id($this->payment_account_id)) { |
|
| 552 | 552 | throw new Exception($lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | // TODO Проверка на сервер_ид - как бы и не нужна, наверное? |
| 556 | - if(!empty($this->payment_params['server_id'])) { |
|
| 556 | + if (!empty($this->payment_params['server_id'])) { |
|
| 557 | 557 | $this->request_server_id = sys_get_param_str($this->payment_params['server_id']); |
| 558 | - if(SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
| 558 | + if (SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
| 559 | 559 | throw new Exception($lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | // Сверка количества оплаченной ММ с учётом бонусов |
| 564 | - if(!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
| 564 | + if (!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
| 565 | 565 | $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']); |
| 566 | - if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
| 566 | + if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
| 567 | 567 | throw new Exception($lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID); |
| 568 | 568 | } |
| 569 | 569 | empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false; |
| 570 | 570 | } |
| 571 | - if(empty($this->payment_dark_matter_paid)) { |
|
| 571 | + if (empty($this->payment_dark_matter_paid)) { |
|
| 572 | 572 | // TODO - обратный расчёт из gained |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | // Проверка наличия внешнего ИД платежа |
| 576 | - if(!empty($this->payment_params['payment_external_id'])) { |
|
| 576 | + if (!empty($this->payment_params['payment_external_id'])) { |
|
| 577 | 577 | $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']); |
| 578 | - if(empty($request_payment_external_id)) { |
|
| 578 | + if (empty($request_payment_external_id)) { |
|
| 579 | 579 | throw new exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
| 580 | - } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
| 580 | + } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
| 581 | 581 | // TODO - Может быть поменять сообщение |
| 582 | 582 | throw new exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
| 583 | 583 | } |
| 584 | 584 | $this->payment_external_id = $request_payment_external_id; |
| 585 | 585 | } |
| 586 | 586 | // Сверка суммы, запрошенной СН к оплате |
| 587 | - if(!empty($this->payment_params['payment_external_money'])) { |
|
| 587 | + if (!empty($this->payment_params['payment_external_money'])) { |
|
| 588 | 588 | $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']); |
| 589 | - if($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
| 589 | + if ($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
| 590 | 590 | throw new Exception($lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
| 591 | 591 | } |
| 592 | 592 | empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false; |
| 593 | 593 | } |
| 594 | 594 | // Заполняем поле валюты платёжной системы |
| 595 | - if(!empty($this->payment_params['payment_external_currency'])) { |
|
| 595 | + if (!empty($this->payment_params['payment_external_currency'])) { |
|
| 596 | 596 | $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']); |
| 597 | - if(empty($this->payment_external_currency)) { |
|
| 597 | + if (empty($this->payment_external_currency)) { |
|
| 598 | 598 | // TODO - поменять сообщение |
| 599 | 599 | throw new Exception($lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | - if(empty($this->payment_external_currency)) { |
|
| 602 | + if (empty($this->payment_external_currency)) { |
|
| 603 | 603 | $this->payment_external_currency = $this->config['currency']; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | // Заполнение внутренней суммы и валюты из внешних данных |
| 607 | - if(empty($this->payment_currency)) { |
|
| 607 | + if (empty($this->payment_currency)) { |
|
| 608 | 608 | $this->payment_currency = $config->payment_currency_default; |
| 609 | 609 | } |
| 610 | - if(empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
| 610 | + if (empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
| 611 | 611 | $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | // TODO - Тестовый режим |
| 615 | - if(!empty($this->payment_params['test'])) { |
|
| 615 | + if (!empty($this->payment_params['test'])) { |
|
| 616 | 616 | $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']); |
| 617 | 617 | } |
| 618 | 618 | |
@@ -641,12 +641,12 @@ discard block |
||
| 641 | 641 | sn_db_transaction_start(); |
| 642 | 642 | try { |
| 643 | 643 | $response = $this->payment_request_process(); |
| 644 | - } catch(Exception $e) { |
|
| 644 | + } catch (Exception $e) { |
|
| 645 | 645 | $response['result'] = $e->getCode(); |
| 646 | 646 | $response['message'] = $e->getMessage(); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - if($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
| 649 | + if ($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
| 650 | 650 | sn_db_transaction_commit(); |
| 651 | 651 | $debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT); |
| 652 | 652 | } else { |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // Переводим код результата из СН в код платежной системы |
| 658 | - if(is_array($this->result_translations) && !empty($this->result_translations)) { |
|
| 658 | + if (is_array($this->result_translations) && !empty($this->result_translations)) { |
|
| 659 | 659 | $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR]; |
| 660 | 660 | } |
| 661 | 661 | |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | $currency_from = strtolower($currency_from); |
| 681 | 681 | $currency_to = strtolower($currency_to); |
| 682 | 682 | |
| 683 | - if($currency_from != $currency_to) { |
|
| 683 | + if ($currency_from != $currency_to) { |
|
| 684 | 684 | // $config_currency_from_name = 'payment_currency_exchange_' . $currency_from; |
| 685 | 685 | // $config_currency_to_name = 'payment_currency_exchange_' . $currency_to; |
| 686 | 686 | |
@@ -710,10 +710,10 @@ discard block |
||
| 710 | 710 | public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) { |
| 711 | 711 | $bonus = 0; |
| 712 | 712 | $dark_matter_new = $dark_matter; |
| 713 | - if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
| 714 | - if($direct) { |
|
| 715 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 716 | - if($dm_for_bonus <= $dark_matter) { |
|
| 713 | + if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
| 714 | + if ($direct) { |
|
| 715 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 716 | + if ($dm_for_bonus <= $dark_matter) { |
|
| 717 | 717 | $dark_matter_new = $dark_matter * (1 + $multiplier); |
| 718 | 718 | $bonus = $multiplier; |
| 719 | 719 | } else { |
@@ -721,9 +721,9 @@ discard block |
||
| 721 | 721 | } |
| 722 | 722 | } |
| 723 | 723 | } else { |
| 724 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 724 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 725 | 725 | $temp = $dm_for_bonus * (1 + $multiplier); |
| 726 | - if($dark_matter >= $temp) { |
|
| 726 | + if ($dark_matter >= $temp) { |
|
| 727 | 727 | $dark_matter_new = round($dark_matter / (1 + $multiplier)); |
| 728 | 728 | $bonus = $multiplier; |
| 729 | 729 | } else { |
@@ -779,13 +779,13 @@ discard block |
||
| 779 | 779 | ); |
| 780 | 780 | |
| 781 | 781 | $replace = false; |
| 782 | - if($this->payment_id) { |
|
| 782 | + if ($this->payment_id) { |
|
| 783 | 783 | $payment['payment_id'] = $this->payment_id; |
| 784 | 784 | $replace = true; |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | $query = array(); |
| 788 | - foreach($payment as $key => $value) { |
|
| 788 | + foreach ($payment as $key => $value) { |
|
| 789 | 789 | $value = is_string($value) ? '"' . db_escape($value) . '"' : $value; |
| 790 | 790 | $query[] = "`{$key}` = {$value}"; |
| 791 | 791 | } |
@@ -797,12 +797,12 @@ discard block |
||
| 797 | 797 | |
| 798 | 798 | |
| 799 | 799 | function payment_adjust_mm_new() { |
| 800 | - if(!$this->payment_test) { |
|
| 800 | + if (!$this->payment_test) { |
|
| 801 | 801 | // Not a test payment. Adding DM to account |
| 802 | 802 | $this->account = new Account($this->db); |
| 803 | 803 | $this->account->db_get_by_id($this->payment_account_id); |
| 804 | 804 | $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment); |
| 805 | - if(!$result) { |
|
| 805 | + if (!$result) { |
|
| 806 | 806 | throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
| 807 | 807 | } |
| 808 | 808 | } |
@@ -812,25 +812,25 @@ discard block |
||
| 812 | 812 | die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}'); |
| 813 | 813 | global $lang; |
| 814 | 814 | |
| 815 | - if(!isset($payment['payment_status'])) { |
|
| 815 | + if (!isset($payment['payment_status'])) { |
|
| 816 | 816 | throw new exception($lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND); |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 820 | - $safe_comment = db_escape($payment['payment_comment'] = $lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']); |
|
| 819 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 820 | + $safe_comment = db_escape($payment['payment_comment'] = $lang['pay_msg_request_payment_cancelled'] . ' ' . $payment['payment_comment']); |
|
| 821 | 821 | |
| 822 | - if(!$payment['payment_test']) { |
|
| 822 | + if (!$payment['payment_test']) { |
|
| 823 | 823 | $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']); |
| 824 | - if(!$result) { |
|
| 824 | + if (!$result) { |
|
| 825 | 825 | throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
| 826 | 826 | } |
| 827 | 827 | } |
| 828 | 828 | $payment['payment_status'] = PAYMENT_STATUS_CANCELED; |
| 829 | 829 | doquery("UPDATE {{payment}} SET payment_status = {$payment['payment_status']}, payment_comment = '{$safe_comment}' WHERE payment_id = {$payment['payment_id']};"); |
| 830 | 830 | throw new exception($lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK); |
| 831 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
| 831 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
| 832 | 832 | throw new exception($lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK); |
| 833 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 833 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 834 | 834 | throw new exception($lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE); |
| 835 | 835 | } |
| 836 | 836 | } |
@@ -844,8 +844,8 @@ discard block |
||
| 844 | 844 | |
| 845 | 845 | protected function db_complete_payment() { |
| 846 | 846 | // TODO - поле payment_processed |
| 847 | - if($this->payment_status == PAYMENT_STATUS_NONE) { |
|
| 848 | - if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
| 847 | + if ($this->payment_status == PAYMENT_STATUS_NONE) { |
|
| 848 | + if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
| 849 | 849 | $this->payment_adjust_mm_new(); |
| 850 | 850 | $this->payment_status = PAYMENT_STATUS_COMPLETE; |
| 851 | 851 | } else { |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | protected function db_assign_payment($payment = null) { |
| 893 | 893 | $this->payment_reset(); |
| 894 | 894 | |
| 895 | - if(is_array($payment) && isset($payment['payment_id'])) { |
|
| 895 | + if (is_array($payment) && isset($payment['payment_id'])) { |
|
| 896 | 896 | $this->payment_id = $payment['payment_id']; |
| 897 | 897 | $this->payment_status = $payment['payment_status']; |
| 898 | 898 | $this->payment_date = $payment['payment_date']; |