diff --git a/README.md b/README.md index 6bc78a6..0a3c1da 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,13 @@ | [search.funami.tech](https://search.funami.tech/) | ❌ | ❌ | πŸ‡°πŸ‡· KR | | [librex.catalyst.sx](https://librex.catalyst.sx/) | ❌ | ❌ | πŸ‡ΊπŸ‡Έ US | | [search.madreyk.xyz](https://search.madreyk.xyz/) | ❌ | ❌ | πŸ‡©πŸ‡ͺ DE | -| ❌ | [βœ…](http://librex.so2mpiyfo4cje7bof5v52y3cvjyo2haxpqfvut4sr6gj2ul4mddx2jid.onion/) | ❌ | ??? | +| ❌ | [βœ…](http://librex.so2mpiyfo4cje7bof5v52y3cvjyo2haxpqfvut4sr6gj2ul4mddx2jid.onion/) | ❌ | ??? |
### About LibreX -LibreX gives you results from Google, Qwant and popular torrent sites without spying on you. +LibreX gives you results from Google, Brave, Qwant and popular torrent sites without spying on you.

If you would like to learn more about LibreX check out the [Wiki](https://github.com/hnhx/librex/wiki). @@ -33,7 +33,7 @@ If you would like to learn more about LibreX check out the [Wiki](https://github
### Mirror -In case GitHub would remove LibreX, you can access the source code via this git mirror +You can access the source code via this git mirror ``` git clone https://git.beparanoid.de/librex ``` diff --git a/config.php.example b/config.php.example index 6c42f62..5d90e18 100644 --- a/config.php.example +++ b/config.php.example @@ -10,16 +10,16 @@ "disable_bittorent_search" => false, "bittorent_trackers" => "&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce", - /* + /* Preset privacy friendly frontends for users, these can be overwritten by users in settings e.g.: "invidious" => "https://yewtu.be", */ - "invidious" => "", - "bibliogram" => "", - "nitter" => "", - "libreddit" => "", - "proxitok" => "", - "wikiless" => "", + "invidious" => "", // youtube + "bibliogram" => "", // instagram + "nitter" => "", // twitter + "libreddit" => "", // reddit + "proxitok" => "", // tiktok + "wikiless" => "", // wikipedia /* To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE: @@ -45,7 +45,7 @@ CURLOPT_PROTOCOLS => CURLPROTO_HTTPS | CURLPROTO_HTTP, CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTPS | CURLPROTO_HTTP, CURLOPT_MAXREDIRS => 5, - CURLOPT_TIMEOUT => 8, + CURLOPT_TIMEOUT => 18, CURLOPT_VERBOSE => false ) diff --git a/engines/brave/video.php b/engines/brave/video.php new file mode 100644 index 0000000..77fbc26 --- /dev/null +++ b/engines/brave/video.php @@ -0,0 +1,65 @@ +query("//div[@id='results']//div[@class='card']") as $result) + { + $url = $xpath->evaluate(".//a/@href", $result)[0]->textContent; + $title = $xpath->evaluate(".//div/@title", $result)[0]->textContent; + $views = $xpath->evaluate(".//div/@title", $result)[1]->textContent; + $date = $xpath->evaluate(".//div//span", $result)[0]->textContent; + $thumbnail_raw1 = $xpath->evaluate(".//div/@style", $result)[0]->textContent; + $thumbnail_raw2 = explode("url('", $thumbnail_raw1)[1]; + $thumbnail = explode("'), url", $thumbnail_raw2)[0]; + + $url = check_for_privacy_frontend($url); + + array_push($results, + array ( + "title" => htmlspecialchars($title), + "url" => htmlspecialchars($url), + "base_url" => htmlspecialchars(get_base_url($url)), + "views" => htmlspecialchars($views), + "date" => htmlspecialchars($date), + "thumbnail" => htmlspecialchars($thumbnail) + ) + ); + } + + return $results; + } + + function print_video_results($results) + { + echo "
"; + + foreach($results as $result) + { + $title = $result["title"]; + $url = $result["url"]; + $base_url = $result["base_url"]; + $views = $result["views"]; + $date = $result["date"]; + $thumbnail = $result["thumbnail"]; + + echo "
"; + echo ""; + echo "$base_url"; + echo "

$title

"; + echo ""; + echo "
"; + echo "$date - $views"; + echo "
"; + echo "
"; + } + + echo "
"; + } +?> diff --git a/engines/google/video.php b/engines/google/video.php deleted file mode 100644 index a9a2b6c..0000000 --- a/engines/google/video.php +++ /dev/null @@ -1,61 +0,0 @@ -google_domain/search?&q=$query&start=$page&hl=$config->google_language&tbm=vid"; - $response = request($url); - $xpath = get_xpath($response); - - $results = array(); - - foreach($xpath->query("//div[@id='search']//div[contains(@class, 'g')]") as $result) - { - $url = $xpath->evaluate(".//a/@href", $result)[0]; - - if ($url == null) - continue; - - if (!empty($results)) // filter duplicate results - if (end($results)["url"] == $url->textContent) - continue; - - $url = $url->textContent; - - $url = check_for_privacy_frontend($url); - - $title = $xpath->evaluate(".//h3", $result)[0]; - - array_push($results, - array ( - "title" => htmlspecialchars($title->textContent), - "url" => htmlspecialchars($url), - "base_url" => htmlspecialchars(get_base_url($url)) - ) - ); - } - - return $results; - } - - function print_video_results($results) - { - echo "
"; - - foreach($results as $result) - { - $title = $result["title"]; - $url = $result["url"]; - $base_url = $result["base_url"]; - - echo "
"; - echo ""; - echo "$base_url"; - echo "

$title

"; - echo "
"; - echo "
"; - } - - echo "
"; - } -?> diff --git a/image_proxy.php b/image_proxy.php index c0d536f..9521952 100644 --- a/image_proxy.php +++ b/image_proxy.php @@ -7,11 +7,11 @@ $split_url = explode("/", $url); $base_url = $split_url[2]; - + $base_url_main_split = explode(".", strrev($base_url)); $base_url_main = strrev($base_url_main_split[1]) . "." . strrev($base_url_main_split[0]); - if ($base_url_main == "qwant.com" || $base_url_main == "wikimedia.org") + if ($base_url_main == "qwant.com" || $base_url_main == "wikimedia.org" || $base_url_main == "brave.com") { $image = $url; $image_src = request($image); diff --git a/instances.json b/instances.json new file mode 100644 index 0000000..d99885c --- /dev/null +++ b/instances.json @@ -0,0 +1,46 @@ +{ + "instances": [ + { + "clearnet": "https://librex.beparanoid.de/", + "tor": "http://librex.2356uhnbpv5nk3bni5bv6jg2cd6lgj664kwx3lhyelstpttpyv4kk2qd.onion/", + "i2p": null, + "country": "HU" + }, + { + "clearnet": "https://librex.extravi.dev/", + "tor": "http://ncblhz7q4sfbf755bdbhebfzxcpypz7ewafgi4agatecojz7pln4i3id.onion/", + "i2p": "http://rra33hiaf6nmby7jfpqe2gqmng3jnzkvbu2n7jgce7vbhoyuhzya.b32.i2p/", + "country": "DE" + }, + { + "clearnet": "https://search.davidovski.xyz/", + "tor": null, + "i2p": null, + "country": "UK" + }, + { + "clearnet": "https://search.funami.tech/", + "tor": null, + "i2p": null, + "country": "KR" + }, + { + "clearnet": "https://librex.catalyst.sx/", + "tor": null, + "i2p": null, + "country": "US" + }, + { + "clearnet": "https://search.madreyk.xyz/", + "tor": null, + "i2p": null, + "country": "DE" + }, + { + "clearnet": null, + "tor": "http://librex.so2mpiyfo4cje7bof5v52y3cvjyo2haxpqfvut4sr6gj2ul4mddx2jid.onion/", + "i2p": null, + "country": null + } + ] +} diff --git a/misc/tools.php b/misc/tools.php index ccec96f..b2ca595 100644 --- a/misc/tools.php +++ b/misc/tools.php @@ -19,12 +19,12 @@ else if (!empty($config->$frontend)) $frontend = $config->$frontend; - if ($original == "instagram.com") + if ($original == "instagram.com") { if (!strpos($url, "/p/")) $frontend .= "/u"; } - + $url = $frontend . explode($original, $url)[1]; return $url; @@ -59,10 +59,14 @@ function check_ddg_bang($query) { - $bangs_json = file_get_contents("static/misc/ddg_bang.json"); + $bangs_json = file_get_contents("static/misc/ddg_bang.json"); $bangs = json_decode($bangs_json, true); + + if (substr($query, 0, 1) == "!") + $search_word = substr(explode(" ", $query)[0], 1); + else + $search_word = substr(end(explode(" ", $query)), 1); - $search_word = substr(explode(" ", $query)[0], 1); $bang_url = null; foreach($bangs as $bang) diff --git a/search.php b/search.php index 4d1fb1d..c02c7cb 100644 --- a/search.php +++ b/search.php @@ -1,6 +1,10 @@ - <?php echo $_REQUEST["q"]; ?> - LibreX + +<?php + $query = htmlspecialchars(trim($_REQUEST["q"])); + echo $query; +?> - LibreX
@@ -8,7 +12,6 @@ strlen($query) || strlen($query) > 256) @@ -46,7 +49,7 @@ switch ($type) { case 0: - if (substr($query, 0, 1) == "!") + if (substr($query, 0, 1) == "!" || substr(end(explode(" ", $query)), 0, 1) == "!") check_ddg_bang($query); require "engines/google/text.php"; $results = get_text_results($query, $page); @@ -62,8 +65,8 @@ break; case 2: - require "engines/google/video.php"; - $results = get_video_results($query_encoded, $page); + require "engines/brave/video.php"; + $results = get_video_results($query_encoded); print_elapsed_time($start_time); print_video_results($results); break; @@ -91,7 +94,7 @@ } - if ($type != 3) + if (2 > $type) { echo "
"; diff --git a/static/images/image_result.png b/static/images/image_result.png index 732a295..84dfca0 100644 Binary files a/static/images/image_result.png and b/static/images/image_result.png differ diff --git a/static/images/text_result.png b/static/images/text_result.png index ef8a43a..bdb859d 100644 Binary files a/static/images/text_result.png and b/static/images/text_result.png differ diff --git a/static/images/torrent_result.png b/static/images/torrent_result.png index 9dcfb01..7104820 100644 Binary files a/static/images/torrent_result.png and b/static/images/torrent_result.png differ diff --git a/static/images/video_result.png b/static/images/video_result.png index bceeab4..d59dd77 100644 Binary files a/static/images/video_result.png and b/static/images/video_result.png differ