Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev > Mods & Themes
Reply
  #1  
Old 24th April 2008, 16:20
Fynnon's Avatar
Fynnon Fynnon is offline
xxx
 
Join Date: Nov 2007
P2P
Posts: 984
Default Snatchlist MOD
This mod is an re-written improved version of the snatchlist, which is the result of code created by OiNK, rightthere, thebrass, Cue, Sir_SnuggleBunny, and me (ScarS).

If you already have a snatchlist mod installed, you either have to remove that code first, or find out how to edit it.

A little info on what it does:
This mod will make a duplicate of your peers table, with a bit more information added. It has all the fields which are in the peers table (except for the passkey field) and in addition it has the fields upspeed, downspeed, seedtime and leechtime. So what this mod does is it holds all the information of all the users that have snatched the torrent, so it can be viewed on the snatches.php page or in a user's profile.


Well, here we go!

Code:
CREATE TABLE `snatched` (
`id` int(10) unsigned NOT NULL auto_increment,
`userid` int(10) unsigned NOT NULL default '0',
`torrentid` int(10) unsigned NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`port` smallint(5) unsigned NOT NULL default '0',
`connectable` enum('yes','no') NOT NULL default 'no',
`agent` varchar(60) NOT NULL default '',
`peer_id` varchar(20) NOT NULL default '',
`uploaded` bigint(20) unsigned NOT NULL default '0',
`upspeed` bigint(20) NOT NULL default '0',
`downloaded` bigint(20) unsigned NOT NULL default '0',
`downspeed` bigint(20) NOT NULL default '0',
`to_go` bigint(20) unsigned NOT NULL default '0',
`seeder` enum('yes','no') NOT NULL default 'no',
`seedtime` int(10) unsigned NOT NULL default '0',
`leechtime` int(10) unsigned NOT NULL default '0',
`start_date` datetime NOT NULL default '0000-00-00 00:00:00',
`last_action` datetime NOT NULL default '0000-00-00 00:00:00',
`complete_date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
);
announce.php

If you have this part:
Code:
$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid";
replace it with:
Code:
$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid, (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_action)) AS announcetime";
If you did not have the previous part, find this query:
Code:
$res = mysql_query("SELECT seeder, peer_id, ip, port, uploaded, downloaded, userid FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");
and replace it with:
Code:
$res = mysql_query("SELECT seeder, peer_id, ip, port, uploaded, downloaded, userid, (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_action)) AS announcetime FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");
Then find the part where $upthis and $downthis are defined:
Code:
$upthis = max(0, $uploaded - $self["uploaded"]);
$downthis = max(0, $downloaded - $self["downloaded"]);
and add under it:
Code:
$upspeed = ($upthis > 0 ? $upthis / $self["announcetime"] : 0);
$downspeed = ($downthis > 0 ? $downthis / $self["announcetime"] : 0);
$announcetime = ($self["seeder"] == "yes" ? "seedtime = seedtime + $self[announcetime]" : "leechtime = leechtime + $self[announcetime]");
If you would like to report users with abnormal upload speeds you can add the auto report script here (the current minimum speed before being reported is set at 2 MB/s). Note that you still have to fill in the rest of the information of the INSERT INTO reports query. I think there are several mods out there, so just look which fields you have and add the the needed fields.

To use the auto report abnormal upload speeds script put this after the previous added code:
Code:
$maxupspeed = 1024 * 1024 * 2; // When to report users?
if ($upspeed > $maxupspeed) {
  mysql_query("INSERT INTO reports (added, userid) VALUES('".get_date_time()."', $userid)") or err("R Err 1");
}
Continuing the snatchlist mod, find the part where it checks your port for blacklisting and connectabilty:
Code:
if (portblacklisted($port))
            err("Port $port is blacklisted.");
        else
        {
            $sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
            if (!$sockres)
                $connectable = "no";
            else
            {
                $connectable = "yes";
                @fclose($sockres);
            }
        }
and move (copy/paste) it to after: (which is a couple lines up)
Code:
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;
}
Then the biggest part to replace, the whole part where it updates the peerlist (and snatchlist).
Find:
Code:
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 = NOW(), seeder = '$seeder'"
. ($seeder == "yes" && $self["seeder"] != $seeder ? ", finishedat = " . time() : "") . " WHERE $selfwhere");
if (mysql_affected_rows() && $self["seeder"] != $seeder)
{
if ($seeder == "yes")
{
$updateset[] = "seeders = seeders + 1";
$updateset[] = "leechers = leechers - 1";
}
else
{
$updateset[] = "seeders = seeders - 1";
$updateset[] = "leechers = leechers + 1";
}
}
}
else
{
$ret = mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", $port, $uploaded, $downloaded, $left, NOW(), NOW(), '$seeder', $userid, " . sqlesc($agent) . ", $uploaded, $downloaded)");
if ($ret)
{
if ($seeder == "yes")
$updateset[] = "seeders = seeders + 1";
else
$updateset[] = "leechers = leechers + 1";
}
}
}
And replace it with:
Code:
if (isset($self) && $event == "stopped") {
mysql_query("DELETE FROM peers WHERE $selfwhere") or err("D Err");

if (mysql_affected_rows()) {
$updateset[] = ($self["seeder"] == "yes" ? "seeders = seeders - 1" : "leechers = leechers - 1");
mysql_query("UPDATE snatched SET ip = ".sqlesc($ip).", port = $port, connectable = '$connectable', uploaded = uploaded + $upthis, downloaded = downloaded + $downthis, to_go = $left, upspeed = $upspeed, downspeed = $downspeed, $announcetime, last_action = '".get_date_time()."', seeder = '$seeder', agent = ".sqlesc($agent)." WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 1");
}
} elseif (isset($self)) {

if ($event == "completed") {
$updateset[] = "times_completed = times_completed + 1";
$finished = ", finishedat = UNIX_TIMESTAMP()";
$finished1 = ", complete_date = '".get_date_time()."'";
}

mysql_query("UPDATE peers SET ip = ".sqlesc($ip).", port = $port, connectable = '$connectable', uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder', agent = ".sqlesc($agent)." $finished WHERE $selfwhere") or err("PL Err 1");

if (mysql_affected_rows()) {
if ($seeder <> $self["seeder"])
$updateset[] = ($seeder == "yes" ? "seeders = seeders + 1, leechers = leechers - 1" : "seeders = seeders - 1, leechers = leechers + 1");
mysql_query("UPDATE snatched SET ip = ".sqlesc($ip).", port = $port, connectable = '$connectable', uploaded = uploaded + $upthis, downloaded = downloaded + $downthis, to_go = $left, upspeed = $upspeed, downspeed = $downspeed, $announcetime, last_action = '".get_date_time()."', seeder = '$seeder', agent = ".sqlesc($agent)." $finished1 WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 2");
}
} else {
// if ($az["parked"] == "yes")
// err("Your account is parked! (Read the FAQ)");
// elseif ($az["downloadpos"] == "no")
// err("Your downloading priviledges have been disabled! (Read the rules)");

mysql_query("INSERT INTO peers (torrent, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, started, last_action, seeder, agent, downloadoffset, uploadoffset, passkey) VALUES ($torrentid, $userid, ".sqlesc($peer_id).", ".sqlesc($ip).", $port, '$connectable', $uploaded, $downloaded, $left, NOW(), NOW(), '$seeder', ".sqlesc($agent).", $downloaded, $uploaded, ".sqlesc(unesc($passkey)).")") or err("PL Err 2");

if (mysql_affected_rows()) {
$updateset[] = ($seeder == "yes" ? "seeders = seeders + 1" : "leechers = leechers + 1");
mysql_query("UPDATE snatched SET ip = ".sqlesc($ip).", port = $port, connectable = '$connectable', to_go = $left, last_action = '".get_date_time()."', seeder = '$seeder', agent = ".sqlesc($agent)." WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 3");

if (!mysql_affected_rows() && $seeder == "no")
mysql_query("INSERT INTO snatched (torrentid, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, start_date, last_action, seeder, agent) VALUES ($torrentid, $userid, ".sqlesc($peer_id).", ".sqlesc($ip).", $port, '$connectable', $uploaded, $downloaded, $left, '".get_date_time()."', '".get_date_time()."', '$seeder', ".sqlesc($agent).")") or err("SL Err 4");
}
}
Note:
If you were unable to find the previous piece of code you had to replace, it will most likely be the same code that starts here:
Code:
if ($event == "stopped")
and ends here:
Code:
if ($seeder == "yes")
                $updateset[] = "seeders = seeders + 1";
            else
                $updateset[] = "leechers = leechers + 1";
        }
    }
}
So you should remove the code starting from and including the first part until and including the second part, and replace it with the above code.


Well, that was the part for announce, the hardest part is over!

details.php

Not really much to change here, only a link to the snatches page.
Find:
Code:
tr("Snatched", $row["times_completed"] . " time(s)");
and replace with:
Code:
tr("Snatched", ($row["times_completed"] > 0 ? "<a href=snatches.php?id=$id>$row[times_completed] time(s)</a>" : "0 times"), 1);
bittorrent.php
Not really much to change here either, also only a link to the snatches page.
Find:
Code:
print("<td align=center>" . number_format($row["times_completed"]) . "
time$_s</td>\n");
and replace with:
Code:
print("<td align=center>".($row["times_completed"] > 0 ? "<a href=snatches.php?id=$id>".number_format($row["times_completed"])."
time$_s</a>" : "0 times")."</td>\n");
userdetails.php

Here we have to add the snatchlist for the user in his profile.
Find:
Code:
function maketable($res)
before add:
Code:
function snatchtable($res) {

$table = "<table class=main border=1 cellspacing=0 cellpadding=5>
<tr>
<td class=colhead>Category</td>
<td class=colhead>Torrent</td>
<td class=colhead>Up.</td>
<td class=colhead>Rate</td>
<td class=colhead>Downl.</td>
<td class=colhead>Rate</td>
<td class=colhead>Ratio</td>
<td class=colhead>Activity</td>
<td class=colhead>Finished</td>
</tr>";

while ($arr = mysql_fetch_assoc($res)) {

$upspeed = ($arr["upspeed"] > 0 ? mksize($arr["upspeed"]) : ($arr["seedtime"] > 0 ? mksize($arr["uploaded"] / ($arr["seedtime"] + $arr["leechtime"])) : mksize(0)));
$downspeed = ($arr["downspeed"] > 0 ? mksize($arr["downspeed"]) : ($arr["leechtime"] > 0 ? mksize($arr["downloaded"] / $arr["leechtime"]) : mksize(0)));
$ratio = ($arr["downloaded"] > 0 ? number_format($arr["uploaded"] / $arr["downloaded"], 3) : ($arr["uploaded"] > 0 ? "Inf." : "---"));

$table .= "<tr>
<td style='padding: 0px'>[img]pic/".htmlspecialchars($arr["catimg"])."[/img]</td>
<td><a href=details.php?id=$arr[torrentid]>".(strlen($arr["name"]) > 50 ? substr($arr["name"], 0, 50 - 3)."..." : $arr["name"])."</a></td>
<td>".mksize($arr["uploaded"])."</td>
<td>$upspeed/s</td>
<td>".mksize($arr["downloaded"])."</td>
<td>$downspeed/s</td>
<td>$ratio</td>
<td>".mkprettytime($arr["seedtime"] + $arr["leechtime"])."</td>
<td>".($arr["complete_date"] <> "0000-00-00 00:00:00" ? "<font color=green>Yes</font>" : "<font color=red>No</font>")."</td>
</tr>\n";
}
$table .= "</table>\n";

return $table;
}
Then we need a place to display it.
Find:
Code:
if ($leeching)
  print("<tr valign=top><td class=rowhead>Currently leeching</td><td align=left>$leeching</td></tr>\n");
and after it add:
Code:
$res = mysql_query("SELECT s.*, t.name AS name, c.name AS catname, c.image AS catimg FROM snatched AS s INNER JOIN torrents AS t ON s.torrentid = t.id LEFT JOIN categories AS c ON t.category = c.id WHERE s.userid = $user[id]") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0)
  $snatches = snatchtable($res);
if ($snatches)
  print("<tr valign=top><td class=rowhead>Recently snatched</td><td align=left>$snatches</td></tr>\n");
Or if you can't find this, look how your Currently seeding and Currently leeching codes are, and make it like those are.


Well, that's all the code you had to add/edit/remove on your pages, now the final part:

snatches.php:
Code:
<?
require_once("include/bittorrent.php");
dbconn();
loggedinorreturn();

$id = 0 + $_GET["id"];

if (!is_valid_id($id))
stderr("Error", "It appears that you have entered an invalid id.");

$res = mysql_query("SELECT id, name FROM torrents WHERE id = $id") or sqlerr();
$arr = mysql_fetch_assoc($res);

if (!$arr)
stderr("Error", "It appears that there is no torrent with that id.");

$res = mysql_query("SELECT COUNT(*) FROM snatched WHERE torrentid = $id") or sqlerr();
$row = mysql_fetch_row($res);
$count = $row[0];
$perpage = 100;

if (!$count)
stderr("No snatches", "It appears that there are currently no snatches for the torrent <a href=details.php?id=$arr[id]>$arr[name]</a>.");

list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, "?");

stdhead("Snatches");
print("<h1>Snatches for torrent <a href=details.php?id=$arr[id]>$arr[name]</a></h1>\n");
print("<h2>Currently $row[0] snatch".($row[0] == 1 ? "" : "es")."</h2>\n");
if ($count > $perpage)
print("$pagertop");
print("<table border=0 cellspacing=0 cellpadding=5>\n");
print("<tr>\n");
print("<td class=colhead align=left>Username</td>\n");
print("<td class=colhead align=center>Connectable</td>\n");
print("<td class=colhead align=right>Uploaded</td>\n");
print("<td class=colhead align=right>Upspeed</td>\n");
print("<td class=colhead align=right>Downloaded</td>\n");
print("<td class=colhead align=right>Downspeed</td>\n");
print("<td class=colhead align=right>Ratio</td>\n");
print("<td class=colhead align=right>Completed</td>\n");
print("<td class=colhead align=right>Seed time</td>\n");
print("<td class=colhead align=right>Leech time</td>\n");
print("<td class=colhead align=center>Last action</td>\n");
print("<td class=colhead align=center>Completed at</td>\n");
print("<td class=colhead align=center>Client</td>\n");
print("<td class=colhead align=center>Port</td>\n");
print("</tr>\n");

$res = mysql_query("SELECT s.*, size, username, parked, warned, enabled, donor FROM snatched AS s INNER JOIN users ON s.userid = users.id INNER JOIN torrents ON s.torrentid = torrents.id WHERE torrentid = $id ORDER BY complete_date DESC $limit") or sqlerr();
while ($arr = mysql_fetch_assoc($res)) {

$upspeed = ($arr["upspeed"] > 0 ? mksize($arr["upspeed"]) : ($arr["seedtime"] > 0 ? mksize($arr["uploaded"] / ($arr["seedtime"] + $arr["leechtime"])) : mksize(0)));
$downspeed = ($arr["downspeed"] > 0 ? mksize($arr["downspeed"]) : ($arr["leechtime"] > 0 ? mksize($arr["downloaded"] / $arr["leechtime"]) : mksize(0)));
$ratio = ($arr["downloaded"] > 0 ? number_format($arr["uploaded"] / $arr["downloaded"], 3) : ($arr["uploaded"] > 0 ? "Inf." : "---"));
$completed = sprintf("%.2f%%", 100 * (1 - ($arr["to_go"] / $arr["size"])));

print("<tr>\n");
print("<td align=left><a href=userdetails.php?id=$arr[userid]>$arr[username]</a>".get_user_icons($arr)."</td>\n");
print("<td align=center>".($arr["connectable"] == "yes" ? "<font color=green>Yes</font>" : "<font color=red>No</font>")."</td>\n");
print("<td align=right>".mksize($arr["uploaded"])."</td>\n");
print("<td align=right>$upspeed/s</td>\n");
print("<td align=right>".mksize($arr["downloaded"])."</td>\n");
print("<td align=right>$downspeed/s</td>\n");
print("<td align=right>$ratio</td>\n");
print("<td align=right>$completed</td>\n");
print("<td align=right>".mkprettytime($arr["seedtime"])."</td>\n");
print("<td align=right>".mkprettytime($arr["leechtime"])."</td>\n");
print("<td align=center>$arr[last_action]</td>\n");
print("<td align=center>".($arr["complete_date"] == "0000-00-00 00:00:00" ? "Not completed" : $arr["complete_date"])."</td>\n");
print("<td align=center>$arr[agent]</td>\n");
print("<td align=center>$arr[port]</td>\n");
print("</tr>\n");
}
print("</table>\n");
if ($count > $perpage)
print("$pagerbottom");
stdfoot();
?>


Mod By Scars@ TBDev.net

Reply With Quote
The Following 5 Users Say Thank You to Fynnon For This Useful Post:
adrian21 (10th June 2010), alex0082ass (13th October 2010), kallin (6th September 2013), NatashaRhea (19th August 2008), nicholas08 (5th May 2010)
  #2  
Old 8th June 2010, 02:56
ajax's Avatar
ajax ajax is offline
Senior Member
 
Join Date: Apr 2009
United Kingdom
Posts: 165
Unhappy
Hey all,I tryied to add this mod much times but always one: 'Tracker sending invalid data...'.

Can someone help me pls.?

My announce.php
PHP Code:

<?php

ob_start
("ob_gzhandler");

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

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

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

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

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

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





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

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



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

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

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

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

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

$GLOBALS[$tmpname] = $tmpvalue;

}



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



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



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

$ip getip();

$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;
    }
}

$agent $_SERVER["HTTP_USER_AGENT"];

if (
ereg("^Mozilla\\/"$agent) || ereg("^Opera\\/"$agent) || ereg("^Links "$agent) || ereg("^Lynx\\/"$agent))
    
err("torrent not registered with this tracker");

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

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

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

dbconn(false);

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

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

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

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

$torrentid $torrent["id"];

$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid, (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_action)) AS announcetime";

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

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

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

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

$resp .= "ee";

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

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

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



if (!isset($self))

{

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

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

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



$rz mysql_query("SELECT id, uploaded, downloaded, class FROM users WHERE passkey=".sqlesc($passkey)." AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");

if (
$MEMBERSONLY && mysql_num_rows($rz) == 0)

err("Unknown passkey. Please redownload the torrent from $BASEURL.");
    
$az mysql_fetch_assoc($rz);
    
$userid $az["id"];

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

 if (
$upthis || $downthis 0)

 
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");


}

$upspeed = ($upthis $upthis $self["announcetime"] : 0);
$downspeed = ($downthis $downthis $self["announcetime"] : 0);
$announcetime = ($self["seeder"] == "yes" "seedtime = seedtime + $self[announcetime]"leechtime = leechtime + $self[announcetime]");







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



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

function portblacklisted($port)
{
    
// direct connect
    
if ($port >= 411 && $port <= 413) return true;

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

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

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

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

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

    return 
false;
}




$updateset = array();




















if (isset(
$self) && $event == "stopped") {
mysql_query("DELETE FROM peers WHERE $selfwhere") or err("D Err");

if (
mysql_affected_rows()) {
$updateset[] = ($self["seeder"] == "yes" "seeders = seeders - 1" "leechers = leechers - 1");
mysql_query("UPDATE snatched SET ip = ".sqlesc($ip).", port = $port, connectable = '$connectable', uploaded = uploaded + $upthis, downloaded = downloaded + $downthis, to_go = $left, upspeed = $upspeed, downspeed = $downspeed$announcetime, last_action = '".get_date_time()."', seeder = '$seeder', agent = ".sqlesc($agent)." WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 1");
}
} elseif (isset(
$self)) {

if (
$event == "completed") {
$updateset[] = "times_completed = times_completed + 1";
$finished ", finishedat = UNIX_TIMESTAMP()";
$finished1 ", complete_date = '".get_date_time()."'";
}

mysql_query("UPDATE peers SET ip = ".sqlesc($ip).", port = $port, connectable = '$connectable', uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder', agent = ".sqlesc($agent).$finished WHERE $selfwhere") or err("PL Err 1");

if (
mysql_affected_rows()) {
if (
$seeder <> $self["seeder"])
$updateset[] = ($seeder == "yes" "seeders = seeders + 1, leechers = leechers - 1" "seeders = seeders - 1, leechers = leechers + 1");
mysql_query("UPDATE snatched SET ip = ".sqlesc($ip).", port = $port, connectable = '$connectable', uploaded = uploaded + $upthis, downloaded = downloaded + $downthis, to_go = $left, upspeed = $upspeed, downspeed = $downspeed$announcetime, last_action = '".get_date_time()."', seeder = '$seeder', agent = ".sqlesc($agent).$finished1 WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 2");
}
} else {
// if ($az["parked"] == "yes")
// err("Your account is parked! (Read the FAQ)");
// elseif ($az["downloadpos"] == "no")
// err("Your downloading priviledges have been disabled! (Read the rules)");

mysql_query("INSERT INTO peers (torrent, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, started, last_action, seeder, agent, downloadoffset, uploadoffset, passkey) VALUES ($torrentid$userid, ".sqlesc($peer_id).", ".sqlesc($ip).", $port, '$connectable', $uploaded$downloaded$left, NOW(), NOW(), '$seeder', ".sqlesc($agent).", $downloaded$uploaded, ".sqlesc(unesc($passkey)).")") or err("PL Err 2");

if (
mysql_affected_rows()) {
$updateset[] = ($seeder == "yes" "seeders = seeders + 1" "leechers = leechers + 1");
mysql_query("UPDATE snatched SET ip = ".sqlesc($ip).", port = $port, connectable = '$connectable', to_go = $left, last_action = '".get_date_time()."', seeder = '$seeder', agent = ".sqlesc($agent)." WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 3");

if (!
mysql_affected_rows() && $seeder == "no")
mysql_query("INSERT INTO snatched (torrentid, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, start_date, last_action, seeder, agent) VALUES ($torrentid$userid, ".sqlesc($peer_id).", ".sqlesc($ip).", $port, '$connectable', $uploaded$downloaded$left, '".get_date_time()."', '".get_date_time()."', '$seeder', ".sqlesc($agent).")") or err("SL Err 4");
}
}
    
    
    
    
    
    
    
    else
    {
        if (
portblacklisted($port))
            
err("Port $port is blacklisted.");
        else
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }

        
$ret mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset, passkey) VALUES ('$connectable', $torrentid, " sqlesc($peer_id) . ", " sqlesc($ip) . ", $port$uploaded$downloaded$left, NOW(), NOW(), '$seeder', $userid, " sqlesc($agent) . ", $uploaded$downloaded, " sqlesc($passkey) . ")");
        if (
$ret)
        {
            if (
$seeder == "yes")
                
$updateset[] = "seeders = seeders + 1";
            else
                
$updateset[] = "leechers = leechers + 1";
        }
    }
}

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

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

benc_resp_raw($resp);

?>
__________________
"ALWAYS BE YOURSELF.
UNLESS YOU CAN BE A UNICORN.
THEN ALWAYS BE A UNICORN."
Reply With Quote
  #3  
Old 28th August 2010, 09:36
DND DND is offline
VIP
 
Join Date: Dec 2008
Posts: 1,241
Default
cool ...on tbdev was deleted

hope this is the same :)

working 100%
Reply With Quote
  #4  
Old 4th March 2015, 14:14
WhyMe WhyMe is offline
Banned
 
Join Date: Apr 2014
P2P
Posts: 160
Thumbs up
hi

SOVED

Last edited by WhyMe; 4th March 2015 at 16:28.
Reply With Quote
Reply

Tags
mod , snatchlist

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TBDev] shoutcast radio for tbdev Slatkis TBDev 14 3rd June 2017 09:08
TorrentStrike theme engine to TBdev Kotafi Mods & Themes 6 13th May 2012 04:42
[TBDEV] Pets Scripts for TBDev BacKUP TBDev 4 7th September 2011 15:36
Problems installing New and Improved Snatchlist lovebeer TBDev 2 31st May 2010 17:09



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