Back to vBulletin 3.7 Add-ons

Banlog Stats
Mod Version: 1.00, by jredrum

This modification is in the archives.
vB Version: 3.7.2 Rating: (3 votes - 5.00 average) Installs: 19
Released: 14 Aug 2008 Last Update: Never Downloads: 19
Not Supported Template Edits  

What it does? - Adds a simple banlog to show who has been banned, for what reason, and how long until that ban is up.

Demo - http://www.theboredspot.com/banlog.php

Instructions:
First, create a file called 'banlog.php' in your forum root. Copy/paste this in that file

PHP Code:
<?php 

// ######################## SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 

define('THIS_SCRIPT''banlist');  

// #################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array(); 

// get special data templates from the datastore 
$specialtemplates = array(); 

// pre-cache templates used by all actions 
$globaltemplates = array(  
        
'my_banlist' 
); 

// pre-cache templates used by specific actions 
$actiontemplates = array(); 

// ########################## REQUIRE BACK-END ############################ 
require_once('./global.php'); 

// #################### HARD CODE JAVASCRIPT PATHS ######################## 
$headinclude str_replace('clientscript'$vbulletin->options['bburl'] . '/clientscript'$headinclude); 

// ######################################################################## 
// ######################### START MAIN SCRIPT ############################ 
// ######################################################################## 

$navbits = array();  

$navbits[$parent] = 'The Ban Log'

$navbits construct_navbits($navbits); 
eval(
'$navbar = "' fetch_template('navbar') . '";'); 

