Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
cef54e37
Commit
cef54e37
authored
Feb 17, 2020
by
Dominik Hebeler
Browse files
fixed spam.txt
parent
9e116674
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MetaGerSearch.php
View file @
cef54e37
...
...
@@ -20,6 +20,7 @@ class MetaGerSearch extends Controller
}
$time
=
microtime
(
true
);
$spamEntries
=
[];
$spamEntry
=
null
;
if
(
file_exists
(
config_path
(
'spam.txt'
)))
{
$spamEntries
=
file
(
config_path
(
'spam.txt'
));
}
...
...
@@ -37,6 +38,17 @@ class MetaGerSearch extends Controller
return
redirect
(
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
'/'
));
}
foreach
(
$spamEntries
as
$index
=>
$entry
)
{
$entry
=
trim
(
$entry
);
if
(
empty
(
$entry
))
{
continue
;
}
if
(
preg_match
(
"/"
.
$entry
.
"/si"
,
$eingabe
))
{
$spamEntry
=
$entry
;
break
;
}
}
# Mit gelieferte Formulardaten parsen und abspeichern:
$metager
->
parseFormData
(
$request
);
if
(
!
empty
(
$timings
))
{
...
...
@@ -49,8 +61,10 @@ class MetaGerSearch extends Controller
$timings
[
"checkSpecialSearches"
]
=
microtime
(
true
)
-
$time
;
}
if
(
Cache
::
has
(
'spam.'
.
$metager
->
getFokus
()
.
"."
.
md5
(
$metager
->
getQ
())))
{
return
response
(
Cache
::
get
(
'spam.'
.
$metager
->
getFokus
()
.
"."
.
md5
(
$metager
->
getEingabe
())));
if
(
$spamEntry
!==
null
&&
Cache
::
has
(
'spam.'
.
$metager
->
getFokus
()
.
"."
.
md5
(
$spamEntry
)))
{
$responseContent
=
Cache
::
get
(
'spam.'
.
$metager
->
getFokus
()
.
"."
.
md5
(
$spamEntry
));
$responseContent
=
preg_replace
(
'/(name="eingabe"\s+value=")[^"]+/'
,
"$1
$eingabe
"
,
$responseContent
);
return
response
(
$responseContent
);
}
# Die Quicktips als Job erstellen
...
...
@@ -108,15 +122,10 @@ class MetaGerSearch extends Controller
# Die Ausgabe erstellen:
$resultpage
=
$metager
->
createView
(
$quicktipResults
);
foreach
(
$spamEntries
as
$index
=>
$entry
)
{
$entry
=
trim
(
$entry
);
if
(
empty
(
$entry
))
{
continue
;
}
if
(
preg_match
(
"/"
.
$entry
.
"/si"
,
$metager
->
getEingabe
()))
{
Cache
::
put
(
'spam.'
.
$metager
->
getFokus
()
.
"."
.
md5
(
$metager
->
getEingabe
()),
$resultpage
->
render
(),
604800
);
}
if
(
$spamEntry
!==
null
)
{
Cache
::
put
(
'spam.'
.
$metager
->
getFokus
()
.
"."
.
md5
(
$spamEntry
),
$resultpage
->
render
(),
604800
);
}
if
(
!
empty
(
$timings
))
{
$timings
[
"createView"
]
=
microtime
(
true
)
-
$time
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment