Commit 2f713eac authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Adgoal eingefügt

parent b7125fa5
......@@ -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)
......
......@@ -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)
{
......
......@@ -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;
......
......@@ -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{
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment