Kod:
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("index_end", "najb_start");
function najb_info() // Informacje
{
return array(
"name" => "Najbogatsi!",
"description" => "Plugin dodający na stronie głównej listę najbogatszych użytkowników. Wymaga NewPoints!",
"website" => "http://www.mybboard.pl",
"author" => "Matslom",
"authorsite" => "http://webax.pl",
"version" => "1.0",
'guid' => '*',
'compatibility' => '18*'
);
}
function najb_activate() // Aktywacja
{
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
$returnStatus1 = find_replace_templatesets("index", "#".preg_quote('{$forums}') . "#i", '{$forums}' . "\n" . '{$najb}');
}
function najb_deactivate() // Dezaktywacja
{
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
$returnStatus1 = find_replace_templatesets(
"index", "#".preg_quote('{$forums}' . "\n" . '{$najb}') . "#i",
'{$forums}',0);
}
function najb_start()
{
global $db, $mybb, $page, $najb, $theme, $nwepoints;
/*if ($mybb->settings['newpoints_main_statsvisible'] != 1)
error('Statystyki sią wyłączone');*/
$najb = '<table border="0" cellspacing="1" cellpadding="3" class="tborder" style="margin-bottom:10px;">
<tr>
<td class="thead" colspan="2"><strong>Najbogatsi</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>Użytkownik</strong></td>
<td class="tcat" width="50%" align="center"><strong>Ilość</strong></td>
</tr>';
$richest_users = '';
$bgcolor = alt_trow();
$fields = array('uid', 'username', 'newpoints');
// get richest users
$query_n = $db->query("SELECT username, usergroup, displaygroup, uid, newpoints FROM ".TABLE_PREFIX."users ORDER BY `newpoints` DESC LIMIT 10 ");
$query = $db->simple_select('users', implode(',', $fields), '', array('order_by' => 'newpoints', 'order_dir' => 'DESC', 'limit' => 10));
while($user = $db->fetch_array($query_n)) {
$bgcolor = alt_trow();
$usernameFormatted = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
$username = '<a href="member.php?action=profile&uid='.intval($user['uid']).'"> '.$usernameFormatted.'</a>';
#$nick = build_profile_link(htmlspecialchars_uni($user['username']), intval($user['uid']));
$ile = newpoints_format_points($user['newpoints']);
$najb .= '<tr><td class="trow1" width="50%">'.$username.'</td><td class="trow1" width="50%" align="center">'.$ile.'</td></tr>';
}
$naj .= '</table><br/>';
}
?>