mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 05:13:54 -07:00
Demo mode: Save user language in cookies (#1584)
* Updated * Update User.php * Update User.php * Update register.php * Update CHANGELOG.md
This commit is contained in:
parent
bd34132469
commit
e9d62f10a6
3 changed files with 13 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
||||||
- [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576), [\#1582](https://github.com/torrentpier/torrentpier/pull/1582) ([belomaxorka](https://github.com/belomaxorka))
|
- [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576), [\#1582](https://github.com/torrentpier/torrentpier/pull/1582) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Added some new HTML meta-tags [\#1562](https://github.com/torrentpier/torrentpier/pull/1562) ([belomaxorka](https://github.com/belomaxorka))
|
- Added some new HTML meta-tags [\#1562](https://github.com/torrentpier/torrentpier/pull/1562) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Added showing releaser stats in profile [\#1568](https://github.com/torrentpier/torrentpier/pull/1568) ([belomaxorka](https://github.com/belomaxorka))
|
- Added showing releaser stats in profile [\#1568](https://github.com/torrentpier/torrentpier/pull/1568) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
|
- Demo mode: Save user language in cookies [\#1584](https://github.com/torrentpier/torrentpier/pull/1584) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Fixed `md5()` deprecated in PHP 8.4 [\#1561](https://github.com/torrentpier/torrentpier/pull/1561) ([belomaxorka](https://github.com/belomaxorka))
|
- Fixed `md5()` deprecated in PHP 8.4 [\#1561](https://github.com/torrentpier/torrentpier/pull/1561) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Increased `USEREMAIL_MAX_LENGTH` [\#1566](https://github.com/torrentpier/torrentpier/pull/1566) ([belomaxorka](https://github.com/belomaxorka))
|
- Increased `USEREMAIL_MAX_LENGTH` [\#1566](https://github.com/torrentpier/torrentpier/pull/1566) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Minor improvements [\#1570](https://github.com/torrentpier/torrentpier/pull/1570), [\#1571](https://github.com/torrentpier/torrentpier/pull/1571), [\#1575](https://github.com/torrentpier/torrentpier/pull/1575) ([belomaxorka](https://github.com/belomaxorka))
|
- Minor improvements [\#1570](https://github.com/torrentpier/torrentpier/pull/1570), [\#1571](https://github.com/torrentpier/torrentpier/pull/1571), [\#1575](https://github.com/torrentpier/torrentpier/pull/1575) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
|
|
|
@ -142,6 +142,9 @@ switch ($mode) {
|
||||||
if (!$pr_data = DB()->fetch_row($sql)) {
|
if (!$pr_data = DB()->fetch_row($sql)) {
|
||||||
bb_die($lang['PROFILE_NOT_FOUND']);
|
bb_die($lang['PROFILE_NOT_FOUND']);
|
||||||
}
|
}
|
||||||
|
if (IN_DEMO_MODE && isset($_COOKIE['user_lang'])) {
|
||||||
|
$pr_data['user_lang'] = $_COOKIE['user_lang'];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -286,7 +289,11 @@ foreach ($profile_fields as $field => $can_edit) {
|
||||||
$user_lang = isset($_POST['user_lang']) ? (string)$_POST['user_lang'] : $pr_data['user_lang'];
|
$user_lang = isset($_POST['user_lang']) ? (string)$_POST['user_lang'] : $pr_data['user_lang'];
|
||||||
if ($submit && ($user_lang != $pr_data['user_lang'] || $mode == 'register')) {
|
if ($submit && ($user_lang != $pr_data['user_lang'] || $mode == 'register')) {
|
||||||
$pr_data['user_lang'] = $user_lang;
|
$pr_data['user_lang'] = $user_lang;
|
||||||
$db_data['user_lang'] = $user_lang;
|
if (IN_DEMO_MODE) {
|
||||||
|
bb_setcookie('user_lang', $user_lang);
|
||||||
|
} else {
|
||||||
|
$db_data['user_lang'] = $user_lang;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -472,7 +472,7 @@ class User
|
||||||
public function set_session_cookies($user_id)
|
public function set_session_cookies($user_id)
|
||||||
{
|
{
|
||||||
if ($user_id == GUEST_UID) {
|
if ($user_id == GUEST_UID) {
|
||||||
$delete_cookies = [COOKIE_DATA, 'torhelp'];
|
$delete_cookies = [COOKIE_DATA, 'torhelp', 'user_lang'];
|
||||||
|
|
||||||
foreach ($delete_cookies as $cookie) {
|
foreach ($delete_cookies as $cookie) {
|
||||||
if (isset($_COOKIE[$cookie])) {
|
if (isset($_COOKIE[$cookie])) {
|
||||||
|
@ -579,6 +579,9 @@ class User
|
||||||
define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/source/');
|
define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/source/');
|
||||||
|
|
||||||
if ($this->data['user_id'] != GUEST_UID) {
|
if ($this->data['user_id'] != GUEST_UID) {
|
||||||
|
if (IN_DEMO_MODE && isset($_COOKIE['user_lang'])) {
|
||||||
|
$this->data['user_lang'] = $_COOKIE['user_lang'];
|
||||||
|
}
|
||||||
if ($this->data['user_lang'] && $this->data['user_lang'] != $bb_cfg['default_lang']) {
|
if ($this->data['user_lang'] && $this->data['user_lang'] != $bb_cfg['default_lang']) {
|
||||||
$bb_cfg['default_lang'] = basename($this->data['user_lang']);
|
$bb_cfg['default_lang'] = basename($this->data['user_lang']);
|
||||||
define('LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/');
|
define('LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue