mainURL = "google.com"; $this->altURL = "www.google.com"; $this->mainTitle = "Google"; $this->engineName = "Google"; $this->author = "kboy"; $this->version = "1.00-tfb"; $this->updateURL = "http://www.torrentflux.com/forum/index.php/topic,1690.0.html"; $this->Initialize($cfg); } //---------------------------------------------------------------- // Function to get Latest.. function getLatest() { $this->msg = "Get Latest Not available on this Engine"; return $this->msg; } //---------------------------------------------------------------- // Function to perform Search. function performSearch($searchTerm) { //http://www.google.com/search?as_q=test+d8&num=3&as_qdr=m3&as_filetype=torrent // as_q -> advanced search query term (NOTE: we must add +d8 to scrub down to just true torrent files) // num -> is the number of results per page. // lr -> language (lang_en) for english // as_qdr -> advanced search query days returned. (m3) is updated in the past 1 months // m3 ... and y (year) are valid values. // as_filetype -> to search for torrents :-) $searchTerm = str_replace(" ", "+", $searchTerm); $request = '/search?as_q=' . $searchTerm . '+d8&num=100&lr=lang_en&as_qdr=m3&as_filetype=torrent'; if ($this->makeRequest($request)) { return $this->parseResponse(); } else { return $this->msg; } } //---------------------------------------------------------------- // Function to parse the response. function parseResponse() { $output = $this->tableHeader(); $output .= "\n \n"; $thing = $this->htmlPage; // We got a response so display it. // Chop the front end off. while (is_integer(strpos($thing,"Results"))) { $thing = substr($thing,strpos($thing,"Results")); $thing = substr($thing,strpos($thing,"")+strlen("")); if (is_integer(strpos($thing,"Sponsored Links"))) { $thing = substr($thing,strpos($thing,"Sponsored Links")); $thing = substr($thing,strpos($thing,"")+strlen("")); } //$thing = substr($thing,strpos($thing,"
")-strlen("
"); $tmpList = substr($thing,0,strpos($thing,"
")); if (is_integer(strpos($tmpList,"In order to show you the most relevant results"))) { $tmpList = substr($thing,0,strpos($thing,"In order to show you the most relevant results")) . "
"; } // ok so now we have the listing. //$tmpListArr = explode("

",$tmpList); $allowedTags = '
'; // ok so now we have the listing. $tmpListArr = explode("
",strip_tags($tmpList,$allowedTags)); $langFile = $this->cfg['_FILE']; $bg = $this->cfg["bgLight"]; foreach($tmpListArr as $key =>$value) { if (strpos($value,"Similar pages")) { } elseif (strpos($value, "ile Format:")) { } elseif (strpos($value, "Cached")) { } elseif (strpos($value, "More results from")) { } elseif (strpos($value, "Translate this page")) { } else { $goo = new gOOGLE($value); if (!empty($goo->torrentFile)) { $output .= trim($goo->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,"")); } $output .= ""; $output .= "\n \n"; return $output; } } // This is a worker class that takes in a row in a table and parses it. class gOOGLE { var $torrentName = ""; var $torrentDisplayName = ""; var $torrentFile = ""; var $torrentStatus = ""; var $torrentSize = ""; var $fileCount = ""; var $Seeds = ""; var $Peers = ""; var $Data = ""; function gOOGLE( $htmlLine ) { $tmpVal = substr($htmlLine,strpos($htmlLine," 0) { $this->Data = $htmlLine; $tmpVal2 = substr($tmpVal,strpos($tmpVal,"href=\"")+strlen("href=\"")); $this->torrentFile = substr($tmpVal2,0,strpos($tmpVal2,"\"")); $html = FetchHTMLNoWaitNoFollow( $this->torrentFile ); // Make sure we have a torrent file if( strpos( $html, "d8:" ) === false ) { // We don't have a Torrent File... it is something else $this->torrentFile = ""; } else { $array = BDecode($html); $this->torrentSize = formatBytesTokBMBGBTB($array["info"]["piece length"] * (strlen($array["info"]["pieces"]) / 20)); $this->torrentName = $array['info']['name']; $this->fileCount = count($array['info']['files']); $this->torrentDisplayName = $array['info']['name']; if(array_key_exists('comment',$array)) { $this->torrentDisplayName .= " [". $array['comment']."]"; } } /* $this->Seeds = $this->cleanLine($tmpListArr["4"]); // Seeds $this->Peers = $this->cleanLine($tmpListArr["5"]); // Peers */ if ($this->Peers == '') { $this->Peers = "N/A"; if (empty($this->Seeds)) $this->Seeds = "N/A"; } if ($this->Seeds == '') $this->Seeds = "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"; $output .= "  \n"; $output .= " ".$this->torrentSize."\n"; $output .= " ".$this->Seeds."\n"; $output .= " ".$this->Peers."\n"; $output .= "\n"; return $output; } } ?>