Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Snatchlist [TTv3]
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2019-03-16 08:45:41
Updated for V3 credit to Original Author

SQL
CREATE TABLE IF NOT EXISTS `snatched` (
 `sid` int(11) unsigned NOT NULL auto_increment,
 `tid` int(11) unsigned NOT NULL default '0',
 `uid` int(11) unsigned NOT NULL default '0',
 `stime` int(11) unsigned NOT NULL default '0',
 `utime` int(11) unsigned NOT NULL default '0',
 `ltime` int(11) unsigned NOT NULL default '0',
 `uload` bigint(20) unsigned NOT NULL default '0',
 `dload` bigint(20) unsigned NOT NULL default '0',
 `completed` enum('0','1') NOT NULL default '0',
 `hnr` enum('no','yes') NOT NULL default 'no',
 PRIMARY KEY  (`sid`),
 UNIQUE KEY `tid_uid` (`tid`,`uid`),
 KEY `completed` (`completed`),
 KEY `tid` (`tid`),
 KEY `uid` (`uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;



In functions.php find
SQL_Query_exec("DELETE FROM reports WHERE votedfor = $id AND type = 'torrent'");


add after
SQL_Query_exec("DELETE FROM `snatched` WHERE `tid` = '$id'");


find
SQL_Query_exec("DELETE FROM pollanswers WHERE userid = $userid");


add after
SQL_Query_exec("DELETE FROM `snatched` WHERE `uid` = '$userid'");


In the most bottom place, before ?> add:
function seedtime($ts = 0)
{                                                                                                  
   $days = floor($ts / 86400);
   $hours = floor($ts / 3600 ) % 24;  
   $mins = floor($ts / 60) % 60;
   $secs = $ts % 60;
   return sprintf( '%d days, %d hours, %d minutes, %d seconds...', $days, $hours, $mins, $secs);
}



In announce.php find
$ret = SQL_Query_exec("INSERT INTO peers (connectable, torrent, peer_id, ip, passkey, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, client) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", " . sqlesc($passkey) . ", $port, $uploaded, $downloaded, $left, '".get_date_time()."', '".get_date_time()."', '$seeder', '$userid', " . sqlesc($agent) . ")");


add underneath
if ( ($MEMBERSONLY) && (($seeder == 'no' && $torrent['freeleech'] == 0)) ) {
   SQL_Query_exec("INSERT INTO `snatched` (`uid`, `tid`, `stime`, `utime`) VALUES ('$userid', '$torrentid', '".gmtime()."', '".gmtime()."') ON DUPLICATE KEY UPDATE `utime` = '" . gmtime() . "'");
}


find
if ( $MEMBERSONLY )
SQL_Query_exec("INSERT INTO completed (userid, torrentid, date) VALUES ($userid, $torrentid, '".get_date_time()."')");


replace with
if ( $MEMBERSONLY )
{
   SQL_Query_exec("INSERT INTO completed (userid, torrentid, date) VALUES ($userid, $torrentid, '".get_date_time()."')");
   SQL_Query_exec("UPDATE LOW_PRIORITY `snatched` SET `completed` = '1' WHERE `tid` = '$torrentid' AND `uid` = '$userid' AND `utime` = '" . gmtime() . "'");
}


find
$upthis = max(0, $uploaded - $self["uploaded"]);


add above
$elapsed = ($self['seeder'] == 'yes') ? $site_config['announce_interval'] - floor(($self['ez'] - time()) / 60) : 0;


find
if (($upthis > 0 || $downthis > 0) && is_valid_id($userid))


replace with
if (($upthis > 0 || $downthis > 0 || $elapsed > 0) && is_valid_id($userid))


find
SQL_Query_exec("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error: Unable to update stats");


add underneath
SQL_Query_exec("UPDATE LOW_PRIORITY `snatched` SET `uload` = `uload` + '$upthis', `dload` = `dload` + '$downthis', `utime` = '".gmtime()."', `ltime` = `ltime` + '$elapsed' WHERE `tid` = '$torrentid' AND `uid` = '$userid'");



In account.php find
        <?php print("<a href='mailbox.php'><b>".T_("YOUR_MESSAGES")."</b></a>");?>


add after
        &nbsp;|&nbsp;
       <?php print("<a href='snatched.php'><b>".T_("YOUR_SNATCHLIST")."</b></a>");?>


find
<?php print("<b>".T_("IP").":</b> " . $CURUSER["ip"] . "\n"); ?><br />


add after
<?php if ($CURUSER["edit_users"]=="yes" && $CURUSER["class"] > $user["class"]) { ?>
 <div style="margin-bottom:3px"><a href="snatched.php?uid=<?php echo $user["id"]?>"><?php echo "<input type='submit' value='".T_("SNATCHLIST")."'>"; ?></a></div>
<?php } ?>



In account-detail find
<a href="report.php?user=<?php echo $user["id"]?>"><?php echo T_("REPORT_MEMBER"); ?></a><br />


add after
                <?php if ($CURUSER["edit_users"]=="yes") { ?>
 <div style="margin-bottom:3px"><a href="snatched.php?uid=<?php echo $user["id"]?>"><?php echo "<input type='submit' value='".T_("SNATCHLIST")."'>"; ?></a></div>
<?php } ?>



In torrents-details.php
find
echo "[<a href='torrents-edit.php?id=$row[id]&amp;returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "'><b>".T_("EDIT_TORRENT")."</b></a>]";


add underneath
echo "&nbsp;<a href=snatched.php?tid=$row[id]><input type='submit' value='".T_("SNATCHLIST")."'></a>&nbsp;";



add to english.php
//===| Snatchlist
$LANG["SNATCHLIST"] = "Snatchlist";
$LANG["YOUR_SNATCHLIST"] = "Your Snatchlist";
$LANG["SNATCHLIST_FOR"] = "Snatchlist For:";
$LANG["LAST_ACTION"] = "Last Action";
$LANG["SEED_TIME"] = "Seed Time";
$LANG["GO_TO_YOUR_PROFILE"] = "Go to Your Profile";
$LANG["GO_TO_USER_ACCOUNT"] = "Go to User Account";
$LANG["HNR"] = "<font color=#FF1200><b>H</b><small>&</small><b>R</b></font>";
$LANG["SNATCHED_MESSAGE"] = "This page displays the details to all downloaded torrents, completed or not.";
$LANG["NO_USER_WITH_ID"] = "There is no user with ID: ";
$LANG["NO_TORRENT_WITH_ID"] = "There is no torrent with ID: ";
$LANG["REGISTERED_MEMBERS_TO_TORRENT"] = "Registered Members To Torrent:";
$LANG["NO_PERMISSION"] = "You don't have permission for this action!";
$LANG["T_L_OR_E"] = "Local or External";
$LANG["LOCAL_TORRENT"] = "Local Torrent";
$LANG["EXTERNAL_TORRENT"] = "External Torrent";
$LANG["FREE"] = "Free";



Upload /snatched.php to root
Upload /images to images folder
snatch.zip
Download
2019-05-17 23:30:17
Thanks You! (y)
Unknown User
2019-10-01 15:38:01
Thanks You!
Unknown User
2019-11-23 17:39:07
I have tiny differences and my site doesn't work properly snatchlist.  Some users display information correctly, but some have only zeros, although there should be information about uploading and downloading.

My database [ATTACH]5249[/ATTACH]

I have files with this content on the server
snatched-DB-tables.png
snatched-DB-tables.png
account.php.zip
Download
account-details.php.zip
Download
announce.php.zip
Download
functions.php.zip
Download
torrents-details.php.zip
Download
2019-12-19 09:31:54
I come to see that I have members who have downloaded and that the snatched system has caught on?
2020-02-12 17:14:00
I have an announce.php that looks like this if it helps you any. This one is set to use the DBconnector in TTv3. You can change it if you are using a different method :)
<?php
       
// Please Note: Languages should not be implemented here...
       
error_reporting(E_ALL ^ E_NOTICE);
require_once("backend/mysql.php");
require_once("backend/config.php");
require_once("backend/mysql.class.php");
require_once("backend/cache.php");

$GLOBALS["DBconnector"] = @mysqli_connect($mysql_host, $mysql_user, $mysql_pass) or err('dbconn: mysqli_connect: ' . mysqli_connect_error());
@mysqli_select_db($GLOBALS["DBconnector"],$mysql_db) or err('dbconn: mysqli_select_db: ' . mysqli_error($GLOBALS["DBconnector"]));

$MEMBERSONLY = $site_config["MEMBERSONLY"];
$MEMBERSONLY_WAIT = $site_config["MEMBERSONLY_WAIT"];

$_GET = array_map_recursive("unesc", $_GET);

//START FUNCTIONS
function array_map_recursive ($callback, $array) {
   $ret = array();

   if (!is_array($array))
       return $callback($array);

   foreach ($array as $key => $val) {
       $ret[$key] = array_map_recursive($callback, $val);
   }
   return $ret;
}

function unesc($x) {
   if (get_magic_quotes_gpc())
       return stripslashes($x);
   return $x;
}

// Testing removal of magic quotes for php 7.4.2
// function unesc($x) {
//    mysqli_real_escape_string($GLOBALS["DBconnector"],$x);
//        return stripslashes($x);
//    return $x;
// }

function is_valid_id($id) {
   return is_numeric($id) && ($id > 0) && (floor($id) == $id);
}

function sqlesc($x) {
   return "'".mysqli_real_escape_string($GLOBALS["DBconnector"],$x)."'";
}

function err($msg) {
   return benc_resp_raw("d".benc_str("failure reason").benc_str($msg)."e");
}

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

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

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

   if (extension_loaded('zlib') && !ini_get('zlib.output_compression') && $_SERVER["HTTP_ACCEPT_ENCODING"] == "gzip") {
       header("Content-Encoding: gzip");
       echo gzencode($x, 9, FORCE_GZIP);
   } else
       print($x);

   exit();
}

function gmtime() {
   return strtotime(get_date_time());
}

function get_date_time($timestamp = 0) {
   if ($timestamp)
       return date("Y-m-d H:i:s", $timestamp);
   else
   return gmdate("Y-m-d H:i:s");
}

function portblacklisted($port) {
   // direct connect
   if ($port >= 411 && $port <= 413) 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;
}

//////////////////////// NOW WE DO THE ANNOUNCE CODE ////////////////////////
                                       
// BLOCK ACCESS WITH WEB BROWSERS
$agent = $_SERVER["HTTP_USER_AGENT"];
if (preg_match("/^Mozilla|^Opera|^Links|^Lynx/i", $agent))
   die("No");

//GET DETAILS OF PEERS ANNOUNCE
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] = 0 + $_GET[$x];

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

foreach (array("info_hash","peer_id","port","downloaded","uploaded","left") as $x)
       if (!isset($$x))
               err("Missing key: $x");

// split passkey ckeck

foreach (array("passkey") as $x)
       if (!isset($$x) && $MEMBERSONLY)
               err("Missing key: $x");
       
if (strlen($peer_id) != 20)
       err("Invalid peer_id");
$no_peer_id = (int) $_GET["no_peer_id"];

   if (strlen($GLOBALS['info_hash']) == 20)
       $GLOBALS['info_hash'] = bin2hex($GLOBALS['info_hash']);
   else if (strlen($GLOBALS['info_hash']) != 40) {
   mysqli_close($GLOBALS["DBconnector"]);
       err("Invalid info hash value.");
   }
   $GLOBALS['info_hash'] = strtolower($GLOBALS['info_hash']);

   if ($MEMBERSONLY){
       if (strlen($passkey) != 32) {
       mysqli_close($GLOBALS["DBconnector"]);
           err("Invalid passkey (" . strlen($passkey) . " - $passkey)");
       }
       }

$ip = $_SERVER["REMOTE_ADDR"];

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




//PORT CHECK
if (!$port || $port > 0xffff) {
   mysqli_close($GLOBALS["DBconnector"]);
   err("invalid port");
}
//TRACKER EVENT CHECK
if (!isset($event))
   $event = "";

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

//Agent Ban
$agentarray = array_map("trim", explode(",", $site_config["BANNED_AGENTS"]));
$useragent = substr($peer_id, 0, 8);
foreach($agentarray as $bannedclient)
if (@strpos($useragent, $bannedclient) !== false) {
   mysqli_close($GLOBALS["DBconnector"]);
   err("Client is banned");
}
   //End Agent Bans

if (portblacklisted($port)) {
   mysqli_close($GLOBALS["DBconnector"]);
   err("Port $port is blacklisted.");
}
$userfields = "u.id, u.class, u.uploaded, u.downloaded, u.ip, u.passkey, g.can_download"; //user details to get

$peerfields = "seeder, UNIX_TIMESTAMP(last_action) AS ez, peer_id, ip, port, uploaded, downloaded, userid, passkey"; //peers details to get




$torrentfields = "id, info_hash, banned, freeleech, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts, seeders, leechers, times_completed, size"; //torrent details to get

$userid = 0;
if ($MEMBERSONLY){
   //check passkey is valid, and get users details
   $res = SQL_Query_exec("SELECT $userfields FROM users u INNER JOIN groups g ON u.class = g.group_id WHERE u.passkey=".sqlesc($passkey)." AND u.enabled = 'yes' AND u.status = 'confirmed' LIMIT 1") or err("Cannot Get User Details");
   $user = mysqli_fetch_array($res);
   if (!$user) {
       mysqli_close($GLOBALS["DBconnector"]);
       err("Cannot locate a user with that passkey!");
   }
   $userid = $user["id"]; //etc
}


//check torrent is valid and get torrent fields
$res = SQL_Query_exec("SELECT $torrentfields FROM torrents WHERE info_hash=".sqlesc($info_hash));
$torrent = mysqli_fetch_array($res);

if (!$torrent) {
   mysqli_close($GLOBALS["DBconnector"]);
   err("Torrent not found on this tracker - hash = " . $info_hash);
   }
   if ($torrent["banned"]=='yes') {
   mysqli_close($GLOBALS["DBconnector"]);
   err("Torrent has been banned - hash = " . $info_hash);
   }
   $torrentid = $torrent["id"];
   $tsize = $torrent["size"];


//Now get data from peers table
$peerlimit = 50;
$numpeers = $torrent["numpeers"];
if ($numpeers > $peerlimit){
   $limit = "ORDER BY RAND() LIMIT $peerlimit";
}else{
   $limit = "";
}

//$res = SQL_Query_exec("SELECT $peerfields FROM peers WHERE torrent = $torrentid $limit") or err("Error Selecting Peers");
//$res = SQL_Query_exec("SELECT $peerfields FROM peers WHERE torrent = $torrentid $limit");
if ($site_config["cache_peers"]) {
$rows = SQL_Query_exec_cached("SELECT $peerfields FROM peers WHERE torrent = $torrentid $limit", $site_config["cache_peers_time"]);
} else {
$res = SQL_Query_exec("SELECT $peerfields FROM peers WHERE torrent = $torrentid $limit") or err("Error Selecting Peers");
$rows = array();
while ($row = mysqli_fetch_assoc($res))
        $rows[] = $row;
}

//DO SOME BENC STUFF TO THE PEERS CONNECTION
$resp = "d8:completei$torrent[seeders]e10:downloadedi$torrent[times_completed]e10:incompletei$torrent[leechers]e";
$resp .= benc_str("interval") . "i" . $site_config['announce_interval'] . "e" . benc_str("min interval") . "i300e" . benc_str("peers");
unset($self);
foreach ($rows as $row) {
   if ($row["peer_id"] === $peer_id) {
       $self = $row;
       continue;
   }

   $peers .= "d" . benc_str("ip") . benc_str($row["ip"]);
       if (!$no_peer_id)
       $peers .= benc_str("peer id") . benc_str($row["peer_id"]);
       $peers .= benc_str("port") . "i" . $row["port"] . "ee";
}
$resp .= "l{$peers}e";
$resp .= "ee";

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



// FILL $SELF WITH DETAILS FROM PEERS TABLE (CONNECTING PEERS DETAILS)
if (!isset($self)){

   //check passkey isnt leaked
   if ($MEMBERSONLY) {
       $valid = @mysqli_fetch_row(@SQL_Query_exec("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') {
           mysqli_close($GLOBALS["DBconnector"]);
           err("Connection limit exceeded!");
       }
       }

   $res = SQL_Query_exec("SELECT $peerfields FROM peers WHERE $selfwhere");
   $row = mysqli_fetch_assoc($res);
   if ($row){
           $self = $row;
   }
}
// END $SELF FILL


if (!isset($self)){ //IF PEER IS NOT IN PEERS TABLE DO THE WAIT TIME CHECK
   if ($MEMBERSONLY_WAIT && $MEMBERSONLY){
       //wait time check
       if($left > 0 && in_array($user["class"], explode(",",$site_config["WAIT_CLASS"]))){ //check only leechers and lowest user class
           $gigs = $user["uploaded"] / (1024*1024*1024);
           $elapsed = floor((gmtime() - $torrent["ts"]) / 3600);
           $ratio = (($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1);
           if ($ratio == 0 && $gigs == 0) $wait = $site_config["WAITA"];
           elseif ($ratio < $site_config["RATIOA"] || $gigs < $site_config["GIGSA"]) $wait = $site_config["WAITA"];
           elseif ($ratio < $site_config["RATIOB"] || $gigs < $site_config["GIGSB"]) $wait = $site_config["WAITB"];
           elseif ($ratio < $site_config["RATIOC"] || $gigs < $site_config["GIGSC"]) $wait = $site_config["WAITC"];
           elseif ($ratio < $site_config["RATIOD"] || $gigs < $site_config["GIGSD"]) $wait = $site_config["WAITD"];
           else $wait = 0;
       if ($elapsed < $wait) {
           mysqli_close($GLOBALS["DBconnector"]);
           err("Wait Time (" . ($wait - $elapsed) . " hours) - Visit ".$site_config["SITEURL"]." for more info");
       }
       }
   }
   $sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
   if (!$sockres)
       $connectable = "no";
   else
       $connectable = "yes";
   @fclose($sockres);

}else{

////////////////H&R SYSTEM EDITS///////////////////////////////////////////////
//    if ( $_GET[ 'event' ] != 'stopped' && $site_config["ENABLE_HNR_SYSTEM"] == true)
//{
//$elapsed = ($self['seeder'] == 'yes') ? $site_config['announce_interval'] - floor(($self['ez'] - time()) / 60) : 0;
//}
//    else
//////////////END H&R SYSTEM EDITS////////////////////////////////////////////

   $elapsed = ($self['seeder'] == 'yes') ? $site_config['announce_interval'] - floor(($self['ez'] - time()) / 60) : 0;
   $upthis = max(0, $uploaded - $self["uploaded"]);
   $downthis = max(0, $downloaded - $self["downloaded"]);

   if (($upthis > 0 || $downthis > 0 || $elapsed > 0) && is_valid_id($userid)){ // LIVE STATS!)
       if ($torrent["freeleech"] == 1){
           SQL_Query_exec("UPDATE users SET uploaded = uploaded + $upthis WHERE id=$userid");
       }else{
           SQL_Query_exec("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error: Unable to update stats");
       }
   SQL_Query_exec("UPDATE LOW_PRIORITY `snatched` SET `uload` = `uload` + '$upthis', `dload` = `dload` + '$downthis', `utime` = '".gmtime()."', `ltime` = `ltime` + '$elapsed' WHERE `tid` = '$torrentid' AND `uid` = '$userid'");
   }
}//END WAIT AND STATS UPDATE

$updateset = array();

////////////////// NOW WE DO THE TRACKER EVENT UPDATES ///////////////////

if ($event == "stopped") { // UPDATE "STOPPED" EVENT
       SQL_Query_exec("DELETE FROM peers WHERE $selfwhere");
       if (mysqli_affected_rows($GLOBALS["DBconnector"])){
           if ($self["seeder"] == "yes")
               $updateset[] = "seeders = (CASE WHEN (seeders < 1) THEN 0 ELSE (seeders - 1) END)";
           else
                $updateset[] = "leechers = (CASE WHEN (leechers < 1) THEN 0 ELSE (leechers - 1) END)";
       }
}

if ($event == "completed") { // UPDATE "COMPLETED" EVENT
   $updateset[] = "times_completed = times_completed + 1";

if ( $MEMBERSONLY )
{
SQL_Query_exec("INSERT INTO completed (userid, torrentid, date) VALUES ($userid, $torrentid, '".get_date_time()."')");
SQL_Query_exec("UPDATE LOW_PRIORITY `snatched` SET `completed` = '1' WHERE `tid` = '$torrentid' AND `uid` = '$userid' AND `utime` = '" . gmtime() . "'");
}
}//END COMPLETED

if (isset($self)){// NO EVENT? THEN WE MUST BE A NEW PEER OR ARE NOW SEEDING A COMPLETED TORRENT

   SQL_Query_exec("UPDATE peers SET ip = " . sqlesc($ip) . ", passkey = " . sqlesc($passkey) . ", port = $port, uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = '".get_date_time()."', client = " . sqlesc($agent) . ", seeder = '$seeder' WHERE $selfwhere");

   if (mysqli_affected_rows($GLOBALS["DBconnector"]) && $self["seeder"] != $seeder){
       if ($seeder == "yes"){
           $updateset[] = "seeders = (CASE WHEN (seeders < 1) THEN 0 ELSE (seeders - 1) END)";
            $updateset[] = "leechers = (CASE WHEN (leechers < 1) THEN 0 ELSE (leechers - 1) END)";
       } else {
           $updateset[] = "seeders = (CASE WHEN (seeders < 1) THEN 0 ELSE (seeders - 1) END)";
           $updateset[] = "leechers = (CASE WHEN (leechers < 1) THEN 0 ELSE (leechers - 1) END)";
       }
   }

} else {

   $ret = SQL_Query_exec("INSERT INTO peers (connectable, torrent, peer_id, ip, passkey, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, client) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", " . sqlesc($passkey) . ", $port, $uploaded, $downloaded, $left, '".get_date_time()."', '".get_date_time()."', '$seeder', '$userid', " . sqlesc($agent) . ")");
//    if ( ( $MEMBERSONLY ) && ( $seeder == 'no' ) && ( $torrent['freeleech'] == 0 ) ) {

   if ( ( $MEMBERSONLY ) && ( $seeder == 'no' ) ) {
        SQL_Query_exec("INSERT DELAYED INTO `snatched` (`uid`, `tid`, `stime`, `utime`) VALUES ('$userid', '$torrentid', '".gmtime()."', '".gmtime()."') ON DUPLICATE KEY UPDATE `utime` = '" . gmtime() . "'");
} else {
        SQL_Query_exec("INSERT DELAYED INTO `snatched` (`uid`, `tid`, `stime`, `utime`, `dload`, `completed`) VALUES ('$userid', '$torrentid', '".gmtime()."', '".gmtime()."', '".$tsize."', '1') ON DUPLICATE KEY UPDATE `utime` = '" . gmtime() . "'");
}


   if ($ret){
       if ($seeder == "yes")
           $updateset[] = "seeders = (CASE WHEN (seeders < 1) THEN 0 ELSE (seeders - 1) END)";
       else
           $updateset[] = "leechers = (CASE WHEN (leechers < 1) THEN 0 ELSE (leechers - 1) END)";
   }
}

//////////////////    END TRACKER EVENT UPDATES ///////////////////

// SEEDED, LETS MAKE IT VISIBLE THEN
if ($seeder == "yes") {
   if ($torrent["banned"] != "yes") // DONT MAKE BANNED ONES VISIBLE
       $updateset[] = "visible = 'yes'";
   $updateset[] = "last_action = '".get_date_time()."'";
}

// NOW WE UPDATE THE TORRENT AS PER ABOVE
if (count($updateset))
   SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id=$torrentid");

// NOW BENC THE DATA AND SEND TO CLIENT???
benc_resp_raw($resp);
mysqli_close($GLOBALS["DBconnector"]);
?>

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-02-12 20:52:13
hmmm, ok. Where do you see an error? It always worked fine, but I do understand that some setups are a bit different from server to server, but do you see an error in there? I dont see one, but im all for learning
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-02-12 22:47:11
oh, ok. Which part is sending NULL so I know what to look at?
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-02-26 19:21:35
Sorry, what does this mod do exactly? Is it just a table with stored stats on non-external torrents?
2020-02-26 20:24:27
On torrentsdetails and accountdetails it provides a link to  that user or that torrents download history
This data is in a table
Upload, download, ratio, added, startime, endtime Seedtime
This is set so only staff can view  (y)
2020-08-30 09:50:55
Dug this out of a old announce [USER=60]@Propaganda[/USER] sent me so big thank you to him
looks like missing piece of snatchlist mod that records part completed torrents in announce

if ($event == "stopped") {

////////////////////////SNATCHED/////////////////////////////////////////
               $res_se = mysql_query("SELECT userid, seed_end, torrentid FROM snatched WHERE torrentid = $torrentid AND userid = $userid");
while ($row_se = mysql_fetch_assoc($res_se)) {
mysql_query("UPDATE snatched SET seed_end  = $dt WHERE finished = 'yes' AND torrentid = ". $row_se[torrentid] ." AND userid = ". $row_se[userid] ."");
}
/////////////////////////////////////////////////////////////////////////

// UPDATE "STOPPED" EVENT


cant really test this at minute and not 100% sure of the sql heres my pdo update for reference


function portblacklisted($port)


above add

$dt = gmtime() - 180;
$dt = get_date_time($dt);


find

if ($event == "stopped") { // UPDATE "STOPPED" EVENT


below add

// SNATCHED
$res_se = DB::run("SELECT uid, utime, tid FROM snatched WHERE tid = $torrentid AND uid = $userid");
while ($row_se = $res_se->fetch(PDO::FETCH_ASSOC)) {
   DB::run("UPDATE snatched SET utime  =? WHERE completed =? AND tid =? AND uid =?", [$dt, 'yes', $row_se['tid'], $row_se['uid']]);
}


here is my understanding of sql (its the times im not sure of)
// sid = id
// uid = userid
// tid = torrentid
// completed = finished
// uload = upload time
// dload = download time
// hnr = was snatched

// utime = seeded time ?
// ltime = lastaction ?
// stime - start time ?
2020-08-30 10:08:01
hnr = hit and run, meaning snatched and not seeded and data back.
If It Ain't Dutch, It Ain't Much!!
2020-08-30 15:25:54
Just added hit & run mod and I think I've got utime and ltime mixed up so query would need changing
2020-08-30 19:28:20
That code brothers me (I'm adding it in right now and improving. First, their iterating a query without a ->close() method or equilevant (like break in foreach), second they should be defining indexes or calling on array (as $row) in the loop and calling outside of it. I'll post the updated code. I don't have these tables so I can't test further but I like it already.
2020-08-31 01:09:49
i will add this in, but very touchy as the file is perfection at the moment. I want max slots added too, but again I don’t want to break what’s not broken and cause bugs elsewhere.

Can you explain the logic for Snatched list please? It will greatly assist in a good plan for the code.
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728