reorganized the whole code base , added disable torrent search to config

This commit is contained in:
hnhx 2022-02-25 10:42:32 +01:00
parent 65caead67a
commit 0abdf068d1
26 changed files with 286 additions and 294 deletions

View file

@ -38,7 +38,7 @@ All you need is a webserver (e.g.: nginx) and PHP, and you are good to go.
# API # API
Example API request: `.../api.php?q=gentoo&p=2&type=0` <br/> Example API request: `.../api.php?q=gentoo&p=2&type=0` <br/>
Where `q` is the keyword, `p` is the result page (the first page is `0`) and `type` is the search type (`0`=text, `1`=image, `2`=video) Where `q` is the keyword, `p` is the result page (the first page is `0`) and `type` is the search type (`0`=text, `1`=image, `2`=video, `3`=torrent)
<br/><br/> <br/><br/>
JSON result: JSON result:
+ In case of text search: + In case of text search:
@ -52,6 +52,12 @@ JSON result:
+ `title`: Title of the result video + `title`: Title of the result video
+ `url`: Full URL of the video + `url`: Full URL of the video
+ `base_url`: The base URL of the result (e.g.: http://youtube.com/watch -> http://youtube.com/) + `base_url`: The base URL of the result (e.g.: http://youtube.com/watch -> http://youtube.com/)
+ In case of torrent search:
+ `hash`: Hash of the torrent
+ `name`: Name of the torrent
+ `seeders`: The amount of seeders
+ `leechers`: The amount of leechers
+ `magnet`: The magnet link
<br/> <br/>
The API also supports both GET and POST requests The API also supports both GET and POST requests

36
api.php
View file

@ -1,6 +1,5 @@
<?php <?php
require "engines/google.php"; require "config.php";
require "engines/bittorrent.php";
if (!isset($_REQUEST["q"])) if (!isset($_REQUEST["q"]))
{ {
@ -8,11 +7,40 @@
die(); die();
} }
$query = $_REQUEST["q"]; $query_encoded = urlencode($_REQUEST["q"]);
$page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0; $page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0;
$type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0; $type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0;
$results = $type != 3 ? get_google_results($query, $page, $type) : get_bittorrent_results($query); $results = array();
switch ($type)
{
case 0:
require "engines/google/text.php";
$results = get_text_results($query_encoded, $page);
break;
case 1:
require "engines/google/image.php";
$results = get_image_results($query_encoded);
break;
case 2:
require "engines/google/video.php";
$results = get_video_results($query_encoded, $page);
break;
case 3:
if ($config_disable_bittorent_search)
$results = array("error" => "disabled");
else
{
require "engines/bittorrent/thepiratebay.php";
$results = get_thepiratebay_results($query_encoded);
}
break;
default:
require "engines/google/text.php";
$results = get_text_results($query_encoded, $page);
break;
}
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($results, JSON_PRETTY_PRINT); echo json_encode($results, JSON_PRETTY_PRINT);

View file

@ -8,9 +8,8 @@
// Results will be in this language // Results will be in this language
$config_google_language = "en"; $config_google_language = "en";
// Maxmium size of the cache // Disable BitTorrent search
$config_cache_size = 1024 * 1024 * 1024; $config_disable_bittorent_search = false;
/* /*
youtube.com results will be replaced with the given invidious instance youtube.com results will be replaced with the given invidious instance

13
donate.php Normal file
View file

@ -0,0 +1,13 @@
<?php require "static/header.html"; ?>
</head>
<body>
<div class="donate-container">
<p>Support the host</p>
<span>(Your donation thingy goes here...)</span>
<p>Support the creator</p>
<span>Monero (XMR): <br/><br/><span style="background-color:black;">41dGQr9EwZBfYBY3fibTtJZYfssfRuzJZDSVDeneoVcgckehK3BiLxAV4FvEVJiVqdiW996zvMxhFB8G8ot9nBFqQ84VkuC</span></span>
<img src="static/images/xmr.png" alt="xmr qr code"/>
</div>
<?php require "static/footer.html"; ?>

View file

@ -1,29 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>LibreX - Donate ❤️</title>
<meta http-equiv="Content-type" content="application/xhtml+xml;charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="A privacy respecting meta search engine."/>
<meta name="referrer" content="no-referrer"/>
<link rel="stylesheet" type="text/css" href="static/styles.css"/>
<link rel="shortcut icon" href="static/librex.png" />
</head>
<body>
<div class="donate-container">
<p>Support the host</p>
<span>(Your donation thingy goes here...)</span>
<p>Support the creator</p>
<span>Monero (XMR): <span style="background-color:black;">41dGQr9EwZBfYBY3fibTtJZYfssfRuzJZDSVDeneoVcgckehK3BiLxAV4FvEVJiVqdiW996zvMxhFB8G8ot9nBFqQ84VkuC</span></span>
<img src="static/xmr.png" alt="xmr qr code"/>
</div>
<div class="footer-container">
<a href="/">LibreX</a>
<a href="https://github.com/hnhx/librex/" target="_blank">Source &amp; Instance list</a>
<a href="/api.php" target="_blank">API</a>
<a href="/donate.xhtml" id="right">Donate ❤️</a>
</div>
</body>
</html>

View file

@ -1,20 +1,16 @@
<?php <?php
function get_bittorrent_results($query) function get_thepiratebay_results($query)
{ {
require "config.php"; require "config.php";
require "misc/tools.php";
$query = urlencode($query); $query = urlencode($query);
$results = array(); $results = array();
$url = "https://apibay.org/q.php?q=$query"; $url = "https://apibay.org/q.php?q=$query";
$response = request($url);
$ch = curl_init($url);
curl_setopt_array($ch, $config_curl_settings);
$response = curl_exec($ch);
$json_response = json_decode($response, true); $json_response = json_decode($response, true);
foreach ($json_response as $response) foreach ($json_response as $response)
@ -41,4 +37,28 @@
return $results; return $results;
} }
function print_thepiratebay_results($results)
{
echo "<div class=\"text-result-container\">";
foreach($results as $result)
{
$hash = $result["hash"];
$name = $result["name"];
$seeders = $result["seeders"];
$leechers = $result["leechers"];
$magnet = $result["magnet"];
echo "<div class=\"text-result-wrapper\">";
echo "<a href=\"$magnet\">";
echo "$hash";
echo "<h2>$name</h2>";
echo "</a>";
echo "<span>SE: $seeders - LE: $leechers</span>";
echo "</div>";
}
echo "</div>";
}
?> ?>

View file

@ -1,45 +0,0 @@
<?php
function get_google_results($query, $page=0, $type=0)
{
require "config.php";
require_once "results/google/image.php";
require_once "results/google/text.php";
require_once "results/google/video.php";
$query_encoded = urlencode($query);
$google = "https://www.google.$config_google_domain/search?&q=$query_encoded&start=$page&hl=$config_google_language";
if ($type == 1)
$google .= "&tbm=isch";
else if ($type == 2)
$google .= "&tbm=vid";
$ch = curl_init($google);
curl_setopt_array($ch, $config_curl_settings);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200)
{
echo "<p id=\"special-result\">";
echo "Google rejected the request! :C";
echo "</p>";
die();
}
$htmlDom = new DOMDocument;
@$htmlDom->loadHTML($response);
$xpath = new DOMXPath($htmlDom);
switch ($type)
{
case 0:
return text_results($xpath);
case 1:
return image_results($xpath);
case 2:
return video_results($xpath);
default:
return text_results($xpath);
}
}
?>

View file

@ -1,7 +1,12 @@
<?php <?php
function image_results($xpath) function get_image_results($query)
{ {
require "config.php"; require "config.php";
require "misc/tools.php";
$url = "https://www.google.$config_google_domain/search?&q=$query&hl=$config_google_language&tbm=isch";
$response = request($url);
$xpath = get_xpath($response);
$mh = curl_multi_init(); $mh = curl_multi_init();
$chs = $alts = $results = array(); $chs = $alts = $results = array();
@ -40,4 +45,21 @@
return $results; return $results;
} }
function print_image_results($results)
{
echo "<div class=\"image-result-container\">";
foreach($results as $result)
{
$src = $result["base64"];
$alt = $result["alt"];
echo "<a title=\"$alt\" href=\"data:image/jpeg;base64,$src\" target=\"_blank\">";
echo "<img src=\"data:image/jpeg;base64,$src\" width=\"350\" height=\"200\">";
echo "</a>";
}
echo "</div>";
}
?> ?>

View file

@ -1,9 +1,13 @@
<?php <?php
function text_results($xpath) function get_text_results($query, $page=0)
{ {
require_once "misc/tools.php";
require "config.php"; require "config.php";
require "misc/tools.php";
$url = "https://www.google.$config_google_domain/search?&q=$query&start=$page&hl=$config_google_language";
$response = request($url);
$xpath = get_xpath($response);
$results = array(); $results = array();
@ -41,4 +45,29 @@
return $results; return $results;
} }
function print_text_results($results)
{
global $query , $page;
//check_for_special_search($query);
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>";
}
echo "</div>";
}
?> ?>

View file

@ -1,8 +1,12 @@
<?php <?php
function video_results($xpath) function get_video_results($query, $page=0)
{ {
require_once "misc/tools.php";
require "config.php"; require "config.php";
require "misc/tools.php";
$url = "https://www.google.$config_google_domain/search?&q=$query&start=$page&hl=$config_google_language&tbm=vid";
$response = request($url);
$xpath = get_xpath($response);
$results = array(); $results = array();
@ -36,4 +40,25 @@
return $results; return $results;
} }
function print_video_results($results)
{
echo "<div class=\"text-result-container\">";
foreach($results as $result)
{
$title = $result["title"];
$url = $result["url"];
$base_url = $result["base_url"];
echo "<div class=\"text-result-wrapper\">";
echo "<a href=\"$url\">";
echo "$base_url";
echo "<h2>$title</h2>";
echo "</a>";
echo "</div>";
}
echo "</div>";
}
?> ?>

View file

@ -1,23 +0,0 @@
<?php
function check_for_special_search($query)
{
$query_lower = strtolower($query);
if (strpos($query_lower, "to"))
{
require_once "results/special/currency.php";
currency_results($query);
}
else if (strpos($query_lower, "mean"))
{
require_once "results/special/definition.php";
definition_results($query);
}
else if (3 > count(explode(" ", $query))) // long queries usually wont return a wiki result thats why this check exists
{
require_once "results/special/wikipedia.php";
wikipedia_results($query_lower);
return;
}
}
?>

View file

@ -1,7 +1,8 @@
<?php <?php
function currency_results($query) function currency_results($query)
{ {
require "config.php"; require "config.php";
require_once "misc/tools.php";
$split_query = explode(" ", $query); $split_query = explode(" ", $query);
@ -14,9 +15,8 @@
$base_currency = strtoupper($split_query[1]); $base_currency = strtoupper($split_query[1]);
$currency_to_convert = strtoupper($split_query[3]); $currency_to_convert = strtoupper($split_query[3]);
$ch = curl_init("https://cdn.moneyconvert.net/api/latest.json"); $url = "https://cdn.moneyconvert.net/api/latest.json";
curl_setopt_array($ch, $config_curl_settings); $response = request($url);
$response = curl_exec($ch);
$json_response = json_decode($response, true); $json_response = json_decode($response, true);
$rates = $json_response["rates"]; $rates = $json_response["rates"];

View file

@ -2,6 +2,7 @@
function definition_results($query) function definition_results($query)
{ {
require "config.php"; require "config.php";
require_once "misc/tools.php";
$split_query = explode(" ", $query); $split_query = explode(" ", $query);
@ -10,9 +11,8 @@
$reversed_split_q = array_reverse($split_query); $reversed_split_q = array_reverse($split_query);
$word_to_define = $reversed_split_q[1]; $word_to_define = $reversed_split_q[1];
$ch = curl_init("https://api.dictionaryapi.dev/api/v2/entries/en/$word_to_define"); $url = "https://api.dictionaryapi.dev/api/v2/entries/en/$word_to_define";
curl_setopt_array($ch, $config_curl_settings); $response = request($url);
$response = curl_exec($ch);
$json_response = json_decode($response, true); $json_response = json_decode($response, true);
if (!array_key_exists("title", $json_response)) if (!array_key_exists("title", $json_response))

View file

@ -2,13 +2,12 @@
function wikipedia_results($query) function wikipedia_results($query)
{ {
require "config.php"; require "config.php";
require_once "misc/tools.php";
$query_encoded = urlencode($query); $query_encoded = urlencode($query);
$ch = curl_init("https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded"); $url = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded";
curl_setopt_array($ch, $config_curl_settings); $response = request($url);
$response = curl_exec($ch);
$json_response = json_decode($response, true); $json_response = json_decode($response, true);
$first_page = array_values($json_response["query"]["pages"])[0]; $first_page = array_values($json_response["query"]["pages"])[0];
@ -25,9 +24,8 @@
if (array_key_exists("thumbnail", $first_page)) if (array_key_exists("thumbnail", $first_page))
{ {
$img_src = $first_page["thumbnail"]["source"]; $img_src = $first_page["thumbnail"]["source"];
$ch_image = curl_init($first_page["thumbnail"]["source"]); $url = $first_page["thumbnail"]["source"];
curl_setopt_array($ch_image, $config_curl_settings); $image_response = request($url);
$image_response = curl_exec($ch_image);
$base64_image = base64_encode($image_response); $base64_image = base64_encode($image_response);
echo "<a href=\"data:image/jpeg;base64,$base64_image\" target=\"_blank\">"; echo "<a href=\"data:image/jpeg;base64,$base64_image\" target=\"_blank\">";

17
index.php Normal file
View file

@ -0,0 +1,17 @@
<?php require "static/header.html"; ?>
</head>
<body>
<form class="search-container" action="search.php" method="post" enctype="multipart/form-data" autocomplete="off">
<h1>Libre<span style="color:#bd93f9;">X</span></h1>
<input type="text" name="q"/>
<input type="hidden" name="p" value="0"/>
<input type="hidden" name="type" value="0"/>
<input type="submit" style="display:none"/>
<div class="search-button-wrapper">
<button name="type" value="0" type="submit">Search with LibreX</button>
<button name="type" value="1" type="submit">Search images with LibreX</button>
</div>
</form>
<?php require "static/footer.html"; ?>

View file

@ -1,33 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>LibreX</title>
<meta http-equiv="Content-type" content="application/xhtml+xml;charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="A privacy respecting meta search engine."/>
<meta name="referrer" content="no-referrer"/>
<link rel="stylesheet" type="text/css" href="static/styles.css"/>
<link rel="shortcut icon" href="static/librex.png" />
</head>
<body>
<form class="search-container" action="search.php" method="post" enctype="multipart/form-data" autocomplete="off">
<h1>Libre<span style="color:#bd93f9;">X</span></h1>
<input type="text" name="q"/>
<input type="hidden" name="p" value="0"/>
<input type="hidden" name="type" value="0"/>
<input type="submit" style="display:none"/>
<div class="search-button-wrapper">
<button name="type" value="0" type="submit">Search with LibreX</button>
<button name="type" value="1" type="submit">Search images with LibreX</button>
</div>
</form>
<div class="footer-container">
<a href="/">LibreX</a>
<a href="https://github.com/hnhx/librex/" target="_blank">Source &amp; Instance list</a>
<a href="/api.php" target="_blank">API</a>
<a href="/donate.xhtml" id="right">Donate ❤️</a>
</div>
</body>
</html>

View file

@ -6,102 +6,33 @@
return $base_url; return $base_url;
} }
function get_xpath($response)
function print_text_results($results)
{ {
global $query , $page; $htmlDom = new DOMDocument;
@$htmlDom->loadHTML($response);
$xpath = new DOMXPath($htmlDom);
if ($page == 0) return $xpath;
check_for_special_search($query);
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>";
}
echo "</div>";
} }
function print_image_results($results) function request($url)
{ {
echo "<div class=\"image-result-container\">"; require "config.php";
foreach($results as $result) $ch = curl_init($url);
{ curl_setopt_array($ch, $config_curl_settings);
$src = $result["base64"]; $response = curl_exec($ch);
$alt = $result["alt"];
echo "<a title=\"$alt\" href=\"data:image/jpeg;base64,$src\" target=\"_blank\">"; return $response;
echo "<img src=\"data:image/jpeg;base64,$src\" width=\"350\" height=\"200\">";
echo "</a>";
}
echo "</div>";
} }
function print_video_results($results) function print_next_page_button($text, $page, $query, $type)
{
echo "<div class=\"text-result-container\">";
foreach($results as $result)
{
$title = $result["title"];
$url = $result["url"];
$base_url = $result["base_url"];
echo "<div class=\"text-result-wrapper\">";
echo "<a href=\"$url\">";
echo "$base_url";
echo "<h2>$title</h2>";
echo "</a>";
echo "</div>";
}
echo "</div>";
}
function print_bittorrent_results($results)
{
echo "<div class=\"text-result-container\">";
foreach($results as $result)
{
$hash = $result["hash"];
$name = $result["name"];
$seeders = $result["seeders"];
$leechers = $result["leechers"];
$magnet = $result["magnet"];
echo "<div class=\"text-result-wrapper\">";
echo "<a href=\"$magnet\">";
echo "$hash";
echo "<h2>$name</h2>";
echo "</a>";
echo "<span>SE: $seeders - LE: $leechers</span>";
echo "</div>";
}
echo "</div>";
}
function print_next_page_button($page, $button_val, $q, $type)
{ {
echo "<form id=\"page\" action=\"search.php\" target=\"_top\" method=\"post\" enctype=\"multipart/form-data\" autocomplete=\"off\">"; echo "<form id=\"page\" action=\"search.php\" target=\"_top\" method=\"post\" enctype=\"multipart/form-data\" autocomplete=\"off\">";
echo "<input type=\"hidden\" name=\"p\" value=\"" . $page . "\" />"; echo "<input type=\"hidden\" name=\"p\" value=\"" . $page . "\" />";
echo "<input type=\"hidden\" name=\"q\" value=\"$q\" />"; echo "<input type=\"hidden\" name=\"q\" value=\"$query\" />";
echo "<input type=\"hidden\" name=\"type\" value=\"$type\" />"; echo "<input type=\"hidden\" name=\"type\" value=\"$type\" />";
echo "<button type=\"submit\">$button_val</button>"; echo "<button type=\"submit\">$text</button>";
echo "</form>"; echo "</form>";
} }
?> ?>

View file

@ -1,19 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php require "static/header.html"; ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <title> <?php echo $_REQUEST["q"]; ?> - LibreX</title>
<head> </head>
<title> <?php echo $_REQUEST["q"]; ?> - LibreX</title>
<meta http-equiv="Content-type" content="application/xhtml+xml;charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="A privacy respecting meta search engine."/>
<meta name="referrer" content="no-referrer"/>
<link rel="stylesheet" type="text/css" href="static/styles.css"/>
<link title="LibreX search" type="application/opensearchdescription+xml" href="/opensearch.xml?method=POST" rel="search"/>
<link rel="shortcut icon" href="static/librex.png" />
</head>
<body> <body>
<form class="sub-search-container" method="post" enctype="multipart/form-data" autocomplete="off"> <form class="sub-search-container" method="post" enctype="multipart/form-data" autocomplete="off">
<a href="/"><img id="logo" src="static/librex.png" alt="librex"></a> <a href="/"><img id="logo" src="static/images/librex.png" alt="librex"></a>
<input type="text" name="q" <input type="text" name="q"
<?php <?php
$query = trim($_REQUEST["q"]); $query = trim($_REQUEST["q"]);
@ -35,80 +26,104 @@
<button type="submit" style="display:none;"></button> <button type="submit" style="display:none;"></button>
<input type="hidden" name="p" value="0"> <input type="hidden" name="p" value="0">
<div class="sub-search-button-wrapper"> <div class="sub-search-button-wrapper">
<button name="type" value="0"><img src="static/text_result.png">Text</button> <button name="type" value="0"><img src="static/images/text_result.png">Text</button>
<button name="type" value="1"><img src="static/image_result.png">Images</button> <button name="type" value="1"><img src="static/images/image_result.png">Images</button>
<button name="type" value="2"><img src="static/video_result.png">Videos</button> <button name="type" value="2"><img src="static/images/video_result.png">Videos</button>
<button name="type" value="3"><img src="static/torrent_result.png">Torrents</button> <button name="type" value="3"><img src="static/images/torrent_result.png">Torrents</button>
</div> </div>
<hr> <hr>
</form> </form>
<?php <?php
require "config.php";
require_once "engines/google.php"; function check_for_special_search($query)
require_once "engines/special.php"; {
require_once "misc/tools.php"; $query_lower = strtolower($query);
require_once "engines/bittorrent.php";
require_once "config.php"; if (strpos($query_lower, "to"))
{
require "engines/special/currency.php";
currency_results($query);
}
else if (strpos($query_lower, "mean"))
{
require "engines/special/definition.php";
definition_results($query);
}
else if (3 > count(explode(" ", $query))) // long queries usually wont return a wiki result thats why this check exists
{
require "engines/special/wikipedia.php";
wikipedia_results($query_lower);
return;
}
}
$page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0; $page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0;
$type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0; $type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0;
$query_encoded = urlencode($query);
$start_time = microtime(true);
$results = $type != 3 ? get_google_results($query, $page, $type) : get_bittorrent_results($query);
$end_time = number_format(microtime(true) - $start_time, 2, '.', '');
echo "<p id=\"time\">Fetched the results in $end_time seconds</p>";
switch ($type) switch ($type)
{ {
case 0: case 0:
require "engines/google/text.php";
$results = get_text_results($query_encoded, $page);
if ($page == 0)
check_for_special_search($query);
print_text_results($results); print_text_results($results);
break; break;
case 1: case 1:
require "engines/google/image.php";
$results = get_image_results($query_encoded);
print_image_results($results); print_image_results($results);
break; break;
case 2: case 2:
require "engines/google/video.php";
$results = get_video_results($query_encoded, $page);
print_video_results($results); print_video_results($results);
break; break;
case 3: case 3:
print_bittorrent_results($results); if ($config_disable_bittorent_search)
echo "<p class=\"text-result-container\">The host disabled this feature! :C</p>";
else
{
require "engines/bittorrent/thepiratebay.php";
$results = get_thepiratebay_results($query_encoded);
print_thepiratebay_results($results);
}
break; break;
default: default:
require "engines/google/text.php";
$results = get_text_results($query_encoded, $page);
print_text_results($results); print_text_results($results);
break; break;
} }
if ($type != 1 && $type != 3 )
if ($type == 0 || $type == 2 )
{ {
echo "<div class=\"next-page-button-wrapper\">"; echo "<div class=\"next-page-button-wrapper\">";
if ($page != 0) if ($page != 0)
{ {
print_next_page_button(0, "&lt;&lt;", $query, $type); print_next_page_button("&lt;&lt;", 0, $query, $type);
print_next_page_button($page - 10, "&lt;", $query, $type); print_next_page_button("&lt;", $page - 10, $query, $type);
} }
for ($i=$page / 10; $page / 10 + 10 > $i; $i++) for ($i=$page / 10; $page / 10 + 10 > $i; $i++)
{ print_next_page_button($i + 1, $i * 10, $query, $type);
$page_input = $i * 10;
$page_button = $i + 1;
print_next_page_button($page_input, $page_button, $query, $type);
}
print_next_page_button($page + 10, "&gt;", $query, $type); print_next_page_button("&gt;", $page + 10, $query, $type);
echo "</div>"; echo "</div>";
} }
?> ?>
<div class="footer-container"> <?php require "static/footer.html"; ?>
<a href="/">LibreX</a>
<a href="https://github.com/hnhx/librex/" target="_blank">Source &amp; Instance list</a>
<a href="/api.php" target="_blank">API</a>
<a href="/donate.xhtml" id="right">Donate ❤️</a>
</div>
</body>
</html>

8
static/footer.html Normal file
View file

@ -0,0 +1,8 @@
<div class="footer-container">
<a href="/">LibreX</a>
<a href="https://github.com/hnhx/librex/" target="_blank">Source &amp; Instance list</a>
<a href="/api.php" target="_blank">API</a>
<a href="/donate.php" id="right">Donate ❤️</a>
</div>
</body>
</html>

11
static/header.html Normal file
View file

@ -0,0 +1,11 @@
<!DOCTYPE html >
<html lang="en">
<head>
<meta http-equiv="Content-type" content="application/xhtml+xml;charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="A privacy respecting meta search engine."/>
<meta name="referrer" content="no-referrer"/>
<link rel="stylesheet" type="text/css" href="static/styles.css"/>
<link title="LibreX search" type="application/opensearchdescription+xml" href="/opensearch.xml?method=POST" rel="search"/>
<link rel="shortcut icon" href="static/images/librex.png" />

View file

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 5 KiB

View file

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB