diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24cd1e0c1..23f319d6c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,7 +18,7 @@
- search.php parameter sanitizing [\#1213](https://github.com/torrentpier/torrentpier/pull/1213) ([kovalensky](https://github.com/kovalensky), [belomaxorka](https://github.com/belomaxorka))
- Limit execution time for forum file-listing [\#1211](https://github.com/torrentpier/torrentpier/pull/1211) ([kovalensky](https://github.com/kovalensky), [belomaxorka](https://github.com/belomaxorka))
- Some reported bugfixes [\#1214](https://github.com/torrentpier/torrentpier/pull/1214) ([belomaxorka](https://github.com/belomaxorka))
-- Minor improvements [\#1206](https://github.com/torrentpier/torrentpier/pull/1206), [\#1215](https://github.com/torrentpier/torrentpier/pull/1215), [\#1217](https://github.com/torrentpier/torrentpier/pull/1217), [\#1219](https://github.com/torrentpier/torrentpier/pull/1219), [\#1220](https://github.com/torrentpier/torrentpier/pull/1220), [\#1224](https://github.com/torrentpier/torrentpier/pull/1224), [\#1228](https://github.com/torrentpier/torrentpier/pull/1228), [\#1229](https://github.com/torrentpier/torrentpier/pull/1229), [\#1230](https://github.com/torrentpier/torrentpier/pull/1230), [\#1234](https://github.com/torrentpier/torrentpier/pull/1234), [\#1236](https://github.com/torrentpier/torrentpier/pull/1236), [\#1243](https://github.com/torrentpier/torrentpier/pull/1243), [\#1248](https://github.com/torrentpier/torrentpier/pull/1248), [\#1253](https://github.com/torrentpier/torrentpier/pull/1253), [\#1254](https://github.com/torrentpier/torrentpier/pull/1254), [\#1259](https://github.com/torrentpier/torrentpier/pull/1259), [\#1263](https://github.com/torrentpier/torrentpier/pull/1263), [\#1265](https://github.com/torrentpier/torrentpier/pull/1265), [\#1266](https://github.com/torrentpier/torrentpier/pull/1266) ([belomaxorka](https://github.com/belomaxorka))
+- Minor improvements [\#1206](https://github.com/torrentpier/torrentpier/pull/1206), [\#1215](https://github.com/torrentpier/torrentpier/pull/1215), [\#1217](https://github.com/torrentpier/torrentpier/pull/1217), [\#1219](https://github.com/torrentpier/torrentpier/pull/1219), [\#1220](https://github.com/torrentpier/torrentpier/pull/1220), [\#1224](https://github.com/torrentpier/torrentpier/pull/1224), [\#1228](https://github.com/torrentpier/torrentpier/pull/1228), [\#1229](https://github.com/torrentpier/torrentpier/pull/1229), [\#1230](https://github.com/torrentpier/torrentpier/pull/1230), [\#1234](https://github.com/torrentpier/torrentpier/pull/1234), [\#1236](https://github.com/torrentpier/torrentpier/pull/1236), [\#1243](https://github.com/torrentpier/torrentpier/pull/1243), [\#1248](https://github.com/torrentpier/torrentpier/pull/1248), [\#1253](https://github.com/torrentpier/torrentpier/pull/1253), [\#1254](https://github.com/torrentpier/torrentpier/pull/1254), [\#1259](https://github.com/torrentpier/torrentpier/pull/1259), [\#1263](https://github.com/torrentpier/torrentpier/pull/1263), [\#1265](https://github.com/torrentpier/torrentpier/pull/1265), [\#1266](https://github.com/torrentpier/torrentpier/pull/1266), [\#1271](https://github.com/torrentpier/torrentpier/pull/1271), [\#1273](https://github.com/torrentpier/torrentpier/pull/1273) ([belomaxorka](https://github.com/belomaxorka))
- Fixed extensions issue [\#1218](https://github.com/torrentpier/torrentpier/pull/1218) ([belomaxorka](https://github.com/belomaxorka))
- Fixed broken sorting in group.php [\#1221](https://github.com/torrentpier/torrentpier/pull/1221) ([belomaxorka](https://github.com/belomaxorka))
- Code re-formatting [\#1225](https://github.com/torrentpier/torrentpier/pull/1225) ([kovalensky](https://github.com/kovalensky))
@@ -28,7 +28,7 @@
- Hide vote button in poll if user already voted [\#1235](https://github.com/torrentpier/torrentpier/pull/1235) ([belomaxorka](https://github.com/belomaxorka))
- Exception handling for Bencode errors [\#1237](https://github.com/torrentpier/torrentpier/pull/1237), [\#1239](https://github.com/torrentpier/torrentpier/pull/1239) ([kovalensky](https://github.com/kovalensky))
- Handle & show upload_max_filesize occurrences [\#1241](https://github.com/torrentpier/torrentpier/pull/1241) ([kovalensky](https://github.com/kovalensky))
-- Little improvements [\#1244](https://github.com/torrentpier/torrentpier/pull/1244) ([kovalensky](https://github.com/kovalensky))
+- Little improvements [\#1244](https://github.com/torrentpier/torrentpier/pull/1244), [\#1272](https://github.com/torrentpier/torrentpier/pull/1272) ([kovalensky](https://github.com/kovalensky))
- Improved handling errors while uploading [\#1246](https://github.com/torrentpier/torrentpier/pull/1246)
- Use hardcoded dictionary names for better counting result in file listing [\#1247](https://github.com/torrentpier/torrentpier/pull/1247) ([kovalensky](https://github.com/kovalensky))
- Refactored thumbnail creation 🌄 [\#1249](https://github.com/torrentpier/torrentpier/pull/1249) ([belomaxorka](https://github.com/belomaxorka))
diff --git a/admin/admin_user_ban.php b/admin/admin_user_ban.php
index 742c753a6..49d5a1501 100644
--- a/admin/admin_user_ban.php
+++ b/admin/admin_user_ban.php
@@ -14,20 +14,14 @@ if (!empty($setmodules)) {
require __DIR__ . '/pagestart.php';
-// Get bans info from datastore
-if (!$bans = $datastore->get('ban_list')) {
- $datastore->update('ban_list');
- $bans = $datastore->get('ban_list');
-}
-
if (isset($_POST['submit'])) {
// Ban action
if (!empty($_POST['username'])) {
if (!$this_userdata = get_userdata($_POST['username'], true)) {
- bb_die($lang['NO_USER_ID_SPECIFIED']);
+ bb_die($lang['NO_USER_ID_SPECIFIED'] . '
' . sprintf($lang['CLICK_RETURN_BANADMIN'], '', '') . '
' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ''));
}
- if (!array_key_exists($this_userdata['user_id'], $bans)) {
+ if (!getBanInfo((int)$this_userdata['user_id'])) {
$sql = 'INSERT INTO ' . BB_BANLIST . ' (ban_userid) VALUES (' . $this_userdata['user_id'] . ')';
if (!DB()->sql_query($sql)) {
bb_die('Could not insert ban_userid info into database');
@@ -61,7 +55,7 @@ if (isset($_POST['submit'])) {
$template->assign_vars(['S_BANLIST_ACTION' => 'admin_user_ban.php']);
$select_userlist = '';
- foreach ($bans as $ban) {
+ foreach (getBanInfo() as $ban) {
$select_userlist .= '';
}
diff --git a/library/includes/functions.php b/library/includes/functions.php
index f07cb8c99..6dbb0acba 100644
--- a/library/includes/functions.php
+++ b/library/includes/functions.php
@@ -1981,7 +1981,7 @@ function profile_url($data)
if (!in_array($user_id, explode(',', EXCLUDED_USERS)) && $username) {
$profile = '' . $profile . '';
- if ((bool)getUserBanInfo($user_id)) {
+ if (getBanInfo((int)$user_id)) {
return '' . $profile . '';
}
}
@@ -2178,10 +2178,10 @@ function user_birthday_icon($user_birthday, $user_id): string
/**
* Returns information about user ban
*
- * @param int $userId
+ * @param int|null $userId
* @return array|null
*/
-function getUserBanInfo(int $userId): ?array
+function getBanInfo(int $userId = null): ?array
{
global $datastore;
@@ -2191,5 +2191,9 @@ function getUserBanInfo(int $userId): ?array
$bans = $datastore->get('ban_list');
}
+ if (!isset($userId)) {
+ return $bans;
+ }
+
return $bans[$userId] ?? [];
}
diff --git a/library/includes/ucp/viewprofile.php b/library/includes/ucp/viewprofile.php
index a28e8fd79..b27d79e15 100644
--- a/library/includes/ucp/viewprofile.php
+++ b/library/includes/ucp/viewprofile.php
@@ -75,7 +75,7 @@ if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) {
}
// Ban information
-if ($banInfo = getUserBanInfo((int)$profiledata['user_id'])) {
+if ($banInfo = getBanInfo((int)$profiledata['user_id'])) {
$template->assign_block_vars('ban', [
'IS_BANNED' => true,
'BAN_REASON' => $banInfo['ban_reason']
diff --git a/src/Legacy/Common/User.php b/src/Legacy/Common/User.php
index a8e47817e..2cb572651 100644
--- a/src/Legacy/Common/User.php
+++ b/src/Legacy/Common/User.php
@@ -218,7 +218,7 @@ class User
$this->init_userprefs();
// Initial ban check
- if ($banInfo = getUserBanInfo((int)$this->id)) {
+ if ($banInfo = getBanInfo((int)$this->id)) {
if (!empty($banInfo['ban_reason'])) {
bb_die($lang['YOU_BEEN_BANNED'] . '
' . $banInfo['ban_reason']);
} else {
diff --git a/viewtopic.php b/viewtopic.php
index 6315958d1..66b066f4e 100644
--- a/viewtopic.php
+++ b/viewtopic.php
@@ -735,7 +735,7 @@ for ($i = 0; $i < $total_posts; $i++) {
]);
// Ban information
- if ($banInfo = getUserBanInfo((int)$poster_id)) {
+ if ($banInfo = getBanInfo((int)$poster_id)) {
$template->assign_block_vars('postrow.ban', [
'IS_BANNED' => true,
'BAN_REASON' => $banInfo['ban_reason']