@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | * Defining some constants |
14 | 14 | */ |
15 | 15 | define('CACHER_NOT_INIT', -1); |
16 | -define('CACHER_NO_CACHE', 0); |
|
17 | -define('CACHER_XCACHE' , 1); |
|
16 | +define('CACHER_NO_CACHE', 0); |
|
17 | +define('CACHER_XCACHE', 1); |
|
18 | 18 | |
19 | 19 | define('CACHER_LOCK_WAIT', 5); // maximum cacher wait for table unlock in seconds. Can be float |
20 | 20 | |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | protected static $cacheObject; |
47 | 47 | |
48 | 48 | public function __construct($prefIn = 'CACHE_', $init_mode = false) { |
49 | - if( !($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')) )) { |
|
49 | + if (!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) { |
|
50 | 50 | throw new UnexpectedValueException('Wrong work mode or current mode does not supported on your server'); |
51 | 51 | } |
52 | 52 | |
53 | 53 | $this->prefix = $prefIn; |
54 | - if(extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
55 | - if(self::$mode === CACHER_NOT_INIT) { |
|
54 | + if (extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
55 | + if (self::$mode === CACHER_NOT_INIT) { |
|
56 | 56 | self::$mode = CACHER_XCACHE; |
57 | 57 | } |
58 | 58 | } else { |
59 | - if(self::$mode === CACHER_NOT_INIT) { |
|
59 | + if (self::$mode === CACHER_NOT_INIT) { |
|
60 | 60 | self::$mode = CACHER_NO_CACHE; |
61 | - if(!self::$data) { |
|
61 | + if (!self::$data) { |
|
62 | 62 | self::$data = array(); |
63 | 63 | } |
64 | 64 | } |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | default: |
95 | 95 | switch (self::$mode) { |
96 | 96 | case CACHER_NO_CACHE: |
97 | - self::$data[$this->prefix.$name] = $value; |
|
97 | + self::$data[$this->prefix . $name] = $value; |
|
98 | 98 | break; |
99 | 99 | |
100 | 100 | case CACHER_XCACHE: |
101 | - xcache_set($this->prefix.$name, $value); |
|
101 | + xcache_set($this->prefix . $name, $value); |
|
102 | 102 | break; |
103 | 103 | } |
104 | 104 | break; |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | default: |
119 | 119 | switch (self::$mode) { |
120 | 120 | case CACHER_NO_CACHE: |
121 | - return self::$data[$this->prefix.$name]; |
|
121 | + return self::$data[$this->prefix . $name]; |
|
122 | 122 | break; |
123 | 123 | |
124 | 124 | case CACHER_XCACHE: |
125 | - return xcache_get($this->prefix.$name); |
|
125 | + return xcache_get($this->prefix . $name); |
|
126 | 126 | break; |
127 | 127 | |
128 | 128 | } |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | public function __isset($name) { |
136 | 136 | switch (self::$mode) { |
137 | 137 | case CACHER_NO_CACHE: |
138 | - return isset(self::$data[$this->prefix.$name]); |
|
138 | + return isset(self::$data[$this->prefix . $name]); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case CACHER_XCACHE: |
142 | - return xcache_isset($this->prefix.$name) && ($this->__get($name) !== null); |
|
142 | + return xcache_isset($this->prefix . $name) && ($this->__get($name) !== null); |
|
143 | 143 | break; |
144 | 144 | } |
145 | 145 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | public function unset_by_prefix($prefix_unset = '') { |
162 | 162 | static $array_clear; |
163 | - !$array_clear ? $array_clear = function(&$v,$k,$p) { |
|
163 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
164 | 164 | strpos($k, $p) === 0 ? $v = NULL : false; |
165 | 165 | } : false; |
166 | 166 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | break; |
173 | 173 | |
174 | 174 | case CACHER_XCACHE: |
175 | - if(!function_exists('xcache_unset_by_prefix')) { |
|
175 | + if (!function_exists('xcache_unset_by_prefix')) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | return xcache_unset_by_prefix($this->prefix . $prefix_unset); |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | protected function make_element_name($args, $diff = 0) { |
189 | 189 | $num_args = count($args); |
190 | 190 | |
191 | - if($num_args < 1) { |
|
191 | + if ($num_args < 1) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
195 | 195 | $name = ''; |
196 | 196 | $aName = array(); |
197 | - for($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
197 | + for ($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
198 | 198 | $name .= "[{$args[$i]}]"; |
199 | 199 | array_unshift($aName, $name); |
200 | 200 | } |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | $args = func_get_args(); |
207 | 207 | $name = $this->make_element_name($args, 1); |
208 | 208 | |
209 | - if(!$name) { |
|
209 | + if (!$name) { |
|
210 | 210 | return NULL; |
211 | 211 | } |
212 | 212 | |
213 | - if($this->$name[0] === NULL) { |
|
214 | - for($i = count($name) - 1; $i > 0; $i--) { |
|
213 | + if ($this->$name[0] === NULL) { |
|
214 | + for ($i = count($name) - 1; $i > 0; $i--) { |
|
215 | 215 | $cName = "{$name[$i]}_COUNT"; |
216 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
217 | - if($this->$cName1 == NULL || $i == 1) { |
|
216 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
217 | + if ($this->$cName1 == NULL || $i == 1) { |
|
218 | 218 | $this->$cName++; |
219 | 219 | } |
220 | 220 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | public function array_get() { |
228 | 228 | $name = $this->make_element_name(func_get_args()); |
229 | - if(!$name) { |
|
229 | + if (!$name) { |
|
230 | 230 | return NULL; |
231 | 231 | } |
232 | 232 | return $this->$name[0]; |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | |
235 | 235 | public function array_count() { |
236 | 236 | $name = $this->make_element_name(func_get_args()); |
237 | - if(!$name) { |
|
237 | + if (!$name) { |
|
238 | 238 | return 0; |
239 | 239 | } |
240 | 240 | $cName = "{$name[0]}_COUNT"; |
241 | 241 | $retVal = $this->$cName; |
242 | - if(!$retVal) { |
|
242 | + if (!$retVal) { |
|
243 | 243 | $retVal = NULL; |
244 | 244 | } |
245 | 245 | return $retVal; |
@@ -248,18 +248,18 @@ discard block |
||
248 | 248 | public function array_unset() { |
249 | 249 | $name = $this->make_element_name(func_get_args()); |
250 | 250 | |
251 | - if(!$name) { |
|
251 | + if (!$name) { |
|
252 | 252 | return false; |
253 | 253 | } |
254 | 254 | $this->unset_by_prefix($name[0]); |
255 | 255 | |
256 | - for($i = 1; $i < count($name); $i++) { |
|
256 | + for ($i = 1; $i < count($name); $i++) { |
|
257 | 257 | $cName = "{$name[$i]}_COUNT"; |
258 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
258 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
259 | 259 | |
260 | - if($i == 1 || $this->$cName1 === NULL) { |
|
260 | + if ($i == 1 || $this->$cName1 === NULL) { |
|
261 | 261 | $this->$cName--; |
262 | - if($this->$cName <= 0) { |
|
262 | + if ($this->$cName <= 0) { |
|
263 | 263 | unset($this->$cName); |
264 | 264 | } |
265 | 265 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $this->sql_index_field = "{$table_name}_name"; |
320 | 320 | $this->sql_value_field = "{$table_name}_value"; |
321 | 321 | |
322 | - if(!$this->_DB_LOADED) { |
|
322 | + if (!$this->_DB_LOADED) { |
|
323 | 323 | $this->db_loadAll(); |
324 | 324 | } |
325 | 325 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | public function db_loadItem($index) { |
336 | 336 | $result = null; |
337 | - if($index) { |
|
337 | + if ($index) { |
|
338 | 338 | $index_safe = db_escape($index); |
339 | 339 | $result = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
340 | 340 | // В две строки - что бы быть уверенным в порядке выполнения |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | $this->loadDefaults(); |
349 | 349 | |
350 | 350 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
351 | - while($row = db_fetch($query)) { |
|
351 | + while ($row = db_fetch($query)) { |
|
352 | 352 | $this->$row[$this->sql_index_field] = $row[$this->sql_value_field]; |
353 | 353 | } |
354 | 354 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | |
358 | 358 | public function loadDefaults() { |
359 | - foreach($this->defaults as $defName => $defValue) { |
|
359 | + foreach ($this->defaults as $defName => $defValue) { |
|
360 | 360 | $this->$defName = $defValue; |
361 | 361 | } |
362 | 362 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | } |
373 | 373 | |
374 | 374 | public function db_saveItem($item_list, $value = NULL) { |
375 | - if(empty($item_list)) { |
|
375 | + if (empty($item_list)) { |
|
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | |
381 | 381 | // Сначала записываем данные в базу - что бы поймать все блокировки |
382 | 382 | $qry = array(); |
383 | - foreach($item_list as $item_name => $item_value) { |
|
384 | - if($item_name) { |
|
383 | + foreach ($item_list as $item_name => $item_value) { |
|
384 | + if ($item_name) { |
|
385 | 385 | $item_value = db_escape($item_value === NULL ? $this->$item_name : $item_value); |
386 | 386 | $item_name = db_escape($item_name); |
387 | 387 | $qry[] = "('{$item_name}', '{$item_value}')"; |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
391 | 391 | |
392 | 392 | // И только после взятия блокировок - меняем значения в кэше |
393 | - foreach($item_list as $item_name => $item_value) { |
|
394 | - if($item_name && $item_value !== NULL) { |
|
393 | + foreach ($item_list as $item_name => $item_value) { |
|
394 | + if ($item_name && $item_value !== NULL) { |
|
395 | 395 | $this->$item_name = $item_value; |
396 | 396 | } |
397 | 397 | } |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
420 | 420 | |
421 | 421 | // Alliance bonus calculations |
422 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
422 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
423 | 423 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
424 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
424 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
425 | 425 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
426 | 426 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
427 | 427 | |
@@ -452,25 +452,25 @@ discard block |
||
452 | 452 | 'deuterium_basic_income' => 0, |
453 | 453 | 'eco_scale_storage' => 1, |
454 | 454 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
455 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
455 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
456 | 456 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
457 | 457 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
458 | 458 | 'energy_basic_income' => 0, |
459 | 459 | |
460 | 460 | // Bashing protection settings |
461 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
462 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
463 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
464 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
465 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
461 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
462 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
463 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
464 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
465 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
466 | 466 | |
467 | 467 | 'Fleet_Cdr' => 30, |
468 | 468 | 'fleet_speed' => 1, |
469 | 469 | |
470 | 470 | 'fleet_update_interval' => 4, |
471 | 471 | |
472 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
473 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
472 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
473 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
474 | 474 | // Defaults |
475 | 475 | 'game_default_language' => 'ru', |
476 | 476 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -484,13 +484,13 @@ discard block |
||
484 | 484 | 'game_maxSystem' => 199, |
485 | 485 | 'game_maxPlanet' => 15, |
486 | 486 | // Game global settings |
487 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
487 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
488 | 488 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
489 | 489 | |
490 | 490 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
491 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
491 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
492 | 492 | // Noob protection |
493 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
493 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
494 | 494 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
495 | 495 | |
496 | 496 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | 'payment_currency_exchange_wmu' => 30, |
540 | 540 | 'payment_currency_exchange_wmz' => 1, |
541 | 541 | |
542 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
543 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
542 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
543 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
544 | 544 | |
545 | 545 | 'planet_teleport_cost' => 50000, // |
546 | 546 | 'planet_teleport_timeout' => 86400, // |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | 'resource_multiplier' => 1, |
559 | 559 | |
560 | 560 | //Roleplay system |
561 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
561 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
562 | 562 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
563 | 563 | |
564 | 564 | // Black Market - General |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | } |
645 | 645 | |
646 | 646 | public static function getInstance($gamePrefix = 'sn_', $table_name = 'config') { |
647 | - if(!isset(self::$cacheObject)) { |
|
647 | + if (!isset(self::$cacheObject)) { |
|
648 | 648 | $className = get_class(); |
649 | 649 | self::$cacheObject = new $className($gamePrefix, $table_name); |
650 | 650 | } |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | $this->prepare(); |
137 | 137 | |
138 | 138 | $this->manifest['active'] = false; |
139 | - if(!empty($this->config) && is_array($this->config['db'])) { |
|
139 | + if (!empty($this->config) && is_array($this->config['db'])) { |
|
140 | 140 | // БД, отличная от стандартной |
141 | 141 | $this->db = new db_mysql(); |
142 | 142 | |
143 | 143 | $this->db->sn_db_connect($this->config['db']); |
144 | - if($this->manifest['active'] = $this->db->connected) { |
|
144 | + if ($this->manifest['active'] = $this->db->connected) { |
|
145 | 145 | $this->provider_id = ACCOUNT_PROVIDER_CENTRAL; |
146 | 146 | |
147 | 147 | $this->domain = $this->config['domain']; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | // Fallback to local DB |
158 | - if(!$this->manifest['active']) { |
|
158 | + if (!$this->manifest['active']) { |
|
159 | 159 | $this->db = classSupernova::$db; |
160 | 160 | |
161 | 161 | $this->provider_id = ACCOUNT_PROVIDER_LOCAL; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // OK v4.5 |
212 | 212 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
213 | 213 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
214 | - if($result) { |
|
214 | + if ($result) { |
|
215 | 215 | $this->cookie_set(); |
216 | 216 | } |
217 | 217 | |
@@ -241,12 +241,12 @@ discard block |
||
241 | 241 | protected function password_reset_send_code() { |
242 | 242 | global $lang, $config; |
243 | 243 | |
244 | - if(!$this->is_password_reset) { |
|
244 | + if (!$this->is_password_reset) { |
|
245 | 245 | return $this->account_login_status; |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Проверяем поддержку сброса пароля |
249 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
249 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
250 | 250 | return $this->account_login_status; |
251 | 251 | } |
252 | 252 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | unset($this->account); |
257 | 257 | $this->account = new Account($this->db); |
258 | 258 | |
259 | - if(!$this->account->db_get_by_email($email_unsafe)) { |
|
259 | + if (!$this->account->db_get_by_email($email_unsafe)) { |
|
260 | 260 | throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR); |
261 | 261 | // return $this->account_login_status; |
262 | 262 | } |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | |
267 | 267 | // TODO - Проверять уровень доступа аккаунта! |
268 | 268 | // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ! |
269 | - foreach($user_list as $user_id => $user_data) { |
|
270 | - if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
269 | + foreach ($user_list as $user_id => $user_data) { |
|
270 | + if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
271 | 271 | throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR); |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | 275 | $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
276 | - if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
276 | + if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
277 | 277 | throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR); |
278 | 278 | } |
279 | 279 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | ); |
291 | 291 | |
292 | 292 | $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING; |
293 | - } catch(Exception $e) { |
|
293 | + } catch (Exception $e) { |
|
294 | 294 | sn_db_transaction_rollback(); |
295 | 295 | $result = $e->getMessage(); |
296 | 296 | } |
@@ -306,46 +306,46 @@ discard block |
||
306 | 306 | protected function password_reset_confirm() { |
307 | 307 | global $lang, $config; |
308 | 308 | |
309 | - if(!$this->is_password_reset_confirm) { |
|
309 | + if (!$this->is_password_reset_confirm) { |
|
310 | 310 | return $this->account_login_status; |
311 | 311 | } |
312 | 312 | |
313 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
313 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
314 | 314 | return $this->account_login_status; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Проверяем поддержку сброса пароля |
318 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
318 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
319 | 319 | return $this->account_login_status; |
320 | 320 | } |
321 | 321 | |
322 | 322 | try { |
323 | 323 | $code_unsafe = sys_get_param_str_unsafe('password_reset_code'); |
324 | - if(empty($code_unsafe)) { |
|
324 | + if (empty($code_unsafe)) { |
|
325 | 325 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR); |
326 | 326 | } |
327 | 327 | |
328 | 328 | sn_db_transaction_start(); |
329 | 329 | $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5 |
330 | 330 | |
331 | - if(empty($confirmation)) { |
|
331 | + if (empty($confirmation)) { |
|
332 | 332 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR); |
333 | 333 | } |
334 | 334 | |
335 | - if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
335 | + if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
336 | 336 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR); |
337 | 337 | } |
338 | 338 | |
339 | 339 | unset($this->account); |
340 | 340 | $this->account = new Account($this->db); |
341 | 341 | |
342 | - if(!$this->account->db_get_by_email($confirmation['email'])) { |
|
342 | + if (!$this->account->db_get_by_email($confirmation['email'])) { |
|
343 | 343 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR); |
344 | 344 | } |
345 | 345 | |
346 | 346 | $new_password_unsafe = $this->make_random_password(); |
347 | 347 | $salt_unsafe = $this->password_salt_generate(); |
348 | - if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
348 | + if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
349 | 349 | // Ошибка смены пароля |
350 | 350 | throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR); |
351 | 351 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $this->cookie_set(); |
356 | 356 | $this->login_cookie(); |
357 | 357 | |
358 | - if($this->account_login_status == LOGIN_SUCCESS) { |
|
358 | + if ($this->account_login_status == LOGIN_SUCCESS) { |
|
359 | 359 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
360 | 360 | $message_header = sprintf($lang['log_lost_email_title'], $config->game_name); |
361 | 361 | $message = sprintf($lang['log_lost_email_pass'], $config->game_name, $this->account->account_name, $new_password_unsafe); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | |
364 | 364 | // $users_translated = classSupernova::$auth->db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
365 | 365 | $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
366 | - if(!empty($users_translated)) { |
|
366 | + if (!empty($users_translated)) { |
|
367 | 367 | // Отправляем в лички письмо о сбросе пароля |
368 | 368 | |
369 | 369 | // ПО ОПРЕДЕЛЕНИЮ в $users_translated только |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $message = sys_bbcodeParse($message) . '<br><br>'; |
376 | 376 | // msg_send_simple_message($found_provider->data[F_USER_ID], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message); |
377 | 377 | |
378 | - foreach($users_translated as $user_id => $providers_list) { |
|
378 | + foreach ($users_translated as $user_id => $providers_list) { |
|
379 | 379 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message); |
380 | 380 | } |
381 | 381 | } else { |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id); |
431 | 431 | |
432 | 432 | try { |
433 | - if(!$this->is_register) { |
|
433 | + if (!$this->is_register) { |
|
434 | 434 | $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем'); |
435 | 435 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
436 | 436 | } |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | // $this->account_check_duplicate_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
443 | 443 | |
444 | 444 | $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
445 | - if($this->account->is_exists) { |
|
446 | - if($this->account->account_email == $this->input_email_unsafe) { |
|
445 | + if ($this->account->is_exists) { |
|
446 | + if ($this->account->account_email == $this->input_email_unsafe) { |
|
447 | 447 | throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR); |
448 | 448 | } else { |
449 | 449 | throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR); |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth |
483 | 483 | // $this->register_account(); |
484 | 484 | sn_db_transaction_commit(); |
485 | - } catch(Exception $e) { |
|
485 | + } catch (Exception $e) { |
|
486 | 486 | sn_db_transaction_rollback(); |
487 | 487 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
488 | 488 | } |
@@ -498,15 +498,15 @@ discard block |
||
498 | 498 | */ |
499 | 499 | // OK v4.5 |
500 | 500 | protected function login_cookie() { |
501 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
501 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
502 | 502 | return $this->account_login_status; |
503 | 503 | } |
504 | 504 | |
505 | 505 | // Пытаемся войти по куке |
506 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
506 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
507 | 507 | // Кто хотел - уже сконвертировал старые куки в новые |
508 | 508 | // Update оказывается - не все... |
509 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
509 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
510 | 510 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
511 | 511 | } else { |
512 | 512 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | |
515 | 515 | // $account = $this->db_account_get_by_id($account_id_unsafe); |
516 | 516 | |
517 | - if( |
|
517 | + if ( |
|
518 | 518 | $this->account->db_get_by_id($account_id_unsafe) |
519 | 519 | && ($this->password_encode_for_cookie($this->account->account_password) == $cookie_password_hash_salted) |
520 | 520 | ) { |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
527 | - if($this->account_login_status != LOGIN_SUCCESS) { |
|
527 | + if ($this->account_login_status != LOGIN_SUCCESS) { |
|
528 | 528 | // Невалидная кука - чистим |
529 | 529 | $this->cookie_clear(); |
530 | 530 | } |
@@ -542,13 +542,13 @@ discard block |
||
542 | 542 | protected function login_username() { |
543 | 543 | // TODO - Логин по старым именам |
544 | 544 | try { |
545 | - if(!$this->is_login) { |
|
545 | + if (!$this->is_login) { |
|
546 | 546 | $this->flog('Логин: не выставлен флаг входа в игру - это не логин'); |
547 | 547 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
548 | 548 | } |
549 | 549 | |
550 | 550 | // TODO Пустое имя аккаунта |
551 | - if(!$this->input_login_unsafe) { |
|
551 | + if (!$this->input_login_unsafe) { |
|
552 | 552 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
553 | 553 | } |
554 | 554 | |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | // if(empty($account)) { |
559 | 559 | // throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
560 | 560 | // } |
561 | - if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
561 | + if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
562 | 562 | throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
563 | 563 | } |
564 | 564 | |
565 | - if(!$this->account->password_check($this->input_login_password_raw)) { |
|
565 | + if (!$this->account->password_check($this->input_login_password_raw)) { |
|
566 | 566 | throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR); |
567 | 567 | } |
568 | 568 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | |
571 | 571 | $this->cookie_set(); |
572 | 572 | $this->account_login_status = LOGIN_SUCCESS; |
573 | - } catch(Exception $e) { |
|
573 | + } catch (Exception $e) { |
|
574 | 574 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
575 | 575 | } |
576 | 576 | |
@@ -592,11 +592,11 @@ discard block |
||
592 | 592 | protected function cookie_set($account_to_impersonate = null) { |
593 | 593 | $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account; |
594 | 594 | |
595 | - if(!is_object($this_account) || !$this_account->is_exists) { |
|
595 | + if (!is_object($this_account) || !$this_account->is_exists) { |
|
596 | 596 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
597 | 597 | } |
598 | 598 | |
599 | - if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
599 | + if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
600 | 600 | sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
601 | 601 | } |
602 | 602 | |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | // OK v4.1 |
615 | 615 | protected function cookie_clear() { |
616 | 616 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
617 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
617 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
618 | 618 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
619 | 619 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $this->domain); |
620 | 620 | } else { |
@@ -633,10 +633,10 @@ discard block |
||
633 | 633 | protected function login_validate_input() { |
634 | 634 | // Проверяем, что бы в начале и конце не было пустых символов |
635 | 635 | // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию! |
636 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
636 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
637 | 637 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
638 | 638 | } |
639 | - if(!$this->input_login_password_raw) { |
|
639 | + if (!$this->input_login_password_raw) { |
|
640 | 640 | throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR); |
641 | 641 | } |
642 | 642 | } |
@@ -652,37 +652,37 @@ discard block |
||
652 | 652 | $this->login_validate_input(); |
653 | 653 | |
654 | 654 | // Если нет имени пользователя - NO GO! |
655 | - if(!$this->input_login_unsafe) { |
|
655 | + if (!$this->input_login_unsafe) { |
|
656 | 656 | throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR); |
657 | 657 | } |
658 | 658 | // Если логин имеет запрещенные символы - NO GO! |
659 | - if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
659 | + if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
660 | 660 | throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
661 | 661 | } |
662 | 662 | // Если логин меньше минимальной длины - NO GO! |
663 | - if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
663 | + if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
664 | 664 | throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR); |
665 | 665 | } |
666 | 666 | // Если пароль меньше минимальной длины - NO GO! |
667 | - if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
667 | + if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
668 | 668 | throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR); |
669 | 669 | } |
670 | 670 | // Если пароль имеет пробельные символы в начале или конце - NO GO! |
671 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
671 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
672 | 672 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
673 | 673 | } |
674 | 674 | // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше |
675 | 675 | //Если они есть у повтора - значит пароль и повтор не совпадут |
676 | - if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
676 | + if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
677 | 677 | throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR); |
678 | 678 | } |
679 | 679 | // Если нет емейла - NO GO! |
680 | 680 | // TODO - регистрация без емейла |
681 | - if(!$this->input_email_unsafe) { |
|
681 | + if (!$this->input_email_unsafe) { |
|
682 | 682 | throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR); |
683 | 683 | } |
684 | 684 | // Если емейл не является емейлом - NO GO! |
685 | - if(!is_email($this->input_email_unsafe)) { |
|
685 | + if (!is_email($this->input_email_unsafe)) { |
|
686 | 686 | throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR); |
687 | 687 | } |
688 | 688 | } |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | return core_auth::make_random_password(); |
716 | 716 | } |
717 | 717 | protected function flog($message, $die = false) { |
718 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
718 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
719 | 719 | return; |
720 | 720 | } |
721 | 721 | list($called, $caller) = debug_backtrace(false); |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
732 | 732 | |
733 | 733 | classSupernova::log_file("$message - $caller_name"); |
734 | - if($die) { |
|
734 | + if ($die) { |
|
735 | 735 | // pdump($caller); |
736 | 736 | // pdump(debug_backtrace(false)); |
737 | 737 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | |
29 | 29 | $this->container = array(); |
30 | 30 | |
31 | - if(classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
31 | + if (classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
32 | 32 | $this->cache = classSupernova::$cache; |
33 | 33 | classSupernova::log_file('locale.__constructor: Cache is present'); |
34 | 34 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
35 | 35 | } |
36 | 36 | |
37 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
37 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
38 | 38 | $this->enable_stat_usage = $enable_stat_usage; |
39 | 39 | $this->usage_stat_load(); |
40 | 40 | // TODO shutdown function |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | unset($fallback[$this->active]); |
61 | 61 | |
62 | 62 | // Проходим по оставшимся локалям |
63 | - foreach($fallback as $try_language) { |
|
63 | + foreach ($fallback as $try_language) { |
|
64 | 64 | // Если нет такой строки - пытаемся вытащить из кэша |
65 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
65 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
66 | 66 | $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
67 | 67 | // Записываем результат работы кэша |
68 | 68 | $locale_cache_statistic['queries']++; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | // Если мы как-то где-то нашли строку... |
74 | - if(isset($this->container[$try_language][$offset])) { |
|
74 | + if (isset($this->container[$try_language][$offset])) { |
|
75 | 75 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
76 | 76 | $this[$offset] = $this->container[$try_language][$offset]; |
77 | 77 | $locale_cache_statistic['fallbacks']++; |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | $this->container[$this->active][] = $value; |
88 | 88 | } else { |
89 | 89 | $this->container[$this->active][$offset] = $value; |
90 | - if($this->cache) { |
|
90 | + if ($this->cache) { |
|
91 | 91 | $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
95 | 95 | public function offsetExists($offset) { |
96 | 96 | // Шорткат если у нас уже есть строка в памяти PHP |
97 | - if(!isset($this->container[$this->active][$offset])) { |
|
97 | + if (!isset($this->container[$this->active][$offset])) { |
|
98 | 98 | // pdump($this->cache_prefix_lang . $offset); |
99 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
99 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
100 | 100 | // pdump($this->cache_prefix_lang . $offset); |
101 | 101 | // Если нету такой строки - делаем фоллбэк |
102 | 102 | $this->locale_string_fallback($offset); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | public function offsetGet($offset) { |
114 | 114 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
115 | - if($this->enable_stat_usage) { |
|
115 | + if ($this->enable_stat_usage) { |
|
116 | 116 | $this->usage_stat_log($offset, $value); |
117 | 117 | } |
118 | 118 | return $value; |
@@ -129,24 +129,24 @@ discard block |
||
129 | 129 | public function usage_stat_load() { |
130 | 130 | global $sn_cache; |
131 | 131 | |
132 | - $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
133 | - if(empty($this->stat_usage)) { |
|
132 | + $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
133 | + if (empty($this->stat_usage)) { |
|
134 | 134 | $query = doquery("SELECT * FROM {{lng_usage_stat}}"); |
135 | - while($row = db_fetch($query)) { |
|
135 | + while ($row = db_fetch($query)) { |
|
136 | 136 | $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
137 | 137 | } |
138 | 138 | } |
139 | 139 | } |
140 | 140 | public function usage_stat_save() { |
141 | - if(!empty($this->stat_usage_new)) { |
|
141 | + if (!empty($this->stat_usage_new)) { |
|
142 | 142 | global $sn_cache; |
143 | 143 | $sn_cache->lng_stat_usage = $this->stat_usage; |
144 | 144 | doquery("SELECT 1 FROM {{lng_usage_stat}} LIMIT 1"); |
145 | - foreach($this->stat_usage_new as &$value) { |
|
146 | - foreach($value as &$value2) { |
|
145 | + foreach ($this->stat_usage_new as &$value) { |
|
146 | + foreach ($value as &$value2) { |
|
147 | 147 | $value2 = '"' . db_escape($value2) . '"'; |
148 | 148 | } |
149 | - $value = '(' . implode(',', $value) .')'; |
|
149 | + $value = '(' . implode(',', $value) . ')'; |
|
150 | 150 | } |
151 | 151 | doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES " . implode(',', $this->stat_usage_new)); |
152 | 152 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
160 | 160 | |
161 | 161 | $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
162 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != $empty) { |
|
162 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != $empty) { |
|
163 | 163 | $this->stat_usage[$string_id] = empty($value); |
164 | 164 | $this->stat_usage_new[] = array( |
165 | 165 | 'lang_code' => $this->active, |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
200 | 200 | |
201 | 201 | // Подключен ли внешний кэш? |
202 | - if($this->cache) { |
|
202 | + if ($this->cache) { |
|
203 | 203 | // Загружен ли уже данный файл? |
204 | 204 | $cache_file_status = $this->cache->__get($cache_file_key); |
205 | 205 | 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); |
206 | - if($cache_file_status) { |
|
206 | + if ($cache_file_status) { |
|
207 | 207 | // Если да - повторять загрузку нет смысла |
208 | 208 | return null; |
209 | 209 | } |
@@ -217,35 +217,35 @@ discard block |
||
217 | 217 | $this->make_fallback($language); |
218 | 218 | |
219 | 219 | $file_path = ''; |
220 | - foreach($this->fallback as $lang_try) { |
|
221 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
220 | + foreach ($this->fallback as $lang_try) { |
|
221 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | |
225 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
225 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
226 | 226 | break; |
227 | 227 | } |
228 | 228 | |
229 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
229 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
230 | 230 | break; |
231 | 231 | } |
232 | 232 | |
233 | 233 | $file_path = ''; |
234 | 234 | } |
235 | 235 | |
236 | - if($file_path) { |
|
236 | + if ($file_path) { |
|
237 | 237 | include($file_path); |
238 | 238 | |
239 | - if(!empty($a_lang_array)) { |
|
239 | + if (!empty($a_lang_array)) { |
|
240 | 240 | $this->merge($a_lang_array); |
241 | 241 | |
242 | 242 | // Загрузка данных из файла в кэш |
243 | - if($this->cache) { |
|
243 | + if ($this->cache) { |
|
244 | 244 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
245 | - foreach($a_lang_array as $key => $value) { |
|
245 | + foreach ($a_lang_array as $key => $value) { |
|
246 | 246 | $value_cache_key = $this->cache_prefix_lang . $key; |
247 | - if($this->cache->__isset($value_cache_key)) { |
|
248 | - if(is_array($value)) { |
|
247 | + if ($this->cache->__isset($value_cache_key)) { |
|
248 | + if (is_array($value)) { |
|
249 | 249 | $alt_value = $this->cache->__get($value_cache_key); |
250 | 250 | $value = array_replace_recursive($alt_value, $value); |
251 | 251 | // pdump($alt_value, $alt_value); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if($this->cache) { |
|
259 | + if ($this->cache) { |
|
260 | 260 | $this->cache->__set($cache_file_key, true); |
261 | 261 | } |
262 | 262 | |
@@ -269,14 +269,14 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | public function lng_load_i18n($i18n) { |
272 | - if(!isset($i18n)) { |
|
272 | + if (!isset($i18n)) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | - foreach($i18n as $i18n_data) { |
|
277 | - if(is_string($i18n_data)) { |
|
276 | + foreach ($i18n as $i18n_data) { |
|
277 | + if (is_string($i18n_data)) { |
|
278 | 278 | $this->lng_include($i18n_data); |
279 | - } elseif(is_array($i18n_data)) { |
|
279 | + } elseif (is_array($i18n_data)) { |
|
280 | 280 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
281 | 281 | } |
282 | 282 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | |
295 | 295 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
296 | 296 | |
297 | - if($language_new == $this->active) { |
|
297 | + if ($language_new == $this->active) { |
|
298 | 298 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
299 | 299 | return false; |
300 | 300 | } |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
306 | 306 | $this->make_fallback($this->active); |
307 | 307 | |
308 | - if($this->cache) { |
|
308 | + if ($this->cache) { |
|
309 | 309 | $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
310 | 310 | 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); |
311 | - if($cache_lang_init_status) { |
|
311 | + if ($cache_lang_init_status) { |
|
312 | 312 | return false; |
313 | 313 | } |
314 | 314 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | // Loading global language files |
325 | 325 | $this->lng_load_i18n($sn_mvc['i18n']['']); |
326 | 326 | |
327 | - if($this->cache) { |
|
327 | + if ($this->cache) { |
|
328 | 328 | classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
329 | 329 | $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
330 | 330 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | public function lng_get_info($entry) { |
339 | 339 | $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
340 | 340 | $lang_info = array(); |
341 | - if(file_exists($file_name)) { |
|
341 | + if (file_exists($file_name)) { |
|
342 | 342 | include($file_name); |
343 | 343 | } |
344 | 344 | |
@@ -346,15 +346,15 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | public function lng_get_list() { |
349 | - if(empty($this->lang_list)) { |
|
349 | + if (empty($this->lang_list)) { |
|
350 | 350 | $this->lang_list = array(); |
351 | 351 | |
352 | 352 | $path = SN_ROOT_PHYSICAL . 'language/'; |
353 | 353 | $dir = dir($path); |
354 | - while(false !== ($entry = $dir->read())) { |
|
355 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
354 | + while (false !== ($entry = $dir->read())) { |
|
355 | + if (is_dir($path . $entry) && $entry[0] != '.') { |
|
356 | 356 | $lang_info = $this->lng_get_info($entry); |
357 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
357 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
358 | 358 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
359 | 359 | } |
360 | 360 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected static $is_init = false; |
20 | 20 | |
21 | 21 | protected static function init() { |
22 | - if(!empty(static::$db)) { |
|
22 | + if (!empty(static::$db)) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | static::$db = classSupernova::$db; |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | $provider_id_safe = intval($provider_id_unsafe); |
67 | 67 | !is_array($account_list) ? $account_list = array($account_list) : false; |
68 | 68 | |
69 | - foreach($account_list as $provider_account_id_unsafe) { |
|
69 | + foreach ($account_list as $provider_account_id_unsafe) { |
|
70 | 70 | $provider_account_id_safe = intval($provider_account_id_unsafe); |
71 | 71 | |
72 | 72 | // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером |
73 | 73 | $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE"); |
74 | - while($row = static::$db->db_fetch($query)) { |
|
74 | + while ($row = static::$db->db_fetch($query)) { |
|
75 | 75 | $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true; |
76 | 76 | } |
77 | 77 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " . |
92 | 92 | ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') . |
93 | 93 | "ORDER BY `timestamp` FOR UPDATE"); |
94 | - while($row = static::$db->db_fetch($query)) { |
|
94 | + while ($row = static::$db->db_fetch($query)) { |
|
95 | 95 | $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row; |
96 | 96 | } |
97 | 97 |
@@ -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}} |
@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | |
31 | 31 | static $need_keys = array('server', 'user', 'pass', 'name', 'prefix'); |
32 | 32 | |
33 | - if($this->connected) { |
|
33 | + if ($this->connected) { |
|
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | - if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
37 | + if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
38 | 38 | $debug->error_fatal('There is missconfiguration in your config.php. Check it again', $this->mysql_error()); |
39 | 39 | } |
40 | 40 | |
41 | 41 | // TODO !!!!!! DEBUG -> error!!!! |
42 | 42 | @$this->link = mysql_connect($settings['server'], $settings['user'], $settings['pass']); |
43 | - if(!is_resource($this->link)) { |
|
43 | + if (!is_resource($this->link)) { |
|
44 | 44 | $debug->error_fatal('DB Error - cannot connect to server', $this->mysql_error()); |
45 | 45 | } |
46 | 46 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | return mysql_real_escape_string($unescaped_string, $this->link); |
69 | 69 | } |
70 | 70 | function mysql_close_link() { |
71 | - if($this->connected) { |
|
71 | + if ($this->connected) { |
|
72 | 72 | $this->connected = false; |
73 | 73 | mysql_close($this->link); |
74 | 74 | unset($this->link); |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | |
117 | 117 | $update_cache = false; |
118 | 118 | |
119 | - if(!empty($this->to_write)) { |
|
120 | - foreach($this->to_write as $key => $cork) { |
|
119 | + if (!empty($this->to_write)) { |
|
120 | + foreach ($this->to_write as $key => $cork) { |
|
121 | 121 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
122 | 122 | $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')"; |
123 | 123 | } |
@@ -128,19 +128,19 @@ discard block |
||
128 | 128 | $update_cache = true; |
129 | 129 | } |
130 | 130 | |
131 | - if(!empty($this->to_delete)) { |
|
132 | - foreach($this->to_delete as $key => &$value) { |
|
133 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
131 | + if (!empty($this->to_delete)) { |
|
132 | + foreach ($this->to_delete as $key => &$value) { |
|
133 | + $value = is_string($key) ? "'" . db_escape($key) . "'" : $key; |
|
134 | 134 | } |
135 | 135 | |
136 | - doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") "); |
|
136 | + doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (" . implode(',', $this->to_delete) . ") "); |
|
137 | 137 | // pdump("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") "); |
138 | 138 | |
139 | 139 | $this->to_delete = array(); |
140 | 140 | $update_cache = true; |
141 | 141 | } |
142 | 142 | |
143 | - if($update_cache) { |
|
143 | + if ($update_cache) { |
|
144 | 144 | global $sn_cache; |
145 | 145 | |
146 | 146 | $field_name = $this->cached_name(); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | protected function load() { |
168 | 168 | global $sn_cache; |
169 | 169 | |
170 | - if($this->loaded) { |
|
170 | + if ($this->loaded) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $this->to_write = array(); |
176 | 176 | $this->to_delete = array(); |
177 | 177 | |
178 | - if(!$this->user_id) { |
|
178 | + if (!$this->user_id) { |
|
179 | 179 | $this->loaded = true; |
180 | 180 | return; |
181 | 181 | } |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | $field_name = $this->cached_name(); |
184 | 184 | $a_data = $sn_cache->$field_name; |
185 | 185 | |
186 | - if(!empty($a_data)) { |
|
186 | + if (!empty($a_data)) { |
|
187 | 187 | $this->data = array_replace_recursive($this->data, $a_data); |
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | 191 | $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
192 | - while($row = db_fetch($query)) { |
|
192 | + while ($row = db_fetch($query)) { |
|
193 | 193 | // $this->data[$row['option_id']] = $row['value']; |
194 | 194 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
195 | 195 | } |
@@ -269,14 +269,14 @@ discard block |
||
269 | 269 | // Если в массиве индекса только один элемент - значит это просто индекс |
270 | 270 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
271 | 271 | |
272 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
272 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
273 | 273 | $this->load(); |
274 | 274 | } |
275 | 275 | |
276 | - if(is_array($option_id)) { |
|
276 | + if (is_array($option_id)) { |
|
277 | 277 | $result = $this->data; |
278 | - foreach($option_id as $sub_key) { |
|
279 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
278 | + foreach ($option_id as $sub_key) { |
|
279 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
280 | 280 | $result = null; |
281 | 281 | break; |
282 | 282 | } |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | public function __set($option, $value = null) { |
297 | 297 | global $sn_cache; |
298 | 298 | |
299 | - if(empty($option) || !$this->user_id) { |
|
299 | + if (empty($option) || !$this->user_id) { |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Если в массиве индекса только один элемент - значит это просто индекс |
304 | - if(is_array($option) && count($option) == 1) { |
|
304 | + if (is_array($option) && count($option) == 1) { |
|
305 | 305 | // Разворачиваем его в индекс |
306 | 306 | $option = array(reset($option) => $value); |
307 | 307 | unset($value); |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | |
311 | 311 | $to_write = array(); |
312 | 312 | // Адресация многомерного массива через массив индексов в $option |
313 | - if(is_array($option) && isset($value)) { |
|
313 | + if (is_array($option) && isset($value)) { |
|
314 | 314 | $a_data = &$this->data; |
315 | - foreach($option as $option_id) { |
|
315 | + foreach ($option as $option_id) { |
|
316 | 316 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
317 | 317 | $a_data = &$a_data[$option_id]; |
318 | 318 | } |
319 | - if($a_data != $value) { |
|
319 | + if ($a_data != $value) { |
|
320 | 320 | $a_data = $value; |
321 | 321 | $to_write[reset($option)] = null; |
322 | 322 | } |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | // Пакетная запись из массива ключ -> значение |
325 | 325 | !is_array($option) ? $option = array($option => $value) : false; |
326 | 326 | |
327 | - foreach($option as $option_id => $option_value) { |
|
328 | - if($this->data[$option_id] !== $option_value) { |
|
327 | + foreach ($option as $option_id => $option_value) { |
|
328 | + if ($this->data[$option_id] !== $option_value) { |
|
329 | 329 | // TODO - вынести отдельно в обработчик |
330 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
330 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
331 | 331 | sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
332 | 332 | } |
333 | 333 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - if(!empty($to_write)) { |
|
340 | + if (!empty($to_write)) { |
|
341 | 341 | $field_name = $this->cached_name(); |
342 | 342 | $sn_cache->$field_name = $this->data; |
343 | 343 | |
344 | - foreach($to_write as $option_id => &$option_value) { |
|
344 | + foreach ($to_write as $option_id => &$option_value) { |
|
345 | 345 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
346 | 346 | $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')"; |
347 | 347 | } |
@@ -353,26 +353,26 @@ discard block |
||
353 | 353 | protected function load() { |
354 | 354 | global $sn_cache; |
355 | 355 | |
356 | - if($this->loaded) { |
|
356 | + if ($this->loaded) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
360 | 360 | $this->data = $this->defaults; |
361 | 361 | |
362 | - if(!$this->user_id) { |
|
362 | + if (!$this->user_id) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
366 | 366 | $field_name = $this->cached_name(); |
367 | 367 | $a_data = $sn_cache->$field_name; |
368 | 368 | |
369 | - if(!empty($a_data)) { |
|
369 | + if (!empty($a_data)) { |
|
370 | 370 | $this->data = array_replace($this->data, $a_data); |
371 | 371 | return; |
372 | 372 | } |
373 | 373 | |
374 | 374 | $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
375 | - while($row = db_fetch($query)) { |
|
375 | + while ($row = db_fetch($query)) { |
|
376 | 376 | // $this->data[$row['option_id']] = $row['value']; |
377 | 377 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
378 | 378 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | return $this->__get($offset); |
389 | 389 | } |
390 | 390 | public function offsetSet($offset, $value) { |
391 | - if(!is_null($offset)) { |
|
391 | + if (!is_null($offset)) { |
|
392 | 392 | // $this->data[$offset] = $value; |
393 | 393 | $this->__set($offset, $value); |
394 | 394 | } else { |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | // Re-position template blocks |
629 | 629 | for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--) |
630 | 630 | { |
631 | - $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1]; |
|
631 | + $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i - 1]; |
|
632 | 632 | $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i; |
633 | 633 | } |
634 | 634 | |
@@ -710,13 +710,13 @@ discard block |
||
710 | 710 | */ |
711 | 711 | function assign_recursive($values, $name = '') |
712 | 712 | { |
713 | - if(isset($values['.'])) |
|
713 | + if (isset($values['.'])) |
|
714 | 714 | { |
715 | 715 | $values_extra = $values['.']; |
716 | 716 | unset($values['.']); |
717 | 717 | } |
718 | 718 | |
719 | - if(!$name) |
|
719 | + if (!$name) |
|
720 | 720 | { |
721 | 721 | $this->assign_vars($values); |
722 | 722 | } |
@@ -725,12 +725,12 @@ discard block |
||
725 | 725 | $this->assign_block_vars($name, $values); |
726 | 726 | } |
727 | 727 | |
728 | - if(isset($values_extra)) |
|
728 | + if (isset($values_extra)) |
|
729 | 729 | { |
730 | - foreach($values_extra as $sub_array_name => $sub_array) |
|
730 | + foreach ($values_extra as $sub_array_name => $sub_array) |
|
731 | 731 | { |
732 | 732 | $new_name = $name . ($name ? '.' : '') . $sub_array_name; |
733 | - foreach($sub_array as $sub_element) |
|
733 | + foreach ($sub_array as $sub_element) |
|
734 | 734 | { |
735 | 735 | $this->assign_recursive($sub_element, $new_name); |
736 | 736 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | // OK 4.9 |
37 | 37 | public function __construct($filename = __FILE__) { |
38 | - if($this->provider_id == ACCOUNT_PROVIDER_NONE) { |
|
38 | + if ($this->provider_id == ACCOUNT_PROVIDER_NONE) { |
|
39 | 39 | die('У всех провайдеров должен быть $provider_id!'); |
40 | 40 | } |
41 | 41 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | // OK 4.6 |
134 | 134 | public function player_name_suggest() { |
135 | 135 | $name = ''; |
136 | - if(is_object($this->account) && !empty($this->account->account_email)) { |
|
136 | + if (is_object($this->account) && !empty($this->account->account_email)) { |
|
137 | 137 | list($name) = explode('@', $this->account->account_email); |
138 | 138 | } |
139 | 139 |