Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
  #11  
Old 20th March 2012, 03:30
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
ok give this a shot
PHP Code:
<?
$free 
false;
$double false;
ob_start("ob_gzhandler");

require_once(
"include/bittorrent.php");
require_once(
"include/benc.php");



function 
err($msg)
{
    
benc_resp(array("failure reason" => array(type => "string"value => $msg)));
    exit();
}

function 
benc_resp($d)
{
    
benc_resp_raw(benc(array(type => "dictionary"value => $d)));
}

function 
benc_resp_raw($x)
{
    
header("Content-Type: text/plain");
    
header("Pragma: no-cache");
    print(
$x);
}

foreach (array(
"info_hash","peer_id","ip","event","passkey") as $x)

$GLOBALS[$x] = $_GET[$x];





foreach (array(
"port","downloaded","uploaded","left") as $x)

$GLOBALS[$x] = $_GET[$x];



if (
strpos($passkey"?")) {

  
$tmp substr($passkeystrpos($passkey"?"));

$passkey substr($passkey0strpos($passkey"?"));

$tmpname substr($tmp1strpos($tmp"=")-1);

$tmpvalue substr($tmpstrpos($tmp"=")+1);

$GLOBALS[$tmpname] = $tmpvalue;

}



foreach (array(
"info_hash","peer_id","port","downloaded","uploaded","left") as $x)

if (!isset(
$x)) err("Missing key: $x");



foreach (array(
"info_hash","peer_id") as $x)

if (
strlen($GLOBALS[$x]) != 20err("Invalid $x (" strlen($GLOBALS[$x]) . " - " urlencode($GLOBALS[$x]) . ")");



if (isset(
$passkey)AND !$passkey =='' AND strlen($passkey) != 32err("Invalid passkey (" strlen($passkey) . " - $passkey)");
if (!isset(
$passkey)) $passkey '';



//if (empty($ip) || !preg_match('/^(d{1,3}.){3}d{1,3}$/s', $ip))

$ip getip();

$rsize 50;
foreach(array(
"num want""numwant""num_want") as $k)
{
    if (isset(
$_GET[$k]))
    {
        
$rsize $_GET[$k];
        break;
    }
}

$agent $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (ereg("^Mozilla\\/"$agent) || ereg("^Opera\\/"$agent) || ereg("^Links "$agent) || ereg("^Lynx\\/"$agent))
    
err("torrent not registered with this tracker");

if (!
$port || $port 0xffff)
    
err("invalid port");

if (!isset(
$event))
    
$event "";

$seeder = ($left == 0) ? "yes" "no";

dbconn(false);

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM users WHERE passkey=" sqlesc($passkey)));

if (
$valid[0] != 1err("Invalid passkey! Re-download the .torrent from $BASEURL");


$res mysql_query("SELECT id, banned, free, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " hash_where("info_hash"$info_hash));

$torrent mysql_fetch_assoc($res);
if (!
$torrent)
    
err("torrent not registered with this tracker");

$torrentid $torrent["id"];

//$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid";
$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid, UNIX_TIMESTAMP(last_action) AS ts";

$numpeers $torrent["numpeers"];
$limit "";
if (
$numpeers $rsize)
    
$limit "ORDER BY RAND() LIMIT $rsize";
$res mysql_query("SELECT $fields FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");

$resp "d" benc_str("interval") . "i" $announce_interval "e" benc_str("peers") . "l";
unset(
$self);
while (
$row mysql_fetch_assoc($res))
{
    
$row["peer_id"] = hash_pad($row["peer_id"]);

    if (
$row["peer_id"] === $peer_id)
    {
        
$userid $row["userid"];
        
$self $row;
        continue;
    }

    
$resp .= "d" .
        
benc_str("ip") . benc_str($row["ip"]) .
        
benc_str("peer id") . benc_str($row["peer_id"]) .
        
benc_str("port") . "i" $row["port"] . "e" .
        
"e";
}

$resp .= "ee";

$selfwhere "torrent = $torrentid AND " hash_where("peer_id"$peer_id);

if (!isset(
$self))
{
    
$res mysql_query("SELECT $fields FROM peers WHERE $selfwhere");
    
$row mysql_fetch_assoc($res);
    if (
$row)
    {
        
$userid $row["userid"];
        
$self $row;
    }
}

//// Up/down stats ////////////////////////////////////////////////////////////


if (!isset($self))

{

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND passkey=" sqlesc($passkey)));

if (
$valid[0] >= && $seeder == 'no'err("Connection limit exceeded! You may only leech from one location at a time.");

if (
$valid[0] >= && $seeder == 'yes'err("Connection limit exceeded!");

    
$rz mysql_query("SELECT id, uploaded, downloaded, class, parked FROM users WHERE (ip='$ip' or passkey='$passkey') AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
    if (
$MEMBERSONLY && mysql_num_rows($rz) == 0)
    
err("Unknown passkey. Please redownload the torrent from $BASEURL.");
    
$az mysql_fetch_assoc($rz);
    
$userid $az["id"];

//    if ($left > 0 && $az["class"] < UC_VIP)
    
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!");
    }
}
else
{
    
    
// Get the last uploaded amount from user account for reference and store it in $last_up
    
$rst mysql_query("SELECT class, uploaded FROM users WHERE id = $userid") or err("Tracker error 5");
    
$art mysql_fetch_array($rst);
    
$last_up $art["uploaded"];
    
$class $art["class"];

    
$upthis max(0$uploaded $self["uploaded"]);
    
$downthis max(0$downloaded $self["downloaded"]);
    
    if (
$free)
        
$downthis 0;
    if (
$double)
        
$upthis *= 2;

 if (
$upthis || $downthis 0)
 
mysql_query("UPDATE users SET uploaded = uploaded + $upthis". ($torrent['free']=='no'?", downloaded = downloaded + $downthis ":' '). "WHERE id=$userid") or err("Tracker error 3");

// Initial sanity check xMB/s for 1 second
    
if($upthis 2097152)
    {
        
//Work out time difference
        
$endtime time();
        
$starttime $self['ts'];
        
$diff = ($endtime $starttime);
        
//Normalise to prevent divide by zero.
        
$rate = ($upthis / ($diff 1));
        
//Currently 2MB/s (2097152). Increase to 5MB/s (5242880) once finished testing.
        
if ($rate 2097152)
        {
            if (
$class UC_MODERATOR)
            {
                
$rate mksize($rate);
                
$client $agent;
                
$userip getip();

                
auto_enter_cheater($userid$rate$upthis$diff$torrentid$client$userip$last_up);
            }
        }
    }
}

/////////////////////Fix Increase ratio using Firefox //////////////////////
$headers getallheaders();
if (isset(
$headers["Cookie"]) || isset($headers["Accept-Language"]) || isset($headers["Accept-Charset"]))
err("Anti-Cheater= You cannot use this agent");
///////////////////end of fix//////////////////////




$dt gmtime() - 180;
$dt sqlesc(get_date_time($dt));
function 
portblacklisted($port)
{
    
// direct connect
    
if ($port >= 411 && $port <= 413) return true;

    
// bittorrent
    
if ($port >= 6881 && $port <= 6889) return true;

    
// kazaa
    
if ($port == 1214) return true;

    
// gnutella
    
if ($port >= 6346 && $port <= 6347) return true;

    
// emule
    
if ($port == 4662) return true;

    
// winmx
    
if ($port == 6699) return true;

    return 
false;
}

$updateset = array();

if (
$event == "stopped")
{
    if (isset(
$self))
    {
        
mysql_query("DELETE FROM peers WHERE $selfwhere");
        if (
mysql_affected_rows())
        {
            if (
$self["seeder"] == "yes")
                
$updateset[] = "seeders = seeders - 1";
            else
                
$updateset[] = "leechers = leechers - 1";
        }
    }
}
else
{
if (
$event == "completed")
{
mysql_query("UPDATE snatched SET  finished  = 'yes', complete_date = $dt WHERE torrentid = $torrentid AND userid = $userid");
$updateset[] = "times_completed = times_completed + 1";
}

    if (isset(
$self))
    {
    
$res_s mysql_query("SELECT uploaded, downloaded FROM snatched WHERE torrentid = $torrentid AND userid = $userid");
$row_s mysql_fetch_array($res_s);
$downloaded2 max(0$downloaded $self["downloaded"]);
$uploaded2 max(0$uploaded $self["uploaded"]);
mysql_query("UPDATE snatched SET uploaded = uploaded + $uploaded2, port = $port, agent= " sqlesc($agent) . ", last_action = $dt WHERE torrentid = $torrentid AND userid = $userid");
mysql_query("UPDATE snatched SET downloaded = downloaded + $downloaded2 WHERE torrentid = $torrentid AND userid = $userid");
        
mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder'"
            
. ($seeder == "yes" && $self["seeder"] != $seeder ", finishedat = " time() : "") . " WHERE $selfwhere");
        if (
mysql_affected_rows() && $self["seeder"] != $seeder)
        {
            if (
$seeder == "yes")
            {
                
$updateset[] = "seeders = seeders + 1";
                
$updateset[] = "leechers = leechers - 1";
            }
            else
            {
                
$updateset[] = "seeders = seeders - 1";
                
$updateset[] = "leechers = leechers + 1";
            }
        }
    }
    else
    {
    
           if (
$az["parked"] == "yes")
err("Error, your account is parked! Please read the FAQ!");
    
        if (
portblacklisted($port))
            
err("Port $port is blacklisted.");
        else
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }
        
$res1_s mysql_query("SELECT torrentid, userid FROM snatched WHERE torrentid = $torrentid AND userid = $userid") or err('Tracker error (120)');
$row1_s mysql_fetch_assoc($res1_s);
if (!
$row1_s)
mysql_query("INSERT INTO snatched (torrentid, userid, port, start_date, agent,ip,peer_id) VALUES ($torrentid$userid$port$dt, " sqlesc($agent) . "," sqlesc($ip) . "," sqlesc($peer_id) . ")");
        
$ret mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset, passkey) VALUES ('$connectable', $torrentid, " sqlesc($peer_id) . ", " sqlesc($ip) . ", $port$uploaded$downloaded$left, NOW(), NOW(), '$seeder', $userid, " sqlesc($agent) . ", $uploaded$downloaded, " sqlesc($passkey) . ")");
        if (
$ret)
        {
            if (
$seeder == "yes")
                
$updateset[] = "seeders = seeders + 1";
            else
                
$updateset[] = "leechers = leechers + 1";
        }
    }
}

if (
$seeder == "yes")
{
    if (
$torrent["banned"] != "yes")
        
$updateset[] = "visible = 'yes'";
    
$updateset[] = "last_action = NOW()";
}

if (
count($updateset))
    
mysql_query("UPDATE torrents SET " join(","$updateset) . " WHERE id = $torrentid");

benc_resp_raw($resp);


?>
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #12  
Old 20th March 2012, 03:35
ZenoX ZenoX is offline
Senior Member
 
Join Date: Jul 2009
P2P
Posts: 19
Default
Just uploaded a fresh file of it, still got the same error except it is 22 in ( ) instead of 21

Thanks
Reply With Quote
  #13  
Old 20th March 2012, 03:44
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
lmao this would be faster if i could see what was going on but any how try this one
PHP Code:
<?
$free 
false;
$double false;
ob_start("ob_gzhandler");

require_once(
"include/bittorrent.php");
require_once(
"include/benc.php");



function 
err($msg)
{
    
benc_resp(array("failure reason" => array(type => "string"value => $msg)));
    exit();
}

function 
benc_resp($d)
{
    
benc_resp_raw(benc(array(type => "dictionary"value => $d)));
}

function 
benc_resp_raw($x)
{
    
header("Content-Type: text/plain");
    
header("Pragma: no-cache");
    print(
$x);
}

foreach (array(
"info_hash","peer_id","ip","event","passkey") as $x)

if(isset(
$_GET[$x]))$GLOBALS[$x] = $_GET[$x];





foreach (array(
"port","downloaded","uploaded","left") as $x)

$GLOBALS[$x] = $_GET[$x];



if (
strpos($passkey"?")) {

  
$tmp substr($passkeystrpos($passkey"?"));

$passkey substr($passkey0strpos($passkey"?"));

$tmpname substr($tmp1strpos($tmp"=")-1);

$tmpvalue substr($tmpstrpos($tmp"=")+1);

$GLOBALS[$tmpname] = $tmpvalue;

}



foreach (array(
"info_hash","peer_id","port","downloaded","uploaded","left") as $x)

if (!isset(
$x)) err("Missing key: $x");



foreach (array(
"info_hash","peer_id") as $x)

if (
strlen($GLOBALS[$x]) != 20err("Invalid $x (" strlen($GLOBALS[$x]) . " - " urlencode($GLOBALS[$x]) . ")");



if (isset(
$passkey)AND !$passkey =='' AND strlen($passkey) != 32err("Invalid passkey (" strlen($passkey) . " - $passkey)");
if (!isset(
$passkey)) $passkey '';



//if (empty($ip) || !preg_match('/^(d{1,3}.){3}d{1,3}$/s', $ip))

$ip getip();

$rsize 50;
foreach(array(
"num want""numwant""num_want") as $k)
{
    if (isset(
$_GET[$k]))
    {
        
$rsize $_GET[$k];
        break;
    }
}

$agent $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (ereg("^Mozilla\\/"$agent) || ereg("^Opera\\/"$agent) || ereg("^Links "$agent) || ereg("^Lynx\\/"$agent))
    
err("torrent not registered with this tracker");

if (!
$port || $port 0xffff)
    
err("invalid port");

if (!isset(
$event))
    
$event "";

$seeder = ($left == 0) ? "yes" "no";

dbconn(false);

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM users WHERE passkey=" sqlesc($passkey)));

if (
$valid[0] != 1err("Invalid passkey! Re-download the .torrent from $BASEURL");


$res mysql_query("SELECT id, banned, free, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " hash_where("info_hash"$info_hash));

$torrent mysql_fetch_assoc($res);
if (!
$torrent)
    
err("torrent not registered with this tracker");

$torrentid $torrent["id"];

//$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid";
$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid, UNIX_TIMESTAMP(last_action) AS ts";

$numpeers $torrent["numpeers"];
$limit "";
if (
$numpeers $rsize)
    
$limit "ORDER BY RAND() LIMIT $rsize";
$res mysql_query("SELECT $fields FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");

$resp "d" benc_str("interval") . "i" $announce_interval "e" benc_str("peers") . "l";
unset(
$self);
while (
$row mysql_fetch_assoc($res))
{
    
$row["peer_id"] = hash_pad($row["peer_id"]);

    if (
$row["peer_id"] === $peer_id)
    {
        
$userid $row["userid"];
        
$self $row;
        continue;
    }

    
$resp .= "d" .
        
benc_str("ip") . benc_str($row["ip"]) .
        
benc_str("peer id") . benc_str($row["peer_id"]) .
        
benc_str("port") . "i" $row["port"] . "e" .
        
"e";
}

$resp .= "ee";

$selfwhere "torrent = $torrentid AND " hash_where("peer_id"$peer_id);

if (!isset(
$self))
{
    
$res mysql_query("SELECT $fields FROM peers WHERE $selfwhere");
    
$row mysql_fetch_assoc($res);
    if (
$row)
    {
        
$userid $row["userid"];
        
$self $row;
    }
}

//// Up/down stats ////////////////////////////////////////////////////////////


if (!isset($self))

{

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND passkey=" sqlesc($passkey)));

if (
$valid[0] >= && $seeder == 'no'err("Connection limit exceeded! You may only leech from one location at a time.");

if (
$valid[0] >= && $seeder == 'yes'err("Connection limit exceeded!");

    
$rz mysql_query("SELECT id, uploaded, downloaded, class, parked FROM users WHERE (ip='$ip' or passkey='$passkey') AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
    if (
$MEMBERSONLY && mysql_num_rows($rz) == 0)
    
err("Unknown passkey. Please redownload the torrent from $BASEURL.");
    
$az mysql_fetch_assoc($rz);
    
$userid $az["id"];

//    if ($left > 0 && $az["class"] < UC_VIP)
    
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!");
    }
}
else
{
    
    
// Get the last uploaded amount from user account for reference and store it in $last_up
    
$rst mysql_query("SELECT class, uploaded FROM users WHERE id = $userid") or err("Tracker error 5");
    
$art mysql_fetch_array($rst);
    
$last_up $art["uploaded"];
    
$class $art["class"];

    
$upthis max(0$uploaded $self["uploaded"]);
    
$downthis max(0$downloaded $self["downloaded"]);
    
    if (
$free)
        
$downthis 0;
    if (
$double)
        
$upthis *= 2;

 if (
$upthis || $downthis 0)
 
mysql_query("UPDATE users SET uploaded = uploaded + $upthis". ($torrent['free']=='no'?", downloaded = downloaded + $downthis ":' '). "WHERE id=$userid") or err("Tracker error 3");

// Initial sanity check xMB/s for 1 second
    
if($upthis 2097152)
    {
        
//Work out time difference
        
$endtime time();
        
$starttime $self['ts'];
        
$diff = ($endtime $starttime);
        
//Normalise to prevent divide by zero.
        
$rate = ($upthis / ($diff 1));
        
//Currently 2MB/s (2097152). Increase to 5MB/s (5242880) once finished testing.
        
if ($rate 2097152)
        {
            if (
$class UC_MODERATOR)
            {
                
$rate mksize($rate);
                
$client $agent;
                
$userip getip();

                
auto_enter_cheater($userid$rate$upthis$diff$torrentid$client$userip$last_up);
            }
        }
    }
}

/////////////////////Fix Increase ratio using Firefox //////////////////////
$headers getallheaders();
if (isset(
$headers["Cookie"]) || isset($headers["Accept-Language"]) || isset($headers["Accept-Charset"]))
err("Anti-Cheater= You cannot use this agent");
///////////////////end of fix//////////////////////




$dt gmtime() - 180;
$dt sqlesc(get_date_time($dt));
function 
portblacklisted($port)
{
    
// direct connect
    
if ($port >= 411 && $port <= 413) return true;

    
// bittorrent
    
if ($port >= 6881 && $port <= 6889) return true;

    
// kazaa
    
if ($port == 1214) return true;

    
// gnutella
    
if ($port >= 6346 && $port <= 6347) return true;

    
// emule
    
if ($port == 4662) return true;

    
// winmx
    
if ($port == 6699) return true;

    return 
false;
}

$updateset = array();

if (
$event == "stopped")
{
    if (isset(
$self))
    {
        
mysql_query("DELETE FROM peers WHERE $selfwhere");
        if (
mysql_affected_rows())
        {
            if (
$self["seeder"] == "yes")
                
$updateset[] = "seeders = seeders - 1";
            else
                
$updateset[] = "leechers = leechers - 1";
        }
    }
}
else
{
if (
$event == "completed")
{
mysql_query("UPDATE snatched SET  finished  = 'yes', complete_date = $dt WHERE torrentid = $torrentid AND userid = $userid");
$updateset[] = "times_completed = times_completed + 1";
}

    if (isset(
$self))
    {
    
$res_s mysql_query("SELECT uploaded, downloaded FROM snatched WHERE torrentid = $torrentid AND userid = $userid");
$row_s mysql_fetch_array($res_s);
$downloaded2 max(0$downloaded $self["downloaded"]);
$uploaded2 max(0$uploaded $self["uploaded"]);
mysql_query("UPDATE snatched SET uploaded = uploaded + $uploaded2, port = $port, agent= " sqlesc($agent) . ", last_action = $dt WHERE torrentid = $torrentid AND userid = $userid");
mysql_query("UPDATE snatched SET downloaded = downloaded + $downloaded2 WHERE torrentid = $torrentid AND userid = $userid");
        
mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder'"
            
. ($seeder == "yes" && $self["seeder"] != $seeder ", finishedat = " time() : "") . " WHERE $selfwhere");
        if (
mysql_affected_rows() && $self["seeder"] != $seeder)
        {
            if (
$seeder == "yes")
            {
                
$updateset[] = "seeders = seeders + 1";
                
$updateset[] = "leechers = leechers - 1";
            }
            else
            {
                
$updateset[] = "seeders = seeders - 1";
                
$updateset[] = "leechers = leechers + 1";
            }
        }
    }
    else
    {
    
           if (
$az["parked"] == "yes")
err("Error, your account is parked! Please read the FAQ!");
    
        if (
portblacklisted($port))
            
err("Port $port is blacklisted.");
        else
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }
        
$res1_s mysql_query("SELECT torrentid, userid FROM snatched WHERE torrentid = $torrentid AND userid = $userid") or err('Tracker error (120)');
$row1_s mysql_fetch_assoc($res1_s);
if (!
$row1_s)
mysql_query("INSERT INTO snatched (torrentid, userid, port, start_date, agent,ip,peer_id) VALUES ($torrentid$userid$port$dt, " sqlesc($agent) . "," sqlesc($ip) . "," sqlesc($peer_id) . ")");
        
$ret mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset, passkey) VALUES ('$connectable', $torrentid, " sqlesc($peer_id) . ", " sqlesc($ip) . ", $port$uploaded$downloaded$left, NOW(), NOW(), '$seeder', $userid, " sqlesc($agent) . ", $uploaded$downloaded, " sqlesc($passkey) . ")");
        if (
$ret)
        {
            if (
$seeder == "yes")
                
$updateset[] = "seeders = seeders + 1";
            else
                
$updateset[] = "leechers = leechers + 1";
        }
    }
}

if (
$seeder == "yes")
{
    if (
$torrent["banned"] != "yes")
        
$updateset[] = "visible = 'yes'";
    
$updateset[] = "last_action = NOW()";
}

if (
count($updateset))
    
mysql_query("UPDATE torrents SET " join(","$updateset) . " WHERE id = $torrentid");

benc_resp_raw($resp);


?>
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #14  
Old 20th March 2012, 03:50
ZenoX ZenoX is offline
Senior Member
 
Join Date: Jul 2009
P2P
Posts: 19
Default
ahh crap, it works again with the passkey in the announce of the torrent. But if i remove the passkey so its /announce.php it say's invalid passkey again :(

lol and i know, i can give the url to the site, but i'd of probably changed over by the time you checked.
Reply With Quote
  #15  
Old 20th March 2012, 03:57
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
PHP Code:
<?
$free 
false;
$double false;
ob_start("ob_gzhandler");

require_once(
"include/bittorrent.php");
require_once(
"include/benc.php");



function 
err($msg)
{
    
benc_resp(array("failure reason" => array(type => "string"value => $msg)));
    exit();
}

function 
benc_resp($d)
{
    
benc_resp_raw(benc(array(type => "dictionary"value => $d)));
}

function 
benc_resp_raw($x)
{
    
header("Content-Type: text/plain");
    
header("Pragma: no-cache");
    print(
$x);
}

foreach (array(
"info_hash","peer_id","ip","event","passkey") as $x)

if(isset(
$_GET[$x]))$GLOBALS[$x] = $_GET[$x];


if (!isset(
$GLOBALS['passkey'])) $GLOBALS['passkey'] = '!';



foreach (array(
"port","downloaded","uploaded","left") as $x)

$GLOBALS[$x] = $_GET[$x];



if (
strpos($passkey"?")) {

  
$tmp substr($passkeystrpos($passkey"?"));

$passkey substr($passkey0strpos($passkey"?"));

$tmpname substr($tmp1strpos($tmp"=")-1);

$tmpvalue substr($tmpstrpos($tmp"=")+1);

$GLOBALS[$tmpname] = $tmpvalue;

}



foreach (array(
"info_hash","peer_id","port","downloaded","uploaded","left") as $x)

if (!isset(
$x)) err("Missing key: $x");



foreach (array(
"info_hash","peer_id") as $x)

if (
strlen($GLOBALS[$x]) != 20err("Invalid $x (" strlen($GLOBALS[$x]) . " - " urlencode($GLOBALS[$x]) . ")");



if (
$passkey !='!' AND strlen($passkey) != 32err("Invalid passkey (" strlen($passkey) . " - $passkey)");



//if (empty($ip) || !preg_match('/^(d{1,3}.){3}d{1,3}$/s', $ip))

$ip getip();

$rsize 50;
foreach(array(
"num want""numwant""num_want") as $k)
{
    if (isset(
$_GET[$k]))
    {
        
$rsize $_GET[$k];
        break;
    }
}

$agent $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (ereg("^Mozilla\\/"$agent) || ereg("^Opera\\/"$agent) || ereg("^Links "$agent) || ereg("^Lynx\\/"$agent))
    
err("torrent not registered with this tracker");

if (!
$port || $port 0xffff)
    
err("invalid port");

if (!isset(
$event))
    
$event "";

$seeder = ($left == 0) ? "yes" "no";

dbconn(false);

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM users WHERE passkey=" sqlesc($passkey)));

if (
$valid[0] != 1err("Invalid passkey! Re-download the .torrent from $BASEURL");


$res mysql_query("SELECT id, banned, free, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " hash_where("info_hash"$info_hash));

$torrent mysql_fetch_assoc($res);
if (!
$torrent)
    
err("torrent not registered with this tracker");

$torrentid $torrent["id"];

//$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid";
$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid, UNIX_TIMESTAMP(last_action) AS ts";

$numpeers $torrent["numpeers"];
$limit "";
if (
$numpeers $rsize)
    
$limit "ORDER BY RAND() LIMIT $rsize";
$res mysql_query("SELECT $fields FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");

$resp "d" benc_str("interval") . "i" $announce_interval "e" benc_str("peers") . "l";
unset(
$self);
while (
$row mysql_fetch_assoc($res))
{
    
$row["peer_id"] = hash_pad($row["peer_id"]);

    if (
$row["peer_id"] === $peer_id)
    {
        
$userid $row["userid"];
        
$self $row;
        continue;
    }

    
$resp .= "d" .
        
benc_str("ip") . benc_str($row["ip"]) .
        
benc_str("peer id") . benc_str($row["peer_id"]) .
        
benc_str("port") . "i" $row["port"] . "e" .
        
"e";
}

$resp .= "ee";

$selfwhere "torrent = $torrentid AND " hash_where("peer_id"$peer_id);

if (!isset(
$self))
{
    
$res mysql_query("SELECT $fields FROM peers WHERE $selfwhere");
    
$row mysql_fetch_assoc($res);
    if (
$row)
    {
        
$userid $row["userid"];
        
$self $row;
    }
}

//// Up/down stats ////////////////////////////////////////////////////////////


if (!isset($self))

{

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND passkey=" sqlesc($passkey)));

if (
$valid[0] >= && $seeder == 'no'err("Connection limit exceeded! You may only leech from one location at a time.");

if (
$valid[0] >= && $seeder == 'yes'err("Connection limit exceeded!");

    
$rz mysql_query("SELECT id, uploaded, downloaded, class, parked FROM users WHERE (ip='$ip' or passkey='$passkey') AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
    if (
$MEMBERSONLY && mysql_num_rows($rz) == 0)
    
err("Unknown passkey. Please redownload the torrent from $BASEURL.");
    
$az mysql_fetch_assoc($rz);
    
$userid $az["id"];

//    if ($left > 0 && $az["class"] < UC_VIP)
    
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!");
    }
}
else
{
    
    
// Get the last uploaded amount from user account for reference and store it in $last_up
    
$rst mysql_query("SELECT class, uploaded FROM users WHERE id = $userid") or err("Tracker error 5");
    
$art mysql_fetch_array($rst);
    
$last_up $art["uploaded"];
    
$class $art["class"];

    
$upthis max(0$uploaded $self["uploaded"]);
    
$downthis max(0$downloaded $self["downloaded"]);
    
    if (
$free)
        
$downthis 0;
    if (
$double)
        
$upthis *= 2;

 if (
$upthis || $downthis 0)
 
mysql_query("UPDATE users SET uploaded = uploaded + $upthis". ($torrent['free']=='no'?", downloaded = downloaded + $downthis ":' '). "WHERE id=$userid") or err("Tracker error 3");

// Initial sanity check xMB/s for 1 second
    
if($upthis 2097152)
    {
        
//Work out time difference
        
$endtime time();
        
$starttime $self['ts'];
        
$diff = ($endtime $starttime);
        
//Normalise to prevent divide by zero.
        
$rate = ($upthis / ($diff 1));
        
//Currently 2MB/s (2097152). Increase to 5MB/s (5242880) once finished testing.
        
if ($rate 2097152)
        {
            if (
$class UC_MODERATOR)
            {
                
$rate mksize($rate);
                
$client $agent;
                
$userip getip();

                
auto_enter_cheater($userid$rate$upthis$diff$torrentid$client$userip$last_up);
            }
        }
    }
}

/////////////////////Fix Increase ratio using Firefox //////////////////////
$headers getallheaders();
if (isset(
$headers["Cookie"]) || isset($headers["Accept-Language"]) || isset($headers["Accept-Charset"]))
err("Anti-Cheater= You cannot use this agent");
///////////////////end of fix//////////////////////




$dt gmtime() - 180;
$dt sqlesc(get_date_time($dt));
function 
portblacklisted($port)
{
    
// direct connect
    
if ($port >= 411 && $port <= 413) return true;

    
// bittorrent
    
if ($port >= 6881 && $port <= 6889) return true;

    
// kazaa
    
if ($port == 1214) return true;

    
// gnutella
    
if ($port >= 6346 && $port <= 6347) return true;

    
// emule
    
if ($port == 4662) return true;

    
// winmx
    
if ($port == 6699) return true;

    return 
false;
}

$updateset = array();

if (
$event == "stopped")
{
    if (isset(
$self))
    {
        
mysql_query("DELETE FROM peers WHERE $selfwhere");
        if (
mysql_affected_rows())
        {
            if (
$self["seeder"] == "yes")
                
$updateset[] = "seeders = seeders - 1";
            else
                
$updateset[] = "leechers = leechers - 1";
        }
    }
}
else
{
if (
$event == "completed")
{
mysql_query("UPDATE snatched SET  finished  = 'yes', complete_date = $dt WHERE torrentid = $torrentid AND userid = $userid");
$updateset[] = "times_completed = times_completed + 1";
}

    if (isset(
$self))
    {
    
$res_s mysql_query("SELECT uploaded, downloaded FROM snatched WHERE torrentid = $torrentid AND userid = $userid");
$row_s mysql_fetch_array($res_s);
$downloaded2 max(0$downloaded $self["downloaded"]);
$uploaded2 max(0$uploaded $self["uploaded"]);
mysql_query("UPDATE snatched SET uploaded = uploaded + $uploaded2, port = $port, agent= " sqlesc($agent) . ", last_action = $dt WHERE torrentid = $torrentid AND userid = $userid");
mysql_query("UPDATE snatched SET downloaded = downloaded + $downloaded2 WHERE torrentid = $torrentid AND userid = $userid");
        
mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder'"
            
. ($seeder == "yes" && $self["seeder"] != $seeder ", finishedat = " time() : "") . " WHERE $selfwhere");
        if (
mysql_affected_rows() && $self["seeder"] != $seeder)
        {
            if (
$seeder == "yes")
            {
                
$updateset[] = "seeders = seeders + 1";
                
$updateset[] = "leechers = leechers - 1";
            }
            else
            {
                
$updateset[] = "seeders = seeders - 1";
                
$updateset[] = "leechers = leechers + 1";
            }
        }
    }
    else
    {
    
           if (
$az["parked"] == "yes")
err("Error, your account is parked! Please read the FAQ!");
    
        if (
portblacklisted($port))
            
err("Port $port is blacklisted.");
        else
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }
        
$res1_s mysql_query("SELECT torrentid, userid FROM snatched WHERE torrentid = $torrentid AND userid = $userid") or err('Tracker error (120)');
$row1_s mysql_fetch_assoc($res1_s);
if (!
$row1_s)
mysql_query("INSERT INTO snatched (torrentid, userid, port, start_date, agent,ip,peer_id) VALUES ($torrentid$userid$port$dt, " sqlesc($agent) . "," sqlesc($ip) . "," sqlesc($peer_id) . ")");
        
$ret mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset, passkey) VALUES ('$connectable', $torrentid, " sqlesc($peer_id) . ", " sqlesc($ip) . ", $port$uploaded$downloaded$left, NOW(), NOW(), '$seeder', $userid, " sqlesc($agent) . ", $uploaded$downloaded, " sqlesc($passkey) . ")");
        if (
$ret)
        {
            if (
$seeder == "yes")
                
$updateset[] = "seeders = seeders + 1";
            else
                
$updateset[] = "leechers = leechers + 1";
        }
    }
}

if (
$seeder == "yes")
{
    if (
$torrent["banned"] != "yes")
        
$updateset[] = "visible = 'yes'";
    
$updateset[] = "last_action = NOW()";
}

if (
count($updateset))
    
mysql_query("UPDATE torrents SET " join(","$updateset) . " WHERE id = $torrentid");

benc_resp_raw($resp);


?>
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #16  
Old 20th March 2012, 04:00
ZenoX ZenoX is offline
Senior Member
 
Join Date: Jul 2009
P2P
Posts: 19
Default
The dreaded Failure: Invalid Info Hash (21) has returned :(

Also have you heard of a mod where you are able to add a seedbox IP into userdetails.php and that is added as a second IP in the database? I've had alot of members say a few sites do it that way. I've never found the mod for it though..

Thanks
Reply With Quote
  #17  
Old 20th March 2012, 04:09
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
Quote:
Originally Posted by ZenoX View Post
The dreaded Failure: Invalid Info Hash (21) has returned :(

Also have you heard of a mod where you are able to add a seedbox IP into userdetails.php and that is added as a second IP in the database? I've had alot of members say a few sites do it that way. I've never found the mod for it though..

Thanks
as for the info hash thing give it a minute and try again

as for the mod only tracker I know that has it by default is phpMyBitTorrent
and I've not seen a mod for it
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #18  
Old 20th March 2012, 04:14
ZenoX ZenoX is offline
Senior Member
 
Join Date: Jul 2009
P2P
Posts: 19
Default
I reset my passkey and that fixed the info hash error. But when i removed the passkey from the torrent file so it's /announce.php it said "Failure: invalid passkey, please re-download etc" again :(

And ahh ok, is there no way to rip mods from that for TBDev or is that alot of work?
Reply With Quote
  #19  
Old 20th March 2012, 04:26
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
sorry im not going to do that mod but I think this should be it as far as your announce goes

PHP Code:
<?
$free 
false;
$double false;
ob_start("ob_gzhandler");

require_once(
"include/bittorrent.php");
require_once(
"include/benc.php");



function 
err($msg)
{
    
benc_resp(array("failure reason" => array(type => "string"value => $msg)));
    exit();
}

function 
benc_resp($d)
{
    
benc_resp_raw(benc(array(type => "dictionary"value => $d)));
}

function 
benc_resp_raw($x)
{
    
header("Content-Type: text/plain");
    
header("Pragma: no-cache");
    print(
$x);
}

foreach (array(
"info_hash","peer_id","ip","event","passkey") as $x)

if(isset(
$_GET[$x]))$GLOBALS[$x] = $_GET[$x];


if (!isset(
$GLOBALS['passkey'])) $passkey '';



foreach (array(
"port","downloaded","uploaded","left") as $x)

$GLOBALS[$x] = $_GET[$x];



if (
strpos($passkey"?")) {

  
$tmp substr($passkeystrpos($passkey"?"));

$passkey substr($passkey0strpos($passkey"?"));

$tmpname substr($tmp1strpos($tmp"=")-1);

$tmpvalue substr($tmpstrpos($tmp"=")+1);

$GLOBALS[$tmpname] = $tmpvalue;

}



foreach (array(
"info_hash","peer_id","port","downloaded","uploaded","left") as $x)

if (!isset(
$x)) err("Missing key: $x");



foreach (array(
"info_hash","peer_id") as $x)

if (
strlen($GLOBALS[$x]) != 20err("Invalid $x (" strlen($GLOBALS[$x]) . " - " urlencode($GLOBALS[$x]) . ")");


if (
$passkey !='' ){
if (
strlen($passkey) != 32err("Invalid passkey (" strlen($passkey) . " - $passkey)");
}



//if (empty($ip) || !preg_match('/^(d{1,3}.){3}d{1,3}$/s', $ip))

$ip getip();

$rsize 50;
foreach(array(
"num want""numwant""num_want") as $k)
{
    if (isset(
$_GET[$k]))
    {
        
$rsize $_GET[$k];
        break;
    }
}

$agent $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (ereg("^Mozilla\\/"$agent) || ereg("^Opera\\/"$agent) || ereg("^Links "$agent) || ereg("^Lynx\\/"$agent))
    
err("torrent not registered with this tracker");

if (!
$port || $port 0xffff)
    
err("invalid port");

if (!isset(
$event))
    
$event "";

$seeder = ($left == 0) ? "yes" "no";

dbconn(false);

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM users WHERE passkey=" sqlesc($passkey)));

if (
$valid[0] != 1err("Invalid passkey! Re-download the .torrent from $BASEURL");


$res mysql_query("SELECT id, banned, free, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " hash_where("info_hash"$info_hash));

$torrent mysql_fetch_assoc($res);
if (!
$torrent)
    
err("torrent not registered with this tracker");

$torrentid $torrent["id"];

//$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid";
$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid, UNIX_TIMESTAMP(last_action) AS ts";

$numpeers $torrent["numpeers"];
$limit "";
if (
$numpeers $rsize)
    
$limit "ORDER BY RAND() LIMIT $rsize";
$res mysql_query("SELECT $fields FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");

$resp "d" benc_str("interval") . "i" $announce_interval "e" benc_str("peers") . "l";
unset(
$self);
while (
$row mysql_fetch_assoc($res))
{
    
$row["peer_id"] = hash_pad($row["peer_id"]);

    if (
$row["peer_id"] === $peer_id)
    {
        
$userid $row["userid"];
        
$self $row;
        continue;
    }

    
$resp .= "d" .
        
benc_str("ip") . benc_str($row["ip"]) .
        
benc_str("peer id") . benc_str($row["peer_id"]) .
        
benc_str("port") . "i" $row["port"] . "e" .
        
"e";
}

$resp .= "ee";

$selfwhere "torrent = $torrentid AND " hash_where("peer_id"$peer_id);

if (!isset(
$self))
{
    
$res mysql_query("SELECT $fields FROM peers WHERE $selfwhere");
    
$row mysql_fetch_assoc($res);
    if (
$row)
    {
        
$userid $row["userid"];
        
$self $row;
    }
}

//// Up/down stats ////////////////////////////////////////////////////////////


if (!isset($self))

{

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND passkey=" sqlesc($passkey)));

if (
$valid[0] >= && $seeder == 'no'err("Connection limit exceeded! You may only leech from one location at a time.");

if (
$valid[0] >= && $seeder == 'yes'err("Connection limit exceeded!");

    
$rz mysql_query("SELECT id, uploaded, downloaded, class, parked FROM users WHERE (ip='$ip' or passkey='$passkey') AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
    if (
$MEMBERSONLY && mysql_num_rows($rz) == 0)
    
err("Unknown passkey. Please redownload the torrent from $BASEURL.");
    
$az mysql_fetch_assoc($rz);
    
$userid $az["id"];

//    if ($left > 0 && $az["class"] < UC_VIP)
    
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!");
    }
}
else
{
    
    
// Get the last uploaded amount from user account for reference and store it in $last_up
    
$rst mysql_query("SELECT class, uploaded FROM users WHERE id = $userid") or err("Tracker error 5");
    
$art mysql_fetch_array($rst);
    
$last_up $art["uploaded"];
    
$class $art["class"];

    
$upthis max(0$uploaded $self["uploaded"]);
    
$downthis max(0$downloaded $self["downloaded"]);
    
    if (
$free)
        
$downthis 0;
    if (
$double)
        
$upthis *= 2;

 if (
$upthis || $downthis 0)
 
mysql_query("UPDATE users SET uploaded = uploaded + $upthis". ($torrent['free']=='no'?", downloaded = downloaded + $downthis ":' '). "WHERE id=$userid") or err("Tracker error 3");

// Initial sanity check xMB/s for 1 second
    
if($upthis 2097152)
    {
        
//Work out time difference
        
$endtime time();
        
$starttime $self['ts'];
        
$diff = ($endtime $starttime);
        
//Normalise to prevent divide by zero.
        
$rate = ($upthis / ($diff 1));
        
//Currently 2MB/s (2097152). Increase to 5MB/s (5242880) once finished testing.
        
if ($rate 2097152)
        {
            if (
$class UC_MODERATOR)
            {
                
$rate mksize($rate);
                
$client $agent;
                
$userip getip();

                
auto_enter_cheater($userid$rate$upthis$diff$torrentid$client$userip$last_up);
            }
        }
    }
}

/////////////////////Fix Increase ratio using Firefox //////////////////////
$headers getallheaders();
if (isset(
$headers["Cookie"]) || isset($headers["Accept-Language"]) || isset($headers["Accept-Charset"]))
err("Anti-Cheater= You cannot use this agent");
///////////////////end of fix//////////////////////




$dt gmtime() - 180;
$dt sqlesc(get_date_time($dt));
function 
portblacklisted($port)
{
    
// direct connect
    
if ($port >= 411 && $port <= 413) return true;

    
// bittorrent
    
if ($port >= 6881 && $port <= 6889) return true;

    
// kazaa
    
if ($port == 1214) return true;

    
// gnutella
    
if ($port >= 6346 && $port <= 6347) return true;

    
// emule
    
if ($port == 4662) return true;

    
// winmx
    
if ($port == 6699) return true;

    return 
false;
}

$updateset = array();

if (
$event == "stopped")
{
    if (isset(
$self))
    {
        
mysql_query("DELETE FROM peers WHERE $selfwhere");
        if (
mysql_affected_rows())
        {
            if (
$self["seeder"] == "yes")
                
$updateset[] = "seeders = seeders - 1";
            else
                
$updateset[] = "leechers = leechers - 1";
        }
    }
}
else
{
if (
$event == "completed")
{
mysql_query("UPDATE snatched SET  finished  = 'yes', complete_date = $dt WHERE torrentid = $torrentid AND userid = $userid");
$updateset[] = "times_completed = times_completed + 1";
}

    if (isset(
$self))
    {
    
$res_s mysql_query("SELECT uploaded, downloaded FROM snatched WHERE torrentid = $torrentid AND userid = $userid");
$row_s mysql_fetch_array($res_s);
$downloaded2 max(0$downloaded $self["downloaded"]);
$uploaded2 max(0$uploaded $self["uploaded"]);
mysql_query("UPDATE snatched SET uploaded = uploaded + $uploaded2, port = $port, agent= " sqlesc($agent) . ", last_action = $dt WHERE torrentid = $torrentid AND userid = $userid");
mysql_query("UPDATE snatched SET downloaded = downloaded + $downloaded2 WHERE torrentid = $torrentid AND userid = $userid");
        
mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder'"
            
. ($seeder == "yes" && $self["seeder"] != $seeder ", finishedat = " time() : "") . " WHERE $selfwhere");
        if (
mysql_affected_rows() && $self["seeder"] != $seeder)
        {
            if (
$seeder == "yes")
            {
                
$updateset[] = "seeders = seeders + 1";
                
$updateset[] = "leechers = leechers - 1";
            }
            else
            {
                
$updateset[] = "seeders = seeders - 1";
                
$updateset[] = "leechers = leechers + 1";
            }
        }
    }
    else
    {
    
           if (
$az["parked"] == "yes")
err("Error, your account is parked! Please read the FAQ!");
    
        if (
portblacklisted($port))
            
err("Port $port is blacklisted.");
        else
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }
        
$res1_s mysql_query("SELECT torrentid, userid FROM snatched WHERE torrentid = $torrentid AND userid = $userid") or err('Tracker error (120)');
$row1_s mysql_fetch_assoc($res1_s);
if (!
$row1_s)
mysql_query("INSERT INTO snatched (torrentid, userid, port, start_date, agent,ip,peer_id) VALUES ($torrentid$userid$port$dt, " sqlesc($agent) . "," sqlesc($ip) . "," sqlesc($peer_id) . ")");
        
$ret mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset, passkey) VALUES ('$connectable', $torrentid, " sqlesc($peer_id) . ", " sqlesc($ip) . ", $port$uploaded$downloaded$left, NOW(), NOW(), '$seeder', $userid, " sqlesc($agent) . ", $uploaded$downloaded, " sqlesc($passkey) . ")");
        if (
$ret)
        {
            if (
$seeder == "yes")
                
$updateset[] = "seeders = seeders + 1";
            else
                
$updateset[] = "leechers = leechers + 1";
        }
    }
}

if (
$seeder == "yes")
{
    if (
$torrent["banned"] != "yes")
        
$updateset[] = "visible = 'yes'";
    
$updateset[] = "last_action = NOW()";
}

if (
count($updateset))
    
mysql_query("UPDATE torrents SET " join(","$updateset) . " WHERE id = $torrentid");

benc_resp_raw($resp);


?>
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #20  
Old 20th March 2012, 04:29
ZenoX ZenoX is offline
Senior Member
 
Join Date: Jul 2009
P2P
Posts: 19
Default
Ohh no i wasn't asking you to do it, was just curious :)

That worked again with the passkey, but said invalid passkey when just /announce.php on the torrent >.<

Thanks
Reply With Quote
Reply

Tags
account , adding , address , ip , member , seedbox

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 10:19. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.