I have this code I have written to make my life easier when downloading .torrents, the code is as follows,
$file = 'http://kat.ph/new/';
if($file = file_get_contents($file)) {
// RETURN ALL MAGNET URIS FROM FILE
preg_match_all('/\"magnet\:\?xt\=urn\:btih\:(.*?)\"/x', $file, $magnetURI);
// FOR EACH MAGNET URI RETURNED
foreach($magnetURI[1] as $info) {
echo '<a href="magnet:?xt=urn:btih:' . $info . '">' . $info . '</a><br /><br /><br /><br />';
}
} else {
echo '<strong>FAIL</strong>';
}
It is supposed to match magnet uri links and return them to me in easy to click links, it works on other websites try replacing the file with http://thepiratebay.se/recent/0, but for some reason the website in the example it will not work on?!?
Thanks for your help!
It works for me, try removing the
xmodifier.The problem is the
file_get_contents()call, apparently kat.ph doesn’t like anonymous user agents, if you try to output the$filevariable you get a bunch of garbage like:Try setting the user agent to a known browser (via
file_get_contents()HTTP context or CURL).