sql_query($sql) )
{
$auth_group_ids = array();
while ( $row = $db->sql_fetchrow($result) )
{
$auth_group_ids[] = $row['group_id'];
}
}
// Get users who are in an authorised group
if ( !empty($auth_group_ids) )
{
for($i = 0; $i < count($auth_group_ids); $i++)
{
$sql = "SELECT user_id
FROM " . USER_GROUP_TABLE . "
WHERE group_id = " . $auth_group_ids[$i];
if ( $result = $db->sql_query($sql) )
{
while ( $row = $db->sql_fetchrow($result) )
{
// Add user if he is not yet in the array of authorised users (prevent adding twice)
$add = '1';
for($j = 0; $j < count($auth_users); $j++)
{
if ( $row['user_id'] == $auth_users[$j] )
{
$add = '0';
}
}
if ( $add == '1' )
{
$auth_users[] = $row['user_id'];
}
}
}
}
}
}
// Give error message when no users are authorised to play games (nothing to display)
if (count($auth_users) == 0)
{
message_die(GENERAL_MESSAGE, $lang['Games_No_Auth_Users'] );
}
// Select all authorised users and all available gamers
$j = 0;
for($i = 0; $i < count($auth_users); $i++)
{
if ($i == 0)
{
$sql_where = "user_id = " . $auth_users[$i];
}
else
{
$sql_where .= " OR user_id = " . $auth_users[$i];
}
if ( $userdata['user_id'] != $auth_users[$i] )
{
if ($j == 0)
{
$sql_2_where = "user_id = " . $auth_users[$i];
$j++;
}
else
{
$sql_2_where .= " OR user_id = " . $auth_users[$i];
}
}
}
// Get all info of authorised users
$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE " . $sql_where . "
ORDER BY games_points DESC, games_won DESC, games_lost ASC, username";
if ( $result = $db->sql_query($sql) )
{
$auth_users_info = array();
while ( $row = $db->sql_fetchrow($result) )
{
$auth_users_info[] = $row;
}
}
//END GET INF0Z
$total = $i;
$points = $auth_users_id[$i]['games_points'];
echo '$i: ' . $i . '
';
echo 'count($auth_users_info): ' . count($auth_users_info) . '
';
for ($i = count($auth_users_info); $i > 0; $i--)
{
$rank = $i;
$auth_users_id[$i]['user_id'] == $id;
}
echo 'User #'.$id.' has '.$points.' points, and is ranked #'.$rank.' out of '.$total.'
';
echo '$i: ' . $i . '
';
echo 'count($auth_users_info): ' . count($auth_users_info) . '
';
?>