Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
  #1  
Old 13th December 2013, 22:11
shubham9418 shubham9418 is offline
Member
 
Join Date: Dec 2013
India
Posts: 3
Red face invalid announce url! must be http://localhost/TB/announce.php
Upload failed!
invalid announce url! must be http://localhost/TB/announce.php

help please!!!!!!!

config.php
Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   http://www.tbdev.net
|   =============================================
|   svn: http://sourceforge.net/projects/tbdevnet/
|   Licence Info: GPL
+------------------------------------------------
|   $Date$
|   $Revision$
|   $Author$
|   $URL$
+------------------------------------------------
*/
error_reporting(E_ALL);

define('SQL_DEBUG', 2);

/* Compare php version for date/time stuff etc! */
	if (version_compare(PHP_VERSION, "5.1.0RC1", ">="))
		date_default_timezone_set('Europe/London');


define('TIME_NOW', time());

$TBDEV['time_adjust'] =  0;
$TBDEV['time_offset'] = '0'; 
$TBDEV['time_use_relative'] = 1;
$TBDEV['time_use_relative_format'] = '{--}, h:i A';
$TBDEV['time_joined'] = 'j-F y';
$TBDEV['time_short'] = 'jS F Y - h:i A';
$TBDEV['time_long'] = 'M j Y, h:i A';
$TBDEV['time_tiny'] = '';
$TBDEV['time_date'] = '';


// DB setup
// FYNNON FUCKWIT FRENCH RETARD
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "root";
$TBDEV['mysql_pass'] = "";
$TBDEV['mysql_db']   = "shubham";

// Cookie setup
$TBDEV['cookie_prefix']  = 'tbalpha_'; // This allows you to have multiple trackers, eg for demos, testing etc.
$TBDEV['cookie_path']    = '/TB'; // ATTENTION: You should never need this unless the above applies eg: /tbdev
$TBDEV['cookie_domain']  = ''; // set to eg: .somedomain.com or is subdomain set to: .sub.somedomain.com
                              
$TBDEV['site_online'] = 1;
$TBDEV['tracker_post_key'] = 'love';
$TBDEV['max_torrent_size'] = 1000000;
$TBDEV['announce_interval'] = 60 * 30;
$TBDEV['signup_timeout'] = 86400 * 3;
$TBDEV['minvotes'] = 1;
$TBDEV['max_dead_torrent_time'] = 6 * 3600;

// Max users on site
$TBDEV['maxusers'] = 5000; // LoL Who we kiddin' here?


if ( strtoupper( substr(PHP_OS, 0, 3) ) == 'WIN' )
  {
    $file_path = str_replace( "\\", "/", dirname(__FILE__) );
    $file_path = str_replace( "/include", "", $file_path );
  }
  else
  {
    $file_path = dirname(__FILE__);
    $file_path = str_replace( "/include", "", $file_path );
  }
  
define('ROOT_PATH', $file_path);
$TBDEV['torrent_dir'] = ROOT_PATH . '/torrents'; # must be writable for httpd user   

# the first one will be displayed on the pages
$TBDEV['announce_urls'] = array();
$TBDEV['announce_urls'][] = "http://localhost/TB/announce.php";
//$TBDEV['announce_urls'] = "http://localhost:2710/announce";
//$TBDEV['announce_urls'] = "http://localhost:83/announce.php";

if ($_SERVER["HTTP_HOST"] == "")
  $_SERVER["HTTP_HOST"] = $_SERVER["SERVER_NAME"];
  
$TBDEV['baseurl'] = "http://" . $_SERVER["HTTP_HOST"]."/TB";

/*
## DO NOT UNCOMMENT THIS: IT'S FOR LATER USE!
$host = getenv( 'SERVER_NAME' );
$script = getenv( 'SCRIPT_NAME' );
$script = str_replace( "\\", "/", $script );

  if( $host AND $script )
  {
    $script = str_replace( '/index.php', '', $script );

    $TBDEV['baseurl'] = "http://{$host}{$script}";
  }
*/

//set this to true to make this a tracker that only registered users may use
//$TBDEV['membersonly'] = 1; //deprecated no longer needed

//maximum number of peers (seeders+leechers) allowed before torrents starts to be deleted to make room...
//set this to something high if you don't require this feature
//$TBDEV['peerlimit'] = 50000; //deprecated. no longer used.

// Email for sender/return path.
$TBDEV['site_email'] = "coldfusion@localhost";

$TBDEV['site_name'] = "TBDEV.NET";

$TBDEV['language'] = 'en';
//charset
$TBDEV['char_set'] = 'UTF-8'; //also to be used site wide in meta tags
if (ini_get('default_charset') != $TBDEV['char_set']) {
ini_set('default_charset',$TBDEV['char_set']);
}
$TBDEV['msg_alert'] = 0; // saves a query when off

$TBDEV['autoclean_interval'] = 900;
$TBDEV['sql_error_log'] = ROOT_PATH.'/logs/sql_err_'.date("M_D_Y").'.log';
$TBDEV['pic_base_url'] = "./pic/";
$TBDEV['stylesheet'] = "./1.css";
$TBDEV['readpost_expiry'] = 14*86400; // 14 days
//set this to size of user avatars
$TBDEV['av_img_height'] = 100;
$TBDEV['av_img_width'] = 100;
$TBDEV['allowed_ext'] = array('image/gif', 'image/png', 'image/jpeg');
// Set this to the line break character sequence of your system
//$TBDEV['linebreak'] = "\r\n"; // not used at present.

define ('UC_USER', 0);
define ('UC_POWER_USER', 1);
define ('UC_VIP', 2);
define ('UC_UPLOADER', 3);
define ('UC_MODERATOR', 4);
define ('UC_ADMINISTRATOR', 5);
define ('UC_SYSOP', 6);

//Do not modify -- versioning system
//This will help identify code for support issues at tbdev.net
define ('TBVERSION','TBDev_2009_svn');

?>

announce.php
Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   http://www.tbdev.net
|   =============================================
|   svn: http://sourceforge.net/projects/tbdevnet/
|   Licence Info: GPL
+------------------------------------------------
|   $Date$
|   $Revision$
|   $Author$
|   $URL$
+------------------------------------------------
*/error_reporting(0);
////////////////// GLOBAL VARIABLES ////////////////////////////	
$TBDEV['baseurl'] = 'http://localhost/TB';
$TBDEV['announce_interval'] = 60 * 30;
$TBDEV['user_ratios'] = 0;
$TBDEV['connectable_check'] = 0;
define ('UC_VIP', 2);
// DB setup
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "root";
$TBDEV['mysql_pass'] = "";
$TBDEV['mysql_db']   = "shubham";
////////////////// GLOBAL VARIABLES ////////////////////////////

// DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!

$agent = $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (
    ereg("^Mozilla\\/", $agent) || 
    ereg("^Opera\\/", $agent) || 
    ereg("^Links ", $agent) || 
    ereg("^Lynx\\/", $agent) || 
    isset($_SERVER['HTTP_COOKIE']) || 
    isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) || 
    isset($_SERVER['HTTP_ACCEPT_CHARSET'])
    )
    err("torrent not registered with this tracker CODE 1");

/////////////////////// FUNCTION DEFS ///////////////////////////////////
function dbconn()
{
    global $TBDEV;

    if (!@mysql_connect($TBDEV['mysql_host'], $TBDEV['mysql_user'], $TBDEV['mysql_pass']))
    {
	  err('Please call back later');
    }
    mysql_select_db($TBDEV['mysql_db']) or err('Please call back later');
}

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" );

    if ( $_SERVER['HTTP_ACCEPT_ENCODING'] == 'gzip' )
    {
        header( "Content-Encoding: gzip" );
        echo gzencode( $x, 9, FORCE_GZIP );
    }
    else
        echo $x ;
}

function benc($obj) {
	if (!is_array($obj) || !isset($obj["type"]) || !isset($obj["value"]))
		return;
	$c = $obj["value"];
	switch ($obj["type"]) {
		case "string":
			return benc_str($c);
		case "integer":
			return benc_int($c);
		case "list":
			return benc_list($c);
		case "dictionary":
			return benc_dict($c);
		default:
			return;
	}
}

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

function benc_int($i) {
	return "i" . $i . "e";
}

function benc_list($a) {
	$s = "l";
	foreach ($a as $e) {
		$s .= benc($e);
	}
	$s .= "e";
	return $s;
}

function benc_dict($d) {
	$s = "d";
	$keys = array_keys($d);
	sort($keys);
	foreach ($keys as $k) {
		$v = $d[$k];
		$s .= benc_str($k);
		$s .= benc($v);
	}
	$s .= "e";
	return $s;
}

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

function sqlesc($x) {
    return "'".mysql_real_escape_string($x)."'";
}

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;
}
/////////////////////// FUNCTION DEFS END ///////////////////////////////

$parts = array();
$pattern = '[0-9a-fA-F]{32}';
if( !isset($_GET['passkey']) OR !ereg($pattern, $_GET['passkey'], $parts) ) 
		err("Invalid Passkey");
	else
		$GLOBALS['passkey'] = $parts[0];
		
foreach (array("info_hash","peer_id","event","ip","localip") as $x) 
{
if(isset($_GET["$x"]))
$GLOBALS[$x] = "" . $_GET[$x];
}

foreach (array("port","downloaded","uploaded","left") as $x)
{
$GLOBALS[$x] = 0 + $_GET[$x];
}


foreach (array("passkey","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]) != 20) err("Invalid $x (" . strlen($GLOBALS[$x]) . " - " . urlencode($GLOBALS[$x]) . ")");

unset($x);

$info_hash = bin2hex($info_hash);

$ip = $_SERVER['REMOTE_ADDR'];

$port = 0 + $port;
$downloaded = 0 + $downloaded;
$uploaded = 0 + $uploaded;
$left = 0 + $left;

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


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

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

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

dbconn();


$user_query = mysql_query("SELECT id, uploaded, downloaded, class, enabled FROM users WHERE passkey=".sqlesc($passkey)) or err("Tracker error 2");

if ( mysql_num_rows($user_query) != 1 )

 err("Unknown passkey. Please redownload the torrent from {$TBDEV['baseurl']}.");
 
	$user = mysql_fetch_assoc($user_query);
	if( $user['enabled'] == 'no' ) err('Permission denied, you\'re not enabled');
	
	
$res = mysql_query("SELECT id, banned, seeders + leechers AS numpeers, added AS ts FROM torrents WHERE info_hash = " .sqlesc($info_hash));//" . hash_where("info_hash", $info_hash));

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

$torrentid = $torrent["id"];

$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid";

$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");

//////////////////// START NEW COMPACT MODE/////////////////////////////

if($_GET['compact'] != 1)

{

$resp = "d" . benc_str("interval") . "i" . $TBDEV['announce_interval'] . "e" . benc_str("peers") . "l";

}

else

{

$resp = "d" . benc_str("interval") . "i" . $TBDEV['announce_interval'] ."e" . benc_str("min interval") . "i" . 300 ."e5:"."peers" ;

}

$peer = array();

$peer_num = 0;
while ($row = mysql_fetch_assoc($res))

{

    if($_GET['compact'] != 1)

{



$row["peer_id"] = str_pad($row["peer_id"], 20);



if ($row["peer_id"] === $peer_id)

{

 $self = $row;

 continue;

}



$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_ip = explode('.', $row["ip"]);

$peer_ip = pack("C*", $peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]);

$peer_port = pack("n*", (int)$row["port"]);

$time = intval((time() % 7680) / 60);

if($_GET['left'] == 0)

{

$time += 128;

}

$time = pack("C", $time);



   $peer[] = $time . $peer_ip . $peer_port;

$peer_num++;


      }

}



if ($_GET['compact']!=1)

$resp .= "ee";

else

{
$o = "";
for($i=0;$i<$peer_num;$i++)

 {

  $o .= substr($peer[$i], 1, 6);

 }

$resp .= strlen($o) . ':' . $o . 'e';

}

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

///////////////////////////// END NEW COMPACT MODE////////////////////////////////



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] >= 1 && $seeder == 'no') err("Connection limit exceeded! You may only leech from one location at a time.");

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


	if ($left > 0 && $user['class'] < UC_VIP && $TBDEV['user_ratios'])
	{
		$gigs = $user["uploaded"] / (1024*1024*1024);
		$elapsed = floor((time() - $torrent["ts"]) / 3600);
		$ratio = (($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1);
		if ($ratio < 0.5 || $gigs < 5) $wait = 48;
		elseif ($ratio < 0.65 || $gigs < 6.5) $wait = 24;
		elseif ($ratio < 0.8 || $gigs < 8) $wait = 12;
		elseif ($ratio < 0.95 || $gigs < 9.5) $wait = 6;
		else $wait = 0;
		if ($elapsed < $wait)
				err("Not authorized (" . ($wait - $elapsed) . "h) - READ THE FAQ!");
	}
}
else
{
	$upthis = max(0, $uploaded - $self["uploaded"]);
	$downthis = max(0, $downloaded - $self["downloaded"]);

	if ($upthis > 0 || $downthis > 0)
		mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=".$user['id']) or err("Tracker error 3");
}

///////////////////////////////////////////////////////////////////////////////


$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")
		$updateset[] = "times_completed = times_completed + 1";

	if (isset($self))
	{
		mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = ".time().", 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 ($event != "started")
			err("Peer not found. ".$passkey." Restart the torrent.");

		if (portblacklisted($port))
		{
			err("Port $port is blacklisted.");
		}
		elseif ( $TBDEV['connectable_check'] )
		{
			$sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
			if (!$sockres)
				$connectable = "no";
			else
			{
				$connectable = "yes";
				@fclose($sockres);
			}
		}
		else
		{
      $connectable = 'yes';
		}

		$ret = mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, passkey) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", $port, $uploaded, $downloaded, $left, ".time().", ".time().", '$seeder', {$user['id']}, " . sqlesc($agent) . "," . 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 = ".time();
}

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

benc_resp_raw($resp);



?>
Attached Files
File Type: php announce.php (11.5 KB, 6 views)
File Type: php config.php (4.7 KB, 5 views)
Reply With Quote
  #2  
Old 13th December 2013, 22:50
Krypto Krypto is offline
Retired from BVList
 
Join Date: Jan 2008
P2P
Posts: 510
Red face
1. Make an Introduction in the appropriate section.
2. Use the Search, as this has been covered before.
Reply With Quote
  #3  
Old 14th December 2013, 10:18
firefly007's Avatar
firefly007 firefly007 is offline
SUPPORT GURU
 
Join Date: Jun 2010
P2P
Posts: 721
Default
Quote:
Originally Posted by shubham9418 View Post
Upload failed!
invalid announce url! must be http://localhost/TB/announce.php

help please!!!!!!!
1) It would be nice if you introduced your self!!

2) Look in your config and remove TB from http://localhost/TB/announce.php/ so it will look like this http://localhost/announce.php
__________________




Please Support Majority Report


You can contact me on Skype live:phesadent.elect but please let me know first.


If you are ever need me desperately then please email me at dan.oak44@gmail.com and I will contact u within a week.


Due to free time I'm able to help interested member's with their tracker.

Please Note!
Depending on your requests I will charge you for my assistance for Tracker installs and mods.
All my mods are custom and prices will very depending on the request.
I'm able to install any tracker and mods including themes.

Please PM me

Reply With Quote
  #4  
Old 14th December 2013, 12:58
Birkoff's Avatar
Birkoff Birkoff is offline
Senior Member
 
Join Date: Aug 2010
P2P
Posts: 24
Thumbs up Like this ?
Config.php
PHP Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   http://www.tbdev.net
|   =============================================
|   svn: http://sourceforge.net/projects/tbdevnet/
|   Licence Info: GPL
+------------------------------------------------
|   $Date$
|   $Revision$
|   $Author$
|   $URL$
+------------------------------------------------
*/
error_reporting(E_ALL);

define('SQL_DEBUG'2);

/* Compare php version for date/time stuff etc! */
    
if (version_compare(PHP_VERSION"5.1.0RC1"">="))
        
date_default_timezone_set('Europe/London');


define('TIME_NOW'time());

$TBDEV['time_adjust'] =  0;
$TBDEV['time_offset'] = '0'
$TBDEV['time_use_relative'] = 1;
$TBDEV['time_use_relative_format'] = '{--}, h:i A';
$TBDEV['time_joined'] = 'j-F y';
$TBDEV['time_short'] = 'jS F Y - h:i A';
$TBDEV['time_long'] = 'M j Y, h:i A';
$TBDEV['time_tiny'] = '';
$TBDEV['time_date'] = '';


// DB setup
// FYNNON FUCKWIT FRENCH RETARD
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "youruser";
$TBDEV['mysql_pass'] = "yourpass";
$TBDEV['mysql_db']   = "yourdb";

// Cookie setup
$TBDEV['cookie_prefix']  = ''// This allows you to have multiple trackers, eg for demos, testing etc.
$TBDEV['cookie_path']    = ''// ATTENTION: You should never need this unless the above applies eg: /tbdev
$TBDEV['cookie_domain']  = ''// set to eg: .somedomain.com or is subdomain set to: .sub.somedomain.com
                              
$TBDEV['site_online'] = 1;
$TBDEV['tracker_post_key'] = 'love';
$TBDEV['max_torrent_size'] = 1000000;
$TBDEV['announce_interval'] = 60 30;
$TBDEV['signup_timeout'] = 86400 3;
$TBDEV['minvotes'] = 1;
$TBDEV['max_dead_torrent_time'] = 3600;

// Max users on site
$TBDEV['maxusers'] = 5000// LoL Who we kiddin' here?


if ( strtouppersubstr(PHP_OS03) ) == 'WIN' )
  {
    
$file_path str_replace"\\""/"dirname(__FILE__) );
    
$file_path str_replace"/include"""$file_path );
  }
  else
  {
    
$file_path dirname(__FILE__);
    
$file_path str_replace"/include"""$file_path );
  }
  
define('ROOT_PATH'$file_path);
$TBDEV['torrent_dir'] = ROOT_PATH '/torrents'# must be writable for httpd user   

# the first one will be displayed on the pages
$TBDEV['announce_urls'] = array();
$TBDEV['announce_urls'][] = "http://yoursitename/announce.php";
//$TBDEV['announce_urls'] = "http://localhost:2710/announce";
//$TBDEV['announce_urls'] = "http://localhost:83/announce.php";

if ($_SERVER["HTTP_HOST"] == "")
  
$_SERVER["HTTP_HOST"] = $_SERVER["SERVER_NAME"];
  
$TBDEV['baseurl'] = "http://" $_SERVER["HTTP_HOST"]."/TB";

/*
## DO NOT UNCOMMENT THIS: IT'S FOR LATER USE!
$host = getenv( 'SERVER_NAME' );
$script = getenv( 'SCRIPT_NAME' );
$script = str_replace( "\\", "/", $script );

  if( $host AND $script )
  {
    $script = str_replace( '/index.php', '', $script );

    $TBDEV['baseurl'] = "http://{$host}{$script}";
  }
*/

//set this to true to make this a tracker that only registered users may use
//$TBDEV['membersonly'] = 1; //deprecated no longer needed

//maximum number of peers (seeders+leechers) allowed before torrents starts to be deleted to make room...
//set this to something high if you don't require this feature
//$TBDEV['peerlimit'] = 50000; //deprecated. no longer used.

// Email for sender/return path.
$TBDEV['site_email'] = "coldfusion@localhost";

$TBDEV['site_name'] = "Yoursitename";

$TBDEV['language'] = 'en';
//charset
$TBDEV['char_set'] = 'UTF-8'//also to be used site wide in meta tags
if (ini_get('default_charset') != $TBDEV['char_set']) {
ini_set('default_charset',$TBDEV['char_set']);
}
$TBDEV['msg_alert'] = 0// saves a query when off

$TBDEV['autoclean_interval'] = 900;
$TBDEV['sql_error_log'] = ROOT_PATH.'/logs/sql_err_'.date("M_D_Y").'.log';
$TBDEV['pic_base_url'] = "./pic/";
$TBDEV['stylesheet'] = "./1.css";
$TBDEV['readpost_expiry'] = 14*86400// 14 days
//set this to size of user avatars
$TBDEV['av_img_height'] = 100;
$TBDEV['av_img_width'] = 100;
$TBDEV['allowed_ext'] = array('image/gif''image/png''image/jpeg');
// Set this to the line break character sequence of your system
//$TBDEV['linebreak'] = "\r\n"; // not used at present.

define ('UC_USER'0);
define ('UC_POWER_USER'1);
define ('UC_VIP'2);
define ('UC_UPLOADER'3);
define ('UC_MODERATOR'4);
define ('UC_ADMINISTRATOR'5);
define ('UC_SYSOP'6);

//Do not modify -- versioning system
//This will help identify code for support issues at tbdev.net
define ('TBVERSION','TBDev_2009_svn');

?>
Announce.php
PHP Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   http://www.tbdev.net
|   =============================================
|   svn: http://sourceforge.net/projects/tbdevnet/
|   Licence Info: GPL
+------------------------------------------------
|   $Date$
|   $Revision$
|   $Author$
|   $URL$
+------------------------------------------------
*/
error_reporting(0);
////////////////// GLOBAL VARIABLES ////////////////////////////    
$TBDEV['baseurl'] = 'http://yoursitename';
$TBDEV['announce_interval'] = 60 30;
$TBDEV['user_ratios'] = 0;
$TBDEV['connectable_check'] = 0;
define ('UC_VIP'2);
// DB setup
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "youruser";
$TBDEV['mysql_pass'] = "yourpass";
$TBDEV['mysql_db']   = "yourdb";
////////////////// GLOBAL VARIABLES ////////////////////////////

// DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!

$agent $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (
    
ereg("^Mozilla\\/"$agent) || 
    
ereg("^Opera\\/"$agent) || 
    
ereg("^Links "$agent) || 
    
ereg("^Lynx\\/"$agent) || 
    isset(
$_SERVER['HTTP_COOKIE']) || 
    isset(
$_SERVER['HTTP_ACCEPT_LANGUAGE']) || 
    isset(
$_SERVER['HTTP_ACCEPT_CHARSET'])
    )
    
err("torrent not registered with this tracker CODE 1");

/////////////////////// FUNCTION DEFS ///////////////////////////////////
function dbconn()
{
    global 
$TBDEV;

    if (!@
mysql_connect($TBDEV['mysql_host'], $TBDEV['mysql_user'], $TBDEV['mysql_pass']))
    {
      
err('Please call back later');
    }
    
mysql_select_db($TBDEV['mysql_db']) or err('Please call back later');
}

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" );

    if ( 
$_SERVER['HTTP_ACCEPT_ENCODING'] == 'gzip' )
    {
        
header"Content-Encoding: gzip" );
        echo 
gzencode$x9FORCE_GZIP );
    }
    else
        echo 
$x ;
}

function 
benc($obj) {
    if (!
is_array($obj) || !isset($obj["type"]) || !isset($obj["value"]))
        return;
    
$c $obj["value"];
    switch (
$obj["type"]) {
        case 
"string":
            return 
benc_str($c);
        case 
"integer":
            return 
benc_int($c);
        case 
"list":
            return 
benc_list($c);
        case 
"dictionary":
            return 
benc_dict($c);
        default:
            return;
    }
}

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

function 
benc_int($i) {
    return 
"i" $i "e";
}

function 
benc_list($a) {
    
$s "l";
    foreach (
$a as $e) {
        
$s .= benc($e);
    }
    
$s .= "e";
    return 
$s;
}

function 
benc_dict($d) {
    
$s "d";
    
$keys array_keys($d);
    
sort($keys);
    foreach (
$keys as $k) {
        
$v $d[$k];
        
$s .= benc_str($k);
        
$s .= benc($v);
    }
    
$s .= "e";
    return 
$s;
}

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

function 
sqlesc($x) {
    return 
"'".mysql_real_escape_string($x)."'";
}

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;
}
/////////////////////// FUNCTION DEFS END ///////////////////////////////

$parts = array();
$pattern '[0-9a-fA-F]{32}';
if( !isset(
$_GET['passkey']) OR !ereg($pattern$_GET['passkey'], $parts) ) 
        
err("Invalid Passkey");
    else
        
$GLOBALS['passkey'] = $parts[0];
        
foreach (array(
"info_hash","peer_id","event","ip","localip") as $x
{
if(isset(
$_GET["$x"]))
$GLOBALS[$x] = "" $_GET[$x];
}

foreach (array(
"port","downloaded","uploaded","left") as $x)
{
$GLOBALS[$x] = $_GET[$x];
}


foreach (array(
"passkey","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]) . ")");

unset(
$x);

$info_hash bin2hex($info_hash);

$ip $_SERVER['REMOTE_ADDR'];

$port $port;
$downloaded $downloaded;
$uploaded $uploaded;
$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("invalid port");

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

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

dbconn();


$user_query mysql_query("SELECT id, uploaded, downloaded, class, enabled FROM users WHERE passkey=".sqlesc($passkey)) or err("Tracker error 2");

if ( 
mysql_num_rows($user_query) != )

 
err("Unknown passkey. Please redownload the torrent from {$TBDEV['baseurl']}.");
 
    
$user mysql_fetch_assoc($user_query);
    if( 
$user['enabled'] == 'no' err('Permission denied, you\'re not enabled');
    
    
$res mysql_query("SELECT id, banned, seeders + leechers AS numpeers, added AS ts FROM torrents WHERE info_hash = " .sqlesc($info_hash));//" . hash_where("info_hash", $info_hash));

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

$torrentid $torrent["id"];

$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid";

$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");

//////////////////// START NEW COMPACT MODE/////////////////////////////

if($_GET['compact'] != 1)

{

$resp "d" benc_str("interval") . "i" $TBDEV['announce_interval'] . "e" benc_str("peers") . "l";

}

else

{

$resp "d" benc_str("interval") . "i" $TBDEV['announce_interval'] ."e" benc_str("min interval") . "i" 300 ."e5:"."peers" ;

}

$peer = array();

$peer_num 0;
while (
$row mysql_fetch_assoc($res))

{

    if(
$_GET['compact'] != 1)

{



$row["peer_id"] = str_pad($row["peer_id"], 20);



if (
$row["peer_id"] === $peer_id)

{

 
$self $row;

 continue;

}



$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_ip explode('.'$row["ip"]);

$peer_ip pack("C*"$peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]);

$peer_port pack("n*", (int)$row["port"]);

$time intval((time() % 7680) / 60);

if(
$_GET['left'] == 0)

{

$time += 128;

}

$time pack("C"$time);



   
$peer[] = $time $peer_ip $peer_port;

$peer_num++;


      }

}



if (
$_GET['compact']!=1)

$resp .= "ee";

else

{
$o "";
for(
$i=0;$i<$peer_num;$i++)

 {

  
$o .= substr($peer[$i], 16);

 }

$resp .= strlen($o) . ':' $o 'e';

}

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

///////////////////////////// END NEW COMPACT MODE////////////////////////////////



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!");


    if (
$left && $user['class'] < UC_VIP && $TBDEV['user_ratios'])
    {
        
$gigs $user["uploaded"] / (1024*1024*1024);
        
$elapsed floor((time() - $torrent["ts"]) / 3600);
        
$ratio = (($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1);
        if (
$ratio 0.5 || $gigs 5$wait 48;
        elseif (
$ratio 0.65 || $gigs 6.5$wait 24;
        elseif (
$ratio 0.8 || $gigs 8$wait 12;
        elseif (
$ratio 0.95 || $gigs 9.5$wait 6;
        else 
$wait 0;
        if (
$elapsed $wait)
                
err("Not authorized (" . ($wait $elapsed) . "h) - READ THE FAQ!");
    }
}
else
{
    
$upthis max(0$uploaded $self["uploaded"]);
    
$downthis max(0$downloaded $self["downloaded"]);

    if (
$upthis || $downthis 0)
        
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=".$user['id']) or err("Tracker error 3");
}

///////////////////////////////////////////////////////////////////////////////


$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")
        
$updateset[] = "times_completed = times_completed + 1";

    if (isset(
$self))
    {
        
mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = ".time().", 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 (
$event != "started")
            
err("Peer not found. ".$passkey." Restart the torrent.");

        if (
portblacklisted($port))
        {
            
err("Port $port is blacklisted.");
        }
        elseif ( 
$TBDEV['connectable_check'] )
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }
        else
        {
      
$connectable 'yes';
        }

        
$ret mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, passkey) VALUES ('$connectable', $torrentid, " sqlesc($peer_id) . ", " sqlesc($ip) . ", $port$uploaded$downloaded$left, ".time().", ".time().", '$seeder', {$user['id']}, " sqlesc($agent) . "," 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 = ".time();
}

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

benc_resp_raw($resp);



?>
Reply With Quote
  #5  
Old 14th December 2013, 14:36
shubham9418 shubham9418 is offline
Member
 
Join Date: Dec 2013
India
Posts: 3
Default invalid announce url! must be http://localhost/TB/announce.php
Really thanks Sir for your reply...

But TB is my web site folder on Xampp Local host..



config.php
PHP Code:
<?php

error_reporting
(E_ALL);

define('SQL_DEBUG'2);

/* Compare php version for date/time stuff etc! */
    
if (version_compare(PHP_VERSION"5.1.0RC1"">="))
        
date_default_timezone_set('Europe/London');


define('TIME_NOW'time());

$TBDEV['time_adjust'] =  0;
$TBDEV['time_offset'] = '0'
$TBDEV['time_use_relative'] = 1;
$TBDEV['time_use_relative_format'] = '{--}, h:i A';
$TBDEV['time_joined'] = 'j-F y';
$TBDEV['time_short'] = 'jS F Y - h:i A';
$TBDEV['time_long'] = 'M j Y, h:i A';
$TBDEV['time_tiny'] = '';
$TBDEV['time_date'] = '';


// DB setup
// FYNNON FUCKWIT FRENCH RETARD
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "root";
$TBDEV['mysql_pass'] = "";
$TBDEV['mysql_db']   = "shubham";

// Cookie setup
$TBDEV['cookie_prefix']  = 'tbalpha_'// This allows you to have multiple trackers, eg for demos, testing etc.
$TBDEV['cookie_path']    = '/TB'// ATTENTION: You should never need this unless the above applies eg: /tbdev
$TBDEV['cookie_domain']  = ''// set to eg: .somedomain.com or is subdomain set to: .sub.somedomain.com
                              
$TBDEV['site_online'] = 1;
$TBDEV['tracker_post_key'] = 'love';
$TBDEV['max_torrent_size'] = 1000000;
$TBDEV['announce_interval'] = 60 30;
$TBDEV['signup_timeout'] = 86400 3;
$TBDEV['minvotes'] = 1;
$TBDEV['max_dead_torrent_time'] = 3600;

// Max users on site
$TBDEV['maxusers'] = 5000// LoL Who we kiddin' here?


if ( strtouppersubstr(PHP_OS03) ) == 'WIN' )
  {
    
$file_path str_replace"\\""/"dirname(__FILE__) );
    
$file_path str_replace"/include"""$file_path );
  }
  else
  {
    
$file_path dirname(__FILE__);
    
$file_path str_replace"/include"""$file_path );
  }
  
define('ROOT_PATH'$file_path);
$TBDEV['torrent_dir'] = ROOT_PATH '/torrents'# must be writable for httpd user   

# the first one will be displayed on the pages
$TBDEV['announce_urls'] = array();
$TBDEV['announce_urls'][] = "http://localhost/TB/announce.php";
//$TBDEV['announce_urls'] = "http://localhost:2710/announce";
//$TBDEV['announce_urls'] = "http://localhost:83/announce.php";

if ($_SERVER["HTTP_HOST"] == "")
  
$_SERVER["HTTP_HOST"] = $_SERVER["SERVER_NAME"];
  
$TBDEV['baseurl'] = "http://" $_SERVER["HTTP_HOST"]."/TB";

/*
## DO NOT UNCOMMENT THIS: IT'S FOR LATER USE!
$host = getenv( 'SERVER_NAME' );
$script = getenv( 'SCRIPT_NAME' );
$script = str_replace( "\\", "/", $script );

  if( $host AND $script )
  {
    $script = str_replace( '/index.php', '', $script );

    $TBDEV['baseurl'] = "http://{$host}{$script}";
  }
*/

//set this to true to make this a tracker that only registered users may use
//$TBDEV['membersonly'] = 1; //deprecated no longer needed

//maximum number of peers (seeders+leechers) allowed before torrents starts to be deleted to make room...
//set this to something high if you don't require this feature
//$TBDEV['peerlimit'] = 50000; //deprecated. no longer used.

// Email for sender/return path.
$TBDEV['site_email'] = "coldfusion@localhost";

$TBDEV['site_name'] = "TBDEV.NET";

$TBDEV['language'] = 'en';
//charset
$TBDEV['char_set'] = 'UTF-8'//also to be used site wide in meta tags
if (ini_get('default_charset') != $TBDEV['char_set']) {
ini_set('default_charset',$TBDEV['char_set']);
}
$TBDEV['msg_alert'] = 0// saves a query when off

$TBDEV['autoclean_interval'] = 900;
$TBDEV['sql_error_log'] = ROOT_PATH.'/logs/sql_err_'.date("M_D_Y").'.log';
$TBDEV['pic_base_url'] = "./pic/";
$TBDEV['stylesheet'] = "./1.css";
$TBDEV['readpost_expiry'] = 14*86400// 14 days
//set this to size of user avatars
$TBDEV['av_img_height'] = 100;
$TBDEV['av_img_width'] = 100;
$TBDEV['allowed_ext'] = array('image/gif''image/png''image/jpeg');
// Set this to the line break character sequence of your system
//$TBDEV['linebreak'] = "\r\n"; // not used at present.

define ('UC_USER'0);
define ('UC_POWER_USER'1);
define ('UC_VIP'2);
define ('UC_UPLOADER'3);
define ('UC_MODERATOR'4);
define ('UC_ADMINISTRATOR'5);
define ('UC_SYSOP'6);

//Do not modify -- versioning system
//This will help identify code for support issues at tbdev.net
define ('TBVERSION','TBDev_2009_svn');

?>

announce.php
PHP Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   http://www.tbdev.net
|   =============================================
|   svn: http://sourceforge.net/projects/tbdevnet/
|   Licence Info: GPL
+------------------------------------------------
|   $Date$
|   $Revision$
|   $Author$
|   $URL$
+------------------------------------------------
*/
error_reporting(0);
////////////////// GLOBAL VARIABLES ////////////////////////////    
$TBDEV['baseurl'] = 'http://localhost/TB';
$TBDEV['announce_interval'] = 60 30;
$TBDEV['user_ratios'] = 0;
$TBDEV['connectable_check'] = 0;
define ('UC_VIP'2);
// DB setup
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "root";
$TBDEV['mysql_pass'] = "";
$TBDEV['mysql_db']   = "shubham";
////////////////// GLOBAL VARIABLES ////////////////////////////

// DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!

$agent $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (
    
ereg("^Mozilla\\/"$agent) || 
    
ereg("^Opera\\/"$agent) || 
    
ereg("^Links "$agent) || 
    
ereg("^Lynx\\/"$agent) || 
    isset(
$_SERVER['HTTP_COOKIE']) || 
    isset(
$_SERVER['HTTP_ACCEPT_LANGUAGE']) || 
    isset(
$_SERVER['HTTP_ACCEPT_CHARSET'])
    )
    
err("torrent not registered with this tracker CODE 1");

/////////////////////// FUNCTION DEFS ///////////////////////////////////
function dbconn()
{
    global 
$TBDEV;

    if (!@
mysql_connect($TBDEV['mysql_host'], $TBDEV['mysql_user'], $TBDEV['mysql_pass']))
    {
      
err('Please call back later');
    }
    
mysql_select_db($TBDEV['mysql_db']) or err('Please call back later');
}

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" );

    if ( 
$_SERVER['HTTP_ACCEPT_ENCODING'] == 'gzip' )
    {
        
header"Content-Encoding: gzip" );
        echo 
gzencode$x9FORCE_GZIP );
    }
    else
        echo 
$x ;
}

function 
benc($obj) {
    if (!
is_array($obj) || !isset($obj["type"]) || !isset($obj["value"]))
        return;
    
$c $obj["value"];
    switch (
$obj["type"]) {
        case 
"string":
            return 
benc_str($c);
        case 
"integer":
            return 
benc_int($c);
        case 
"list":
            return 
benc_list($c);
        case 
"dictionary":
            return 
benc_dict($c);
        default:
            return;
    }
}

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

function 
benc_int($i) {
    return 
"i" $i "e";
}

function 
benc_list($a) {
    
$s "l";
    foreach (
$a as $e) {
        
$s .= benc($e);
    }
    
$s .= "e";
    return 
$s;
}

function 
benc_dict($d) {
    
$s "d";
    
$keys array_keys($d);
    
sort($keys);
    foreach (
$keys as $k) {
        
$v $d[$k];
        
$s .= benc_str($k);
        
$s .= benc($v);
    }
    
$s .= "e";
    return 
$s;
}

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

function 
sqlesc($x) {
    return 
"'".mysql_real_escape_string($x)."'";
}

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;
}
/////////////////////// FUNCTION DEFS END ///////////////////////////////

$parts = array();
$pattern '[0-9a-fA-F]{32}';
if( !isset(
$_GET['passkey']) OR !ereg($pattern$_GET['passkey'], $parts) ) 
        
err("Invalid Passkey");
    else
        
$GLOBALS['passkey'] = $parts[0];
        
foreach (array(
"info_hash","peer_id","event","ip","localip") as $x
{
if(isset(
$_GET["$x"]))
$GLOBALS[$x] = "" $_GET[$x];
}

foreach (array(
"port","downloaded","uploaded","left") as $x)
{
$GLOBALS[$x] = $_GET[$x];
}


foreach (array(
"passkey","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]) . ")");

unset(
$x);

$info_hash bin2hex($info_hash);

$ip $_SERVER['REMOTE_ADDR'];

$port $port;
$downloaded $downloaded;
$uploaded $uploaded;
$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("invalid port");

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

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

dbconn();


$user_query mysql_query("SELECT id, uploaded, downloaded, class, enabled FROM users WHERE passkey=".sqlesc($passkey)) or err("Tracker error 2");

if ( 
mysql_num_rows($user_query) != )

 
err("Unknown passkey. Please redownload the torrent from {$TBDEV['baseurl']}.");
 
    
$user mysql_fetch_assoc($user_query);
    if( 
$user['enabled'] == 'no' err('Permission denied, you\'re not enabled');
    
    
$res mysql_query("SELECT id, banned, seeders + leechers AS numpeers, added AS ts FROM torrents WHERE info_hash = " .sqlesc($info_hash));//" . hash_where("info_hash", $info_hash));

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

$torrentid $torrent["id"];

$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid";

$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");

//////////////////// START NEW COMPACT MODE/////////////////////////////

if($_GET['compact'] != 1)

{

$resp "d" benc_str("interval") . "i" $TBDEV['announce_interval'] . "e" benc_str("peers") . "l";

}

else

{

$resp "d" benc_str("interval") . "i" $TBDEV['announce_interval'] ."e" benc_str("min interval") . "i" 300 ."e5:"."peers" ;

}

$peer = array();

$peer_num 0;
while (
$row mysql_fetch_assoc($res))

{

    if(
$_GET['compact'] != 1)

{



$row["peer_id"] = str_pad($row["peer_id"], 20);



if (
$row["peer_id"] === $peer_id)

{

 
$self $row;

 continue;

}



$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_ip explode('.'$row["ip"]);

$peer_ip pack("C*"$peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]);

$peer_port pack("n*", (int)$row["port"]);

$time intval((time() % 7680) / 60);

if(
$_GET['left'] == 0)

{

$time += 128;

}

$time pack("C"$time);



   
$peer[] = $time $peer_ip $peer_port;

$peer_num++;


      }

}



if (
$_GET['compact']!=1)

$resp .= "ee";

else

{
$o "";
for(
$i=0;$i<$peer_num;$i++)

 {

  
$o .= substr($peer[$i], 16);

 }

$resp .= strlen($o) . ':' $o 'e';

}

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

///////////////////////////// END NEW COMPACT MODE////////////////////////////////



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!");


    if (
$left && $user['class'] < UC_VIP && $TBDEV['user_ratios'])
    {
        
$gigs $user["uploaded"] / (1024*1024*1024);
        
$elapsed floor((time() - $torrent["ts"]) / 3600);
        
$ratio = (($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1);
        if (
$ratio 0.5 || $gigs 5$wait 48;
        elseif (
$ratio 0.65 || $gigs 6.5$wait 24;
        elseif (
$ratio 0.8 || $gigs 8$wait 12;
        elseif (
$ratio 0.95 || $gigs 9.5$wait 6;
        else 
$wait 0;
        if (
$elapsed $wait)
                
err("Not authorized (" . ($wait $elapsed) . "h) - READ THE FAQ!");
    }
}
else
{
    
$upthis max(0$uploaded $self["uploaded"]);
    
$downthis max(0$downloaded $self["downloaded"]);

    if (
$upthis || $downthis 0)
        
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=".$user['id']) or err("Tracker error 3");
}

///////////////////////////////////////////////////////////////////////////////


$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")
        
$updateset[] = "times_completed = times_completed + 1";

    if (isset(
$self))
    {
        
mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = ".time().", 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 (
$event != "started")
            
err("Peer not found. ".$passkey." Restart the torrent.");

        if (
portblacklisted($port))
        {
            
err("Port $port is blacklisted.");
        }
        elseif ( 
$TBDEV['connectable_check'] )
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }
        else
        {
      
$connectable 'yes';
        }

        
$ret mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, passkey) VALUES ('$connectable', $torrentid, " sqlesc($peer_id) . ", " sqlesc($ip) . ", $port$uploaded$downloaded$left, ".time().", ".time().", '$seeder', {$user['id']}, " sqlesc($agent) . "," 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 = ".time();
}

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

benc_resp_raw($resp);



?>
Reply With Quote
  #6  
Old 14th December 2013, 16:40
shubham9418 shubham9418 is offline
Member
 
Join Date: Dec 2013
India
Posts: 3
Unhappy Upload failed! invalid announce url! must be http://localhost/ann
Hello Sir.

I Am not able to upload torrent

error:

Upload failed!
invalid announce url! must be http://localhost/announce.php


config.php
PHP Code:
<?php

error_reporting
(E_ALL);

define('SQL_DEBUG'2);

/* Compare php version for date/time stuff etc! */
    
if (version_compare(PHP_VERSION"5.1.0RC1"">="))
        
date_default_timezone_set('Europe/London');


define('TIME_NOW'time());

$TBDEV['time_adjust'] =  0;
$TBDEV['time_offset'] = '0'
$TBDEV['time_use_relative'] = 1;
$TBDEV['time_use_relative_format'] = '{--}, h:i A';
$TBDEV['time_joined'] = 'j-F y';
$TBDEV['time_short'] = 'jS F Y - h:i A';
$TBDEV['time_long'] = 'M j Y, h:i A';
$TBDEV['time_tiny'] = '';
$TBDEV['time_date'] = '';


// DB setup
// FYNNON FUCKWIT FRENCH RETARD
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "root";
$TBDEV['mysql_pass'] = "";
$TBDEV['mysql_db']   = "shubham";

// Cookie setup
$TBDEV['cookie_prefix']  = 'tbalpha_'// This allows you to have multiple trackers, eg for demos, testing etc.
$TBDEV['cookie_path']    = ''// ATTENTION: You should never need this unless the above applies eg: /tbdev
$TBDEV['cookie_domain']  = ''// set to eg: .somedomain.com or is subdomain set to: .sub.somedomain.com
                              
$TBDEV['site_online'] = 1;
$TBDEV['tracker_post_key'] = 'love';
$TBDEV['max_torrent_size'] = 1000000;
$TBDEV['announce_interval'] = 60 30;
$TBDEV['signup_timeout'] = 86400 3;
$TBDEV['minvotes'] = 1;
$TBDEV['max_dead_torrent_time'] = 3600;

// Max users on site
$TBDEV['maxusers'] = 5000// LoL Who we kiddin' here?


if ( strtouppersubstr(PHP_OS03) ) == 'WIN' )
  {
    
$file_path str_replace"\\""/"dirname(__FILE__) );
    
$file_path str_replace"/include"""$file_path );
  }
  else
  {
    
$file_path dirname(__FILE__);
    
$file_path str_replace"/include"""$file_path );
  }
  
define('ROOT_PATH'$file_path);
$TBDEV['torrent_dir'] = ROOT_PATH '/torrents'# must be writable for httpd user   

# the first one will be displayed on the pages
$TBDEV['announce_urls'] = array();
$TBDEV['announce_urls'][] = "http://localhost/announce.php";
//$TBDEV['announce_urls'] = "http://localhost:2710/announce";
//$TBDEV['announce_urls'] = "http://localhost:83/announce.php";

if ($_SERVER["HTTP_HOST"] == "")
  
$_SERVER["HTTP_HOST"] = $_SERVER["SERVER_NAME"];
  
$TBDEV['baseurl'] = "http://" $_SERVER["HTTP_HOST"]."";

/*
## DO NOT UNCOMMENT THIS: IT'S FOR LATER USE!
$host = getenv( 'SERVER_NAME' );
$script = getenv( 'SCRIPT_NAME' );
$script = str_replace( "\\", "/", $script );

  if( $host AND $script )
  {
    $script = str_replace( '/index.php', '', $script );

    $TBDEV['baseurl'] = "http://{$host}{$script}";
  }
*/

//set this to true to make this a tracker that only registered users may use
//$TBDEV['membersonly'] = 1; //deprecated no longer needed

//maximum number of peers (seeders+leechers) allowed before torrents starts to be deleted to make room...
//set this to something high if you don't require this feature
//$TBDEV['peerlimit'] = 50000; //deprecated. no longer used.

// Email for sender/return path.
$TBDEV['site_email'] = "coldfusion@localhost";

$TBDEV['site_name'] = "TBDEV.NET";

$TBDEV['language'] = 'en';
//charset
$TBDEV['char_set'] = 'UTF-8'//also to be used site wide in meta tags
if (ini_get('default_charset') != $TBDEV['char_set']) {
ini_set('default_charset',$TBDEV['char_set']);
}
$TBDEV['msg_alert'] = 0// saves a query when off

$TBDEV['autoclean_interval'] = 900;
$TBDEV['sql_error_log'] = ROOT_PATH.'/logs/sql_err_'.date("M_D_Y").'.log';
$TBDEV['pic_base_url'] = "./pic/";
$TBDEV['stylesheet'] = "./1.css";
$TBDEV['readpost_expiry'] = 14*86400// 14 days
//set this to size of user avatars
$TBDEV['av_img_height'] = 100;
$TBDEV['av_img_width'] = 100;
$TBDEV['allowed_ext'] = array('image/gif''image/png''image/jpeg');
// Set this to the line break character sequence of your system
//$TBDEV['linebreak'] = "\r\n"; // not used at present.

define ('UC_USER'0);
define ('UC_POWER_USER'1);
define ('UC_VIP'2);
define ('UC_UPLOADER'3);
define ('UC_MODERATOR'4);
define ('UC_ADMINISTRATOR'5);
define ('UC_SYSOP'6);

//Do not modify -- versioning system
//This will help identify code for support issues at tbdev.net
define ('TBVERSION','TBDev_2009_svn');

?>


announce.php
PHP Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   http://www.tbdev.net
|   =============================================
|   svn: http://sourceforge.net/projects/tbdevnet/
|   Licence Info: GPL
+------------------------------------------------
|   $Date$
|   $Revision$
|   $Author$
|   $URL$
+------------------------------------------------
*/
error_reporting(0);
////////////////// GLOBAL VARIABLES ////////////////////////////    
$TBDEV['baseurl'] = 'http://localhost';
$TBDEV['announce_interval'] = 60 30;
$TBDEV['user_ratios'] = 0;
$TBDEV['connectable_check'] = 0;
define ('UC_VIP'2);
// DB setup
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "root";
$TBDEV['mysql_pass'] = "";
$TBDEV['mysql_db']   = "shubham";
////////////////// GLOBAL VARIABLES ////////////////////////////

// DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!

$agent $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (
    
ereg("^Mozilla\\/"$agent) || 
    
ereg("^Opera\\/"$agent) || 
    
ereg("^Links "$agent) || 
    
ereg("^Lynx\\/"$agent) || 
    isset(
$_SERVER['HTTP_COOKIE']) || 
    isset(
$_SERVER['HTTP_ACCEPT_LANGUAGE']) || 
    isset(
$_SERVER['HTTP_ACCEPT_CHARSET'])
    )
    
err("torrent not registered with this tracker CODE 1");

/////////////////////// FUNCTION DEFS ///////////////////////////////////
function dbconn()
{
    global 
$TBDEV;

    if (!@
mysql_connect($TBDEV['mysql_host'], $TBDEV['mysql_user'], $TBDEV['mysql_pass']))
    {
      
err('Please call back later');
    }
    
mysql_select_db($TBDEV['mysql_db']) or err('Please call back later');
}

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" );

    if ( 
$_SERVER['HTTP_ACCEPT_ENCODING'] == 'gzip' )
    {
        
header"Content-Encoding: gzip" );
        echo 
gzencode$x9FORCE_GZIP );
    }
    else
        echo 
$x ;
}

function 
benc($obj) {
    if (!
is_array($obj) || !isset($obj["type"]) || !isset($obj["value"]))
        return;
    
$c $obj["value"];
    switch (
$obj["type"]) {
        case 
"string":
            return 
benc_str($c);
        case 
"integer":
            return 
benc_int($c);
        case 
"list":
            return 
benc_list($c);
        case 
"dictionary":
            return 
benc_dict($c);
        default:
            return;
    }
}

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

function 
benc_int($i) {
    return 
"i" $i "e";
}

function 
benc_list($a) {
    
$s "l";
    foreach (
$a as $e) {
        
$s .= benc($e);
    }
    
$s .= "e";
    return 
$s;
}

function 
benc_dict($d) {
    
$s "d";
    
$keys array_keys($d);
    
sort($keys);
    foreach (
$keys as $k) {
        
$v $d[$k];
        
$s .= benc_str($k);
        
$s .= benc($v);
    }
    
$s .= "e";
    return 
$s;
}

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

function 
sqlesc($x) {
    return 
"'".mysql_real_escape_string($x)."'";
}

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;
}
/////////////////////// FUNCTION DEFS END ///////////////////////////////

$parts = array();
$pattern '[0-9a-fA-F]{32}';
if( !isset(
$_GET['passkey']) OR !ereg($pattern$_GET['passkey'], $parts) ) 
        
err("Invalid Passkey");
    else
        
$GLOBALS['passkey'] = $parts[0];
        
foreach (array(
"info_hash","peer_id","event","ip","localip") as $x
{
if(isset(
$_GET["$x"]))
$GLOBALS[$x] = "" $_GET[$x];
}

foreach (array(
"port","downloaded","uploaded","left") as $x)
{
$GLOBALS[$x] = $_GET[$x];
}


foreach (array(
"passkey","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]) . ")");

unset(
$x);

$info_hash bin2hex($info_hash);

$ip $_SERVER['REMOTE_ADDR'];

$port $port;
$downloaded $downloaded;
$uploaded $uploaded;
$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("invalid port");

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

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

dbconn();


$user_query mysql_query("SELECT id, uploaded, downloaded, class, enabled FROM users WHERE passkey=".sqlesc($passkey)) or err("Tracker error 2");

if ( 
mysql_num_rows($user_query) != )

 
err("Unknown passkey. Please redownload the torrent from {$TBDEV['baseurl']}.");
 
    
$user mysql_fetch_assoc($user_query);
    if( 
$user['enabled'] == 'no' err('Permission denied, you\'re not enabled');
    
    
$res mysql_query("SELECT id, banned, seeders + leechers AS numpeers, added AS ts FROM torrents WHERE info_hash = " .sqlesc($info_hash));//" . hash_where("info_hash", $info_hash));

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

$torrentid $torrent["id"];

$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid";

$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");

//////////////////// START NEW COMPACT MODE/////////////////////////////

if($_GET['compact'] != 1)

{

$resp "d" benc_str("interval") . "i" $TBDEV['announce_interval'] . "e" benc_str("peers") . "l";

}

else

{

$resp "d" benc_str("interval") . "i" $TBDEV['announce_interval'] ."e" benc_str("min interval") . "i" 300 ."e5:"."peers" ;

}

$peer = array();

$peer_num 0;
while (
$row mysql_fetch_assoc($res))

{

    if(
$_GET['compact'] != 1)

{



$row["peer_id"] = str_pad($row["peer_id"], 20);



if (
$row["peer_id"] === $peer_id)

{

 
$self $row;

 continue;

}



$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_ip explode('.'$row["ip"]);

$peer_ip pack("C*"$peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]);

$peer_port pack("n*", (int)$row["port"]);

$time intval((time() % 7680) / 60);

if(
$_GET['left'] == 0)

{

$time += 128;

}

$time pack("C"$time);



   
$peer[] = $time $peer_ip $peer_port;

$peer_num++;


      }

}



if (
$_GET['compact']!=1)

$resp .= "ee";

else

{
$o "";
for(
$i=0;$i<$peer_num;$i++)

 {

  
$o .= substr($peer[$i], 16);

 }

$resp .= strlen($o) . ':' $o 'e';

}

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

///////////////////////////// END NEW COMPACT MODE////////////////////////////////



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!");


    if (
$left && $user['class'] < UC_VIP && $TBDEV['user_ratios'])
    {
        
$gigs $user["uploaded"] / (1024*1024*1024);
        
$elapsed floor((time() - $torrent["ts"]) / 3600);
        
$ratio = (($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1);
        if (
$ratio 0.5 || $gigs 5$wait 48;
        elseif (
$ratio 0.65 || $gigs 6.5$wait 24;
        elseif (
$ratio 0.8 || $gigs 8$wait 12;
        elseif (
$ratio 0.95 || $gigs 9.5$wait 6;
        else 
$wait 0;
        if (
$elapsed $wait)
                
err("Not authorized (" . ($wait $elapsed) . "h) - READ THE FAQ!");
    }
}
else
{
    
$upthis max(0$uploaded $self["uploaded"]);
    
$downthis max(0$downloaded $self["downloaded"]);

    if (
$upthis || $downthis 0)
        
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=".$user['id']) or err("Tracker error 3");
}

///////////////////////////////////////////////////////////////////////////////


$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")
        
$updateset[] = "times_completed = times_completed + 1";

    if (isset(
$self))
    {
        
mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = ".time().", 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 (
$event != "started")
            
err("Peer not found. ".$passkey." Restart the torrent.");

        if (
portblacklisted($port))
        {
            
err("Port $port is blacklisted.");
        }
        elseif ( 
$TBDEV['connectable_check'] )
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }
        else
        {
      
$connectable 'yes';
        }

        
$ret mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, passkey) VALUES ('$connectable', $torrentid, " sqlesc($peer_id) . ", " sqlesc($ip) . ", $port$uploaded$downloaded$left, ".time().", ".time().", '$seeder', {$user['id']}, " sqlesc($agent) . "," 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 = ".time();
}

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

benc_resp_raw($resp);



?>
Reply With Quote
  #7  
Old 14th December 2013, 17:10
DND DND is offline
VIP
 
Join Date: Dec 2008
Posts: 1,241
Default
attention

Attention

why make another thread for the same problem ?
stop trying to make the site work in TB folder, a.k.a subdomain.
upload it on the root folder.




then in config.php make sure you have

PHP Code:
$TBDEV['baseurl'] = "http://" $_SERVER["HTTP_HOST"].""
and

PHP Code:
$TBDEV['announce_urls'] = array();
$TBDEV['announce_urls'][] = "http://localhost/announce.php"
in announce.php make sure u have
PHP Code:
$TBDEV['baseurl'] = 'http://localhost/'
make sure torrents folder is chmod 777 if using linux OS.

***** when creating the .torrent file make sure you have in your torrent client the correct announce url, in your case http://localhost/announce.php
Reply With Quote
  #8  
Old 15th December 2013, 11:14
Krypto Krypto is offline
Retired from BVList
 
Join Date: Jan 2008
P2P
Posts: 510
Angry
DO NOT make new Threads for the same problem, it won't get you your answer any quicker and will in the future just get your Thread REMOVED.

Also you've still not made an Introduction


Threads Merged.
Reply With Quote
The Following User Says Thank You to Krypto For This Useful Post:
roland22 (22nd January 2015)
  #9  
Old 29th October 2018, 12:29
torrenty torrenty is offline
Member
 
Join Date: Jun 2018
Posts: 2
Default
Znane jest wkońcu rozwiązanie problemu?
Reply With Quote
Reply

Tags
announce , failed , http or or localhost or ann , http or or localhost or tb or announcephp , invalid , upload , url

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 21:26. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.