mainURL = "btjunkie.org"; $this->altURL = "www.btjunkie.org"; $this->mainTitle = "btjunkie"; $this->engineName = "btJunkie"; $this->author = "kboy"; $this->version = "1.01-tfb"; $this->updateURL = "http://www.torrentflux.com/forum/index.php/topic,874.0.html"; $this->Initialize($cfg); } function populateMainCategories() { $this->mainCatalog["1"] = "Audio"; $this->mainCatalog["7"] = "Anime"; $this->mainCatalog["2"] = "Games"; $this->mainCatalog["3"] = "Software"; $this->mainCatalog["4"] = "TV"; $this->mainCatalog["5"] = "Unsorted"; $this->mainCatalog["6"] = "Video"; $this->mainCatalog["8"] = "XXX"; } //---------------------------------------------------------------- // Function to Make the Request (overriding base) function makeRequest($request) { return parent::makeRequest($request, false); } //---------------------------------------------------------------- // Function to get Latest.. function getLatest() { $cat = tfb_getRequestVar('mainGenre'); if (empty($cat)) $cat = tfb_getRequestVar('c'); if(!empty($cat)) { $request = "/browse"; if(strpos($request,"?")) { $request .= "&c=".$cat; } else { $request .= "?c=".$cat; } } else { $request = "/?do=latest"; } if (!empty($this->pg)) { if(strpos($request,"?")) { $request .= "&p=" . $this->pg; } else { $request .= "?p=" . $this->pg; } } $request .= "&o=72"; // Sort Newest to Oldest //$request .= "&o=52"; // Sort Most Seeded if ($this->makeRequest($request)) { return $this->parseResponse(); } else { return $this->msg; } } //---------------------------------------------------------------- // Function to perform Search. function performSearch($searchTerm) { $searchTerm = str_replace(" ", "+", $searchTerm); $request = "/search?q=".$searchTerm; if(!empty($cat)) { $request .= "&c=".$cat; } if (!empty($this->pg)) { $request .= "&p=" . $this->pg; } //$request .= "&o=72"; // Sort Newest to Oldest $request .= "&o=52"; // Sort Most Seeded $request .= "&m=0"; // Search Exact //$request .= "&m=1"; // Search Contains if ($this->makeRequest($request)) { return $this->parseResponse(); } else { return $this->msg; } } //---------------------------------------------------------------- // Function to parse the response. function parseResponse() { $output = $this->tableHeader(); $thing = $this->htmlPage; // Chop the front end off. while (is_integer(strpos($thing,">Torrent Name<"))) { $thing = substr($thing,strpos($thing,">Health<")); $thing = substr($thing,strpos($thing,"",$tmpList); $langFile = $this->cfg["_FILE"]; $bg = $this->cfg["bgLight"]; foreach($tmpListArr as $key =>$value) { $buildLine = true; if (strpos($value,"/torrent?do")) { $ts = new btJunk($value); // Determine if we should build this output if (is_int(array_search($ts->MainId,$this->catFilter))) { $buildLine = false; } if ($this->hideSeedless == "yes") { if($ts->Seeds == "N/A" || $ts->Seeds == "0") { $buildLine = false; } } if (!empty($ts->torrentFile) && $buildLine) { $output .= trim($ts->BuildOutput($bg,$langFile,$this->searchURL())); // ok switch colors. if ($bg == $this->cfg["bgLight"]) { $bg = $this->cfg["bgDark"]; } else { $bg = $this->cfg["bgLight"]; } } } } // set thing to end of this table. $thing = substr($thing,strpos($thing,"do=gear")); } $output .= ""; // is there paging at the bottom? if (strpos($thing, "

Pages (") !== false) { // Yes, then lets grab it and display it! ;) $thing = substr($thing,strpos($thing,"

Pages (")+strlen("

")); $pages = substr($thing,0,strpos($thing,"

")); $page1 = substr($pages,0,strpos($pages,"')+1); $pages = $page1.$page2; $output .= "
".$pages."

"; } return $output; } } // This is a worker class that takes in a row in a table and parses it. class btJunk { var $torrentName = ""; var $torrentDisplayName = ""; var $torrentFile = ""; var $MainId = ""; var $MainCategory = ""; var $torrentSize = ""; var $Seeds = ""; var $Peers = ""; var $Data = ""; function btJunk( $htmlLine ) { if (strlen($htmlLine) > 0) { $this->Data = $htmlLine; // Chunck up the row into columns. $tmpListArr = explode("",$htmlLine); /* ( [0] => Download Torrent File Listing  Paris Hilton - Paris (withcovers) a DHZ Inc Release ) */ if(count($tmpListArr) > 5) { //$tmpListArr["0"]; // Torrent Name, Download Link, Status $this->torrentDisplayName = $this->cleanLine($tmpListArr["0"]); // TorrentName $tmpStr = substr($tmpListArr["0"],strpos($tmpListArr["0"],"torrent?"),strpos($tmpListArr["0"],">torrentFile = "http://btjunkie.org/" . substr($tmpStr,0,strpos($tmpStr,"\"")); if (strpos($this->torrentFile,"do=stat")) { $this->torrentFile = str_replace("do=stat","do=download",$this->torrentFile); } $this->torrentName = $this->torrentDisplayName; $this->MainCategory = $this->cleanLine($tmpListArr["1"]); $this->MainId = substr($tmpStr,0,strpos($tmpStr,"\"")); $this->torrentSize = $this->cleanLine($tmpListArr["2"]); // Size of File $this->Seeds = $this->cleanLine($tmpListArr["4"]); // Seeds $this->Peers = $this->cleanLine($tmpListArr["5"]); // Peers if ($this->Seeds == '') $this->Seeds = "N/A"; if ($this->Seeds == 'X') $this->Seeds = "N/A"; if ($this->Peers == '') $this->Peers = "N/A"; if ($this->Peers == 'X') $this->Peers = "N/A"; if(strlen($this->torrentDisplayName) > 50) { $this->torrentDisplayName = substr($this->torrentDisplayName,0,50)."..."; } } } } function cleanLine($stringIn,$tags='') { if(empty($tags)) return trim(str_replace(array(" "," ")," ",strip_tags($stringIn))); else return trim(str_replace(array(" "," ")," ",strip_tags($stringIn,$tags))); } //---------------------------------------------------------------- // Function to build output for the table. function BuildOutput($bg,$langFILE, $searchURL = '') { $output = "\n"; $output .= " torrentFile."\">torrentName."\" border=0>\n"; $output .= " torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName."\n"; $output .= "\n"; if (strlen($this->MainCategory) > 1){ $genre = "MainId."\">".$this->MainCategory.""; } $output .= " ". $genre ."\n"; $output .= " ".$this->torrentSize."\n"; $output .= " ".$this->Seeds."\n"; $output .= " ".$this->Peers."\n"; $output .= "\n"; return $output; } } ?>