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

[USER=20288]@m-jay[/USER]

How would we need to fix the simple search to be able to search users via email?
Thanks [USER=20288]@m-jay[/USER]. But for some reason wildcard not working when I want to search for example: *@gmail.com
"m-jay, post: 66870, member: 20288":

This is done two ways with the input m8, for the email address in some cases what you type is the send address ($email)
The input is also at times crypted/decrypted to check db, show email ($mail)

What about advanced user search into admin panel

I got to show mails, but can't make search work.
I just changed the function to scrape only 1 tracker and the first one. It's pointless and very slow when scraping all of the backup trackers.

Now we need to change torrents-upload.php to scrape a torrent WITHOUT backend/parse.php because it is so slow.

Here's how to add announces into the backup tracker

Find [ICODE]if (strtolower(substr($val, 0, 4)) != "udp:") { [/ICODE] and replace with if (strtolower(substr($val, 0, 4)) != "https:") {

It will not include HTTP and UDP trackers.

Now the problem:

I fixed external scraping like this BUT it's scraping torrent via this [ICODE]$TorrentInfo = ParseTorrent("$site_config[torrent_dir]/$rowu[id].torrent");[/ICODE] which is very slow and can take over 40 seconds when uploading.

    //EXTERNAL SCRAPE
   if ($external=='yes' && $site_config['UPLOADSCRAPE']){
          $resu = SQL_Query_exec("SELECT id, info_hash FROM torrents WHERE external = 'yes' AND id = $id");
           while ($rowu = mysqli_fetch_array($resu))
           {
               $TorrentInfo = ParseTorrent("$site_config[torrent_dir]/$rowu[id].torrent");
               $ann = $TorrentInfo[0];
               $annlist = array();

               if ($TorrentInfo[6])
               {
                   foreach ($TorrentInfo[6] as $ann)
                   {
                       $annlist[] = $ann[0];
                   }
               }
               else
                   $annlist = array($ann);

               $seeders = $leechers = $downloaded = null;
               foreach ($annlist as $ann)
               {
                   $tracker = explode("/", $ann);
                   $path = array_pop($tracker);
                   $oldpath = $path;
                   $path = str_replace("announce", "scrape", $path);
                   $tracker = implode("/", $tracker)."/".$path;

                   if ($oldpath == $path)
                   {
                       continue;
                   }
               
                   if(preg_match('/udp:\/\//', $tracker))
                   {
                       $udp=true;
                       try
                       {
                           $timeout = 5;
                           $udp= new udptscraper($timeout);
                           $stats=$udp->scrape($tracker,$rowu["info_hash"]);
                           //print_r($stats); exit();
                           foreach ($stats as $idu=>$scrape)
                           {
                               $seeders += $scrape['seeders'];
                               $leechers += $scrape['leechers'];
                               $downloaded    += $scrape['completed'];
                           }
                       }
                       catch(ScraperException $e)
                       {
                           $e->isConnectionError();
                       }
                   }
                   else
                   {
                       $stats = torrent_scrape_url($tracker, $rowu["info_hash"]);
                   }

                   if ($stats['seeds'] != -1)
                   {
                       $seeders += $stats['seeds'];
                       $leechers += $stats['peers'];
                       $downloaded += $stats['downloaded'];

                       SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = '".$seeders."', `leechers` = '".$leechers."', `times_completed` = '".$downloaded."' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $rowu[id]");
                   } else {
                       SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $rowu[id]");
                   }
               }

               if ($seeders !== null)
               {
                   SQL_Query_exec("UPDATE torrents SET leechers = '".$leechers."', seeders = '".$seeders."', times_completed = '".$downloaded."', last_action = '".get_date_time()."', visible = 'yes' WHERE id = '".$rowu['id']."'");
               }
               else
               {
                   SQL_Query_exec("UPDATE torrents SET last_action = '".get_date_time()."' WHERE id='".$rowu['id']."'");
               }
           }
   }
         
   //END SCRAPE
"serph, post: 67060, member: 1398":

yes [USER=20311]@shadows[/USER] its updating from last tracker also if any trackers are down i dont think its setting them as offline either ?

1.  Add += on all 6 places  ($seeders+= $scrape[ 'seeders' ];)
2. Try changing if ($seeders != -1) to if ($seeders != null)
[USER=1398]@serph[/USER] Seems like its working. You already separated via preg_replace http from udp?

Only issue I found is that the final stats is taken from last tracker only.
I'll test it later on today or tomorrow as I was kinda busy
I'm getting -1 -1 -1 ?

Btw, what you did is scraping all trackers. If there are other udp they will be scraped. and stats will be taken from there.  That's why it looks like it works.


PS: Try changing this part to this:
else {
           $stats = torrent_scrape_url('[url='http://tracker.trackerfix.com/announce']http://tracker.trackerfix.com:80/announce[/url] ',  '7B783325F1629F0D157E501AACE0C71DB8D16955');
           }

It will force-check only this tracker and hash. (It has over 1k seeds on http)

use this torrent I attached for testing. It has only http trackers.
"serph, post: 67045, member: 1398":

cant get this working [USER=20311]@shadows[/USER] :unsure: seems to break the page i even replaced the udp and put the http only still same have you got the code intergrated into the udp maybe im messing the code up somewere

I manage everything to get working, BUT the code of httpscraper.php needs tweaking. It's showing for every http tracker that url can't be open.



PS: I will update previous post with code im using.
"serph, post: 67043, member: 1398":

You have a code? I've tried the defualt http scrape I'm not getting any stats back only -1

I created something like this.

backend/httptscraper.php

<?php
   require_once(dirname(__FILE__) . '/tscraper.php');
 
   class httptscraper extends tscraper{
   /**
    * @var int
    */
   protected $maxreadsize;
   /**
    * HttpScraper constructor.
    * @param int $timeout
    * @param int $maxreadsize
    */
   public function __construct($timeout = 2, $maxreadsize = 4096)
   {
       $this->maxreadsize = $maxreadsize;
       parent::__construct($timeout);
   }
   /*     $url: Tracker url like: http://tracker.tld:port/announce or http://tracker.tld:port/scrape
       $infohash: Infohash string or array. 40 char long infohash.
       */
   /**
    * @param string $url
    * @param string $info_hash
    * @return array
    * @throws Exception\ScraperException
    */
   public function scrape($url, $info_hash)
   {
       if (!is_array($info_hash)) {
           $info_hash = array($info_hash);
       }
       foreach ($info_hash as $hash) {
           if (!preg_match('#^[a-f0-9]{40}$#i', $hash)) {
               throw new ScraperException('Invalid infohash: ' . $hash . '.');
           }
       }
       $url = trim($url);
       if (preg_match('%(http://.*?/)announce([^/]*)$%i', $url, $m)) {
           $url = $m[1] . 'scrape' . $m[2];
       } elseif (preg_match('%(http://.*?/)scrape([^/]*)$%i', $url, $m)) {
       } else {
           throw new ScraperException('Invalid tracker url: ' . $url);
       }
       $sep = preg_match('/\?.{1,}?/i', $url) ? '&' : '?';
       $request_url = $url;
       foreach ($info_hash as $hash) {
           $request_url .= $sep . 'info_hash=' . rawurlencode(pack('H*', $hash));
           $sep = '&';
       }
       ini_set('default_socket_timeout', $this->timeout);
       $rh = @fopen($request_url, 'r');
       if (!$rh) {
           throw new ScraperException('Could not open HTTP connection.', 0, true);
       }
       stream_set_timeout($rh, $this->timeout);
       $return = '';
       $pos = 0;
       while (!feof($rh) && $pos < $this->maxreadsize) {
           $return .= fread($rh, 1024);
       }
       fclose($rh);
       if (!substr($return, 0, 1) == 'd') {
           throw new ScraperException('Invalid scrape response.');
       }
       $arr_scrape_data = Lib\LightBenc::bdecode($return);
       $torrents = array();
       foreach ($info_hash as $hash) {
           $ehash = pack('H*', $hash);
           if (isset($arr_scrape_data['files'][$ehash])) {
               $torrents[$hash] = array(
                   'infohash' => $hash,
                   'seeders' => (int)$arr_scrape_data['files'][$ehash]['complete'],
                   'completed' => (int)$arr_scrape_data['files'][$ehash]['downloaded'],
                   'leechers' => (int)$arr_scrape_data['files'][$ehash]['incomplete'],
               );
           } else {
               $torrents[$hash] = false;
           }
       }
       return $torrents;
   }
}


Account-details.php on top add:
require("backend/httptscraper.php");


//===| Scrape External Torrents  
if ($scrape == '1') {
   $tracker = htmlspecialchars($row['announce']);
   $resu = SQL_Query_exec("SELECT id, info_hash, announce FROM torrents WHERE external = 'yes' AND id = $id");
while ($rowu = mysqli_fetch_array($resu)) {
       if (preg_match('/udp:\/\//', $tracker)) {
           $udp = true;
           try {
               $timeout = 5;
               $udp = new udptscraper($timeout);
               $stats = $udp->scrape($tracker, $row["info_hash"]);
               foreach ($stats as $idu => $scrape) {
                   $seeders= $scrape['seeders'];
                   $leechers= $scrape['leechers'];
                   $downloaded= $scrape['completed'];
               }
           }
           catch(ScraperException $e) {
               $e->isConnectionError();
           }
       } elseif (preg_match('/http:\/\//', $tracker)) {
           try {
       $http = true;
       $timeout = 5;
       //Read only 4MiB of the scrape response
       $maxread = 1024 * 4;
       $http = new httptscraper($timeout,$maxread);
       $stats = $http->scrape($tracker, $row["info_hash"]);
       foreach ($stats as $idu => $scrape) {
                   $seeders= $scrape['seeders'];
                   $leechers= $scrape['leechers'];
                   $downloaded= $scrape['completed'];
       }
   }
   catch(ScraperException $e) {
       $e->isConnectionError();
   }
       }
       if ($scrape['seeds'] != -1) {
           $seeders= $scrape['seeders'];
           $leechers= $scrape['leechers'];
           $downloaded= $scrape['completed'];
           SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = '" . $scrape["seeders"] . "', `leechers` = '" . $scrape["leechers"] . "', `times_completed` = '" . $scrape["completed"] . "' WHERE `url` = " . sqlesc($ann) . " AND `torrent` = $id");
       } else {
           SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = " . sqlesc($ann) . " AND `torrent` = $id");
       }
   }
   if ($seeders !== NULL) {
       SQL_Query_exec("UPDATE torrents SET leechers = '" . $leechers . "', seeders = '" . $seeders . "', times_completed = '" . $downloaded . "', last_action = '" . get_date_time() . "', visible = 'yes' WHERE id = '" . $row['id'] . "'");
   } else {
       SQL_Query_exec("UPDATE torrents SET last_action = '" . get_date_time() . "' WHERE id ='" . $row['id'] . "'");
   }      
//===| End UDP Scraper
"serph, post: 67041, member: 1398":

ill be on later today [USER=20311]@shadows[/USER]  see what we have :unsure:

Well we just need to fix importing into db :D you can try via $scrape["seeders"] instead of $stats["seeds"] and so forth
I think I fixed completely announce to be added. Once [USER=1398]@serph[/USER] gets back at weekend and we fix this, I will post all the work i did and merge with udp + http tracker
"serph, post: 67030, member: 1398":

i dont have any http announces to test :(

Download any rarbg torrent. They use http tracker as 1st tracker
Wrong naming. We need to use seeders instead seeds. We use scrape[seeders] to enter values into db
"serph, post: 67022, member: 1398":

i now see what you wanted the backup stats and torrent stats seprate i prefer the original way as it gives total seeds etc but if its good for you
btw you can remove

} else {
           $stats = torrent_scrape_url($tracker, $row["info_hash"]);
       }

not needed

We can just include http scraper there from github :D

<?php
/*
Torrent HTTP Scraper
v1.0
2010 by Johannes Zinnau
johannes@johnimedia.de
Licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
http://creativecommons.org/licenses/by-sa/3.0/
It would be very nice if you send me your changes on this class, so that i can include them if they are improve it.
Thanks!
Usage:
```
try{
$timeout = 2;
//Read only 4MiB of the scrape response
$maxread = 1024 * 4;

$scraper = new httptscraper($timeout,$maxread);
$ret = $scraper->scrape('http://tracker.tld:port/announce',array('0000000000000000000000000000000000000000'));

print_r($ret);
}catch(ScraperException $e){
echo('Error: ' . $e->getMessage() . "<br />\n");
echo('Connection error: ' . ($e->isConnectionError() ? 'yes' : 'no') . "<br />\n");
}
```
*/
namespace Scrapers\Trackers;
/**
* Class HttpScraper
* @package Scrapers\Trackers
*/
class HttpScraper extends TScraper
{
   /**
    * @var int
    */
   protected $maxreadsize;
   /**
    * HttpScraper constructor.
    * @param int $timeout
    * @param int $maxreadsize
    */
   public function __construct($timeout = 2, $maxreadsize = 4096)
   {
       $this->maxreadsize = $maxreadsize;
       parent::__construct($timeout);
   }
   /* $url: Tracker url like: http://tracker.tld:port/announce or http://tracker.tld:port/scrape
       $infohash: Infohash string or array. 40 char long infohash.
       */
   /**
    * @param string $url
    * @param string $info_hash
    * @return array
    * @throws Exception\ScraperException
    */
   public function scrape($url, $info_hash)
   {
       if (!is_array($info_hash)) {
           $info_hash = array($info_hash);
       }
       foreach ($info_hash as $hash) {
           if (!preg_match('#^[a-f0-9]{40}$#i', $hash)) {
               throw new Exception\ScraperException('Invalid infohash: ' . $hash . '.');
           }
       }
       $url = trim($url);
       if (preg_match('%(http://.*?/)announce([^/]*)$%i', $url, $m)) {
           $url = $m[1] . 'scrape' . $m[2];
       } elseif (preg_match('%(http://.*?/)scrape([^/]*)$%i', $url, $m)) {
       } else {
           throw new Exception\ScraperException('Invalid tracker url: ' . $url);
       }
       $sep = preg_match('/\?.{1,}?/i', $url) ? '&' : '?';
       $request_url = $url;
       foreach ($info_hash as $hash) {
           $request_url .= $sep . 'info_hash=' . rawurlencode(pack('H*', $hash));
           $sep = '&';
       }
       ini_set('default_socket_timeout', $this->timeout);
       $rh = @fopen($request_url, 'r');
       if (!$rh) {
           throw new Exception\ScraperException('Could not open HTTP connection.', 0, true);
       }
       stream_set_timeout($rh, $this->timeout);
       $return = '';
       $pos = 0;
       while (!feof($rh) && $pos < $this->maxreadsize) {
           $return .= fread($rh, 1024);
       }
       fclose($rh);
       if (!substr($return, 0, 1) == 'd') {
           throw new Exception\ScraperException('Invalid scrape response.');
       }
       $arr_scrape_data = Lib\LightBenc::bdecode($return);
       $torrents = array();
       foreach ($info_hash as $hash) {
           $ehash = pack('H*', $hash);
           if (isset($arr_scrape_data['files'][$ehash])) {
               $torrents[$hash] = array(
                   'infohash' => $hash,
                   'seeders' => (int)$arr_scrape_data['files'][$ehash]['complete'],
                   'completed' => (int)$arr_scrape_data['files'][$ehash]['downloaded'],
                   'leechers' => (int)$arr_scrape_data['files'][$ehash]['incomplete'],
               );
           } else {
               $torrents[$hash] = false;
           }
       }
       return $torrents;
   }
}
"mostvotedplaya, post: 67024, member: 20335":

You should not be using backend/Parse.php that is only used to decode the .torrent file. To obtain the infohash of a torrent just use the database and if im honest with you the megascrape is pretty slow, you should convert it to a cli app that can make use of multithreading.

This should also do the job php -f /var/www/megascrape.php > /var/www/results.html
Removed some unnecessary parts from your code which weren't needed to improve speed.
Add rest of your html code below the '.....' part.

[color=rgb(250, 197, 28)]Important: [/color]
array_pop($tracker) will only scrape the last announce in additional trackers and show stats for it (It will also update all other additional trackers, but will take stats only from last one). So stats might look very low.


if ($scrape == '1') {
   $seeders = $leechers = $downloaded = NULL;
   $tress = SQL_Query_exec("SELECT * FROM `announce` WHERE `torrent` = $id");
   if (mysqli_num_rows($tress) > 1) {
       $resu = SQL_Query_exec("SELECT url FROM announce WHERE torrent=$id");
   } else {
       $resu = SQL_Query_exec("SELECT id, info_hash, announce FROM torrents WHERE external = 'yes' AND id = $id");
   }
   while ($rowu = mysqli_fetch_array($resu)) {
       if (mysqli_num_rows($tress) > 1) {
           $ann = $rowu["url"];
       } else {
           $ann = $rowu["announce"];
       }
       $annlist = array($ann);
       $seeders = $leechers = $downloaded = NULL;
       foreach ($annlist as $ann) {
           $tracker = explode("/", $ann);
           $path = array_pop($tracker);
           $oldpath = $path;
           $path = preg_replace("/^announce/", "scrape", $path);
           $tracker = implode("/", $tracker) . "/" . $path;
           if ($oldpath == $path) {
               continue;
           }
       }
       if (preg_match('/udp:\/\//', $tracker)) {
           $udp = true;
           try {
               $timeout = 5;
               $udp = new udptscraper($timeout);
               $stats = $udp->scrape($tracker, $row["info_hash"]);
               foreach ($stats as $idu => $scrape) {
                   $seeders1+= $scrape['seeders'];
                   $leechers1+= $scrape['leechers'];
                   $downloaded1+= $scrape['completed'];
               }
           }
           catch(ScraperException $e) {
               $e->isConnectionError();
           }
       } else {
           $stats = torrent_scrape_url($tracker, $row["info_hash"]);
       }
       if ($scrape['seeds'] != - 1) {
           $seeders+= $scrape['seeds'];
           $leechers+= $scrape['peers'];
           $downloaded+= $scrape['downloaded'];
           SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = '" . $scrape["seeders"] . "', `leechers` = '" . $scrape["leechers"] . "', `times_completed` = '" . $scrape["completed"] . "' WHERE `url` = " . sqlesc($ann) . " AND `torrent` = $id");
       } else {
           SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = " . sqlesc($ann) . " AND `torrent` = $id");
       }
   }
   if ($seeders !== NULL) {
       SQL_Query_exec("UPDATE torrents SET leechers = '" . $scrape["leechers"] . "', seeders = '" . $scrape["seeders"] . "', times_completed = '" . $scrape["completed"] . "', last_action = '" . get_date_time() . "', visible = 'yes' WHERE id = '" . $row['id'] . "'");
   } else {
       SQL_Query_exec("UPDATE torrents SET last_action = '" . get_date_time() . "' WHERE id ='" . $row['id'] . "'");
   }
   
           //===| End UDP Scraper

  if ($seeders !== NULL)
           {
               print ("<div style='margin-bottom:5px; margin-left:20px'><b>".T_("LIVE_STATS")."</b>: </div>");
               print ("<div style='margin-left:20px'>".T_("SEEDERS").": <font color='limegreen'>".$scrape["seeders"]."</font></div>");
               print ("<div style='margin-left:20px'>".T_("LEECHERS").": <font color='#FF2000'>".$scrape["leechers"]."</font></div>");
               print ("<div style='margin-left:20px'>".T_("COMPLETED").": <font color='#0080FF'>".$scrape["completed"]."</font></div>");
           }
.......
         
To fix this ststs merging you should replace in update torrents seeders1 to $scrape['seeders'], etc and it will work as supposed. I added manually trackers into announce via sql on localhost for trsting purpose to see how it will react until i fix importing announces
[USER=1398]@serph[/USER] i got it to work , but it counts all announces together and adds total seeds based on announces. 30 announces with 5 seeders = 30 * 5 = 1500+ seeds
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