diff --git a/README.md b/README.md index 51ea957..87520e1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ If you wish to get your instance added create an issue with the `new instance` l Your request will be **rejected** if your instance: + contains JavaScript -+ contains cookies + contains ads + has been heavily modified diff --git a/api.php b/api.php index 1185d4f..9bee3c6 100644 --- a/api.php +++ b/api.php @@ -1,5 +1,6 @@ disable_bittorent_search) $results = array("error" => "disabled"); else { diff --git a/config.php b/config.php index e8b5d15..d7bd0f2 100755 --- a/config.php +++ b/config.php @@ -1,61 +1,62 @@ https://google.fr/ - $config_google_domain = "com"; + // e.g.: fr -> https://google.fr/ + "google_domain" => "com", - // Google results will be in this language - $config_google_language = "en"; + // Google results will be in this language + "google_language" => "en", - $config_disable_bittorent_search = false; - $config_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"; + "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", - /* - These are privacy friendly front-ends for popular sites, these settings can be managed by end users as well for their session via cookies. + /* + These are privacy friendly front-ends for popular sites, these settings can be managed by end users as well for their session via cookies. - Online invidious instances: https://docs.invidious.io/Invidious-Instances/ - Online bibliogram instances: https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md - Online nitter instances: https://github.com/zedeus/nitter/wiki/Instances - Online libreddit instances: https://github.com/spikecodes/libreddit + Online invidious instances: https://docs.invidious.io/Invidious-Instances/ + Online bibliogram instances: https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md + Online nitter instances: https://github.com/zedeus/nitter/wiki/Instances + Online libreddit instances: https://github.com/spikecodes/libreddit + + If you don't want to replace YouTube for an example: + $replace_youtube_with_invidious = isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : null; + */ + "replace_youtube_with_invidious" => isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : "https://yewtu.be", + "replace_instagram_with_bibliogram" => isset($_COOKIE["bibliogram"]) ? $_COOKIE["bibliogram"] : "https://bibliogram.pussthecat.org", + "replace_twitter_with_nitter" => isset($_COOKIE["nitter"]) ? $_COOKIE["nitter"] : "https://nitter.namazso.eu", + "replace_reddit_with_libreddit" => isset($_COOKIE["libreddit"]) ? $_COOKIE["libreddit"] : "https://libreddit.dothq.co", + + /* + To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE: + + CURLOPT_PROXYTYPE options: + + CURLPROXY_HTTP + CURLPROXY_SOCKS4 + CURLPROXY_SOCKS4A + CURLPROXY_SOCKS5 + CURLPROXY_SOCKS5_HOSTNAME + + As an example, for a TOR connection you would use these settings: + CURLOPT_PROXY => "127.0.0.1:9050", + CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5, + + !!! ONLY CHANGE THE OTHER OPTIONS IF YOU KNOW WHAT YOU ARE DOING !!! + */ + "curl_settings" => array( + // CURLOPT_PROXY => "ip:port", + // CURLOPT_PROXYTYPE => CURLPROXY_HTTP, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36", + CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_SSL_VERIFYHOST => false, + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_SSL_VERIFYSTATUS => false, + CURLOPT_VERBOSE => false, + CURLOPT_TCP_FASTOPEN => true + ) - If you don't want to replace YouTube for an example: - $config_replace_youtube_with_invidious = isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : null; - */ - $config_replace_youtube_with_invidious = isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : "https://yewtu.be"; - $config_replace_instagram_with_bibliogram = isset($_COOKIE["bibliogram"]) ? $_COOKIE["bibliogram"] : "https://bibliogram.pussthecat.org"; - $config_replace_twitter_with_nitter = isset($_COOKIE["nitter"]) ? $_COOKIE["nitter"] : "https://nitter.namazso.eu"; - $config_replace_reddit_with_libreddit = isset($_COOKIE["libreddit"]) ? $_COOKIE["libreddit"] : "https://libreddit.dothq.co"; - - /* - To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE: - - CURLOPT_PROXYTYPE options: - - CURLPROXY_HTTP - CURLPROXY_SOCKS4 - CURLPROXY_SOCKS4A - CURLPROXY_SOCKS5 - CURLPROXY_SOCKS5_HOSTNAME - - As an example, for a TOR connection you would use these settings: - CURLOPT_PROXY => "127.0.0.1:9050", - CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5, - - !!! ONLY CHANGE THE OTHER OPTIONS IF YOU KNOW WHAT YOU ARE DOING !!! - */ - $config_curl_settings = array( - // CURLOPT_PROXY => "ip:port", - // CURLOPT_PROXYTYPE => CURLPROXY_HTTP, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_USERAGENT => $config_user_agent, - CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_SSL_VERIFYHOST => false, - CURLOPT_SSL_VERIFYPEER => false, - CURLOPT_SSL_VERIFYSTATUS => false, - CURLOPT_VERBOSE => false, - CURLOPT_TCP_FASTOPEN => true ); ?> \ No newline at end of file diff --git a/donate.php b/donate.php index 9a149f0..908d781 100644 --- a/donate.php +++ b/donate.php @@ -1,4 +1,5 @@ - + + LibreX - Donate @@ -10,4 +11,4 @@ xmr qr code - \ No newline at end of file + \ No newline at end of file diff --git a/engines/bittorrent/merge.php b/engines/bittorrent/merge.php index e68c340..d1ee79d 100644 --- a/engines/bittorrent/merge.php +++ b/engines/bittorrent/merge.php @@ -22,6 +22,8 @@ { echo "
"; + if (!empty($results)) + { foreach($results as $result) { $source = $result["source"]; @@ -41,6 +43,9 @@ echo "$size"; echo "
"; } + } + else + echo "

There are no results. Please try different keywords!

"; echo ""; } diff --git a/engines/bittorrent/nyaa.php b/engines/bittorrent/nyaa.php index 18550da..4a30968 100644 --- a/engines/bittorrent/nyaa.php +++ b/engines/bittorrent/nyaa.php @@ -1,8 +1,7 @@ query("//tbody/tr") as $result) { - global $config_bittorent_trackers; - $name = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result)[0]->textContent; $centered = $xpath->evaluate(".//td[@class='text-center']", $result); $magnet = $xpath->evaluate(".//a[2]/@href", $centered[0])[0]->textContent; $magnet_without_tracker = explode("&tr=", $magnet)[0]; - $magnet = $magnet_without_tracker . $config_bittorent_trackers; + $magnet = $magnet_without_tracker . $config->bittorent_trackers; $size = $centered[1]->textContent; $seeders = $centered[3]->textContent; $leechers = $centered[4]->textContent; diff --git a/engines/bittorrent/rutor.php b/engines/bittorrent/rutor.php index 179c76f..060eb5b 100644 --- a/engines/bittorrent/rutor.php +++ b/engines/bittorrent/rutor.php @@ -1,8 +1,7 @@ query("//table/tr[@class='gai' or @class='tum']") as $result) { - global $config_bittorent_trackers; - $name = $xpath->evaluate(".//td/a", $result)[2]->textContent; $magnet = $xpath->evaluate(".//td/a/@href", $result)[1]->textContent; $magnet_without_tracker = explode("&tr=", $magnet)[0]; - $magnet = $magnet_without_tracker . $config_bittorent_trackers; + $magnet = $magnet_without_tracker . $config->bittorent_trackers; $size = $xpath->evaluate(".//td", $result)[3]->textContent; $seeders = $xpath->evaluate(".//span", $result)[0]->textContent; $leechers = $xpath->evaluate(".//span", $result)[1]->textContent; diff --git a/engines/bittorrent/thepiratebay.php b/engines/bittorrent/thepiratebay.php index bf46866..f7d1351 100644 --- a/engines/bittorrent/thepiratebay.php +++ b/engines/bittorrent/thepiratebay.php @@ -2,8 +2,7 @@ function get_thepiratebay_results($query) { - require_once "config.php"; - require_once "misc/tools.php"; + global $config; $query = urlencode($query); @@ -16,15 +15,16 @@ foreach ($json_response as $response) { - global $config_bittorent_trackers; - $size = human_filesize($response["size"]); $hash = $response["info_hash"]; $name = $response["name"]; $seeders = (int) $response["seeders"]; $leechers = (int) $response["leechers"]; - $magnet = "magnet:?xt=urn:btih:$hash&dn=$name$config_bittorent_trackers"; + $magnet = "magnet:?xt=urn:btih:$hash&dn=$name" . $config->bittorent_trackers; + + if ($name == "No results returned") + break; array_push($results, array ( diff --git a/engines/bittorrent/yts.php b/engines/bittorrent/yts.php index 6d68f25..d08847c 100644 --- a/engines/bittorrent/yts.php +++ b/engines/bittorrent/yts.php @@ -2,8 +2,7 @@ function get_yts_results($query) { - require_once "config.php"; - require_once "misc/tools.php"; + global $config; $query = urlencode($query); @@ -23,14 +22,13 @@ foreach ($movie["torrents"] as $torrent) { - global $config_bittorent_trackers; $hash = $torrent["hash"]; $seeders = $torrent["seeds"]; $leechers = $torrent["peers"]; $size = $torrent["size"]; - $magnet = "magnet:?xt=urn:btih:$hash&dn=$name_encoded$config_bittorent_trackers"; + $magnet = "magnet:?xt=urn:btih:$hash&dn=$name_encoded$config->bittorent_trackers"; array_push($results, array ( diff --git a/engines/google/image.php b/engines/google/image.php index 135da9b..721ab6a 100644 --- a/engines/google/image.php +++ b/engines/google/image.php @@ -1,10 +1,9 @@ google_domain/search?&q=$query&hl=$config->google_language&tbm=isch"; $response = request($url); $xpath = get_xpath($response); @@ -19,7 +18,7 @@ if (!empty($alt)) { $ch = curl_init($src); - curl_setopt_array($ch, $config_curl_settings); + curl_setopt_array($ch, $config->curl_settings); array_push($chs, $ch); curl_multi_add_handle($mh, $ch); diff --git a/engines/google/text.php b/engines/google/text.php index 88ea500..234ca79 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -20,17 +20,16 @@ function get_text_results($query, $page=0) { - require "config.php"; - require "misc/tools.php"; + global $config; $mh = curl_multi_init(); $query_lower = strtolower($query); $query_encoded = urlencode($query); $results = array(); - $url = "https://www.google.$config_google_domain/search?&q=$query_encoded&start=$page&hl=$config_google_language"; + $url = "https://www.google.$config->google_domain/search?&q=$query_encoded&start=$page&hl=$config->google_language"; $google_ch = curl_init($url); - curl_setopt_array($google_ch, $config_curl_settings); + curl_setopt_array($google_ch, $config->curl_settings); curl_multi_add_handle($mh, $google_ch); @@ -56,7 +55,7 @@ } $special_ch = curl_init($url); - curl_setopt_array($special_ch, $config_curl_settings); + curl_setopt_array($special_ch, $config->curl_settings); curl_multi_add_handle($mh, $special_ch); } diff --git a/engines/google/video.php b/engines/google/video.php index cc6e351..f6963c0 100644 --- a/engines/google/video.php +++ b/engines/google/video.php @@ -1,10 +1,9 @@ google_domain/search?&q=$query&start=$page&hl=$config->google_language&tbm=vid"; $response = request($url); $xpath = get_xpath($response); diff --git a/engines/special/currency.php b/engines/special/currency.php index b7f119b..4fbc2aa 100644 --- a/engines/special/currency.php +++ b/engines/special/currency.php @@ -1,9 +1,6 @@ + LibreX @@ -15,4 +15,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/static/footer.html b/misc/footer.php similarity index 100% rename from static/footer.html rename to misc/footer.php diff --git a/static/header.php b/misc/header.php similarity index 76% rename from static/header.php rename to misc/header.php index 52ef1b9..2536e85 100644 --- a/static/header.php +++ b/misc/header.php @@ -5,8 +5,8 @@ - + - "/> \ No newline at end of file + "/> \ No newline at end of file diff --git a/misc/tools.php b/misc/tools.php index 06c4710..94b1af2 100644 --- a/misc/tools.php +++ b/misc/tools.php @@ -8,21 +8,21 @@ function check_for_privacy_friendly_alternative($url) { - require "config.php"; + $config = require "config.php"; - if ($config_replace_youtube_with_invidious != null && strpos($url, "youtube.com")) - $url = $config_replace_youtube_with_invidious . explode("youtube.com", $url)[1]; - else if ($config_replace_instagram_with_bibliogram != null && strpos($url, "instagram.com")) + if ($config->replace_youtube_with_invidious != null && strpos($url, "youtube.com")) + $url = $config->replace_youtube_with_invidious . explode("youtube.com", $url)[1]; + else if ($config->replace_instagram_with_bibliogram != null && strpos($url, "instagram.com")) { if (!strpos($url, "/p/")) - $config_replace_instagram_with_bibliogram .= "/u"; + $config->replace_instagram_with_bibliogram .= "/u"; - $url = $config_replace_instagram_with_bibliogram . explode("instagram.com", $url)[1]; + $url = $config->replace_instagram_with_bibliogram . explode("instagram.com", $url)[1]; } - else if ($config_replace_twitter_with_nitter != null && strpos($url, "twitter.com")) - $url = $config_replace_twitter_with_nitter . explode("twitter.com", $url)[1]; - else if ($config_replace_reddit_with_libreddit != null && strpos($url, "reddit.com")) - $url = $config_replace_reddit_with_libreddit . explode("reddit.com", $url)[1]; + else if ($config->replace_twitter_with_nitter != null && strpos($url, "twitter.com")) + $url = $config->replace_twitter_with_nitter . explode("twitter.com", $url)[1]; + else if ($config->replace_reddit_with_libreddit != null && strpos($url, "reddit.com")) + $url = $config->replace_reddit_with_libreddit . explode("reddit.com", $url)[1]; return $url; } @@ -38,10 +38,10 @@ function request($url) { - require "config.php"; + $config = require "config.php"; $ch = curl_init($url); - curl_setopt_array($ch, $config_curl_settings); + curl_setopt_array($ch, $config->curl_settings); $response = curl_exec($ch); return $response; diff --git a/search.php b/search.php index c394ef5..ff97c67 100644 --- a/search.php +++ b/search.php @@ -1,4 +1,4 @@ - + <?php echo $_REQUEST["q"]; ?> - LibreX @@ -36,7 +36,8 @@ disable_bittorent_search) echo "

The host disabled this feature! :C

"; else { @@ -108,4 +109,4 @@ } ?> - \ No newline at end of file + \ No newline at end of file diff --git a/settings.php b/settings.php index a184c5e..2472809 100644 --- a/settings.php +++ b/settings.php @@ -1,4 +1,4 @@ - + LibreX - Settings @@ -97,4 +97,4 @@ ?> - + \ No newline at end of file diff --git a/static/auto.css b/static/css/auto.css similarity index 100% rename from static/auto.css rename to static/css/auto.css diff --git a/static/dark.css b/static/css/dark.css similarity index 100% rename from static/dark.css rename to static/css/dark.css diff --git a/static/discord.css b/static/css/discord.css similarity index 100% rename from static/discord.css rename to static/css/discord.css diff --git a/static/light.css b/static/css/light.css similarity index 100% rename from static/light.css rename to static/css/light.css diff --git a/static/night_owl.css b/static/css/night_owl.css similarity index 100% rename from static/night_owl.css rename to static/css/night_owl.css diff --git a/static/nord.css b/static/css/nord.css similarity index 100% rename from static/nord.css rename to static/css/nord.css diff --git a/static/styles.css b/static/css/styles.css similarity index 100% rename from static/styles.css rename to static/css/styles.css