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

Minimize blocks — 2025-03-25 21:14:54 in v3 Support
updated github with Yadjoe fix. Let me know if thats good. I never noticed this issue lol. I never even knew you could minimize blocks. I missed that somehow. Thanks obiwan for pointing it out. If anyone sees anything else, just post
hmm, I updated the link. It works for me. Not sure what else I should do. Along with botanicar, people here share freely. Good luck with your endeavor. Your pages look nice. We openly share code and other stuff because thats what it was always about. Sharing is caring. its OK if you want paid for your work, just not sure how many takers you will find here since most people who are capable of editing this code will share freely when asked. Its all cool if you want to charge for that, I get it, you did the work. I have no issues with it. Maybe try over at bvlist too and see if you get any takers. best wishes

@Botanicar, how are you posting those images here? I cant figure it out
External scraper fix — 2025-03-24 11:35:29 in General Chat
you should move your db connection outside of that file I think, like using
require_once "backend/functions.php";
dbconn();
See if that works better. keeping db stuff in one place is better than in multiple files and since you already have it in mysql.php called in functions, it just keeps things simple
Server load fix — 2025-03-23 22:11:31 in v3 Support
what do you mean? Explain more
instructions here https://github.com/MicrosoulV3/TorrentTrader-v3/blob/master/README.md

I removed all code from here because its easier to maintain it on github.
no, you are fine, no worries
mine is a little different than yours, not much, but feel free to try it
<?php
//TTv3 Micro Edition
// 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 = [];

   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"; // Handle NULL values
   }
   
   if (is_numeric($x)) {
       return $x; // No need to escape numeric values
   }
   
   return "'" . mysqli_real_escape_string($GLOBALS["DBconnector"], $x) . "'";
}


function err($msg)
{
   SQL_Query_exec("INSERT INTO announce_log (message, added) VALUES ('$msg', NOW())");
   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("Eat my cunt. Why are you doing this? None of this works this way");
}

//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 check

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 = "";
}

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 = [];
   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') {
           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");
   $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 = [];

////////////////// 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) {
       $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";
   }
   
}

//////////////////    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

// Make sure $updateset is an array or an object implementing Countable
if (is_array($updateset) || $updateset instanceof Countable) {
   $updatesCount = count($updateset);

   if ($updatesCount > 0) {
       $updatesString = join(",", $updateset);
       SQL_Query_exec("UPDATE torrents SET $updatesString WHERE id=$torrentid");
   }
}

// NOW BENC THE DATA AND SEND TO CLIENT???
benc_resp_raw($resp);
mysqli_close($GLOBALS["DBconnector"]);
you had problems before with your forums page also. I dont know what version of linux you are running, but if I may make a suggestion, use ubuntu 20.04 LTS. I know most variants are similar, but subtle changes in each distro can alter things unless you really know what you are doing. I only use ubuntu, and its been flawless for years, aside from that, post your files. Did you get your copy from github?
lets all be friends everyone. Sharing is caring. All is well. No worries.
I can appreciate your hard work, but you have to understand something, you have a very limited audience for this. When I updated the dead TT to where it is now, or atleast the v3, I didnt ask for anything, I just gave it away, because im old school. Sharing is caring, but you do what you feel you need to. Could always try over at bvlist also, see if you get any takers. Most folks here (most) know how to do alot of things, so your market is extremely limited, but your work is always appreciated. Keep the torch lit
I logged on and saw it also at first, had to refresh page then I was ok. Check wherever that message gets generated and look at the code that would execute that message and see what is going on to display that message. It could be something really silly like some bad code, etc. Seemed like it only happened at login, but I cant be sure. Ask if they only see that when logging in. If so, check your login page or cookie settings. Im just taking guesses at this point
Im not sure. make sure your site is chown www-data. Thats the only thing I ever saw that will cause weird issues. sudo chown -R www-data:www-data /var/www/site
Link TMDB — 2025-03-05 20:18:32 in v3 Support
I dont use TMDB, but here is my imdb case line from functions.php.
			case 'imdb':
     if ($row["imdb"])  
           print("<td class='ttable_col$x' align='center'><a href=".$row['imdb']." target='_blank'><".htmlspecialchars($row['imdb'])."><img src='" . $site_config['SITEURL'] . "/images/imdb.png'  border='0' width='50' height='50' alt=\"\" /></a></td>");
        else
        print("<td class='ttable_colx' align='center'>-</td>");  
        break;
referer mod — 2025-03-05 00:35:05 in v3 Support
I updated this a little bit. Here ya go. I wanted a delete button
if ($action == "referer")
{
   if (isset($_POST['delete'])) {
       $referer = mysqli_real_escape_string($GLOBALS['DBconnector'], $_POST['delete']);
       SQL_Query_exec("DELETE FROM `referer` WHERE `referer` = '$referer'");
       autolink("admincp.php?action=referer", "<b><font color='#ff0000'>Referers Deleted</font></b>");
   }

   $count = get_row_count("referer");
   
   list ($pagertop, $pagerbottom, $limit) = pager(20, $count, 'admincp.php?action=referer&');
   
   $res = SQL_Query_exec("SELECT * FROM `referer` ORDER BY `added` DESC $limit");
   
   stdhead("Site Referer");
   
   begin_frame("Site Referer");
   
   if (mysqli_num_rows($res) > 0)
   {
       ?>
       <table class="table_table" cellpadding="3" cellspacing="3" width="75%" align="center">
       <tr>
           <th class="table_head">Referer</th>
           <th class="table_head">Added</th>
           <th class="table_head">Count</th>
           <th class="table_head">Action</th>
       </tr>
       <?php while ($row = mysqli_fetch_assoc($res)): ?>
       <tr>
           <td class="table_col1"><a href="<?php echo $row['referer']; ?>"><?php echo $row['referer']; ?></a></td>
           <td class="table_col2"><?php echo date('F d, Y g:i a', $row['added']); ?></td>
           <td class="table_col1"><?php echo number_format($row['count']); ?></td>
           <td class="table_col2" style="text-align: center;">
               <form method="post" action="admincp.php?action=referer"
                     onsubmit="return confirm('Are you sure you want to delete this referer?')"
                     style="display: inline;">
                   <input type="hidden" name="delete" value="<?php echo htmlspecialchars($row['referer']); ?>">
                   <input type="submit" value="Delete">
               </form>
           </td>
       </tr>
       <?php endwhile; ?>
       </table>
       <?php
       if ($count > 20) echo $pagerbottom;
   }
   else
   {
       echo('<center><b>No Referrals Found...</b></center>');
   }
   
   end_frame();
   navmenu();
   stdfoot();
}
Cloudflare Captcha — 2025-02-25 06:01:33 in Tutorials
I always used google for years, and I learned about cloudflare. I like it better personally. Here is my login page. This is stock TTv3 account-login.php from github edited to use cloudflares captcha.

Go here and sign up for free https://www.cloudflare.com/application-services/products/turnstile/

Get your keys

Add to backend/config.php
// CLOUDFLARE TURNSTILE RECAPTCHA
$site_config['CLOUDSITEKEY'] = 'add-key-here'; // Cloudflare turnstile captcha Sitekey
$site_config['CLOUDSECRET'] = 'add-key-here'; // Cloudflare turnstile captcha Secretkey


here is the entire login page
<?php
// Updated login for sql security May 14 2023
require_once("backend/functions.php");
dbconn();
session_start();

if (!empty($_REQUEST["returnto"])) {
   if (!isset($_GET["nowarn"])) {
       $nowarn = T_("MEMBERS_ONLY");
   }
}

if (isset($_POST["username"]) && isset($_POST["password"])) {
   if (!empty($_POST["username"]) && !empty($_POST["password"])) {
       $username = htmlspecialchars($_POST["username"]);
       $password = htmlspecialchars($_POST["password"]);
       $password_hash = passhash($password);
       $stmt = $GLOBALS["DBconnector"]->prepare("SELECT id, password, secret, status, enabled FROM users WHERE username = ? LIMIT 1");
       $stmt->bind_param("s", $username);
       $stmt->execute();

       if ($stmt->error) {
           die("Query failed: " . $stmt->error);
       }
       $res = $stmt->get_result();
       $row = $res->fetch_assoc();

       if ($row) {
           if ($row["password"] !== $password_hash) {
               $message = T_("LOGIN_INCORRECT");
           } elseif ($row["status"] === "pending") {
               $message = T_("ACCOUNT_PENDING");
           } elseif ($row["enabled"] === "no") {
               $message = T_("ACCOUNT_DISABLED");
           } else {

               if (isset($_POST['cf-turnstile-response'])) {
                   $turnstile_response = $_POST['cf-turnstile-response'];

                   if (empty($turnstile_response)) {
                       $message = "Please complete the verification";
                   } else {
                       $secretKey = $site_config['CLOUDSECRET'];
                       $ip = $_SERVER['REMOTE_ADDR'];
                       $ch = curl_init();
                       curl_setopt($ch, CURLOPT_URL, 'https://challenges.cloudflare.com/turnstile/v0/siteverify');
                       curl_setopt($ch, CURLOPT_POST, 1);
                       curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
                           'secret' => $secretKey,
                           'response' => $turnstile_response,
                           'remoteip' => $ip
                       ]));
                       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
                       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                       $response = curl_exec($ch);
                       if (curl_errno($ch)) {
                           $message = "Verification error: " . curl_error($ch);
                       }
                       curl_close($ch);
                       $response = json_decode($response);

                       if ($response->success !== true) {
                           $message = "Verification failed. Please try again.";
                       }
                   }
               } else {
                   $message = "Verification missing. Please try again.";
               }
           }
       } else {
           $message = T_("LOGIN_INCORRECT");
       }
   } else {
       $message = T_("NO_EMPTY_FIELDS");
   }

   if (!isset($message) || !$message) {
       logincookie($row["id"], $row["password"], $row["secret"]);
       
       if (!empty($_POST["returnto"])) {
           header("Refresh: 0; url=" . $_POST["returnto"]);
           die();
       } else {
           header("Refresh: 0; url=index.php");
           die();
       }
   } else {
       show_error_msg(T_("ACCESS_DENIED"), $message, 1);
   }
}
logoutcookie();

stdhead(T_("LOGIN"));

if (isset($nowarn)) {
   show_error_msg(T_("ERROR"), $nowarn, 0);
}

begin_frame(T_("LOGIN"));
?>

<form method="post" action="account-login.php">
   <table border="0" cellpadding="3" align="center">
       <tr>
           <td align="center">
               <b><?php echo T_("USERNAME"); ?>:</b>
               <input type="text" size="40" name="username" />
           </td>
       </tr>
       <tr>
           <td align="center">
               <b><?php echo T_("PASSWORD"); ?>:</b>
               <input type="password" size="40" name="password" />
           </td>
       </tr>
       <tr>
           <td align="center">
               <div class="cf-turnstile" data-sitekey="<?php echo $site_config['CLOUDSITEKEY']; ?>"></div>
           </td>
       </tr>
       <tr>
           <td colspan="2" align="center">
               <input type="submit" value="<?php echo T_("LOGIN"); ?>" />
               <br />
               <br />
               <i><?php echo T_("COOKIES");?></i>
           </td>
       </tr>
   </table>

   <?php
   if (!empty($_REQUEST["returnto"])) {
       ?>
       <input type="hidden" name="returnto" value="<?php echo cleanstr($_REQUEST["returnto"]); ?>" />
       <?php
   }
   ?>
</form>

<p align="center">
   <a href="account-signup.php"><?php echo T_("SIGNUP"); ?></a> |
   <a href="account-recover.php"><?php echo T_("RECOVER_ACCOUNT"); ?></a>
</p>

<?php
end_frame();
stdfoot();
?>

<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
comment — 2025-02-20 22:34:27 in v3 Support
I cant duplicate your issue on TTv3
torrents-search — 2025-02-13 22:12:03 in v3 Support
try mine. Should work just fine with TTv3 with no extra sql, nothing. I did test yours real quick and I see the same errors you posted. Try and let me know. There are some differences, like this. Your file has this
foreach ($searcha as $searchss) {
      if (strlen($searchss) <= 0)
      continue;
      $sc++;
      if ($sc > 1)
      break;
      $ssa = array();
      foreach (array("torrents.name") as $sss)
      $ssa[] = "LOWER($sss) LIKE '%" . sqlwildcardesc(strtolower($searchss)) . "%'"; // update by raidewine 2021-08-30
      $wherea[] = "(" . implode(" OR ", $ssa) . ")";
  }

torrents-search — 2025-02-11 22:59:48 in v3 Support
using zeros in datetime can be an issue if you have strict on, but if not, you are fine. Just be mindful of this issue if you have strict mode on. Its better to just do it this way anyhow. NULL for datetime is the best way to do that


`searched_at` datetime DEFAULT NULL;
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