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

BT v1/v2 parser Work — 2022-02-28 04:46:54 in M-BiTsy Support
I noticed the piratebay shows all this, I wasn't really sure why
Grid may be better in this case for this 3-column layout, because you can shift/arrange content instead of shrinking it by viewport resolution.

This is incredibly easy to replicate by eye, and use a populate framework.

This is why I used Smarty v3 a while back, but due to the overhead and parsing time increased (slower), I decided to simply edit my theme files as raw markup mixed with PHP instead of using any template engine.

You should see a offline cache of multiple pages if you navigate to your browsers temp files and trace the markup files in there.

Like I said, there is not a lot going on with the UI so it’s easy to rip and upload.
Go with PDO - best advice I can give. Regards,
Weekend. I’ve been jammed. This will be on my list Saturday/Sunday.

I will also attempt to merge most up to date changes I have as I recently performed a clean up and optimization on my live script (not this one).

There may be SQL changes involved but I will work to get this truly working first.
Force Login [TTv3] — 2022-02-25 14:22:17 in v3 Mods Completed
You could do this to sign up if you send a post request to login page using signup fields if checks pass, or redirect to login with a GET read of url parameters, allowing them to “confirm”, or you can force a cookie and push login as I believe TTv3 operates - it doesn’t support sessions so its very different.

If I read the subject correctly lol
BT v1/v2 parser Work — 2022-02-24 03:16:17 in M-BiTsy Support
Not for display purposes, no.

Who wants to read through and wonder what a “pad file” is? Only after they decide that this “pad” file must not be what they are looking for, therefor it becomes a strange and confusing torrent to almost all users.

Your statement also held no reason or explanation for perfectly good code. Enjoy lol
AJAX Polls v1 — 2022-02-20 19:51:26 in v3 Mods Completed
This mod was completely rewritten last summer, with extended features and rewritten javascript that parses 2 arrays coming out of the ajax file.

I used to have it like this, which just decided which  DIVs to show or not based on a table read. But that contradicted the AJAX feature so now its all combined and updates live.

You can use any db connector/object as long as you retain the SQL you see. After that, it really doesn't matter how its interpreted, as long as the SQL is there it will show up.

Today's version running live, is hired (freelancer.com) work that took 6 hours and now spans data across 3 tables with very specific references and JOINs. Its had a few updates lol


If votes exceed 10, a flag appears and its a running race to the most votes

Is this mod working for you ?

Which means base64_encode() failed given the variable it was told to read. Sounds like a database empty field. This is why I use ternary's, so it returns a condition if the first failed, and reduces fatal errors if the function is designed to halt compiler on empty variable. In this case, its useful to check if empty + check if string and always.. trim() the final result - even trim(base64_encode($var))
Patience is necessary. I stayed awake 3 full nights until 6am to pull this off - mind you, I did take rest during the day. Coding tired sucks and it always effects variable/function naming, and not so much the goal or logic at hand lol sloppy finger tips.

Parser - Upload works across all versions 100%
Details page - File list (with directories) work across all versions 100%
Vouchers (my work) - filters from list and activates feature 100%

Anyone need any help porting any of that to your TT edition - do PM me and I can assist - but this really should be a class before I do any further work. Right now, its all put together fairly well, and even allowed me to remove a lot of my old code that was so-so to behind with - Thank you ALL for your help and work on this. 😉

I can't find a single tracker script that even supports V2 out there, so this should be a milestone for the community!

BT v1/v2 parser Work — 2022-02-16 22:18:32 in M-BiTsy Support
Now for the file list work within directories


// Detect if item is within a directory (v1)
foreach ($torrentInfo['files'] as $file)
{
  if (strstr(implode('/', $file['path']), '/')) {
     echo "I am in a folder";
  }
}

What is the difference between SPL iterator and this


