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
{
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");
if ($focus === "maps") {
......@@ -35,6 +40,10 @@ class MetaGerSearch extends Controller
# Nach Spezialsuchen überprüfen:
$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
$quicktips = $metager->createQuicktips();
......@@ -66,7 +75,14 @@ class MetaGerSearch extends Controller
$pipeline->execute();
# 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)
......
^[\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