Top 20 active users list

From PunBB Resource Wiki

Jump to: navigation, search

Author: ultime

index.php

Find

<?php
 
$footer_style = 'index';
require PUN_ROOT.'footer.php';

Before, Add

<!--- "Top 20 most active users" Script by ultime (ultime@omgultime.com) created for PunBB --->
<div id="announce" class="block">
    <h2><span><b>Top 20 most active users</b></span></h2>
    <div class="box">
        <div class="inbox">
            <div>
<?php
 
$result = $db->query('SELECT id, username, num_posts FROM '.$db->prefix.'users ORDER BY num_posts DESC, username LIMIT 20') or error('Unable to fetch user data', __FILE__, __LINE__, $db->error());
while ($data = $db->fetch_assoc($result))
{
echo "\t\t\t\t\t\t".'<a href="profile.php?id='.$data['id'].'">'.pun_htmlspecialchars($data['username']).'</a> ('.$data['num_posts'].') '."\n";
}
 
?>
        </div>
    </div>
</div>
</div>
<!--- End for "Top 20 most active users" --->

EDIT: Here's the same code, with edits, if you don't want the user "Guest" to appear:

<!--- "Top 20 most active users" Script by ultime (ultime@omgultime.com) created for PunBB --->
<div id="announce" class="block">
    <h2><span><b>Top 20 most active users</b></span></h2>
    <div class="box">
        <div class="inbox">
            <div>
<?php
 
$result = $db->query('SELECT id, username, num_posts FROM '.$db->prefix.'users ORDER BY num_posts DESC, username LIMIT 20') or error('Unable to fetch user data', __FILE__, __LINE__, $db->error());
while ($data = $db->fetch_assoc($result))
{
	if ($data['id'] != 1)
	{
		echo "\t\t\t\t\t\t".'<a href="profile.php?id='.$data['id'].'">'.pun_htmlspecialchars($data['username']).'</a> ('.$data['num_posts'].') '."\n";
	}
}
 
?>
        </div>
    </div>
</div>
</div>
<!--- End for "Top 20 most active users" --->
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox