Active Transfers. This is a back-port of a AJAX feature I rolled out to my community in the summer. See if this works for you and post the results in a comment.
What this does is displays current downloads for the current logged-in user. It displays:
- Torrent link
- Client Speed
- File Size
While this is actually interactive and automatically updates, you simply wont get that ability with a plain old block, but this should work for you anyway.
Save as activetransfers_block.php and upload to /blocks
Add to /languages/english.php
What this does is displays current downloads for the current logged-in user. It displays:
- Torrent link
- Client Speed
- File Size
While this is actually interactive and automatically updates, you simply wont get that ability with a plain old block, but this should work for you anyway.
Save as activetransfers_block.php and upload to /blocks
<?php
// TTv3 Active Transfers - Block
function calc_speed($b) {
if ($b < 1024) return round($b,2) . 'B/Sec';
$b /= 1024.0;
if ($b < 1024) return round($b,2) . 'KB/Sec';
$b /= 1024.0;
if ($b < 1024) return round($b,2) . 'MB/Sec';
$b /= 1024.0;
if ($b < 1024) return round($b,2) . 'GB/Sec';
$b /= 1024.0;
return round($b,2) . 'TB';
}
function calc_size($b) {
if ($b < 1024) return round($b,2) . 'B';
$b /= 1024.0;
if ($b < 1024) return round($b,2) . 'KB';
$b /= 1024.0;
if ($b < 1024) return round($b,2) . 'MB';
$b /= 1024.0;
if ($b < 1024) return round($b,2) . 'GB';
$b /= 1024.0;
return round($b,2) . 'TB';
}
if (get_user_class() >= 7) {
begin_block(T_("ACTIVE_TRANSFERS"));
$expires = 1200;
if (($rows = $TTCache->Get("activetransfers_block", $expires)) === false) {
$res = SQL_Query_exec("SELECT (SUM(peers.downloaded)) / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(peers.started)) AS speed, peers.seeder, peers.id, peers.connectable, users.id, peers.started, torrents.id AS torrentid, torrents.name, torrents.size, peers.to_go FROM peers LEFT JOIN torrents ON torrents.id = peers.id LEFT JOIN users ON peers.id = users.id WHERE peers.id = $CURUSER[id] AND peers.seeder = 'no' GROUP BY peers.started DESC LIMIT 6");
foreach (mysqli_fetch_assoc($res) as $row) {
$rows = $row;
if (array_key_exists('torrentid', $row)) {
print("Active Transfers: <div><a href='torrents-details.php?id=$row[torrentid]'>$row[name]</a></div><div>Speed: " . calc_speed($row['speed']) . ", Size: " . calc_size($row['size']) . "</div>");
} else {
echo T_("NO_ACTIVE_TRANSFERS");
}
}
$TTCache->Set("activetransfers_block", $rows, $expires);
}
end_block();
}
?>
Add to /languages/english.php
$LANG["NO_ACTIVE_TRANSFERS"] = "No current transfers.";
$LANG["ACTIVE_TRANSFERS"] = "Active Transfers.";
