Commit c5890d03 authored by Dominik Hebeler's avatar Dominik Hebeler

implemented stronger caching for possible spam

parent ddb68893
...@@ -16,6 +16,11 @@ class MetaGerSearch extends Controller ...@@ -16,6 +16,11 @@ class MetaGerSearch extends Controller
{ {
public function search(Request $request, MetaGer $metager) public function search(Request $request, MetaGer $metager)
{ {
$spamEntries = [];
if (file_exists(config_path('spam.txt'))) {
$spamEntries = file(config_path('spam.txt'));
}
$focus = $request->input("focus", "web"); $focus = $request->input("focus", "web");
if ($focus === "maps") { if ($focus === "maps") {
...@@ -35,6 +40,10 @@ class MetaGerSearch extends Controller ...@@ -35,6 +40,10 @@ class MetaGerSearch extends Controller
# Nach Spezialsuchen überprüfen: # Nach Spezialsuchen überprüfen:
$metager->checkSpecialSearches($request); $metager->checkSpecialSearches($request);
if (Cache::has('spam.' . $metager->getFokus() . "." . md5($metager->getQ()))) {
return response(Cache::get('spam.' . $metager->getFokus() . "." . md5($metager->getQ())));
}
# Die Quicktips als Job erstellen # Die Quicktips als Job erstellen
$quicktips = $metager->createQuicktips(); $quicktips = $metager->createQuicktips();
...@@ -66,7 +75,14 @@ class MetaGerSearch extends Controller ...@@ -66,7 +75,14 @@ class MetaGerSearch extends Controller
$pipeline->execute(); $pipeline->execute();
# Die Ausgabe erstellen: # Die Ausgabe erstellen:
return $metager->createView($quicktipResults); $resultpage = $metager->createView($quicktipResults);
foreach ($spamEntries as $index => $entry) {
$entry = trim($entry);
if (preg_match("/" . $entry . "/si", $metager->getEingabe())) {
Cache::put('spam.' . $metager->getFokus() . "." . md5($metager->getQ()), $resultpage->render(), 1440);
}
}
return $resultpage;
} }
public function loadMore(Request $request) public function loadMore(Request $request)
......
^[\d]{3}chan
"155chan"
^hebe chan$
^jailbait chan$
^http[s]{0,1}:\/\/[\d]{3}chan\..{2}
^susimail\s+-site:[^\s]+\s-site:
\ 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