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
TT Torrent Client
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2020-07-11 04:53:19
First, create ajax_dl_progress.php


<?
// TT Torrent Client v1
// STorrents2020 @TorrentTrader.xyz
try {
   $dsn      = 'mysql:dbname=database;host=localhost';
   $user     = 'username';
   $password = 'password';
   $stmt     = new PDO($dsn, $user, $password);
   $stmt->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
   die('Unable to connect to database');
}
$userid = isset($_GET['userid']) ? intval($_GET['userid']) : 0;
$stmt   = $conn->prepare("SELECT id, download_perc, download_peers, download_speed, download_status, download_conn FROM users WHERE id = :userid");
$stmt->bindParam(":userid", $userid, PDO::PARAM_INT);
$stmt->execute();
$progressdata = array();
if ($stmt->rowCount() > 0) {
   $transfer = $stmt->fetchAll(PDO::FETCH_ASSOC);
   foreach ($transfer as $row => $data) {
       $data['id']              = $row['id'];
       $data['value']           = $row['download_perc'];
       $data['download_peers']  = $row['download_peers'];
       $data['download_speed']  = $row['download_speed'];
       $data['download_status'] = $row['download_status'];
       $data['download_conn'] = $row['download_conn'];
       array_push($progressdata, $transfer);
   }
}
echo json_encode($usersactive);
?>


Open header.php and add


<script>
function fetchDownloadProgress() {
   $(document).ready(function () {
       $.ajax({
           url: 'ajax_dl_progress.php?userid=<? echo $CURUSER["id"]; ?>',
           method: "GET",
           dataType: 'JSON',
           success: function (data) {
               var html_to_append = '';
           
$.each(data, function (i, item) {
                   html_to_append +=
                       '<div style="padding-left:15px;padding-top:20px"><span style="font-size:25px"><i class="material-icons" style="color:#E72225;font-size:35px;vertical-align:bottom;padding-right:10px">cloud_download</i>' +
                       item.download_perc +
                       '</span><span style="font-size:25px;padding-left:20px"><i class="material-icons" style="color:rgba(46,168,4,1);font-size:35px;vertical-align:bottom;padding-right:10px">face</i>' +
                       item.download_peers +
                       '</span><span style="font-size:25px"><span style="font-size:25px;padding-left:20px"><i class="material-icons" style="color:#FFCE00;font-size:35px;vertical-align:bottom;padding-right:10px">flash_on</i>' +
                       item.download_speed +
                       '</span><span style="font-size:25px"><span style="font-size:25px;padding-left:20px"><i class="material-icons" style="color:#C0C0C0;font-size:35px;vertical-align:bottom;padding-right:10px">restore</i>' +
                       item.download_status +
                       '</span><div><span style="font-size:25px"><span style="font-size:25px"><i class="material-icons" style="color:#C0C0C0;font-size:35px;vertical-align:bottom;padding-right:10px">people</i>' +
                       item.download_conn +
                       '</span></div></div>';
               });
               $("#download-progress").html(html_to_append);
           }
       });
   });
}
fetchDownloadProgress();
setInterval(function () {
   fetchDownloadProgress()
}, 5000);
</script>


Open torrents-details.php and find


print ("<a href=\"../download/?id=$id&amp;name=" . rawurlencode($row["filename"]) . "\"><button type='button' class='btn btn-large btn-danger'>DOWNLOAD TORRENT</button></a>
<a href=\"../download/?id=$id&amp;name=" . rawurlencode($row["filename"]) . "\"></a><br />");


And replace with


print ("<a href=\"../download/?id=$id&amp;name=" . rawurlencode($row["filename"]) . "\"><button type='button' class='btn btn-large btn-danger'>DOWNLOAD TORRENT</button></a>
<a href=\"../download/?id=$id&amp;name=" . rawurlencode($row["filename"]) . "\"></a><br />");
print("<form method='get' action='/client'><input type='button'  class='btn btn-large ban-danger' value='Direct Download' onclick='this.form.submit();'><input type='hidden' name='id' value='$id'><input type='hidden' name='userid' value='$CURUSER[id]'></form>");


Run following queries


ALTER TABLE users ADD download_perc VARCHAR(5);
ALTER TABLE users ADD download_peers VARCHAR(10);
ALTER TABLE users ADD download_speed VARCHAR(10);
ALTER TABLE users ADD download_status TEXT(20);
ALTER TABLE users ADD download_conn TEXT(100);


Add anywhere you wish users to see their Direct Download progress


<!-- Direct Download AJAX response -->
<div id="download-progress"></div>


Now open /client/index.php and edit the following to match your database details


   try {
       $dsn      = 'mysql:dbname=database;host=localhost';
       $user     = 'username';
       $password = 'password';
       $stmt     = new PDO($dsn, $user, $password);
       $stmt->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
   }




Events I've added into database, and add more as I go. UDP connection info can be for admin, I just added so I know its working.

[ATTACH type="full" alt="starting.png"]5621[/ATTACH]

[ATTACH type="full" width="740px" alt="checking.png"]5622[/ATTACH]

[ATTACH type="full" alt="Downloading.png"]5624[/ATTACH]

[ATTACH type="full" width="743px" alt="ReqPieces.png"]5625[/ATTACH]

Lastly, upload ZIP to root / of web directory
TT_Torrent_Client_v1.zip
Download
starting.png
starting.png
checking.png
checking.png
Downloading.png
Downloading.png
ReqPieces.png
ReqPieces.png
2020-07-11 18:15:18
looks really cool. Thanks :) Imma have to try this out, looks like fun
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)
2020-07-11 20:04:03
Downloading this way doesn’t put you into peer list, so maybe we should query to work with peers table?

Security:
Im going to create another hidden input, this time with a unique key that each user will have in a column, that way no one can modify the form and use any userid. If both fail check, hammering requests at the script won’t do very much with die() either. It will have to check both and if successful, will continue like normal.

I can turn on Rate Limiting anytime, but not everyone is on a DNS provider with this functionality.

I’ll update post for extra SQL column, and user/key check.
2020-07-28 22:30:08
I guess there are 2 places to add DB info and username etc? Wonder if it can be made to read the backend/mysql.php file instead of adding the info across multiple files? hmm
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)
2020-07-30 10:50:40
"MicroMonkey, post: 68877, member: 311":

I guess there are 2 places to add DB info and username etc? Wonder if it can be made to read the backend/mysql.php file instead of adding the info across multiple files? hmm


I should of done that, I didn’t even use my dB file on my end either, good idea
2020-07-30 19:54:16
Can you do that? Im not sure what to do since you are using PDO, im still trying to get better at that. I dont know if a REQUIRE would be correct or not
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)
2020-07-30 21:02:16
you can include and the global db settings global $mysql_host, $mysql_user, $mysql_pass, $mysql_db

include 'backend/mysql.php';
global $mysql_host, $mysql_user, $mysql_pass, $mysql_db;


so we use

       $dsn      = 'mysql:host=' . $mysql_host . ';dbname=' . $mysql_db . ';
       $user     = '$mysql_user';
       $password = '$mysql_pass';


or define paths.php and include in index.php

include 'backend/mysql.php';
define('DB_HOST', $mysql_host);
define('DB_NAME', $mysql_db);
define('DB_USER', $mysql_user);
define('DB_PASS', $mysql_pass);


so we use

       $dsn      = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';
       $user     = 'DB_USER';
       $password = 'DB_PASS';
2020-07-31 02:12:42
Thank you yes - please use m-jay TT compatibility code above @ everyone reading this mod. :cool:
2020-07-31 02:15:14
"MicroMonkey, post: 68885, member: 311":

Can you do that? Im not sure what to do since you are using PDO, im still trying to get better at that. I dont know if a REQUIRE would be correct or not


I don't even use raw PDO anymore, its even worse now lmao I use a really nice db class that does the thinking and security for me. MIT license with 4 contributors, best out there it seems
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: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728