Skip to content
Snippets Groups Projects
Commit cffb46fa authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '156-confidential-issue' into 'development'

Adgoal eingefügt

Closes #156

See merge request !214
parents 394da0f8 efbaf9a4
No related branches found
No related tags found
1 merge request!1365Resolve "Filter Options for MetaGer"
...@@ -17,8 +17,14 @@ class Pictureproxy extends Controller ...@@ -17,8 +17,14 @@ class Pictureproxy extends Controller
function get(Request $request) { function get(Request $request) {
if( $request->has('url') ) if( $request->has('url') )
{ {
try{ try{
$file = file_get_contents($request->input('url')); $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]; $responseCode = explode(" ", $http_response_header[0])[1];
$contentType = ""; $contentType = "";
foreach($http_response_header as $header) foreach($http_response_header as $header)
......
...@@ -259,6 +259,9 @@ class MetaGer ...@@ -259,6 +259,9 @@ class MetaGer
//Slice the collection to get the items to display in current page //Slice the collection to get the items to display in current page
$currentPageSearchResults = $collection->slice($offset * $perPage, $perPage)->all(); $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 //Create our paginator and pass it to the view
$paginatedSearchResults= new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage); $paginatedSearchResults= new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage);
$paginatedSearchResults->setPath('/meta/meta.ger3'); $paginatedSearchResults->setPath('/meta/meta.ger3');
...@@ -287,6 +290,70 @@ class MetaGer ...@@ -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) public function createSearchEngines (Request $request)
{ {
......
...@@ -28,7 +28,7 @@ class Result ...@@ -28,7 +28,7 @@ class Result
$this->sourceRank = 20 - $this->sourceRank; $this->sourceRank = 20 - $this->sourceRank;
if(isset($provider["engineBoost"])) if(isset($provider["engineBoost"]))
{ {
$this->engineBoost = $provider["engineBoost"]; $this->engineBoost = floatval($provider["engineBoost"]->__toString());
}else }else
{ {
$this->engineBoost = 1; $this->engineBoost = 1;
......
...@@ -323,11 +323,15 @@ a:hover ...@@ -323,11 +323,15 @@ a:hover
margin-bottom: 3px; margin-bottom: 3px;
color: black; color: black;
font-size: 14px; font-size: 14px;
white-space:pre-wrap;
line-height: 1.3; line-height: 1.3;
clear: both; clear: both;
} }
.result .description img {
margin:5px;
margin-left:0;
}
.result.ad .description { .result.ad .description {
color: green; color: green;
max-width: 115ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 115ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
...@@ -362,8 +366,8 @@ a:hover ...@@ -362,8 +366,8 @@ a:hover
margin-right:2px margin-right:2px
} }
.result .image { .description-container {
padding:0; margin:0!important;
} }
.result .image > img{ .result .image > img{
......
...@@ -2,14 +2,7 @@ ...@@ -2,14 +2,7 @@
<div class="number col-sm-1 hidden-xs" style="color:{{ $result->color }}"> <div class="number col-sm-1 hidden-xs" style="color:{{ $result->color }}">
{{ $result->number }}) {{ $result->number }})
</div> </div>
@if( $result->image !== "" ) <div class="resultInformation col-xs-12 col-sm-11">
<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
<p class="title"> <p class="title">
<a class="title" href="{{ $result->link }}" target="{{ $metager->getTab() }}" data-hoster="{{ strip_tags($result->gefVon) }}" data-count="{{ $result->number }}"> <a class="title" href="{{ $result->link }}" target="{{ $metager->getTab() }}" data-hoster="{{ strip_tags($result->gefVon) }}" data-count="{{ $result->number }}">
{{ $result->titel }} {{ $result->titel }}
...@@ -65,6 +58,13 @@ ...@@ -65,6 +58,13 @@
anonym öffnen anonym öffnen
</a> </a>
</div> </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> <div class="description">{{ $result->descr }}</div>
@endif
</div> </div>
</div> </div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment