From 05b1548ddc6812e21271382f03cef1e2880ddfd9 Mon Sep 17 00:00:00 2001
From: Dominik Hebeler <dominik@suma-ev.de>
Date: Wed, 20 Feb 2019 10:19:01 +0100
Subject: [PATCH] Changed link target for Uni Mainz

---
 app/MetaGer.php                          | 23 ++++-------------------
 resources/views/layouts/result.blade.php |  6 +++---
 2 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/app/MetaGer.php b/app/MetaGer.php
index f1eca712b..54d219621 100644
--- a/app/MetaGer.php
+++ b/app/MetaGer.php
@@ -308,10 +308,6 @@ class MetaGer
 
         }
 
-        if ($this->validated) {
-            $this->ads = [];
-        }
-
         if (count($this->results) <= 0) {
             if (strlen($this->site) > 0) {
                 $no_sitesearch_query = str_replace(urlencode("site:" . $this->site), "", $this->fullUrl);
@@ -978,12 +974,15 @@ class MetaGer
             $this->sprueche = false;
         }
 
-        $this->newtab = $request->input('newtab', 'on');
+        $this->newtab = $request->input('newtab', 'off');
         if ($this->newtab === "on") {
             $this->newtab = "_blank";
         } else {
             $this->newtab = "_self";
         }
+        if ($request->filled("key") && $request->input('key') === getenv("mainz_key")) {
+            $this->newtab = "_top";
+        }
         # Theme
         $this->theme = preg_replace("/[^[:alnum:][:space:]]/u", '', $request->input('theme', 'default'));
         # Ergebnisse pro Seite:
@@ -1025,20 +1024,6 @@ class MetaGer
         // Remove Inputs that are not used
         $this->request = $request->replace($request->except(['verification_id', 'uid', 'verification_count']));
 
-        $this->validated = false;
-        if (isset($this->password)) {
-            # Wir bieten einen bezahlten API-Zugriff an, bei dem dementsprechend die Werbung ausgeblendet wurde:
-            # Aktuell ist es nur die Uni-Mainz. Deshalb überprüfen wir auch nur diese.
-            $password = getenv('mainz');
-            $passwordBerlin = getenv('berlin');
-            $eingabe = $this->eingabe;
-            $password = md5($eingabe . $password);
-            $passwordBerlin = md5($eingabe . $passwordBerlin);
-            if ($this->password === $password || $this->password === $passwordBerlin) {
-                $this->validated = true;
-            }
-        }
-
         $this->out = $request->input('out', "html");
         # Standard output format html
         if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style" && $this->out !== "result-count" && $this->out !== "rss20" && $this->out !== "atom10" && $this->out !== "rich" && $this->out !== "api") {
diff --git a/resources/views/layouts/result.blade.php b/resources/views/layouts/result.blade.php
index 695e7a685..9e5639a7c 100644
--- a/resources/views/layouts/result.blade.php
+++ b/resources/views/layouts/result.blade.php
@@ -15,7 +15,7 @@
 			<a class="result-hoster" href="{{ $result->gefVonLink }}" target="{{ $metager->getNewtab() }}" rel="noopener">{{ $result->gefVon }}</a>
 		</div>
 		<div class="result-subheadline">
-			<a class="result-link" href="{{ $result->link }}" rel="noopener">
+			<a class="result-link" href="{{ $result->link }}" target="{{ $metager->getNewtab() }}" rel="noopener">
 				{{ $result->anzeigeLink }}
 			</a>
 			@if( isset($result->partnershop) && $result->partnershop === TRUE)
@@ -28,14 +28,14 @@
 	<div class="result-body">
 		@if( isset($result->logo) )
 			<div class="result-logo">
-				<a href="{{ $result->link }}" rel="noopener">
+				<a href="{{ $result->link }}" target="{{ $metager->getNewtab() }}" rel="noopener">
 					<img src="{{ $metager->getImageProxyLink($result->logo) }}" alt="" />
 				</a>
 			</div>
 		@endif
 		@if( $result->image !== "" )
 			<div class="result-image">
-				<a href="{{ $result->link }}" rel="noopener">
+				<a href="{{ $result->link }}" target="{{ $metager->getNewtab() }}" rel="noopener">
 					<img src="{{ $metager->getImageProxyLink($result->image) }}" align="left" width="120px" height="60px" alt="" />
 				</a>
 			</div>
-- 
GitLab