|
#1
|
||||
|
||||
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`) ); If you have this part: Code:
$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid"; Code:
$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid, (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_action)) AS announcetime"; Code:
$res = mysql_query("SELECT seeder, peer_id, ip, port, uploaded, downloaded, userid FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit"); 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"); Code:
$upthis = max(0, $uploaded - $self["uploaded"]); $downthis = max(0, $downloaded - $self["downloaded"]); 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]"); 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"); } 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); } } 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; } 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"; } } } 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"); } } 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") Code:
if ($seeder == "yes") $updateset[] = "seeders = seeders + 1"; else $updateset[] = "leechers = leechers + 1"; } } } 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)"); Code:
tr("Snatched", ($row["times_completed"] > 0 ? "<a href=snatches.php?id=$id>$row[times_completed] time(s)</a>" : "0 times"), 1); 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"); 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"); Here we have to add the snatchlist for the user in his profile. Find: Code:
function maketable($res) 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; } Find: Code:
if ($leeching) print("<tr valign=top><td class=rowhead>Currently leeching</td><td align=left>$leeching</td></tr>\n"); 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"); 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 |
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
|
||||
|
||||
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:
__________________
"ALWAYS BE YOURSELF.
UNLESS YOU CAN BE A UNICORN. THEN ALWAYS BE A UNICORN." |
#3
|
|||
|
|||
cool ...on tbdev was deleted
hope this is the same :) working 100% |
#4
|
|||
|
|||
hi
SOVED Last edited by WhyMe; 4th March 2015 at 16:28. |
Tags |
mod , snatchlist |
|
|
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 |