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

ratio moves more — 2022-07-11 23:45:44 in v3 Support
I wouldn’t worry so much about NAT/UPnP, may add further confusion. uTorrent takes care of this most of the time, else it will holepunch for a peer.

Your code is probably fine, and as usual if the file all of the sudden acts strange/buggy with no change.. then issue is SQL!

ratio moves more — 2022-07-10 18:42:14 in v3 Support
It’s not connecting to peers and providing the bencoded output response correctly.

It is gathering int (1) for 1 peer (probably you), and no other connections are established. Is NAT/uPnP working for your client?

You want a debugger for this, trust me. Even a SQL insert at every 30 lines so you know where your code is faulting.  
Another good way to do it!
filetree => v2
Hybrid => filetree && files
uTorrent is Cpp/Python, if not mostly python, Cpp being the executable wrapper. They can easily do it. Something has them not implementing, or simply hiding the option for the meantime. They sure are hard at work on “Application not responding” advertising.

So we ignore that and use Qbt.

No one will catch up with it if mainline clients don’t play along.

Today, we have cloud streamed downloads, new technologies to improve bandwidth and we are coming closer and closer to CDN quality. The implementation needs to reach all clients for v2 to really push off in the wild.

Just feels like we are too late, and polishing a old classic vehicle in hopes it can pair up with today’s Tesla.
v2 not supported? I personally use v1 because my seedbox does not support it, but all 3 are supported on site.

It’s a bit of a useless “too late” approach from libtorrent it feels like. IMHO this should of came out in 2007. Why so late?
Thank you @M-jay for pointing that out.

I have updated the post to fix the broken code. Hopefully that’s all it was.
Thanks for the feedback guys!

Try this:

Replace jQuery (v3 stock) with jQuery 3.6.0 (latest). I had no issues on the stock JS file.

 <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>


Next, confirm the CSS is in the current theme (I just used “default” theme for this). It was a fresh install. This may be different for your site.

Let me know. If still same issue, I want someone’s theme header.php file so I can investigate.

Sending Notifications
I’ll post a update for account-signup.php welcoming a new user to a notification.

Cheers



Notifications for TorrentTrader v3 (AJAX/jQuery)

Requires: TTv3 (mysqli)

Using independent mysqli code for better control.




Import SQL

CREATE TABLE `notifications` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` INT(11) NULL DEFAULT NULL,
`message` VARCHAR(255) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
`added` DATETIME NULL DEFAULT NULL,
`read` ENUM('yes','no') NULL DEFAULT 'no' COLLATE 'latin1_swedish_ci',
`title` VARCHAR(255) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
PRIMARY KEY (`id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;

Create ajax_user_notifications.php & add to root

