diff --git a/metager/app/MetaGer.php b/metager/app/MetaGer.php index 56762787d0ac70f8866ce91c86a8a236ed7a1915..b178a5ff4bccefbd60ac6fa2d3a5a61b5442fc64 100644 --- a/metager/app/MetaGer.php +++ b/metager/app/MetaGer.php @@ -89,17 +89,23 @@ class MetaGer public function __construct($hash = "") { - # Timer starten + # start timer $this->starttime = microtime(true); - # Versuchen Blacklists einzulesen + # Read blocklists if (file_exists(config_path() . "/blacklistDomains.txt") && file_exists(config_path() . "/blacklistUrl.txt")) { $tmp = file_get_contents(config_path() . "/blacklistDomains.txt"); $this->domainsBlacklisted = explode("\n", $tmp); $tmp = file_get_contents(config_path() . "/blacklistUrl.txt"); - $this->urlsBlacklisted = explode("\n", $tmp); + $lines = explode("\n", $tmp); + $filtered_lines = array_filter($lines, function($line) { + return strpos(trim($line), '#') !== 0; + }); + # Re-index the array (array_filter preserves keys by default) + $filtered_lines = array_values($filtered_lines); + $this->urlsBlacklisted = $filtered_lines; } - # Versuchen Blacklists einzulesen + # Read blocklists if (file_exists(config_path() . "/adBlacklistDomains.txt")) { $tmp = file_get_contents(config_path() . "/adBlacklistDomains.txt"); $this->adDomainsBlacklisted = explode("\n", $tmp); diff --git a/metager/app/Models/Result.php b/metager/app/Models/Result.php index 48700a0704aa36b820379e290e7e3371e622c6f0..870525ae4ba2b86874afd42424274057997dc01a 100644 --- a/metager/app/Models/Result.php +++ b/metager/app/Models/Result.php @@ -294,7 +294,10 @@ class Result { if ( ($this->strippedHost !== "" && (in_array($this->strippedHost, $metager->getDomainBlacklist()) || - in_array($this->strippedLink, $metager->getUrlBlacklist()))) + in_array($this->strippedLink, $metager->getUrlBlacklist()) || + in_array($this->strippedLink . "|" . strtolower(app(SearchSettings::class)->q), $metager->getUrlBlacklist()) + ) + ) ) { return true; } else {