@@ -75,7 +75,7 @@ |
||
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | - * @param $fleet_group_id_list |
|
| 78 | + * @param string $fleet_group_id_list |
|
| 79 | 79 | */ |
| 80 | 80 | public static function db_acs_delete_by_list($fleet_group_id_list) { |
| 81 | 81 | doquery("DELETE FROM {{aks}} WHERE `id` IN ({$fleet_group_id_list})"); |
@@ -2,6 +2,10 @@ |
||
| 2 | 2 | |
| 3 | 3 | class DBStaticFleetMissile { |
| 4 | 4 | |
| 5 | + /** |
|
| 6 | + * @param double $arrival |
|
| 7 | + * @param integer $target_structure |
|
| 8 | + */ |
|
| 5 | 9 | public static function db_missile_insert($target_coord, $user, $planetrow, $arrival, $fleet_ship_count, $target_structure) { |
| 6 | 10 | classSupernova::$db->doInsert( |
| 7 | 11 | "INSERT INTO `{{iraks}}` SET |
@@ -467,6 +467,12 @@ |
||
| 467 | 467 | {$StartRec}, 25;"); |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | + /** |
|
| 471 | + * @param integer $message_type |
|
| 472 | + * @param string $from_unsafe |
|
| 473 | + * @param string $subject_unsafe |
|
| 474 | + * @param string $text_unsafe |
|
| 475 | + */ |
|
| 470 | 476 | public static function db_message_insert_all($message_type, $from_unsafe, $subject_unsafe, $text_unsafe) { |
| 471 | 477 | $message_type_safe = intval($message_type); |
| 472 | 478 | $from_safe = db_escape($from_unsafe); |
@@ -50,8 +50,8 @@ |
||
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @param template $template |
| 53 | - * @param $query_where |
|
| 54 | - * @param $query_limit |
|
| 53 | + * @param string $query_where |
|
| 54 | + * @param integer $query_limit |
|
| 55 | 55 | * |
| 56 | 56 | * @return array|bool|mysqli_result|null |
| 57 | 57 | */ |
@@ -21,11 +21,19 @@ discard block |
||
| 21 | 21 | return empty($result) ? null : $result; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | + /** |
|
| 25 | + * @param integer $galaxy |
|
| 26 | + * @param integer $system |
|
| 27 | + * @param integer $planet |
|
| 28 | + */ |
|
| 24 | 29 | public static function db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') { |
| 25 | 30 | return classSupernova::db_get_record_list(LOC_PLANET, |
| 26 | 31 | "{{planets}}.`galaxy` = {$galaxy} AND {{planets}}.`system` = {$system} AND {{planets}}.`planet` = {$planet} AND {{planets}}.`planet_type` = {$planet_type}", true); |
| 27 | 32 | } |
| 28 | 33 | |
| 34 | + /** |
|
| 35 | + * @param integer $planet_type |
|
| 36 | + */ |
|
| 29 | 37 | public static function db_planet_by_gspt($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') { |
| 30 | 38 | $galaxy = intval($galaxy); |
| 31 | 39 | $system = intval($system); |
@@ -120,6 +128,9 @@ discard block |
||
| 120 | 128 | "`id_owner` = '{$user_row['id']}' {$conditions} ORDER BY {$order_by}"); |
| 121 | 129 | } |
| 122 | 130 | |
| 131 | + /** |
|
| 132 | + * @param integer $planet_id |
|
| 133 | + */ |
|
| 123 | 134 | public static function db_planet_list_by_user_or_planet($user_id, $planet_id) { |
| 124 | 135 | if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) { |
| 125 | 136 | return false; |
@@ -138,6 +149,9 @@ discard block |
||
| 138 | 149 | return classSupernova::db_upd_record_by_id(LOC_PLANET, $planet_id, $set); |
| 139 | 150 | } |
| 140 | 151 | |
| 152 | + /** |
|
| 153 | + * @param integer $ui_planet_type |
|
| 154 | + */ |
|
| 141 | 155 | public static function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) { |
| 142 | 156 | if(!($set = trim($set))) { |
| 143 | 157 | return false; |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0; |
| 69 | 69 | $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0; |
| 70 | 70 | $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0; |
| 71 | - $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : |
|
| 72 | - (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
| 71 | + $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
| 73 | 72 | $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type; |
| 74 | 73 | |
| 75 | 74 | return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields); |
@@ -118,6 +118,9 @@ |
||
| 118 | 118 | return classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, $set); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | + /** |
|
| 122 | + * @param integer $unit_location_type |
|
| 123 | + */ |
|
| 121 | 124 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) { |
| 122 | 125 | $where = array('unit_location_type' => $unit_location_type); |
| 123 | 126 | ($unit_location_id = idval($unit_location_id)) ? $where['unit_location_id'] = $unit_location_id : false; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
| 210 | 210 | if (!empty($temp['unit_id'])) { |
| 211 | - $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
| 211 | + $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
| 212 | 212 | LOC_UNIT, |
| 213 | 213 | $temp['unit_id'], |
| 214 | 214 | array(), |
@@ -219,15 +219,15 @@ discard block |
||
| 219 | 219 | } else { |
| 220 | 220 | $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id; |
| 221 | 221 | $unitType = get_unit_param($unit_id, P_UNIT_TYPE); |
| 222 | - $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record( |
|
| 222 | + $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record( |
|
| 223 | 223 | LOC_UNIT, |
| 224 | 224 | array( |
| 225 | 225 | 'unit_player_id' => $user['id'], |
| 226 | - 'unit_location_type' => (int)$unit_location, |
|
| 226 | + 'unit_location_type' => (int) $unit_location, |
|
| 227 | 227 | 'unit_location_id' => $locationIdRendered, |
| 228 | - 'unit_type' => (int)$unitType, |
|
| 229 | - 'unit_snid' => (int)$unit_id, |
|
| 230 | - 'unit_level' => (float)$unit_value, |
|
| 228 | + 'unit_type' => (int) $unitType, |
|
| 229 | + 'unit_snid' => (int) $unit_id, |
|
| 230 | + 'unit_level' => (float) $unit_value, |
|
| 231 | 231 | ) |
| 232 | 232 | ); |
| 233 | 233 | } |
@@ -40,6 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | + * @param string $fields |
|
| 43 | 44 | * @return DbResultIterator |
| 44 | 45 | */ |
| 45 | 46 | protected static function playerSelectIterator($fields, $orderBy = '', $forUpdate = false, $groupHaving = '', $where = '', $limit = '') { |
@@ -134,6 +135,9 @@ discard block |
||
| 134 | 135 | return $result; |
| 135 | 136 | } |
| 136 | 137 | |
| 138 | + /** |
|
| 139 | + * @param integer $config_user_birthday_range |
|
| 140 | + */ |
|
| 137 | 141 | public static function db_user_list_to_celebrate($config_user_birthday_range) { |
| 138 | 142 | $query = "SELECT |
| 139 | 143 | `id`, `username`, `user_birthday`, `user_birthday_celebrated`, |
@@ -213,6 +217,9 @@ discard block |
||
| 213 | 217 | return $user_list; |
| 214 | 218 | } |
| 215 | 219 | |
| 220 | + /** |
|
| 221 | + * @param string $username_unsafe |
|
| 222 | + */ |
|
| 216 | 223 | public static function db_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) { |
| 217 | 224 | // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ? |
| 218 | 225 | if (!($username_unsafe = trim($username_unsafe))) { |
@@ -266,7 +273,6 @@ discard block |
||
| 266 | 273 | |
| 267 | 274 | /** |
| 268 | 275 | * @param $user_id |
| 269 | - * @param array $set |
|
| 270 | 276 | * @param array $adjust |
| 271 | 277 | * |
| 272 | 278 | * @return array|bool|mysqli_result|null |
@@ -283,8 +289,8 @@ discard block |
||
| 283 | 289 | * <p>array - запись пользователя с установленным полем ['id']</p> |
| 284 | 290 | * @param bool $for_update @deprecated |
| 285 | 291 | * @param string $fields @deprecated список полей или '*'/'' для всех полей |
| 286 | - * @param null $player |
|
| 287 | - * @param bool|null $player Признак выбора записи пользователь типа "игрок" |
|
| 292 | + * @param boolean $player |
|
| 293 | + * @param boolean $player Признак выбора записи пользователь типа "игрок" |
|
| 288 | 294 | * <p>null - Можно выбрать запись любого типа</p> |
| 289 | 295 | * <p>true - Выбирается только запись типа "игрок"</p> |
| 290 | 296 | * <p>false - Выбирается только запись типа "альянс"</p> |
@@ -187,6 +187,9 @@ |
||
| 187 | 187 | return $error_backtrace; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | + /** |
|
| 191 | + * @param string $die_message |
|
| 192 | + */ |
|
| 190 | 193 | public function error_fatal($die_message, $details = 'There is a fatal error on page') { |
| 191 | 194 | // TODO - Записывать детали ошибки в лог-файл |
| 192 | 195 | die($die_message); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | defined('INSIDE') || die(); |
| 34 | 34 | |
| 35 | -if(php_sapi_name() == "cli") { |
|
| 35 | +if (php_sapi_name() == "cli") { |
|
| 36 | 36 | // In cli-mode |
| 37 | 37 | define('__DEBUG_CRLF', "\r\n"); |
| 38 | 38 | define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF); |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | public function log_file($message, $ident_change = 0) { |
| 53 | 53 | static $ident = 0; |
| 54 | 54 | |
| 55 | - if(!defined('SN_DEBUG_LOG')) { |
|
| 55 | + if (!defined('SN_DEBUG_LOG')) { |
|
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if($this->log_file_handler === null) { |
|
| 59 | + if ($this->log_file_handler === null) { |
|
| 60 | 60 | $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
| 61 | 61 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
| 62 | 62 | } |
| 63 | 63 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
| 64 | - if($this->log_file_handler) { |
|
| 64 | + if ($this->log_file_handler) { |
|
| 65 | 65 | @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
| 66 | 66 | } |
| 67 | 67 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | $result = array(); |
| 93 | 93 | $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId(); |
| 94 | 94 | $result[] = "tID {$transaction_id}"; |
| 95 | - foreach($backtrace as $a_trace) { |
|
| 96 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
| 95 | + foreach ($backtrace as $a_trace) { |
|
| 96 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
| 97 | 97 | continue; |
| 98 | 98 | } |
| 99 | 99 | $function = |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
| 111 | 111 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
| 112 | 112 | |
| 113 | - if(!$long_comment) { |
|
| 113 | + if (!$long_comment) { |
|
| 114 | 114 | break; |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -131,26 +131,26 @@ discard block |
||
| 131 | 131 | public function dump($dump = false, $force_base = false, $deadlock = false) { |
| 132 | 132 | global $user, $planetrow; |
| 133 | 133 | |
| 134 | - if($dump === false) { |
|
| 134 | + if ($dump === false) { |
|
| 135 | 135 | return; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $error_backtrace = array(); |
| 139 | 139 | $base_dump = false; |
| 140 | 140 | |
| 141 | - if($force_base === true) { |
|
| 141 | + if ($force_base === true) { |
|
| 142 | 142 | $base_dump = true; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if($dump === true) { |
|
| 145 | + if ($dump === true) { |
|
| 146 | 146 | $base_dump = true; |
| 147 | 147 | } else { |
| 148 | - if(!is_array($dump)) { |
|
| 148 | + if (!is_array($dump)) { |
|
| 149 | 149 | $dump = array('var' => $dump); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - foreach($dump as $dump_var_name => $dump_var) { |
|
| 153 | - if($dump_var_name == 'base_dump') { |
|
| 152 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
| 153 | + if ($dump_var_name == 'base_dump') { |
|
| 154 | 154 | $base_dump = $dump_var; |
| 155 | 155 | } else { |
| 156 | 156 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -158,22 +158,21 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
| 161 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
| 162 | 162 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
| 163 | 163 | $error_backtrace['locks'] = classSupernova::$gc->snCache->getLocks(); |
| 164 | 164 | $error_backtrace['cSN_data'] = classSupernova::$gc->snCache->getData(); |
| 165 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
| 166 | - foreach($location as $location_id => &$location_data) { |
|
| 167 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
| 168 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
| 165 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
| 166 | + foreach ($location as $location_id => &$location_data) { |
|
| 167 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
| 169 | 168 | } |
| 170 | 169 | } |
| 171 | 170 | $error_backtrace['cSN_queries'] = classSupernova::$gc->snCache->getQueries(); |
| 172 | 171 | } |
| 173 | 172 | |
| 174 | - if($base_dump) { |
|
| 175 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
| 176 | - foreach($this->log_array as $log) { |
|
| 173 | + if ($base_dump) { |
|
| 174 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
| 175 | + foreach ($this->log_array as $log) { |
|
| 177 | 176 | $error_backtrace['queries'][] = $log; |
| 178 | 177 | } |
| 179 | 178 | } |
@@ -202,14 +201,14 @@ discard block |
||
| 202 | 201 | public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
| 203 | 202 | global $sys_stop_log_hit, $sys_log_disabled, $user; |
| 204 | 203 | |
| 205 | - if(empty(classSupernova::$db->connected)) { |
|
| 204 | + if (empty(classSupernova::$db->connected)) { |
|
| 206 | 205 | // TODO - писать ошибку в файл |
| 207 | 206 | die('SQL server currently unavailable. Please contact Administration...'); |
| 208 | 207 | } |
| 209 | 208 | |
| 210 | 209 | sn_db_transaction_rollback(); |
| 211 | 210 | |
| 212 | - if(classSupernova::$config->debug == 1) { |
|
| 211 | + if (classSupernova::$config->debug == 1) { |
|
| 213 | 212 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
| 214 | 213 | echo "<table>{$this->log}</table>"; |
| 215 | 214 | } |
@@ -221,7 +220,7 @@ discard block |
||
| 221 | 220 | |
| 222 | 221 | $userId = empty($user['id']) ? 0 : $user['id']; |
| 223 | 222 | |
| 224 | - if(!$sys_log_disabled) { |
|
| 223 | + if (!$sys_log_disabled) { |
|
| 225 | 224 | $query = "INSERT INTO `{{logs}}` SET |
| 226 | 225 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "', |
| 227 | 226 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -240,7 +239,7 @@ discard block |
||
| 240 | 239 | ob_start(); |
| 241 | 240 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
| 242 | 241 | |
| 243 | - foreach($error_backtrace as $name => $value) { |
|
| 242 | + foreach ($error_backtrace as $name => $value) { |
|
| 244 | 243 | print(__DEBUG_LINE); |
| 245 | 244 | pdump($value, $name); |
| 246 | 245 | } |
@@ -258,7 +257,7 @@ discard block |
||
| 258 | 257 | public function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
| 259 | 258 | global $user, $sys_log_disabled; |
| 260 | 259 | |
| 261 | - if(empty(classSupernova::$db->connected)) { |
|
| 260 | + if (empty(classSupernova::$db->connected)) { |
|
| 262 | 261 | // TODO - писать ошибку в файл |
| 263 | 262 | die('SQL server currently unavailable. Please contact Administration...'); |
| 264 | 263 | } |
@@ -267,7 +266,7 @@ discard block |
||
| 267 | 266 | |
| 268 | 267 | $userId = empty($user['id']) ? 0 : $user['id']; |
| 269 | 268 | |
| 270 | - if(!$sys_log_disabled) { |
|
| 269 | + if (!$sys_log_disabled) { |
|
| 271 | 270 | $query = "INSERT INTO `{{logs}}` SET |
| 272 | 271 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "', |
| 273 | 272 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -285,11 +284,11 @@ discard block |
||
| 285 | 284 | // Dump variables nicer then var_dump() |
| 286 | 285 | |
| 287 | 286 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
| 288 | - if(isset($varname)) { |
|
| 287 | + if (isset($varname)) { |
|
| 289 | 288 | $varname .= " = "; |
| 290 | 289 | } |
| 291 | 290 | |
| 292 | - if($level == -1) { |
|
| 291 | + if ($level == -1) { |
|
| 293 | 292 | $trans[' '] = '∴'; |
| 294 | 293 | $trans["\t"] = '⇒'; |
| 295 | 294 | $trans["\n"] = '¶;'; |
@@ -298,7 +297,7 @@ discard block |
||
| 298 | 297 | |
| 299 | 298 | return strtr(htmlspecialchars($value), $trans); |
| 300 | 299 | } |
| 301 | - if($level == 0) { |
|
| 300 | + if ($level == 0) { |
|
| 302 | 301 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
| 303 | 302 | $dumper = mt_rand(10, 99) . '|' . $varname; |
| 304 | 303 | } |
@@ -306,22 +305,22 @@ discard block |
||
| 306 | 305 | $type = gettype($value); |
| 307 | 306 | $dumper .= $type; |
| 308 | 307 | |
| 309 | - if($type == TYPE_STRING) { |
|
| 308 | + if ($type == TYPE_STRING) { |
|
| 310 | 309 | $dumper .= '(' . strlen($value) . ')'; |
| 311 | 310 | $value = dump($value, '', -1); |
| 312 | - } elseif($type == TYPE_BOOLEAN) { |
|
| 311 | + } elseif ($type == TYPE_BOOLEAN) { |
|
| 313 | 312 | $value = ($value ? 'true' : 'false'); |
| 314 | - } elseif($type == 'object') { |
|
| 313 | + } elseif ($type == 'object') { |
|
| 315 | 314 | $props = get_class_vars(get_class($value)); |
| 316 | 315 | $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
| 317 | - foreach($props as $key => $val) { |
|
| 316 | + foreach ($props as $key => $val) { |
|
| 318 | 317 | $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
| 319 | 318 | $dumper .= dump($value->$key, '', $level + 1); |
| 320 | 319 | } |
| 321 | 320 | $value = ''; |
| 322 | - } elseif($type == TYPE_ARRAY) { |
|
| 321 | + } elseif ($type == TYPE_ARRAY) { |
|
| 323 | 322 | $dumper .= '(' . count($value) . ')'; |
| 324 | - foreach($value as $key => $val) { |
|
| 323 | + foreach ($value as $key => $val) { |
|
| 325 | 324 | $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
| 326 | 325 | $dumper .= dump($val, '', $level + 1); |
| 327 | 326 | } |
@@ -341,7 +340,7 @@ discard block |
||
| 341 | 340 | // $backtrace = $backtrace[1]; |
| 342 | 341 | |
| 343 | 342 | $caller = ''; |
| 344 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
| 343 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
| 345 | 344 | $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
| 346 | 345 | (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
| 347 | 346 | $backtrace[1]['function'] . |
@@ -368,7 +367,7 @@ discard block |
||
| 368 | 367 | } |
| 369 | 368 | |
| 370 | 369 | function pr($prePrint = false) { |
| 371 | - if($prePrint) { |
|
| 370 | + if ($prePrint) { |
|
| 372 | 371 | print(__DEBUG_CRLF); |
| 373 | 372 | } |
| 374 | 373 | print(mt_rand() . __DEBUG_CRLF); |
@@ -378,7 +377,7 @@ discard block |
||
| 378 | 377 | global $_PRINT_COUNT_VALUE; |
| 379 | 378 | $_PRINT_COUNT_VALUE++; |
| 380 | 379 | |
| 381 | - if($prePrint) { |
|
| 380 | + if ($prePrint) { |
|
| 382 | 381 | print(__DEBUG_CRLF); |
| 383 | 382 | } |
| 384 | 383 | print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
@@ -409,7 +408,7 @@ discard block |
||
| 409 | 408 | */ |
| 410 | 409 | function pdie($message = '', $level = 0) { |
| 411 | 410 | $backtrace = debug_backtrace(); |
| 412 | - for($i = 0; $i < $level; $i++) { |
|
| 411 | + for ($i = 0; $i < $level; $i++) { |
|
| 413 | 412 | array_pop($backtrace); |
| 414 | 413 | } |
| 415 | 414 | |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | |
| 92 | 92 | $result = array(); |
| 93 | 93 | $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId(); |
| 94 | - $result[] = "tID {$transaction_id}"; |
|
| 94 | + $result[] = "tid {$transaction_id}"; |
|
| 95 | 95 | foreach($backtrace as $a_trace) { |
| 96 | 96 | if(in_array($a_trace['function'], $exclude_functions)) { |
| 97 | 97 | continue; |
@@ -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 | } |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | public function compile_request($request) { |
| 449 | 449 | global $user; |
| 450 | 450 | |
| 451 | - if(!(classSupernova::$auth->account instanceof Account)) { |
|
| 451 | + if (!(classSupernova::$auth->account instanceof Account)) { |
|
| 452 | 452 | // TODO - throw new Exception(lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
| 453 | 453 | } |
| 454 | 454 | $this->account = classSupernova::$auth->account; |
@@ -469,15 +469,15 @@ discard block |
||
| 469 | 469 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
| 470 | 470 | $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency); |
| 471 | 471 | |
| 472 | - if(empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
| 472 | + if (empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
| 473 | 473 | $this->payment_external_currency = $this->config['currency']; |
| 474 | 474 | } |
| 475 | - if(empty($this->payment_external_currency)) { |
|
| 475 | + if (empty($this->payment_external_currency)) { |
|
| 476 | 476 | throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET); |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency); |
| 480 | - if($this->payment_external_amount < 0.01) { |
|
| 480 | + if ($this->payment_external_amount < 0.01) { |
|
| 481 | 481 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
| 482 | 482 | } |
| 483 | 483 | |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | $this->generate_description(); |
| 487 | 487 | |
| 488 | 488 | $this->db_insert(); |
| 489 | - if(!$this->is_exists) { |
|
| 489 | + if (!$this->is_exists) { |
|
| 490 | 490 | throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE); |
| 491 | 491 | } |
| 492 | 492 | } |
@@ -498,24 +498,24 @@ discard block |
||
| 498 | 498 | * @throws Exception |
| 499 | 499 | */ |
| 500 | 500 | protected function payment_request_process($options = array()) { |
| 501 | - if(!$this->manifest['active']) { |
|
| 501 | + if (!$this->manifest['active']) { |
|
| 502 | 502 | throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED); |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | // Если есть payment_id - загружаем под него данные |
| 506 | - if(!empty($this->payment_params['payment_id'])) { |
|
| 506 | + if (!empty($this->payment_params['payment_id'])) { |
|
| 507 | 507 | $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']); |
| 508 | - if(!$this->request_payment_id) { |
|
| 508 | + if (!$this->request_payment_id) { |
|
| 509 | 509 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - if(!$this->db_get_by_id($this->request_payment_id)) { |
|
| 512 | + if (!$this->db_get_by_id($this->request_payment_id)) { |
|
| 513 | 513 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | // Проверяем - был ли этот платеж обработан? |
| 517 | 517 | // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed |
| 518 | - if($this->payment_status != PAYMENT_STATUS_NONE) { |
|
| 518 | + if ($this->payment_status != PAYMENT_STATUS_NONE) { |
|
| 519 | 519 | sn_db_transaction_rollback(); |
| 520 | 520 | sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id); |
| 521 | 521 | die(); |
@@ -525,89 +525,89 @@ discard block |
||
| 525 | 525 | // Пытаемся получить из запроса ИД аккаунта |
| 526 | 526 | $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0; |
| 527 | 527 | // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id |
| 528 | - if(empty($request_account_id) && !empty($this->payment_account_id)) { |
|
| 528 | + if (empty($request_account_id) && !empty($this->payment_account_id)) { |
|
| 529 | 529 | $request_account_id = $this->payment_account_id; |
| 530 | 530 | } |
| 531 | 531 | // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать |
| 532 | - if(empty($request_account_id)) { |
|
| 532 | + if (empty($request_account_id)) { |
|
| 533 | 533 | // TODO - аккаунт |
| 534 | 534 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 535 | 535 | } |
| 536 | 536 | // Если нет записи в таблице - тогда берем payment_account_id из запроса |
| 537 | - if(empty($this->payment_account_id)) { |
|
| 537 | + if (empty($this->payment_account_id)) { |
|
| 538 | 538 | $this->payment_account_id = $request_account_id; |
| 539 | 539 | } |
| 540 | 540 | // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать |
| 541 | - if($this->payment_account_id != $request_account_id) { |
|
| 541 | + if ($this->payment_account_id != $request_account_id) { |
|
| 542 | 542 | // TODO - Поменять сообщение об ошибке |
| 543 | 543 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 544 | 544 | } |
| 545 | 545 | // Проверяем существование аккаунта с данным ИД |
| 546 | - if(!$this->account->db_get_by_id($this->payment_account_id)) { |
|
| 546 | + if (!$this->account->db_get_by_id($this->payment_account_id)) { |
|
| 547 | 547 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | // TODO Проверка на сервер_ид - как бы и не нужна, наверное? |
| 551 | - if(!empty($this->payment_params['server_id'])) { |
|
| 551 | + if (!empty($this->payment_params['server_id'])) { |
|
| 552 | 552 | $this->request_server_id = sys_get_param_str($this->payment_params['server_id']); |
| 553 | - if(SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
| 553 | + if (SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
| 554 | 554 | throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | // Сверка количества оплаченной ММ с учётом бонусов |
| 559 | - if(!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
| 559 | + if (!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
| 560 | 560 | $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']); |
| 561 | - if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
| 561 | + if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
| 562 | 562 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID); |
| 563 | 563 | } |
| 564 | 564 | empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false; |
| 565 | 565 | } |
| 566 | - if(empty($this->payment_dark_matter_paid)) { |
|
| 566 | + if (empty($this->payment_dark_matter_paid)) { |
|
| 567 | 567 | // TODO - обратный расчёт из gained |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | // Проверка наличия внешнего ИД платежа |
| 571 | - if(!empty($this->payment_params['payment_external_id'])) { |
|
| 571 | + if (!empty($this->payment_params['payment_external_id'])) { |
|
| 572 | 572 | $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']); |
| 573 | - if(empty($request_payment_external_id)) { |
|
| 573 | + if (empty($request_payment_external_id)) { |
|
| 574 | 574 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
| 575 | - } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
| 575 | + } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
| 576 | 576 | // TODO - Может быть поменять сообщение |
| 577 | 577 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
| 578 | 578 | } |
| 579 | 579 | $this->payment_external_id = $request_payment_external_id; |
| 580 | 580 | } |
| 581 | 581 | // Сверка суммы, запрошенной СН к оплате |
| 582 | - if(!empty($this->payment_params['payment_external_money'])) { |
|
| 582 | + if (!empty($this->payment_params['payment_external_money'])) { |
|
| 583 | 583 | $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']); |
| 584 | - if($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
| 584 | + if ($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
| 585 | 585 | throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
| 586 | 586 | } |
| 587 | 587 | empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false; |
| 588 | 588 | } |
| 589 | 589 | // Заполняем поле валюты платёжной системы |
| 590 | - if(!empty($this->payment_params['payment_external_currency'])) { |
|
| 590 | + if (!empty($this->payment_params['payment_external_currency'])) { |
|
| 591 | 591 | $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']); |
| 592 | - if(empty($this->payment_external_currency)) { |
|
| 592 | + if (empty($this->payment_external_currency)) { |
|
| 593 | 593 | // TODO - поменять сообщение |
| 594 | 594 | throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | - if(empty($this->payment_external_currency)) { |
|
| 597 | + if (empty($this->payment_external_currency)) { |
|
| 598 | 598 | $this->payment_external_currency = $this->config['currency']; |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | // Заполнение внутренней суммы и валюты из внешних данных |
| 602 | - if(empty($this->payment_currency)) { |
|
| 602 | + if (empty($this->payment_currency)) { |
|
| 603 | 603 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
| 604 | 604 | } |
| 605 | - if(empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
| 605 | + if (empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
| 606 | 606 | $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency); |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // TODO - Тестовый режим |
| 610 | - if(!empty($this->payment_params['test'])) { |
|
| 610 | + if (!empty($this->payment_params['test'])) { |
|
| 611 | 611 | $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']); |
| 612 | 612 | } |
| 613 | 613 | |
@@ -634,12 +634,12 @@ discard block |
||
| 634 | 634 | sn_db_transaction_start(); |
| 635 | 635 | try { |
| 636 | 636 | $response = $this->payment_request_process(); |
| 637 | - } catch(Exception $e) { |
|
| 637 | + } catch (Exception $e) { |
|
| 638 | 638 | $response['result'] = $e->getCode(); |
| 639 | 639 | $response['message'] = $e->getMessage(); |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - if($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
| 642 | + if ($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
| 643 | 643 | sn_db_transaction_commit(); |
| 644 | 644 | classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT); |
| 645 | 645 | } else { |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | // Переводим код результата из СН в код платежной системы |
| 651 | - if(is_array($this->result_translations) && !empty($this->result_translations)) { |
|
| 651 | + if (is_array($this->result_translations) && !empty($this->result_translations)) { |
|
| 652 | 652 | $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR]; |
| 653 | 653 | } |
| 654 | 654 | |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | $currency_from = strtolower($currency_from); |
| 672 | 672 | $currency_to = strtolower($currency_to); |
| 673 | 673 | |
| 674 | - if($currency_from != $currency_to) { |
|
| 674 | + if ($currency_from != $currency_to) { |
|
| 675 | 675 | $exchange_from = get_exchange_rate($currency_from); |
| 676 | 676 | $exchange_to = get_exchange_rate($currency_to); |
| 677 | 677 | |
@@ -695,10 +695,10 @@ discard block |
||
| 695 | 695 | public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) { |
| 696 | 696 | $bonus = 0; |
| 697 | 697 | $dark_matter_new = $dark_matter; |
| 698 | - if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
| 699 | - if($direct) { |
|
| 700 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 701 | - if($dm_for_bonus <= $dark_matter) { |
|
| 698 | + if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
| 699 | + if ($direct) { |
|
| 700 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 701 | + if ($dm_for_bonus <= $dark_matter) { |
|
| 702 | 702 | $dark_matter_new = $dark_matter * (1 + $multiplier); |
| 703 | 703 | $bonus = $multiplier; |
| 704 | 704 | } else { |
@@ -706,9 +706,9 @@ discard block |
||
| 706 | 706 | } |
| 707 | 707 | } |
| 708 | 708 | } else { |
| 709 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 709 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 710 | 710 | $temp = $dm_for_bonus * (1 + $multiplier); |
| 711 | - if($dark_matter >= $temp) { |
|
| 711 | + if ($dark_matter >= $temp) { |
|
| 712 | 712 | $dark_matter_new = round($dark_matter / (1 + $multiplier)); |
| 713 | 713 | $bonus = $multiplier; |
| 714 | 714 | } else { |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | 'payment_external_lots' => $this->payment_dark_matter_paid / get_mm_cost(), |
| 762 | 762 | ); |
| 763 | 763 | |
| 764 | - if($this->payment_id) { |
|
| 764 | + if ($this->payment_id) { |
|
| 765 | 765 | $payment['payment_id'] = $this->payment_id; |
| 766 | 766 | classSupernova::$gc->db->doReplaceSet('payment', $payment); |
| 767 | 767 | } else { |
@@ -773,12 +773,12 @@ discard block |
||
| 773 | 773 | |
| 774 | 774 | |
| 775 | 775 | public function payment_adjust_mm_new() { |
| 776 | - if(!$this->payment_test) { |
|
| 776 | + if (!$this->payment_test) { |
|
| 777 | 777 | // Not a test payment. Adding DM to account |
| 778 | 778 | $this->account = new Account($this->db); |
| 779 | 779 | $this->account->db_get_by_id($this->payment_account_id); |
| 780 | 780 | $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment); |
| 781 | - if(!$result) { |
|
| 781 | + if (!$result) { |
|
| 782 | 782 | throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
| 783 | 783 | } |
| 784 | 784 | } |
@@ -787,25 +787,25 @@ discard block |
||
| 787 | 787 | public function payment_cancel(&$payment) { |
| 788 | 788 | die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}'); |
| 789 | 789 | |
| 790 | - if(!isset($payment['payment_status'])) { |
|
| 790 | + if (!isset($payment['payment_status'])) { |
|
| 791 | 791 | throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND); |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 795 | - $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']; |
|
| 794 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 795 | + $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] . ' ' . $payment['payment_comment']; |
|
| 796 | 796 | |
| 797 | - if(!$payment['payment_test']) { |
|
| 797 | + if (!$payment['payment_test']) { |
|
| 798 | 798 | $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']); |
| 799 | - if(!$result) { |
|
| 799 | + if (!$result) { |
|
| 800 | 800 | throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | 803 | $payment['payment_status'] = PAYMENT_STATUS_CANCELED; |
| 804 | 804 | db_payment_update($payment['payment_id'], $payment['payment_status'], $comment_unsafe); |
| 805 | 805 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK); |
| 806 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
| 806 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
| 807 | 807 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK); |
| 808 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 808 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 809 | 809 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE); |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -828,8 +828,8 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | protected function db_complete_payment() { |
| 830 | 830 | // TODO - поле payment_processed |
| 831 | - if($this->payment_status == PAYMENT_STATUS_NONE) { |
|
| 832 | - if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
| 831 | + if ($this->payment_status == PAYMENT_STATUS_NONE) { |
|
| 832 | + if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
| 833 | 833 | $this->payment_adjust_mm_new(); |
| 834 | 834 | $this->payment_status = PAYMENT_STATUS_COMPLETE; |
| 835 | 835 | } else { |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | protected function db_assign_payment($payment = null) { |
| 877 | 877 | $this->payment_reset(); |
| 878 | 878 | |
| 879 | - if(is_array($payment) && isset($payment['payment_id'])) { |
|
| 879 | + if (is_array($payment) && isset($payment['payment_id'])) { |
|
| 880 | 880 | $this->payment_id = $payment['payment_id']; |
| 881 | 881 | $this->payment_status = $payment['payment_status']; |
| 882 | 882 | $this->payment_date = $payment['payment_date']; |