<?php
// TTv3 AJAX User Notifications
require_once 'backend/functions.php';
dbconn();
$db = new mysqli($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
if ($db->connect_errno) {
   die(json_encode(array(
       'error' => $db->connect_error
   )));
}
if (loggedinonly() !== false) {
   if ($_SERVER['REQUEST_METHOD'] === 'POST') {
       if (isset($_POST['id']) && intval($_POST['id']) > 0) {
           if (isset($_POST['viewed']) && $_POST['viewed'] !== false) {
               $read = $db->prepare("UPDATE notifications SET `read` = 'yes' WHERE id = ? AND user_id = ?") or die('SQL Query Error');
               $read->bind_param('ii', intval($_POST['id']), $CURUSER['id']);
               $read->execute();
               if ($read) {
                   echo json_encode(array(
                       'read' => true
                   ));
               }
           } else {
               $delnotif = $db->prepare('DELETE FROM notifications WHERE id = ? AND user_id = ?') or die('SQL Query Error');
               $delnotif->bind_param('ii', intval($_POST['id']), $CURUSER['id']);
               $delnotif->execute();
               if ($delnotif) {
                   echo json_encode(array(
                       'delete' => true
                   ));
               }
           }
       }
   } else {
       $notif = $db->prepare('SELECT id, user_id AS uid, message, added, `read`, title FROM notifications WHERE user_id = ?') or die('SQL Query Error');
       $notif->bind_param('i', $CURUSER['id']);
       $notif->execute();
       $result       = $notif->get_result();
       $notification = array();
       while ($row = $result->fetch_assoc()) {
           $data['id']      = intval($row['id']);
           $data['message'] = trim($row['message']);
           $data['total']   = count($row);
           $data['added']   = $row['added'];
           $data['read']    = $row['read'];
           $data['title']   = $row['title'];
           array_push($notification, $data);
       }
       echo json_encode($notification, JSON_UNESCAPED_SLASHES);
       $notif->free_result();
       $db->close();
   }
}


Open header.php and add

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script>
function truncateString(str, num) {
return (str.length > num) ? str.slice(0, num) + '...' : str;
}

function getSelected() {
return (window.getSelection) ? window.getSelection().toString() : document.getSelection().toString();
}

function closeNotificationDrop() {
$(document).on('click', '*', function (e) {
if (!$(e.target).is('.notification--bell')
&& !$(e.target).is('.notification--num')
&& !$(e.target).is('span#rate-notif-feature')
&& !$(e.target).is('div#back-notif-list')
&& !$(e.target).is('span#show-all-notif')
&& !$(e.target).is('#notif_container')
&& !$(e.target).is('#vote-actions')
&& !$(e.target).is('span#clean-all-notif')) {  
$('#notif_container').hide();
//$('.notif').removeAttr('data-id');
}
});
}
// Get notification count
function fetchNotificationCount() {
   $(function () {});
let total = 0;
const delay = 2000;
$('.notification--bell').css('animation-play-state', 'paused');
$('.notification--bellClapper').css('animation-play-state', 'paused');
if (!$.trim($('.notification--num').html()).length || parseInt($('.notification--num').text()) === total) {
$('.notification--bell').css('fill', '#D3D3D3');
$('.notification--bellClapper').css('fill', '#D3D3D3');
}
   $.ajax({
       url: 'ajax_user_notifications.php',
       method: 'GET',
       dataType: 'JSON',
       success: function (data) {
$('.notification--bell').css('fill', '#FFF');
$('.notification--bellClapper').css('fill', '#FFF');
let html_to_append = '';
$.each(data, function (i, item) {
total = item.total;
});
if (total > 0) {
$('.notification--num').html(total);
if (!($('.notif').is('[data-id]'))) {
$('.notification--bell').css('animation-play-state', 'running');
$('.notification--bellClapper').css('animation-play-state', 'running');
}
if (parseInt($('.notification--num').text()) > 0) {
setTimeout(function() {
$('.notification--bell').css('animation-play-state', 'paused');
$('.notification--bellClapper').css('animation-play-state', 'paused');
}, delay);
}
}
},
error: function(errorThrown) {
$('.notification--num').html(total);
}
   });
}
fetchNotificationCount();
setInterval(function () {
fetchNotificationCount()
}, 15000);

/* Get notifications */
$(document).ready(function() {
$('.notification--bell, .notification--num').click(function () {
const request = 'ajax_user_notifications.php';
$(function () {});
$.ajax({
url: request,
method: 'GET',
dataType: 'JSON',
success: function (data) {
$('#notif_container').css('box-shadow', '0 2px 5px 0 rgba(0, 0, 0, .16), 0 2px 10px 0 rgba(0, 0, 0, .12)');
if ($('.notif').children('div').length > 0) {
$('#notif_container').toggle('fade');
}
var html_to_append = '';
var morelink = false;
var effect = 'drop';
$.each(data, function (i, item) {
let read = (item.read === 'yes') ? '· read' : '';
html_to_append += '<div class="notif" notif-read="' + item.read + '" data-id="' + item.id + '" style="background:#d2d2d2;cursor:pointer;padding:0;height:70px;margin-bottom:17px;"><div style="display:inline;float:left;padding:8px 10px"><a href="/user/?id=' + item.user_id + '"><span class="material-icons" style="color:orange;vertical-align:middle;padding-right:5px;font-size:45px;margin-top:-11px">notifications</span></a></div> <div style="float:left;display:inline;padding-top:0px;font-size:15px">' + truncateString(item.message, 40) + '</div><div class="added-' + item.id + '" style="display:inline;float:left"><small>' + item.title + ' · ' + jQuery.timeago(item.added) + ' ago ' + read + '</small></div><div style="clear:both"></div></div>';
if (i >= 5) {
morelink = true;
return false;
}
});
$('#notif_container').html(html_to_append).css('position', 'absolute').css('left', '0').css('top', '27px').css('width', '320px').css('padding', '0px 17px 17px 17px').css('border-bottom-left-radius', '5px').css('border-bottom-right-radius', '5px');
if (morelink === true) {
$('#notif_container').append('<span id="show-all-notif" style="cursor:pointer;user-select:none;border-radius:4px;font-size:15px;padding:2px 8px;text-align:center;background:#d2d2d2">+ ' + (data.length - 5) + ' hidden</span> <span style="float:right"><span style="padding-left:5px">·</span> <span class="material-icons" style="vertical-align:middle;font-size:17px">thumb_up</span> <span id="rate-notif-feature" style="font-size:15px;cursor:pointer">Rate</span></span><span style="float:right"><span class="material-icons" style="vertical-align:middle">delete_sweep</span> <span id="clean-all-notif" style="font-size:15px;cursor:pointer">Clean up</span></span>');
}
$('#rate-notif-feature').on('click', function () {
$('.notif').children('div').remove();
$('#notif_container').html('<div style="padding-top:8px"><div style="display:inline;float:left;margin-top:8px;color:#F0494F"><span class="material-icons" style="font-size:27px">science</span></div><div style="display:inline;float:left;padding-left:20px"><span>This is a beta feature. Let us know!</span></div><div style="clear:both"></div></div>');
$('#notif_container').append('<div style="text-align:center" id="vote-actions"><span id="vote_up" user-id="<?=$CURUSER['id']?>" class="material-icons" style="font-size:27px;vertical-align:top">thumb_up</span><span style="padding:0 20px"></span><span id="vote_down" user-id="<?=$CURUSER['id']?>" class="material-icons" style="font-size:27px;vertical-align:top">thumb_down</span></div>');
$('#notif_container').append('<div id="back-notif-list" style="margin-top:-30px;text-decoration:underline;cursor:pointer">back</div>');
$('#back-notif-list').on('click', function () {
$('#notif_container').html(html_to_append);
});
// Handle voting actions
$('#vote_up').on('click', function () {
return false;
});
return false;
});
$('#clean-all-notif').on('click', function () {
let count = parseInt($('.notif').children('div').length);
if (Array.isArray(results)) {
$.each(results[1], function (i, item) {
$.ajax({
url: request,
method: 'POST',
data: {
id: item.id
},
dataType: 'JSON',
success: function (data) {
if (data.delete === true) {
$('.notif').children('div').remove();
if ($('.notif').children('div').length === 0) {
$('.notification--num').text('0');
$('.notification--bell').css('fill', '#D3D3D3');
$('.notification--bellClapper').css('fill', '#D3D3D3');
}
}
}
});
});
$('#notif_container').html('No more notifications.').delay(1000).fadeIn().delay(1000).toggle(effect);
} else {
$('#notif_container').html('Unable to delete notifications.');
return false;
}
});
$('#show-all-notif').on('click', function () {
$('#notif_container').html(html_to_append);
});
$('.notif').each(function (index) {
var notif = $(this);
const notification_id = notif.attr('data-id');
notif.hover(function () {
$.ajax({
url: request,
method: 'POST',
data: {
id: notification_id,
viewed: true
},
dataType: 'JSON',
success: function (data) {
if (data.read === true) {
if ($('.added-' + notification_id).children('small:contains("read")').length === 0) {
$('.added-' + notification_id).children('small').append(' · read');
}
}
}
});
notif.css('background', '#C0C0C0');
}, function () {
notif.css('background', '#D2D2D2');
});
notif.on('click', function () {
var sel = getSelected().toString();
if (sel === '') {
$.ajax({
url: request,
method: 'POST',
data: {
id: notification_id
},
dataType: 'JSON',
success: function (data) {
if (data.delete === true) {
$('div[data-id=' + notification_id + ']').text('Notification deleted.').css('text-align', 'center').delay(1000).fadeIn().delay(1000).toggle(effect);
let counter = parseInt($('.notification--num').text());
$('.notification--num').text((counter - 1));
if ($('.notif').children('div').length === 0) {
$('#notif_container').html('No more notifications.');
}
}
}
});
return false;
}
});
});
},
error: function(errorThrown) {
$('#notif_container')
.css('position', 'absolute')
.css('left', '0')
.css('top', '40px')
.css('width', '320px')
.css('padding', '0 17px')
.css('border-bottom-left-radius', '5px')
.css('border-bottom-right-radius', '5px');
$('#notif_container').html('No notifications yet :(');
}
});
closeNotificationDrop();
});
});
</script>

Add to themes/default/theme.css

/* Notifications */
#notif_container {
position: relative;
z-index: 9999999;
background: #FFF;
height: auto;
}
#notif_container div {
margin-top:15px
}
.notif-main {
 cursor: pointer;
 display: flex;
 justify-content: center;
 align-items: center;
 position: relative;
 width: 1.563rem;
}
.notif-main .notification {
 position: relative;
 width: 3em;
 height: 3em;
}
.notif-main .notification svg {
 width: 3em;
 height: 3em;
}
.notif-main .notification svg > path {
 fill: #FFFFFF;
}
.notif-main .notification--bell {
 animation: bell 2.2s linear infinite;
 transform-origin: 50% 0%;
}
.notif-main .notification--bellClapper {
 animation: bellClapper 2.2s 0.1s linear infinite;
}
.notif-main .notification--num {
 position: absolute;
 top: -5%;
 left: 50%;
 line-height: 0.375rem;
 font-size: 0.75rem;
 border-radius: 50%;
 width: 0.5357142857em;
 height: 0.5357142857em;
 background-color: #FF4C13;
 border: 5px solid #FF4C13;
 color: #FFFFFF;
 text-align: center;
 animation: notification 2.2s linear;
}

@keyframes bell {
 0%, 25%, 75%, 100% {
   transform: rotate(0deg);
 }
 40% {
   transform: rotate(10deg);
 }
 45% {
   transform: rotate(-10deg);
 }
 55% {
   transform: rotate(8deg);
 }
 60% {
   transform: rotate(-8deg);
 }
}
@keyframes bellClapper {
 0%, 25%, 75%, 100% {
   transform: translateX(0);
 }
 40% {
   transform: translateX(-0.15em);
 }
 45% {
   transform: translateX(0.15em);
 }
 55% {
   transform: translateX(-0.1em);
 }
 60% {
   transform: translateX(0.1em);
 }
}
@keyframes notification {
 0%, 25%, 75%, 100% {
   opacity: 1;
 }
 30%, 70% {
   opacity: 0;
 }
}

Open /backend/functions.php and replace entire loggedinonly() function with

function loggedinonly()
{
   global $CURUSER;
   if (!$CURUSER) {
       header("Refresh: 0; url=account-login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]));
       exit();
   }
   return true;
}


To send a notfication, add to /backend/functions.php

function sendNotif($userid, $message, $title = '')
{
   $notif = SQL_Query_exec("INSERT INTO `notifications` (`user_id`, `message`, `added`, `read`, `title`) VALUES (" . $userid . ", " . $message . ", NOW(), 'no', " . $title . ")");
   if ($notif)
       return true;
   return false;
}


And use like this in pages/areas where another user is concerned (like cleanup, login, account updates, announcement, etc)
sendNotif($CURUSER['id'], 'Welcome to site', 'New User');
What is happening, is get_date_time() is giving you nothing back. So MySQL notices no default value to rely on in this case, so it halts transaction with a error. You always want a field default value, it avoids all of this.

Replace each instance of get_date_time() with NOW().

Try that.
To support both 'passkey' and 'token' announcement parameters for clients, I have enabled the use of both.

nginx.conf


map $passkey $id_type { ~^\d+$   passkey; default  token; }
rewrite ^/announce/([^/]*)/(?<passkey>[^/]+)/$ /announce.php?$id_type&$id_type=$passkey;


This allows using both, while it checks which one is actually requested per request. For those who are using NGINX and would like to know how to support both, or anything else for that matter on any kind of rewrite.

Now we have
  /announce/passkey/ ... /
  /announce/token/ ... /

I updated the rewrite to support /passkey/ -or- /token/ read from parameter type for better adaption (within url, not =value)


I kept my SQL client open all night on table view, morning I refreshed and 23 entries were there, with missing IDs which means they
1. ) they successfully validated and changed password
2. ) waited too long, and expiry removed the row

today its a very large list, with 60% many missing ids.

Some people even put the token hash in the email field, so its important to be clear to visitors on this page.
Check for true or false,

 var_dump(extension_loaded('curl'));
I made this solution with 2 mobile verification options (SMS 2FA/Number Verification), and took 2 days to construct the login integration and conditions. It was not easy. But is very doable with almost any SMS API out there.

The rest, your just storing the 5 digit PIN to a database table, and verify that way or go the long mile and hash a token that stores for later validation. I did 3 steps because better safe than finding out later.
mt_rand is faster
I think it’s better to return the bencoded data and only return bool on error. That way I’m not using file_get_contents on download.php to read signed.torrent
Updated to match tool output


function sign_torrent(string $name, int $torrent_id, $bencoded): bool
{
   global $db;

   $report = array();
   if (file_put_contents('unsigned.torrent', $bencoded)) {
       $decoded = Bencode::decode($bencoded, bigInt: BigInt::INTERNAL);
       if (!is_null($decoded)) {
           $report[] = 'Torrent loaded.';
       }
       $pKey = file_get_contents('private.key');
       $pKey = openssl_pkey_get_private($pKey, 'password');
       if ($pKey) {
           $report[] = 'Private key loaded.';
       }
       openssl_sign(Bencode::encode($decoded['info']), $signature, $pKey);
       $buffer = file_get_contents('certificate.pem');
       $field  = openssl_x509_parse($buffer);
       if ($buffer) {
           $report[] = sprintf('Certificate loaded. (indentity = %s)', $field['subject']['CN']);
       }
       $convert = convertToDer($buffer);
       if ($convert->status === 'success') {
           $dict = $decoded;
           $dict      = array(
               'signatures' => array(
                   'com.switch-torrents' => array(
                       'certificate' => $convert->result,
                       'signature' => $signature
                   )
               )
           );
           $report[] = sprintf('Signature size: %s', intval(mb_strlen($signature, '8bit')));
           $report[] = sprintf('Bencoded certificate size: %s', intval(mb_strlen(Bencode::encode($convert->result), '8bit')));
           $report[] = sprintf('Bencoded signature size: %s', intval(mb_strlen(Bencode::encode($signature), '8bit')));
           $dict     = Bencode::encode($decoded + $dict);
           if (file_put_contents('signed.torrent', $dict)) {
               $report[] = 'Done!';
               $db->query_params('INSERT INTO signing_log (added, txt) VALUES(NOW(), :log)', array(
                   'log' => sprintf("Torrent \"%s\" ID: %s %s  %s  %s  %s  %s  %s  %s", $name, $torrent_id, $report[0], $report[1], $report[2], $report[3], $report[4], $report[5], $report[6])
               ));
               return true;
           }
       } else {
           return false;
       }
   } else {
       return false;
   }
}
I was wondering about that after opening my .pem cert and viewing the encoding. The logic appears to be as much as I can assume is what is needed.

Mimicking the cpp script is hard but I think it’s correct, only I replaced fopen seek with file_get_contents, the second being more memory efficient.

If we can hammer this out with basic testing, we have a universal BEP for anyone
I have this so far, matching as close as possible to the format used in. Still not matching the encoded method the C++ implementation

https://github.com/bittorrent/ut-signing-tool/blob/master/src/main.cpp


<?
// BEP_35 - Torrent Signing
function signtorrent(string $in, string $out, string $certfile, string $keyfile): bool
{
   $parsed = Bencode::decode(file_get_contents($in), bigInt: BigInt::INTERNAL);
   if (!isset($array['signatures'])) {
       $certFile      = file_get_contents($certfile);
       $keyFile       = file_get_contents($keyfile);
       $result        = openssl_x509_parse($certFile);
       $keyPassphrase = 'password';
       $privatekey    = openssl_get_privatekey($keyFile, $keyPassphrase);
       openssl_sign($parse, $signature, $privatekey);
       $info       = array();
       $fields     = $result['issuer']['C'] . $result['issuer']['ST'] . $result['issuer']['L'] . $result['issuer']['O'] . $result['issuer']['OU'] . $result['validFrom'] . $result['validTo'] . $result['subject']['O'] . $result['subject']['CN'];
       $signatures = array(
           'signatures' => array(
               'com.bittorrent' => array(
                   'certificate' => $fields . $signature, // optional, DER encoded x.509 certificate
                   'info' => $info, // optional
                   'signature' => sha1(Bencode::encode($parsed['info'])) . (!empty($info) ? Bencode::encode($info) : '') // signed data = info + sig info if present
               )
           )
       );
       if (isset($array['url-list'])) {
           unset($array['url-list']);
       }
       $array = array_merge($parsed, $signatures);
       if (file_put_contents($out, Bencode::encode($array))) {
           return true;
       }
   }
   return false;
}


echo signtorrent('in.torrent', 'out.torrent', 'signing/certificate.pem', 'signing/private.key') ? 'success' : 'failed';
The answer to this is using a pointer instead. Example:

foreach ($array as $foo => &$var) {
}


No need for Each().
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: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728