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

V2 LibTorrent — 2022-01-16 11:00:43 in General Chat
how do you know ?  its just the hash so how did you test

here is improvement to looking through info array and getting file array
                        //Get files here
                       $torrentInfo['files'] = $info["file tree"];
                     
                       foreach ($info["file tree"] as  $key => $value) {

                           $path = $key;
                           foreach($value as $detail){
                               $filecount = ++$filecount;
                               $torrentsize += $detail['length'];
                               $newfiles[] = [
                                   'path' => $path, // key is important
                                   'length' => $detail['length']
                               ];
                           }
                       }
                       // Replace File Stucture
                       $torrentInfo['files'] = $newfiles;

V2 LibTorrent — 2022-01-16 10:17:50 in General Chat
this is what im testing at minute
                        $hash = hash('sha256', Bencode::encode($info));
                       $torrentInfo['hash'] = mb_substr($hash, 0, 40);$hash;
V2 LibTorrent — 2022-01-16 09:41:25 in General Chat
Not sure yet, with v1 we have 20byte sha1 and with v2 it says (possibly truncated) SHA-256 hash so if that v2 hash that's sha256 at 64 characters is cut to 20 should be fine - should lol still needs further testing

To explain why if you look at scrape.php page the old original internal one all we do with scrape is select torrent by hash then we count seeders peers and return. By that same logic if external we just use hash as like a $_GET to identify the torrent so site can return seeds and leech

This is just theory it depends how each person saves in database if everyone cuts length of sha256 to 20 it would make sense but without some v2 from piratebay, kickass etc I don't know the common way same with magnets

V2 LibTorrent — 2022-01-16 07:44:47 in General Chat
On local host every thing is fine, just going to take a look at hybrid torrents then I'll do live test and look at announce

With hybrid you can connect to v1 & v2 swarms
V2 LibTorrent — 2022-01-16 07:05:11 in General Chat
noticed the files were not insert into database correctly because there if a difference between the return file/filetree array so now i make a array for v2 but in the old v1 way, if this can be improved please help out.

For those on v3 all i have done is edit the backend/parse.php we still need to check announce but this takes care of uploading v2 torrents to the site
my codes different i use it in a class but its pretty easy to walk through the difference

in the parse function i changed $torrentinfo[?] to have named keys to make it easier to read, if you do this you would need to change the same in import.php & upload.php or leave as numbers which ever.

    public function Parse($filename = "")
   {
       $torrentInfo = array();
       $array = array();

       //check file type is a torrents
       $torrent = explode(".", $filename);
       // $fileend = end($torrent);
       $fileend = strtolower(end($torrent));

       if ($fileend == "torrent") {
           $parse = file_get_contents("$filename");
        // If Parse Lets Read It
        if (!isset($parse)) {
           Redirect::autolink(URLROOT, Lang::T("Error Getting Torrent file"));
       } else {
           // Decode File Array
           $array = Bencode::decode($parse);
           // If Array Lets Read It
           if ($array === false) {
               Redirect::autolink(URLROOT, Lang::T("Unable to decode file."));
           } else {
               if (array_key_exists("info", $array) === false) {
                   Redirect::autolink(URLROOT . "/index", Lang::T("Error opening torrent.<br>"));
               } else {
                   //Get Announce URL
                   $torrentInfo['announce'] = $array["announce"];
                   //Get Announce List Array
                   if (isset($array["announce-list"])) {
                       $torrentInfo["announce-list"] = $array["announce-list"];
                   }
                   // Calculates date from UNIX Epoch
                   $torrentInfo["creation date"] = date('r', $array["creation date"]);
                   //Get torrents comment
                   if (isset($array['comment'])) {
                       $torrentInfo['comment'] = $array['comment'];
                   }
                   // Read info - files
                   $info = $array["info"];
                   // The name of the torrents is different to the file name
                   $torrentInfo['name'] = $info['name'];
                   // Calculate Size/Count
                   $filecount = 0;
                   $torrentsize = 0;
                   // Get file list
                   if (isset($info["files"]) && is_array($info["files"])) {
                       // Calculates SHA1 Hash
                       $torrentInfo['hash'] = hash('sha1', Bencode::encode($info));
                       // Return Marker To identify as v1
                       $torrentInfo['type'] = '1';
                       //Get files here
                       $torrentInfo['files'] = $info["files"];

                       foreach ($info["files"] as $file) {
                           $filecount = ++$filecount;
                           $torrentsize += $file['length'];
                       }
                       $torrentInfo['length'] = $torrentsize;
                       $torrentInfo['ttfilecount'] = $filecount;

                   } elseif (isset($info["file tree"]) && is_array($info["file tree"])) {
                       // Calculates SHA256 Hash
                       $torrentInfo['hash'] = hash('sha256', Bencode::encode($info));
                       // Return Marker To identify as v2
                       $torrentInfo['type'] = '2';
                       //Get files here
                       $torrentInfo['files'] = $info["file tree"];
                       //$torrentInfo['files'] = array("path"=>$info["file tree"], "length"=>$info["file tree"][$torrentInfo['name']][$torrentInfo['length']]);

                       foreach ($info["file tree"] as  $key => $value) {
                           $test = array_flatten($torrentInfo['files']);
                           $filecount = ++$filecount;
                           $torrentsize += $test['length'];
                           $newfiles[] = [
                               'path' => array($key),
                               'length' => $test['length']
                           ];
                       }
                       // Replace File Stucture
                       $torrentInfo['files'] = $newfiles;

                       $torrentInfo['length'] = $torrentsize;
                       $torrentInfo['ttfilecount'] = $filecount;

                   } else {
                       // Single File Torrent
                       $torrentInfo['name'] = $info['name'];
                       $torrentInfo['length'] = $info['length'];
                       $torrentInfo['ttfilecount'] = 1;
                   }

               }
           }
           
       }
       }
       return $torrentInfo;
       //var_dump($torrentInfo);
   }


i also used this function so add above parse function on parse.php
//convert multi to single array
function array_flatten($array) {
   if (!is_array($array)) {
     return FALSE;
   }
   $result = array();
   foreach ($array as $key => $value) {
     if (is_array($value)) {
       $result = array_merge($result, array_flatten($value));
     }
     else {
       $result[$key] = $value;
     }
   }
   return $result;
}
Tree file — 2022-01-16 05:48:34 in General Chat
are you inserting files into file table or using the serialised array in torrent table ?
V2 LibTorrent — 2022-01-15 09:13:49 in General Chat
Looking at hashes as well need to replace binhex from announce need to return the sha256 and sha1 hashes from the client so there same length maybe so there 32, remember we only us hash to identify the torrent in our code its also used in scraping but we get the hash and trackers directly from the file not the database

this seems to be working switching between both, the sha256 hash is to big for table its 64 but this could be useful you can tell difference in future by hash length

update fully working using $info["file tree"][$torrentInfo['name']]

        // Target File
       $torrent_dir = UPLOADDIR."/torrents/2.torrent";
       // Lets Get Contents
       $parse = file_get_contents($torrent_dir);
       
       // If Parse Lets Read It
       if (!isset($parse)) {
           Redirect::autolink(URLROOT, Lang::T("Error Getting Torrent file"));
       } else {
           // Decode File Array
           $array = Bencode::decode($parse);
           // If Array Lets Read It
           if ($array === false) {
               Redirect::autolink(URLROOT, Lang::T("Unable to decode file."));
           } else {
               if (array_key_exists("info", $array) === false) {
                   Redirect::autolink(URLROOT . "/index", Lang::T("Error opening torrent.<br>"));
               } else {
                   //Get Announce URL
                   $torrentInfo['announce'] = $array["announce"];
                   //Get Announce List Array
                   if (isset($array["announce-list"])) {
                       $torrentInfo["announce-list"] = $array["announce-list"];
                   }
                   // Calculates date from UNIX Epoch
                   $torrentInfo["creation date"] = date('r', $array["creation date"]);
                   //Get torrents comment
                   if (isset($array['comment'])) {
                       $torrentInfo['comment'] = $array['comment'];
                   }
                   // Read info - files
                   $info = $array["info"];
                   // The name of the torrents is different to the file name
                   $torrentInfo['name'] = $info['name'];
                   // Calculate Size/Count
                   $filecount = 0;
                   $torrentsize = 0;
                   // Get file list
                   if (isset($info["files"]) && is_array($info["files"])) {
                       // Calculates SHA1 Hash
                       $torrentInfo['hash'] = hash('sha1', Bencode::encode($info));
                       // Return Marker To identify as v1
                       $torrentInfo['type'] = '1';
                       //Get files here
                       $torrentInfo['files'] = $info["files"];
                       foreach ($info["files"] as $file) {
                           $filecount = ++$filecount;
                           $torrentsize += $file['length'];
                       }
                       $torrentInfo['length'] = $torrentsize;
                       $torrentInfo['ttfilecount'] = $filecount;

                   } elseif (isset($info["file tree"]) && is_array($info["file tree"])) {
                       // Calculates SHA256 Hash
                       $torrentInfo['hash'] = hash('sha256', Bencode::encode($info));
                       // Return Marker To identify as v2
                       $torrentInfo['type'] = '2';
                       //Get files here
                       $torrentInfo['files'] = $info["file tree"][$torrentInfo['name']];
                       foreach ($info["file tree"][$torrentInfo['name']] as $file) {
                           $filecount = ++$filecount;
                           $torrentsize += $file['length'];
                       }
                       $torrentInfo['length'] = $torrentsize;
                       $torrentInfo['ttfilecount'] = $filecount;

                   } else {
                       // Single File Torrent
                       $torrentInfo['name'] = $info['name'];
                       $torrentInfo['length'] = $info['length'];
                       $torrentInfo['ttfilecount'] = 1;
                   }
               
                   echo 'so heres the return parse function<br>';
                   echo '<pre>' , print_r($torrentInfo) , '</pre><br>';

               }
           }
           
       }


new test
https://torrenttrader.uk/atest
V2 LibTorrent — 2022-01-15 08:54:07 in General Chat
Passkey is added on internal on download so that's fine we use sprintf to replace announce.php in  parsed string with announce?passkey=

Maybe we could use array_key_exsist on file tree if tree is there means v2 mark torrent as v2

If that file tree not there must be v1 file continue with original code

Or if table column can be null try save as both file and file tree

If file tree key exist we would have to mark the torrent with a column type eg 1 or 2 so we can identify in are code because printing out the files would be different
V2 LibTorrent — 2022-01-15 06:48:56 in General Chat
ive manged to get a qbit - official source didn't work at all lol

ive uploaded a v2 torrent fine just need to check the files are inserted correctly just the files and announce-list could do with a big multi external v2 to thoroughly test not sure the big sites will use v2 torrents.

this is whats returned from parse.  These items are missing announcelist(not external needs tests), files(not sure why current issue), comments (not used any way)
Quote:
array(6) {
["announce"]=> string(27) "http://example.com/announce"
["hash"]=> string(40) "c14199bbec64d0e9e439aa3b6b7639e666b86eca"
["creation date"]=> string(31) "Sat, 15 Jan 2022 07:44:49 +0100"
["name"]=> string(7) "test64K"
["length"]=> int(65536)
["ttfilecount"]=> int(1)
}


heres the inserted row
INSERT INTO `torrents` (`id`, `info_hash`, `name`, `filename`, `save_as`, `descr`, `image1`, `image2`, `category`, `size`, `added`, `type`, `numfiles`, `comments`, `views`, `hits`, `times_completed`, `leechers`, `seeders`, `last_action`, `visible`, `banned`, `owner`, `anon`, `numratings`, `ratingsum`, `nfo`, `announce`, `external`, `torrentlang`, `freeleech`, `tube`, `tmdb`, `uplreq`, `sticky`, `vip`, `announcelist`, `filelist`) VALUES
(2, 'c14199bbec64d0e9e439aa3b6b7639e666b86eca', 'test64K', '2.torrent', '2.torrent', 'test', NULL, NULL, 45, 65536, '2022-01-15 06:36:43', 'single', 1, 0, 0, 0, 0, 0, 0, '2022-01-15 06:36:43', 'yes', 'no', 1, 'no', 0, 0, 'no', 0x687474703a2f2f6578616d706c652e636f6d2f616e6e6f756e6365, 'yes', 0, '0', NULL, NULL, 'no', 'no', '', 'b:0;', 'b:0;');
this can be used for testing ill add to github when i know its fully working
https://mega.nz/file/ZUplHYSb#GTfGEEuKkxn7eNq1u-kArMi_E5v4q11yLOPYUAyObBc

19.01.21 link updated
V2 LibTorrent — 2022-01-14 21:25:41 in General Chat
not a lot of details of php torrents online and its had me scratching my head a few times so if it helps any one

the only thing the client does is connect to the announce.php to get a return of peer_ids, ports & ips.
thats all - all the other data like files, announcelist is not used for the client - in TT we have users, torrents, agentchecks etc but thats got nothing to do with the torrent or client.

The hash is just a id to recognise that connecting client to the site so as long as it is always same shouldn't matter how its encoded instead of sha256 it could be md5 because when you md5 a sha256 hash you will always get same result - this is just to give idea how it works use sha256

For the client the torrent file itself shares all the information about files, announces etc and in TT we dont write a file - we just copy that file to our server, we dont encode or decode - just straight copy. We add passkey on download but thats fine the code does that already

The torrent & client side is pretty straight forward its the interaction with TT this is where the parse function comes in we need to be able to read the file array to save the details in the database - nothing to do with the torrent itself, just the database im thinking return a big array for v1 & v2

V2 LibTorrent — 2022-01-14 20:28:54 in General Chat
added pre tags  👍  the path would need changing for v3 eg
$torrent_dir = "uploads/2.torrent";


thanks for torrent micromonkey still getting errors uploading but it looks like it just the parse function returning null on some of the data could you add something like TTv3 in a v2 torrent so i can check file/folder/path reading

Quote:
Uncaught Exception: 2022-01-14 20:16:26 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'size' cannot be null in file /global/torrent1/app/libraries/DB.php on line 39

Call Stack

[0] File: /global/torrent1/app/libraries/DB.php Line: 39
Function: PDOStatement->execute
Call parameters
Param[0]: Passed value: array (
 0 => 'Wind\'s.mp3.torrent',
 1 => '1',
 2 => 'Wind\'s.mp3',
 3 => 0,
 4 => 'test v2',
 5 => NULL,
 6 => NULL,
 7 => 18,
 8 => NULL,
 9 => '2022-01-14 20:16:26',
 10 => 'c22e5f3b13ce8e230a6c3b0775fb83c9a524f91d',
 11 => NULL,
 12 => 1,
 13 => 'Wind\'s.mp3.torrent',
 14 => 'https://torrenttrader.uk/announce.php',
 15 => 'no',
 16 => 'no',
 17 => 0,
 18 => 'no',
 19 => '2022-01-14 20:16:26',
 20 => 0,
 21 => NULL,
 22 => NULL,
 23 => 'b:0;',
)
V2 LibTorrent — 2022-01-14 16:32:47 in General Chat
For those interested in torrenting this is a place to share information about the new v2 implementation.

This can be links, wikis, videos, code snippets anything and is here to help keep update for connecting to clients in PHP.

Few Links
libtorrent  https://blog.libtorrent.org/2020/09/bittorrent-v2/
BEP52 http://bittorrent.org/beps/bep_0052.html

The first things that stuck out to me are:
The hash is now SHA-256 this still needs to be 20 bytes long (bytes not characters at moment the sha1 is 40bytes but we use hexbin to 20 this should be the same using a limit on a custom hex_bin function like on bitstorm - after having a quick look at this we don't send the hash back to the client ist just to identify in our dB that id to the id of the client  it's connecting to that should be just a case of changing table column length and change for sh256

A integer with any leading zeros (except 0 itself). e.g. “i0004e” are not allowed - this bit had me puzzled at first until i read my notes on bencoding, this will be extremely uncommon  if at all bencode is string length say eg 5 followed by the string eg hello so that would be i5ehello so the torrent string should never start with 0

In the future all old torrents will be obsolete, but for now we can do hybrid torrents so saving the new hash and data is a good idea to start on now

The structure of the torrent file array is different filetree, but also how pieces & paths work this needs live test

Here is a few test v2 torrents https://github.com/arvidn/libtorrent/tree/RC_2_0/test/test_torrents

If anyone has anything to add or has any progress please can you post here and ill update the post as we go. Progress might be slow but if everyone shares there work and knowledge we can keep up to date  👍

At moment qbit crashes for me so cant make a v2 torrent with my own announce but i have tried decoding one of the test ones from above, when i try upload to TT i get a few things come back null from the parser function, if someone knows how to set qbit to create v2 torrent that would be a big help i think i can grab the data but until qbit 4.4 works for me i cant test that much

here is link to test - first two dumps are v2 & last one is v1 so far it looks like its just the parse function (upload & import) and announce will need changing
https://torrenttrader.uk/atest

code used for testing page ive attached my bencode class, im using not sure if its working as it should for v2 but ive been using it for v1 for some time
        echo '<br><br>v2 torrent<br><br>';
       
       $torrent_dir = UPLOADDIR."/torrents/2.torrent";

       $test = Bencode::load($torrent_dir);
       var_dump($test);

       echo '<br><br>another v2 torrent<br><br>';

       $torrent_dir = UPLOADDIR."/torrents/16.torrent";

       $test = Bencode::load($torrent_dir);
       var_dump($test);
       
       echo '<br><br>original v1 torrent<br><br>';

       $torrent_dir = UPLOADDIR."/torrents/1.torrent";

       $test = Bencode::load($torrent_dir);
       var_dump($test);
good idea  😊 my query's are different but manged to add.  useful for forum views &  download hits 👍

            $pvkey_var = "v_".$id;
           $views = $_SESSION[$pvkey_var] == 1 ? $row["views"] + 0 : $row["views"] + 1;
           $_SESSION[$pvkey_var] = 1;
           DB::update('torrents', ['views'=>$views], ['id'=>$id]);
 
not all but most of them. there is loads of mods i will go thorugh post this weekend and make a list of whats included
ill post a copy on friday  👍 just a few last things to iron out  😉
Bug Tracker — 2022-01-12 13:37:24 in M-BiTsy Support
kiki2020:
in forum the QUOTE reply not work ! sort only [quote=] , pseudo is blank  


thanks for letting me know fixed
Scrape — 2022-01-12 11:40:13 in v3 Support
Edited my code above, working fine for me if someone else can test

if you get socket error find this line on php.ini and remove ; from front
;extension=sockets
Scrape — 2022-01-11 21:26:38 in v3 Support
That means it may be server side did you try remove surrounding /* & */

/*
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
*/
Scrape — 2022-01-11 15:23:09 in v3 Support
Updated code above
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