Minor improvements (#1266)

This commit is contained in:
Roman Kelesidis 2023-12-26 23:02:40 +07:00 committed by GitHub
commit 23f3d352e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 23 deletions

View file

@ -15,12 +15,9 @@ if (!empty($setmodules)) {
require __DIR__ . '/pagestart.php'; require __DIR__ . '/pagestart.php';
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
$user_bansql = '';
$user_list = []; $user_list = [];
if (!empty($_POST['username'])) { if (!empty($_POST['username'])) {
$this_userdata = get_userdata($_POST['username'], true); if (!$this_userdata = get_userdata($_POST['username'], true)) {
if (!$this_userdata) {
bb_die($lang['NO_USER_ID_SPECIFIED']); bb_die($lang['NO_USER_ID_SPECIFIED']);
} }
@ -35,8 +32,6 @@ if (isset($_POST['submit'])) {
$current_banlist = DB()->sql_fetchrowset($result); $current_banlist = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result); DB()->sql_freeresult($result);
$kill_session_sql = '';
for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) { for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) {
$in_banlist = false; $in_banlist = false;
for ($j = 0, $jMax = count($current_banlist); $j < $jMax; $j++) { for ($j = 0, $jMax = count($current_banlist); $j < $jMax; $j++) {
@ -46,8 +41,6 @@ if (isset($_POST['submit'])) {
} }
if (!$in_banlist) { if (!$in_banlist) {
$kill_session_sql .= (($kill_session_sql != '') ? ' OR ' : '') . 'session_user_id = ' . $user_list[$i];
$sql = 'INSERT INTO ' . BB_BANLIST . ' (ban_userid) VALUES (' . $user_list[$i] . ')'; $sql = 'INSERT INTO ' . BB_BANLIST . ' (ban_userid) VALUES (' . $user_list[$i] . ')';
if (!DB()->sql_query($sql)) { if (!DB()->sql_query($sql)) {
bb_die('Could not insert ban_userid info into database'); bb_die('Could not insert ban_userid info into database');
@ -55,14 +48,6 @@ if (isset($_POST['submit'])) {
} }
} }
// Now we'll delete all entries from the session table
if ($kill_session_sql != '') {
$sql = 'DELETE FROM ' . BB_SESSIONS . " WHERE $kill_session_sql";
if (!DB()->sql_query($sql)) {
bb_die('Could not delete banned sessions from database');
}
}
$where_sql = ''; $where_sql = '';
if (isset($_POST['unban_user'])) { if (isset($_POST['unban_user'])) {
@ -70,8 +55,7 @@ if (isset($_POST['submit'])) {
for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) { for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) {
if ($user_list[$i] != -1) { if ($user_list[$i] != -1) {
$where_sql .= (($where_sql != '') ? ', ' : '') . (int)$user_list[$i]; $where_sql = (int)$user_list[$i];
}
} }
} }
@ -81,6 +65,7 @@ if (isset($_POST['submit'])) {
bb_die('Could not delete ban info from database'); bb_die('Could not delete ban info from database');
} }
} }
}
bb_die($lang['BAN_UPDATE_SUCESSFUL'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_BANADMIN'], '<a href="admin_user_ban.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>')); bb_die($lang['BAN_UPDATE_SUCESSFUL'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_BANADMIN'], '<a href="admin_user_ban.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
} else { } else {

View file

@ -28,4 +28,3 @@
</form> </form>
<br> <br>
<p>{L_BAN_EXPLAIN_WARN}</p>