Commit efb79016 authored by Davide Aprea's avatar Davide Aprea

added focus awareness

parent 46e1136f
......@@ -61,6 +61,14 @@ class SettingsController extends Controller
}
}
$cookies = Cookie::get();
$blacklist = [];
foreach($cookies as $key => $value){
if(stripos($key, 'blpage') !== false && stripos($key, $fokus) !== false){
$blacklist[$key] = $value;
}
}
return view('settings.index')
->with('title', trans('titles.settings', ['fokus' => $fokusName]))
->with('fokus', $request->input('fokus', ''))
......@@ -69,7 +77,8 @@ class SettingsController extends Controller
->with('sumas', $sumas)
->with('filter', $filters)
->with('settingActive', $settingActive)
->with('url', $url);
->with('url', $url)
->with('blacklist', $blacklist);
}
private function getSumas($fokus)
......@@ -306,7 +315,7 @@ class SettingsController extends Controller
Cookie::queue($cookieName, $blacklist, 0, $cookiePath, null, false, false);
}
}
return redirect($request->input('url', 'https://metager.de'));
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('settings', ["fokus" => $fokus, "url" => $url])));
}
public function deleteBlacklist(Request $request)
......@@ -319,7 +328,7 @@ class SettingsController extends Controller
Cookie::queue($cookieKey, "", 0, $cookiePath, null, false, false);
return redirect($request->input('url', 'https://metager.de'));
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('settings', ["fokus" => $fokus, "url" => $url])));
}
public function clearBlacklist(Request $request)
......@@ -333,11 +342,11 @@ class SettingsController extends Controller
$cookies = Cookie::get();
foreach($cookies as $key => $value){
if(stripos($key, 'blpage') !== false) {
if(stripos($key, 'blpage') !== false && stripos($key, $fokus) !== false) {
Cookie::queue($key, "", 0, $cookiePath, null, false, false);
}
}
return redirect($request->input('url', 'https://metager.de'));
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('settings', ["fokus" => $fokus, "url" => $url])));
}
}
......@@ -1352,14 +1352,13 @@ class MetaGer
$this->hostBlacklist[] = $blacklistString;
}
}
foreach(Cookie::get() as $key => $value){
if(stripos($key, 'blpage') !== false && stripos($value, '*.') === false){
if((stripos($key, 'blpage') !== false) && (stripos($key, $this->fokus) !== false) && (stripos($value, '*.') === false)){
$this->hostBlacklist[] = $value;
}
}
array_unique($this->hostBlacklist);
$this->hostBlacklist = array_unique($this->hostBlacklist);
// print the host blacklist as a user warning
if (sizeof($this->hostBlacklist) > 0) {
......@@ -1395,14 +1394,13 @@ class MetaGer
$this->domainBlacklist[] = substr($blacklistString, strpos($blacklistString, "*.") + 2);
}
}
foreach(Cookie::get() as $key => $value){
if(stripos($key, 'blpage') !== false && stripos($value, '*.') !== false){
if(stripos($key, 'blpage') !== false && stripos($key, $this->fokus) !== false && stripos($value, '*.') !== false){
$this->domainBlacklist[] = $value;
}
}
array_unique($this->domainBlacklist);
$this->domainBlacklist = array_unique($this->domainBlacklist);
// print the domain blacklist as a user warning
if (sizeof($this->domainBlacklist) > 0) {
......
......@@ -94,20 +94,18 @@
<input id="blacklist" name="blacklist" type="text" placeholder="example.com">
<button type="submit" class="btn btn-default">@lang('settings.add')</button>
</form>
@if(!empty(Cookie::get()))
@if(!empty($blacklist))
<form id="deleteentry" action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('deleteBlacklist', ["fokus" => $fokus, "url" => $url])) }}" method="post">
<table>
@foreach(Cookie::get() as $key => $value)
@if(stripos($key, 'blpage') !== false)
<tr>
<td>
{{ $value }}
</td>
<td>
<button type="submit" name="cookieKey" value="{{ $key }}"><i class="fas fa-trash-alt"></i></button>
</td>
</tr>
@endif
@foreach($blacklist as $key => $value)
<tr>
<td>
{{ $value }}
</td>
<td>
<button type="submit" name="cookieKey" value="{{ $key }}"><i class="fas fa-trash-alt"></i></button>
</td>
</tr>
@endforeach
</table>
</form>
......
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