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
PHP Warning: fsockopen(): ERROR LOGS
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2.08 Support

2022-11-30 16:53:44
php_network_getaddresses: getaddrinfo failed: Name or service not known) in /var/bd/udptscraper.php on line 19

line 19:
$transaction_id = mt_rand(0,65535);
$fp = fsockopen($tracker, $port, $errno, $errstr);
if(!$fp){ throw new ScraperException('Could not open UDP connection: ' . $errno . ' - ' . $errstr,0,true); }
stream_set_timeout($fp, $this->timeout);


<?php

require_once(dirname(__FILE__) . '/tscraper.php');

class udptscraper extends tscraper{

public function scrape($url,$infohash)
{
if(!is_array($infohash)){ $infohash = array($infohash); }
foreach($infohash as $hash){
if(!preg_match('#^[a-f0-9]{40}$#i',$hash)){ throw new ScraperException('Invalid infohash: ' . $hash . '.'); }
}
if(count($infohash) > 74){ throw new ScraperException('Too many infohashes provided.'); }
if(!preg_match('%udp://([^:/]*)(?::([0-9]*))?(?:/)?%si', $url, $m)){ throw new ScraperException('Invalid tracker url.'); }
$tracker = 'udp://' . $m[1];
$port = isset($m[2]) ? $m[2] : 80;

$transaction_id = mt_rand(0,65535);
$fp = fsockopen($tracker, $port, $errno, $errstr);
if(!$fp){ throw new ScraperException('Could not open UDP connection: ' . $errno . ' - ' . $errstr,0,true); }
stream_set_timeout($fp, $this->timeout);

$current_connid = "\x00\x00\x04\x17\x27\x10\x19\x80";

//Connection request
$packet = $current_connid . pack("N", 0) . pack("N", $transaction_id);
fwrite($fp,$packet);

//Connection response
$ret = fread($fp, 16);
if(strlen($ret) < 1){ throw new ScraperException('No connection response.',0,true); }
if(strlen($ret) < 16){ throw new ScraperException('Too short connection response.'); }
$retd = unpack("Naction/Ntransid",$ret);
if($retd['action'] != 0 || $retd['transid'] != $transaction_id){
throw new ScraperException('Invalid connection response.');
}
$current_connid = substr($ret,8,8);

//Scrape request
$hashes = '';
foreach($infohash as $hash){ $hashes .= pack('H*', $hash); }
$packet = $current_connid . pack("N", 2) . pack("N", $transaction_id) . $hashes;
fwrite($fp,$packet);

//Scrape response
$readlength = 8 + (12 * count($infohash));
$ret = fread($fp, $readlength);
if(strlen($ret) < 1){ throw new ScraperException('No scrape response.',0,true); }
if(strlen($ret) < 8){ throw new ScraperException('Too short scrape response.'); }
$retd = unpack("Naction/Ntransid",$ret);
// Todo check for error string if response = 3
if($retd['action'] != 2 || $retd['transid'] != $transaction_id){
throw new ScraperException('Invalid scrape response.');
}
if(strlen($ret) < $readlength){ throw new ScraperException('Too short scrape response.'); }
$torrents = array();
$index = 8;
foreach($infohash as $hash){
$retd = unpack("Nseeders/Ncompleted/Nleechers",substr($ret,$index,12));
$retd['infohash'] = $hash;
$torrents[$hash] = $retd;
$index = $index + 12;
}

return($torrents);
}
}
?>

____________________________________________________________________________
ERROR 2
PHP Warning:  Illegal string offset 'files' in /var/bd/functions.php on line 502 / 503 / 504
}else{
$stats = BDecode($fp);
$binhash = pack("H*", $hash);
$seeds = $stats['files'][$binhash]['complete'];
$peers = $stats['files'][$binhash]['incomplete'];
$downloaded = $stats['files'][$binhash]['downloaded'];
$ret['seeds'] = $seeds;
$ret['peers'] = $peers;
$ret['downloaded'] = $downloaded;
}
return $ret;
}


Any idea how to fix this bug?
Last edited by Extremlym66 on 2022-11-30 16:54:11
2022-11-30 18:35:19
$stats[] should be the decoded array. Calling $stats[‘files’] should be valid, however it is an array too. So the return should be an array that is enumerable.

The code looks correct.

I think the class is too old. Was this scraper included with your install?
2022-11-30 20:05:21
NO was not included
2022-12-01 00:41:31
The error is telling you the tracker url may be incorrect or simply offline. Have you verified this?
2022-12-01 12:41:21
theats correct but how do i disable it .. for not recording error log! is making GB of txt file with it
2022-12-01 18:45:05
Error and access logs grow every day, if you mean server logs.

That would be at server-level. As for the script, I really dont know - I didn’t use any of its logging at any time as it was vague.
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