Commit db55785d authored by Phil Höfer's avatar Phil Höfer
Browse files

Merge branch '767-domainauschlusssuche-funktionuckelt-nicht' into 'development'

Resolve "Domainauschlusssuche funktionuckelt nicht"

Closes #767

See merge request !1295
parents 23cda137 bc5fa0ab
...@@ -3,12 +3,12 @@ namespace App; ...@@ -3,12 +3,12 @@ namespace App;
use App; use App;
use Cache; use Cache;
use Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use Jenssegers\Agent\Agent; use Jenssegers\Agent\Agent;
use LaravelLocalization; use LaravelLocalization;
use Log; use Log;
use Carbon;
use Predis\Connection\ConnectionException; use Predis\Connection\ConnectionException;
class MetaGer class MetaGer
...@@ -453,10 +453,11 @@ class MetaGer ...@@ -453,10 +453,11 @@ class MetaGer
return $results; return $results;
} }
public function humanVerification($results){ public function humanVerification($results)
{
# Let's check if we need to implement a redirect for human verification # Let's check if we need to implement a redirect for human verification
if($this->verificationCount > 10){ if ($this->verificationCount > 10) {
foreach($results as $result){ foreach ($results as $result) {
$link = $result->link; $link = $result->link;
$day = Carbon::now()->day; $day = Carbon::now()->day;
$pw = md5($this->verificationId . $day . $link . env("PROXY_PASSWORD")); $pw = md5($this->verificationId . $day . $link . env("PROXY_PASSWORD"));
...@@ -464,7 +465,7 @@ class MetaGer ...@@ -464,7 +465,7 @@ class MetaGer
$result->link = $url; $result->link = $url;
} }
return $results; return $results;
}else{ } else {
return $results; return $results;
} }
} }
...@@ -955,7 +956,7 @@ class MetaGer ...@@ -955,7 +956,7 @@ class MetaGer
} }
# Sucheingabe # Sucheingabe
$this->eingabe = trim($request->input('eingabe', '')); $this->eingabe = trim($request->input('eingabe', ''));
$this->q = $this->eingabe; $this->q = $this->eingabe;
# IP # IP
$this->ip = $request->ip(); $this->ip = $request->ip();
# Unser erster Schritt wird sein, IP-Adresse und USER-Agent zu anonymisieren, damit # Unser erster Schritt wird sein, IP-Adresse und USER-Agent zu anonymisieren, damit
...@@ -1083,19 +1084,37 @@ class MetaGer ...@@ -1083,19 +1084,37 @@ class MetaGer
public function checkSpecialSearches(Request $request) public function checkSpecialSearches(Request $request)
{ {
$this->searchCheckPhrase();
$this->searchCheckSitesearch($request); $this->searchCheckSitesearch($request);
$this->searchCheckHostBlacklist($request); $this->searchCheckHostBlacklist($request);
$this->searchCheckDomainBlacklist($request); $this->searchCheckDomainBlacklist($request);
$this->searchCheckUrlBlacklist(); $this->searchCheckUrlBlacklist();
$this->searchCheckPhrase();
$this->searchCheckStopwords($request); $this->searchCheckStopwords($request);
$this->searchCheckNoSearch(); $this->searchCheckNoSearch();
} }
private function searchCheckPhrase()
{
$p = "";
$tmp = $this->q;
// matches '[... ]"test satz"[ ...]'
while (preg_match("/(^|.*?\s)\"(\S+)\"(\s.*|$)/si", $tmp, $match)) {
$tmp = $match[1] . $match[3];
$this->phrases[] = $match[2];
}
foreach ($this->phrases as $phrase) {
$p .= "\"$phrase\", ";
}
$p = rtrim($p, ", ");
if (sizeof($this->phrases) > 0) {
$this->warnings[] = trans('metaGer.formdata.phrase', ['phrase' => $p]);
}
}
private function searchCheckSitesearch($request) private function searchCheckSitesearch($request)
{ {
// matches '[... ]site:test.de[ ...]' // matches '[... ]site:test.de[ ...]'
while (preg_match("/(^|.+\s)site:(\S+)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.*?\s)site:(\S+)(\s.*|$)/si", $this->q, $match)) {
$this->site = $match[2]; $this->site = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
} }
...@@ -1108,7 +1127,7 @@ class MetaGer ...@@ -1108,7 +1127,7 @@ class MetaGer
private function searchCheckHostBlacklist($request) private function searchCheckHostBlacklist($request)
{ {
// matches '[... ]-site:test.de[ ...]' // matches '[... ]-site:test.de[ ...]'
while (preg_match("/(^|.+\s)-site:([^\s\*]\S*)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.*?\s)-site:([^\*\s]\S*)(\s.*|$)/si", $this->q, $match)) {
$this->hostBlacklist[] = $match[2]; $this->hostBlacklist[] = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
} }
...@@ -1143,7 +1162,7 @@ class MetaGer ...@@ -1143,7 +1162,7 @@ class MetaGer
private function searchCheckDomainBlacklist($request) private function searchCheckDomainBlacklist($request)
{ {
// matches '[... ]-site:*.test.de[ ...]' // matches '[... ]-site:*.test.de[ ...]'
while (preg_match("/(^|.+\s)-site:\*\.(\S+)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.*?\s)-site:(\*\.\S+)(\s.*|$)/si", $this->q, $match)) {
$this->domainBlacklist[] = $match[2]; $this->domainBlacklist[] = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
} }
...@@ -1177,7 +1196,7 @@ class MetaGer ...@@ -1177,7 +1196,7 @@ class MetaGer
private function searchCheckUrlBlacklist() private function searchCheckUrlBlacklist()
{ {
// matches '[... ]-site:*.test.de[ ...]' // matches '[... ]-site:*.test.de[ ...]'
while (preg_match("/(^|.+\s)-url:(\S+)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.*?\s)-url:(\S+)(\s.*|$)/si", $this->q, $match)) {
$this->urlBlacklist[] = $match[2]; $this->urlBlacklist[] = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
} }
...@@ -1195,7 +1214,7 @@ class MetaGer ...@@ -1195,7 +1214,7 @@ class MetaGer
private function searchCheckStopwords($request) private function searchCheckStopwords($request)
{ {
// matches '[... ]-test[ ...]' // matches '[... ]-test[ ...]'
while (preg_match("/(^|[^\s]+\s)-(\S+)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.*?\s)-(\S+)(\s.*|$)/si", $this->q, $match)) {
$this->stopWords[] = $match[2]; $this->stopWords[] = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
} }
...@@ -1224,24 +1243,6 @@ class MetaGer ...@@ -1224,24 +1243,6 @@ class MetaGer
} }
} }
private function searchCheckPhrase()
{
$p = "";
$tmp = $this->q;
// matches '[... ]"test satz"[ ...]'
while (preg_match("/(^|.+\s)\"(.+)\"(?:\s(.+)|($))/si", $tmp, $match)) {
$tmp = $match[1] . $match[3];
$this->phrases[] = $match[2];
}
foreach ($this->phrases as $phrase) {
$p .= "\"$phrase\", ";
}
$p = rtrim($p, ", ");
if (sizeof($this->phrases) > 0) {
$this->warnings[] = trans('metaGer.formdata.phrase', ['phrase' => $p]);
}
}
private function searchCheckNoSearch() private function searchCheckNoSearch()
{ {
if ($this->q === "") { if ($this->q === "") {
......
...@@ -182,6 +182,9 @@ ...@@ -182,6 +182,9 @@
display: none; display: none;
} }
} }
.search-input input {
padding-right: 35px; // Makes it so the overlayed delete button does not hide the text belowF
}
} }
} }
......
Supports Markdown
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