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 scraper fix
You don't have permission for this action!
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / General / General Chat

2025-03-20 09:01:15
Hi, @YadJoe you can try to leave your fix here

Thanks and Regards


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2025-03-20 09:18:06
Fixing Seed/Leech Update Issue on TTV3 - A Step-by-Step Guide

I encountered an issue with the seed/leech update on TTV3. It has been days, and I truly appreciate the messages from the OGS. It seems like a new issue has arisen. Today, I managed to find a solution. While it's a workaround, it's working as expected.

Step 1: Add a New Row to the Torrent Table
To resolve the issue, the first thing you need to do is add a new column to the torrent table. You can do this with the following SQL query:


ALTER TABLE torrents ADD COLUMN last_updated TIMESTAMP DEFAULT (CURRENT_TIMESTAMP - INTERVAL 8 DAY) ON UPDATE CURRENT_TIMESTAMP;


Step 2: Create a New PHP File
Next, create a new PHP file on your server or hosting. This file will be responsible for updating the torrent stats.

Here's the PHP code you'll need:


<?php
/**********************************************
* Torrent Stats Updater
* Instructions:
* 1. Configure database settings below
* 2. Install dependencies: `sudo apt-get install php-cli`
* 3. Run: `php tracker-updater.php`
* 4. Recommended to run as background process
**********************************************/

// Database Configuration
require_once "backend/functions.php";
dbconn();

// Tracker Configuration (HTTP trackers only)
$trackers = [
  "http://tracker.opentrackr.org:1337/announce",
  "http://tracker810.xyz:11450/announce",
  "http://tracker.xiaoduola.xyz:6969/announce",
  "http://tracker.ipv6tracker.org:80/announce",
  "http://tracker.dmcomic.org:2710/announce",
  "http://tracker.bittor.pw:1337/announce",
  "http://t.jaekr.sh:6969/announce",
  "http://shubt.net:2710/announce",
  "http://share.hkg-fansub.info:80/announce.php",
  "http://retracker.spark-rostov.ru:80/announce",
  "http://open.trackerlist.xyz:80/announce",
  "http://home.yxgz.club:6969/announce",
  "http://highteahop.top:6960/announce",
  "http://finbytes.org:80/announce.php",
  "http://bt.poletracker.org:2710/announce",
  "http://www.torrentsnipe.info:2701/announce",
  "http://www.genesis-sp.org:2710/announce",
  "http://wepzone.net:6969/announce",
  "http://tracker2.dler.org:80/announce",
  "http://tracker.waaa.moe:6969/announce",
  "http://tracker.vanitycore.co:6969/announce",
  "http://tracker.sbsub.com:2710/announce",
  "http://tracker.renfei.net:8080/announce",
  "http://tracker.mywaifu.best:6969/announce",
  "http://tracker.moxing.party:6969/announce",
  "http://tracker.lintk.me:2710/announce",
  "http://tracker.edkj.club:6969/announce",
  "http://tracker.dler.org:6969/announce",
  "http://tracker.dler.com:6969/announce",
  "http://tracker.darkness.services:6969/announce",
  "http://tracker.corpscorp.online:80/announce",
  "http://tracker.bz:80/announce",
  "http://tracker.bt4g.com:2095/announce",
  "http://tracker.bt-hash.com:80/announce",
  "http://tr.nyacat.pw:80/announce",
  "http://taciturn-shadow.spb.ru:6969/announce",
  "http://t.overflow.biz:6969/announce",
  "http://servandroidkino.ru:80/announce",
  "http://seeders-paradise.org:80/announce",
  "http://p4p.arenabg.com:1337/announce",
  "http://fleira.no:6969/announce",
  "http://ch3oh.ru:6969/announce",
  "http://buny.uk:6969/announce",
  "http://bt1.xxxxbt.cc:6969/announce",
  "http://bittorrent-tracker.e-n-c-r-y-p-t.net:1337/announce",
  "http://0d.kebhana.mx:443/announce",
  "http://0123456789nonexistent.com:80/announce",
  "http://tracker.zhuqiy.top:80/announce",
  "http://tracker.ghostchu-services.top:80/announce",
  "http://tracker.23794.top:6969/announce",
  "http://open.acgtracker.com:1096/announce",
  "http://4.tracker.devnak.win:6969/announce",
  "http://1337.abcvg.info:80/announce"
];

// Logging Configuration
$logFile = __DIR__.'/tracker-updater.log';

// BDecode Implementation
function bdecode($s, &$pos=0) {
   $result = [];
   while($pos < strlen($s)) {
       $type = $s[$pos];
       
       if($type === 'i') {
           $pos++;
           $end = strpos($s, 'e', $pos);
           $result = (int)substr($s, $pos, $end - $pos);
           $pos = $end + 1;
           return $result;
       }
       
       if($type === 'l') {
           $pos++;
           $result = [];
           while($s[$pos] !== 'e') {
               $result[] = bdecode($s, $pos);
           }
           $pos++;
           return $result;
       }
       
       if($type === 'd') {
           $pos++;
           $result = [];
           while($s[$pos] !== 'e') {
               $key = bdecode($s, $pos);
               $value = bdecode($s, $pos);
               $result[$key] = $value;
           }
           $pos++;
           return $result;
       }
       
       if(is_numeric($type)) {
           $lenEnd = strpos($s, ':', $pos);
           $length = (int)substr($s, $pos, $lenEnd - $pos);
           $pos = $lenEnd + 1;
           $result = substr($s, $pos, $length);
           $pos += $length;
           return $result;
       }
       
       $pos++;
   }
   return $result;
}

// Connect to Database
try {
   $pdo = new PDO("mysql:host=$dbHost;dbname=$dbName", $dbUser, $dbPass);
   $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
   file_put_contents($logFile, date('Y-m-d H:i:s')." - Database connection failed: ".$e->getMessage()."\n", FILE_APPEND);
   exit(1);
}

file_put_contents($logFile, date('Y-m-d H:i:s')." - Service started\n", FILE_APPEND);

// Main loop
while(true) {
   try {
       // Get oldest torrent that needs updating
       $stmt = $pdo->prepare("
           SELECT id, info_hash
           FROM torrents
           WHERE last_updated < NOW() - INTERVAL 1 WEEK
           ORDER BY last_updated ASC
           LIMIT 1
       ");
       $stmt->execute();
       $torrent = $stmt->fetch(PDO::FETCH_ASSOC);

       if(!$torrent) {
           file_put_contents($logFile, date('Y-m-d H:i:s')." - No torrents need updating\n", FILE_APPEND);
           sleep(300);
           continue;
       }

       $infoHash = hex2bin($torrent['info_hash']);
       $torrentId = $torrent['id'];
       $peerId = '-PC0001-'.substr(md5(mt_rand()), 0, 12);

       $seeders = 0;
       $leechers = 0;

       foreach($trackers as $tracker) {
           try {
               $query = http_build_query([
                   'info_hash'  => $infoHash,
                   'peer_id'    => $peerId,
                   'port'       => 6881,
                   'uploaded'   => 0,
                   'downloaded' => 0,
                   'left'       => 0,
                   'compact'    => 1,
                   'event'      => 'started'
               ]);

               $context = stream_context_create(['http' => ['timeout' => 5]]);
               $response = @file_get_contents("$tracker?$query", false, $context);

               if($response) {
                   $data = bdecode($response);
                   if(isset($data['complete']) && isset($data['incomplete'])) {
                       $seeders = (int)$data['complete'];
                       $leechers = (int)$data['incomplete'];
                       break;
                   }
               }
           } catch(Exception $e) {
               file_put_contents($logFile, date('Y-m-d H:i:s')." - Tracker $tracker failed: ".$e->getMessage()."\n", FILE_APPEND);
           }
       }

       // Update database
       $updateStmt = $pdo->prepare("
           UPDATE torrents
           SET seeders = ?, leechers = ?, last_updated = NOW()
           WHERE id = ?
       ");
       $updateStmt->execute([$seeders, $leechers, $torrentId]);

       $logMsg = sprintf(
           "Updated torrent #%d - Seeders: %d, Leechers: %d",
           $torrentId,
           $seeders,
           $leechers
       );
       file_put_contents($logFile, date('Y-m-d H:i:s')." - $logMsg\n", FILE_APPEND);

       // Random sleep between 2-5 minutes
       sleep(rand(120, 300));

   } catch(PDOException $e) {
       file_put_contents($logFile, date('Y-m-d H:i:s')." - Database error: ".$e->getMessage()."\n", FILE_APPEND);
       sleep(60);
   } catch(Exception $e) {
       file_put_contents($logFile, date('Y-m-d H:i:s')." - Error: ".$e->getMessage()."\n", FILE_APPEND);
       sleep(60);
   }
}


Step 3: Run the PHP File
To run the script, use the following command:


php tracker-updater.php


Alternatively, you can run it on your shared hosting by visiting the page once. Do not wait for it to load; just trigger the process, and it will continue working in the background.
EDITED as @MM recommended
Last edited by YadJoe on 2025-06-21 23:17:54
2025-03-24 11:35:29
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
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)
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: 4
  • Members: 0
  • Guests online: 4
  • Comments: 3
  • Messages: 1,728