if (isset($info['files']) || $filecount > 1)
           {
               if (isset($info['files']) && is_array($info['files']))
               {
                   $torrentInfo['files'] = $info['files'];
                   foreach ($info['files'] as $file)
                   {
                       $filecount = ++$filecount;
                       $torrentsize += $file['length'];
                   }
                   $torrentInfo['length'] = $torrentsize;
                   $torrentInfo['ttfilecount'] = !empty($path) ? count($path) : $filecount;
               }
           }


The iterator class works perfectly, exact same result - with less looping needed. Is your iterator code faster or just elegant? I chose to replace with it as the code looks a lot cleaner but its a long routine compared to the code posted ^
BT v1/v2 parser Work — 2022-02-16 06:11:34 in M-BiTsy Support
BT v1/v2 parser Work — 2022-02-15 21:08:15 in M-BiTsy Support
I think I got the array now. It matches libtorrents design perfectly, and smaller code than before. I think I'm happy with this now. I dont see a lot else to do for it other than adding to a class maybe


<?
function torr( ? string $filename = '') : mixed
{
   $torrentInfo = array();
   $array = array();
   $version = array();

   $torrent = explode(".", $filename);
   $fileend = strtolower(end($torrent));
   if ($fileend == "torrent")
   {
       $parse = file_get_contents("$filename");
       if ($parse === false)
       {
           echo "Error Getting Torrent file";
       }
       else
       {
           // Decode File Array
           $array = Bencode::decode($parse, bigInt:
               BigInt::INTERNAL);
               // Push version to Array
               array_push($version, (array_key_exists('meta version', $array['info']) ? intval($array['info']['meta version']) : 1));
               // If Array Lets Read It
               if (empty($array))
               {
                   die('Unable to decode metadata.');
               }
               else
               {
                   if (array_key_exists('info', $array) !== true)
                   {
                       die('Error opening torrent');
                   }
                   else
                   {
                       $path = array();
                       $info = $array["info"];
                       $torrentInfo['name'] = $info['name'];
                       $torrentInfo['announce'] = isset($array["announce"]) ? $array["announce"] : null;
                       $torrentInfo["announce-list"] = (isset($array["announce-list"])) ? $array["announce-list"] : null;
                       $torrentInfo["creation date"] = isset($array["creation date"]) ? date('r', $array["creation date"]) : null;
                       $torrentInfo['info_hash'] = in_array(2, $version) ? hash('sha256', Bencode::encode($info)) : hash('sha1', Bencode::encode($info));
                       $torrentInfo['version'] = $version[0];

                       if (isset($info['file tree']) && isset($info['pieces']))
                       {
                           $torrentInfo['info_hash v1'] = hash('sha1', Bencode::encode($info));
                           $torrentInfo['info_hash v2'] = hash('sha256', Bencode::encode($info));
                           $torrentInfo['version'] = 'Hybrid';
                           unset($torrentInfo['info_hash']);
                           $torrentInfo['info_hash'] = $torrentInfo['info_hash v1'];
                       }

                       $tracker = !empty($array['announce']) ? array(
                           $array['announce']
                       ) : null;
                       foreach ((new Scrape())->scrape($torrentInfo['info_hash'], $tracker) as $value)
                       {
                           $torrentInfo['seeders'] = intval($value['seeders']);
                           $torrentInfo['leechers'] = intval($value['leechers']);
                           $torrentInfo['completed'] = intval($value['completed']);
                       }
                       if ((new Scrape())->has_errors())
                       {
                           $torrentInfo['scrape error'] = (new Scrape())->get_errors();
                       }

                       $torrentInfo['files'] = $path;
                       if (in_array(2, $version))
                       {
                           unset($torrentInfo['files']);
                           array_push($path, $info);
                           $torrentInfo['file tree'] = $info['file tree'];
                       }

                       $filecount = 0;
                       $torrentsize = 0;
                       $torrentInfo['length'] = $torrentsize;
                       $torrentInfo['ttfilecount'] = $filecount;
                       $torrentInfo['private'] = array_key_exists('private', $info) ? 'Yes' : 'No';
                       $torrentInfo['signed'] = array_key_exists('signatures', $array) ? 'Yes' : 'No';

                       if (array_key_exists('signatures', $array))
                       {
                           foreach ($array['signatures'] as $value => $key)
                           {
                               $torrentInfo['authority'] = $value;
                               foreach ($key as $certinfo)
                               {
                                   $filter = array(
                                       '' => '',
                                       '' => '',
                                       '' => '',
                                       '' => '',
                                       '' => '',
                                       ' ' => '',
                                       '' => '',
                                       'U' => '',
                                       '6' => '',
                                       '/' => ' ',
                                       '0x06' => '',
                                       '' => '',
                                       '' => '',
                                       '1' => '',
                                       '8' => '',
                                       '0' => '',
                                       '' => '',
                                       '2' => '',
                                       '4' => '',
                                       '9' => '',
                                       'Z' => '',
                                       '3' => '',
                                       'b' => ''
                                   );
                                   $alloc = strtr($certinfo, $filter);
                                   $torrentInfo['certificate'] = explode(' ', trim(explode("\n", $alloc) [3]) , 3) [2];
                                   $split = explode("\n", $alloc) [3];
                                   $sep = preg_split('/[\s,]+/', $split, 3);
                                   $torrentInfo['issuer'] = implode(', ', array(
                                       $sep[0],
                                       $sep[1]
                                   ));
                                   break;
                               }
                           }
                       }

                       if (array_key_exists('file tree', $info) || array_key_exists('files', $info))
                       {
                           // Calc file counts
                           if (isset($info['files']) || $filecount > 1)
                           {
                               if (isset($info['files']) && is_array($info['files']))
                               {
                                   $torrentInfo['files'] = $info['files'];
                                   foreach ($info['files'] as $file)
                                   {
                                       $filecount = ++$filecount;
                                       $torrentsize += $file['length'];
                                   }
                                   $torrentInfo['length'] = $torrentsize;
                                   $torrentInfo['ttfilecount'] = !empty($path) ? count($path) : $filecount;
                               }
                           }
                       }
                   }
               }
           }
       }
       return print_r($torrentInfo);
   }


The array produced from code above:

bittorrent-v1-test.torrent
Array
(
   [name] => Qubes-R4.1.0-x86_64
   [announce] => http://linuxtracker.org:2710/00000000000000000000000000000000/announce
   [announce-list] => Array
       (
           [0] => Array
               (
                   [0] => udp://tracker.openbittorrent.com:80
               )

           [1] => Array
               (
                   [0] => udp://tracker.coppersurfer.tk:6969
               )

           [2] => Array
               (
                   [0] => udp://tracker.torrent.eu.org:451
               )

           [3] => Array
               (
                   [0] => http://linuxtracker.org:2710/00000000000000000000000000000000/announce
               )

       )

   [creation date] =>
   [info_hash] => ec0397eceff415d9fba61399a1cd4efbd7406922
   [version] => 1
   [seeders] => 14
   [leechers] => 0
   [completed] => 33
   [files] => Array
       (
           [0] => Array
               (
                   [length] => 5954863104
                   [path] => Array
                       (
                           [0] => Qubes-R4.1.0-x86_64.iso
                       )

               )

           [1] => Array
               (
                   [length] => 1251
                   [path] => Array
                       (
                           [0] => Qubes-R4.1.0-x86_64.iso.DIGESTS
                       )

               )

           [2] => Array
               (
                   [length] => 833
                   [path] => Array
                       (
                           [0] => Qubes-R4.1.0-x86_64.iso.asc
                       )

               )

       )

   [length] => 5954865188
   [ttfilecount] => 3
   [private] => No
   [signed] => No
)
bittorrent-v2-test.torrent

Array
(
   [name] => bittorrent-v2-test
   [announce] =>
   [announce-list] =>
   [creation date] => Thu, 21 May 2020 14:40:57 -0700
   [info_hash] => caf1e1c30e81cb361b9ee167c4aa64228a7fa4fa9f6105232b28ad099f3a302e
   [version] => 2
   [file tree] => Array
       (
           [13.Popsy Team - ViP 2.vob.mp4] => Array
               (
                   [] => Array
                       (
                           [length] => 27551708
                           [pieces root] => ��?���Ý�V�|s�{��!F4��$��
                       )

               )

           [Chameleon by ASD (female voice).mov] => Array
               (
                   [] => Array
                       (
                           [length] => 91862892
                           [pieces root] => ��H�NA����H"뢂�@`e9��c=��N/
Array
               (
                   [] => Array
                       (
                           [length] => 6535405
                           [pieces root] => �1��%�3gh�x&ȩ��}��fD(��
                       )

               )

           [Struct by Outracks (FullHD 1080p HQ demoscene).mov] => Array
               (
                   [] => Array
                       (
                           [length] => 141132865
                           [pieces root] => M��!ķ5��x�9�����>�˯���kP%FE;
                       )

               )

           [asd-rupture.mp4] => Array
               (
                   [] => Array
                       (
                           [length] => 263671468
                           [pieces root] => �=�9�
��P�K�Ն.=z���5�״f�,
                       )

               )

           [cncd_fairlight-ceasefire_(all_falls_down)-1080p.mp4] => Array
               (
                   [] => Array
                       (
                           [length] => 342230630
                           [pieces root] => i}�S�a��~]�]�*~���l��ꪃ��D���
                       )

               )

           [crionics & silents - hardwired (1991, hpad, divx5).avi] => Array
               (
                   [] => Array
                       (
                           [length] => 135000064
                           [pieces root] => -�x�Y�diVK��9Ʉ������ ����~
                       )

               )

           [elevated_4000.avi] => Array
               (
                   [] => Array
                       (
                           [length] => 113274880
                           [pieces root] => ]� ��Xv&o^]ͫ(��k��K�?:&i`�ъ�\�
                       )

               )

           [luma - mercury _ 64k _ Final.mp4] => Array
               (
                   [] => Array
                       (
                           [length] => 183814243
                           [pieces root] => b�i�4ܝ�L� >c�(f�N�Oݻww��=�
                       )

               )

           [readme.txt] => Array
               (
                   [] => Array
                       (
                           [length] => 61
                           [pieces root] => ; Array
               (
                   [] => Array
                       (
                           [length] => 229148672
                           [pieces root] => �?�_θ��U�/!� 쬕qu�TJ��(e�Dz�
                       )

               )

       )

   [length] => 0
   [ttfilecount] => 0
   [private] => No
   [signed] => No
)

bittorrent-v2-hybrid-test.torrent

Array
(
   [name] => bittorrent-v1-v2-hybrid-test
   [announce] =>
   [announce-list] =>
   [creation date] => Wed, 03 Jun 2020 01:45:06 -0700
   [version] => Hybrid
   [info_hash v1] => 631a31dd0a46257d5078c0dee4e66e26f73e42ac
   [info_hash v2] => d8dd32ac93357c368556af3ac1d95c9d76bd0dff6fa9833ecdac3d53134efabb
   [info_hash] => 631a31dd0a46257d5078c0dee4e66e26f73e42ac
   [file tree] => Array
       (
           [Darkroom (Stellar, 1994, Amiga ECS) HQ.mp4] => Array
               (
                   [] => Array
                       (
                           [length] => 6535405
                           [pieces root] => �1��%�3gh�x&ȩ��}��fD(��
                       )

               )

           [Spaceballs-StateOfTheArt.avi] => Array
               (
                   [] => Array
                       (
                           [attr] => x
                           [length] => 20506624
                           [pieces root] => $���&=U݄�,�6o`����
֗��.�Q�
                       )

               )

           [cncd_fairlight-ceasefire_(all_falls_down)-1080p.mp4] => Array
               (
                   [] => Array
                       (
                           [length] => 342230630
                           [pieces root] => i}�S�a��~]�]�*~���l��ꪃ��D���
                       )

               )

           [eld-dust.mkv] => Array
               (
                   [] => Array
                       (
                           [length] => 61638604
                           [pieces root] => ǩj� �2��a��X��:�����@��
                       )

               )

           [fairlight_cncd-agenda_circling_forth-1080p30lq.mp4] => Array
               (
                   [] => Array
                       (
                           [length] => 277889766
                           [pieces root] => � k�6�853���
|����'�g���8�r
                       )

               )

           [meet the deadline - Still _ Evoke 2014.mp4] => Array
               (
                   [] => Array
                       (
                           [length] => 44577773
                           [pieces root] => ϩOGyj�θ�n�HCPC���K"�7�-U��
                       )

               )

           [readme.txt] => Array
               (
                   [] => Array
                       (
                           [attr] => x
                           [length] => 61
                           [pieces root] => ; Array
               (
                   [] => Array
                       (
                           [attr] => x
                           [length] => 26296320
                           [pieces root] => �D�<�����"�F��P��wO����÷���Q
                       )

               )

           [tbl-tint.mpg] => Array
               (
                   [] => Array
                       (
                           [length] => 115869700
                           [pieces root] => w�<�(���B=�����Z�/��Z)�=]ë��B

                       )

               )

       )

   [length] => 898631684
   [ttfilecount] => 1
   [private] => No
   [signed] => No
   [files] => Array
       (
           [0] => Array
               (
                   [length] => 6535405
                   [path] => Array
                       (
                           [0] => Darkroom (Stellar, 1994, Amiga ECS) HQ.mp4
                       )

               )

           [1] => Array
               (
                   [attr] => p
                   [length] => 280339
                   [path] => Array
                       (
                           [0] => .pad
                           [1] => 280339
                       )

               )

           [2] => Array
               (
                   [attr] => x
                   [length] => 20506624
                   [path] => Array
                       (
                           [0] => Spaceballs-StateOfTheArt.avi
                       )

               )

           [3] => Array
               (
                   [attr] => p
                   [length] => 464896
                   [path] => Array
                       (
                           [0] => .pad
                           [1] => 464896
                       )

               )

           [4] => Array
               (
                   [length] => 342230630
                   [path] => Array
                       (
                           [0] => cncd_fairlight-ceasefire_(all_falls_down)-1080p.mp4
                       )

               )

           [5] => Array
               (
                   [attr] => p
                   [length] => 129434
                   [path] => Array
                       (
                           [0] => .pad
                           [1] => 129434
                       )

               )

           [6] => Array
               (
                   [length] => 61638604
                   [path] => Array
                       (
                           [0] => eld-dust.mkv
                       )

               )

           [7] => Array
               (
                   [attr] => p
                   [length] => 227380
                   [path] => Array
                       (
                           [0] => .pad
                           [1] => 227380
                       )

               )

           [8] => Array
               (
                   [length] => 277889766
                   [path] => Array
                       (
                           [0] => fairlight_cncd-agenda_circling_forth-1080p30lq.mp4
                       )

               )

           [9] => Array
               (
                   [attr] => p
                   [length] => 507162
                   [path] => Array
                       (
                           [0] => .pad
                           [1] => 507162
                       )

               )

           [10] => Array
               (
                   [length] => 44577773
                   [path] => Array
                       (
                           [0] => meet the deadline - Still _ Evoke 2014.mp4
                       )

               )

           [11] => Array
               (
                   [attr] => p
                   [length] => 510995
                   [path] => Array
                       (
                           [0] => .pad
                           [1] => 510995
                       )

               )

           [12] => Array
               (
                   [attr] => x
                   [length] => 61
                   [path] => Array
                       (
                           [0] => readme.txt
                       )

               )

           [13] => Array
               (
                   [attr] => p
                   [length] => 524227
                   [path] => Array
                       (
                           [0] => .pad
                           [1] => 524227
                       )

               )

           [14] => Array
               (
                   [attr] => x
                   [length] => 26296320
                   [path] => Array
                       (
                           [0] => tbl-goa.avi
                       )

               )

           [15] => Array
               (
                   [attr] => p
                   [length] => 442368
                   [path] => Array
                       (
                           [0] => .pad
                           [1] => 442368
                       )

               )

           [16] => Array
               (
                   [length] => 115869700
                   [path] => Array
                       (
                           [0] => tbl-tint.mpg
                       )

               )

       )

)
BT v1/v2 parser Work — 2022-02-15 19:01:44 in M-BiTsy Support
Checking if v1/v2/hybrid and provide correct hash


