Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   TBDev 2009 with XBT Tracker (http://www.bvlist.com/showthread.php?t=10573)

inception 1st November 2015 20:05

TBDev 2009 with XBT Tracker
 
Hi,
I have installed TBDEV 2009.. I wanted to know how to integrate the XBT Tracker with this... Please help

smoky28 16th March 2016 12:49

Hi, I have been working in the tbdev being fitted XBT Tracker 2009 will be slow him up and I'll give it the assistance.

DND 16th March 2016 13:32

its not worth it to install XBT instead of the php-announce..

1. XBT is only good if you have more than ~500.000 peers connected at the same time.
2. with XBT some features won't work.

Phogo 16th March 2016 17:27

Also, if you want to use XBT why not use u-232?

szaby 19th March 2016 15:54

Because I can not start it

smoky28 16th April 2016 19:52

Xbt integracion tutiroal.
 
Xbt integracion tutiroal.


Code:

$infohash = sha1($info["string"]);
replace with


Code:

$infohash = pack("H*", sha1($info["string"]));
then update db


Code:

ALTER TABLE `torrents` CHANGE `info_hash` `info_hash` BINARY( 20 ) NOT NULL;
download.php
look for


Code:

if (!isset($CURUSER['passkey']) || strlen($CURUSER['passkey']) != 32)
  {

    $CURUSER['passkey'] = md5($CURUSER['username'].time().$CURUSER['passhash']);

    @mysql_query("UPDATE users SET passkey='{$CURUSER['passkey']}' WHERE id={$CURUSER['id']}");

  }

replace with


Code:

if (!isset($CURUSER['torrent_pass']) || strlen($CURUSER['torrent_pass']) != 32)
  {

    $CURUSER['torrent_pass'] = md5($CURUSER['username'].time().$CURUSER['passhash']);

    @mysql_query("UPDATE users SET torrent_pass='{$CURUSER['torrent_pass']}' WHERE id={$CURUSER['id']}");

  }

look for


Code:

$dict['value']['announce']['value'] = "{$TBDEV['announce_urls'][0]}?passkey={$CURUSER['passkey']}";
replace with


Code:

$dict['value']['announce']['value'] = "http://192.168.0.100:2710/{$CURUSER['torrent_pass']}/announce";
replace 192.168.0.100 with your site name
and change in db, passkey to torrent_pass

Code:

ALTER TABLE `users` CHANGE `passkey` `torrent_pass` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''
details.php
look for


Code:

$HTMLOUT .= tr("{$lang['details_info_hash']}", $row["info_hash"]);
replace with


Code:

function hex_esc($matches) {
            return sprintf("%02x", ord($matches[0]));
        }
        $HTMLOUT .= tr("{$lang['details_info_hash']}", preg_replace_callback('/./s', "hex_esc", hash_pad($row["info_hash"])));

run following in your database


Code:

ALTER TABLE `torrents` ADD `flags` INT( 11 ) NOT NULL;
ALTER TABLE `torrents` ADD `mtime` INT( 11 ) NOT NULL;
ALTER TABLE `torrents` ADD `ctime` INT( 11 ) NOT NULL;
ALTER TABLE `torrents` ADD `freetorrent` enum('0','1') NOT NULL DEFAULT '0';
ALTER TABLE `torrents` ADD `balance` INT( 11 ) NOT NULL;
ALTER TABLE `users` ADD `torrent_pass_version` INT( 11 ) NOT NULL;
ALTER TABLE `users` ADD `name` char(8) NOT NULL COMMENT 'useless column';
ALTER TABLE `users` ADD `pass` blob NOT NULL COMMENT 'useless column';
ALTER TABLE `users` ADD `can_leech` tinyint(4) NOT NULL DEFAULT '1';
ALTER TABLE `users` ADD  `wait_time` int(11) NOT NULL;
ALTER TABLE `users` ADD  `peers_limit` int(11) DEFAULT '1000';
ALTER TABLE `users` ADD  `torrents_limit` int(11) DEFAULT '1000';
ALTER TABLE `users` ADD  `torrent_pass_secret` bigint(20) NOT NULL COMMENT 'useless column';
INSERT INTO `xbt_client_whitelist` (`id`, `peer_id`, `vstring`) VALUES (1, '-', 'all');

if you are using olaf's xbt, you just need


Code:

ALTER TABLE `torrents` ADD `flags` INT( 11 ) NOT NULL
ALTER TABLE `torrents` ADD `mtime` INT( 11 ) NOT NULL
ALTER TABLE `torrents` ADD `ctime` INT( 11 ) NOT NULL
ALTER TABLE `users` ADD `torrent_pass_version` INT( 11 ) NOT NULL

then import xbt database

Code:

CREATE TABLE `xbt_announce_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ipa` int(10) unsigned NOT NULL,
  `port` int(11) NOT NULL,
  `event` int(11) NOT NULL,
  `info_hash` blob NOT NULL,
  `peer_id` blob NOT NULL,
  `downloaded` bigint(20) NOT NULL,
  `left0` bigint(20) NOT NULL,
  `uploaded` bigint(20) NOT NULL,
  `uid` int(11) NOT NULL,
  `mtime` int(11) NOT NULL,
  `useragent` varchar(51) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_cheat` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL,
  `ipa` int(10) unsigned NOT NULL,
  `upspeed` bigint(20) NOT NULL,
  `tstamp` int(11) NOT NULL,
  `uploaded` bigint(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_client_whitelist` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `peer_id` varchar(20) DEFAULT NULL,
  `vstring` varchar(200) DEFAULT '',
  PRIMARY KEY (`id`),
  UNIQUE KEY `peer_id` (`peer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_config` (
  `name` varchar(255) NOT NULL,
  `value` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_deny_from_hosts` (
  `begin` int(11) NOT NULL,
  `end` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_files` (
  `fid` int(11) NOT NULL AUTO_INCREMENT,
  `info_hash` blob NOT NULL,
  `leechers` int(11) NOT NULL,
  `seeders` int(11) NOT NULL,
  `completed` int(11) NOT NULL,
  `announced_http` int(11) NOT NULL,
  `announced_http_compact` int(11) NOT NULL,
  `announced_http_no_peer_id` int(11) NOT NULL,
  `announced_udp` int(11) NOT NULL,
  `scraped_http` int(11) NOT NULL,
  `scraped_udp` int(11) NOT NULL,
  `started` int(11) NOT NULL,
  `stopped` int(11) NOT NULL,
  `flags` int(11) NOT NULL,
  `mtime` int(11) NOT NULL,
  `ctime` int(11) NOT NULL,
  `balance` int(11) NOT NULL,
  `freetorrent` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`fid`),
  UNIQUE KEY `info_hash` (`info_hash`(20))
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_files_users` (
  `uid` int(11) NOT NULL,
  `active` tinyint(1) NOT NULL,
  `announced` int(11) NOT NULL,
  `completed` int(11) NOT NULL,
  `downloaded` bigint(20) NOT NULL,
  `remaining` bigint(20) NOT NULL,
  `uploaded` bigint(20) NOT NULL,
  `upspeed` bigint(20) NOT NULL,
  `downspeed` bigint(20) NOT NULL,
  `corrupt` bigint(20) NOT NULL DEFAULT '0',
  `timespent` bigint(20) NOT NULL,
  `useragent` varchar(51) NOT NULL,
  `connectable` tinyint(4) NOT NULL DEFAULT '1',
  `peer_id` binary(20) DEFAULT NULL,
  `fid` int(11) NOT NULL,
  `ipa` int(12) unsigned NOT NULL,
  `mtime` int(11) NOT NULL,
  `ip` varchar(15) NOT NULL DEFAULT '',
  UNIQUE KEY `uid_2` (`uid`,`fid`,`ipa`),
  KEY `uid` (`uid`),
  KEY `remaining_idx` (`remaining`),
  KEY `fid_idx` (`fid`),
  KEY `mtime_idx` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_scrape_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ipa` int(11) NOT NULL,
  `info_hash` blob,
  `uid` int(11) NOT NULL,
  `mtime` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_snatched` (
  `uid` int(11) NOT NULL DEFAULT '0',
  `tstamp` int(11) NOT NULL,
  `fid` int(11) NOT NULL,
  `IP` varchar(15) NOT NULL,
  KEY `fid` (`fid`),
  KEY `uid` (`uid`),
  KEY `tstamp` (`tstamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `xbt_users` (
  `uid` int(11) NOT NULL AUTO_INCREMENT,
  `name` char(8) NOT NULL,
  `pass` blob NOT NULL,
  `can_leech` tinyint(4) NOT NULL DEFAULT '1',
  `wait_time` int(11) NOT NULL,
  `peers_limit` int(11) NOT NULL,
  `torrents_limit` int(11) NOT NULL,
  `torrent_pass` char(32) NOT NULL,
  `torrent_pass_secret` bigint(20) NOT NULL,
  `downloaded` bigint(20) NOT NULL,
  `uploaded` bigint(20) NOT NULL,
  `fid_end` int(11) NOT NULL,
  PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

for olaf's xbt via ssh type


Code:

mysql -u -p < xbt_tracker.sql
replace peerlist.php with attached file
for olaf's xbt version ... remember to replace "remaining" with "left" and comment useragent and connectable

cleanup.php
look for


Code:

do {
        $res = mysql_query("SELECT id FROM torrents");
        $ar = array();
        while ($row = mysql_fetch_array($res,MYSQL_NUM)) {
            $id = $row[0];
            $ar[$id] = 1;
        }

        if (!count($ar))
            break;

        $dp = @opendir($TBDEV['torrent_dir']);
        if (!$dp)
            break;

        $ar2 = array();
        while (($file = readdir($dp)) !== false) {
            if (!preg_match('/^(\d+)\.torrent$/', $file, $m))
                continue;
            $id = $m[1];
            $ar2[$id] = 1;
            if (isset($ar[$id]) && $ar[$id])
                continue;
            $ff = $TBDEV['torrent_dir'] . "/$file";
            unlink($ff);
        }
        closedir($dp);

        if (!count($ar2))
            break;

        $delids = array();
        foreach (array_keys($ar) as $k) {
            if (isset($ar2[$k]) && $ar2[$k])
                continue;
            $delids[] = $k;
            unset($ar[$k]);
        }
        if (count($delids))
            mysql_query("DELETE FROM torrents WHERE id IN (" . join(",", $delids) . ")");

        $res = mysql_query("SELECT torrent FROM peers GROUP BY torrent");
        $delids = array();
        while ($row = mysql_fetch_array($res,MYSQL_NUM)) {
            $id = $row[0];
            if (isset($ar[$id]) && $ar[$id])
                continue;
            $delids[] = $id;
        }
        if (count($delids))
            mysql_query("DELETE FROM peers WHERE torrent IN (" . join(",", $delids) . ")");

        $res = mysql_query("SELECT torrent FROM files GROUP BY torrent");
        $delids = array();
        while ($row = mysql_fetch_array($res,MYSQL_NUM)) {
            $id = $row[0];
            if (isset($ar[$id]) && $ar[$id])
                continue;
            $delids[] = $id;
        }
        if (count($delids))
            mysql_query("DELETE FROM files WHERE torrent IN (" . join(",", $delids) . ")");
    } while (0);

    $deadtime = deadtime();
    @mysql_query("DELETE FROM peers WHERE last_action < $deadtime");

    $deadtime -= $TBDEV['max_dead_torrent_time'];
    @mysql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < $deadtime");

    $deadtime = time() - $TBDEV['signup_timeout'];
    @mysql_query("DELETE FROM users WHERE status = 'pending' AND added < $deadtime AND last_login < $deadtime AND last_access < $deadtime");

    $torrents = array();
    $res = @mysql_query("SELECT torrent, seeder, COUNT(*) AS c FROM peers GROUP BY torrent, seeder");
    while ($row = mysql_fetch_assoc($res)) {
        if ($row["seeder"] == "yes")
            $key = "seeders";
        else
            $key = "leechers";
        $torrents[$row["torrent"]][$key] = $row["c"];
    }

    $res = @mysql_query("SELECT torrent, COUNT(*) AS c FROM comments GROUP BY torrent");
    while ($row = mysql_fetch_assoc($res)) {
        $torrents[$row["torrent"]]["comments"] = $row["c"];
    }
   
   
    $fields = explode(":", "comments:leechers:seeders");
    $res = @mysql_query("SELECT id, seeders, leechers, comments FROM torrents");
    while ($row = mysql_fetch_assoc($res)) {
        $id = $row["id"];
        if(isset($torrents[$id]))
        $torr = $torrents[$id];
        foreach ($fields as $field) {
            if (!isset($torr[$field]))
                $torr[$field] = 0;
        }
        $update = array();
        foreach ($fields as $field) {
            if ($torr[$field] != $row[$field])
                $update[] = "$field = " . $torr[$field];
        }
        if (count($update))
            @mysql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id");
    }

replace with



Code:

mysql_query("DELETE FROM xbt_files_users WHERE mtime < UNIX_TIMESTAMP() - 3600") or sqlerr(__FILE__, __LINE__);
    mysql_query("DELETE FROM `xbt_files_users` WHERE `active` = '0'");
   
    //torrents visable
    mysql_query("UPDATE torrents SET visible='yes' WHERE seeders >'0'");
    mysql_query("UPDATE torrents SET visible='no' WHERE seeders ='0'");

look for


Code:

@mysql_query("DELETE FROM torrents WHERE id={$arr['id']}");
replace with


Code:

@mysql_query("UPDATE torrents SET flags='1' id={$arr['id']}");
delete.php

look for


Code:

mysql_query("DELETE FROM torrents WHERE id = $id");
    foreach(explode(".","peers.files.comments.ratings") as $x)

replace with


Code:

mysql_query("UPDATE torrents SET flags = 1 WHERE id = $id");
    foreach(explode(".","files.comments.ratings") as $x)

bittorrent.php
look for


Code:

$res2 = @mysql_query("SELECT seeder, COUNT(*) AS pCount FROM peers WHERE userid=".$CURUSER['id']." GROUP BY seeder") or sqlerr(__LINE__,__FILE__);
   
    $seedleech = array('yes' => '0', 'no' => '0');
   
    while( $row = mysql_fetch_assoc($res2) ) {
        if($row['seeder'] == 'yes')
            $seedleech['yes'] = $row['pCount'];
        else
            $seedleech['no'] = $row['pCount'];
       
    }

replace with


Code:

$res2 = mysql_query("SELECT COUNT(*) FROM `xbt_files_users` WHERE uid=".$CURUSER['id']." AND `remaining`=0 AND `active`=1");
$row = mysql_fetch_row($res2);
$activeseed = $row[0];

$res2 = mysql_query("SELECT COUNT(*) FROM `xbt_files_users` WHERE uid=".$CURUSER['id']." AND `remaining`>0 AND `active`=1");
$row = mysql_fetch_row($res2);
$activeleech = $row[0];

olaf's xbt, change remaining to left

look for


Code:

 {$seedleech['yes']}
replace with


Code:

 $activeseed
look for


Code:

 {$seedleech['no']}
replace with


Code:

 $activeleech
userdetails.php
look for


Code:

"
" . htmlspecialchars($arr["torrentname"]) .
replace with


Code:

"
" . htmlspecialchars($arr["torrentname"]) .
look for


Code:

$res = mysql_query("SELECT p.torrent, p.uploaded, p.downloaded, p.seeder, t.added, t.name as torrentname, t.size, t.category, t.seeders, t.leechers, c.name as catname, c.image FROM peers p LEFT JOIN torrents t ON p.torrent = t.id LEFT JOIN categories c ON t.category = c.id WHERE p.userid=$id") or sqlerr();

    while ($arr = mysql_fetch_assoc($res))
    {
        if ($arr['seeder'] == 'yes')
            $seeding[] = $arr;
        else
            $leeching[] = $arr;
    }

replace with


Code:

$res = mysql_query("SELECT torrents.id, added,uploaded,downloaded,torrents.name as torrentname,categories.name as catname,size,image,category,seeders,leechers,remaining FROM xbt_files_users JOIN torrents ON xbt_files_users.fid = torrents.id JOIN categories ON torrents.category = categories.id WHERE uid=$id") or sqlerr();

    while ($arr = mysql_fetch_assoc($res))
    {
        if ($arr['remaining'] == '0')
            $seeding[] = $arr;
        else
            $leeching[] = $arr;
    }

index.php
look for


Code:

$r = mysql_query("SELECT value_u FROM avps WHERE arg='seeders'") or sqlerr(__FILE__, __LINE__);
    $a = mysql_fetch_row($r);
    $seeders = 0 + $a[0];
    $r = mysql_query("SELECT value_u FROM avps WHERE arg='leechers'") or sqlerr(__FILE__, __LINE__);
    $a = mysql_fetch_row($r);
    $leechers = 0 + $a[0];
    if ($leechers == 0)
      $ratio = 0;
    else
      $ratio = round($seeders / $leechers * 100);
    $peers = number_format($seeders + $leechers);
    $seeders = number_format($seeders);
    $leechers = number_format($leechers);

replace with


Code:

$r = mysql_query("SELECT SUM(seeders) FROM torrents") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$seeders = 0 + $a[0];
$r = mysql_query("SELECT SUM(leechers) FROM torrents") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$leechers = 0 + $a[0];
if ($leechers == 0)
  $ratio = 0;
else
  $ratio = round($seeders / $leechers * 100);
$peers = number_format($seeders + $leechers);
$seeders = number_format($seeders);
$leechers = number_format($leechers);

Excuse me just quickly copied into the backup coals as to what the user's own tracker Forum to this copied.

DND 16th April 2016 21:15

from what forum did ya copied this? =]]
at least put it inside correct tags.:coffee:

MJUER 21st April 2016 12:16

I want to create cleaning code but I can not , I tried it but did not go

mysql_query("DELETE FROM xbt_snatched WHERE torrentid=$arr[uid]") or sqlerr(__FILE__, __LINE__);


http://s31.postimg.org/mci4tpyt7/image.png


http://s31.postimg.org/f41wqowor/image.png



All times are GMT +2. The time now is 14:17.

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