diff --git a/app/Http/Controllers/MetaGerSearch.php b/app/Http/Controllers/MetaGerSearch.php index ce8e4595d8cb1367cba84a215aabb09258379405..dbc9c50dd124adf5603732e73754c7ddf1daac07 100644 --- a/app/Http/Controllers/MetaGerSearch.php +++ b/app/Http/Controllers/MetaGerSearch.php @@ -245,11 +245,11 @@ class MetaGerSearch extends Controller $newResults = 0; foreach ($metager->getResults() as $index => $resultTmp) { - if ($resultTmp->new || $resultTmp->adgoalChanged) { + if ($resultTmp->new || $resultTmp->changed) { if ($metager->getFokus() !== "bilder") { $view = View::make('layouts.result', ['index' => $index, 'result' => $resultTmp, 'metager' => $metager]); $html = $view->render(); - if (!$resultTmp->new && $resultTmp->adgoalChanged) { + if (!$resultTmp->new && $resultTmp->changed) { $result['changedResults'][$index] = $html; } else { $result['newResults'][$index] = $html; @@ -258,7 +258,7 @@ class MetaGerSearch extends Controller } else { $view = View::make('layouts.image_result', ['index' => $index, 'result' => $resultTmp, 'metager' => $metager]); $html = $view->render(); - if (!$resultTmp->new && $resultTmp->adgoalChanged) { + if (!$resultTmp->new && $resultTmp->changed) { $result['changedResults'][$index] = $html; } else { $result['newResults'][$index] = $html; diff --git a/app/MetaGer.php b/app/MetaGer.php index fb8dd7677e32b123b256ddeebfd408efb62392fc..c0e1d0487690f3075f28f275c709863c845b7fe5 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -297,6 +297,11 @@ class MetaGer if (!empty($timings)) { $timings["prepareResults"]["validated results"] = microtime(true) - $timings["starttime"]; } + + $this->duplicationCheck(); + if(!empty($timings)){ + $timings["prepareResults"]["duplications checked"] = microtime(true) - $timings["starttime"]; + } # Validate Advertisements $newResults = []; foreach ($this->ads as $ad) { @@ -399,6 +404,42 @@ 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, 1); + $i--; + if($arr[$link]->new === true || $this->results[$i]->new === true){ + $arr[$link]->changed = true; + } + }else{ + $arr[$link] = &$this->results[$i]; + } + } + } + public function startAdgoal(&$results) { $publicKey = getenv('adgoal_public'); @@ -505,7 +546,7 @@ class MetaGer $newLink = "https://api.smartredirect.de/api_v2/ClickGate.php?p=" . urlencode($publicKey) . "&k=" . urlencode($gateHash) . "&url=" . urlencode($targetUrl) . "&q=" . urlencode($query); $result->link = $newLink; $result->partnershop = true; - $result->adgoalChanged = true; + $result->changed = true; } } } diff --git a/app/Models/Result.php b/app/Models/Result.php index 05c2ac78bfb4bf28a9fc959efb188e8de8e26d17..51e69f0cba39432ee99d648aee65fe3abfc982ed 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) @@ -31,7 +31,7 @@ class Result public $strippedLinkAnzeige; # Der Link in Form "foo.bar.de/test" public $rank; # Das Ranking für das Ergebnis public $new = true; - public $adgoalChanged = false; + public $changed = false; # Erstellt ein neues Ergebnis public function __construct($provider, $titel, $link, $anzeigeLink, $descr, $gefVon, $gefVonLink, $sourceRank, $additionalInformation = []) @@ -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/lang/de/result.php b/resources/lang/de/result.php index cc538da4935c5c6ef59b1f8753068bca08d326c2..d491c90dfc622169b219b94eb8a9d04ccc5f1132 100644 --- a/resources/lang/de/result.php +++ b/resources/lang/de/result.php @@ -13,5 +13,6 @@ return [ 'options.more' => 'MEHR', 'options.less' => 'WENIGER', 'gefVon' => 'von', + 'providers' => 'Anbietern', 'proxytext' => 'Der Link wird anonymisiert geöffnet. Ihre Daten werden nicht zum Zielserver übertragen. Möglicherweise funktionieren manche Webseiten nicht wie gewohnt.', ]; diff --git a/resources/lang/en/result.php b/resources/lang/en/result.php index 407f98ed17ecc938418ffe4b2c6a140a6d683b00..53d1b7af253c85e9461ad92dd83e71a7ecc6c30b 100644 --- a/resources/lang/en/result.php +++ b/resources/lang/en/result.php @@ -13,5 +13,6 @@ return [ 'options.more' => 'MORE', 'options.less' => 'LESS', 'gefVon' => 'by', + 'providers' => 'providers', 'proxytext' => 'Result link is opened anonymously. Your data will not be transferred to destination servers. Some webpages may not work as usual.' ]; \ No newline at end of file diff --git a/resources/views/layouts/ad.blade.php b/resources/views/layouts/ad.blade.php index 8f112ca3fc5a7b31047be8b73ee5b747548cc065..f0857daf2d9eb1e4277d0fabbf8d9918d2b9feaf 100644 --- a/resources/views/layouts/ad.blade.php +++ b/resources/views/layouts/ad.blade.php @@ -8,7 +8,7 @@ {{ $ad->titel }} </a> </h2> - <a class="ad-label" href="{{ $ad->gefVonLink }}" target="_blank" rel="noopener">{!! $ad->gefVon !!}</a> + <a class="ad-label" href="{{ $ad->gefVonLink[0] }}" target="_blank" rel="noopener">{!! $ad->gefVon[0] !!}</a> </div> <div class="result-subheadline"> <a class="result-link" href="{{ $ad->link }}" target="{{ $metager->getNewtab() }}" tabindex="-1"> diff --git a/resources/views/layouts/atom10ad.blade.php b/resources/views/layouts/atom10ad.blade.php index d19f7ebddac8a59288ad3dccce7a3c2a9a1850ce..beaa2ba03565db5670b3d7a691367845dd51ca72 100644 --- a/resources/views/layouts/atom10ad.blade.php +++ b/resources/views/layouts/atom10ad.blade.php @@ -1,6 +1,6 @@ @if(isset($ad)) <ad:advertisement> - <ad:callOut type="TEXT">{!! trans('ad.werbung') !!} {!! trans('ad.von') !!} {!! $ad->gefVon !!}</ad:callOut> + <ad:callOut type="TEXT">{!! trans('ad.werbung') !!} {!! trans('ad.von') !!} {!! $ad->gefVon[0] !!}</ad:callOut> <ad:title type="TEXT">{{ $ad->titel }}</ad:title> <ad:displayUrl type="TEXT">{{ $ad->anzeigeLink }}</ad:displayUrl> <ad:subTitle type="TEXT">{{ $ad->descr }}</ad:subTitle> diff --git a/resources/views/layouts/image_result.blade.php b/resources/views/layouts/image_result.blade.php index 01c48941306fc8cd8947e66de1bd64a52cdbf5d5..d9e8a93db999f809c30ae229dfde0b904c9ec5ab 100644 --- a/resources/views/layouts/image_result.blade.php +++ b/resources/views/layouts/image_result.blade.php @@ -2,7 +2,7 @@ <a href="{{ $result->link }}" target="_blank"> <div title="{{ $result->titel }}"> <img src="{{ $metager->getImageProxyLink($result->image)}}" alt="{{ $result->titel }}"/> - <div>{{ $result->gefVon }}</div> + <div>{{ $result->gefVon[0] }}</div> </div> </a> </div> diff --git a/resources/views/layouts/result.blade.php b/resources/views/layouts/result.blade.php index 7ad73ddb914b0d227713b79197ec0396cd1dad55..28cec0e578418805dce4b11d822f60b3a3690a9f 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"> {{ trans('result.gefVon') . " " . sizeof($result->gefVon) . " " . trans('result.providers') }} </span> + @endif </div> <div class="result-subheadline"> <a class="result-link" href="{{ $result->link }}" title="{{ $result->anzeigeLink }}" rel="noopener" tabindex="-1"> diff --git a/resources/views/layouts/rich/ad.blade.php b/resources/views/layouts/rich/ad.blade.php index 1ea4b1dd25df84b2d5c4b2bdd8da0ace3a616917..7db614f4ca949f9af42477fa7df35b8481e86a46 100644 --- a/resources/views/layouts/rich/ad.blade.php +++ b/resources/views/layouts/rich/ad.blade.php @@ -4,7 +4,7 @@ <h1 class="result-title">{{ $result->titel }}</h1> <h2 class="result-display-link"><a href="{{ $result->link }}">{{ $result->anzeigeLink }}</a></h2> <p class="result-description">{{ $result->descr }}</p> - <p class="result-source">Werbung von {!! $result->gefVon !!}</p> + <p class="result-source">Werbung von {!! $result->gefVon[0] !!}</p> @if( isset($result->logo) ) <img class="result-thumbnail" src="{{ $metager->getImageProxyLink($result->logo) }}" alt="" /> @endif diff --git a/resources/views/layouts/rich/result.blade.php b/resources/views/layouts/rich/result.blade.php index da7da6ac9fc56e02d97aed0caf3e41f2bc530193..c5b9d1f28f0f7924a83ec6f8497ed7813c3fc775 100644 --- a/resources/views/layouts/rich/result.blade.php +++ b/resources/views/layouts/rich/result.blade.php @@ -3,7 +3,7 @@ <h1 class="result-title">{{ $result->titel }}</h1> <h2 class="result-display-link"><a href="{{ $result->link }}">{{ $result->anzeigeLink }}</a></h2> <p class="result-description">{{ $result->descr }}</p> - <p class="result-source">gefunden von {!! $result->gefVon !!}</p> + <p class="result-source">gefunden von {!! $result->gefVon[0] !!}</p> @if( isset($result->logo) ) <img class="result-thumbnail" src="{{ $metager->getImageProxyLink($result->logo) }}" alt="" /> @endif