// Calculates Hashes - SHA1/SHA256
$torrentInfo['info_hash'] = in_array(2, $version) ? hash('sha256', Bencode::encode($info)) : hash('sha1', Bencode::encode($info));
$torrentInfo['version']   = $version[0];
if (isset($info['file tree']) && isset($info['pieces'])) {
   $torrentInfo['info_hash v1'] = hash('sha1', Bencode::encode($info));
   $torrentInfo['info_hash v2'] = hash('sha256', Bencode::encode($info));
   $torrentInfo['version']      = 'Hybrid';
   unset($torrentInfo['info_hash']);
}
Win PHP port is necessarily better although you don’t want to rely on that for production. It may be more streamlined with IIS using the fcgi module.

I would mostly worry about paths and that is the main issue most have, then it’s Apache permissions and that’s usually smooth.
BT v1/v2 parser Work — 2022-02-15 05:51:40 in M-BiTsy Support
I love this stuff haha I'll do it for hours honestly - awesome looking good! I got the upload page finished and its all collected. scraping, file count, hash, etc

I ignore ignore v2 hash for hybrid, because that I think is just up to the client... it has a file tree so we know already lol

That's what they added that 'meta version' field, I think to help clients pick up the .torrent file type more easily as long as parsers catch up reading it - really up to the bittorrent codebase I guess - or libtorrent/rtorrent

Stay lit, stay high!  🔥
BEP 35 - Torrent Signing

This allows you to attach a certificate to 'signatures' field to prove authenticity of that media within the torrent file. Editing the file will remove the verification as it collects a checksum of the files and produces a certificate field, and a sha1 field of infoDict + Length.

OpenSSL 1.1.0 or greater - PHP 5.6, 7, 8

This expects a DER encoded X.509 certificate and private key file generated when you created your CSR (Ask your host).

I've managed to pull it off based on this:
https://github.com/bittorrent/ut-signing-tool

Spec:
http://bittorrent.org/beps/bep_0035.html


// Open torrent file for reading
$parse = file_get_contents('in.torrent');
$array = Bencode::decode($parse);

// BEP_35 - Torrent Signing
if (!isset($array['signatures'])) {
   $certFile      = file_get_contents('certificate.pem');
   $keyFile       = file_get_contents('private.key');
   $result        = openssl_x509_parse($certFile);
   $keyPassphrase = 'Your_Private_Key_Passphrase';
   $privatekey    = openssl_get_privatekey($keyFile, $keyPassphrase);
   openssl_sign($parse, $signature, $privatekey);
   $signatures = array(
       'signatures' => array(
           $result['subject']['CN'] => array(
               'certificate' => null, // <--- we need to now deal with this
               'info' => 'Optional',
               'signature' => $signature
           )
       )
   );
   $array      = array_merge($array, $signatures);
   array_merge($result, $array);
   file_put_contents('out.torrent', Bencode::encode($array));
} else {
   echo 'torrent is already signed.';
}
// Test
echo '<pre>';
print_r($array);
echo '</pre>';


Its nearly finished, as I realize the binary (unix executable) just dumps the parsed X509 certificates array into the bencoded data and from there it Bencode::encode($array) like the program in the link.

So I converted it to PHP native functions and Im nearly finished. All the update needs is a change to your upload script, and a small change to download.php - optionally you can showcase the signed feature on your torrent details page.

