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
User Posts

Go to Profile

LOGOUT_COOKIE issue — 2025-11-22 16:41:30 in v3 Support
does this work?  
function logoutcookie() {
   if (session_status() === PHP_SESSION_ACTIVE) {
       $_SESSION = [];
       session_unset();
       session_destroy();
       session_write_close();
   }
   $params = session_get_cookie_params();
   setcookie(session_name(), '', time() - 3600, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
   foreach (['pass', 'uid'] as $cookie) {
       setcookie($cookie, '', time() - 3600, $params['path'], $params['domain'], true, true);
   }
   return true;
}
LOGOUT_COOKIE issue — 2025-11-16 03:59:39 in v3 Support
Replace the code with the original. its commented, and see if that does anything.
LOGOUT_COOKIE issue — 2025-11-16 03:31:10 in v3 Support
hmm. It does that on my site too? I checked and I did make a few edits. I guess they were incorrect. This is the original.
function logincookie($id, $password, $secret, $updatedb = 1, $expires = 0x7fffffff) {
$hash = sha1($id.$secret.$password.getip().$secret);
setcookie("pass", $hash, $expires, "/");
setcookie("uid", $id, $expires, "/");

if ($updatedb)
SQL_Query_exec("UPDATE users SET last_login = '".get_date_time()."' WHERE id = $id");
}

function logoutcookie() {
setcookie("pass", null, time(), "/");
setcookie("uid", null, time(), "/");
}
I also have some instructions for using gmail with phpmailer if that helps anyone. I just put it on the main github page for TTv3 https://github.com/MicrosoulV3/TorrentTrader-v3
Github link for TTv3.8.x — 2025-11-01 16:42:49 in Download
THIS IS NOT FINAL CODE! IT IS A WORK IN PROGRESS. THERE WILL BE ERRORS https://github.com/ExYuSubs/TT-v3.8.3
This is great. Having everyone help will speed it up. I will be able to help soon, but you all are doing great. Thanks for all the updates  😊
Here it is
want to try mine? Also be mindful of mysql strict mode unless you fixed any issues related to that
<?php
// TTv3 Micro Edition - HTTP Tracker
// 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";
require_once "backend/BEncode.php"; // Include BEncode

// Database connection
$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"]));

// Site config
$MEMBERSONLY = $site_config["MEMBERSONLY"];
$MEMBERSONLY_WAIT = $site_config["MEMBERSONLY_WAIT"];

// Process GET parameters
$_GET = array_map_recursive("unesc", $_GET);

// START FUNCTIONS
function array_map_recursive($callback, $array) {
   $ret = [];
   if (!is_array($array)) {
       return $callback($array);
   }
   foreach ($array as $key => $val) {
       $ret[$key] = array_map_recursive($callback, $val);
   }
   return $ret;
}

function unesc($x) {
   return $x;
}

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

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

function err($msg) {
   SQL_Query_exec("INSERT INTO announce_log (message, added) VALUES ('$msg', NOW())");
   $response = ["failure reason" => $msg];
   benc_resp_raw(BEncode($response));
}

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) {
   return $timestamp ? date("Y-m-d H:i:s", $timestamp) : gmdate("Y-m-d H:i:s");
}

function portblacklisted($port) {
   if (($port >= 411 && $port <= 413) || $port == 1214 || ($port >= 6346 && $port <= 6347) || $port == 4662 || $port == 6699) {
       return true;
   }
   return false;
}

// BLOCK ACCESS WITH WEB BROWSERS
$agent = $_SERVER["HTTP_USER_AGENT"];
if (preg_match("/^Mozilla|^Opera|^Links|^Lynx/i", $agent)) {
   die("NO go joe");
}

// GET DETAILS OF PEERS ANNOUNCE
$passkey = $_GET["passkey"] ?? null;
$info_hash = $_GET["info_hash"] ?? null;
$peer_id = $_GET["peer_id"] ?? null;
$ip = $_GET["ip"] ?? $_SERVER["REMOTE_ADDR"];
$event = $_GET["event"] ?? "";
$port = (int)($_GET["port"] ?? 0);
$downloaded = (int)($_GET["downloaded"] ?? 0);
$uploaded = (int)($_GET["uploaded"] ?? 0);
$left = (int)($_GET["left"] ?? 0);

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);
   $_GET[$tmpname] = $tmpvalue;
}

// Validation
foreach (["info_hash", "peer_id", "port", "downloaded", "uploaded", "left"] as $x) {
   if (!isset($_GET[$x])) {
       err("Missing key: $x");
   }
}
if ($MEMBERSONLY && !$passkey) {
   err("Missing key: passkey");
}
if (strlen($peer_id) != 20) {
   err("Invalid peer_id");
}
$no_peer_id = (int)($_GET["no_peer_id"] ?? 0);
if (strlen($info_hash) == 20) {
   $info_hash = bin2hex($info_hash);
} elseif (strlen($info_hash) != 40) {
   mysqli_close($GLOBALS["DBconnector"]);
   err("Invalid info hash value.");
}
$info_hash = strtolower($info_hash);
if ($MEMBERSONLY && strlen($passkey) != 32) {
   mysqli_close($GLOBALS["DBconnector"]);
   err("Invalid passkey (" . strlen($passkey) . " - $passkey)");
}
if (!$port || $port > 0xffff) {
   mysqli_close($GLOBALS["DBconnector"]);
   err("invalid port");
}

// 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");
   }
}
if (portblacklisted($port)) {
   mysqli_close($GLOBALS["DBconnector"]);
   err("Port $port is blacklisted.");
}

// Database queries
$userfields = "u.id, u.class, u.uploaded, u.downloaded, u.ip, u.passkey, g.can_download";
$peerfields = "seeder, UNIX_TIMESTAMP(last_action) AS ez, peer_id, ip, port, uploaded, downloaded, userid, passkey";
$torrentfields = "id, info_hash, banned, freeleech, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts, seeders, leechers, times_completed, size";

$userid = 0;
if ($MEMBERSONLY) {
   $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"];
}

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

$peerlimit = 50;
$numpeers = $torrent["numpeers"];
$limit = ($numpeers > $peerlimit) ? "ORDER BY RAND() LIMIT $peerlimit" : "";
$rows = $site_config["cache_peers"]
   ? SQL_Query_exec_cached("SELECT $peerfields FROM peers WHERE torrent = $torrentid $limit", $site_config["cache_peers_time"])
   : mysqli_fetch_all(SQL_Query_exec("SELECT $peerfields FROM peers WHERE torrent = $torrentid $limit"), MYSQLI_ASSOC);

// Build peers list
$peers_list = [];
$self = null;
foreach ($rows as $row) {
   if ($row["peer_id"] === $peer_id) {
       $self = $row;
       continue;
   }
   $peer = ["ip" => $row["ip"], "port" => (int)$row["port"]];
   if (!$no_peer_id) {
       $peer["peer id"] = $row["peer_id"];
   }
   $peers_list[] = $peer;
}

// Self handling
$seeder = ($left == 0) ? "yes" : "no";
$selfwhere = "torrent = $torrentid AND peer_id = " . sqlesc($peer_id);

if (!$self) {
   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') {
           mysqli_close($GLOBALS["DBconnector"]);
           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");
   $self = mysqli_fetch_assoc($res) ?: null;
}

if (!$self && $MEMBERSONLY_WAIT && $MEMBERSONLY && $left > 0 && in_array($user["class"], explode(",", $site_config["WAIT_CLASS"]))) {
   $gigs = $user["uploaded"] / (1024 * 1024 * 1024);
   $elapsed = floor((gmtime() - $torrent["ts"]) / 3600);
   $ratio = ($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1;
   $wait = 0;
   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"];
   if ($elapsed < $wait) {
       mysqli_close($GLOBALS["DBconnector"]);
       err("Wait Time (" . ($wait - $elapsed) . " hours) - Visit " . $site_config["SITEURL"] . " for more info");
   }
}

$connectable = "no";
if (!$self) {
   $sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
   if ($sockres) {
       $connectable = "yes";
       @fclose($sockres);
   }
} else {
   $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)) {
       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'");
   }
}

// Tracker event updates
$updateset = [];
if ($event == "stopped") {
   SQL_Query_exec("DELETE FROM peers WHERE $selfwhere");
   if (mysqli_affected_rows($GLOBALS["DBconnector"])) {
       $updateset[] = ($self["seeder"] == "yes")
           ? "seeders = (CASE WHEN (seeders < 1) THEN 0 ELSE (seeders - 1) END)"
           : "leechers = (CASE WHEN (leechers < 1) THEN 0 ELSE (leechers - 1) END)";
   }
}
if ($event == "completed") {
   $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() . "'");
   }
}

if ($self) {
   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) {
       $updateset[] = $seeder == "yes" ? "seeders = seeders + 1" : "seeders = (CASE WHEN (seeders < 1) THEN 0 ELSE (seeders - 1) END)";
       $updateset[] = $seeder == "yes" ? "leechers = (CASE WHEN (leechers < 1) THEN 0 ELSE (leechers - 1) END)" : "leechers = leechers + 1";
   }
} 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') {
       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) {
       $updateset[] = ($seeder == "yes") ? "seeders = seeders + 1" : "leechers = leechers + 1";
   }
}

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

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

// Send response
$response = [
   "complete" => (int)$torrent["seeders"],
   "downloaded" => (int)$torrent["times_completed"],
   "incomplete" => (int)$torrent["leechers"],
   "interval" => $site_config["announce_interval"],
   "min interval" => 300,
   "peers" => $peers_list
];
benc_resp_raw(BEncode($response));

mysqli_close($GLOBALS["DBconnector"]);
?>
Here is my mysql.class  
<?php function SQL_Query(string $query) {
   return new SQL_Query($query);
}

function SQL_Query_exec(string $query) {
   try {
       $sql = new SQL_Query($query);
       return $sql->execute();
   } catch (Exception $e) {
       error_log("SQL Query Execution Error: " . $e->getMessage());
       return null;
   }
}

class SQL_Query {
   private string $query = "";
   private array $params = [];

   public function __construct(string $query) {
       $this->query = $query;
       return $this;
   }

   public function p($param) {
       if (is_numeric($param)) {
           $this->params[] = $param;
       } elseif (is_array($param)) {
           $this->params[] = implode(", ", array_map([$this, "escape"], $param));
       } else {
           $this->params[] = $this->escape($param);
       }
       return $this;
   }

   public function p_name(string $param) {
       $this->params[] = "`" . mysqli_real_escape_string($GLOBALS["DBconnector"], $param) . "`";
       return $this;
   }

   public function escape($s) {
       if (is_numeric($s)) {
           return $s;
       }
       return "'" . mysqli_real_escape_string($GLOBALS["DBconnector"], $s) . "'";
   }

   public function read() {
       $ret = "";
       if (count($this->params)) {
           reset($this->params);
           for ($i = 0; $i < strlen($this->query); $i++) {
               if ($this->query[$i] == "?") {
                   $val = current($this->params);
                   next($this->params);
                   $ret .= $val;
               } else {
                   $ret .= $this->query[$i];
               }
           }
           reset($this->params);
       } else {
           $ret = $this->query;
       }
       return $ret;
   }

   public function execute() {
       $query = $this->read();
       $res = mysqli_query($GLOBALS["DBconnector"], $query);

       if ($res || mysqli_errno($GLOBALS["DBconnector"]) == 1062) {
           return $res;
       }
       $mysqli_error = mysqli_error($GLOBALS["DBconnector"]);
       $mysqli_errno = mysqli_errno($GLOBALS["DBconnector"]);

       if (function_exists("debug_backtrace")) {
           $bt = debug_backtrace();
           $i = 1;
           if ($bt[$i]["function"] == "SQL_Query_exec_cached" || $bt[$i]["function"] == "get_row_count_cached" || $bt[$i]["function"] == "get_row_count") {
               $i++;
           }
           $line = $bt[$i]["line"];
           $file = str_replace(getcwd() . DIRECTORY_SEPARATOR, "", $bt[$i]["file"]);
           $msg = "Database Error in $file on line $line: $mysqli_error. Query was: $query.";
       } else {
           $file = str_replace(getcwd() . DIRECTORY_SEPARATOR, "", $_SERVER["SCRIPT_FILENAME"]);
           $msg = "Database Error in $file: $mysqli_error. Query was: $query";
       }

       mysqli_query($GLOBALS["DBconnector"], "INSERT INTO `sqlerr` (`txt`, `time`)
                    VALUES (" . sqlesc($msg) . ", '" . get_date_time() . "')");

       show_error_msg("Database Error", "Database Error. Please report this to an administrator.", 1);

       return null;
   }
}
?>
there is nothing wrong with that class file, you made a bad edit somewhere and its calling a function in that file and crashing. Its not that file. Check whatever edits you recently did
TTV3 Upload — 2025-08-13 19:48:08 in v3 Support
where did you get the copy of TT from?
Internal Server Error — 2025-05-27 18:31:20 in v3 Support
I cant remember if I fixed it for use with strict sql mode. Try no_engine_substitution as your sql mode. A white page is usually an issue with php
Internal Server Error — 2025-05-27 14:42:08 in v3 Support
use php 7.4
thats a neat approach. You also have this that may help https://www.projecthoneypot.org/
@coco, here is my functions file. Again, this is only testing so I cant guarantee anything. I havent had any time lately to keep working on this, so backup your files.
backend/functions.php find and replace.
function logincookie($id, $password, $secret, $updatedb = true, $expires = null) {
   if ($expires === null) {
       $expires = time() + (30 * 24 * 60 * 60); // Extend 30 days from now on each visit
   }

   $hash = sha1($id . $secret . $password . getip() . $secret);
   
   // Set secure cookies with a rolling expiration
   setcookie("pass", $hash, $expires, "/", "", true, true);
   setcookie("uid", $id, $expires, "/", "", true, true);

   if ($updatedb) {
       $stmt = $GLOBALS["DBconnector"]->prepare("UPDATE users SET last_login = ? WHERE id = ?");
       $stmt->bind_param("si", get_date_time(), $id);
       $stmt->execute();
       $stmt->close();
   }
}

function logoutcookie() {
setcookie("pass", "", time() - 3600, "/", "", true, true);
setcookie("uid", "", time() - 3600, "/", "", true, true);

}
ahh, I did forget to mention turning on 2FA. I assume that centos would work just like ubuntu. Use composer to install phpmailer.  you need to be in your backend folder when you run composer require phpmailer/phpmailer because it will place the files needed for phpmailer there. phpmailer has to be in the same directory as your mail.php. its just simpler that way
torrents.php — 2025-04-07 23:54:20 in v3 Support
are you using TTv3? I see a few mysql_ in the code you posted. If you are using php 7.4, those lines should be mysqli_
Server load fix — 2025-03-26 21:17:20 in v3 Support
can you post that image in a different way? We cant see it. use imgbb or do what botanicar uses
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: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728