define('TOPSEEDER_BRONZ_1', 1);
define('TOPSEEDER_BRONZ_2', 2);
define('TOPSEEDER_BRONZ_3', 3);
define('TOPSEEDER_BRONZ_4', 4);
define('TOPSEEDER_BRONZ_5', 5);
$sql = DB()->fetch_rowset("
SELECT u.*, bt.*,
COUNT(tor.topic_id) as releases
FROM bb_users u
LEFT JOIN bb_bt_torrents tor ON ( tor.poster_id = u.user_id )
LEFT JOIN bb_bt_users bt ON ( bt.user_id = u.user_id )
WHERE u.user_active = 1
GROUP BY u.user_id
");
foreach ($sql as $key => $row)
{
$ratio = ($row['u_down_total']) ? ($row['u_up_total'] + $row['u_up_release'] + $row['u_up_bonus']) / $row['u_down_total'] : '0';
$u_rate = round(($row['u_up_total'])/1024/1024/1024, 2) ;
if(($ratio >= 1) && ($row['releases'] >= 20))
{
if(($u_rate >= 150)&&($u_rate < 299))
{
$Topseeder_Bronz_1[] = $row['user_id'];
}
if (($u_rate >= 300)&&($u_rate < 499))
{
$Topseeder_Bronz_2[] = $row['user_id'];
}
if (($u_rate >= 500)&&($u_rate < 749))
{
$Topseeder_Bronz_3[] = $row['user_id'];
}
if (($u_rate >= 750)&&($u_rate < 999))
{
$Topseeder_Bronz_4[] = $row['user_id'];
}
if (($u_rate >= 1000)&&($u_rate < 1299))
{
$Topseeder_Bronz_5[] = $row['user_id'];
}
else
{
$User[] = $row['user_id'];
}
}
DB()->query("UPDATE bb_users SET user_rank_seeder = ". USER ." WHERE user_id IN(". implode(', ', array_diff($User, array(''))) .")");
DB()->query("UPDATE bb_users SET user_rank_seeder = ". TOPSEEDER_BRONZ_1 ." WHERE user_id IN(". implode(', ', array_diff($Topseeder_Bronz_1, array(''))) .")");
DB()->query("UPDATE bb_users SET user_rank_seeder = ". TOPSEEDER_BRONZ_2 ." WHERE user_id IN(". implode(', ', array_diff($Topseeder_Bronz_2, array(''))) .")");
DB()->query("UPDATE bb_users SET user_rank_seeder = ". TOPSEEDER_BRONZ_3 ." WHERE user_id IN(". implode(', ', array_diff($Topseeder_Bronz_3, array(''))) .")");
DB()->query("UPDATE bb_users SET user_rank_seeder = ". TOPSEEDER_BRONZ_4 ." WHERE user_id IN(". implode(', ', array_diff($Topseeder_Bronz_4, array(''))) .")");
DB()->query("UPDATE bb_users SET user_rank_seeder = ". TOPSEEDER_BRONZ_5 ." WHERE user_id IN(". implode(', ', array_diff($Topseeder_Bronz_5, array(''))) .")");