Welcome to Admin Junkies, Guest — join our community!

Register or log in to explore all our content and services for free on Admin Junkies.

Ban List Page

mastersly

Addicted member
Joined
Apr 29, 2020
Messages
988
Credits
0
https://inlobos.com/bans.phpBrian.
1:Create a new file in your forum root called "bans.php"

2:paste the following code
[hide]
Code:
<?php

// Copyright 2012 Paul Hedman

define('IN_MYBB',1);
require_once('global.php');

define("PAGINATION",20);

$lang->load("modcp");

if($mybb->user['uid'] == 0)
{
	error_no_permission();
}

add_breadcrumb("Banned Users List");

if(isset($mybb->input['asc']))
{
	$options['order_dir'] = 'asc';
	$ascdesc = '&asc';
	$ascdesci = '&desc';
} else {
	$options['order_dir'] = 'desc';
	$ascdesc = '&desc';
	$ascdesci = '&asc';
}

switch($mybb->input['sortby'])
{
	case 'issued':
		$options['order_by'] = 'dateline';
		break;
	case 'lifted':
		$options['order_by'] = 'lifted';
		break;

	default:
		$options['order_by'] = 'dateline';
}

if(isset($mybb->input['page']))
{
	$page = (int)$mybb->input['page'];
} else {
	$page = 1;
}

$extra = "&orderby={$options['order_by']}{$ascdesc}";

$query = $db->simple_select("banned", "COUNT(uid) AS count");
$bannum = $db->fetch_field($query, "count");

$multipage = multipage($bannum,PAGINATION,$page,'bans.php?page={page}'.$extra);

$options['limit'] = PAGINATION;
$options['limit_start'] = ($page - 1) * PAGINATION;

$query = $db->simple_select('banned','*',null,$options);


$bans = '<tr class="mobile-hide">
<td class="tcat" align="center"><span class="smalltext"><strong>'.$lang->username.'</strong></span></td>
<td class="tcat" align="center"><span class="smalltext"><strong>'.$lang->reason.'</strong></span></td>
<td class="tcat" align="center"><span class="smalltext"><strong>'.$lang->ban_bannedby.'</strong></span></td>
<td class="tcat" align="center"><span class="smalltext"><strong><a href="bans.php?sortby=issued'.$ascdesci.'">Ban Date</a></strong></span></td>
<td class="tcat" align="center"><span class="smalltext"><strong><a href="bans.php?sortby=lifted'.$ascdesci.'">Unban Date</a></strong></span></td>
</tr>';

$banlist = '';

$bantimes = fetch_ban_times();

while($banned = $db->fetch_array($query))
{
	$user = get_user($banned['uid']);
	$bannedby = get_user($banned['admin']);

	if($banned['lifted'] == 'perm' || $banned['lifted'] == '' || $banned['bantime'] == 'perm' || $banned['bantime'] == '---')
	{
			$banlength = $lang->permanent;
			$timeremaining = $lang->na;
	}
	else
	{
		$banlength = $bantimes[$banned['bantime']];
		$remaining = $banned['lifted']-TIME_NOW;
		$timeremaining = nice_time($remaining, array('short' => 1, 'seconds' => false))."";

		if($remaining < 3600)
		{
			$timeremaining = "<span style=\"color: red;\">({$timeremaining} {$lang->ban_remaining})</span>";
		}
		else if($remaining < 86400)
		{
			$timeremaining = "<span style=\"color: maroon;\">({$timeremaining} {$lang->ban_remaining})</span>";
		}
		else if($remaining < 604800)
		{
			$timeremaining = "<span style=\"color: green;\">({$timeremaining} {$lang->ban_remaining})</span>";
		}
		else
		{
			$timeremaining = "({$timeremaining} {$lang->ban_remaining})";
		}

		$timeremaining = my_date($mybb->settings['dateformat'],$banned['lifted'])." <br/ ><span class=\"smalltext\">{$timeremaining}</span>";
	}

	// Sanitize all user inputs.
	$user['username'] = htmlspecialchars_uni($user['username']);
	$bannedby['username'] = htmlspecialchars_uni($bannedby['username']);
	$banned['reason'] = htmlspecialchars_uni($banned['reason']);

	$banlist .= "<tr>
<td class=\"trow1\" align=\"center\">".build_profile_link($user['username'], $user['uid'])."</td>
<td class=\"trow1\" align=\"center\">{$banned['reason']}</td>
<td class=\"trow1 mobile-hide\" align=\"center\">".build_profile_link($bannedby['username'], $bannedby['uid'])."</td>
<td class=\"trow1 mobile-hide\" align=\"center\">".my_date($mybb->settings['dateformat'],$banned['dateline'])."</td>
<td class=\"trow1 mobile-hide\" align=\"center\">{$timeremaining}</td>
</tr>";
}

if($banlist == '')
{
	$banlist = '<tr><td colspan="5">'.$lang->no_banned.'</td></tr>';
}

$bans .= $banlist;

$page = "<html>
<head>
<title>Banned Users List</title>
{$headerinclude}
</head>
<body>
{$header}
<br />
<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
<tr>
<td class=\"thead\" colspan=\"5\"><span class=\"smalltext\"><strong>Banned Users List</strong></span></td>
</tr>
{$bans}
</table>
{$multipage}
{$footer}
</body>
</html>";

output_page($page);
?>

[/hide]
 
Advertisement Placeholder
I think that this can be helpful because for those people that are active and new to teh forum as well, they will be able to see who is banned and they can see why if they follow their accounts.
 

Log in or register to unlock full forum benefits!

Log in or register to unlock full forum benefits!

Register

Register on Admin Junkies completely free.

Register now
Log in

If you have an account, please log in

Log in
Who read this thread (Total readers: 0)
No registered users viewing this thread.

New Threads

Would You Rather #9

  • Start a forum in a popular but highly competitive niche

    Votes: 9 27.3%
  • Initiate a forum within a limited-known niche with zero competition

    Votes: 24 72.7%
Win this space by entering the Website of The Month Contest

Theme editor

Theme customizations

Graphic Backgrounds

Granite Backgrounds