public function fetch($url, $encode = 1, $method = "GET", $content_type = "", $body = "") { $client = $this->makeClient($url); if ($encode) { $url = Snoopy::linkencode($url); } $client->fetchComplex($url, $method, $content_type, $body); if ($client->status >= 200 && $client->status < 300) { ini_set("pcre.backtrack_limit", max(strlen($client->results), 100000)); return $client; } return false; }
public function action($what, $cat, &$ret, $limit, $useGlobalCats) { $added = 0; $url = 'http://scenehd.org'; if ($useGlobalCats) { $categories = array('all' => '', 'movies' => '&cat=1,4,8,22', 'tv' => '&cat=5,7'); } else { $categories =& $this->categories; } if (!array_key_exists($cat, $categories)) { $cat = $categories['all']; } else { $cat = $categories[$cat]; } for ($pg = 0; $pg < 11; $pg++) { $cli = $this->fetch(Snoopy::linkencode($url . '/browse.php?search=' . $what . '&sort=9&page=' . $pg) . '&cat=' . $cat, false); if ($cli == false || strpos($cli->results, "<h2>No torrents found!</h2>") !== false || strpos($cli->results, "<td>Password</td>") !== false) { break; } $res = preg_match_all('/<img border="0" src="\\/pic\\/cats\\/.*" title="(?P<cat>.*)"><\\/a><\\/td>.*' . '<a href="details\\.php\\?id=(?P<id>\\d+)" title="(?P<name>.*)">.*' . '<td.*>.*<\\/td>.*' . '<td.*>.*<\\/td>.*' . '<td.*>.*<\\/td>.*' . '<td.*>.*<\\/td>.*' . '<td.*>(?P<size>.*)<\\/td>.*' . '<td.*>(?P<date>.*)<\\/td>.*' . '<td.*>(?P<seeds>.*)<\\/td>.*' . '<td.*>(?P<leech>.*)<\\/td>.*' . '<td.*>.*<\\/td>.*<\\/tr>/siU', $cli->results, $matches); if ($res !== false && $res > 0 && count($matches["cat"]) == count($matches["id"]) && count($matches["id"]) == count($matches["name"]) && count($matches["name"]) == count($matches["size"]) && count($matches["size"]) == count($matches["seeds"]) && count($matches["size"]) == count($matches["date"]) && count($matches["seeds"]) == count($matches["leech"])) { for ($i = 0; $i < count($matches["id"]); $i++) { $link = $url . "/download.php?id=" . $matches["id"][$i]; if (!array_key_exists($link, $ret)) { $item = $this->getNewEntry(); $item["cat"] = $matches["cat"][$i]; $item["desc"] = $url . "/details.php?id=" . $matches["id"][$i]; $item["name"] = self::removeTags($matches["name"][$i]); $item["size"] = self::formatSize($matches["size"][$i]); $item["time"] = strtotime(self::removeTags(str_replace("<br>", " ", $matches["date"][$i]))); $item["seeds"] = intval(self::removeTags($matches["seeds"][$i])); $item["peers"] = intval(self::removeTags($matches["leech"][$i])); $ret[$link] = $item; $added++; if ($added >= $limit) { return; } } } } else { break; } } }
public function action($what, $cat, &$ret, $limit, $useGlobalCats) { $added = 0; $url = 'https://www.torrentleech.org'; if ($useGlobalCats) { $categories = array('all' => '', 'movies' => '/categories/1,8,9,10,11,12,13,14,15,29', 'tv' => '/categories/2,26,27', 'music' => '/categories/4,16,31', 'games' => '/categories/3,17,18,19,20,21,22,28,30', 'anime' => '/categories/7', 'software' => '/categories/6,23,24,25', 'books' => '/categories/5'); } else { $categories =& $this->categories; } if (!array_key_exists($cat, $categories)) { $cat = $categories['all']; } else { $cat = $categories[$cat]; } for ($pg = 1; $pg < 11; $pg++) { $cli = $this->fetch(Snoopy::linkencode($url . '/torrents/browse/index/query/' . $what . '/orderby/seeders/order/desc/page/' . $pg) . $cat, false); if ($cli == false || strpos($cli->results, "There are no results found, based on your search parameters") !== false || strpos($cli->results, ">Password") !== false) { break; } $res = preg_match_all('`<td class="category"><a href="/torrents/browse/index/categories/(?P<cat>\\d*)">.*' . '<td class="name"><span class="title"><a href="/torrent/(?P<id>\\d*)">(?P<name>.*)</a></span>.*Added in <b>.*</b>\\son\\s+(?P<date>\\S+ \\S+ ).*</td>.*' . '<td class="quickdownload">.*</td>.*' . '<td>.*</td>.*' . '<td>(?P<size>[^<]*)</td>.*' . '<td class="seeders">(?P<seeds>.*)</td>.*' . '<td class="leechers">(?P<leech>.*)</td>' . '`siU', $cli->results, $matches); if ($res) { for ($i = 0; $i < $res; $i++) { $link = $url . "/download/" . $matches["id"][$i] . '/dummy'; if (!array_key_exists($link, $ret)) { $item = $this->getNewEntry(); $item["cat"] = self::getInnerCategory($matches["cat"][$i]); $item["desc"] = $url . "/torrent/" . $matches["id"][$i]; $item["name"] = self::removeTags($matches["name"][$i]); $item["size"] = self::formatSize($matches["size"][$i]); $item["time"] = strtotime(self::removeTags($matches["date"][$i])); $item["seeds"] = intval(self::removeTags($matches["seeds"][$i])); $item["peers"] = intval(self::removeTags($matches["leech"][$i])); $ret[$link] = $item; $added++; if ($added >= $limit) { return; } } } } else { break; } } }
public function getTorrent($href) { if (strpos($href, "magnet:") === 0) { return "magnet"; } global $profileMask; $cli = self::fetchURL(Snoopy::linkencode($href), $this->cookies); if ($cli && $cli->status >= 200 && $cli->status < 300) { $name = $cli->get_filename(); if ($name === false) { $name = md5($href) . ".torrent"; } $name = getUniqueUploadedFilename($name); $f = @fopen($name, "w"); if ($f !== false) { @fwrite($f, $cli->results, strlen($cli->results)); fclose($f); @chmod($name, $profileMask & 0666); return $name; } } return false; }
$tracker = rawurldecode($_REQUEST["tracker"]); $name = dirname(__FILE__) . "/trackers/" . $tracker . ".png"; if (is_readable($name)) { sendFile($name, "image/png"); exit; } $name = getSettingsPath() . '/trackers'; if (!is_dir($name)) { makeDirectory($name); } $name .= '/'; if (strlen($tracker)) { $name .= $tracker; $name .= '.ico'; if (!is_readable($name)) { $url = Snoopy::linkencode("http://" . $tracker . "/favicon.ico"); $client = new Snoopy(); @$client->fetchComplex($url); if ($client->status == 200) { file_put_contents($name, $client->results); } } if (is_readable($name)) { sendFile($name, "image/x-icon"); exit; } } } header("HTTP/1.0 302 Moved Temporarily"); header("Location: " . dirname($_SERVER['PHP_SELF']) . '/trackers/unknown.png'); exit;
public function action($what, $cat, &$ret, $limit, $useGlobalCats) { $added = 0; $url = 'http://thepiratebay.org'; if ($useGlobalCats) { $categories = array('all' => '100,200,300,400,500,600', 'movies' => '200', 'tv' => '205', 'music' => '100', 'games' => '400', 'anime' => '0', 'software' => '300', 'pictures' => '603', 'books' => '601'); } else { $categories =& $this->categories; } if (!array_key_exists($cat, $categories)) { $cat = $categories['all']; } else { $cat = $categories[$cat]; } $maxPage = 10; for ($pg = 0; $pg < $maxPage; $pg++) { $cli = $this->fetch(Snoopy::linkencode($url . '/search/' . $what . '/' . $pg) . '/7/' . $cat, false); if ($cli == false || !preg_match('/<\\/span> Displaying hits from \\d+ to \\d+ \\(approx (?P<cnt>\\d+) found\\)/siU', $cli->results, $matches)) { break; } $maxPage = ceil(intval($matches["cnt"]) / 30); $res = preg_match_all('/<td class="vertTh"><a href="\\/browse.*>(?P<cat>.*)<\\/a><\\/td>.*' . '<td><a href="\\/torrent\\/(?P<desc>.*)".*>(?P<name>.*)<\\/a>.*<\\/td>.*' . '<td>(?P<date>.*)<\\/td>.*' . '<td><nobr><a href="magnet:(?P<link>[^"]*)".*' . '<td align="right">(?P<size>.*)<\\/td>.*' . '<td align="right">(?P<seeds>.*)<\\/td>.*' . '<td align="right">(?P<leech>.*)<\\/td>' . '/siU', $cli->results, $matches); if ($res !== false && $res > 0 && count($matches["desc"]) == count($matches["name"]) && count($matches["cat"]) == count($matches["name"]) && count($matches["name"]) == count($matches["date"]) && count($matches["date"]) == count($matches["link"]) && count($matches["size"]) == count($matches["link"]) && count($matches["size"]) == count($matches["seeds"]) && count($matches["seeds"]) == count($matches["leech"])) { for ($i = 0; $i < count($matches["link"]); $i++) { $link = "magnet:" . $matches["link"][$i]; if (!array_key_exists($link, $ret)) { $item = $this->getNewEntry(); $item["cat"] = self::removeTags($matches["cat"][$i]); $item["desc"] = $url . "/torrent/" . $matches["desc"][$i]; $item["name"] = self::removeTags($matches["name"][$i]); $item["size"] = self::formatSize($matches["size"][$i]); $item["seeds"] = intval(self::removeTags($matches["seeds"][$i])); $item["peers"] = intval(self::removeTags($matches["leech"][$i])); $tms = self::removeTags($matches["date"][$i]); if (strpos($tms, ":") !== false) { $tm = strptime($tms, "%m-%d %H:%M"); if ($tm === false) { $tms = str_replace("Y-day", "-1 day", $tms); $tm = strtotime($tms); if ($tm !== false) { $tm = localtime($tm, true); } } else { $tm["tm_year"] = date("Y") - 1900; } } else { if (preg_match('/^(\\d+) mins? ago$/i', $tms, $match)) { $tms = "-" . $match[1] . " minute"; $tm = strtotime($tms); if ($tm !== false) { $tm = localtime($tm, true); } } else { $tm = strptime($tms, "%m-%d %Y"); } } if ($tm !== false) { $item["time"] = mktime($tm["tm_hour"], $tm["tm_min"], $tm["tm_sec"], $tm["tm_mon"] + 1, $tm["tm_mday"], $tm["tm_year"] + 1900); } $ret[$link] = $item; $added++; if ($added >= $limit) { return; } } } } else { break; } } }