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

Snatchlist [TTv3] — 2020-08-31 01:09:49 in v3 Mods Completed
i will add this in, but very touchy as the file is perfection at the moment. I want max slots added too, but again I don’t want to break what’s not broken and cause bugs elsewhere.

Can you explain the logic for Snatched list please? It will greatly assist in a good plan for the code.
Snatchlist [TTv3] — 2020-08-30 19:28:20 in v3 Mods Completed
That code brothers me (I'm adding it in right now and improving. First, their iterating a query without a ->close() method or equilevant (like break in foreach), second they should be defining indexes or calling on array (as $row) in the loop and calling outside of it. I'll post the updated code. I don't have these tables so I can't test further but I like it already.
Upload image error — 2020-08-30 05:14:55 in M-BiTsy Support
VARCHAR(10) - if the image is a a ID
"m-jay, post: 69229, member: 20288":

la valeur par défaut peut être changée en null
mais cela a l'air bien, d'après mon expérience, nul ne peut être non
mieux vaut vérifier lors du téléchargement ajouter image2 miss image1

the default value can be changed to null
but it looks good in my experience null can not be no
better check when uploading add image2 miss image1


SQL way: This can be taken care of too by adding SELECT * FROM torrents IFNULL(image1, false) AS img1, IFNULL(image2, false) AS img2

Reducing extra code for a simple check.
Looking good! Will have a look at that and see what I can do. That leaves plenty to play with for sure
You guys can cut out all the JOIN work and just declare clause conditions, which do the same thing. I do this for now on.

SELECT (SUM(peers.downloaded)) / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(peers.started)) AS totalspeed FROM peers, users WHERE (users.id = 1 [color=rgb(44, 130, 201)]AND[/color] peers.userid = 1)

Throw as many AND/OR in there as you like, as long as you defined the desired table with a comma.
nice work. is SQL_Query_exec mysqli enabled for you guys? I've never used the mysqli edition so its mysterious to me still. Thats a ton of code ?
"MicroMonkey, post: 69198, member: 311":

I havent tested v3 on mysql 8. I have only tested on ubuntu 18.04 lts. Havent tried ubuntu 19 or 20, or whatever they are up to now. Your first error is a theme issue, its not seeing your themes directory in the variable. M-jay is correct on that. try ubuntu 18 if you are able. Bleeding edge isnt always best


FreeBSD for life lmao. I love my OS (runs Paypal, Yahoo, tons of sites). Fast as hell and upgrading is 1 command. Linux has a better feature.. rebootless kernel updating (that’s a UNIX breakthrough). I hope we get that soon ...

Start stock with the files (fresh) and get rid of 8.0, let us know what happens
"tzuriel, post: 69189, member: 713":

So it seems every occurrence of groups has to be replaced with `groups`  I am using  this version
version()               |
+-------------------------+
| 8.0.21-0ubuntu0.20.04.4 |

Is that the issue?


Don’t use 8.0 ... you will hate it all along the way (and discover it won’t work well for you). I used it back in January, and not only was it very slow for me, it also prevented me from logging in, remote connection to MySQL, etc etc. It was not worth the trouble in the end, I consider 8.0 more of a enterprise/community server that holds very new things, things that need close attention and that takes a really long time, especially for a high tier server like 8.0

You want query caching, performance and optimized JOIN settings in your my.cnf file, because TT v3 uses a lot of table joining, and wayy too many occurrences linking ‘users’ table, so optimizing the setup even simply, is recommended.

MySQL 5.5 - 5.7 - or - MariaDB 10.x is perfect.
Absolutely, I was wondering about that myself. I will turn on errors too for you in script, just in case. Do you have a style for this? It’s just a 10px radius border with 3 colours and border outlines with maybe 20px of padding in each “cell”.
Thanks man! Events key is true/false - can be set anytime. You are right, and I can't seem to get events working though,, so I got around it with a bool check in the class by adding or deducting 1 from seeders/leechers in torrents table based on completed or not and connectable or not (those 2 conditions), that seems to be doing the trick 'without events'.

Cheap trick, really as it is relying now on 'left' (to_go in peers table). It'll do for now. More deeper testing from ppl will be required for announce to be tuned right. For now, it works fine and has 2 fixes updated in post. It's pretty aware about things now with the clients and the users.

Better IP/port checking too in the function isConnectable() - old one was not working and was not compliant either. fclose() was not in the right place and yet checks were made anyway, doesn't make sense. Its been improved and fixed into a function now. I settled for fsockopen for flexibility sake. Not everyone has cURL installed on their box.

We need events, its really important. I'll keep tracking at it. Its supported and built in by default so its strange i am missing a key to that array when I set to true. Very odd. It worked before.
Give this a try. Im not sure how your template is setup so this is barebones. I used SQL_Query_exec() in case you have mysqli enabled in mysql.class.php
I added some type casting to show what is doing what (string = mixed chars that are not INT or BOOL) (int = numbers) (bool = true/false, 1/0 etc)

For the inline CSS in the tags, adjust [color=rgb(226, 80, 65)]padding-right: 50px [/color][color=rgb(209, 213, 216)]to your page width. [/color]


<?php
// Top 5 Seeders
require_once("backend/functions.php");
dbconn(false); // Set to true to trigger clean interval check - it may help these stats
stdhead("Top 5 Seeders");

function formatBytes($bytes, $precision = 2) {
   $units = array('B/sec', 'KB/sec', 'MB/sec', 'GB/sec', 'TB/sec');
   $bytes = max($bytes, 0);
   $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
   $pow = min($pow, count($units) - 1);
   $bytes /= pow(1024, $pow);
   return round($bytes, $precision) . ' ' . $units[$pow];
}

$res = SQL_Query_exec("SELECT (SUM(p.downloaded)) / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(p.started)) AS totalspeed, (SELECT uploaded / downloaded FROM users LIMIT 1) AS ratio, (SELECT torrentid % 100 / userid FROM completed LIMIT 1) AS completed, u.username, u.uploaded, u.downloaded FROM peers p LEFT JOIN users u ON u.id = p.userid LEFT JOIN completed c ON u.id = c.userid WHERE (p.seeder = 'yes') ORDER BY ratio DESC LIMIT 5");

while ($row = mysqli_fetch_assoc($res)): ?>

<h1>Top 5 Seeders</h1>

<div style="float:left;padding-right:50px">
  <label style="font-weight:bold">Username</label>
  <p>          
     <?=(string)htmlspecialchars($row['username'])?>
  </p>
</div>
<div style="float:left;padding-right:50px">
  <label style="font-weight:bold">Uploaded</label>
  <p>          
     <?=(string)mksize($row['uploaded'])?>
  </p>
</div>
<div style="float:left;padding-right:50px">
  <label style="font-weight:bold">Speed</label>
  <p>          
     <?=(string)formatBytes($row['totalspeed'])?>
  </p>
</div>
<div style="float:left;padding-right:50px">
  <label style="font-weight:bold">Ratio</label>
  <p>          
     <?=(int)number_format($row['ratio'])?>
  </p>
</div>
<div style="float:left;padding-right:50px">
  <label style="font-weight:bold">Finished %</label>
  <p>          
     <?=(int)$row['completed']?>%
  </p>
</div>
<div style="clear:both"></div>

<?php endwhile; stdfoot(); ?>


More can be done though, just so you know. Such as 'connectable yes/no', 'last announce time', etc etc tons of stuff.
Query is built, it didn't take too long. i went pure SQL on this one to learn a few things. Hope thats okay on your DB server if this is a busy page.

SELECT (SUM(p.downloaded)) / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(p.started)) AS totalspeed, (SELECT uploaded / downloaded FROM users LIMIT 1) AS ratio, (SELECT torrentid % 100 / userid FROM completed LIMIT 1) AS completed, u.username, u.uploaded, u.downloaded FROM peers p LEFT JOIN users u ON u.id = p.userid LEFT JOIN completed c ON u.id = c.userid ORDER BY ratio DESC LIMIT 5


That query will produce (for you different) results:

[ATTACH type="full" alt="Demo.png"]5805[/ATTACH]

Making code now
New Announce : bugs

1. ) Started time does not insert to database yet.

2. ) Peers/Seeds are not yet accounted for yet for local torrents. Public seeds show in client without issues.  [color=rgb(44, 130, 201)]Fixed[/color]

3. ) Completed torrents are not added to 'completed' table - [color=rgb(226, 80, 65)]is this necessary? We handle this now in peer table[/color]

4. ) Max slots feature is not yet added - [color=rgb(226, 80, 65)]is this necessary? It was a old mod. [/color]

5. ) Client/Agent ID is not added to peer table yet.[color=rgb(226, 80, 65)]  [/color][color=rgb(44, 130, 201)]Fixed[/color]

Everything else is perfect. I've tested all night various of my own private torrents off seedbox and no problems, just no stats currently! Amazing speeds and very light script.

I imported a few TT-only announce features into the new announce with full success.

--

Announce has taken longer than expected, but due to the fact that it is a complete redo of the old aging TT announce script that will see dust soon (and mass depreciation).

[color=rgb(226, 80, 65)]is this necessary? [/color]means I can easily do it, but do we need it? Please let me know so I can add these in if their a staple of your tracker.

Final announce.php => to be added to BETA2 (with limits listed above in post)



<?

require_once '../site.php';
require_once '../bencoding.php';
$db->connect();

$db->query_params('DELETE FROM peers WHERE last_announce + ' . $db->interval('1 hour') . ' < CURRENT_TIMESTAMP');

header('Content-Type: text/plain');

function fail($reason) {
   die(bencode(array('failure reason' => $reason)));
}

function ip2bytes($ip) {
   $res = '';
   $parts = explode('.', $ip);
   if (count($parts) !== 4) return null;
   for ($i = 0; $i < 4; $i++) {
       $b = $parts[$i];
       if (!is_numeric($b)) return null;
       $b = intval($b);
       if ($b < 0 || $b >= 256) return null;
       $res .= chr($b);
   }
   return $res;
}

function isConnectable($ip, $port) {
   $fp = @fsockopen($ip, $port, $errno, $errstr, 0.1);
   if (!$fp) {
       return false;
   } else {
       fclose($fp);
       return true;
   }
}

$keys = array(
   'downloaded' => true,
   'uploaded' => true,
   'passkey' => true,
   'username' => false,
   'torrent_id' => false,
   'token' => false,
   'info_hash' => true,
   'peer_id' => true,
   'port' => true,
   'no_peer_id' => false,
   'ip' => false,
   'numwant' => false,
   'event' => false,
   'left' => true,
   'compact' => false,
);

$data = array();
foreach ($keys as $key => $req) {
   if (array_key_exists($key, $_GET)) {
       $data[$key] = $_GET[$key];
   } else if ($req) {
       fail(sprintf('missing key: %s', $key));
   }
}

// Added. Check if seeder
$seeder = ($data['left'] == 0) ? 'yes' : 'no';
$data['info_hash'] = bin2hex($data['info_hash']);
$data['peer_id'] = $data['peer_id']; // bin2hex to scramble peer ID (we wont get client version/name)

// Added. Get client info and strip out the rest
$clientstring = mb_substr($data['peer_id'], 0, 7);
$client2 = str_replace('-', '', $clientstring);
$client  = str_replace('M', 'Bittorrent ', $client2);

$res = $db->query_params('SELECT user_id, passkey FROM users WHERE passkey = :passkey', array('passkey' => $data['passkey'])) or fail('db error line 56');
$user_row = $res->fetch() or fail("access denied line 57");

// added
if (array_key_exists('token', $data)) {
   $token = md5('token{' . $data['torrent_id'] . ',' . $user_row['passkey'] . '}');
   if (!hash_equals($token, $data['token'])) fail('access denied line 67');
}

if (!is_numeric($data['port'])) fail('invalid port');

$data['port'] = intval($data['port']);
if ($data['port'] < 1 || $data['port'] >= 65536) fail('invalid port');

if (array_key_exists('left', $data)) {
   if (!is_numeric($data['left'])) fail('invalid left');
   $data['left'] = intval($data['left']);
   if ($data['left'] < 0) fail('invalid left');
}

if (!array_key_exists('ip', $data)) {
   $data['ip'] = getip();

   $try_keys = array('HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP');
   foreach ($try_keys as $key) {
       if (array_key_exists($key, $_SERVER)) {
           $potential_ip = trim(explode(',', $_SERVER[$key])[0]);

           // Ignore private IP addresses
           if (strpos($potential_ip, '10.') === 0) continue;
           if (strpos($potential_ip, '192.168.') === 0) continue;
           // TODO: 172.16.0.0/12 is also private

           $data['ip'] = $potential_ip;
           break;
       }
   }
}

if (array_key_exists('numwant', $data)) {
   if (!is_numeric($data['numwant'])) fail('invalid numwant');
   $data['numwant'] = intval($data['numwant']);
   if ($data['numwant'] < 0) $data['numwant'] = 1000;
   if ($data['numwant'] > 1000) $data['numwant'] = 1000;
} else {
   $data['numwant'] = 30;
}

// Added. Check if user is connectable
if (isConnectable($data['ip'], $data['port'])): $connectable = 'yes'; else: $connectable = 'no'; endif;

$res = $db->query_params('SELECT torrent_id FROM torrents WHERE info_hash = :info_hash', array('info_hash' => $data['info_hash'])) or fail('db error');
$torrent_row = $res->fetch() or fail('no such torrent');

$valid = $db->query_params('SELECT count(*) FROM peers WHERE torrent_id = :torrent_id AND passkey = :passkey', array('torrent_id' => $torrent_row['torrent_id'], 'passkey' => $data['passkey'])) or fail('db error');

// Added. Check connection limits
if ($active = $valid->fetch()) {
   //if ($active >= 1 && $seeder == 'no') fail('Connection limit exceeded! You may only leech from one location at a time.');
   //if ($active >= 3 && $seeder == 'yes') fail('Connection limit exceeded!');  
}
 
$res = $db->query_params('SELECT peer_id, completed, seeder FROM peers WHERE user_id = :user_id AND torrent_id = :torrent_id AND chosen_peer_id = :chosen_peer_id', array('user_id' => $user_row['user_id'], 'torrent_id' => $torrent_row['torrent_id'], 'chosen_peer_id' => $data['peer_id'])) or fail('db error');
 
if (!($peer_row = $res->fetch())) {
 
   $res = $db->query_params('INSERT INTO peers (connectable, user_id, torrent_id, chosen_peer_id, ip, port, client) VALUES (:connectable, :user_id, :torrent_id, :chosen_peer_id, :ip, :port, :client)', array('connectable' => $connectable, 'user_id' => $user_row['user_id'], 'torrent_id' => $torrent_row['torrent_id'], 'chosen_peer_id' => $data['peer_id'], 'ip' => $data['ip'], 'port' => $data['port'], 'client' => $client), 'peer_id')  or fail('Cant insert peer.');
   $peer_row = array('peer_id' => $res);
 
} else {
   $db->query_params('UPDATE peers SET connectable = :connectable, to_go = :to_go, uploaded = :uploaded, downloaded = :downloaded, seeder = :seeder, client = :client, ip = :ip, port = :port, last_announce = CURRENT_TIMESTAMP WHERE peer_id = :peer_id', array('connectable' => $connectable, 'to_go' => $data['left'], 'uploaded' => $data['uploaded'], 'downloaded' => $data['downloaded'], 'seeder' => $seeder, 'client' => $client, 'ip' => $data['ip'], 'port' => $data['port'], 'peer_id' => $peer_row['peer_id'])) or fail('db error');
}

if (array_key_exists('left', $data)) {
 
   // Cheap fix until events are working
   if ($seeder === 'no'){
       $db->query_params('UPDATE torrents SET leechers = leechers + :addleecher WHERE torrent_id = :torrent_id', array('addleecher' => $db->encode_bool($data['left'] === 0), 'torrent_id' => $torrent_row['torrent_id'])) or fail('db error');
   }else{
       $db->query_params('UPDATE torrents SET seeders = seeders + :addseeder WHERE torrent_id = :torrent_id', array('addseeder' => $db->encode_bool($data['left'] === 0), 'torrent_id' => $torrent_row['torrent_id'])) or fail('db error');
   }
 
   $db->query_params('UPDATE peers SET completed = :completed, seeder = :seeder WHERE peer_id = :peer_id', array('completed' => $db->encode_bool($data['left'] === 0), 'seeder' => $seeder, 'peer_id' => $peer_row['peer_id']));
}

if (array_key_exists('event', $data) && $data['event'] === 'stopped') {
   $db->query_params('DELETE FROM peers WHERE peer_id = :peer_id', array('peer_id' => $peer_row['peer_id']));
}
 
$res = $db->query_params('SELECT count(nullif(completed,false)) AS complete, count(nullif(completed,true)) AS incomplete FROM peers WHERE torrent_id = :torrent_id', array('torrent_id' => $torrent_row['torrent_id'])) or fail('db error');
$comp_res = $res->fetch() or fail('db error');

$output = array(
   'interval' => 30 * 60,
   'complete' => intval($comp_res['complete']),
   'incomplete' => intval($comp_res['incomplete']),
   'peers' => array(),
);

$res = $db->query_params('SELECT chosen_peer_id, ip, port FROM peers WHERE torrent_id = :torrent_id AND peer_id != :peer_id ORDER BY ' . $db->random() . ' LIMIT :limit', array('torrent_id' => $torrent_row['torrent_id'], 'peer_id' => $peer_row['peer_id'], 'limit' => $data['numwant'])) or fail('db error');

while ($row = $res->fetch()) {
   $peer = array(
       'ip' => $row['ip'],
       'port' => intval($row['port']),
   );
   if (!array_key_exists('no_peer_id', $data)) {
       $peer['peer_id'] = hex2bin($row['chosen_peer_id']);
   }
   $output['peers'] []= $peer;
}

if (array_key_exists('compact', $data)) {
   $peer_data = '';
   foreach ($output['peers'] as $peer) {
       $bs = ip2bytes($peer['ip']);
       if (is_null($bs)) continue;
       $peer_data .= $bs;
       $peer_data .= chr($peer['port'] >> 8);
       $peer_data .= chr($peer['port'] & 0xff);
   }

   if (empty($output['peers']) || !empty($peer_data)) {
       $output['peers'] = $peer_data;
   }
}

echo bencode($output);
I can't seem to locate the mod, but i can design by eye. Do you want that table in that design?
Hi niki, this is easy. Please indicate: mysqli or PDO + tt version used. I can do the code if you provide me your current CODE/HTML.
Try: Username: Administrator / Password: password

It fails then wait for beta2 (day or two)  release as a great deal of issues are fixed, this had unfortunately leaks in login that point to my macs testing URL.
Seed Bonus [TTv3] — 2020-08-22 20:19:09 in v3 Mods Completed
"MicroMonkey, post: 69148, member: 311":

simplest solution in backend/cleanup.php if your cleanup runs every 10 minutes (600 seconds). I revisited this because your solution didnt work for me, and im lazy, so I just did this. I touched the keyboard a very minimal amount of times haha
SQL_Query_exec("UPDATE users SET seedbonus = seedbonus + '" . (($site_config["bonuspertime"] / 6) * $row->count) . "' WHERE id = '" . $row->peer . "' AND seedbonus < ".$site_config["bonusmax"]."");



MySQLi. * for PDO, this is prepared and mostly different.
"spiritblue, post: 69129, member: 401":

ok, I have had error_log errors for some time! but can you give me an example?
thank you
=================================================//
ok, justement j'ai des erreurs de _log depuis quelque temps! mais vous pouvez me faire un exemple?
merci


whoops got a wrong text paste in there,  the edited jumps on me all the time and I fight with autocorrect lols
"spiritblue, post: 69125, member: 401":

I changed the ID of one of my category and pouf! ... solved! ?


this work for pirate servers?
"niki, post: 69064, member: 20338":

- Bonjour je cherche a mettre le logo cliquable allociné sur la page des torrent a droite du non du torrent pour être redirigé sur allociné quand on clic sur le logo allociné.


- Hello I'm looking to put the allocinated clickable logo on the torrent page to the right of the torrent's no to be redirected to allocinated when you click on the allocinated logo.


- example... dans le fichier function.php, ajouter une case comme ceci...

- example... in the function.php file, add a case like this...





case'allocine':
               echo "<th>allocine</th>";





case 'allocine':
if (!empty($row['image1']))

{
   $imgCover = 'images/allocine.jpg';
}
echo '<td class=ttable_col'.$x.' align="center"><img width="70" height="75" src="'.$imgCover.'"></td>';
break;


if not empty, load placeholder? Or is that cat picture? Use isset or since it is row you can use just

if ($row[image1]
Will return true is data exists. So use else { to return false and handle the alternative. that picture, just confused. !operators work too and do the same thing.

empty() and isset() is great to satisfy php undefined index errors, it closes off loose endpoints in code etc
statt — 2020-08-20 20:27:59 in v2.08 Support
My users make constant mistake of using https in announce URL. That happens all the time, but download.php replaces announce anyway, it just might be reason. I notice it in my table quite often. SSL (https) is CPU-heavy so I don’t rcommend, bittorrent is a heavy player on bandwidth and exchange.
Users online

No users online

Search



Statistics

    Torrents

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

  • Members

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

  • Online

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