@@ -1,5 +1,4 @@ |
||
1 | 1 | <?php |
2 | -use DBStatic\DBStaticUser; |
|
3 | 2 | |
4 | 3 | /** |
5 | 4 | * |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
191 | 191 | |
192 | 192 | // Alliance bonus calculations |
193 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
193 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
194 | 194 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
195 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
195 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
196 | 196 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
197 | 197 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
198 | 198 | |
@@ -223,25 +223,25 @@ discard block |
||
223 | 223 | 'deuterium_basic_income' => 0, |
224 | 224 | 'eco_scale_storage' => 1, |
225 | 225 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
226 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
226 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
227 | 227 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
228 | 228 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
229 | 229 | 'energy_basic_income' => 0, |
230 | 230 | |
231 | 231 | // Bashing protection settings |
232 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
233 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
234 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
235 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
236 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
232 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
233 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
234 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
235 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
236 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
237 | 237 | |
238 | 238 | 'Fleet_Cdr' => 30, |
239 | 239 | 'fleet_speed' => 1, |
240 | 240 | |
241 | 241 | 'fleet_update_interval' => 4, |
242 | 242 | |
243 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
244 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
243 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
244 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
245 | 245 | // Defaults |
246 | 246 | 'game_default_language' => 'ru', |
247 | 247 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | 'game_maxSystem' => 199, |
256 | 256 | 'game_maxPlanet' => 15, |
257 | 257 | // Game global settings |
258 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
258 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
259 | 259 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
260 | 260 | |
261 | 261 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
262 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
262 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
263 | 263 | // Noob protection |
264 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
264 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
265 | 265 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
266 | 266 | |
267 | 267 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | 'payment_currency_exchange_wmu' => 30, |
312 | 312 | 'payment_currency_exchange_wmz' => 1, |
313 | 313 | |
314 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
315 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
314 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
315 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
316 | 316 | |
317 | 317 | 'planet_teleport_cost' => 50000, // |
318 | 318 | 'planet_teleport_timeout' => 86400, // |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | 'resource_multiplier' => 1, |
331 | 331 | |
332 | 332 | //Roleplay system |
333 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
333 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
334 | 334 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
335 | 335 | |
336 | 336 | // Black Market - General |
@@ -173,6 +173,9 @@ |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | + /** |
|
177 | + * @param string $path |
|
178 | + */ |
|
176 | 179 | protected function lng_try_filepath($path, $file_path_relative) { |
177 | 180 | $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
178 | 181 | return file_exists($file_path) ? $file_path : false; |
@@ -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,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(); |
|
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)) { |
|
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 | } |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | use Vector\Vector; |
4 | - |
|
5 | 4 | use Common\GlobalContainer; |
6 | 5 | |
7 | 6 | class classSupernova { |
@@ -112,7 +112,7 @@ |
||
112 | 112 | public static function init_3_load_config_file() { |
113 | 113 | $dbsettings = array(); |
114 | 114 | |
115 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
115 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
116 | 116 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
117 | 117 | self::$db_name = $dbsettings['name']; |
118 | 118 | self::$sn_secret_word = $dbsettings['secretword']; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param int $sigma |
19 | 19 | * @param bool $strict |
20 | 20 | * |
21 | - * @return int |
|
21 | + * @return double |
|
22 | 22 | */ |
23 | 23 | public static function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) { |
24 | 24 | // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param float $range_start - Начало диапазона |
44 | 44 | * @param float $range_end - Конец диапазона |
45 | - * @param bool|int $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
45 | + * @param boolean $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
46 | 46 | * @param int $strict - В сколько сигм надо уложить результат |
47 | 47 | * @param bool|false $cut_extreme - надо ли обрезать крайние значения. Например, при $strict = 2 их слишком много |
48 | 48 | * |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | } |
131 | 131 | if ($logProcess) { |
132 | - pdump($linear, 'Нормализовано по х' . $from); |
|
132 | + pdump($linear, 'Нормализовано по х'.$from); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | for ($i = $from + 1; $i < count($linear); $i++) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | } |
141 | 141 | if ($logProcess) { |
142 | - pdump($linear, 'Подставили х' . $from); |
|
142 | + pdump($linear, 'Подставили х'.$from); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | if ($from < count($linear) - 1) { |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | if ($logProcess) { |
157 | - pdump($linear, 'Подставили обратно х' . $from); |
|
157 | + pdump($linear, 'Подставили обратно х'.$from); |
|
158 | 158 | } |
159 | 159 | } else { |
160 | 160 | if ($logProcess) { |
161 | - pdump($linear, 'Результат' . $from); |
|
161 | + pdump($linear, 'Результат'.$from); |
|
162 | 162 | } |
163 | 163 | foreach ($linear as $index => &$eq) { |
164 | - pdump($eq[count($linear)], 'x' . $index); |
|
164 | + pdump($eq[count($linear)], 'x'.$index); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -18,6 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
20 | 20 | // TODO - OK 4.6 |
21 | + |
|
22 | + /** |
|
23 | + * @param integer $confirmation_type_safe |
|
24 | + * @param string $email_unsafe |
|
25 | + */ |
|
21 | 26 | public function db_confirmation_get_latest_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
22 | 27 | $email_safe = $this->db->db_escape($email_unsafe); |
23 | 28 | |
@@ -26,12 +31,21 @@ discard block |
||
26 | 31 | `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}' ORDER BY create_time DESC LIMIT 1;", true); |
27 | 32 | } |
28 | 33 | // TODO - OK 4.6 |
34 | + |
|
35 | + /** |
|
36 | + * @param integer $confirmation_type_safe |
|
37 | + */ |
|
29 | 38 | public function db_confirmation_delete_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
30 | 39 | $email_safe = $this->db->db_escape($email_unsafe); |
31 | 40 | |
32 | 41 | return $this->db->doquery("DELETE FROM {{confirmations}} WHERE `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}'"); |
33 | 42 | } |
34 | 43 | // TODO - OK 4.6 |
44 | + |
|
45 | + /** |
|
46 | + * @param integer $confirmation_type_safe |
|
47 | + * @param string $email_unsafe |
|
48 | + */ |
|
35 | 49 | public function db_confirmation_get_unique_code_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
36 | 50 | $email_safe = $this->db->db_escape($email_unsafe); |
37 | 51 | |
@@ -50,6 +64,11 @@ discard block |
||
50 | 64 | return $confirm_code_unsafe; |
51 | 65 | } |
52 | 66 | // TODO - OK 4.6 |
67 | + |
|
68 | + /** |
|
69 | + * @param integer $confirmation_type_safe |
|
70 | + * @param string $confirmation_code_unsafe |
|
71 | + */ |
|
53 | 72 | public function db_confirmation_get_by_type_and_code($confirmation_type_safe, $confirmation_code_unsafe) { |
54 | 73 | $confirmation_code_safe = $this->db->db_escape($confirmation_code_unsafe); |
55 | 74 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | // $query = static::$db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' AND `type` = {$confirmation_type_safe} FOR UPDATE", true); |
42 | 42 | // Тип не нужен для проверки - код подтверждения должен быть уникален от слова "совсем" |
43 | 43 | $query = $this->db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE", true); |
44 | - } while($query); |
|
44 | + } while ($query); |
|
45 | 45 | |
46 | 46 | $this->db->doquery( |
47 | 47 | "REPLACE INTO {{confirmations}} |
@@ -286,7 +286,6 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * Функция пытается залогиниться по всем известным провайдерам |
288 | 288 | * |
289 | - * @param null $result |
|
290 | 289 | */ |
291 | 290 | public function login() { |
292 | 291 | if(empty(sn_module::$sn_module_list['auth'])) { |
@@ -823,10 +822,17 @@ discard block |
||
823 | 822 | |
824 | 823 | // OK v4.5 |
825 | 824 | // TODO - REMEMBER_ME |
825 | + |
|
826 | + /** |
|
827 | + * @param integer $period |
|
828 | + */ |
|
826 | 829 | protected static function cookie_set($value, $impersonate = false, $period = null) { |
827 | 830 | sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE); |
828 | 831 | } |
829 | 832 | |
833 | + /** |
|
834 | + * @param string $message |
|
835 | + */ |
|
830 | 836 | protected static function flog($message, $die = false) { |
831 | 837 | if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
832 | 838 | return; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | // Проверить наличие такого имени в истории имён |
223 | 223 | do { |
224 | 224 | sn_db_transaction_rollback(); |
225 | - $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
225 | + $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
226 | 226 | sn_db_transaction_start(); |
227 | 227 | } while (db_player_name_exists($this->player_suggested_name)); |
228 | 228 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | if ($player_name_submitted) { |
232 | 232 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
233 | 233 | if ($this->register_status == LOGIN_SUCCESS) { |
234 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
|
234 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); |
|
235 | 235 | } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
236 | 236 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
237 | 237 | } |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | ); |
258 | 258 | |
259 | 259 | if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
260 | - $prohibited_characters = array_map(function ($value) { |
|
261 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
|
260 | + $prohibited_characters = array_map(function($value) { |
|
261 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; |
|
262 | 262 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
263 | 263 | $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters); |
264 | 264 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | foreach ($this->providers as $provider_id => $provider) { |
307 | 307 | $login_status = $provider->login(); // OK v4.5 |
308 | - self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
308 | + self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
309 | 309 | if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
310 | 310 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
311 | 311 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | if (!$this->is_player_register) { |
346 | 346 | // Нет - отправляем на процесс регистрации |
347 | 347 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
348 | - sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
|
348 | + sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : '')); |
|
349 | 349 | } |
350 | 350 | } else { |
351 | 351 | // Да, есть доступные игроки, которые так же прописаны в базе |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | if ($redirect === true) { |
408 | - sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
408 | + sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
409 | 409 | } elseif ($redirect !== false) { |
410 | 410 | sys_redirect($redirect); |
411 | 411 | } |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | */ |
802 | 802 | // OK v4 |
803 | 803 | public static function password_encode($password, $salt) { |
804 | - return md5($password . $salt); |
|
804 | + return md5($password.$salt); |
|
805 | 805 | } |
806 | 806 | /** |
807 | 807 | * Генерирует соль |
@@ -827,10 +827,10 @@ discard block |
||
827 | 827 | } |
828 | 828 | list($called, $caller) = debug_backtrace(false); |
829 | 829 | $caller_name = |
830 | - (!empty($caller['class']) ? $caller['class'] : '') . |
|
831 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
832 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
833 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
830 | + (!empty($caller['class']) ? $caller['class'] : ''). |
|
831 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
832 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
833 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
834 | 834 | |
835 | 835 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
836 | 836 | |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | if ($die) { |
839 | 839 | // pdump($caller); |
840 | 840 | // pdump(debug_backtrace(false)); |
841 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
841 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
842 | 842 | } |
843 | 843 | } |
844 | 844 |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | /** |
158 | 158 | * @param string $query |
159 | 159 | * |
160 | - * @return mixed|string |
|
160 | + * @return string |
|
161 | 161 | */ |
162 | 162 | public function replaceTablePlaceholders($query) { |
163 | 163 | $sql = $query; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | - * @param $query |
|
174 | + * @param string $query |
|
175 | 175 | */ |
176 | 176 | protected function logQuery($query) { |
177 | 177 | if (!classSupernova::$config->debug) { |
@@ -286,6 +286,7 @@ discard block |
||
286 | 286 | * @param array $fields |
287 | 287 | * @param array $where |
288 | 288 | * @param bool $isOneRecord |
289 | + * @param boolean $forUpdate |
|
289 | 290 | * |
290 | 291 | * @return array|bool|mysqli_result|null |
291 | 292 | */ |
@@ -331,6 +332,11 @@ discard block |
||
331 | 332 | |
332 | 333 | |
333 | 334 | // INSERT/REPLACE |
335 | + |
|
336 | + /** |
|
337 | + * @param string $table |
|
338 | + * @param integer $replace |
|
339 | + */ |
|
334 | 340 | protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) { |
335 | 341 | $query = DbQuery::build($this) |
336 | 342 | ->setTable($table) |
@@ -368,6 +374,10 @@ discard block |
||
368 | 374 | |
369 | 375 | |
370 | 376 | // INSERTERS |
377 | + |
|
378 | + /** |
|
379 | + * @param string $query |
|
380 | + */ |
|
371 | 381 | public function doInsertComplex($query) { |
372 | 382 | return $this->doSql($query); |
373 | 383 | } |
@@ -387,7 +397,7 @@ discard block |
||
387 | 397 | * Values should be passed as-is |
388 | 398 | * |
389 | 399 | * @param string $table |
390 | - * @param array $fields |
|
400 | + * @param string[] $fields |
|
391 | 401 | * @param string[] $values |
392 | 402 | * |
393 | 403 | * @return array|bool|mysqli_result|null |
@@ -440,7 +450,7 @@ discard block |
||
440 | 450 | * Self-contained - means no params used |
441 | 451 | * Such queries usually used to make large amount of in-base calculations |
442 | 452 | * |
443 | - * @param $query |
|
453 | + * @param string $query |
|
444 | 454 | * |
445 | 455 | * @return array|bool|mysqli_result|null |
446 | 456 | */ |
@@ -457,13 +467,16 @@ discard block |
||
457 | 467 | } |
458 | 468 | |
459 | 469 | /** |
460 | - * @param $DbQuery DbQuery |
|
470 | + * @param DbQuery $DbQuery DbQuery |
|
461 | 471 | */ |
462 | 472 | public function doUpdateDbQueryAdjust($DbQuery) { |
463 | 473 | return $this->doUpdateDbQuery($DbQuery); |
464 | 474 | } |
465 | 475 | |
466 | 476 | |
477 | + /** |
|
478 | + * @param boolean $isOneRecord |
|
479 | + */ |
|
467 | 480 | protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL, $whereDanger = array()) { |
468 | 481 | $query = DbQuery::build($this) |
469 | 482 | ->setTable($table) |
@@ -482,6 +495,9 @@ discard block |
||
482 | 495 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE); |
483 | 496 | } |
484 | 497 | |
498 | + /** |
|
499 | + * @param string $table |
|
500 | + */ |
|
485 | 501 | public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) { |
486 | 502 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL); |
487 | 503 | } |
@@ -597,6 +613,10 @@ discard block |
||
597 | 613 | } |
598 | 614 | |
599 | 615 | // TODO Заменить это на новый логгер |
616 | + |
|
617 | + /** |
|
618 | + * @param string $query |
|
619 | + */ |
|
600 | 620 | protected function security_watch_user_queries($query) { |
601 | 621 | global $user; |
602 | 622 | |
@@ -620,6 +640,9 @@ discard block |
||
620 | 640 | } |
621 | 641 | |
622 | 642 | |
643 | + /** |
|
644 | + * @param string $query |
|
645 | + */ |
|
623 | 646 | public function security_query_check_bad_words($query) { |
624 | 647 | if ($this->skipQueryCheck) { |
625 | 648 | return; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | public function load_db_settings($configFile = '') { |
92 | 92 | $dbsettings = array(); |
93 | 93 | |
94 | - empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false; |
|
94 | + empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false; |
|
95 | 95 | |
96 | 96 | require $configFile; |
97 | 97 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | if (empty($this->dbsettings)) { |
114 | - $this->load_db_settings(SN_ROOT_PHYSICAL . "config.php"); |
|
114 | + $this->load_db_settings(SN_ROOT_PHYSICAL."config.php"); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $sql = $query; |
164 | 164 | if (strpos($sql, '{{') !== false) { |
165 | 165 | foreach ($this->table_list as $tableName) { |
166 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
166 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | |
235 | 235 | $queryResult = null; |
236 | 236 | try { |
237 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
237 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
238 | 238 | if (!$queryResult) { |
239 | 239 | throw new Exception(); |
240 | 240 | } |
241 | 241 | } catch (Exception $e) { |
242 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
242 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | return $queryResult; |
@@ -294,16 +294,16 @@ discard block |
||
294 | 294 | if (!empty($where)) { |
295 | 295 | foreach ($where as $key => &$value) { |
296 | 296 | if (!is_int($key)) { |
297 | - $value = "`$key` = '" . $this->db_escape($value) . "'"; |
|
297 | + $value = "`$key` = '".$this->db_escape($value)."'"; |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | 302 | $query = |
303 | - "SELECT " . implode(',', $fields) . |
|
304 | - " FROM `{{{$table}}}`" . |
|
305 | - (!empty($where) ? ' WHERE ' . implode(' AND ', $where) : '') . |
|
306 | - ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : '') . |
|
303 | + "SELECT ".implode(',', $fields). |
|
304 | + " FROM `{{{$table}}}`". |
|
305 | + (!empty($where) ? ' WHERE '.implode(' AND ', $where) : ''). |
|
306 | + ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : ''). |
|
307 | 307 | ($forUpdate == DB_SELECT_FOR_UPDATE ? ' FOR UPDATE' : ''); |
308 | 308 | |
309 | 309 | return $this->doSql($query); |
@@ -609,10 +609,10 @@ discard block |
||
609 | 609 | $this->isWatching = true; |
610 | 610 | $msg = "\$query = \"{$query}\"\n\r"; |
611 | 611 | if (!empty($_POST)) { |
612 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
612 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
613 | 613 | } |
614 | 614 | if (!empty($_GET)) { |
615 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
615 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
616 | 616 | } |
617 | 617 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
618 | 618 | $this->isWatching = false; |
@@ -638,37 +638,37 @@ discard block |
||
638 | 638 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
639 | 639 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
640 | 640 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
641 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
641 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
642 | 642 | $report .= ">Database Inforamation\n"; |
643 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
644 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
645 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
646 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
647 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
648 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
649 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
650 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
651 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
652 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
643 | + $report .= "\tID - ".$user['id']."\n"; |
|
644 | + $report .= "\tUser - ".$user['username']."\n"; |
|
645 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
646 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
647 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
648 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
649 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
650 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
651 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
652 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
653 | 653 | $report .= "\n"; |
654 | 654 | |
655 | 655 | $report .= ">Query Information\n"; |
656 | - $report .= "\tQuery - " . $query . "\n"; |
|
656 | + $report .= "\tQuery - ".$query."\n"; |
|
657 | 657 | $report .= "\n"; |
658 | 658 | |
659 | 659 | $report .= ">\$_SERVER Information\n"; |
660 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
661 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
662 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
663 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
664 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
665 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
666 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
667 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
660 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
661 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
662 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
663 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
664 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
665 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
666 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
667 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
668 | 668 | |
669 | 669 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
670 | 670 | |
671 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
671 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
672 | 672 | fwrite($fp, $report); |
673 | 673 | fclose($fp); |
674 | 674 |
@@ -39,7 +39,7 @@ |
||
39 | 39 | * <p>true - транзакция должна быть запущена - для совместимости с $for_update</p> |
40 | 40 | * <p>false - всё равно - для совместимости с $for_update</p> |
41 | 41 | * |
42 | - * @return bool Текущий статус транзакции |
|
42 | + * @return null|boolean Текущий статус транзакции |
|
43 | 43 | */ |
44 | 44 | public function check($status = null) { |
45 | 45 | $error_msg = false; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | if (!empty($error_msg)) { |
60 | 60 | // TODO - Убрать позже |
61 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
61 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
62 | 62 | $backtrace = debug_backtrace(); |
63 | 63 | array_shift($backtrace); |
64 | 64 | pdump($backtrace); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function start($level = '') { |
72 | 72 | $this->check(null); |
73 | 73 | |
74 | - $level ? $this->db->doSql('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
74 | + $level ? $this->db->doSql('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
75 | 75 | |
76 | 76 | $this->transaction_id++; |
77 | 77 | $this->db->doSql('START TRANSACTION'); |
@@ -444,7 +444,6 @@ discard block |
||
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
447 | - * @param bool $skip_query_check |
|
448 | 447 | * |
449 | 448 | * @return array |
450 | 449 | */ |
@@ -455,7 +454,6 @@ discard block |
||
455 | 454 | } |
456 | 455 | |
457 | 456 | /** |
458 | - * @param bool $skip_query_check |
|
459 | 457 | * |
460 | 458 | * @return mixed|null |
461 | 459 | */ |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | // TODO - rewrite |
229 | 229 | public function getParamsFromStaticClass($className) { |
230 | 230 | if (is_string($className) && $className && class_exists($className)) { |
231 | - if(method_exists($className, 'getDb')) { |
|
231 | + if (method_exists($className, 'getDb')) { |
|
232 | 232 | $this->setDb($className::getDb()); |
233 | 233 | } |
234 | 234 | $this->from($className::$_table); |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | protected function compileFrom() { |
320 | - $this->_compiledQuery[] = 'FROM `{{' . $this->escapeString($this->table) . '}}`'; |
|
320 | + $this->_compiledQuery[] = 'FROM `{{'.$this->escapeString($this->table).'}}`'; |
|
321 | 321 | if (!empty($this->alias)) { |
322 | - $this->_compiledQuery[] = 'AS `' . $this->escapeString($this->alias) . '`'; |
|
322 | + $this->_compiledQuery[] = 'AS `'.$this->escapeString($this->alias).'`'; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -329,29 +329,29 @@ discard block |
||
329 | 329 | |
330 | 330 | protected function compileWhere() { |
331 | 331 | // TODO - fields should be escaped !! |
332 | - !empty($this->where) ? $this->_compiledQuery[] = 'WHERE ' . implode(' AND ', $this->where) : false; |
|
332 | + !empty($this->where) ? $this->_compiledQuery[] = 'WHERE '.implode(' AND ', $this->where) : false; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | protected function compileGroupBy() { |
336 | 336 | // TODO - fields should be escaped !! |
337 | 337 | // !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . implode(',', $this->arrayEscape($this->groupBy)) : false; |
338 | - !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . $this->selectFieldsToString($this->groupBy) : false; |
|
338 | + !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY '.$this->selectFieldsToString($this->groupBy) : false; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | protected function compileOrderBy() { |
342 | 342 | // TODO - fields should be escaped !! |
343 | - !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY ' . implode(',', $this->arrayEscape($this->orderBy)) : false; |
|
343 | + !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY '.implode(',', $this->arrayEscape($this->orderBy)) : false; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | protected function compileHaving() { |
347 | 347 | // TODO - fields should be escaped !! |
348 | - !empty($this->having) ? $this->_compiledQuery[] = 'HAVING ' . implode(' AND ', $this->having) : false; |
|
348 | + !empty($this->having) ? $this->_compiledQuery[] = 'HAVING '.implode(' AND ', $this->having) : false; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | protected function compileLimit() { |
352 | 352 | // TODO - fields should be escaped !! |
353 | 353 | if ($limit = $this->fetchOne ? 1 : $this->limit) { |
354 | - $this->_compiledQuery[] = 'LIMIT ' . $limit . (!empty($this->offset) ? ' OFFSET ' . $this->offset : ''); |
|
354 | + $this->_compiledQuery[] = 'LIMIT '.$limit.(!empty($this->offset) ? ' OFFSET '.$this->offset : ''); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | */ |
396 | 396 | protected function processField($fieldName) { |
397 | 397 | if (is_bool($fieldName)) { |
398 | - $result = (string)intval($fieldName); |
|
398 | + $result = (string) intval($fieldName); |
|
399 | 399 | } elseif (is_numeric($fieldName)) { |
400 | 400 | $result = $fieldName; |
401 | 401 | } elseif (is_null($fieldName)) { |
402 | 402 | $result = 'NULL'; |
403 | 403 | } else { |
404 | 404 | // Field has other type - string or should be convertible to string |
405 | - $result = (string)$fieldName; |
|
405 | + $result = (string) $fieldName; |
|
406 | 406 | if (!$fieldName instanceof DbSqlLiteral) { |
407 | 407 | $result = $this->quoteField($fieldName); |
408 | 408 | } |