First, create ajax_dl_progress.php
Open header.php and add
Open torrents-details.php and find
And replace with
Run following queries
Add anywhere you wish users to see their Direct Download progress
Now open /client/index.php and edit the following to match your database details
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
// 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&name=" . rawurlencode($row["filename"]) . "\"><button type='button' class='btn btn-large btn-danger'>DOWNLOAD TORRENT</button></a>
<a href=\"../download/?id=$id&name=" . rawurlencode($row["filename"]) . "\"></a><br />");
And replace with
print ("<a href=\"../download/?id=$id&name=" . rawurlencode($row["filename"]) . "\"><button type='button' class='btn btn-large btn-danger'>DOWNLOAD TORRENT</button></a>
<a href=\"../download/?id=$id&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
