diff --git a/app/Http/Controllers/Pictureproxy.php b/app/Http/Controllers/Pictureproxy.php index 45312e78ead26b4110d6f72bbe6f05e0a1cee712..276272e927aa3fa88fe14ee6a956fa0b486790a3 100644 --- a/app/Http/Controllers/Pictureproxy.php +++ b/app/Http/Controllers/Pictureproxy.php @@ -17,8 +17,14 @@ class Pictureproxy extends Controller function get(Request $request) { if( $request->has('url') ) { - try{ - $file = file_get_contents($request->input('url')); + try{ + $arrContextOptions=array( + "ssl"=>array( + "verify_peer"=>false, + "verify_peer_name"=>false, + ), + ); + $file = file_get_contents($request->input('url'), false, stream_context_create($arrContextOptions)); $responseCode = explode(" ", $http_response_header[0])[1]; $contentType = ""; foreach($http_response_header as $header) diff --git a/app/MetaGer.php b/app/MetaGer.php index 9fc916f2783aa1fd54a7b6b37b813462efe2ada4..b17dd113dc7d9f377f377a0bbd341279943787c8 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -259,6 +259,9 @@ class MetaGer //Slice the collection to get the items to display in current page $currentPageSearchResults = $collection->slice($offset * $perPage, $perPage)->all(); + # Für diese 20 Links folgt nun unsere Adgoal Implementation. + $currentPageSearchResults = $this->parseAdgoal($currentPageSearchResults); + //Create our paginator and pass it to the view $paginatedSearchResults= new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage); $paginatedSearchResults->setPath('/meta/meta.ger3'); @@ -287,6 +290,70 @@ class MetaGer } } + public function parseAdgoal($results) + { + $publicKey = getenv('adgoal_public'); + $privateKey = getenv('adgoal_private'); + if( $publicKey === FALSE ) + { + return $results; + } + $tldList = ""; + try{ + foreach($results as $result) + { + $link = $result->anzeigeLink; + if(strpos($link, "http") !== 0) + { + $link = "http://" . $link; + } + $tldList .= parse_url($link, PHP_URL_HOST) . ","; + $result->tld = parse_url($link, PHP_URL_HOST); + } + $tldList = rtrim($tldList, ","); + + # Hashwert + $hash = md5("meta" . $publicKey . $tldList . "GER"); + + # Query + $query = urlencode($this->q); + + $link = "https://api.smartredirect.de/api_v2/CheckForAffiliateUniversalsearchMetager.php?p=" . $publicKey . "&k=" . $hash . "&tld=" . $tldList . "&q=" . $query; + $answer = json_decode(file_get_contents($link)); + + + # Nun müssen wir nur noch die Links für die Advertiser ändern: + foreach($answer as $el) + { + $hoster = $el[0]; + $hash = $el[1]; + + foreach($results as $result) + { + if( $hoster === $result->tld ) + { + # Hier ist ein Advertiser: + # Das Logo hinzufügen: + $result->image = "https://img.smartredirect.de/logos_v2/120x60/" . $hash . ".gif"; + # Den Link hinzufügen: + $publicKey = $publicKey; + $targetUrl = $result->link; + if(strpos($targetUrl, "http") !== 0) + $targetUrl = "http://" . $targetUrl; + $hash = md5($targetUrl . $privateKey); + $newLink = "https://api.smartredirect.de/api_v2/ClickGate.php?p=" . $publicKey . "&k=" . $hash . "&url=" . urlencode($targetUrl) . "&q=" . $query; + $result->link = $newLink; + } + } + } + }catch(\ErrorException $e) + { + return $results; + } + + return $results; + } + public function createSearchEngines (Request $request) { diff --git a/app/Models/Result.php b/app/Models/Result.php index 275a54889578f78145e3d4a4b18b87ae8fc3f54c..c85f14419fccdbd809d5e55cf06ef0a6f80cd1f7 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -28,7 +28,7 @@ class Result $this->sourceRank = 20 - $this->sourceRank; if(isset($provider["engineBoost"])) { - $this->engineBoost = $provider["engineBoost"]; + $this->engineBoost = floatval($provider["engineBoost"]->__toString()); }else { $this->engineBoost = 1; diff --git a/public/css/styleResultPage.css b/public/css/styleResultPage.css index 65fb3116e89ff8dbbf432d2895abb1015723278a..48475f52e3d4d5f3e4fd66ab950df437d83a08f7 100644 --- a/public/css/styleResultPage.css +++ b/public/css/styleResultPage.css @@ -323,11 +323,15 @@ a:hover margin-bottom: 3px; color: black; font-size: 14px; - white-space:pre-wrap; line-height: 1.3; clear: both; } +.result .description img { + margin:5px; + margin-left:0; +} + .result.ad .description { color: green; max-width: 115ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; @@ -362,8 +366,8 @@ a:hover margin-right:2px } -.result .image { - padding:0; +.description-container { + margin:0!important; } .result .image > img{ diff --git a/resources/views/layouts/result.blade.php b/resources/views/layouts/result.blade.php index 6e1e3db689f18dea5f6ee891cad90241230f7b54..a504994ed1fed9705c40a8b2278e3fe7c4e838f7 100644 --- a/resources/views/layouts/result.blade.php +++ b/resources/views/layouts/result.blade.php @@ -2,14 +2,7 @@ <div class="number col-sm-1 hidden-xs" style="color:{{ $result->color }}"> {{ $result->number }}) </div> - @if( $result->image !== "" ) - <div class="image col-xs-2 col-sm-1"> - <img src="{{ $metager->getImageProxyLink($result->image) }}" alt="" /> - </div> - <div class="resultInformation col-xs-10 col-sm-10"> - @else - <div class="resultInformation col-xs-12 col-sm-11"> - @endif + <div class="resultInformation col-xs-12 col-sm-11"> <p class="title"> <a class="title" href="{{ $result->link }}" target="{{ $metager->getTab() }}" data-hoster="{{ strip_tags($result->gefVon) }}" data-count="{{ $result->number }}"> {{ $result->titel }} @@ -65,6 +58,13 @@ anonym öffnen </a> </div> + @if( $result->image !== "" ) + <div class="description"> + <img src="{{ $metager->getImageProxyLink($result->image) }}" align="left" width="120px" height="60px" alt="" /> + {{ $result->descr }} + </div> + @else <div class="description">{{ $result->descr }}</div> + @endif </div> </div> \ No newline at end of file