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
File Tree
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / General / General Chat

2022-01-08 12:36:25
file tree from my script

i serialized the file array and inserted into same table instead of dumping into another table(same on announce urls too)


$f_liste = unserialize($row['fstruct']);
$tprice = array_column($f_liste, 'length');
$count_len = count($tprice);
$tprice = array_column($f_liste, 'path');
?>
<div class="tree">
<ul>
   <li class="parent_li">  <i class="fas fa-folder"></i> <?php print("<b>".$row['dirname']."</b> (<b>".mksize($row['size'])."</b>) (<b>".$count_len." files</b>)"); ?>
<ul style="padding-left:42.5px;">
<?php
array_multisort($tprice, SORT_ASC, SORT_REGULAR,$f_liste);
//print_r($f_liste);
foreach($f_liste as $flist){
   $dir = '';
   $size = $flist["length"];
   $count = count($flist["path"]);
   if(isset($flist['path'][1])){
       $t_icon = "<i class=\"fas fa-folder-open\"></i>";
   }else{
       $t_icon = '';
   }
$mdir = '';
   for ($i=0; $i<$count;$i++) {
/*
if($count > 1){
$mdir = $flist["path"][0];
}
*/
   if (($i+1) == $count){
       $fname = $dir.$flist["path"][$i];
} else {  
       $dir .= $flist["path"][$i]." / ";  
   }
   }
   print("<li>".$t_icon." <small>".$fname." (".mksize($size).")</small></li>");
}
?>
</ul>
</li>
</ul>




i want a file tree output like in kickass / 1337x
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-08 12:45:54
2022-01-08 12:37:34
if anybody has new ideas feel free to share
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-08 12:42:24
my script does not contain internal trackers

for more: https://www.bvlist.com/showthread.php?t=12349
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-08 12:42:48
2022-01-08 16:48:06
What type of sql table column do you use mate. Good idea saving array to table could be useful a number of ways. 👍

Just thinking of length of array

Do you use the original parse torrent function in parse.php, can you post any changes made  there on upload
Last edited by M-jay warn on 2022-01-08 17:18:45
2022-01-08 17:52:56

$annlist = $TorrentInfo[6]; // announce urls
$filelist = $TorrentInfo[8]; // file list array

$tor_ftr = array_flatten($annlist);
$tor_tracks = serialize($tor_ftr);
$f_list = serialize($filelist);

//use the above vars
//like
$ret = SQL_Query_exec("INSERT INTO torrents (filename, owner, name, descr, category, added, info_hash, size, save_as, announce, external, torrentlang, anon, trackerurls, fstruct, dirname, last_action,tags,imdb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",[$fname,$CURUSER['id'],$name,$descr,$catid,$uld_d,$infohash,$torrentsize,$fname,$announce,$external,$langid,$anon,$tor_tracks,$f_list,$internalname,$uld_d,$srtag,$imdbi],'','1');


//add this function to functions.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;
}



follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-08 17:55:06
add two rows for announce urls and files. (use datatype text)
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-08 18:12:37
i used the array_flatten function because i use a different lib for scarping torrent peers.
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-08 18:21:18
with it been external do you use this https://github.com/johannes85/PHP-Torrent-Scraper/tree/master/src or some version of it - always looking for good libs  😀
2022-01-08 18:24:12
i think this is better: https://github.com/medariox/scrapeer
enable sockets in php config
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-08 18:25:24
2022-01-08 18:56:58
JohnHasher, thank you so much for this idea,
I can only add that it would be fun to do for "tracker list" such a "tree"


M-jay where can I download this version of TT that you use here, have a little extra time to fix a new theme maybe


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2022-01-08 19:10:35
i was planning to sell this but here you go

add this to functions.php

//scrape fxn
function mscrape($infohash , $tracker){
 require_once (__DIR__ ."/class.scraper.php");
 if(isset($infohash) && isset($tracker)){
     $scraper = new Scrapeer\Scraper();
     $rat = $scraper->scrape( $infohash, $tracker);
     if(isset($rat)){
               if(empty($rat[$infohash]["seeders"]) && empty($rat[$infohash]["leechers"])){
                   $seed  = "0";
                   $leech = "0";
               }
               elseif(empty($rat[$infohash]["leechers"]))
               {
                   $seed  = $rat[$infohash]["seeders"];
                   $leech = "0";
               }
               elseif(empty($rat[$infohash]["seeders"])){
                   $seed  = "0";
                   $leech = $ret[$infohash]["leechers"];
               }
               else {
               $seed  = $rat[$infohash]["seeders"];
               $leech = $rat[$infohash]["leechers"];
               }
       
     SQL_Query_exec("UPDATE `torrents`  SET `last_action` = '".get_date_time()."', `seeders` = '".$seed."', `leechers` = '".$leech."' WHERE `info_hash` = '".$infohash."'");
     $lmessage = "Updated Torrent: ".$infohash." with s: ".$seed." and l: ".$leech."";
       $rcode = 1;
     }else{
         if ($scraper->has_errors()){
           $lmessage = $scraper->get_errors()." _on ".$infohash;
         }
       $rcode = 0;
     }
 write_log($lmessage);
 }else{
$rcode = 0;
 }

   if($rcode == 1){
   $ret[] = array('code' => utf8_encode($rcode),'sd' => utf8_encode($seed), 'lh' => utf8_encode($leech));
   }else{
    $ret[] = array('code' => utf8_encode($rcode));  
   }
   return $ret;
}


follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-08 19:22:13
2022-01-08 19:12:38
use javascript to update the peers without refreshing the page
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-09 11:48:55
im working on finishing and will be released soon Botanicar

really like this array in table idea - just realised when scraping you dont have to read the torrent file on every scrape for users on v3 you can test this
included the scrape class in backend https://github.com/medariox/scrapeer

just change the torrent path - this code would normally be on torrents-upload

<?php
require_once("backend/functions.php");
require_once("backend/Scraper.php");
dbconn();

       $tor = ParseTorrent(UPLOADDIR."/torrents/1.torrent");
       $announce = $tor[0];
       $infohash = $tor[1];
       $creationdate = $tor[2];
       $internalname = $tor[3];
       $torrentsize = $tor[4];
       $filecount = $tor[5];
       $annlist = $tor[6];
       $comment = $tor[7];
       $filelist = $tor[8];

       var_dump($tor);

       $scraper = new Scrapeer\Scraper();
       $ret = $scraper->scrape($infohash, $annlist, 20, 4, true );
       var_dump($ret);


then to encode for db
                if ($external === 'yes') {
                   $multi = array_flatten($annlist);
                   $announcelist = serialize($multi);
               }

               $multi = array_flatten($filelist);
               $fileliststring = serialize($multi);


to display announces on torrent details
    $array = unserialize($row['announcelist']);
   foreach ($array as $subarray){
      echo $subarray."<br>";
    }


then a function to scrape which updates old torrents to insert new serialize array for old torrent just pass torrent announce column
the insert querys would need fixing for v3
function ScrapeId($id, $annlist, $infohash)
   {
       if (!is_array($annlist)) {
           $tor = ParseTorrent(UPLOADDIR."/torrents/$id.torrent");
           $infohash = $tor[1];
           $annlist = array_flatten($tor[6]);
           $var2 = serialize($annlist);
       }
       
       $scraper = new Scraper();
       $scraped = $scraper->scrape($infohash, $annlist, 20, 4, true );

       $myarray = array_shift($scraped);

       $seeders = $leechers = $completed = 0;
       if ($myarray['seeders'] > 0) {
           $seeders = $myarray['seeders'];
       }
       if ($myarray['leechers'] > 0) {
           $leechers = $myarray['leechers'];
       }
       if ($myarray['completed'] > 0) {
           $completed = $myarray['completed'];
       }

       if ($seeders !== 0) {
           // Update the Torrent
           DB::update('torrents', ['leechers' =>$leechers, 'seeders' =>$seeders, 'times_completed' =>$completed, 'last_action' =>TimeDate::get_date_time(), 'visible' =>'yes', 'announcelist'=>$var2,], ['id'=>$id]);
       } else {
           // Its Dead :(
           DB::update('torrents', ['last_action' =>TimeDate::get_date_time()], ['id' => $id]);
       }
   }


just a case of insert the $announcelist & $fileliststring arrays into the torrent table
Last edited by M-jay warn on 2022-01-09 21:54:42
2022-01-09 21:28:31
added the announce and file arrays now  🔥  everything seemed pretty straight forward so i had a look at the file tree

for some reason when i unserialize it breaks not sure if thats because its no longer a multidimensional array but when parsing i can start to split them into sections but im not that experienced with complex arrays it would be easier if the returned array was keyed better

here is as far as i got - change torrent path i tested this on a seperate page my code is a little different but should be able to piece together
        // parse torrent
       $torInfo = new Parse();
       $torrentInfo = $torInfo->torr(UPLOADDIR."/torrents/13.torrent");
       //var_dump($torrentInfo[8]);echo '<br>';echo '<br>';
     
       // get the tree
       $file_tree = $torrentInfo[8];

       // set a path
       $path = '';

       // loop through for path
       foreach ($file_tree as $file) {
           //var_dump($file);
           echo '<br><br>';

           // if path matches must be same folder/file
           if ($file['path'][0] == $path) {
               echo $file['path'][0];
               echo '<p style="color:red">This is a path.</p>';
           } else {
               echo $file['path'][0];
               echo '<p style="color:green">This is a file.</p>';
           }

           // so change or update path path
           $path = $file['path'][0];

       }
Last edited by M-jay warn on 2022-01-09 21:29:51
2022-01-10 14:43:07
let me see what i can do
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
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: 4
  • Members: 0
  • Guests online: 4
  • Comments: 3
  • Messages: 1,728