sql_query($sql)) ) message_die(GENERAL_ERROR, 'Couldn\'t read special ranks', '', __LINE__, __FILE__, $sql);
while ($row = $db->sql_fetchrow($result) ) $spe_ranks[] = $row;
for ($i=0; $i < count($spe_ranks); $i++ )
{
$rank = $spe_ranks[$i]['rank_id'];
$spe_ranks[$i]['users_list'] = '';
$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_active = 1 AND user_rank = $rank ORDER BY username";
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Couldn\'t read users', '', __LINE__, __FILE__, $sql);
while ( $row = $db->sql_fetchrow($result) )
{
$spe_ranks[$i]['users_list'] .= ($spe_ranks[$i]['users_list'] == '') ? '' : ', ';
$spe_ranks[$i]['users_list'] .= '' . CheckUsernameColor($row['user_color_gc'], $row['username']) . '';
}
}
//
// standard ranks
$ranks = array();
$sql = "SELECT * FROM " . RANKS_TABLE . " WHERE rank_special <> 1 ORDER BY rank_min";
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Couldn\'t read standard ranks', '', __LINE__, __FILE__, $sql);
while ($row = $db->sql_fetchrow($result) ) $ranks[] = $row;
$rank_max = 99999999;
for ($i=count($ranks)-1; $i >=0; $i--)
{
$ranks[$i]['rank_max'] = $rank_max;
$rank_min = $ranks[$i]['rank_min'];
// count users
$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_active = 1 AND user_rank = 0 AND user_posts >= $rank_min" . (($rank_max < 99999999) ? " AND user_posts < $rank_max" : "" );
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Couldn\'t read users', '', __LINE__, __FILE__, $sql);
$ranks[$i]['user_number'] = $db->sql_numrows($result);
// store the next limit
$rank_max = $ranks[$i]['rank_min'];
}
//
// set the page title and include the page header
//
$page_title = $lang['Ranks'];
include ('includes/page_header.'.$phpEx);
//
// template setting
//
$template->set_filenames(array(
'body' => 'ranks_body.tpl')
);
// constants
$template->assign_vars(array(
'L_SPECIAL_RANKS' => $lang['Special_ranks'],
'L_USERS_LIST' => $lang['Memberlist'],
'L_RANKS' => $lang['Ranks'],
'L_MINI' => $lang['Rank_minimum'],
'L_TOTAL_USERS' => $lang['Total_users'],
'S_HIDDEN_FIELDS' => '',
)
);
// special ranks
for ($i=0; $i < count($spe_ranks); $i++)
{
$template->assign_block_vars('spe_ranks', array(
'RANK_TITLE' => $spe_ranks[$i]['rank_title'],
'RANK_IMAGE' => ($spe_ranks[$i]['rank_image'] == '') ? '' : '',
'USERS_LIST' => $spe_ranks[$i]['users_list'],
)
);
}
// standard ranks
for ($i=0; $i < count($ranks); $i++)
{
$template->assign_block_vars('ranks', array(
'RANK_TITLE' => $ranks[$i]['rank_title'],
'RANK_IMAGE' => ($ranks[$i]['rank_image'] == '') ? '' : '',
'RANK_MINI' => $ranks[$i]['rank_min'],
'RANK_TOTAL' => $ranks[$i]['user_number'],
)
);
}
//
// page footer
//
$template->pparse('body');
include('includes/page_tail.'.$phpEx);
?>