@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
8 | 8 | |
9 | -if($user['authlevel'] < 3) |
|
9 | +if ($user['authlevel'] < 3) |
|
10 | 10 | { |
11 | 11 | message(classLocale::$lang['sys_noalloaw'], classLocale::$lang['sys_noaccess']); |
12 | 12 | die(); |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | // [#] info_best_battles 1b0 |
23 | 23 | $best_reports = array(); |
24 | 24 | |
25 | -if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
25 | +if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
26 | 26 | $query = db_ube_report_get_best_battles(); |
27 | - while($row = db_fetch($query)) { |
|
27 | + while ($row = db_fetch($query)) { |
|
28 | 28 | $best_reports[] = $row['ube_report_id']; |
29 | 29 | } |
30 | 30 | } |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | $old_server_status == GAME_DISABLE_NONE ? classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false; |
192 | 192 | sn_db_transaction_commit(); |
193 | 193 | |
194 | -foreach($ques as $que_transaction) { |
|
194 | +foreach ($ques as $que_transaction) { |
|
195 | 195 | sn_db_transaction_start(); |
196 | 196 | |
197 | 197 | !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false; |
198 | - foreach($que_transaction as $que) { |
|
198 | + foreach ($que_transaction as $que) { |
|
199 | 199 | set_time_limit(120); |
200 | - if(is_callable($que)) { |
|
200 | + if (is_callable($que)) { |
|
201 | 201 | $QryResult = call_user_func($que); |
202 | 202 | } else { |
203 | 203 | $QryResult = classSupernova::$db->doSql($que); |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | $this->container = array(); |
37 | 37 | |
38 | - if(classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
38 | + if (classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
39 | 39 | $this->cache = classSupernova::$cache; |
40 | 40 | classSupernova::log_file('locale.__constructor: Cache is present'); |
41 | 41 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
42 | 42 | } |
43 | 43 | |
44 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
44 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
45 | 45 | $this->enable_stat_usage = $enable_stat_usage; |
46 | 46 | $this->usage_stat_load(); |
47 | 47 | // TODO shutdown function |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | unset($fallback[$this->active]); |
68 | 68 | |
69 | 69 | // Проходим по оставшимся локалям |
70 | - foreach($fallback as $try_language) { |
|
70 | + foreach ($fallback as $try_language) { |
|
71 | 71 | // Если нет такой строки - пытаемся вытащить из кэша |
72 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
72 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | 73 | $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
74 | 74 | // Записываем результат работы кэша |
75 | 75 | $locale_cache_statistic['queries']++; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | // Если мы как-то где-то нашли строку... |
81 | - if(isset($this->container[$try_language][$offset])) { |
|
81 | + if (isset($this->container[$try_language][$offset])) { |
|
82 | 82 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
83 | 83 | $this[$offset] = $this->container[$try_language][$offset]; |
84 | 84 | $locale_cache_statistic['fallbacks']++; |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | $this->container[$this->active][] = $value; |
95 | 95 | } else { |
96 | 96 | $this->container[$this->active][$offset] = $value; |
97 | - if($this->cache) { |
|
97 | + if ($this->cache) { |
|
98 | 98 | $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | public function offsetExists($offset) { |
103 | 103 | // Шорткат если у нас уже есть строка в памяти PHP |
104 | - if(!isset($this->container[$this->active][$offset])) { |
|
104 | + if (!isset($this->container[$this->active][$offset])) { |
|
105 | 105 | // pdump($this->cache_prefix_lang . $offset); |
106 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
106 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
107 | 107 | // pdump($this->cache_prefix_lang . $offset); |
108 | 108 | // Если нету такой строки - делаем фоллбэк |
109 | 109 | $this->locale_string_fallback($offset); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | public function offsetGet($offset) { |
121 | 121 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
122 | - if($this->enable_stat_usage) { |
|
122 | + if ($this->enable_stat_usage) { |
|
123 | 123 | $this->usage_stat_log($offset, $value); |
124 | 124 | } |
125 | 125 | return $value; |
@@ -134,16 +134,16 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | public function usage_stat_load() { |
137 | - $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); |
|
138 | - if(empty($this->stat_usage)) { |
|
137 | + $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); |
|
138 | + if (empty($this->stat_usage)) { |
|
139 | 139 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{lng_usage_stat}}`"); |
140 | - while($row = db_fetch($query)) { |
|
140 | + while ($row = db_fetch($query)) { |
|
141 | 141 | $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
145 | 145 | public function usage_stat_save() { |
146 | - if(!empty($this->stat_usage_new)) { |
|
146 | + if (!empty($this->stat_usage_new)) { |
|
147 | 147 | classSupernova::$cache->lng_stat_usage = $this->stat_usage; |
148 | 148 | classSupernova::$db->doSelect("SELECT 1 FROM `{{lng_usage_stat}}` LIMIT 1"); |
149 | 149 | // foreach($this->stat_usage_new as &$value) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
173 | 173 | |
174 | 174 | $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
175 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
175 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
176 | 176 | $this->stat_usage[$string_id] = empty($value); |
177 | 177 | $this->stat_usage_new[] = array( |
178 | 178 | 'lang_code' => $this->active, |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
213 | 213 | |
214 | 214 | // Подключен ли внешний кэш? |
215 | - if($this->cache) { |
|
215 | + if ($this->cache) { |
|
216 | 216 | // Загружен ли уже данный файл? |
217 | 217 | $cache_file_status = $this->cache->__get($cache_file_key); |
218 | 218 | classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
219 | - if($cache_file_status) { |
|
219 | + if ($cache_file_status) { |
|
220 | 220 | // Если да - повторять загрузку нет смысла |
221 | 221 | return null; |
222 | 222 | } |
@@ -230,36 +230,36 @@ discard block |
||
230 | 230 | $this->make_fallback($language); |
231 | 231 | |
232 | 232 | $file_path = ''; |
233 | - foreach($this->fallback as $lang_try) { |
|
234 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
233 | + foreach ($this->fallback as $lang_try) { |
|
234 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
235 | 235 | continue; |
236 | 236 | } |
237 | 237 | |
238 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
238 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
239 | 239 | break; |
240 | 240 | } |
241 | 241 | |
242 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
242 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
243 | 243 | break; |
244 | 244 | } |
245 | 245 | |
246 | 246 | $file_path = ''; |
247 | 247 | } |
248 | 248 | |
249 | - if($file_path) { |
|
249 | + if ($file_path) { |
|
250 | 250 | $a_lang_array = array(); |
251 | 251 | include($file_path); |
252 | 252 | |
253 | - if(!empty($a_lang_array)) { |
|
253 | + if (!empty($a_lang_array)) { |
|
254 | 254 | $this->merge($a_lang_array); |
255 | 255 | |
256 | 256 | // Загрузка данных из файла в кэш |
257 | - if($this->cache) { |
|
257 | + if ($this->cache) { |
|
258 | 258 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
259 | - foreach($a_lang_array as $key => $value) { |
|
259 | + foreach ($a_lang_array as $key => $value) { |
|
260 | 260 | $value_cache_key = $this->cache_prefix_lang . $key; |
261 | - if($this->cache->__isset($value_cache_key)) { |
|
262 | - if(is_array($value)) { |
|
261 | + if ($this->cache->__isset($value_cache_key)) { |
|
262 | + if (is_array($value)) { |
|
263 | 263 | $alt_value = $this->cache->__get($value_cache_key); |
264 | 264 | $value = array_replace_recursive($alt_value, $value); |
265 | 265 | // pdump($alt_value, $alt_value); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | - if($this->cache) { |
|
273 | + if ($this->cache) { |
|
274 | 274 | $this->cache->__set($cache_file_key, true); |
275 | 275 | } |
276 | 276 | |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | public function lng_load_i18n($i18n) { |
286 | - if(!isset($i18n)) { |
|
286 | + if (!isset($i18n)) { |
|
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
290 | - foreach($i18n as $i18n_data) { |
|
291 | - if(is_string($i18n_data)) { |
|
290 | + foreach ($i18n as $i18n_data) { |
|
291 | + if (is_string($i18n_data)) { |
|
292 | 292 | $this->lng_include($i18n_data); |
293 | - } elseif(is_array($i18n_data)) { |
|
293 | + } elseif (is_array($i18n_data)) { |
|
294 | 294 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
295 | 295 | } |
296 | 296 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
310 | 310 | |
311 | - if($language_new == $this->active) { |
|
311 | + if ($language_new == $this->active) { |
|
312 | 312 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
313 | 313 | return false; |
314 | 314 | } |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
320 | 320 | $this->make_fallback($this->active); |
321 | 321 | |
322 | - if($this->cache) { |
|
322 | + if ($this->cache) { |
|
323 | 323 | $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
324 | 324 | classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
325 | - if($cache_lang_init_status) { |
|
325 | + if ($cache_lang_init_status) { |
|
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | // Loading global language files |
339 | 339 | $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']); |
340 | 340 | |
341 | - if($this->cache) { |
|
341 | + if ($this->cache) { |
|
342 | 342 | classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
343 | 343 | $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
344 | 344 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public function lng_get_info($entry) { |
353 | 353 | $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
354 | 354 | $lang_info = array(); |
355 | - if(file_exists($file_name)) { |
|
355 | + if (file_exists($file_name)) { |
|
356 | 356 | include($file_name); |
357 | 357 | } |
358 | 358 | |
@@ -360,15 +360,15 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | public function lng_get_list() { |
363 | - if(empty($this->lang_list)) { |
|
363 | + if (empty($this->lang_list)) { |
|
364 | 364 | $this->lang_list = array(); |
365 | 365 | |
366 | 366 | $path = SN_ROOT_PHYSICAL . 'language/'; |
367 | 367 | $dir = dir($path); |
368 | - while(false !== ($entry = $dir->read())) { |
|
369 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
368 | + while (false !== ($entry = $dir->read())) { |
|
369 | + if (is_dir($path . $entry) && $entry[0] != '.') { |
|
370 | 370 | $lang_info = $this->lng_get_info($entry); |
371 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
371 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
372 | 372 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
373 | 373 | } |
374 | 374 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Инициализация харнилища скинов |
153 | 153 | */ |
154 | 154 | protected static function init() { |
155 | - if(static::$is_init) { |
|
155 | + if (static::$is_init) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | // Загружены ли уже данные по текущему скину? |
167 | 167 | //pdump(static::$skin_list[$ini_path], 'static'); |
168 | - if(empty(static::$skin_list[$skin_path])) { |
|
168 | + if (empty(static::$skin_list[$skin_path])) { |
|
169 | 169 | // Прогружаем текущий скин |
170 | 170 | static::$skin_list[$skin_path] = new skin($skin_path); |
171 | 171 | static::$active = static::$skin_list[$skin_path]; |
@@ -201,22 +201,22 @@ discard block |
||
201 | 201 | |
202 | 202 | $this->is_ini_present = false; |
203 | 203 | // Проверка на корректность и существование пути |
204 | - if(is_file($this->root_physical_absolute . 'skin.ini')) { |
|
204 | + if (is_file($this->root_physical_absolute . 'skin.ini')) { |
|
205 | 205 | // Пытаемся распарсить файл |
206 | 206 | |
207 | 207 | // По секциям? images и config? Что бы не копировать конфигурацию? Или просто unset(__inherit) а затем заново записать |
208 | 208 | $this->config = parse_ini_file($this->root_physical_absolute . 'skin.ini'); |
209 | - if(!empty($this->config)) { |
|
209 | + if (!empty($this->config)) { |
|
210 | 210 | |
211 | 211 | $this->is_ini_present = true; |
212 | 212 | |
213 | - if(!empty($this->config['_inherit'])) { |
|
213 | + if (!empty($this->config['_inherit'])) { |
|
214 | 214 | // Если скин наследует себя... |
215 | - if($this->config['_inherit'] == $skin_path) { |
|
215 | + if ($this->config['_inherit'] == $skin_path) { |
|
216 | 216 | // TODO - определять более сложные случаи циклических ссылок в _inherit |
217 | 217 | die('">circular skin inheritance!'); |
218 | 218 | } |
219 | - if(empty(static::$skin_list[$this->config['_inherit']])) { |
|
219 | + if (empty(static::$skin_list[$this->config['_inherit']])) { |
|
220 | 220 | static::$skin_list[$this->config['_inherit']] = new skin($this->config['_inherit']); |
221 | 221 | } |
222 | 222 | $this->parent = static::$skin_list[$this->config['_inherit']]; |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | // Пытаемся скомпилировать _no_image заранее |
235 | - if(!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
235 | + if (!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
236 | 236 | $this->container[SKIN_IMAGE_MISSED_FIELD] = $this->compile_try_path(SKIN_IMAGE_MISSED_FIELD, $this->config[SKIN_IMAGE_MISSED_FIELD]); |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Если нет заглушки |
240 | - if(empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
240 | + if (empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
241 | 241 | $this->container[SKIN_IMAGE_MISSED_FIELD] = empty($this->parent) |
242 | 242 | // Если нет парента - берем хардкод |
243 | 243 | ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL . SKIN_IMAGE_MISSED_FILE_PATH |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $image_tag = $this->image_tag_parse($image_tag, $template); |
268 | 268 | |
269 | 269 | // Проверяем наличие ключа RIT в хранилища. В нём не может быть несуществующих файлов по построению |
270 | - if(!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
270 | + if (!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
271 | 271 | return $this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]]; |
272 | 272 | } |
273 | 273 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | // Нет - image ID не является путём к файлу. Пора обратиться к предкам за помощью... |
286 | 286 | // Пытаемся вытащить путь из родителя и применить к нему свои параметры |
287 | 287 | // Тащим по ID изображения, а не по ТЭГУ - мало ли что там делает с путём родитель и как преобразовывает его в строку? |
288 | - if(empty($this->container[$image_id]) && !empty($this->parent)) { |
|
288 | + if (empty($this->container[$image_id]) && !empty($this->parent)) { |
|
289 | 289 | $this->container[$image_id] = $this->parent->compile_image($image_id, $template); |
290 | 290 | |
291 | 291 | // Если у родителя нет картинки - он вернет пустую строку. Тогда нам надо использовать заглушку - свою или родительскую |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | protected function image_tag_parse($image_tag, $template) { |
307 | 307 | $image_tag_ptl_resolved = $image_tag; |
308 | 308 | // Есть переменные из темплейта ? |
309 | - if(strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
309 | + if (strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
310 | 310 | // Что бы лишний раз не запускать регексп |
311 | 311 | // TODO - многоуровневые вложения ?! Надо ли и где их можно применить |
312 | 312 | preg_match_all('#(\[.+?\])#', $image_tag_ptl_resolved, $matches); |
313 | - foreach($matches[0] as &$match) { |
|
313 | + foreach ($matches[0] as &$match) { |
|
314 | 314 | $var_name = str_replace(array('[', ']'), '', $match); |
315 | - if(strpos($var_name, '.') !== false) { |
|
315 | + if (strpos($var_name, '.') !== false) { |
|
316 | 316 | // Вложенная переменная темплейта - на текущем уровне |
317 | 317 | // TODO Вложенная переменная из корня через "!" |
318 | 318 | list($block_name, $block_var) = explode('.', $var_name); |
319 | 319 | isset($template->_block_value[$block_name][$block_var]) ? $image_tag_ptl_resolved = str_replace($match, $template->_block_value[$block_name][$block_var], $image_tag_ptl_resolved) : false; |
320 | - } elseif(strpos($var_name, '$') !== false) { |
|
320 | + } elseif (strpos($var_name, '$') !== false) { |
|
321 | 321 | // Корневой DEFINE |
322 | 322 | $define_name = substr($var_name, 1); |
323 | 323 | isset($template->_tpldata['DEFINE']['.'][$define_name]) ? $image_tag_ptl_resolved = str_replace($match, $template->_tpldata['DEFINE']['.'][$define_name], $image_tag_ptl_resolved) : false; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | - if(strpos($image_tag_ptl_resolved, '|') !== false) { |
|
331 | + if (strpos($image_tag_ptl_resolved, '|') !== false) { |
|
332 | 332 | $params = explode('|', $image_tag_ptl_resolved); |
333 | 333 | $image_id = $params[0]; |
334 | 334 | unset($params[0]); |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | $image_string = $this->container[$image_tag]; |
393 | 393 | |
394 | 394 | // Нет параметров - просто возвращаем значение по $image_name из контейнера |
395 | - if(!empty($params) && is_array($params)) { |
|
395 | + if (!empty($params) && is_array($params)) { |
|
396 | 396 | // Здесь автоматически произойдёт упорядочивание параметров |
397 | 397 | |
398 | 398 | // Параметр 'html' - выводить изображение в виде HTML-тэга |
399 | - if(in_array('html', $params)) { |
|
399 | + if (in_array('html', $params)) { |
|
400 | 400 | $image_tag = $image_tag . '|html'; |
401 | 401 | $image_string = '<img src="' . $image_string . '" />'; |
402 | 402 | $this->container[$image_tag] = $image_string; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public static function _init($group_name = '') { |
27 | 27 | parent::_init($group_name); |
28 | 28 | |
29 | - foreach(static::$_group_unit_id_list as $resource_id) { |
|
29 | + foreach (static::$_group_unit_id_list as $resource_id) { |
|
30 | 30 | static::$_group_pnames[$resource_id] = pname_resource_name($resource_id); |
31 | 31 | } |
32 | 32 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | !is_array($resource_array) ? $resource_array = array() : false; |
50 | 50 | |
51 | - foreach($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | - if(!$resource_actual_delta) { |
|
51 | + foreach ($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | + if (!$resource_actual_delta) { |
|
53 | 53 | // No delta - no changes |
54 | 54 | continue; |
55 | 55 | } |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | (!empty($where_safe) ? " WHERE {$where_safe}" : '') . |
38 | 38 | " FOR UPDATE;" |
39 | 39 | ); |
40 | - while($row = db_fetch($query)) { |
|
40 | + while ($row = db_fetch($query)) { |
|
41 | 41 | /** |
42 | 42 | * @var Fleet $fleet |
43 | 43 | */ |
44 | 44 | $fleet = $this->_createElement(); |
45 | 45 | $fleet->dbRowParse($row); |
46 | 46 | |
47 | - if(isset($this[$fleet->dbId])) { |
|
47 | + if (isset($this[$fleet->dbId])) { |
|
48 | 48 | // Нужно ли ???? |
49 | 49 | classSupernova::$debug->error('Fleet list already set'); |
50 | 50 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return static |
171 | 171 | */ |
172 | 172 | public static function dbGetFleetListAndMissileByCoordinates($coordinates, $for_phalanx = false) { |
173 | - if(empty($coordinates) || !is_array($coordinates)) { |
|
173 | + if (empty($coordinates) || !is_array($coordinates)) { |
|
174 | 174 | return array(); |
175 | 175 | } |
176 | 176 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @var Fleet[] $array_of_Fleet |
200 | 200 | */ |
201 | 201 | $array_of_Fleet = array(); |
202 | - if(!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
203 | - foreach($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
202 | + if (!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
203 | + foreach ($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
204 | 204 | $array_of_Fleet[$fleet_id] = $objFleet; |
205 | 205 | } |
206 | 206 | $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | "SELECT * FROM `{{iraks}}`" . |
250 | 250 | (!empty($where) ? " WHERE {$where}" : '') . |
251 | 251 | " FOR UPDATE;"); |
252 | - while($missile_db_row = db_fetch($query)) { |
|
252 | + while ($missile_db_row = db_fetch($query)) { |
|
253 | 253 | /** |
254 | 254 | * @var Fleet $objFleet |
255 | 255 | */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public static function dbGetFleetListAndMissileINCOMING($owner_id) { |
273 | 273 | $owner_id_safe = idval($owner_id); |
274 | - if(empty($owner_id_safe)) { |
|
274 | + if (empty($owner_id_safe)) { |
|
275 | 275 | return array(); |
276 | 276 | } |
277 | 277 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public static function fleet_count_flying($player_id, $mission_id = 0) { |
307 | 307 | $player_id_safe = idval($player_id); |
308 | - if(!empty($player_id_safe)) { |
|
308 | + if (!empty($player_id_safe)) { |
|
309 | 309 | $mission_id_safe = intval($mission_id); |
310 | 310 | $result = static::db_fleet_count( |
311 | 311 | "`fleet_owner` = {$player_id_safe}" . |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | |
123 | 123 | $update_cache = false; |
124 | 124 | |
125 | - if(!empty($this->to_write)) { |
|
126 | - foreach($this->to_write as $key => &$value) { |
|
125 | + if (!empty($this->to_write)) { |
|
126 | + foreach ($this->to_write as $key => &$value) { |
|
127 | 127 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
128 | 128 | $value = array($this->user_id, $key, $value); |
129 | 129 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | $update_cache = true; |
142 | 142 | } |
143 | 143 | |
144 | - if(!empty($this->to_delete)) { |
|
145 | - foreach($this->to_delete as $key => &$value) { |
|
146 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
144 | + if (!empty($this->to_delete)) { |
|
145 | + foreach ($this->to_delete as $key => &$value) { |
|
146 | + $value = is_string($key) ? "'" . db_escape($key) . "'" : $key; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | classSupernova::$db->doDeleteDanger( |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $update_cache = true; |
161 | 161 | } |
162 | 162 | |
163 | - if($update_cache) { |
|
163 | + if ($update_cache) { |
|
164 | 164 | $field_name = $this->cached_name(); |
165 | 165 | classSupernova::$cache->$field_name = $this->data; |
166 | 166 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | protected function load() { |
186 | - if($this->loaded) { |
|
186 | + if ($this->loaded) { |
|
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $this->to_write = array(); |
192 | 192 | $this->to_delete = array(); |
193 | 193 | |
194 | - if(!$this->user_id) { |
|
194 | + if (!$this->user_id) { |
|
195 | 195 | $this->loaded = true; |
196 | 196 | return; |
197 | 197 | } |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | $field_name = $this->cached_name(); |
200 | 200 | $a_data = classSupernova::$cache->$field_name; |
201 | 201 | |
202 | - if(!empty($a_data)) { |
|
202 | + if (!empty($a_data)) { |
|
203 | 203 | $this->data = array_replace_recursive($this->data, $a_data); |
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
208 | - while($row = db_fetch($query)) { |
|
208 | + while ($row = db_fetch($query)) { |
|
209 | 209 | // $this->data[$row['option_id']] = $row['value']; |
210 | 210 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
211 | 211 | } |
@@ -290,14 +290,14 @@ discard block |
||
290 | 290 | // Если в массиве индекса только один элемент - значит это просто индекс |
291 | 291 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
292 | 292 | |
293 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
293 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
294 | 294 | $this->load(); |
295 | 295 | } |
296 | 296 | |
297 | - if(is_array($option_id)) { |
|
297 | + if (is_array($option_id)) { |
|
298 | 298 | $result = $this->data; |
299 | - foreach($option_id as $sub_key) { |
|
300 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
299 | + foreach ($option_id as $sub_key) { |
|
300 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
301 | 301 | $result = null; |
302 | 302 | break; |
303 | 303 | } |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | * @param null|mixed $value |
316 | 316 | */ |
317 | 317 | public function __set($option, $value = null) { |
318 | - if(empty($option) || !$this->user_id) { |
|
318 | + if (empty($option) || !$this->user_id) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Если в массиве индекса только один элемент - значит это просто индекс |
323 | - if(is_array($option) && count($option) == 1) { |
|
323 | + if (is_array($option) && count($option) == 1) { |
|
324 | 324 | // Разворачиваем его в индекс |
325 | 325 | $option = array(reset($option) => $value); |
326 | 326 | unset($value); |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | |
330 | 330 | $to_write = array(); |
331 | 331 | // Адресация многомерного массива через массив индексов в $option |
332 | - if(is_array($option) && isset($value)) { |
|
332 | + if (is_array($option) && isset($value)) { |
|
333 | 333 | $a_data = &$this->data; |
334 | - foreach($option as $option_id) { |
|
334 | + foreach ($option as $option_id) { |
|
335 | 335 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
336 | 336 | $a_data = &$a_data[$option_id]; |
337 | 337 | } |
338 | - if($a_data != $value) { |
|
338 | + if ($a_data != $value) { |
|
339 | 339 | $a_data = $value; |
340 | 340 | $to_write[reset($option)] = null; |
341 | 341 | } |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | // Пакетная запись из массива ключ -> значение |
344 | 344 | !is_array($option) ? $option = array($option => $value) : false; |
345 | 345 | |
346 | - foreach($option as $option_id => $option_value) { |
|
347 | - if($this->data[$option_id] !== $option_value) { |
|
346 | + foreach ($option as $option_id => $option_value) { |
|
347 | + if ($this->data[$option_id] !== $option_value) { |
|
348 | 348 | // TODO - вынести отдельно в обработчик |
349 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
349 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
350 | 350 | sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
351 | 351 | } |
352 | 352 | |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | - if(!empty($to_write)) { |
|
359 | + if (!empty($to_write)) { |
|
360 | 360 | $field_name = $this->cached_name(); |
361 | 361 | classSupernova::$cache->$field_name = $this->data; |
362 | 362 | |
363 | - foreach($to_write as $option_id => &$option_value) { |
|
363 | + foreach ($to_write as $option_id => &$option_value) { |
|
364 | 364 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
365 | 365 | $option_value = array($this->user_id, $option_id, $option_value); |
366 | 366 | } |
@@ -376,26 +376,26 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | protected function load() { |
379 | - if($this->loaded) { |
|
379 | + if ($this->loaded) { |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
383 | 383 | $this->data = $this->defaults; |
384 | 384 | |
385 | - if(!$this->user_id) { |
|
385 | + if (!$this->user_id) { |
|
386 | 386 | return; |
387 | 387 | } |
388 | 388 | |
389 | 389 | $field_name = $this->cached_name(); |
390 | 390 | $a_data = classSupernova::$cache->$field_name; |
391 | 391 | |
392 | - if(!empty($a_data)) { |
|
392 | + if (!empty($a_data)) { |
|
393 | 393 | $this->data = array_replace($this->data, $a_data); |
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | 397 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
398 | - while($row = db_fetch($query)) { |
|
398 | + while ($row = db_fetch($query)) { |
|
399 | 399 | // $this->data[$row['option_id']] = $row['value']; |
400 | 400 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
401 | 401 | } |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | return $this->__get($offset); |
412 | 412 | } |
413 | 413 | public function offsetSet($offset, $value) { |
414 | - if(!is_null($offset)) { |
|
414 | + if (!is_null($offset)) { |
|
415 | 415 | // $this->data[$offset] = $value; |
416 | 416 | $this->__set($offset, $value); |
417 | 417 | } else { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | public function compile_request($request) { |
449 | 449 | global $user; |
450 | 450 | |
451 | - if(!(classSupernova::$auth->account instanceof Account)) { |
|
451 | + if (!(classSupernova::$auth->account instanceof Account)) { |
|
452 | 452 | // TODO - throw new Exception(lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
453 | 453 | } |
454 | 454 | $this->account = classSupernova::$auth->account; |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
470 | 470 | $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency); |
471 | 471 | |
472 | - if(empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
472 | + if (empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
473 | 473 | $this->payment_external_currency = $this->config['currency']; |
474 | 474 | } |
475 | - if(empty($this->payment_external_currency)) { |
|
475 | + if (empty($this->payment_external_currency)) { |
|
476 | 476 | throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET); |
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency); |
480 | - if($this->payment_external_amount < 0.01) { |
|
480 | + if ($this->payment_external_amount < 0.01) { |
|
481 | 481 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
482 | 482 | } |
483 | 483 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | $this->generate_description(); |
487 | 487 | |
488 | 488 | $this->db_insert(); |
489 | - if(!$this->is_exists) { |
|
489 | + if (!$this->is_exists) { |
|
490 | 490 | throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE); |
491 | 491 | } |
492 | 492 | } |
@@ -498,24 +498,24 @@ discard block |
||
498 | 498 | * @throws Exception |
499 | 499 | */ |
500 | 500 | protected function payment_request_process($options = array()) { |
501 | - if(!$this->manifest['active']) { |
|
501 | + if (!$this->manifest['active']) { |
|
502 | 502 | throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED); |
503 | 503 | } |
504 | 504 | |
505 | 505 | // Если есть payment_id - загружаем под него данные |
506 | - if(!empty($this->payment_params['payment_id'])) { |
|
506 | + if (!empty($this->payment_params['payment_id'])) { |
|
507 | 507 | $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']); |
508 | - if(!$this->request_payment_id) { |
|
508 | + if (!$this->request_payment_id) { |
|
509 | 509 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
510 | 510 | } |
511 | 511 | |
512 | - if(!$this->db_get_by_id($this->request_payment_id)) { |
|
512 | + if (!$this->db_get_by_id($this->request_payment_id)) { |
|
513 | 513 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
514 | 514 | } |
515 | 515 | |
516 | 516 | // Проверяем - был ли этот платеж обработан? |
517 | 517 | // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed |
518 | - if($this->payment_status != PAYMENT_STATUS_NONE) { |
|
518 | + if ($this->payment_status != PAYMENT_STATUS_NONE) { |
|
519 | 519 | sn_db_transaction_rollback(); |
520 | 520 | sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id); |
521 | 521 | die(); |
@@ -525,89 +525,89 @@ discard block |
||
525 | 525 | // Пытаемся получить из запроса ИД аккаунта |
526 | 526 | $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0; |
527 | 527 | // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id |
528 | - if(empty($request_account_id) && !empty($this->payment_account_id)) { |
|
528 | + if (empty($request_account_id) && !empty($this->payment_account_id)) { |
|
529 | 529 | $request_account_id = $this->payment_account_id; |
530 | 530 | } |
531 | 531 | // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать |
532 | - if(empty($request_account_id)) { |
|
532 | + if (empty($request_account_id)) { |
|
533 | 533 | // TODO - аккаунт |
534 | 534 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
535 | 535 | } |
536 | 536 | // Если нет записи в таблице - тогда берем payment_account_id из запроса |
537 | - if(empty($this->payment_account_id)) { |
|
537 | + if (empty($this->payment_account_id)) { |
|
538 | 538 | $this->payment_account_id = $request_account_id; |
539 | 539 | } |
540 | 540 | // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать |
541 | - if($this->payment_account_id != $request_account_id) { |
|
541 | + if ($this->payment_account_id != $request_account_id) { |
|
542 | 542 | // TODO - Поменять сообщение об ошибке |
543 | 543 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
544 | 544 | } |
545 | 545 | // Проверяем существование аккаунта с данным ИД |
546 | - if(!$this->account->db_get_by_id($this->payment_account_id)) { |
|
546 | + if (!$this->account->db_get_by_id($this->payment_account_id)) { |
|
547 | 547 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
548 | 548 | } |
549 | 549 | |
550 | 550 | // TODO Проверка на сервер_ид - как бы и не нужна, наверное? |
551 | - if(!empty($this->payment_params['server_id'])) { |
|
551 | + if (!empty($this->payment_params['server_id'])) { |
|
552 | 552 | $this->request_server_id = sys_get_param_str($this->payment_params['server_id']); |
553 | - if(SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
553 | + if (SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
554 | 554 | throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
558 | 558 | // Сверка количества оплаченной ММ с учётом бонусов |
559 | - if(!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
559 | + if (!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
560 | 560 | $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']); |
561 | - if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
561 | + if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
562 | 562 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID); |
563 | 563 | } |
564 | 564 | empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false; |
565 | 565 | } |
566 | - if(empty($this->payment_dark_matter_paid)) { |
|
566 | + if (empty($this->payment_dark_matter_paid)) { |
|
567 | 567 | // TODO - обратный расчёт из gained |
568 | 568 | } |
569 | 569 | |
570 | 570 | // Проверка наличия внешнего ИД платежа |
571 | - if(!empty($this->payment_params['payment_external_id'])) { |
|
571 | + if (!empty($this->payment_params['payment_external_id'])) { |
|
572 | 572 | $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']); |
573 | - if(empty($request_payment_external_id)) { |
|
573 | + if (empty($request_payment_external_id)) { |
|
574 | 574 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
575 | - } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
575 | + } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
576 | 576 | // TODO - Может быть поменять сообщение |
577 | 577 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
578 | 578 | } |
579 | 579 | $this->payment_external_id = $request_payment_external_id; |
580 | 580 | } |
581 | 581 | // Сверка суммы, запрошенной СН к оплате |
582 | - if(!empty($this->payment_params['payment_external_money'])) { |
|
582 | + if (!empty($this->payment_params['payment_external_money'])) { |
|
583 | 583 | $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']); |
584 | - if($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
584 | + if ($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
585 | 585 | throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
586 | 586 | } |
587 | 587 | empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false; |
588 | 588 | } |
589 | 589 | // Заполняем поле валюты платёжной системы |
590 | - if(!empty($this->payment_params['payment_external_currency'])) { |
|
590 | + if (!empty($this->payment_params['payment_external_currency'])) { |
|
591 | 591 | $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']); |
592 | - if(empty($this->payment_external_currency)) { |
|
592 | + if (empty($this->payment_external_currency)) { |
|
593 | 593 | // TODO - поменять сообщение |
594 | 594 | throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
595 | 595 | } |
596 | 596 | } |
597 | - if(empty($this->payment_external_currency)) { |
|
597 | + if (empty($this->payment_external_currency)) { |
|
598 | 598 | $this->payment_external_currency = $this->config['currency']; |
599 | 599 | } |
600 | 600 | |
601 | 601 | // Заполнение внутренней суммы и валюты из внешних данных |
602 | - if(empty($this->payment_currency)) { |
|
602 | + if (empty($this->payment_currency)) { |
|
603 | 603 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
604 | 604 | } |
605 | - if(empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
605 | + if (empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
606 | 606 | $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency); |
607 | 607 | } |
608 | 608 | |
609 | 609 | // TODO - Тестовый режим |
610 | - if(!empty($this->payment_params['test'])) { |
|
610 | + if (!empty($this->payment_params['test'])) { |
|
611 | 611 | $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']); |
612 | 612 | } |
613 | 613 | |
@@ -634,12 +634,12 @@ discard block |
||
634 | 634 | sn_db_transaction_start(); |
635 | 635 | try { |
636 | 636 | $response = $this->payment_request_process(); |
637 | - } catch(Exception $e) { |
|
637 | + } catch (Exception $e) { |
|
638 | 638 | $response['result'] = $e->getCode(); |
639 | 639 | $response['message'] = $e->getMessage(); |
640 | 640 | } |
641 | 641 | |
642 | - if($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
642 | + if ($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
643 | 643 | sn_db_transaction_commit(); |
644 | 644 | classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT); |
645 | 645 | } else { |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | } |
649 | 649 | |
650 | 650 | // Переводим код результата из СН в код платежной системы |
651 | - if(is_array($this->result_translations) && !empty($this->result_translations)) { |
|
651 | + if (is_array($this->result_translations) && !empty($this->result_translations)) { |
|
652 | 652 | $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR]; |
653 | 653 | } |
654 | 654 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | $currency_from = strtolower($currency_from); |
672 | 672 | $currency_to = strtolower($currency_to); |
673 | 673 | |
674 | - if($currency_from != $currency_to) { |
|
674 | + if ($currency_from != $currency_to) { |
|
675 | 675 | $exchange_from = get_exchange_rate($currency_from); |
676 | 676 | $exchange_to = get_exchange_rate($currency_to); |
677 | 677 | |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) { |
696 | 696 | $bonus = 0; |
697 | 697 | $dark_matter_new = $dark_matter; |
698 | - if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
699 | - if($direct) { |
|
700 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
701 | - if($dm_for_bonus <= $dark_matter) { |
|
698 | + if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
699 | + if ($direct) { |
|
700 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
701 | + if ($dm_for_bonus <= $dark_matter) { |
|
702 | 702 | $dark_matter_new = $dark_matter * (1 + $multiplier); |
703 | 703 | $bonus = $multiplier; |
704 | 704 | } else { |
@@ -706,9 +706,9 @@ discard block |
||
706 | 706 | } |
707 | 707 | } |
708 | 708 | } else { |
709 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
709 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
710 | 710 | $temp = $dm_for_bonus * (1 + $multiplier); |
711 | - if($dark_matter >= $temp) { |
|
711 | + if ($dark_matter >= $temp) { |
|
712 | 712 | $dark_matter_new = round($dark_matter / (1 + $multiplier)); |
713 | 713 | $bonus = $multiplier; |
714 | 714 | } else { |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | 'payment_external_lots' => $this->payment_dark_matter_paid / get_mm_cost(), |
762 | 762 | ); |
763 | 763 | |
764 | - if($this->payment_id) { |
|
764 | + if ($this->payment_id) { |
|
765 | 765 | $payment['payment_id'] = $this->payment_id; |
766 | 766 | classSupernova::$gc->db->doReplaceSet('payment', $payment); |
767 | 767 | } else { |
@@ -773,12 +773,12 @@ discard block |
||
773 | 773 | |
774 | 774 | |
775 | 775 | public function payment_adjust_mm_new() { |
776 | - if(!$this->payment_test) { |
|
776 | + if (!$this->payment_test) { |
|
777 | 777 | // Not a test payment. Adding DM to account |
778 | 778 | $this->account = new Account($this->db); |
779 | 779 | $this->account->db_get_by_id($this->payment_account_id); |
780 | 780 | $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment); |
781 | - if(!$result) { |
|
781 | + if (!$result) { |
|
782 | 782 | throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
783 | 783 | } |
784 | 784 | } |
@@ -787,25 +787,25 @@ discard block |
||
787 | 787 | public function payment_cancel(&$payment) { |
788 | 788 | die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}'); |
789 | 789 | |
790 | - if(!isset($payment['payment_status'])) { |
|
790 | + if (!isset($payment['payment_status'])) { |
|
791 | 791 | throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND); |
792 | 792 | } |
793 | 793 | |
794 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
795 | - $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']; |
|
794 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
795 | + $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] . ' ' . $payment['payment_comment']; |
|
796 | 796 | |
797 | - if(!$payment['payment_test']) { |
|
797 | + if (!$payment['payment_test']) { |
|
798 | 798 | $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']); |
799 | - if(!$result) { |
|
799 | + if (!$result) { |
|
800 | 800 | throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
801 | 801 | } |
802 | 802 | } |
803 | 803 | $payment['payment_status'] = PAYMENT_STATUS_CANCELED; |
804 | 804 | db_payment_update($payment['payment_id'], $payment['payment_status'], $comment_unsafe); |
805 | 805 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK); |
806 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
806 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
807 | 807 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK); |
808 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
808 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
809 | 809 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE); |
810 | 810 | } |
811 | 811 | } |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | |
829 | 829 | protected function db_complete_payment() { |
830 | 830 | // TODO - поле payment_processed |
831 | - if($this->payment_status == PAYMENT_STATUS_NONE) { |
|
832 | - if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
831 | + if ($this->payment_status == PAYMENT_STATUS_NONE) { |
|
832 | + if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
833 | 833 | $this->payment_adjust_mm_new(); |
834 | 834 | $this->payment_status = PAYMENT_STATUS_COMPLETE; |
835 | 835 | } else { |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | protected function db_assign_payment($payment = null) { |
877 | 877 | $this->payment_reset(); |
878 | 878 | |
879 | - if(is_array($payment) && isset($payment['payment_id'])) { |
|
879 | + if (is_array($payment) && isset($payment['payment_id'])) { |
|
880 | 880 | $this->payment_id = $payment['payment_id']; |
881 | 881 | $this->payment_status = $payment['payment_status']; |
882 | 882 | $this->payment_date = $payment['payment_date']; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @return $this |
32 | 32 | */ |
33 | 33 | public function literal($value) { |
34 | - $this->literal = (string)$value; |
|
34 | + $this->literal = (string) $value; |
|
35 | 35 | |
36 | 36 | return $this; |
37 | 37 | } |
@@ -119,7 +119,7 @@ |
||
119 | 119 | if ($this->contains($object)) { |
120 | 120 | $this->indexUnset($object); |
121 | 121 | } |
122 | - if($this->indexSet($object, $data)) { |
|
122 | + if ($this->indexSet($object, $data)) { |
|
123 | 123 | // Attaches object only if index sets successfully |
124 | 124 | parent::attach($object, $data); |
125 | 125 | } |