Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- $BaseUrl = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
- $QueryString = $_SERVER["QUERY_STRING"];
- if (strpos($QueryString, 'torrents.thepiratebay.org') !== false)
- {
- preg_match('/http.*\/.*\/.*\/(.*?).torrent$$/', $QueryString, $matches);
- $name = $matches[1] . '.torrent';
- $torrent = get_data($QueryString);
- header("Cache-Control: public");
- header("Content-Description: File Transfer");
- header("Content-Disposition: attachment; filename=".$name );
- header("Content-Type: application/x-bittorrent");
- header("Content-Transfer-Encoding: binary");
- echo $torrent;
- exit;
- }
- if (strpos($QueryString, 'q=') !== false)
- $QueryString = "/s/?" . $QueryString;
- $Url = get_furl("http://thepiratebay.org" . $QueryString);
- if (strpos($Url, 'thepiratebay.org') === false)
- {
- header("location: " . $BaseUrl . '?' . $Url);
- exit;
- }
- $Url = "http://thepiratebay.org" . $QueryString;
- $Content = get_data($Url);
- $Content = preg_replace('/a href="(?!magnet)(.*?)"/is', 'a href="' . $BaseUrl . '?\1"', $Content);
- $Content = preg_replace('/<iframe.*?>/is', '', $Content);
- $Content = preg_replace('/div:content -->.*?<\/html>/is', '<\/html>', $Content);
- $Content = preg_replace('/action="\/s\/"/si', 'action="'.$BaseUrl.'?/s/"', $Content);
- $Content = preg_replace('/<script type="text\/javascript">.*?<\/script>/si', '', $Content);
- echo $Content;
- function get_data($url)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- function get_furl($url)
- {
- $furl = false;
- // First check response headers
- $headers = get_headers($url);
- // Test for 301 or 302
- if(preg_match('/^HTTP\/\d\.\d\s+(301|302)/',$headers[0]))
- {
- foreach($headers as $value)
- {
- if(substr(strtolower($value), 0, 9) == "location:")
- {
- $furl = trim(substr($value, 9, strlen($value)));
- }
- }
- }
- // Set final URL
- $furl = ($furl) ? $furl : $url;
- return $furl;
- }
- ?>
- <?php
- error_reporting(E_ALL);
- $BaseUrl = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
- $QueryString = $_SERVER["QUERY_STRING"];
- if (strpos($QueryString, 'torrents.thepiratebay.org') !== false)
- {
- preg_match('/http.*\/.*\/.*\/(.*?).torrent$$/', $QueryString, $matches);
- $name = $matches[1] . '.torrent';
- $torrent = get_data($QueryString);
- header("Cache-Control: public");
- header("Content-Description: File Transfer");
- header("Content-Disposition: attachment; filename=".$name );
- header("Content-Type: application/x-bittorrent");
- header("Content-Transfer-Encoding: binary");
- echo $torrent;
- exit;
- }
- if (strpos($QueryString, 'q=') !== false)
- $QueryString = "/s/?" . $QueryString;
- $Url = get_furl("http://thepiratebay.org" . $QueryString);
- if (strpos($Url, 'thepiratebay.org') === false)
- {
- header("location: " . $BaseUrl . '?' . $Url);
- exit;
- }
- $Url = "http://thepiratebay.org" . $QueryString;
- $Content = get_data($Url);
- $Content = preg_replace('/a href="(?!magnet)(.*?)"/is', 'a href="' . $BaseUrl . '?\1"', $Content);
- $Content = preg_replace('/<iframe.*?>/is', '', $Content);
- $Content = preg_replace('/div:content -->.*?<\/html>/is', '<\/html>', $Content);
- $Content = preg_replace('/action="\/s\/"/si', 'action="'.$BaseUrl.'?/s/"', $Content);
- $Content = preg_replace('/<script type="text\/javascript">.*?<\/script>/si', '', $Content);
- echo $Content;
- function get_data($url)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- function get_furl($url)
- {
- $furl = false;
- // First check response headers
- $headers = get_headers($url);
- // Test for 301 or 302
- if(preg_match('/^HTTP\/\d\.\d\s+(301|302)/',$headers[0]))
- {
- foreach($headers as $value)
- {
- if(substr(strtolower($value), 0, 9) == "location:")
- {
- $furl = trim(substr($value, 9, strlen($value)));
- }
- }
- }
- // Set final URL
- $furl = ($furl) ? $furl : $url;
- return $furl;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement