@@ -38,7 +38,7 @@ |
||
38 | 38 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
39 | 39 | $query[] = "`que_planet_id` IS NULL"; |
40 | 40 | } elseif ($planet_id) { |
41 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
41 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
42 | 42 | } |
43 | 43 | if ($que_type) { |
44 | 44 | $query[] = "`que_type` = {$que_type}"; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
204 | 204 | if (@get_magic_quotes_gpc()) { |
205 | 205 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
206 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
206 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
207 | 207 | $value = stripslashes($value); |
208 | 208 | }); |
209 | 209 | } |
@@ -219,43 +219,43 @@ discard block |
||
219 | 219 | $gc = static::$gc; |
220 | 220 | |
221 | 221 | // Default db |
222 | - $gc->db = function ($c) { |
|
222 | + $gc->db = function($c) { |
|
223 | 223 | $db = new db_mysql($c); |
224 | 224 | $db->sn_db_connect(); |
225 | 225 | |
226 | 226 | return $db; |
227 | 227 | }; |
228 | 228 | |
229 | - $gc->debug = function ($c) { |
|
229 | + $gc->debug = function($c) { |
|
230 | 230 | return new debug(); |
231 | 231 | }; |
232 | 232 | |
233 | - $gc->cache = function ($c) { |
|
233 | + $gc->cache = function($c) { |
|
234 | 234 | return new classCache(classSupernova::$cache_prefix); |
235 | 235 | }; |
236 | 236 | |
237 | - $gc->config = function ($c) { |
|
237 | + $gc->config = function($c) { |
|
238 | 238 | return new classConfig(classSupernova::$cache_prefix); |
239 | 239 | }; |
240 | 240 | |
241 | - $gc->localePlayer = function (GlobalContainer $c) { |
|
241 | + $gc->localePlayer = function(GlobalContainer $c) { |
|
242 | 242 | return new classLocale($c->config->server_locale_log_usage); |
243 | 243 | }; |
244 | 244 | |
245 | - $gc->dbRowOperator = function ($c) { |
|
245 | + $gc->dbRowOperator = function($c) { |
|
246 | 246 | return new DbRowDirectOperator($c); |
247 | 247 | }; |
248 | 248 | |
249 | 249 | $gc->buddyClass = 'Buddy\BuddyModel'; |
250 | - $gc->buddy = $gc->factory(function (GlobalContainer $c) { |
|
250 | + $gc->buddy = $gc->factory(function(GlobalContainer $c) { |
|
251 | 251 | return new $c->buddyClass($c); |
252 | 252 | }); |
253 | 253 | |
254 | - $gc->query = $gc->factory(function (GlobalContainer $c) { |
|
254 | + $gc->query = $gc->factory(function(GlobalContainer $c) { |
|
255 | 255 | return new DbQueryConstructor($c->db); |
256 | 256 | }); |
257 | 257 | |
258 | - $gc->unit = $gc->factory(function (GlobalContainer $c) { |
|
258 | + $gc->unit = $gc->factory(function(GlobalContainer $c) { |
|
259 | 259 | return new \V2Unit\V2UnitModel($c); |
260 | 260 | }); |
261 | 261 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | public static function init_3_load_config_file() { |
269 | 269 | $dbsettings = array(); |
270 | 270 | |
271 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
271 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
272 | 272 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
273 | 273 | self::$db_name = $dbsettings['name']; |
274 | 274 | self::$sn_secret_word = $dbsettings['secretword']; |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | $this->container = array(); |
37 | 37 | |
38 | - if(classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
38 | + if (classSupernova::$cache->_MODE != 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,18 +67,18 @@ 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) { |
|
73 | - $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
|
72 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | + $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix.$try_language.'_'.$offset); |
|
74 | 74 | // Записываем результат работы кэша |
75 | 75 | $locale_cache_statistic['queries']++; |
76 | 76 | isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['hits']++ : $locale_cache_statistic['misses']++; |
77 | -!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix . $try_language . '_' . $offset : false; |
|
77 | +!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix.$try_language.'_'.$offset : false; |
|
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) { |
|
98 | - $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
|
97 | + if ($this->cache) { |
|
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,23 +134,23 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | public function usage_stat_load() { |
137 | - $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); // TODO for debug |
|
138 | - if(empty($this->stat_usage)) { |
|
137 | + $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); // TODO for debug |
|
138 | + if (empty($this->stat_usage)) { |
|
139 | 139 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{lng_usage_stat}}`"); |
140 | - while($row = db_fetch($query)) { |
|
141 | - $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
|
140 | + while ($row = db_fetch($query)) { |
|
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 | - foreach($this->stat_usage_new as &$value) { |
|
150 | - foreach($value as &$value2) { |
|
151 | - $value2 = '"' . db_escape($value2) . '"'; |
|
149 | + foreach ($this->stat_usage_new as &$value) { |
|
150 | + foreach ($value as &$value2) { |
|
151 | + $value2 = '"'.db_escape($value2).'"'; |
|
152 | 152 | } |
153 | - $value = '(' . implode(',', $value) .')'; |
|
153 | + $value = '('.implode(',', $value).')'; |
|
154 | 154 | } |
155 | 155 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
156 | 156 | 'lng_usage_stat', |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | |
174 | 174 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
175 | 175 | |
176 | - $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
|
177 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
176 | + $string_id = $this->active.':'.$offset.':'.$file.':'.$trace[1]['line']; |
|
177 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
178 | 178 | $this->stat_usage[$string_id] = empty($value); |
179 | 179 | $this->stat_usage_new[] = array( |
180 | 180 | 'lang_code' => $this->active, |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | 'file' => $file, |
183 | 183 | 'line' => $trace[1]['line'], |
184 | 184 | 'is_empty' => intval(empty($value)), |
185 | - 'locale' => '' . $value, |
|
185 | + 'locale' => ''.$value, |
|
186 | 186 | ); |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | |
191 | 191 | protected function lng_try_filepath($path, $file_path_relative) { |
192 | - $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
|
192 | + $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative; |
|
193 | 193 | return file_exists($file_path) ? $file_path : false; |
194 | 194 | } |
195 | 195 | |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | |
212 | 212 | classSupernova::log_file("locale.include: Loading data from domain '{$filename}'", 1); |
213 | 213 | |
214 | - $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
|
214 | + $cache_file_key = $this->cache_prefix_lang.'__'.$filename; |
|
215 | 215 | |
216 | 216 | // Подключен ли внешний кэш? |
217 | - if($this->cache) { |
|
217 | + if ($this->cache) { |
|
218 | 218 | // Загружен ли уже данный файл? |
219 | 219 | $cache_file_status = $this->cache->__get($cache_file_key); |
220 | - 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); |
|
221 | - if($cache_file_status) { |
|
220 | + 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); |
|
221 | + if ($cache_file_status) { |
|
222 | 222 | // Если да - повторять загрузку нет смысла |
223 | 223 | return null; |
224 | 224 | } |
@@ -232,47 +232,47 @@ discard block |
||
232 | 232 | $this->make_fallback($language); |
233 | 233 | |
234 | 234 | $file_path = ''; |
235 | - foreach($this->fallback as $lang_try) { |
|
236 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
235 | + foreach ($this->fallback as $lang_try) { |
|
236 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
237 | 237 | continue; |
238 | 238 | } |
239 | 239 | |
240 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
240 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
241 | 241 | break; |
242 | 242 | } |
243 | 243 | |
244 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
244 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
245 | 245 | break; |
246 | 246 | } |
247 | 247 | |
248 | 248 | $file_path = ''; |
249 | 249 | } |
250 | 250 | |
251 | - if($file_path) { |
|
251 | + if ($file_path) { |
|
252 | 252 | $a_lang_array = array(); |
253 | 253 | include($file_path); |
254 | 254 | |
255 | - if(!empty($a_lang_array)) { |
|
255 | + if (!empty($a_lang_array)) { |
|
256 | 256 | $this->merge($a_lang_array); |
257 | 257 | |
258 | 258 | // Загрузка данных из файла в кэш |
259 | - if($this->cache) { |
|
259 | + if ($this->cache) { |
|
260 | 260 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
261 | - foreach($a_lang_array as $key => $value) { |
|
262 | - $value_cache_key = $this->cache_prefix_lang . $key; |
|
263 | - if($this->cache->__isset($value_cache_key)) { |
|
264 | - if(is_array($value)) { |
|
261 | + foreach ($a_lang_array as $key => $value) { |
|
262 | + $value_cache_key = $this->cache_prefix_lang.$key; |
|
263 | + if ($this->cache->__isset($value_cache_key)) { |
|
264 | + if (is_array($value)) { |
|
265 | 265 | $alt_value = $this->cache->__get($value_cache_key); |
266 | 266 | $value = array_replace_recursive($alt_value, $value); |
267 | 267 | // pdump($alt_value, $alt_value); |
268 | 268 | } |
269 | 269 | } |
270 | - $this->cache->__set($this->cache_prefix_lang . $key, $value); |
|
270 | + $this->cache->__set($this->cache_prefix_lang.$key, $value); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | - if($this->cache) { |
|
275 | + if ($this->cache) { |
|
276 | 276 | $this->cache->__set($cache_file_key, true); |
277 | 277 | } |
278 | 278 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | public function lng_load_i18n($i18n) { |
288 | - if(!isset($i18n)) { |
|
288 | + if (!isset($i18n)) { |
|
289 | 289 | return; |
290 | 290 | } |
291 | 291 | |
292 | - foreach($i18n as $i18n_data) { |
|
293 | - if(is_string($i18n_data)) { |
|
292 | + foreach ($i18n as $i18n_data) { |
|
293 | + if (is_string($i18n_data)) { |
|
294 | 294 | $this->lng_include($i18n_data); |
295 | - } elseif(is_array($i18n_data)) { |
|
295 | + } elseif (is_array($i18n_data)) { |
|
296 | 296 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
297 | 297 | } |
298 | 298 | } |
@@ -310,27 +310,27 @@ discard block |
||
310 | 310 | |
311 | 311 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
312 | 312 | |
313 | - if($language_new == $this->active) { |
|
313 | + if ($language_new == $this->active) { |
|
314 | 314 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
318 | 318 | $this->active = $language = $language_new; |
319 | - $this->cache_prefix_lang = $this->cache_prefix . $this->active . '_'; |
|
319 | + $this->cache_prefix_lang = $this->cache_prefix.$this->active.'_'; |
|
320 | 320 | |
321 | 321 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
322 | 322 | $this->make_fallback($this->active); |
323 | 323 | |
324 | - if($this->cache) { |
|
325 | - $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
|
326 | - 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); |
|
327 | - if($cache_lang_init_status) { |
|
324 | + if ($this->cache) { |
|
325 | + $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang.'__INIT'); |
|
326 | + 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); |
|
327 | + if ($cache_lang_init_status) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | 331 | // Чистим текущие локализации из кэша. Достаточно почистить только флаги инициализации языкового кэша и загрузки файлов - они начинаются с '__' |
332 | 332 | classSupernova::log_file("locale.switch: Cache - invalidating data"); |
333 | - $this->cache->unset_by_prefix($this->cache_prefix_lang . '__'); |
|
333 | + $this->cache->unset_by_prefix($this->cache_prefix_lang.'__'); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $this->lng_include('system'); |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | // Loading global language files |
341 | 341 | $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']); |
342 | 342 | |
343 | - if($this->cache) { |
|
344 | - classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
|
345 | - $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
|
343 | + if ($this->cache) { |
|
344 | + classSupernova::log_file("locale.switch: Cache - setting flag ".$this->cache_prefix_lang.'__INIT'); |
|
345 | + $this->cache->__set($this->cache_prefix_lang.'__INIT', true); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | classSupernova::log_file("locale.switch: Complete - EXIT"); |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | |
353 | 353 | |
354 | 354 | public function lng_get_info($entry) { |
355 | - $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
|
355 | + $file_name = SN_ROOT_PHYSICAL.'language/'.$entry.'/language.mo.php'; |
|
356 | 356 | $lang_info = array(); |
357 | - if(file_exists($file_name)) { |
|
357 | + if (file_exists($file_name)) { |
|
358 | 358 | include($file_name); |
359 | 359 | } |
360 | 360 | |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | public function lng_get_list() { |
365 | - if(empty($this->lang_list)) { |
|
365 | + if (empty($this->lang_list)) { |
|
366 | 366 | $this->lang_list = array(); |
367 | 367 | |
368 | - $path = SN_ROOT_PHYSICAL . 'language/'; |
|
368 | + $path = SN_ROOT_PHYSICAL.'language/'; |
|
369 | 369 | $dir = dir($path); |
370 | - while(false !== ($entry = $dir->read())) { |
|
371 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
370 | + while (false !== ($entry = $dir->read())) { |
|
371 | + if (is_dir($path.$entry) && $entry[0] != '.') { |
|
372 | 372 | $lang_info = $this->lng_get_info($entry); |
373 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
373 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
374 | 374 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
375 | 375 | } |
376 | 376 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | define('INSTALL', false); |
13 | 13 | define('IN_ADMIN', true); |
14 | 14 | |
15 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
15 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
16 | 16 | |
17 | -if($user['authlevel'] < 3) { |
|
17 | +if ($user['authlevel'] < 3) { |
|
18 | 18 | AdminMessage(classLocale::$lang['adm_err_denied']); |
19 | 19 | } |
20 | 20 | |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | ), |
29 | 29 | ); |
30 | 30 | $template->assign_block_vars('int_type_selected', $allowed_types[-1]); |
31 | -foreach(DBStaticMessages::$snMessageClassList as $key => $value) { |
|
32 | - if($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) { |
|
31 | +foreach (DBStaticMessages::$snMessageClassList as $key => $value) { |
|
32 | + if ($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) { |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
@@ -41,21 +41,21 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | $deletedMessages = ''; |
44 | -if($idMessageDelete = sys_get_param_id('msg_del')) { |
|
44 | +if ($idMessageDelete = sys_get_param_id('msg_del')) { |
|
45 | 45 | DBStaticMessages::db_message_delete_by_id($idMessageDelete); |
46 | 46 | $deletedMessages = $idMessageDelete; |
47 | -} elseif(sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) { |
|
47 | +} elseif (sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) { |
|
48 | 48 | $message_delete = implode(', ', $message_delete); |
49 | 49 | DBStaticMessages::db_message_list_delete_set($message_delete); |
50 | 50 | $deletedMessages = $message_delete; |
51 | 51 | } |
52 | 52 | |
53 | -if($deletedMessages) { |
|
53 | +if ($deletedMessages) { |
|
54 | 54 | $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['mlst_messages_deleted'], $deletedMessages))); |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | -if(sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) { |
|
58 | +if (sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) { |
|
59 | 59 | $delete_date = "{$year}-{$month}-{$day}"; |
60 | 60 | DBStaticMessages::db_message_list_delete_by_date($delete_date, $int_type_selected); |
61 | 61 | $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['mlst_messages_deleted_date'], $allowed_types[$int_type_selected]['TEXT'], $delete_date))); |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | |
68 | 68 | $int_page_current = min(sys_get_param_id('int_page_current', 1), $page_max); |
69 | 69 | |
70 | -if(sys_get_param('page_prev') && $int_page_current > 1) { |
|
70 | +if (sys_get_param('page_prev') && $int_page_current > 1) { |
|
71 | 71 | $int_page_current--; |
72 | -} elseif(sys_get_param('page_next') && $int_page_current < $page_max) { |
|
72 | +} elseif (sys_get_param('page_next') && $int_page_current < $page_max) { |
|
73 | 73 | $int_page_current++; |
74 | 74 | } |
75 | 75 | |
76 | -for($i = 1; $i <= $page_max; $i++) { |
|
76 | +for ($i = 1; $i <= $page_max; $i++) { |
|
77 | 77 | $template->assign_block_vars('page', array('NUMBER' => $i)); |
78 | 78 | } |
79 | 79 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $StartRec = ($int_page_current - 1) * 25; |
82 | 82 | |
83 | 83 | $Messages = DBStaticMessages::db_message_list_admin_by_type($int_type_selected, $StartRec); |
84 | -while($row = db_fetch($Messages)) { |
|
84 | +while ($row = db_fetch($Messages)) { |
|
85 | 85 | $row['FROM'] = htmlentities($row['FROM'], ENT_COMPAT, 'UTF-8'); |
86 | 86 | $row['OWNER_NAME'] = htmlentities($row['OWNER_NAME'], ENT_COMPAT, 'UTF-8'); |
87 | 87 | $row['TEXT'] = nl2br($row['TEXT']); |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | // Инфа об устройстве и браузере - общая для всех |
88 | 88 | sn_db_transaction_start(); |
89 | 89 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
90 | - if($this->device_cypher) { |
|
90 | + if ($this->device_cypher) { |
|
91 | 91 | $cypher_safe = db_escape($this->device_cypher); |
92 | 92 | $device_id = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE"); |
93 | - if(!empty($device_id['device_id'])) { |
|
93 | + if (!empty($device_id['device_id'])) { |
|
94 | 94 | $this->device_id = $device_id['device_id']; |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - if($this->device_id <= 0) { |
|
98 | + if ($this->device_id <= 0) { |
|
99 | 99 | do { |
100 | 100 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
101 | 101 | $row = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE"); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string'); |
119 | 119 | sn_db_transaction_commit(); |
120 | 120 | |
121 | - if($this->write_full_url) { |
|
121 | + if ($this->write_full_url) { |
|
122 | 122 | sn_db_transaction_start(); |
123 | 123 | $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE)); |
124 | - if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
124 | + if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
125 | 125 | $this->page_url = '/simulator.php'; |
126 | 126 | } |
127 | 127 | $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function db_security_entry_insert($user_id_unsafe) { |
146 | 146 | // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL'; |
147 | - if(empty($user_id_unsafe)) { |
|
147 | + if (empty($user_id_unsafe)) { |
|
148 | 148 | // self::flog('Нет ИД пользователя'); |
149 | 149 | return true; |
150 | 150 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function db_counter_insert($user_id_unsafe) { |
167 | 167 | global $sys_stop_log_hit; |
168 | 168 | |
169 | - if($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
169 | + if ($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | ->setIdField($entity->getIdFieldName()) |
19 | 19 | ->field('*') |
20 | 20 | ->from($entity->getTableName()) |
21 | - ->where($entity->getIdFieldName() . ' = "' . $entity->dbId . '"'); |
|
21 | + ->where($entity->getIdFieldName().' = "'.$entity->dbId.'"'); |
|
22 | 22 | |
23 | 23 | return $stmt->selectRow(); |
24 | 24 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce |
44 | 44 | LEFT JOIN {{users}} AS u ON u.id = a.user_id |
45 | 45 | {$query_where} |
46 | - ORDER BY `tsTimeStamp` DESC, idAnnounce" . |
|
46 | + ORDER BY `tsTimeStamp` DESC, idAnnounce". |
|
47 | 47 | ($query_limit ? " LIMIT {$query_limit}" : '')); |
48 | 48 | |
49 | 49 | $template->assign_var('NEWS_COUNT', classSupernova::$db->db_num_rows($announce_list)); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function debris_add_resource($resource_id, $resource_amount) { |
29 | 29 | // В обломках может быть только металл или кристалл |
30 | - if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
30 | + if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | $this->debris[$resource_id] += $resource_amount; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param bool $is_simulator |
39 | 39 | */ |
40 | 40 | public function add_wrecks(array $wreckage, $is_simulator) { |
41 | - foreach($wreckage as $resource_id => $resource_amount) { |
|
41 | + foreach ($wreckage as $resource_id => $resource_amount) { |
|
42 | 42 | $this->debris_add_resource($resource_id, floor($resource_amount * |
43 | 43 | ($is_simulator |
44 | 44 | ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param bool $is_simulator |
55 | 55 | */ |
56 | 56 | public function add_cargo_drop(array $dropped_resources, $is_simulator) { |
57 | - foreach($dropped_resources as $resource_id => $resource_amount) { |
|
57 | + foreach ($dropped_resources as $resource_id => $resource_amount) { |
|
58 | 58 | $this->debris_add_resource($resource_id, floor($resource_amount * |
59 | 59 | ($is_simulator |
60 | 60 | ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param $moon_debris_left_part |
94 | 94 | */ |
95 | 95 | public function debris_adjust_proportional($moon_debris_left_part) { |
96 | - foreach($this->debris as $resource_id => &$resource_amount) { |
|
96 | + foreach ($this->debris as $resource_id => &$resource_amount) { |
|
97 | 97 | $resource_amount = floor($resource_amount * $moon_debris_left_part); |
98 | 98 | } |
99 | 99 | } |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function report_generate_array() { |
116 | 116 | return array( |
117 | - 'ube_report_debris_metal' => (float)$this->debris_get_resource(RES_METAL), |
|
118 | - 'ube_report_debris_crystal' => (float)$this->debris_get_resource(RES_CRYSTAL), |
|
119 | - 'ube_report_debris_total_in_metal' => (float)$this->debris_in_metal(), |
|
117 | + 'ube_report_debris_metal' => (float) $this->debris_get_resource(RES_METAL), |
|
118 | + 'ube_report_debris_crystal' => (float) $this->debris_get_resource(RES_CRYSTAL), |
|
119 | + 'ube_report_debris_total_in_metal' => (float) $this->debris_in_metal(), |
|
120 | 120 | ); |
121 | 121 | } |
122 | 122 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $debris_for_moon = $debris->debris_total(); |
72 | 72 | |
73 | - if(!$debris_for_moon) { |
|
73 | + if (!$debris_for_moon) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure |
79 | 79 | $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0; |
80 | 80 | $this->create_chance = $moon_chance; |
81 | - if($moon_chance) { |
|
82 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
81 | + if ($moon_chance) { |
|
82 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
83 | 83 | $this->status = UBE_MOON_CREATE_SUCCESS; |
84 | 84 | $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
85 | 85 | |
86 | - if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
86 | + if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
87 | 87 | $debris->_reset(); |
88 | 88 | } else { |
89 | 89 | $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function moon_destroy_try($reapers) { |
104 | 104 | // TODO: $is_simulator |
105 | - if($reapers <= 0) { |
|
105 | + if ($reapers <= 0) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @version 2016-02-25 23:42:45 41a4.68 |
121 | 121 | */ |
122 | 122 | public function calculate_moon(UBE $ube) { |
123 | - if(UBE_MOON_EXISTS == $this->status) { |
|
124 | - if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
123 | + if (UBE_MOON_EXISTS == $this->status) { |
|
124 | + if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
125 | 125 | $reapers = $ube->fleet_list->ube_calculate_attack_reapers(); |
126 | 126 | $this->moon_destroy_try($reapers); |
127 | 127 | } |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function report_generate_array() { |
137 | 137 | return array( |
138 | - 'ube_report_moon' => (int)$this->status, |
|
139 | - 'ube_report_moon_chance' => (int)$this->create_chance, |
|
140 | - 'ube_report_moon_size' => (float)$this->moon_diameter, |
|
141 | - 'ube_report_moon_reapers' => (int)$this->reapers_status, |
|
142 | - 'ube_report_moon_destroy_chance' => (int)$this->destroy_chance, |
|
143 | - 'ube_report_moon_reapers_die_chance' => (int)$this->reaper_die_chance, |
|
138 | + 'ube_report_moon' => (int) $this->status, |
|
139 | + 'ube_report_moon_chance' => (int) $this->create_chance, |
|
140 | + 'ube_report_moon_size' => (float) $this->moon_diameter, |
|
141 | + 'ube_report_moon_reapers' => (int) $this->reapers_status, |
|
142 | + 'ube_report_moon_destroy_chance' => (int) $this->destroy_chance, |
|
143 | + 'ube_report_moon_reapers_die_chance' => (int) $this->reaper_die_chance, |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @param $planet_id |
172 | 172 | */ |
173 | 173 | public function db_apply_result($planet_info, $destination_user_id) { |
174 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
174 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
175 | 175 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
176 | 176 | $this->moon_name = $moon_row['name']; |
177 | 177 | unset($moon_row); |
178 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
178 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
179 | 179 | DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]); |
180 | 180 | } |
181 | 181 | } |
@@ -184,18 +184,18 @@ discard block |
||
184 | 184 | $classLocale = classLocale::$lang; |
185 | 185 | |
186 | 186 | $text_defender = ''; |
187 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
187 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
188 | 188 | $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />"; |
189 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
189 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
190 | 190 | $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
191 | 191 | } |
192 | 192 | |
193 | - if($ube->mission_type_id == MT_DESTROY) { |
|
194 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
193 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
194 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
195 | 195 | $text_defender .= classLocale::$lang['ube_report_moon_reapers_none']; |
196 | 196 | } else { |
197 | 197 | $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
198 | - $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />"; |
|
198 | + $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />"; |
|
199 | 199 | |
200 | 200 | $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. "; |
201 | 201 | $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died']; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @version 2016-02-25 23:42:45 41a4.68 |
221 | 221 | */ |
222 | 222 | public function ubeInitLoadStatis($destination_planet) { |
223 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
223 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
224 | 224 | $this->status = UBE_MOON_EXISTS; |
225 | 225 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
226 | 226 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |