MyBB Community Forums

Full Version: Most Reputations Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

Step 1: Create a new file called mostreputations.php and paste this code into it:
<?php

/**
* Most Reputations Page
* Author: #Raptor
* Author's email: [email protected]
**/

define('IN_MYBB', 1);

require_once("global.php");

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

add_breadcrumb("Most Reputations", $_SERVER['PHP_SELF']);

$sablon = '<html>
<head>
<title>Most Reputations</title>
{$headerinclude}
</head>
<body>
{$header}';

$liste = '<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tbody><tr>
<td class="thead" colspan="2"><strong>Most Reputations Page</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>Username</strong></td>
<td class="tcat" width="50%"><strong>Reputation</strong></td>
</tr>';

$a = $db->simple_select('users', 'uid, username, usergroup, displaygroup, reputation', "reputation > 0 AND usergroup<>7", ['order_by' => 'reputation', 'order_dir' => 'desc', 'limit' => 100]);

while($cek = $db->fetch_array($a)) {

$username = htmlspecialchars_uni($cek['username']);

$kid = $cek['uid'];

$username = format_name($username, $cek['usergroup'], $cek['displaygroup']);
$k = build_profile_link($username, $kid);

$rep = my_number_format($cek['reputation']);

$r = '<div style="color:green;">'.$rep.'</div> <a href="reputation.php?uid='.$kid.'">[Details]</a>';

$liste = $liste . '<tr>
<td class="trow1">'.$k.'</td>
<td class="trow1">'.$r.'</td>
</tr>';

}

$son = $liste . '</tbody></table>
{$footer}
</body>
</html>';

$sablon = $sablon . $son;

$sablon = str_replace("\'", "'", addslashes($sablon));
eval("\$page = \"" . $sablon . "\";");
output_page($page);

?>

Step 2: Upload the file to forum root.

Tested on MyBB 1.8 and works fine.

Screenshot:

[Image: ekrangoruntusu.png]
Thank you! Tested on my forum and works great!
Hi, thank you for your contribution Smile
Without any limit in query ? Imho, adding a WHERE reputation<>0 is necessary. And filtering banned users can be interesting.

Actually, your page will list all users in your database and display them on an unique page. What happen if you have 2k+ users ? Heavy, don't you think ?

And why do you write the full query and use $db->query() when you can use $db->simple_select() ? And performing a select * (which is about 80 fields) when you use only 5 fields ?
(2021-02-15, 08:17 AM)Crazycat Wrote: [ -> ]Without any limit in query ? Imho, adding a WHERE reputation<>0 is necessary. And filtering banned users can be interesting.

Actually, your page will list all users in your database and display them on an unique page. What happen if you have 2k+ users ? Heavy, don't you think ?

And why do you write the full query and use $db->query() when you can use $db->simple_select() ? And performing a select * (which is about 80 fields) when you use only 5 fields ?
Can you edit the code?
There is just 2 lines to modify:

Initial:
$q = "SELECT * from ".TABLE_PREFIX."users ORDER BY `reputation` DESC";
$a = $db->query($q);

Modified:
$a = $db->simple_select('users', 'uid, username, usergroup, displaygroup, reputation', "reputation<>0 AND usergroup<>7", ['order_by' => 'reputation', 'order_dir' => 'desc', 'limit' => 100]);

Assuming your banned group is gid 7, and limiting result to the 100 highest reputations
(2021-02-15, 08:58 AM)Crazycat Wrote: [ -> ]There is just 2 lines to modify:

Initial:
$q = "SELECT * from ".TABLE_PREFIX."users ORDER BY `reputation` DESC";
$a = $db->query($q);

Modified:
$a = $db->simple_select('users', 'uid, username, usergroup, displaygroup, reputation', "reputation<>0 AND usergroup<>7", ['order_by' => 'reputation', 'order_dir' => 'desc', 'limit' => 100]);

Assuming your banned group is gid 7, and limiting result to the 100 highest reputations
Thanks for your help, I was busy. Code is updated.
Updated.
I don't know if the code used to parse data is efficient but it's a cool extension as you don't need to activate it from admin cp, you just upload it. You can make most posts, threads etc variants too.
(2021-02-20, 01:20 PM)Nihility Wrote: [ -> ]I don't know if the code used to parse data is efficient but it's a cool extension as you don't need to activate it from admin cp, you just upload it. You can make most posts, threads etc variants too.
Thanks for your comment.
Pages: 1 2