$querygroups = array();
foreach (
$vbulletin->usergroupcache AS $usergroupid => $usergroup)
{
    if (!(
$usergroup['genericoptions'] & $vbulletin->bf_ugp_genericoptions['isnotbannedgroup']))
    {
        
$querygroups["$usergroupid"] = $usergroup['title'];
    }
}
if (!empty(
$querygroups))
{
    
// now query users from the specified groups
    
$getusers $db->query_read("
        SELECT user.userid, user.username, user.usergroupid AS busergroupid,
        userban.usergroupid AS ousergroupid,
        IF(userban.displaygroupid = 0, userban.usergroupid, userban.displaygroupid) AS odisplaygroupid,
        bandate, liftdate, reason,
        adminuser.userid AS adminid, adminuser.username AS adminname
        FROM " 
TABLE_PREFIX "user AS user
        LEFT JOIN " 
TABLE_PREFIX "userban AS userban ON(userban.userid = user.userid)
        LEFT JOIN " 
TABLE_PREFIX "user AS adminuser ON(adminuser.userid = userban.adminid)
        WHERE user.usergroupid IN(" 
implode(','array_keys($querygroups)) . ")
        ORDER BY userban.liftdate ASC, user.username
    "
);
    if (
$db->num_rows($getusers))
    {
        
$users = array();
        while (
$user $db->fetch_array($getusers))
        {
            
$temporary iif($user['liftdate'], 10);
            
$users["$temporary"][] = $user;
        }
    }
    
$db->free_result($getusers);
    
    
// show temporarily banned users
    
if (!empty($users[1]))
    {
        foreach (
$users[1] AS $user)
        {
            if (
$user['liftdate'] == 0)
            {
                
$user['banperiod'] = $vbphrase['permanent'];
                
$user['banlift'] = $vbphrase['never'];
                
$user['banremaining'] = $vbphrase['forever'];
            }
            else
            {
                
$user['banlift'] = vbdate($vbulletin->options['dateformat'] . ', ~' $vbulletin->options['timeformat'], $user['liftdate']);
                
$user['banperiod'] = ceil(($user['liftdate'] - $user['bandate']) / 86400);
                if (
$user['banperiod'] == 1)
                {
                    
$user['banperiod'] .= $vbphrase[day]";
                }
                else
                {
                    
$user['banperiod'] .= $vbphrase[days]";
                }
    
                
$remain $user['liftdate'] - TIMENOW;
                
$remain_days floor($remain 86400);
                
$remain_hours ceil(($remain - ($remain_days 86400)) / 3600);
                if (
$remain_hours == 24)
                {
                    
$remain_days += 1;
                    
$remain_hours 0;
                }
    
                if (
$remain_days 0)
                {
                    
$user['banremaining'] = "<i>$vbphrase[will_be_lifted_soon]</i>";
                }
                else
                {
                    if (
$remain_days == 1)
                    {
                        
$day_word $vbphrase['day'];
                    }
                    else
                    {
                        
$day_word $vbphrase['days'];
                    }
                    if (
$remain_hours == 1)
                    {
                        
$hour_word $vbphrase['hour'];
                    }
                    else
                    {
                        
$hour_word $vbphrase['hours'];
                    }
                    
$user['banremaining'] = "$remain_days $day_word$remain_hours $hour_word";
                }
            }
            
$lista .= "<tr>
                <td valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['username']."</div>
                </td>
                <td align=\"center\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['adminname']."</div>
                </td>
                <td align=\"right\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.vbdate($vbulletin->options['dateformat'], $user['bandate'])."</div>
                </td>
                <td align=\"center\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['banperiod']."</div>
                </td>
                <td align=\"right\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['banlift']."</div>
                </td>
                <td align=\"center\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['banremaining']."</div>
                </td>
                <td align=\"right\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['reason']."</div>
                </td>
            </tr>"
;
        }
    }
    
    
// show permanently banned users
    
if (!empty($users[0]))
    {
        foreach (
$users[0] AS $user)
        {
            if (
$user['liftdate'] == 0)
            {
                
$user['banperiod'] = "Permanent";
                
$user['banlift'] = "Never";
                
$user['banremaining'] = "Forever";
            }
            else
            {
                
$user['banlift'] = vbdate($vbulletin->options['dateformat'] . ', ~' $vbulletin->options['timeformat'], $user['liftdate']);
                
$user['banperiod'] = ceil(($user['liftdate'] - $user['bandate']) / 86400);
                if (
$user['banperiod'] == 1)
                {
                    
$user['banperiod'] .= $vbphrase[day]";
                }
                else
                {
                    
$user['banperiod'] .= $vbphrase[days]";
                }
    
                
$remain $user['liftdate'] - TIMENOW;
                
$remain_days floor($remain 86400);
                
$remain_hours ceil(($remain - ($remain_days 86400)) / 3600);
                if (
$remain_hours == 24)
                {
                    
$remain_days += 1;
                    
$remain_hours 0;
                }
    
                if (
$remain_days 0)
                {
                    
$user['banremaining'] = "<i>$vbphrase[will_be_lifted_soon]</i>";
                }
                else
                {
                    if (
$remain_days == 1)
                    {
                        
$day_word $vbphrase['day'];
                    }
                    else
                    {
                        
$day_word $vbphrase['days'];
                    }
                    if (
$remain_hours == 1)
                    {
                        
$hour_word $vbphrase['hour'];
                    }
                    else
                    {
                        
$hour_word $vbphrase['hours'];
                    }
                    
$user['banremaining'] = "$remain_days $day_word$remain_hours $hour_word";
                }
            }
            
$listb .= "<tr>
                <td valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['username']."</div>
                </td>
                <td align=\"center\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['adminname']."</div>
                </td>
                <td align=\"right\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.vbdate($vbulletin->options['dateformat'], $user['bandate'])."</div>
                </td>
                <td align=\"center\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['banperiod']."</div>
                </td>
                <td align=\"center\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['banlift']."</div>
                </td>
                <td align=\"center\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['banremaining']."</div>
                </td>
                <td align=\"right\" valign=\"top\" class=\"alt1\">
                <div class=\"smallfont\">"
.$user['reason']."</div>
                </td>
            </tr>"
;
        }
    }
}

eval(
'print_output("' fetch_template('my_banlist') . '");'); 

?>
Next, create a new template for each style you have called 'my_banlist'

Copy/paste this code:

Code:
$stylevar[htmldoctype]
<html xmlns="http://www.w3.org/1999/xhtml" dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>Banlog - $vboptions[bbtitle]</title>
</head>
<body>
$header
$navbar
<table class="tborder" align="center" border="0" cellpadding="3" cellspacing="2" width="100%">
    <tr>
        <td colspan="7" class="tcat">
        <strong>Banned Users: Temporary Bans</strong>
        </td>
    </tr>
    <tr>
        <td align="center" class="alt1">
        <strong>User Name</strong>
        </td><br />
        <td align="center" class="alt1">
        <strong>Banned By</strong>
        </td>
        <td align="center" class="alt1">
        <strong>Banned On</strong>
        </td>
        <td align="center" class="alt1">
        <strong>Ban Period</strong>
        </td>
        <td align="center" class="alt1">
        <strong>Ban Will Be Lifted On</strong>
        </td>
                <td align="center" class="alt1">
        <strong>Ban Time Remaining</strong>
        </td>
                <td align="center" class="alt1">
        <strong>Ban Reason</strong>
        </td>
    </tr>
<if condition="$lista == ''">
</table><br />
        <div align="center"><strong>No one is currently banned...  Hmmmm...  Must be a good day!</strong></div>
<else />
        $lista
</table><br />
</if>
<table class="tborder" align="center" border="0" cellpadding="3" cellspacing="2" width="100%">
    <tr>
        <td colspan="7" class="tcat">
        <strong>Banned Users: Permanent Bans</strong>
        </td>
    </tr>
    <tr>
        <td align="center" class="alt1">
        <strong>User Name</strong>
        </td><br />
        <td align="center" class="alt1">
        <strong>Banned By</strong>
        </td>
        <td align="center" class="alt1">
        <strong>Banned On</strong>
        </td>
        <td align="center" class="alt1">
        <strong>Ban Period</strong>
        </td>
        <td align="center" class="alt1">
        <strong>Ban Will Be Lifted On</strong>
        </td>
                <td align="center" class="alt1">
        <strong>Ban Time Remaining</strong>
        </td>
                <td align="center" class="alt1">
        <strong>Ban Reason</strong>
        </td>
    </tr>
<if condition="$listb == ''">
</table><br />
        <div align="center"><strong>No one is currently banned...  Hmmmm...  Must be a good day!</strong></div>
<else />
        $listb
</table><br />
</if>
$footer
</body>
</html>

That's it.

This should work for any version, though I have only tested it on 3.7

This mod is not supported.

Download

No files for download.


vblts.ru supports vBulletin®, 2022-2024