forked from hnhx/librex
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(*): everything (merge pull request #18 from davidovski/the_r…
…efactor) Major Refactor
- Loading branch information
Showing
34 changed files
with
1,175 additions
and
1,372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,40 @@ | ||
<?php | ||
function get_hidden_service_results($query) | ||
{ | ||
global $config; | ||
require "engines/text/text.php"; | ||
|
||
$url = "https://ahmia.fi/search/?q=$query"; | ||
$response = request($url); | ||
$xpath = get_xpath($response); | ||
|
||
$results = array(); | ||
|
||
foreach($xpath->query("//ol[@class='searchResults']//li[@class='result']") as $result) | ||
{ | ||
$url = "http://" . $xpath->evaluate(".//cite", $result)[0]->textContent; | ||
$title = remove_special($xpath->evaluate(".//h4", $result)[0]->textContent); | ||
$description = $xpath->evaluate(".//p", $result)[0]->textContent; | ||
|
||
array_push($results, | ||
array ( | ||
"title" => $title ? htmlspecialchars($title) : "No description provided", | ||
"url" => htmlspecialchars($url), | ||
"base_url" => htmlspecialchars(get_base_url($url)), | ||
"description" => htmlspecialchars($description) | ||
) | ||
); | ||
class TorSearch extends EngineRequest { | ||
public function get_request_url() { | ||
return "https://ahmia.fi/search/?q=" . urlencode($this->query); | ||
} | ||
|
||
return $results; | ||
} | ||
|
||
function print_hidden_service_results($results) | ||
{ | ||
echo "<div class=\"text-result-container\">"; | ||
|
||
foreach($results as $result) | ||
{ | ||
$title = $result["title"]; | ||
$url = $result["url"]; | ||
$base_url = $result["base_url"]; | ||
$description = $result["description"]; | ||
|
||
echo "<div class=\"text-result-wrapper\">"; | ||
echo "<a href=\"$url\">"; | ||
echo "$base_url"; | ||
echo "<h2>$title</h2>"; | ||
echo "</a>"; | ||
echo "<span>$description</span>"; | ||
echo "</div>"; | ||
public function get_results() { | ||
$response = curl_multi_getcontent($this->ch); | ||
$results = array(); | ||
$xpath = get_xpath($response); | ||
|
||
if (!$xpath) | ||
return $results; | ||
|
||
foreach($xpath->query("//ol[@class='searchResults']//li[@class='result']") as $result) | ||
{ | ||
$url = "http://" . $xpath->evaluate(".//cite", $result)[0]->textContent; | ||
$title = remove_special($xpath->evaluate(".//h4", $result)[0]->textContent); | ||
$description = $xpath->evaluate(".//p", $result)[0]->textContent; | ||
|
||
array_push($results, | ||
array ( | ||
"title" => $title ? htmlspecialchars($title) : "No description provided", | ||
"url" => htmlspecialchars($url), | ||
"base_url" => htmlspecialchars(get_base_url($url)), | ||
"description" => htmlspecialchars($description) | ||
) | ||
); | ||
} | ||
|
||
return $results; | ||
} | ||
|
||
echo "</div>"; | ||
public static function print_results($results) { | ||
TextSearch::print_results($results); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
<?php | ||
$_1337x_url = "https://1337x.to/search/$query/1/"; | ||
class _1337xRequest extends EngineRequest { | ||
public function get_request_url() { | ||
$query = urlencode($this->query); | ||
return "https://1337x.to/search/$query/1/"; | ||
} | ||
|
||
function get_1337x_results($response) | ||
{ | ||
global $config; | ||
$xpath = get_xpath($response); | ||
$results = array(); | ||
public function get_results() { | ||
$response = curl_multi_getcontent($this->ch); | ||
|
||
foreach($xpath->query("//table/tbody/tr") as $result) | ||
{ | ||
$xpath = get_xpath($response); | ||
$results = array(); | ||
|
||
$name = $xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent; | ||
$magnet = "./engines/bittorrent/get_magnet_1337x.php?url=https://1337x.to" . $xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent; | ||
$size_unformatted = explode(" ", $xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent); | ||
$size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]); | ||
$seeders = $xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent; | ||
$leechers = $xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent; | ||
if (!$xpath) | ||
return $results; | ||
|
||
array_push($results, | ||
array ( | ||
"name" => htmlspecialchars($name), | ||
"seeders" => (int) $seeders, | ||
"leechers" => (int) $leechers, | ||
"magnet" => htmlspecialchars($magnet), | ||
"size" => htmlspecialchars($size), | ||
"source" => "1337x.to" | ||
) | ||
); | ||
} | ||
foreach($xpath->query("//table/tbody/tr") as $result) { | ||
$name = $xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent; | ||
$magnet = "./engines/bittorrent/get_magnet_1337x.php?url=https://1337x.to" . $xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent; | ||
$size_unformatted = explode(" ", $xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent); | ||
$size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]); | ||
$seeders = $xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent; | ||
$leechers = $xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent; | ||
|
||
return $results; | ||
array_push($results, | ||
array ( | ||
"name" => htmlspecialchars($name), | ||
"seeders" => (int) $seeders, | ||
"leechers" => (int) $leechers, | ||
"magnet" => htmlspecialchars($magnet), | ||
"size" => htmlspecialchars($size), | ||
"source" => "1337x.to" | ||
) | ||
); | ||
} | ||
|
||
return $results; | ||
} | ||
} | ||
?> |
Oops, something went wrong.