Max Torrents with userclass

Started by rickandmary, July 20, 2012, 01:22:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rickandmary

This sets a limit on how many torrents a member can seed, it's defined by class rather than ratio, adjust to your own liking.

In announce.php below

if ($az["class"] < UC_VIP)
{
$gigs = $az["uploaded"] / (1024*1024*1024);
$elapsed = floor((gmtime() - $torrent["ts"]) / 3600);
$ratio = (($az["downloaded"] > 0) ? ($az["uploaded"] / $az["downloaded"]) : 1);
if ($ratio < 0.5 || $gigs < 5) $wait = 0;
elseif ($ratio < 0.65 || $gigs < 6.5) $wait = 0;
elseif ($ratio < 0.8 || $gigs < 8) $wait = 0;
elseif ($ratio < 0.95 || $gigs < 9.5) $wait = 0;
else $wait = 0;
if ($elapsed < $wait)
err("Not authorized (" . ($wait - $elapsed) . "h) - READ THE FAQ!");

         }


add

//////////////MAX TORRENTS WITH USERCLASSES/////////////////
if ($az["class"] == UC_USER) $max = 4;
elseif ($az["class"] == UC_POWER_USER) $max = 12;
elseif ($az["class"] == UC_VIP) $max = 50;
elseif ($az["class"] == UC_UPLOADER) $max = 999;
elseif ($az["class"] == UC_MODERATOR) $max = 999;
elseif ($az["class"] == UC_ADMINISTRATOR) $max = 999;
elseif ($az["class"] == UC_SYSOP) $max = 999;
else $max = 0;
if ($max > 0) {
$res = mysql_query("SELECT COUNT(*) AS num FROM peers WHERE userid='$userid' AND seeder='no'") or err("Tracker error 5");
$row = mysql_fetch_assoc($res);
if ($row['num'] >= $max) err("Not authorized (You are downloading your maximum number of allowed torrents - $max)");
}
/////////////END MAX TORRENTS WITH USERCLASSES//////////////


in bittorrent.php below

<?=$activeleech?>
      </span></font> &nbsp;<span class="smallfont" style="color: #000000"><font color="white"><span class="smallfont" style="color: #000000"><font color="white">


add

<?=maxslots();?>
</font></span></font></span></td>


add to global.php and change amounts to same as you have in announce.php


function maxslots () {
    global $CURUSER;
    if ($CURUSER["class"] == UC_USER) $max = 4;
    elseif ($CURUSER["class"] == UC_POWER_USER) $max = 12;
    elseif ($CURUSER["class"] == UC_VIP) $max = 50;
                    else $max = 0;
           if ($CURUSER["class"] < UC_MODERATOR) {
        if ($max > 0)
            print ("<font color=#c3aa67>Slots: </font><font color=red><span class=smallfont>$max</span></font>");
        else
            print ("<font color=#c3aa67>Slots: </font><font color=#FFFFFF><span class=smallfont>Unlimited</span></font>");
           }else{
            print ("<font color=#c3aa67>Slots: </font><font color=#FFFFFF><span class=smallfont>Unlimited</span></font>");
}