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
External UDP/HTTPS scrape
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2026-01-20 01:08:19
post removed. bad code. See post below
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)
Last edited by MicroMonkey on 2026-01-21 09:58:40
2026-01-20 10:05:27
I found a github with that scrapes udp https://github.com/medariox/scrapeer
2026-01-20 10:32:35
see post below
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)
Last edited by MicroMonkey on 2026-01-21 09:59:03
2026-01-21 07:30:09
ok,  This seems to work. Should scrape udp and https while keeping all the same files with no external shit or extra files, cuz I dont like that. Test it and lets see. THIS IS COPY/PASTE AND APPLIES TO TTv3 unless you know what you are doing. This will work fine in whatever you have, but I cant tell you where to put it if you have custom code. in backend/functions, just replace the entire torrent_scrape_url
//////////// Begin revised torrent_scrape_url function ////////////

function torrent_scrape_url(string $scrape, string $hash): array
{
   $ret = [
       'seeds'      => 0,
       'peers'      => 0,
       'downloaded' => 0,
   ];

   // info_hash must be 40 hex chars
   if (!preg_match('/^[a-f0-9]{40}$/i', $hash)) {
       return $ret;
   }

   // Parse the input URL as-is (do NOT force http:// yet)
   $url = parse_url($scrape);

   // If no scheme and looks like host-only → default to http
   if (empty($url['scheme']) && !empty($url['host'])) {
       $scrape = 'http://' . $scrape;
       $url = parse_url($scrape); // re-parse
   }

   if (empty($url['host'])) {
       return $ret;
   }

   $scheme = strtolower($url['scheme'] ?? 'http');

   // ────────────────────────────────────────────────
   // UDP branch – handle BEFORE http/https
   // ────────────────────────────────────────────────
   if ($scheme === 'udp') {
       if (empty($url['port'])) {
           $url['port'] = 6969; // common default for udp trackers
       }

       $socket = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
       if (!$socket) {
           return $ret;
       }

       socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => 4, 'usec' => 0]);
       socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, ['sec' => 4, 'usec' => 0]);

       // Connect request
       $conn_req = pack('N*', 0x417, 0x27101980, 0, mt_rand(1, 0x7fffffff));
       @socket_sendto($socket, $conn_req, 16, 0, $url['host'], $url['port']);

       $buf = '';
       $len = @socket_recvfrom($socket, $buf, 16, 0, $dummy1, $dummy2);
       if ($len !== 16) {
           @socket_close($socket);
           return $ret;
       }

       $conn_resp = unpack('Naction/Ntrans_id/Jconnection_id', $buf);
       if ($conn_resp['action'] !== 0) {
           @socket_close($socket);
           return $ret;
       }
       $connection_id = $conn_resp['connection_id'];

       // Scrape request
       $trans_id = mt_rand(1, 0x7fffffff);
       $scrape_req = pack('JNN', $connection_id, 2, $trans_id);
       $scrape_req .= pack('H*', $hash);

       @socket_sendto($socket, $scrape_req, strlen($scrape_req), 0, $url['host'], $url['port']);

       $buf = '';
       $len = @socket_recvfrom($socket, $buf, 8 + 12, 0, $dummy1, $dummy2);
       @socket_close($socket);

       if ($len < 20) {
           return $ret;
       }

       $scrape_resp = unpack('Naction/Ntrans_id', substr($buf, 0, 8));
       if ($scrape_resp['action'] !== 2 || $scrape_resp['trans_id'] !== $trans_id) {
           return $ret;
       }

       $stats = unpack('Ncomplete/Ndownloaded/Nincomplete', substr($buf, 8, 12));

       $ret['seeds']      = max(0, (int)($stats['complete']   ?? 0));
       $ret['peers']      = max(0, (int)($stats['incomplete'] ?? 0));
       $ret['downloaded'] = max(0, (int)($stats['downloaded'] ?? 0));

       return $ret;
   }

   // ────────────────────────────────────────────────
   // HTTP / HTTPS branch
   // ────────────────────────────────────────────────
   if (!in_array($scheme, ['http', 'https'], true)) {
       return $ret;
   }

   // Build clean scrape URL
   $base = $scheme . '://' . $url['host'];
   if (!empty($url['port']) && $url['port'] != ($scheme === 'https' ? 443 : 80)) {
       $base .= ':' . $url['port'];
   }
   $base .= $url['path'] ?? '/announce';

   $query_params = ['info_hash' => pack('H*', $hash)];
   $scrape_url = $base . '?' . http_build_query($query_params);

   // Fetch response
   if (function_exists('curl_init')) {
       $ch = curl_init($scrape_url);
       curl_setopt_array($ch, [
           CURLOPT_RETURNTRANSFER => true,
           CURLOPT_CONNECTTIMEOUT => 5,
           CURLOPT_TIMEOUT        => 10,
           CURLOPT_USERAGENT      => 'FastTracker Scraper/1.1',
           CURLOPT_SSL_VERIFYPEER => ($scheme === 'https'),
       ]);
       $response = curl_exec($ch);
       curl_close($ch);
   } else {
       ini_set('default_socket_timeout', 10);
       $response = @file_get_contents($scrape_url);
   }

   if (!$response) {
       return $ret;
   }

   // Decode tracker response
   $stats = BDecode($response);
   if (!is_array($stats) || empty($stats['files'])) {
       return $ret;
   }

   $binhash = pack('H*', $hash);
   if (!isset($stats['files'][$binhash])) {
       return $ret;
   }

   $file = $stats['files'][$binhash];
   $ret['seeds']      = max(0, (int)($file['complete']   ?? 0));
   $ret['peers']      = max(0, (int)($file['incomplete'] ?? 0));
   $ret['downloaded'] = max(0, (int)($file['downloaded'] ?? 0));

   return $ret;
}
/////////////// End revised torrent_scrape_url function ////////////

and in torrents-details. Replace from //download box to //end download box
 //download box
if ($row["external"] == 'yes') {
   if ($scrape == '1') {
       print("<td valign='top' align='right'>");

       // Buffering control
       @ini_set('output_buffering', 'Off');
       @ini_set('zlib.output_compression', 'Off');
       @ini_set('implicit_flush', true);
       ob_implicit_flush(true);
       while (ob_get_level() > 0) { ob_end_flush(); }
       flush();

       echo "<b id=\"scrapeStatus\">" . T_("LIVE_STATS") . ": Scraping trackers...</b><br />\n";

       // Progress log
       echo "<div id=\"progressLog\" style=\"max-height:300px; overflow-y:auto; border:1px solid #ccc; padding:10px; background:#f8f8f8; font-family:monospace; margin:12px 0; line-height:1.4;\">\n";

       flush();

       $seeders1    = 0;
       $leechers1   = 0;
       $downloaded1 = 0;
       $has_stats   = false;

       $count_res = SQL_Query_exec("SELECT COUNT(*) as total FROM announce WHERE torrent=$id");
       $count_row = mysqli_fetch_assoc($count_res);
       $total     = (int)$count_row['total'];
       $processed = 0;

       $tres = SQL_Query_exec("SELECT url FROM announce WHERE torrent=$id");
       while ($trow = mysqli_fetch_array($tres)) {
           $processed++;
           $ann = $trow["url"];

           echo "[$processed/$total] $ann ... ";
           flush();

           $tracker = explode("/", $ann);
           $path    = array_pop($tracker);
           $oldpath = $path;
           $path    = preg_replace("/^announce/", "scrape", $path);
           $scrape_url = implode("/", $tracker) . "/" . $path;

           if ($oldpath == $path) {
               echo "<span style=\"color:orange;\">skipped (no scrape support)</span><br />\n";
               flush();
               continue;
           }

           $stats = torrent_scrape_url($scrape_url, $row["info_hash"]);

           if ($stats['seeds'] > 0 || $stats['peers'] > 0 || $stats['downloaded'] > 0) {
               $seeders1    += $stats['seeds'];
               $leechers1   += $stats['peers'];
               $downloaded1 += $stats['downloaded'];
               $has_stats   = true;

               echo "<span style=\"color:green;\">OK</span> ";
               echo "(S: " . number_format($stats['seeds']) . " | L: " . number_format($stats['peers']) . " | C: " . number_format($stats['downloaded']) . ")<br />\n";

               $stmt = $GLOBALS["DBconnector"]->prepare(
                   "UPDATE announce SET online='yes', seeders=?, leechers=?, times_completed=? WHERE url=? AND torrent=?"
               );
               $stmt->bind_param("iiisi", $stats['seeds'], $stats['peers'], $stats['downloaded'], $ann, $id);
               $stmt->execute();
           } else {
               echo "<span style=\"color:red;\">no data / timeout</span><br />\n";

               $stmt = $GLOBALS["DBconnector"]->prepare(
                   "UPDATE announce SET online='no' WHERE url=? AND torrent=?"
               );
               $stmt->bind_param("si", $ann, $id);
               $stmt->execute();
           }

           flush();
           usleep(120000);  // slight delay to reduce server load
       }

       echo "</div>\n";

       echo "
       <script type=\"text/javascript\">
           document.getElementById('scrapeStatus').innerHTML = '" . T_("LIVE_STATS") . ": Completed';
           document.getElementById('scrapeStatus').style.color = '#006600';
       </script>\n";

       // Final stats
       if ($has_stats) {
           echo "<br /><b>Final aggregated stats:</b><br />\n";
           echo "Seeders: " . number_format($seeders1) . "<br />\n";
           echo "Leechers: " . number_format($leechers1) . "<br />\n";
           echo T_("COMPLETED") . ": " . number_format($downloaded1) . "<br />\n";

           $stmt = $GLOBALS["DBconnector"]->prepare(
               "UPDATE torrents SET leechers=?, seeders=?, times_completed=?, last_action=?, visible='yes' WHERE id=?"
           );
           $stmt->bind_param("iiisi", $leechers1, $seeders1, $downloaded1, $last_action = get_date_time(), $row['id']);
           $stmt->execute();
       } else {
           echo "<br /><font color='#ff0000'>All trackers failed or timed out<br />Please retry later</font><br />\n";
       }

       echo "<form action='torrents-details.php?id=$id&scrape=1' method='post' style=\"margin-top:15px;\">\n";
       echo "<input type=\"submit\" name=\"submit\" value=\"Update Stats Again\" />\n";
       echo "</form></td>\n";

       // auto-scroll script
       echo "
       <script type=\"text/javascript\">
       (function() {
           const log = document.getElementById('progressLog');
           if (!log) return;

           // Scroll to bottom function
           function scrollToBottom() {
               log.scrollTop = log.scrollHeight;
           }

           // Initial scroll (in case content already there)
           scrollToBottom();

           // MutationObserver – detects added lines and scrolls
           const observer = new MutationObserver(function(mutations) {
               scrollToBottom();
           });

           observer.observe(log, {
               childList: true,    // watch for added/removed nodes
               subtree: true,      // watch descendants too
               characterData: true // catch text changes
           });

           // Fallback polling (if MutationObserver not supported – very old browsers)
           const interval = setInterval(scrollToBottom, 800);

           // Stop polling once scraping is done (after page fully loads)
           window.addEventListener('load', function() {
               clearInterval(interval);
               scrollToBottom();
           });
       })();
       </script>\n";
   } else {
       if ($CURUSER["class"] > 4) {
           print("<td valign='top' align='right'>");
           print("<form action='torrents-details.php?id=$id&scrape=1' method='post'>");
           print("<input type=\"submit\" name=\"submit\" value=\"Update Stats\" />");
           print("</form></td>");
       }
   }
}

I attached a test torrent for you to try. I edited it and removed alot of the dead trackers, but I left enough for you to see how this works. The original had 85 trackers and most were dead. I cut it to 19, some are live and some are not which makes a good test
test.rar
Download

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)
Last edited by MicroMonkey on 2026-02-24 06:30:14
2026-01-26 09:43:23
Hello, and thank you for your help, but I cannot find the scrape code in my files. I am sending you the three files.

download.zip
Download
functions.zip
Download
torrents-details.zip
Download
Last edited by niki on 2026-01-26 09:44:01
2026-02-03 19:57:23
Here are your functions file and torrents-details file and I inserted the code. Backup your files first as I have no way to test this, you will have to on your setup. The code in your files is extremely outdated so I cant make any promises. The code I posted above is for TTv3, but it may work, you will just have to try it
torrents-details.zip
Download
functions.zip
Download

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)
Last edited by MicroMonkey on 2026-02-03 20:02:42
2026-02-22 16:13:30
Hello I added the code in function.php without problem but as my torrents-details.php file is already quite modified I cannot find where to put the code for udp here is my code for the torrents-details.php file below and thank you for your help


<?php

const DEFAULT_DESCRIPTION = 'No description given.';

require_once("backend/functions.php");
require_once("backend/BDecode.php");
dbconn();

$site_config["LEFTNAV"] = true;

$site_config["MIDDLENAV"] = false;

$site_config["RIGHTNAV"] = false;

$torrent_dir = $site_config["torrent_dir"];
$nfo_dir = $site_config["nfo_dir"];









//************ DO SOME "GET" STUFF BEFORE PAGE LAYOUT ***************

$id = (int) $_GET["id"];
$scrape = (int)$_GET["scrape"];
if (!is_valid_id($id))
show_error_msg(T_("ERROR"), T_("THATS_NOT_A_VALID_ID"), 1);

//GET ALL MYSQL VALUES FOR THIS TORRENT
$res = SQL_Query_exec("SELECT torrents.tube, torrents.category, tube, torrents.anon, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, torrents.nfo, torrents.last_action, torrents.numratings, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.external, torrents.image1, torrents.image2, torrents.ddl, ddl, torrents.announce, torrents.numfiles, torrents.freeleech, torrents.tmdb, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.numratings, categories.name AS cat_name, categories.image AS cat_pic, torrentlang.name AS lang_name, torrentlang.image AS lang_image, categories.parent_cat as cat_parent, users.username, users.privacy FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN torrentlang ON torrents.torrentlang = torrentlang.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id");
$row = mysqli_fetch_assoc($res);




$mycats = $site_config['vip_cats'];
if ($CURUSER['class'] < 2 && in_array($row['category'], $mycats)) {
   autolink('torrents.php', '<center>::: Youpss ... Ce Torrent est pour les Membres VIP Donateur ou les Membres Premium avec un ratio de partage de 2.00 minimum!!! :::</center>');
}


$mycats = $site_config['premium_cats'];
if ($CURUSER['class'] < 2 && in_array($row['category'], $mycats)) {
   autolink('torrents.php', '<center>::: Youpss ... Ce Torrent est pour les Membres VIP Donateur ou les Membres Premium avec un ratio de partage de 2.00 minimum !!! :::</center>');
}




//DECIDE IF TORRENT EXISTS
if (!$row || ($row["banned"] == "yes" && $CURUSER["edit_torrents"] == "no"))
show_error_msg(T_("ERROR"), T_("TORRENT_NOT_FOUND"), 1);

//torrent is availiable so do some stuff

if ($_GET["hit"]) {
SQL_Query_exec("UPDATE torrents SET views = views + 1 WHERE id = $id");
header("Location: torrents-details.php?id=$id");
die;
}

stdhead(T_("DETAILS_FOR_TORRENT")." \"" . $row["name"] . "\"");

if ($CURUSER["id"] == $row["owner"] || $CURUSER["edit_torrents"] == "yes")
$owned = 1;
else
$owned = 0;










//take rating
if ($_GET["takerating"] == 'yes'){
$rating = (int)$_POST['rating'];

if ($rating <= 0 || $rating > 5)
show_error_msg(T_("RATING_ERROR"), T_("INVAILD_RATING"), 1);

$res = SQL_Query_exec("INSERT INTO ratings (torrent, user, rating, added) VALUES ($id, " . $CURUSER["id"] . ", $rating, '".get_date_time()."')");

if (!$res) {
if (mysqli_errno($GLOBALS["DBconnector"]) == 1062)
show_error_msg(T_("RATING_ERROR"), T_("YOU_ALREADY_RATED_TORRENT"), 1);
else
show_error_msg(T_("RATING_ERROR"), T_("A_UNKNOWN_ERROR_CONTACT_STAFF"), 1);
}

SQL_Query_exec("UPDATE torrents SET numratings = numratings + 1, ratingsum = ratingsum + $rating WHERE id = $id");
show_error_msg(T_("RATING_SUCCESS"), T_("RATING_THANK")."<br /><br /><a href='torrents-details.php?id=$id'>" .T_("BACK_TO_TORRENT"). "</a>");
}










//take comment add
if ($_GET["takecomment"] == 'yes'){
loggedinonly();
$body = $_POST['body'];

if (!$body)
show_error_msg(T_("RATING_ERROR"), T_("YOU_DID_NOT_ENTER_ANYTHING"), 1);



SQL_Query_exec("UPDATE torrents SET comments = comments + 1 WHERE id = $id");


// Points Seedbonus By spiritblue
$commentaire = get_row_count("comments", "WHERE torrent = $id AND user = $CURUSER[id]");        
if ($commentaire < 1) {
   SQL_Query_exec("UPDATE users SET seedbonus = seedbonus+20.0 WHERE id = ".$CURUSER["id"]."") ;
}
// End Points Seedbonus


SQL_Query_exec("INSERT INTO comments (user, torrent, added, text) VALUES (".$CURUSER["id"].", ".$id.", '" .get_date_time(). "', " . sqlesc($body).")");

if (mysqli_affected_rows($GLOBALS["DBconnector"]) == 1)
show_error_msg(T_("COMPLETED"), T_("COMMENT_ADDED"), 0);
else
show_error_msg(T_("ERROR"), T_("UNABLE_TO_ADD_COMMENT"), 0);
}//end insert comment

//START OF PAGE LAYOUT HERE
$char1 = 60; //cut length
$shortname = CutName(htmlspecialchars($row["name"]), $char1);




//Common Pot (By OXYDE - torrenttrader.uk)
$res_pot = SQL_Query_exec("SELECT status FROM commonpot_status");
$pot = mysqli_fetch_assoc($res_pot);
//End Common Pot (By OXYDE - torrenttrader.uk)






#===============================================#
# Start TMBD cat_parent Films et Tv: By Gollum  #
#===============================================#
// MOVIES
if(!empty($row["cat_parent"] == $config['MOVIES']))  // Réglage dans config.php
$Film .= "Films";
if(!empty($row["cat_parent"] == $config['DOCUMENTARIES'])) // Réglage dans config.php
$Film .= "Films";
// TV
if(!empty($row["cat_parent"] == $config['TV'])) // Réglage dans config.php
$Serie .= "Serie";
if(!empty($row["cat_parent"] == $config['Pack_Series'])) // Réglage dans config.php
$Serie .= "Serie";
#===============================================#
#  End TMBD cat_parent Films et Tv: By Gollum   #
#===============================================#



// MOVIES
if(!empty($row["cat_parent"] == $config['MOVIES']))
$Film .= "Films";
if(!empty($row["cat_parent"] == $config['DOCUMENTARIES']))
$Film .= "Films";
// TV
if(!empty($row["cat_parent"] == $config['TV']))
$Serie .= "Serie";
if(!empty($row["cat_parent"] == $config['Pack_Series']))
$Serie .= "Serie";
#===============================================#
#  End TMBD cat_parent Films et Tv: By Gollum   #
#===============================================#


begin_frame(T_("TORRENT_DETAILS_FOR"). " \"" . $shortname . "\"");


if ( get_user_class() >= 4 )
echo "<div align='right'>[<a href='report.php?torrent=$id'><b>" .T_("REPORT_TORRENT"). "</b></a>]&nbsp;";

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


if ( get_user_class() >= 4 )
echo "

<div align='right'>


[
<a href='torrents-reseed.php?id=$id'><b><font color='#FC5F52'>Demande de remise en Seed pour ce Torrent</font>

</b></a>]<br>&nbsp;";




echo "</div>";

$userdownloaded = mksize($CURUSER["downloaded"]);

$useruploaded = mksize($CURUSER["uploaded"]);

$seedbonus = $CURUSER["seedbonus"];

if ($CURUSER["downloaded"] > 0) {

$userratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);

}else{

$userratio = "---";

}


if ( get_user_class() >= 1 )
print ("
<center>
<font color=#ff0000><b>&darr;&nbsp;$userdownloaded</b></font>&nbsp;&nbsp;<font color=#00cc00><b>&uarr;&nbsp;$useruploaded</b></font>&nbsp;&nbsp;Ratio&nbsp;:&nbsp;<b>$userratio</b>&nbsp;&nbsp;Seed bonus&nbsp;:&nbsp;<a href='mybonus.php'><b>$seedbonus</b></a></center>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");





echo "<br />";
if ($row["external"]!='yes' && $row["freeleech"]=='1' || $row["external"]!='yes' && $pot["status"] == "started"){




if ( get_user_class() >= 1 )
print ("<center><b>FreeLeech: </b><font color='#179D19'>[Ce Torrent est en FreeLeech, donc seul le ratio en upload compte !] </font></center><br />");

}


if ($CURUSER) {
    //check for new pm's
    $res = SQL_Query_exec("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " and unread='yes' AND location IN ('in','both')");
    $arr = mysqli_fetch_row($res);
    $unreadmail = $arr[0];
    if ($unreadmail)
        print("

<h2><div align='center'><font size='3' color='orange'>


<blink>Salut,Vous avez un nouveau message privé !!! >>>&nbsp; </font></blink>[<a href='mailbox.php?inbox' target='_blank'>Lire ICI</a>]</blink>
</center></b></a></font>
</div>

</h2>

&nbsp;&nbsp;");

}


echo "<center><h1>" . $shortname . "</h1></center>";

// Calculate local torrent speed test
if ($row["leechers"] >= 1 && $row["seeders"] >= 1 && $row["external"]!='yes'){
$speedQ = SQL_Query_exec("SELECT (SUM(p.downloaded)) / (UNIX_TIMESTAMP('".get_date_time()."') - UNIX_TIMESTAMP(added)) AS totalspeed FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' AND p.torrent = '$id' GROUP BY t.id ORDER BY added ASC LIMIT 15");
$a = mysqli_fetch_assoc($speedQ);
$totalspeed = mksize($a["totalspeed"]) . "/s";
}else{
$totalspeed = T_("NO_ACTIVITY");
}

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





////////////////// PARTIE DOWNLOAD ET THANKS///////////


echo "<fieldset class='download'><legend><b>Details...</b></legend>
&nbsp;&nbsp;&nbsp;
";



// === Added DDL
if (!empty($row["ddl"])) {
print ("<center>
<a href='".$row['ddl']."' target='_blank'>
<button>
<b>DOWNLOAD DIRECT (DDL)</b>
</button>

</a><br /></center><br>");
}
else
{
print ("<br /> &nbsp;<br /><br>");
}
// === Added DDL



if ( get_user_class() >= 0 )

print ("




<center>





<li class='nav-item'><a class='nav-link' href='account.php?action=mytorrents
'><i class='fa fa-signal text-blue text-bold'></i>
<button>
<b>
::: Voir mes Torrents actifs :::</b>
</button>

</a>

<b>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<a href=\"mybonus.php\" target='_blank'>

&nbsp;&nbsp;&nbsp;

<button>

<b>MON SEED BONUS</b>

".htmlspecialchars($forums_arr['fcname'])." </button></a>

<a href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\">

&nbsp;&nbsp;&nbsp;&nbsp;

<button>
<b>DOWNLOAD TORRENT</b>
</button>

</a>
</li>
</center>
<br>");

////////////////// END PARTIE DOWNLOAD///////////




echo "



<center><table border='0' width='100%'>";




#========================#
#  Start TMBD By Gollum  #
#========================#

if(!empty($row["tmdb"]) && $Film){
$id_tmdb = $row["tmdb"];
$champ = "id_tmdb";
$total = get_row_count("tmdb"," WHERE id_torrent = $id AND id_tmdb = ".$id_tmdb."");

if($total >0)
require_once($_SERVER["DOCUMENT_ROOT"]."/tmdb/modules/traitement_film.php");
else{
print ("</table>");
require_once($_SERVER["DOCUMENT_ROOT"]."/tmdb/modules/creation_film.php");
die();
}

}elseif(!empty($row["tmdb"]) && $Serie){
$id_tmdb = $row["tmdb"];
$champ = "id_tmdb";
$total = get_row_count("tmdb"," WHERE id_torrent = $id AND id_tmdb = ".$id_tmdb."");

if($total > 0)
require_once($_SERVER["DOCUMENT_ROOT"]."/tmdb/modules/traitement_serie.php");
else{
print ("</table>");
require_once($_SERVER["DOCUMENT_ROOT"]."/tmdb/modules/creation_serie.php");
die();
}
}else{
print("<tr><td align='left'><b>".T_("NAME").":</b></td><td>" . $shortname . "</td></tr>\n");
print("<tr><td align='center' colspan='2'><b>" .T_("DESCRIPTION"). ":</b><br />" .  format_comment($row['descr']) . "</td></tr>\n");
}
#=======================#
#  End TMBD By Gollum   #
#=======================#////////////END DETAIL DESCRIPTION////////////////////



/////ADD a description pulled from the IMDB plot and put it in mysql as the descr
if ($row['descr'] === DEFAULT_DESCRIPTION) {
$stmt = $GLOBALS['DBconnector']->prepare('UPDATE `torrents` SET `descr` = ? WHERE `id` = ?');
$stmt->bind_param('si', $_data->Plot, $id);
$stmt->execute();
$stmt->close();
}
/////////////////////////////////IMDB DESCR CACHE//////////////////////





/////////////////////// VOTE /////////////////////////

// $srating IS RATING VARIABLE

$total_votes = 0;
$total_value = 0;
$query = SQL_Query_exec("SELECT COUNT(torrent) as total_votes, SUM(rating) as total_value FROM `ratings` WHERE `torrent` = '$id'");
while ($rating = mysqli_fetch_array($query)) {
$total_votes = $rating['total_votes'];
$total_value = $rating['total_value'];
}
$voted = get_row_count("ratings", "WHERE `torrent` = '" . $id . "' AND `user` = '" . $CURUSER["id"] . "'");
if ($total_votes < 1) {
$count = 0;
} else {
$count = $total_votes;
}
$current_rating = $total_value;
$tense = ($count == 1) ? "vote" : "votes";
if (is_numeric($current_rating) && is_numeric($count)) {
$rating_width = @number_format($current_rating / $count, 2) * 30;
//$rating_width = @number_format((floatval).$current_rating / $count, 2) * 30;
$rating_1 = @number_format($current_rating / $count, 1);
$rating_2 = @number_format($current_rating / $count, 2);
}

if ( get_user_class() >= 0 )


if (!$voted) {
$rater .= '<div id="unit_long' . $id . '">';
$rater .= '<ul id="unit_ul' . $id . '" class="unit-rating" style="width: ' . 30 * 5 . 'px;">';
$rater .= '<li class="current_rating" style="width: ' . $rating_width . '"px;"> Currently ' . $rating_2 . '/' . 5 . '</li>';
for ($ncount = 1; $ncount <= 5; $ncount++) {
if (!$voted) {
if ($CURUSER)
$rater .='<li><a href="torrents-details.php?id=' . $id . '&takerating=yes&j=' . $ncount . '" title="'.$ncount.' out of 5" class="r'.$ncount.'-unit rater" rel="nofollow">'.$ncount.'</a></li>';
else
$rater .='<li><a href="account-login.php?returnto="' . urlencode($_SERVER["REQUEST_URI"]) . '&nowarn=1" title="'.$ncount.' out of '.$units.'" class="r'.$ncount.'-unit rater" rel="nofollow">'.$ncount.'</a></li>';
}
}
$ncount = 0;
}
$rater .= '</ul>';
$rater .= '<p>';


if ( get_user_class() >= 1 )

if ($voted) {
$static_rater = array();
$static_rater[] .= '<div id="unit_long'.$id.'">';
$static_rater[] .= '<ul id="unit_ul'.$id.'" class="unit-rating" style="width:'. 30*5 .'px;">';
$static_rater[] .= '<li class="current-rating" style="width:'.$rating_width.'px;">Currently '.$rating2.'/'.$units.'</li>';
$static_rater[] .= '</ul>';
$rater .= join("\n", $static_rater);
}
$rater .= '<strong>' . $rating_1 . '</strong>/5 (' . $count . ' ' . $tense . ' cast)';
$rater .= '</p>



';

// $srating IS RATING VARIABLE
$srating = "";
$srating .= "<br><table class='f-border' cellspacing=\"1\" cellpadding=\"4\" width='100%'><tr><td class='f-title' width='60'><b>".T_("RATINGS").":</b></td><td class='f-title' valign='middle'>";
if (!isset($row["rating"])) {
$srating .= "Pas encore de note";
}else{
$rpic = ratingpic($row["rating"]);
if (!isset($rpic))
$srating .= "invalid?";
else
$srating .= "$rpic (" . $row["rating"] . " ".T_("OUT_OF")." 5) " . $row["numratings"] . " ".T_("Membres on donner une note");
}
$srating .= "\n";
if (!isset($CURUSER))
$srating .= "(<a href=\"account-login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&nowarn=1\">Log in</a> to rate it)";
else {
$ratings = array(
5 => T_("COOL"),
4 => T_("PRETTY_GOOD"),
3 => T_("DECENT"),
2 => T_("PRETTY_BAD"),
1 => T_("SUCKS")
);
//if (!$owned || $moderator) {
$xres = SQL_Query_exec("SELECT rating, added FROM ratings WHERE torrent = $id AND user = " . $CURUSER["id"]);
$xrow = mysqli_fetch_assoc($xres);
if ($xrow)
$srating .= "<br /><i>(".T_("YOU_RATED")." \"" . $xrow["rating"] . " - " . $ratings[$xrow["rating"]] . "\")</i>";
else {
$srating .= "<form style=\"display:inline;\" method=\"post\" action=\"torrents-details.php?id=$id&takerating=yes\"><input type=\"hidden\" name=\"id\" value=\"$id\" />\n";




$srating .= "<select name=\"rating\">\n";
$srating .= "<option value=\"0\">(".T_("Noter ce torrent").")</option>\n";
foreach ($ratings as $k => $v) {
$srating .= "<option value=\"$k\">$k - $v</option>\n";
}
$srating .= "</select>\n";
$srating .= "<input type=\"submit\" value=\"".T_("VOTE")."\" />";
$srating .= "</form>\n";
}
//}
}
$srating .= "</td></tr></table>";

print("<center>". $srating . "</center><br>");// rating

//////END VOTE DEFINE RATING VARIABLE//////////////////////





   //START THANKS\\\\
 
$thanksl = explode(",", $row['thanks']);
if ($CURUSER['username'] == $row['username']) {
$leftthanks = true;
$leftthanks2 = true;
} else {
foreach ($thanksl as $u) {
$thanks .= ($i > 0) ? ", $u" : $u;
if ($u == $CURUSER['username']) {
$leftthanks2 = true;
$leftthanks = true;
}
$i++;
}
}


if ( get_user_class() >= 1 )


if (!$leftthanks2) {
$button='<br/><center><input type="button" value="Dire merci pour ce torrent" id="refresh"></center><br>';


} else {
$button='';
}


if ( get_user_class() >= 1 )

echo '<table align="center"><b>Merci par : </b></table>

<div id="thankput"></div>'.$button.'
<script type="text/javascript" src="'.$site_config["SITEURL"].'/js/thanks.js"></script>


<script type="text/javascript">
var $s = jQuery.noConflict();

$s("#thankput").load("thanks.php?id='.$id.'");
$s(function() {
$s("#refresh").click(function() {
$s("#thankput").empty().html(\'<center><img src="'.$site_config["SITEURL"].'/images/ajax-loader.gif"></center>\');

$s("#thankput").load("thanks.php?id='.$id.'&to=give&torrent='.$id.'")
return false;
})
})
</script>

';

////END THANKS\\\\\




//download box
echo "
<center><table border='0' width='100%' height='30%'><tr><td>
<div id='downloadbox'>";
if ($row["banned"] == "yes"){
print ("<center><b>" .T_("DOWNLOAD"). ": </b>BANNED!</center>");
}else{


if (!$_data->Plot) {
print ("<table border='0' cellpadding='0' width='90%'><tr><td align='center' valign='middle' width='54'><a href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\">

<img src='".$site_config["SITEURL"]."/uploads/images/$row[image1]'width='145' 'height='193'  border='2' alt='' />


</a>
<br><br>









<a>

<button>
<b>Seed:
</b>


<font color='#179D19'>" . number_format($row["seeders"]) . "</font></a>

&nbsp;



<b>Leech:
</b>


<font color='#FC6539'>" .  number_format($row["leechers"]) . "</font>

</button>
</a>");

}



print ("<center>


<td valign='top'>


<a href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\">


<br>

&nbsp;&nbsp;&nbsp;


</a>

<br>");

if ( get_user_class() >= 1 )

print ("

<B>


&nbsp;&nbsp;&nbsp;


<b>" .T_("HEALTH"). ": </b><img src='".$site_config["SITEURL"]."/images/health/health_".health($row["leechers"], $row["seeders"]).".gif' alt='' />

<br><br>



&nbsp;&nbsp;&nbsp;


<b>
Genre:
</b>

&nbsp;


<b>
" . $row["cat_name"] . "
</b>


<br><br>

&nbsp;&nbsp;&nbsp;

<b>
" . $row["lang_name"] . "
</b>



&nbsp;


<img border=\"0\" src=\"" . $site_config['SITEURL'] . "/images/languages/" . $row["lang_image"] . "\" alt=\"" . $row["lang_name"] . "\" />


<br><br>

&nbsp;&nbsp;&nbsp;

<b>
Poids du fichier:</b>
&nbsp;

<b>
" . mksize($row["size"]) . "
</b>


<br><br>



&nbsp;&nbsp;&nbsp;

<b> Notes:</b>

&nbsp;

<a title='$row[rating]/5'>".ratingpic($row["rating"])."</a>



<br><br>


&nbsp;&nbsp;&nbsp;


<b>
Up le:</b>
&nbsp;


<b>
" . date("d-m-Y H:i:s", utc_to_tz_time($row["added"])) . "
</b>


<br><br>

");


print("");


if ( get_user_class() >= 3 )

if ($row["anon"] == "yes" && !$owned)
print("<tr>&nbsp;&nbsp;&nbsp;
<b>Torrent Partager par:&nbsp;
</b><b>Anonymous</b>");

elseif ($row["username"])
print("&nbsp;&nbsp;&nbsp;
<b>
Torrent Partager par:&nbsp;
</b><a href='account-details.php?id=" . $row["owner"] . "'>

".class_user($row['username'])."


</a>");
else

print("&nbsp;&nbsp;&nbsp;
<b>Torrent Partager par:&nbsp;
</b><b>Unknown</b></td><br>");



if ( get_user_class() >= 1 )
if ($row["external"]!='yes' && $row["freeleech"]=='1'){



if ( get_user_class() >= 1 )
print ("<b>&nbsp;&nbsp;&nbsp;




<font color='#799799' size='3'> ".htmlspecialchars($forums_arr['fcname'])." </font>


<br /><br>

");
}




/////////////////////YOTUBE//////////////////////////
if (!empty($row["tube"]))
print ("<td>
<center>
<embed src='". str_replace("watch?v=", "v/", htmlspecialchars($row["tube"])) ."' type=\"application/x-shockwave-flash\" width=\"600\" height=\"270\"></embed>
</center></td>");

else

print ("<td><center>
<img border=\"2\" width=\"600\" height=\"270\" src=".$site_config["SITEURL"]."/images/novideo.jpg></center>
</td>");
////////////////////EN YOUTUBE///////////////////////





if ($row["external"]=='yes'){

if ($scrape =='1'){
print("<td valign='top' align='right'><b>Tracked: </b>EXTERNAL<br /><br />");
$seeders1 = $leechers1 = $downloaded1 = null;

$tres = SQL_Query_exec("SELECT url FROM announce WHERE torrent=$id");
while ($trow = mysqli_fetch_assoc($tres)) {
$ann = $trow["url"];
$tracker = explode("/", $ann);
$path = array_pop($tracker);
$oldpath = $path;
$path = preg_replace("/^announce/", "scrape", $path);
$tracker = implode("/", $tracker)."/".$path;

if ($oldpath == $path) {
continue; // Scrape not supported, ignored
}

// TPB's tracker is dead. Use openbittorrent instead
if (preg_match("/thepiratebay.org/i", $tracker) || preg_match("/prq.to/", $tracker)) {
$tracker = "http://tracker.openbittorrent.com/scrape";
}

$stats = torrent_scrape_url($tracker, $row["info_hash"]);
if ($stats['seeds'] != -1) {
$seeders1 += $stats['seeds'];
$leechers1 += $stats['peers'];
$downloaded1 += $stats['downloaded'];
SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed` = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` = $id");
} else {
SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $id");

}
}

if ($seeders1 !== null){ //only update stats if data is received
print ("<b>".T_("LIVE_STATS").": </b><br />");
print ("Seeders: ".number_format($seeders1)."<br />");
print ("Leechers: ".number_format($leechers1)."<br />");
print (T_("COMPLETED").": ".number_format($downloaded1)."<br />");

SQL_Query_exec("UPDATE torrents SET leechers='".$leechers1."', seeders='".$seeders1."', times_completed='".$downloaded1."',last_action= '".get_date_time()."',visible='yes' WHERE id='".$row['id']."'");
}else{
print ("<b>".T_("LIVE_STATS").": </b><br />");
print ("<font color='#ff0000'>Tracker Timeout<br />Please retry later</font><br />");
}

print ("<form action='torrents-details.php?id=$id&scrape=1' method='post'><input type=\"submit\" name=\"submit\" value=\"Update Stats\" /></form></td>");
}else{
print ("<td valign='top' align='right'><b>Tracked:</b> EXTERNAL<br /><br /><form action='torrents-details.php?id=$id&scrape=1' method='post'><input type=\"submit\" name=\"submit\" value=\"Update Stats\" /></form></td>");
}
}

echo "</tr>



</table>";
}
echo "</div>



<br>
<center>
<b>
[Dire merci = 10 points Seed Bonus]
</b>
&nbsp;

:::

&nbsp;

<b>
[1 Commentaire = 20 points Seed Bonus]
</b>
</center>
<br>


<center>
<b>Pour télécharger vous devez installer Utorrent !!!</b>
&nbsp;>>&nbsp;

<button>
<a href=\"/clients-bittorrent/1.8.4_utorrent-1.8.4.exe\" target='_blank'>&nbsp;&nbsp;
<b>UTorrent </b>
</button>

&nbsp;:::&nbsp;

<button>
<a href=\"/clients-bittorrent/qbittorrent_4.3.9_setup.exe\" target='_blank'>&nbsp;&nbsp;
<b>qBittorrent</b>
</button>

&nbsp;:::&nbsp;

<button>
<a href=\"/clients-bittorrent/uTorrent.dmg\" target='_blank'>&nbsp;&nbsp;
<b>UTorrent pour Mac</b>
</button></center>

<br>



</td></tr></table></center><br /><br />";
//end download box




if ( get_user_class() >= 4 )
print("<tr><td align='left'><b>Torrent terminé :</b></td><td>

<a href='torrents-completed.php?id=$id'><font color='#ff0000'><b>" .T_("WHOS_COMPLETED"). "</b></a></font>
&nbsp; <b> Complet:&nbsp;</b>
" . number_format($row["times_completed"]) . "</td></tr>
<tr><tr><tr><tr>\n");




if (!empty($row["tube"]))
print ("<tr>


<br><br>


</td></tr>");


else



print ("");




echo "</table></fieldset>";



   ////////////// Similar Torrents mod /////////////////////
begin_frame(T_("SIMILAR_TORRENTS"));
           $char1 = 50; //cut length
           $shortname = CutName(htmlspecialchars($a["name"]), $char1);
           $searchname = substr($row['name'], 0, 8);
           $query1 = str_replace(" ", ".", sqlesc("%" . $searchname . "%"));
           $query2 = str_replace(".", " ", sqlesc("%" . $searchname . "%"));
$r = SQL_Query_exec("SELECT torrents.id,  torrents.name,  torrents.size,  torrents.added,  torrents.seeders,  torrents.leechers,  torrents.category, categories.image FROM torrents LEFT JOIN categories ON (categories.id = torrents.category) WHERE (torrents.name LIKE {$query1} AND seeders > '0' AND torrents.id <> '$id') OR (torrents.name LIKE {$query2} AND seeders > '0' AND torrents.id <> '$id') ORDER BY seeders DESC LIMIT 10");
 
   if (mysqli_num_rows($r) > 0) {
           echo "<table width=90% class=main border=1 cellspacing=0 cellpadding=0 class=table_table>\n" . "
           <tr>
                   <td class='table_head' width='20'>Type</td>
                   <td class='table_head'>Name</td>
                   <td class='table_head' align='center'>Size</td>
                   <td class='table_head' align='center'>Added</td>
                   <td class='table_head' align='center'>S</td>
                   <td class='table_head' align='center'>L</td></tr>\n";
 
   while ($a = mysqli_fetch_assoc($r)) {
 //          $r2 = SQL_Query_exec("SELECT name, image FROM categories WHERE id=$a[category]");
 //          $a2 = mysqli_fetch_assoc($r2);
           $cat = "<img class=glossy src=\"images/categories//$a[image]\" alt=\"$a[name]\" title=\"$row[cat_parent] : $row[cat_name]\"\>";
           $name = $a["name"];
 
           echo"<tr><td class='table_col1' style='padding: 1px' align='center'>$cat</td>
                    <td class='table_col1'><a title=".$a["name"]." href=torrents-details.php?id=" . $a["id"] . "&hit=1><b>" . CutName(htmlspecialchars($a["name"]), $char1) . "</b><br/></a></td>
                    <td class='table_col1' style='padding: 1px' align='center'>" . mksize($a[size]) . "</td>
                    <td class='table_col1' style='padding: 1px' align='center'>$a[added]</td>
                    <td class='table_col1' style='padding: 1px' align='center'><span style='color:Chartreuse'>$a[seeders]</span></td>
                    <td class='table_col1' style='padding: 1px' align=center><span style='color:red'>$a[leechers]</span></td></tr>\n";
   }
     
   echo "</table>";
     
   }
               else {
                   print(T_("NO_SIMILAR_TORRENT_FOUND"));
               }
end_frame();
   ////////////// End Similar Torrents mod /////////////////////





echo "<br />";
   

                                             
if ($row["image1"] != "" OR $row["image2"] != "") {
 if ($row["image1"] != "")
   $img1 = "<img src='".$site_config["SITEURL"]."/uploads/images/$row[image1]' width='0' border='0' alt='' />";
 if ($row["image2"] != "")
   $img2 = "<img src='".$site_config["SITEURL"]."/uploads/images/$row[image2]' width='150' border='0' alt='' />";
 print("<center>". $img1 . "&nbsp;&nbsp;" . $img2."</center><br />");
}



if ($row["external"]=='yes'){
print ("<br /><b>Tracker:</b><br /> ".htmlspecialchars($row['announce'])."<br />");
}

$tres = SQL_Query_exec("SELECT * FROM `announce` WHERE `torrent` = $id");



if ( get_user_class() >= 3 )

if ($row["external"]!='yes'){
echo "<br /><br /><b>".T_("PEERS_LIST").":</b><br />";
$query = SQL_Query_exec("SELECT * FROM peers WHERE torrent = $id ORDER BY seeder DESC");

$result = mysqli_num_rows($query);
if($result == 0) {
echo T_("NO_ACTIVE_PEERS")."\n";
}else{
?>

           <table border="0" cellpadding="3" cellspacing="0" width="100%" class="table_table">
<tr>
               <th class="table_head"><?php echo T_("PORT"); ?></th>
   <th class="table_head"><?php echo T_("UPLOADED"); ?></th>
   <th class="table_head"><?php echo T_("DOWNLOADED"); ?></th>
   <th class="table_head"><?php echo T_("RATIO"); ?></th>
   <th class="table_head"><?php echo T_("_LEFT_"); ?></th>
   <th class="table_head"><?php echo T_("FINISHED_SHORT"). "%"; ?></th>
   <th class="table_head"><?php echo T_("SEED"); ?></th>
   <th class="table_head"><?php echo T_("CONNECTED_SHORT"); ?></th>
   <th class="table_head"><?php echo T_("CLIENT"); ?></th>
   <th class="table_head"><?php echo T_("USER_SHORT"); ?></th>
</tr>

<?php
while($row1 = mysqli_fetch_assoc($query)) {

if ($row1["downloaded"] > 0){
$ratio = $row1["uploaded"] / $row1["downloaded"];
$ratio = number_format($ratio, 3);
}else{
$ratio = "---";
}

$percentcomp = sprintf("%.2f", 100 * (1 - ($row1["to_go"] / $row["size"])));    

if ($site_config["MEMBERSONLY"]) {
$res = SQL_Query_exec("SELECT id, username, privacy FROM users WHERE id=".$row1["userid"]."");
$arr = mysqli_fetch_array($res);
                   
                   $arr["username"] = "<a href='account-details.php?id=$arr[id]'>$arr[username]</a>";
}
               
               # With $site_config["MEMBERSONLY"] off this will be shown.
               if ( !$arr["username"] ) $arr["username"] = "Unknown User";
       
if ($arr["privacy"] != "strong" || ($CURUSER["control_panel"] == "yes")) {
print("<tr><td class='table_col2'>".$row1["port"]."</td><td class='table_col1'>".mksize($row1["uploaded"])."</td><td class='table_col2'>".mksize($row1["downloaded"])."</td><td class='table_col1'>".$ratio."</td><td class='table_col2'>".mksize($row1["to_go"])."</td><td class='table_col1'>".$percentcomp."%</td><td class='table_col2'>$row1[seeder]</td><td class='table_col1'>$row1[connectable]</td><td class='table_col2'>".htmlspecialchars($row1["client"])."</td><td class='table_col1'>$arr[username]</td></tr>");
}else{
print("<tr><td class='table_col2'>".$row1["port"]."</td><td class='table_col1'>".mksize($row1["uploaded"])."</td><td class='table_col2'>".mksize($row1["downloaded"])."</td><td class='table_col1'>".$ratio."</td><td class='table_col2'>".mksize($row1["to_go"])."</td><td class='table_col1'>".$percentcomp."%</td><td class='table_col2'>$row1[seeder]</td><td class='table_col1'>$row1[connectable]</td><td class='table_col2'>".htmlspecialchars($row1["client"])."</td><td class='table_col1'>Private</td></tr>");
}

}
echo "</table>";
}
}

echo "<br /><br />";

//DISPLAY NFO BLOCK
function my_nfo_translate($nfo){
       $trans = array(
       "\x80" => "&#199;", "\x81" => "&#252;", "\x82" => "&#233;", "\x83" => "&#226;", "\x84" => "&#228;", "\x85" => "&#224;", "\x86" => "&#229;", "\x87" => "&#231;", "\x88" => "&#234;", "\x89" => "&#235;", "\x8a" => "&#232;", "\x8b" => "&#239;", "\x8c" => "&#238;", "\x8d" => "&#236;", "\x8e" => "&#196;", "\x8f" => "&#197;", "\x90" => "&#201;",
       "\x91" => "&#230;", "\x92" => "&#198;", "\x93" => "&#244;", "\x94" => "&#246;", "\x95" => "&#242;", "\x96" => "&#251;", "\x97" => "&#249;", "\x98" => "&#255;", "\x99" => "&#214;", "\x9a" => "&#220;", "\x9b" => "&#162;", "\x9c" => "&#163;", "\x9d" => "&#165;", "\x9e" => "&#8359;", "\x9f" => "&#402;", "\xa0" => "&#225;", "\xa1" => "&#237;",
       "\xa2" => "&#243;", "\xa3" => "&#250;", "\xa4" => "&#241;", "\xa5" => "&#209;", "\xa6" => "&#170;", "\xa7" => "&#186;", "\xa8" => "&#191;", "\xa9" => "&#8976;", "\xaa" => "&#172;", "\xab" => "&#189;", "\xac" => "&#188;", "\xad" => "&#161;", "\xae" => "&#171;", "\xaf" => "&#187;", "\xb0" => "&#9617;", "\xb1" => "&#9618;", "\xb2" => "&#9619;",
       "\xb3" => "&#9474;", "\xb4" => "&#9508;", "\xb5" => "&#9569;", "\xb6" => "&#9570;", "\xb7" => "&#9558;", "\xb8" => "&#9557;", "\xb9" => "&#9571;", "\xba" => "&#9553;", "\xbb" => "&#9559;", "\xbc" => "&#9565;", "\xbd" => "&#9564;", "\xbe" => "&#9563;", "\xbf" => "&#9488;", "\xc0" => "&#9492;", "\xc1" => "&#9524;", "\xc2" => "&#9516;", "\xc3" => "&#9500;",
       "\xc4" => "&#9472;", "\xc5" => "&#9532;", "\xc6" => "&#9566;", "\xc7" => "&#9567;", "\xc8" => "&#9562;", "\xc9" => "&#9556;", "\xca" => "&#9577;", "\xcb" => "&#9574;", "\xcc" => "&#9568;", "\xcd" => "&#9552;", "\xce" => "&#9580;", "\xcf" => "&#9575;", "\xd0" => "&#9576;", "\xd1" => "&#9572;", "\xd2" => "&#9573;", "\xd3" => "&#9561;", "\xd4" => "&#9560;",
       "\xd5" => "&#9554;", "\xd6" => "&#9555;", "\xd7" => "&#9579;", "\xd8" => "&#9578;", "\xd9" => "&#9496;", "\xda" => "&#9484;", "\xdb" => "&#9608;", "\xdc" => "&#9604;", "\xdd" => "&#9612;", "\xde" => "&#9616;", "\xdf" => "&#9600;", "\xe0" => "&#945;", "\xe1" => "&#223;", "\xe2" => "&#915;", "\xe3" => "&#960;", "\xe4" => "&#931;", "\xe5" => "&#963;",
       "\xe6" => "&#181;", "\xe7" => "&#964;", "\xe8" => "&#934;", "\xe9" => "&#920;", "\xea" => "&#937;", "\xeb" => "&#948;", "\xec" => "&#8734;", "\xed" => "&#966;", "\xee" => "&#949;", "\xef" => "&#8745;", "\xf0" => "&#8801;", "\xf1" => "&#177;", "\xf2" => "&#8805;", "\xf3" => "&#8804;", "\xf4" => "&#8992;", "\xf5" => "&#8993;", "\xf6" => "&#247;",
       "\xf7" => "&#8776;", "\xf8" => "&#176;", "\xf9" => "&#8729;", "\xfa" => "&#183;", "\xfb" => "&#8730;", "\xfc" => "&#8319;", "\xfd" => "&#178;", "\xfe" => "&#9632;", "\xff" => "&#160;",
       );
       $trans2 = array("\xe4" => "&auml;",        "\xF6" => "&ouml;",        "\xFC" => "&uuml;",        "\xC4" => "&Auml;",        "\xD6" => "&Ouml;",        "\xDC" => "&Uuml;",        "\xDF" => "&szlig;");
       $all_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
       $last_was_ascii = False;
       $tmp = "";
       $nfo = $nfo . "\00";
       for ($i = 0; $i < (strlen($nfo) - 1); $i++)
       {
               $char = $nfo[$i];
               if (isset($trans2[$char]) and ($last_was_ascii or strpos($all_chars, ($nfo[$i + 1]))))
               {
                       $tmp = $tmp . $trans2[$char];
                       $last_was_ascii = True;
               }
               else
               {
                       if (isset($trans[$char]))
                       {
                               $tmp = $tmp . $trans[$char];
                       }
                       else
                       {
                           $tmp = $tmp . $char;
                       }
                       $last_was_ascii = strpos($all_chars, $char);
               }
       }
       return $tmp;
}
//-----------------------------------------------

//DISPLAY NFO BLOCK
if($row["nfo"]== "yes"){
$nfofilelocation = "$nfo_dir/$row[id].nfo";
$filegetcontents = file_get_contents($nfofilelocation);
$nfo = htmlspecialchars($filegetcontents);
if ($nfo) {
$nfo = my_nfo_translate($nfo);
echo "<br /><br /><b>NFO:</b><br />";
print("<textarea class='nfo' style='width:98%;height:100%;' rows='20' cols='20' readonly='readonly'>".stripslashes($nfo)."</textarea>");
       }else{
           print(T_("ERROR")." reading .nfo file!");
       }
}
end_frame();





if ( get_user_class() >= 1 )


begin_frame(T_("COMMENTS"));

//echo "<p align=center><a class=index href=torrents-comment.php?id=$id>" .T_("ADDCOMMENT"). "</a></p>\n";

$subres = SQL_Query_exec("SELECT COUNT(*) FROM comments WHERE torrent = $id");
$subrow = mysqli_fetch_array($subres);
$commcount = $subrow[0];

if ($commcount) {
list($pagertop, $pagerbottom, $limit) = pager(10, $commcount, "torrents-details.php?id=$id&");
$commquery = "SELECT comments.id, text, user, comments.added, avatar, signature, username, title, class, uploaded, downloaded, privacy, donated FROM comments LEFT JOIN users ON comments.user = users.id WHERE torrent = $id ORDER BY comments.id $limit";
$commres = SQL_Query_exec($commquery);
}else{
unset($commres);
}


if ( get_user_class() >= 1 )

if ($commcount) {
print($pagertop);
commenttable($commres, 'torrent');
print($pagerbottom);
}else {
print("<br /><b>" .T_("NOCOMMENTS"). "</b><br />\n");
}

require_once("backend/bbcode.php");

if ($CURUSER) {
echo "<center>";
echo "<form name=\"comment\" method=\"post\" action=\"torrents-details.php?id=$row[id]&takecomment=yes\">";
echo textbbcode("comment","body")."<br />";
echo "<input type=\"submit\"  value=\"".T_("ADDCOMMENT")."\" />";
echo "</form></center>";
}

end_frame();

stdfoot();
?>
2026-02-22 18:43:26
Try replacing this part of your code. You will have to test and see if its right for your file.
if ($row["external"]=='yes'){

if ($scrape =='1'){
print("<td valign='top' align='right'><b>Tracked: </b>EXTERNAL<br /><br />");
$seeders1 = $leechers1 = $downloaded1 = null;

$tres = SQL_Query_exec("SELECT url FROM announce WHERE torrent=$id");
while ($trow = mysqli_fetch_assoc($tres)) {
$ann = $trow["url"];
$tracker = explode("/", $ann);
$path = array_pop($tracker);
$oldpath = $path;
$path = preg_replace("/^announce/", "scrape", $path);
$tracker = implode("/", $tracker)."/".$path;

if ($oldpath == $path) {
continue; // Scrape not supported, ignored
}

// TPB's tracker is dead. Use openbittorrent instead
if (preg_match("/thepiratebay.org/i", $tracker) || preg_match("/prq.to/", $tracker)) {
$tracker = "http://tracker.openbittorrent.com/scrape";
}

$stats = torrent_scrape_url($tracker, $row["info_hash"]);
if ($stats['seeds'] != -1) {
$seeders1 += $stats['seeds'];
$leechers1 += $stats['peers'];
$downloaded1 += $stats['downloaded'];
SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed` = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` = $id");
} else {
SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $id");

}
}

if ($seeders1 !== null){ //only update stats if data is received
print ("<b>".T_("LIVE_STATS").": </b><br />");
print ("Seeders: ".number_format($seeders1)."<br />");
print ("Leechers: ".number_format($leechers1)."<br />");
print (T_("COMPLETED").": ".number_format($downloaded1)."<br />");

SQL_Query_exec("UPDATE torrents SET leechers='".$leechers1."', seeders='".$seeders1."', times_completed='".$downloaded1."',last_action= '".get_date_time()."',visible='yes' WHERE id='".$row['id']."'");
}else{
print ("<b>".T_("LIVE_STATS").": </b><br />");
print ("<font color='#ff0000'>Tracker Timeout<br />Please retry later</font><br />");
}

print ("<form action='torrents-details.php?id=$id&scrape=1' method='post'><input type=\"submit\" name=\"submit\" value=\"Update Stats\" /></form></td>");
}else{
print ("<td valign='top' align='right'><b>Tracked:</b> EXTERNAL<br /><br /><form action='torrents-details.php?id=$id&scrape=1' method='post'><input type=\"submit\" name=\"submit\" value=\"Update Stats\" /></form></td>");
}
}

echo "</tr>



</table>";
}
echo "</div>



<br>
<center>
<b>
[Dire merci = 10 points Seed Bonus]
</b>
&nbsp;

:::

&nbsp;

<b>
[1 Commentaire = 20 points Seed Bonus]
</b>
</center>
<br>


<center>
<b>Pour télécharger vous devez installer Utorrent !!!</b>
&nbsp;>>&nbsp;

<button>
<a href=\"/clients-bittorrent/1.8.4_utorrent-1.8.4.exe\" target='_blank'>&nbsp;&nbsp;
<b>UTorrent </b>
</button>

&nbsp;:::&nbsp;

<button>
<a href=\"/clients-bittorrent/qbittorrent_4.3.9_setup.exe\" target='_blank'>&nbsp;&nbsp;
<b>qBittorrent</b>
</button>

&nbsp;:::&nbsp;

<button>
<a href=\"/clients-bittorrent/uTorrent.dmg\" target='_blank'>&nbsp;&nbsp;
<b>UTorrent pour Mac</b>
</button></center>

<br>



</td></tr></table></center><br /><br />";

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)
2026-02-23 08:56:48
Thanks MicroMonkey, but when I replace that part of the code, I get a blank page with

HTTP ERROR 500
Last edited by niki on 2026-02-23 10:47:41
2026-02-23 19:54:00
I had a typo in my code above. fixed. try again. Ignore the 2 files I attached here. I cant delete them since this forum is broken
torrents-details.php
Download
torrents-details.zip
Download

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)
Last edited by MicroMonkey on 2026-02-24 06:54:01
2026-02-24 18:47:43
Thank you MicroMonkey, there are no more error messages, but can you tell me how to retrieve seeds and leeches from external trackers in UDP, or how to retrieve seeds and leeches in UDP?
2026-02-24 21:51:21
You should have a button to click that will execute the scrape on the torrents-details page of the external torrent and display the tracker stats and final aggregated totals https://i.postimg.cc/3x40W0jj/Screenshot-2026-02-24-164930.png and here https://postimg.cc/LJ8r5Fqx and here https://i.postimg.cc/Px9rg29f/Screenshot-2026-02-24-165417.jpg
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)
Last edited by MicroMonkey on 2026-02-24 21:55:44
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: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728