diff --git a/app/MetaGer.php b/app/MetaGer.php index 84dbfe0586e33e59f4aeb241c53a633dafdca67d..958a95f5be11ac7aa6a6ee2d856a21f329ae105c 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -293,6 +293,7 @@ class MetaGer if(!empty($timings)){ $timings["prepareResults"]["validated results"] = microtime(true) - $timings["starttime"]; } + $this->duplicationCheck(); # Validate Advertisements $newResults = []; foreach ($this->ads as $ad) { @@ -395,6 +396,39 @@ class MetaGer } } + public function duplicationCheck() + { + $arr = []; + for($i = 0; $i < count($this->results); $i++) { + + $link = $this->results[$i]->link; + + if (strpos($link, "http://") === 0) { + $link = substr($link, 7); + } + + if (strpos($link, "https://") === 0) { + $link = substr($link, 8); + } + + if (strpos($link, "www.") === 0) { + $link = substr($link, 4); + } + + $link = trim($link, "/"); + $hash = md5($link); + + if(isset($arr[$link])){ + $arr[$link]->gefVon[] = $this->results[$i]->gefVon[0]; + $arr[$link]->gefVonLink[] = $this->results[$i]->gefVonLink[0]; + array_splice($this->results, $i); + $i--; + }else{ + $arr[$link] = &$this->results[$i]; + } + } + } + public function startAdgoal(&$results) { $publicKey = getenv('adgoal_public'); diff --git a/app/Models/Result.php b/app/Models/Result.php index 05c2ac78bfb4bf28a9fc959efb188e8de8e26d17..e917a4387f733ce39941b57a02b6c2b3ada29edc 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -13,8 +13,8 @@ class Result public $anzeigeLink; # Der tatsächlich angezeigte Link (rein optisch) public $descr; # Die eventuell gekürzte Beschreibung des Suchergebnisses public $longDescr; # Die ungekürzte Beschreibung des Suchergebnisses - public $gefVon; # Die Suchmaschine von der dieses Ergebnis stammt - public $gefVonLink; + public $gefVon = []; # Die Suchmaschine von der dieses Ergebnis stammt + public $gefVonLink = []; public $sourceRank; # Das Ranking für dieses Suchergebnis von der Seite, die es geliefert hat (implizit durch Ergebnisreihenfolge: 20 - Position in Ergebnisliste) public $partnershop; # Ist das Ergebnis von einem Partnershop? (bool) public $image; # Ein Vorschaubild für das Suchergebnis (als URL) @@ -49,8 +49,8 @@ class Result $this->descr = substr($this->descr, 0, strpos($this->descr, "\n")); $this->descr .= "…"; // Ellipsis character } - $this->gefVon = trim($gefVon); - $this->gefVonLink = trim($gefVonLink); + $this->gefVon[] = trim($gefVon); + $this->gefVonLink[] = trim($gefVonLink); $this->proxyLink = $this->generateProxyLink($this->link); $this->sourceRank = $sourceRank; if ($this->sourceRank <= 0 || $this->sourceRank > 20) { @@ -115,7 +115,7 @@ class Result } # Runter Ranken von Yandex Ergebnissen mit zu viel kyrillischen Texten - if (stripos($this->gefVon, "yandex") !== false) { + if (stripos($this->gefVon[0], "yandex") !== false) { $rank -= $this->calcYandexBoost($eingabe); } @@ -279,7 +279,7 @@ class Result /* Der Dublettenfilter, der sicher stellt, * dass wir nach Möglichkeit keinen Link doppelt in der Ergebnisliste haben. - */ + $dublettenLink = $this->strippedLink; if (!empty($this->provider->{"dubletten-include-parameter"}) && sizeof($this->provider->{"dubletten-include-parameter"}) > 0) { $dublettenLink .= "?"; @@ -300,12 +300,13 @@ class Result } } - if ($metager->addLink($dublettenLink)) { + if ($metager->addLink($this)) { $metager->addHostCount($this->strippedHost); return true; } else { return false; - } + }*/ + return true; } public function isBlackListed(\App\MetaGer $metager) diff --git a/resources/views/layouts/result.blade.php b/resources/views/layouts/result.blade.php index 04c53ea16b3cc83fe47b59f84a7f122639bd1c35..125f1bd7ddf866c34e363d8601fce5ebccfb40cb 100644 --- a/resources/views/layouts/result.blade.php +++ b/resources/views/layouts/result.blade.php @@ -9,7 +9,11 @@ {!! $result->titel !!} </a> </h2> - <a class="result-hoster" href="{{ $result->gefVonLink }}" target="{{ $metager->getNewtab() }}" rel="noopener" tabindex="-1">{{ trans('result.gefVon') . " " . $result->gefVon }} </a> + @if(sizeof($result->gefVon)===1) + <a class="result-hoster" href="{{ $result->gefVonLink[0] }}" target="{{ $metager->getNewtab() }}" rel="noopener" tabindex="-1">{{ trans('result.gefVon') . " " . $result->gefVon[0] }} </a> + @else + <span title="{{ (implode(', ', $result->gefVon)) }}" class="result-hoster">von {{ sizeof($result->gefVon) }} Anbietern</span> + @endif </div> <div class="result-subheadline"> <a class="result-link" href="{{ $result->link }}" target="{{ $metager->getNewtab() }}" title="{{ $result->anzeigeLink }}" rel="noopener" tabindex="-1">