MyBB Community Forums

Full Version: Edit these two pages with a new feature
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So this is my ban page for my forums, when a ban expires I want it so it stays on the list instead of being removed off of the list

<?php

    define("IN_MYBB", 1);
    require_once "./global.php";

    if($mybb->user['uid'] == 0)
    {
        error_no_permission();
    }
    
    add_breadcrumb("Custom Pages", "custom.php");
    
    $title = "Banned Member List";
    add_breadcrumb($title);

    if(!$mybb->user['uid']){
        error_no_permission();
    }
    
    //pagination start
    $query = $db->simple_select("banned", "COUNT(uid) AS results"); // change pid to your primary key field
    $totalcount = $db->fetch_field($query, "results"); 
    $perpage = 10;
    $pages = $totalcount / $perpage; 
    $pages = ceil($pages);
    $currentpage = (int) $mybb->input['page'];

    /* some PHP to generate your page */
    $url = $mybb->settings['bburl'] . "/bans.php";
    
    if ($currentpage > 0) {
        $multipage = multipage($totalcount, $perpage, $currentpage, $url);
        $offset = ($currentpage - 1) * $perpage; // forgive the lack of indentation, mybb keeps stripping out the tab characters
    }
    else {
        $multipage = multipage($totalcount, $perpage, '1', $url);
        $offset = 0;
    }
    //pagination end

    $message .= '
    <table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
    <tr>
        <td class="thead" colspan="5"><span class="smalltext"><strong>'.$title.'</strong></span></td>
    </tr>
    <tr>
        <td class="tcat" width="15%"><span class="smalltext"><strong>Username</strong></span></td>
        <td class="tcat" width="40%"><span class="smalltext"><strong>Reason</strong></span></td>
        <td class="tcat" width="15%"><span class="smalltext"><strong>Banned On</strong></span></td>
        <td class="tcat" width="15%"><span class="smalltext"><strong>Expires</strong></span></td>
        <td class="tcat" width="15%"><span class="smalltext"><strong>Issued By</strong></span></td>
    </tr>';


    $bannedlist = $db->query("SELECT * FROM `".TABLE_PREFIX."banned` ORDER BY `dateline` DESC LIMIT ".$offset.", ".$perpage);
    $altbg = "trow1";
    while($ban = $db->fetch_array($bannedlist)){

        //$user = get_user($ban['uid']);
        //$banby = get_user($ban['admin']);
        
        
        
        $user = get_user($ban['uid']);
        
            //Username to UID
            $userto = $user[username];
            $queryto = $db->simple_select("users","*","username='$userto'");
            $uidto = $db->fetch_field($queryto, "uid"); 
            //UID to USERNAME
            $userto = get_user($uidto);
            //Formats USERNAME
            $formattednameto = format_name($userto['username'],$userto['usergroup'],$userto['displaygroup']);
        
        $banby = get_user($ban['admin']);
        
            //Username to UID
            $user_issurer = $banby[username];
            $query_issurer = $db->simple_select("users","*","username='$user_issurer'");
            $uid_issurer = $db->fetch_field($query_issurer, "uid"); 
            //UID to USERNAME
            $user_issurer = get_user($uid_issurer);
            //Formats USERNAME
            $formattedname_issurer = format_name($user_issurer['username'],$user_issurer['usergroup'],$user_issurer['displaygroup']);
        
        
        

        if ($ban['lifted'] == "0"){
            $unban = "Never";
        }else{
            $unban = my_date($mybb->settings['dateformat'],$ban['lifted']);
        }
        $altbg = alt_trow();
        $message .= '<tr>
        <td class="'.$altbg.'"><a href="member.php?action=profile&amp;uid='. $ban['uid']. '">' . $formattednameto . '</a></td>
        <td class="'.$altbg.'">'. $ban['reason']. '</td>
        <td class="'.$altbg.'">'. my_date($mybb->settings['dateformat'],$ban['dateline']) .'</td>
        <td class="'.$altbg.'">'. $unban .'</td>
        <td class="'.$altbg.'"><a href="member.php?action=profile&amp;uid='. $ban['admin']. '">' . $formattedname_issurer . '</a></td>
        </tr>';
    }

    $message .= "</table>";
    //error($message,$title);
    
    $page = "<html><head><title>{$title}</title>{$headerinclude}</head>
    <body>
        {$header}
        <br />
        {$multipage}
        {$message}
        {$multipage}
        {$footer}
    </body>
    </html>";

    output_page($page);


?>
And my warns page I want it so that if your warning is revoked it is removed from the page instead of saying revoked but when it expires it stays
<?php

// The MIT License (MIT)
//
// Copyright (c) 2014 zacharys
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

define("IN_MYBB", 1);
require_once "./global.php";

    add_breadcrumb("Custom Pages", "custom.php");

    $title = "Warn List";
    add_breadcrumb($title);

    if($mybb->user['uid'] == 0)
    {
        error_no_permission();
    }
    
$groupslist = "4,3";
$allowedgroups = explode(",",$groupslist);
	
    if (!in_array($mybb->user['usergroup'],$allowedgroups))
    {
        error_no_permission();
    }

        $message = '<table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
        <tr>
            <td class="thead" colspan="6"><span class="smalltext"><strong>'.$title.'</strong></span></td>
        </tr>
        <tr>
            <td class="tcat" width="15%"><span class="smalltext"><strong>Username</strong></span></td>
            <td class="tcat" width="15%"><span class="smalltext"><strong>Points</strong></span></td>
            <td class="tcat" width="20%"><span class="smalltext"><strong>Issued</strong></span></td>
            <td class="tcat" width="20%"><span class="smalltext"><strong>Expires</strong></span></td>
            <td class="tcat"><span class="smalltext"><strong>Notes</strong></span></td>
            <td class="tcat" width="15%"><span class="smalltext"><strong>Issued By</strong></span></td>
        </tr>';

        $timesearch = time() - (30 * 24 * 60 * 120);
        $warnnedlist = $db->query("SELECT * FROM `".TABLE_PREFIX."warnings` WHERE dateline > '$timesearch' ORDER BY `dateline` DESC");
        $altbg = "trow1";
        while($warn = $db->fetch_array($warnnedlist)){

            $user = get_user($warn['uid']);
            
                //Username to UID
                $userto = $user[username];
                $queryto = $db->simple_select("users","*","username='$userto'");
                $uidto = $db->fetch_field($queryto, "uid");
                //UID to USERNAME
                $userto = get_user($uidto);
                //Formats USERNAME
                $formattednameto = format_name($userto['username'],$userto['usergroup'],$userto['displaygroup']);
            
            $issuedby = get_user($warn['issuedby']);
            
                //Username to UID
                $user_issurer = $issuedby[username];
                $query_issurer = $db->simple_select("users","*","username='$user_issurer'");
                $uid_issurer = $db->fetch_field($query_issurer, "uid");
                //UID to USERNAME
                $user_issurer = get_user($uid_issurer);
                //Formats USERNAME
                $formattedname_issurer = format_name($user_issurer['username'],$user_issurer['usergroup'],$user_issurer['displaygroup']);

            //Get Warning Level + Color
            $memprofile = get_user($warn['uid']);
            $warning_level = round($memprofile['warningpoints']/$mybb->settings['maxwarningpoints']*100);
            if($warning_level > 100)
            {
                $warning_level = 100;
            }
            $warning_level = get_colored_warning_level($warning_level);    
            
            //Check if revoked or expired
            $revokedby = $warn['revokedby'];
            $expired = $warn['expired'];
            if ($revokedby > 0)
            {
                $warnexpire = "REVOKED";
                //Check for tid
                if ($warn['tid'] > 0)
                {
                    $warnnotes = '<font color="#2b2b2b"><s>'.getWarnIDName($warn['tid']).'</s></font>';
                }
                else
                {
                    $warnnotes = '<font color="#2b2b2b"><s>'.$warn['notes'].'</s></font>';
                }
            } else if ($expired > 0) {
                $warnexpire = 'Expired: '.my_date($mybb->settings['dateformat'],$warn['expires']);
                if ($warn['tid'] > 0)
                {
                    $warnnotes = getWarnIDName($warn['tid']);
                }
                else
                {
                    $warnnotes = $warn['notes'];
                }
            } else {
                $warnexpire = my_date($mybb->settings['dateformat'],$warn['expires']);
                if ($warn['tid'] > 0)
                {
                    $warnnotes = getWarnIDName($warn['tid']);
                }
                else
                {
                    $warnnotes = $warn['notes'];
                }
            }
            $altbg = alt_trow();
            $message .= '<tr>
            <td class="'.$altbg.'"><a href="member.php?action=profile&amp;uid='. $warn['uid']. '">' . $formattednameto . '</a></td>
            <td class="'.$altbg.'"> +'. $warn['points']. '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Total ' .$warning_level.')</td>
            <td class="'.$altbg.'">'. my_date($mybb->settings['dateformat'],$warn['dateline']) .'</td>
            <td class="'.$altbg.'">'. $warnexpire .'</td>
            <td class="'.$altbg.'">'. $warnnotes . '</td>
            <td class="'.$altbg.'"><a href="member.php?action=profile&amp;uid='. $warn['issuedby']. '">' . $formattedname_issurer . '</a></td>
            </tr>';
        }

    $message .= "</table>";
    //error($message,$title);
    $page = "<html><head><title>{$title}</title>{$headerinclude}</head>
    <body>
        {$header}
        <br />
        {$message}
        {$footer}
    </body>
    </html>";

    output_page($page);
    
function getWarnIDName($wid) {
    global $db;
    
    $query = $db->query("SELECT * FROM `".TABLE_PREFIX."warningtypes` WHERE tid = '$wid' ");
    while($results = $db->fetch_array($query)){
        return $results['title'];
    }
}

?>
bump.
This seems more like a possible plugin feature you’re looking for, you may have some luck requesting a plugin in the requests board: https://community.mybb.com/forum-65.html
Smile
The first one's a bit more difficult to accomplish. From what I understand, MyBB deletes the user from mybb_banned table after the user is un-banned. There is an lifted column in that table but I'm not sure in what case that would be used for. Hopefully someone else can spread some light on that. To accomplish that you'd probably need a new table which stores bans permanently, from there you can just change the select query on the page to gather the banned users from there instead, so yes, this is much better suited as a plugin.

As for the second, if you want to make the expired warnings disappear from that page you can add the expired column to the WHERE statement in the query. The following should work:

<?php

// The MIT License (MIT)
//
// Copyright (c) 2014 zacharys
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

define("IN_MYBB", 1);
require_once "./global.php";

    add_breadcrumb("Custom Pages", "custom.php");

    $title = "Warn List";
    add_breadcrumb($title);

    if($mybb->user['uid'] == 0)
    {
        error_no_permission();
    }
    
$groupslist = "4,3";
$allowedgroups = explode(",",$groupslist);
	
    if (!in_array($mybb->user['usergroup'],$allowedgroups))
    {
        error_no_permission();
    }

        $message = '<table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
        <tr>
            <td class="thead" colspan="6"><span class="smalltext"><strong>'.$title.'</strong></span></td>
        </tr>
        <tr>
            <td class="tcat" width="15%"><span class="smalltext"><strong>Username</strong></span></td>
            <td class="tcat" width="15%"><span class="smalltext"><strong>Points</strong></span></td>
            <td class="tcat" width="20%"><span class="smalltext"><strong>Issued</strong></span></td>
            <td class="tcat" width="20%"><span class="smalltext"><strong>Expires</strong></span></td>
            <td class="tcat"><span class="smalltext"><strong>Notes</strong></span></td>
            <td class="tcat" width="15%"><span class="smalltext"><strong>Issued By</strong></span></td>
        </tr>';

        $timesearch = time() - (30 * 24 * 60 * 120);
        $warnnedlist = $db->query("SELECT * FROM `".TABLE_PREFIX."warnings` WHERE dateline > '$timesearch' AND expired = 0 ORDER BY `dateline` DESC");
        $altbg = "trow1";
        while($warn = $db->fetch_array($warnnedlist)){

            $user = get_user($warn['uid']);
            
                //Username to UID
                $userto = $user[username];
                $queryto = $db->simple_select("users","*","username='$userto'");
                $uidto = $db->fetch_field($queryto, "uid");
                //UID to USERNAME
                $userto = get_user($uidto);
                //Formats USERNAME
                $formattednameto = format_name($userto['username'],$userto['usergroup'],$userto['displaygroup']);
            
            $issuedby = get_user($warn['issuedby']);
            
                //Username to UID
                $user_issurer = $issuedby[username];
                $query_issurer = $db->simple_select("users","*","username='$user_issurer'");
                $uid_issurer = $db->fetch_field($query_issurer, "uid");
                //UID to USERNAME
                $user_issurer = get_user($uid_issurer);
                //Formats USERNAME
                $formattedname_issurer = format_name($user_issurer['username'],$user_issurer['usergroup'],$user_issurer['displaygroup']);

            //Get Warning Level + Color
            $memprofile = get_user($warn['uid']);
            $warning_level = round($memprofile['warningpoints']/$mybb->settings['maxwarningpoints']*100);
            if($warning_level > 100)
            {
                $warning_level = 100;
            }
            $warning_level = get_colored_warning_level($warning_level);    
            
            //Check if revoked or expired
            $revokedby = $warn['revokedby'];
            $expired = $warn['expired'];
            if ($revokedby > 0)
            {
                $warnexpire = "REVOKED";
                //Check for tid
                if ($warn['tid'] > 0)
                {
                    $warnnotes = '<font color="#2b2b2b"><s>'.getWarnIDName($warn['tid']).'</s></font>';
                }
                else
                {
                    $warnnotes = '<font color="#2b2b2b"><s>'.$warn['notes'].'</s></font>';
                }
            } else if ($expired > 0) {
                $warnexpire = 'Expired: '.my_date($mybb->settings['dateformat'],$warn['expires']);
                if ($warn['tid'] > 0)
                {
                    $warnnotes = getWarnIDName($warn['tid']);
                }
                else
                {
                    $warnnotes = $warn['notes'];
                }
            } else {
                $warnexpire = my_date($mybb->settings['dateformat'],$warn['expires']);
                if ($warn['tid'] > 0)
                {
                    $warnnotes = getWarnIDName($warn['tid']);
                }
                else
                {
                    $warnnotes = $warn['notes'];
                }
            }
            $altbg = alt_trow();
            $message .= '<tr>
            <td class="'.$altbg.'"><a href="member.php?action=profile&amp;uid='. $warn['uid']. '">' . $formattednameto . '</a></td>
            <td class="'.$altbg.'"> +'. $warn['points']. '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Total ' .$warning_level.')</td>
            <td class="'.$altbg.'">'. my_date($mybb->settings['dateformat'],$warn['dateline']) .'</td>
            <td class="'.$altbg.'">'. $warnexpire .'</td>
            <td class="'.$altbg.'">'. $warnnotes . '</td>
            <td class="'.$altbg.'"><a href="member.php?action=profile&amp;uid='. $warn['issuedby']. '">' . $formattedname_issurer . '</a></td>
            </tr>';
        }

    $message .= "</table>";
    //error($message,$title);
    $page = "<html><head><title>{$title}</title>{$headerinclude}</head>
    <body>
        {$header}
        <br />
        {$message}
        {$footer}
    </body>
    </html>";

    output_page($page);
    
function getWarnIDName($wid) {
    global $db;
    
    $query = $db->query("SELECT * FROM `".TABLE_PREFIX."warningtypes` WHERE tid = '$wid' ");
    while($results = $db->fetch_array($query)){
        return $results['title'];
    }
}

?>