Using the link above, you cant change algorithms, add options or even control the data - because its written in pure C++.
So to avoid that (using it for 2 yrs now), I wanted to replicate it in PHP.

It provides the exact same processing as the program in the link. Its the best I can do 😂
BT v1/v2 parser Work — 2022-02-14 15:59:58 in M-BiTsy Support
The SPL iterator classes are great! Nice choice. I’ll try your code there, I like how it looks and I used it for the entire blob migration (the migrator forum post a while back), it works really nicely but definitely avoid calling multiple object references to the same object, it’s a performance impact. But I do t think it matters for parsing data in our case.

Just adding a big block of if/else’s to check my form fields slowed down my code considerably, not sure how to improve that, it must be at least a 5ms increase on page load - no big deal but is preventable.
BT v1/v2 parser Work — 2022-02-14 10:34:00 in M-BiTsy Support
Try this. I think this is all we need because we are just reading keys for the database. We are actually just copying the file to /uploads and ignoring almost all of this (we just need the sizes, name, announce and info_hash).

Most of this is just getting it to pull up files on the details page, which I will do tomorrow in my format and push the code over here.

This is I have so far.

BEPs Supported: 27, 35, 48, 52


function torr( ?string $filename = '') : mixed
{
   // Array storage
   $torrentInfo = array();
   $array = array();
   // Torrent Version
   $version = array();
   // Torrent filename
   $torrent = explode(".", $filename);
   $fileend = strtolower(end($torrent));
   if ($fileend == "torrent")
   {
       $parse = file_get_contents("$filename");
       // If Parse Lets Read It
       if ($parse === false)
       {
           echo "Error Getting Torrent file";
       }
       else
       {
           // Decode File Array
           $array = Bencode::decode($parse, bigInt:
               BigInt::INTERNAL);
               // Push version to Array
               array_push($version, (array_key_exists('meta version', $array['info']) ? intval($array['info']['meta version']) : 1));
               // If Array Lets Read It
               if (empty($array))
               {
                   die('Unable to decode metadata.');
               }
               else
               {
                   if (array_key_exists('info', $array) !== true)
                   {
                       die('Error opening torrent');
                   }
                   else
                   {
                       $path = array();
                       $data['announce'] = isset($array["announce"]) ? $array["announce"] : null;
                       // Get Announce URL
                       $torrentInfo['announce'] = isset($array["announce"]) ? $array["announce"] : null;
                       // Get Announce List Array
                       $torrentInfo["announce-list"] = (isset($array["announce-list"])) ? $array["announce-list"] : null;
                       // Calculates date from UNIX Epoch - You want to return NULL on this if empty to pass parse validation
                       $torrentInfo["creation date"] = isset($array["creation date"]) ? date('r', $array["creation date"]) : null;
                       // Get torrents comment
                       $torrentInfo['comment'] = (isset($array['comment'])) ? $array['comment'] : null;
                       // Read info - files
                       $info = $array["info"];
                       // The name of the torrents is different to the file name
                       $torrentInfo['name'] = $info['name'];
                       // Read the torrent version stored in array previously
                       $torrentInfo['version'] = $version[0];
                       // Calculate Size/Count
                       $filecount = 0;
                       $torrentsize = 0;
                       // Calculates Hashes - SHA1/SHA256
                       $torrentInfo['hash'] = in_array(2, $version) ? hash('sha256', Bencode::encode($info)) : hash('sha1', Bencode::encode($info));
                       $torrentInfo['info_hash v1'] = hash('sha1', Bencode::encode($info));
                       $torrentInfo['info_hash v2'] = hash('sha256', Bencode::encode($info));

                       // Scrape
                       $tracker = !empty($array['announce']) ? array(
                           $array['announce']
                       ) : null;
                       $hash = array(
                           hash('sha1', Bencode::encode($info))
                       );
                       foreach ((new Scrape())->scrape($hash, $tracker) as $value)
                       {
                           $torrentInfo['seeders'] = intval($value['seeders']);
                           $torrentInfo['leechers'] = intval($value['leechers']);
                           $torrentInfo['completed'] = intval($value['completed']);
                       }
                       if ((new Scrape())->has_errors())
                       {
                           $torrentInfo['scrape error'] = (new Scrape())->get_errors();
                       }

                       // File List
                       $struct = in_array(2, $version) ? $info['file tree'] : $info['files'];
                       if (array_key_exists('file tree', $info))
                       {
                           foreach ($struct as $key => $value)
                           {
                               foreach ($value as $detail)
                               {
                                   $filecount = ++$filecount;
                                   $torrentsize += $detail['length'];
                                   array_merge($path, array(
                                       'length' => $detail['length']
                                   ));
                               }
                               array_push($path, array(
                                   'length' => $detail['length'],
                                   'path' => array(
                                       sizeof($value) - 1 => $key
                                   )
                               ));
                           }
                           $torrentInfo['files'] = $path;
                           $torrentInfo['length'] = $torrentsize;
                           $torrentInfo['ttfilecount'] = $filecount;
                       }

                       $torrentInfo['private'] = array_key_exists('private', $info) ? 'Yes' : 'No';
                       $torrentInfo['signed'] = array_key_exists('signatures', $array) ? 'Yes' : 'No';
                       if (array_key_exists('signatures', $array))
                       {
                           foreach ($array['signatures'] as $value => $key)
                           {
                               $torrentInfo['authority'] = $value;
                               foreach ($key as $certinfo)
                               {
                                   $filter = array(
                                       '' => '',
                                       '' => '',
                                       '' => '',
                                       '' => '',
                                       '' => '',
                                       ' ' => '',
                                       '' => '',
                                       'U' => '',
                                       '6' => '',
                                       '/' => ' ',
                                       '0x06' => '',
                                       '' => '',
                                       '' => '',
                                       '1' => '',
                                       '8' => '',
                                       '0' => '',
                                       '' => '',
                                       '2' => '',
                                       '4' => '',
                                       '9' => '',
                                       'Z' => '',
                                       '3' => '',
                                       'b' => ''
                                   );
                                   $alloc = strtr($certinfo, $filter);
                                   $torrentInfo['certificate'] = explode(' ', trim(explode("\n", $alloc) [3]) , 3) [2];
                                   $split = explode("\n", $alloc) [3];
                                   $sep = preg_split('/[\s,]+/', $split, 3);
                                   $torrentInfo['issuer'] = implode(', ', array(
                                       $sep[0],
                                       $sep[1]
                                   ));
                                   break;
                               }
                           }
                       }

                       if (array_key_exists('file tree', $info) || array_key_exists('files', $info))
                       {
                           if (isset($info['files']) || $filecount > 1)
                           {
                               // Multi File
                               if (isset($info['files']) && is_array($info['files']))
                               {
                                   $torrentInfo['files'] = $info['files'];
                                   foreach ($info['files'] as $file)
                                   {
                                       $filecount = ++$filecount;
                                       $torrentsize += $file['length'];
                                   }
                                   $torrentInfo['length'] = $torrentsize;
                                   $torrentInfo['ttfilecount'] = !empty($path) ? count($path) : $filecount;
                               }
                           }
                           else
                           {
                               if ($filecount === 1)
                               {
                                   // Single File - Remove or Use
                                   
                               }
                           }
                       }
                   }
               }
           }
       }
       return print_r($torrentInfo);
   }


require 'Scraper.php';


It works fine for me, only issue I have now is getting download.php to accept anything aside from signed and thats a wrap. I'll know more once I construct the file/icon layout for the file tree on my torrent details page tomorrow. Busy week ahead, hope I have evening time to work on it.
BT v1/v2 parser Work — 2022-02-14 10:32:21 in M-BiTsy Support
incorrect - post. delete this.
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