Victory Road Archive

You are viewing an archive of Victory Road.

Victory Road closed on January 8, 2018. Thank you for making us a part of your lives since 2006! Please read this thread for details if you missed it.

Technology → vBulletin Top Posters Code

Page 1 of 1

1. FreezeWarp said on July 2, 2010, 04:11:32 AM (-07:00)

Kyurem
2,186 posts

The following is simple code for vBulletin top posters:

PHP Code:
/* vBulletin Top Posters Code
 * Copyright © 2010 Joseph Parsons
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>. */
// ############################### Top Posters ##########
if ($_REQUEST['do'] == 'top_posters') {
    
// Note: This is a poor implementation SQL-wise.
    
$periods = array(
        
60*60*24 =&gt'Past Day',
        
60*60*24*=&gt'Past Week',
        
60*60*24*30 =&gt'Past Month',
        
60*60*24*365 =&gt'Past Year',
        
60*60*24*365*10 =&gt'All Time',
    );
    static 
$top_posters_td$top_posters_tbody$top_posters_thead;
    
$i 0;

    foreach (
$periods AS $seconds =&gt$period) {
        
$top_posters_thead .= '<td>' $period '</td>';
        
$top_posters $db->query_read_slave("
            SELECT COUNT(p.postid) AS post_count, u.userid AS userid, u.username AS username
            FROM " 
TABLE_PREFIX "post AS p, " TABLE_PREFIX "thread AS t, " TABLE_PREFIX "user AS u
            WHERE t.threadid = p.threadid AND u.userid = p.userid AND p.dateline > " 
. (time() - $seconds) . "
            GROUP BY p.userid
            ORDER BY post_count DESC
            LIMIT 20
        "
);
        while (
$user $db->fetch_array($top_posters))
        {
            
$i ++;
            
$top_posters_td[$i] .= '<td>' $user['username'] . ' (<a href="http://www.victoryroad.net/search.php?do=finduser&searchdate=' $seconds '&userid=' $user['userid'] . '">' $user['post_count'] . '</a>)</td>';
        }
        
$i 0;
    }

    foreach (
$top_posters_td AS $i =&gt$val) {
        
$top_posters_tbody .= '<tr><td>' $i '</td>' $val '</tr>'
    }

    
$top_posters_html '<thead><tr class="thead"><td colspan="' . (count($periods) + 1) . '">Top Posters</td></tr></thead><thead><tr class="tcat"><td>#</td>' $top_posters_thead '</tr></thead><tbody>' $top_posters_tbody '</tbody><tfoot><tr><td colspan="' . (count($periods) + 1) . '" class="tfoot">Top Posters © Joseph Parsons<br />Governed Under the GNU v3 (<a href="http://crystal-islands.com/content/3983">See Source</a></td></tr></tfoot>';
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'print_output("' fetch_template('TOP_POSTERS') . '");');

It can be used in the hook "misc_start".

See Demo: VictoryRoad

Page 1 of 1

User List - Contact - Privacy Statement - Lycanroc.Net