Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Community Cafe (http://www.bvlist.com/forumdisplay.php?f=18)
-   -   vBulletin Torrent Tracker (http://www.bvlist.com/showthread.php?t=1248)

TheArcadeMaster 23rd October 2008 19:26

vBulletin Torrent Tracker
 
i just install this all seems to be working execpt when u create ur torrent and upload it all i keep getting is a damm 406 error in utorrent anybody any ideas thanks

djlee 24th October 2008 07:51

either a problem with upgraded server software or more commonly its a bit of bad code in announce

TheArcadeMaster 24th October 2008 09:34

heres the announce from vbulliten
 
any ideas anyone

PHP Code:

<?php
/**
 * vBulletin Torrent Tracker 3 PHP v1.1 SVN
 * Coded by Toolmanwill
 **/ 
 
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ######################### REQUIRE BACK-END ############################
require_once('includes/config.php');

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''announce');
define('NO_REGISTER_GLOBALS'1);
define('TABLE_PREFIX'$config['Database']['tableprefix']);

// ############################ FUNCTIONS ################################

function err($string)
{
    echo 
'd14:failure reason'.strlen($string).':'.$string.'e';
    exit();
}

function 
detect_client($peer_id)
{
// Last updated on 03/23/2006 based on BitTorrentSpecification - TheoryOrg

if (substr($peer_id,0,3) == "XBT")
    return 
"XBT Client ".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,4) == "exbc")
    return 
"BitComet";
else if (
substr($peer_id,0,2) == "OP")
    return 
"Opera 8 build".substr($peer_id,2,4);
else if (
substr($peer_id,0,3) == "-AZ")
    return 
"Azureus ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-BB")
    return 
"BitBuddy".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-CT")
    return 
"CTorrent ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};    
else if (
substr($peer_id,0,3) == "-MT")
    return 
"MoonlightTorrent ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-LT")
    return 
"Libtorrent ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-BX")
    return 
"Bittorrent X ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};    
else if (
substr($peer_id,0,3) == "-TS")
    return 
"TorrentStorm ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-UT")
    return 
"uTorrent ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-QT")
    return 
"QT 4 ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-BC")
    return 
"BitComet ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-BL")
    return 
"BitLord ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-SZ")
    return 
"Shareaza ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-RT")
    return 
"Retriever ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-LP")
    return 
"Lphant ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-TN")
    return 
"TorrentDotNet ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-SS")
    return 
"SwarmScope ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-XT")
    return 
"XanTorrent ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-BS")
    return 
"BTSlave ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-ZT")
    return 
"ZipTorrent ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};    
else if (
substr($peer_id,0,3) == "-AR")
    return 
"Artic ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-SB")
    return 
"Swiftbit ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-MP")
    return 
"MooPolice ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,3) == "-lt")
    return 
"libTorrent ".$peer_id{3}.".".$peer_id{4}.".".$peer_id{5}.".".$peer_id{6};
else if (
substr($peer_id,0,1) == "S" && is_int(substr($peer_id,1,3)))
    return 
"Shadow ".$peer_id{1}.".".$peer_id{2}.".".$peer_id{3};
else if (
substr($peer_id,0,1) == "U" && is_int(substr($peer_id,1,3)))
    return 
"UPnP NAT Bit Torrent ".$peer_id{1}.".".$peer_id{2}.".".$peer_id{3};
else if (
substr($peer_id,0,1) == "T"
return 
"BitTornado ".$peer_id{1}.".".$peer_id{2}.".".$peer_id{3};
else if (
substr($peer_id,0,1) == "O" && is_int(substr($peer_id,1,3)))
    return 
"Osprey Permaseed ".$peer_id{1}.".".$peer_id{2}.".".$peer_id{3};
else if (
substr($peer_id,0,2) == "M4" || substr($peer_id,0,2) == "M3")
    return  
"Bittorrent ".str_replace("-",".",substr($peer_id,1,5));
else
    return 
"Unknown";

}

function 
hash_where($name$hash) {
    
$shhash preg_replace('/ *$/s'""$hash);
    return 
"(".$name." = '" $hash "' OR ".$name." = '" $shhash "')";
}

function 
not_hash_where($name$hash) {
    
$shhash preg_replace('/ *$/s'""$hash);
    return 
"(".$name." != '" $hash "' AND ".$name." != '" $shhash "')";
}

function 
benc_str($s) {
    return 
strlen($s) . ":".$s;
}

function 
hex2bin($hex)
{
        
$result '';
        for (
$i 0$i strlen($hex); $i += 2)
                
$result .= chr(hexdec(substr($hex,$i,2)));
        return 
$result;
}

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

header('Content-type: text/plain');
header('Pragma: no-cache');


// we rebuild the correct query string to be processed by the announce !
$query $_SERVER["QUERY_STRING"] ;

if (
strpos($query,"?info_hash") !== false)
{
    
header("Location: ".basename($_SERVER['PHP_SELF'])."?".str_replace("?info_hash","&info_hash",$query));
}


// this page can be requested only by bittorrent clients !
$agent $_SERVER["HTTP_USER_AGENT"];
if ( 
strpos($agent"Mozilla") === || strpos($agent"Opera") === 0|| strpos($agent"Links") === || strpos($agent"Lynx") === || strpos($agent"curl") === 0
    
err("You are not allowed to view this page with a browser"); 
    

/*
$_GET['info_hash'] = hex2bin('d728d5a3266e5e3099366833f1b63ff69188060b');
$_GET['ip'] = '83.10.10.10';
$_GET['passkey'] = '4bec6b05aee6dcd590c564b80d7be24a';
$_GET['port'] = rand(20, 120);
$_GET['uploaded'] = rand(20, 120000);
$_GET['downloaded'] = rand(20, 120000);
$_GET['peer_id'] = 'S588-----gqQ8TqDeqaY';
$_GET['left'] = 0; //rand(0, 3000000);
$_GET['event'] = 'started';
$_GET['numwant'] = 50;
$_GET['compact'] = 0;
*/



// we connect to the database

$link mysql_connect($config['MasterServer']['servername'], $config['MasterServer']['username'], $config['MasterServer']['password']);
if (!
$link) {
   
err ('VBTT 3.0: Database Error. Can\'t connect to database !');
}

// select the current db
$db_selected mysql_select_db($config['Database']['dbname'], $link);
if (!
$db_selected) {
   
err ('VBTT 3.0: Databse Error. Can\'t select database !');
}

// we parse the input of the client

$req "passkey:info_hash:peer_id:!ip:port:uploaded:downloaded:left:!event:compact";
foreach (
explode(":"$req) as $x)
{
    if (
$x[0] == "!")
    {
        
$x substr($x1);
        
$opt 1;
    }
    else
        
$opt 0;
        
    if (!isset(
$_GET[$x]))
    {
        if (!
$opt)
            
err("VBTT 3.0: Error, missing key ($x)");
            
        
$_GET[$x] = "";            
    }
    
    if (
get_magic_quotes_gpc())
    {
        
$GLOBALS[$x] = stripslashes($_GET[$x]);
    }
    else 
$GLOBALS[$x] = $_GET[$x];
}

/*if (strpos($passkey, "?")) {

    $tmp = substr($passkey, strpos($passkey, "?"));
    $passkey = substr($passkey, 0, strpos($passkey, "?"));
    $tmpname = substr($tmp, 1, strpos($tmp, "=")-1);
    $tmpvalue = substr($tmp, strpos($tmp, "=")+1);
    $GLOBALS[$tmpname] = $tmpvalue;

} */


$info_hash bin2hex($info_hash);

if (
strlen($info_hash) != 40)
{
    
err('VBTT 3.0: Invalid info_hash submitted value');
}

if (
strlen($passkey) != 32)
    
err("VBTT 3.0: Invalid Passkey");

// Some Checks

$ri mysql_query("SELECT username, allowtracker FROM " TABLE_PREFIX "user WHERE passkey='".$passkey."' LIMIT 1") or err("vBTT v3.0: ".mysql_error());
$rj mysql_fetch_array($ri);    
    
if (
$rj['allowtracker'] == 'no')
    
err("vBTT v3.0: ".$rj['username']." - You are BANNED from this tracker!!!");    

$rz mysql_query("SELECT userid FROM " TABLE_PREFIX "user WHERE passkey='".$passkey."' AND allowtracker='yes' LIMIT 1") or err("vBTT v3.0: ".mysql_error());
$az mysql_fetch_array($rz);

if (
$az['userid'] == '')
    
err("vBTT v3.0: This is not YOUR passkey!!! (".$passkey.")");


// we retrieve the user ip address

$ip $_SERVER['REMOTE_ADDR'];
$agent detect_client($peer_id);
$port $port;
$uploaded $uploaded;
$downloaded $downloaded;
$left $left;

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

if (!
$port || $port 0xffff)
    
err("VBTT 3.0: Invalid port");

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

// to be added in next beta
// check if the user is authorized on tracker and usergroup allowed on tracker


// Is peer already active on tracker ?

$updateset = array();

$res mysql_query("SELECT * FROM "TABLE_PREFIX ."peers WHERE passkey='".$passkey."' AND info_hash = '".addslashes($info_hash)."' AND " hash_where("peer_id"$peer_id) ." LIMIT 1") or err("VBTT 3.0: ".mysql_error());
$row mysql_fetch_array($res);
// peer is already active on tracker

if ($row
{
    
$self $row;
}
else
{
// we create the peer on the tracker for the given info_hash


        
        
if ($event != "stopped")
        {
            
$connectable "yes";
    
            
// comment this part if you experience slow down and connection problems to server
            /*
    
            $sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
            if (!$sockres)
                $connectable = "no";
            else
            {
                $connectable = "yes";
                @fclose($sockres);
            }
            
            */            

            
$ret mysql_query("INSERT INTO "TABLE_PREFIX ."peers ( passkey, connectable, info_hash, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, agent) VALUES ('".$passkey."','".$connectable."', '".addslashes($info_hash)."', '" mysql_escape_string($peer_id) . "', '" $ip "', ".$port.", ".$uploaded.", ".$downloaded.", ".$left.", NOW(), NOW(), '".$seeder."','".$agent."')") or err("VBTT 3.0: ".mysql_error()); 
    
            
    
            if (
$ret)
            {
    
                if (
$seeder == "yes")
    
                    
$updateset[] = "seeders = seeders + 1";
    
                else
    
                    
$updateset[] = "leechers = leechers + 1";
    
            }
        }    
}    



// we output the list of peers on the tracker

$fields "seeder, peer_id, ip, port, uploaded, downloaded, lastup, lastdown ,last_action";
$limit "ORDER BY RAND() LIMIT $rsize";
    
$res mysql_query("SELECT ".$fields." FROM "TABLE_PREFIX ."peers WHERE info_hash = '".addslashes($info_hash)."' AND ".not_hash_where("peer_id"$peer_id)." ".$limit) or err("VBTT 3.0: ".mysql_error());


if(
$_GET['compact'] != 1)
{
$resp "d" benc_str("interval") . "i1800e" benc_str("peers") . "l";
}
else
{
$resp "d" benc_str("interval") . "i1800e5:"."peers"  ;
}


$peer = array();
while (
$row mysql_fetch_array($res))
{
    if(
$_GET['compact'] != 1)
    {

        
$row["peer_id"] = str_pad($row["peer_id"],20);
    
        
$resp .= "d" .
            
benc_str("ip") . benc_str($row["ip"]) ;
            if (!
$_GET['no_peer_id']) {
                
$resp .= benc_str("peer id") . benc_str($row["peer_id"]);
            }
            
$resp .= benc_str("port") . "i" $row["port"] . "e" .
            
"e";
    }
    else
    {
        
$peer[] = pack('Nn'ip2long($row["ip"]), $row["port"]);
        
$peer_num++;    
    }
}



if (
$_GET['compact']!=1)
$resp .= "ee";
else
{
    for(
$i=0;$i<$peer_num;$i++)
        {
            
$o .= $peer[$i];
        }
 
$resp .= strlen($o) . ':' $o 'e' ;
}


// we update user stats

$selfwhere "passkey='".$passkey."' AND info_hash = '".addslashes($info_hash)."' AND " hash_where("peer_id"$peer_id) ." LIMIT 1";
 

$last_uploaded = isset($self['uploaded']) ? $self['uploaded'] : 0;
$last_downloaded = isset($self['downloaded']) ? $self['downloaded'] : 0;
$time= isset($self["last_action"]) ? (int)(strtotime"now" ) -  strtotime$self["last_action"] )) : ;
if (
$time >0)
{
    
$ulspeed abs($uploaded $last_uploaded) / $time;
    
$dlspeed abs($downloaded $last_downloaded) / $time;
}
else
{
    
$ulspeed 0;
    
$dlspeed 0;    
}

$diff_uploaded max($uploaded $last_uploaded,0);
$diff_downloaded max($downloaded $last_downloaded,0);



mysql_query("UPDATE " TABLE_PREFIX "user SET ulspeed = ".$ulspeed.", dlspeed = ".$dlspeed.", uploaded = uploaded + ".$diff_uploaded.", downloaded = downloaded + ".$diff_downloaded."  WHERE passkey='".$passkey."'") or err("VBTT 3.0: ".mysql_error()); 

// we update the peer stats
if ($event == "stopped")
{
        
mysql_query("DELETE FROM "TABLE_PREFIX ."peers WHERE ".$selfwhere) or err("VBTT 3.0: ".mysql_error());
        if (
mysql_affected_rows())
        {
            if (
$seeder == "yes")
                
$updateset[] = "seeders = seeders - 1";
            else
                
$updateset[] = "leechers = leechers - 1";
        }
}
else
{

        
    if (
$event == "completed")
    {    
            
$username mysql_query("SELECT userid FROM " TABLE_PREFIX "user WHERE passkey='".$passkey."'LIMIT 1");
            
$uname mysql_fetch_array($username);
        
$updateset[] = "completed = completed + 1";
        
$updateset[] = "completed_by = CONCAT(completed_by,';".$uname['userid']."')";
    }


    
mysql_query("UPDATE "TABLE_PREFIX"peers SET ip = '" $ip "',agent= '".$agent."' , port = ".$port.", uploaded = ".$uploaded.", downloaded = ".$downloaded.", lastup = ".$last_uploaded.", lastdown = ".$last_downloaded.", ulspeed = ".$ulspeed.", dlspeed= ".$dlspeed.", to_go = ".$left.", last_action = NOW(), seeder = '".$seeder."' WHERE ".$selfwhere) or err("VBTT 3.0: ".mysql_error());
    
    if (
$self["seeder"] != $seeder && isset($self["seeder"]) )
    {
        if (
$seeder == "yes")
        {
            
$updateset[] = "seeders = seeders + 1";
            
$updateset[] = "leechers = leechers - 1";
        }
        else
        {
            
$updateset[] = "seeders = seeders - 1";
            
$updateset[] = "leechers = leechers + 1";
        }
    }

}


if (
count($updateset))
    
mysql_query("UPDATE " TABLE_PREFIX "attachment SET " join(","$updateset) . " WHERE info_hash = '".addslashes($info_hash)."'") or err("VBTT 3.0: ".mysql_error());
 
echo 
$resp;

?>

PLEASE USE EITHER PHP OR CODE TAGS FOR LINES OF CODE


All times are GMT +2. The time now is 10:22.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.