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
7cadc449
Commit
7cadc449
authored
Jun 09, 2016
by
Dominik Hebeler
Browse files
Logs für eine durchgeführte MetaGer-Suche eingebaut. Diese wird im Redis-System hinterlegt
parent
8d0604bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/MetaGer.php
View file @
7cadc449
...
@@ -7,6 +7,7 @@ use App;
...
@@ -7,6 +7,7 @@ use App;
use
Storage
;
use
Storage
;
use
Log
;
use
Log
;
use
Config
;
use
Config
;
use
Redis
;
use
App\lib\TextLanguageDetect\TextLanguageDetect
;
use
App\lib\TextLanguageDetect\TextLanguageDetect
;
use
App\lib\TextLanguageDetect\LanguageDetect\TextLanguageDetectException
;
use
App\lib\TextLanguageDetect\LanguageDetect\TextLanguageDetectException
;
use
Illuminate\Pagination\LengthAwarePaginator
;
use
Illuminate\Pagination\LengthAwarePaginator
;
...
@@ -50,7 +51,7 @@ class MetaGer
...
@@ -50,7 +51,7 @@ class MetaGer
function
__construct
()
function
__construct
()
{
{
$this
->
time
=
microtime
();
$this
->
start
time
=
microtime
(
true
);
define
(
'CRLF'
,
"
\r\n
"
);
define
(
'CRLF'
,
"
\r\n
"
);
define
(
'BUFFER_LENGTH'
,
8192
);
define
(
'BUFFER_LENGTH'
,
8192
);
if
(
file_exists
(
config_path
()
.
"/blacklistDomains.txt"
)
&&
file_exists
(
config_path
()
.
"/blacklistUrl.txt"
)
)
if
(
file_exists
(
config_path
()
.
"/blacklistDomains.txt"
)
&&
file_exists
(
config_path
()
.
"/blacklistUrl.txt"
)
)
...
@@ -87,6 +88,9 @@ class MetaGer
...
@@ -87,6 +88,9 @@ class MetaGer
$viewResults
[]
=
get_object_vars
(
$result
);
$viewResults
[]
=
get_object_vars
(
$result
);
}
}
# Wir müssen natürlich noch den Log für die durchgeführte Suche schreiben:
$this
->
createLogs
();
if
(
$this
->
fokus
===
"bilder"
)
if
(
$this
->
fokus
===
"bilder"
)
{
{
switch
(
$this
->
out
)
switch
(
$this
->
out
)
...
@@ -141,6 +145,36 @@ class MetaGer
...
@@ -141,6 +145,36 @@ class MetaGer
}
}
}
}
private
function
createLogs
()
{
$redis
=
Redis
::
connection
(
'redisLogs'
);
if
(
$redis
)
{
$logEntry
=
""
;
$logEntry
.
=
"["
.
date
(
DATE_RFC822
,
mktime
(
date
(
"H"
),
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"d"
),
date
(
"Y"
)))
.
"]"
;
$logEntry
.
=
" From="
.
$this
->
ip
;
$logEntry
.
=
" pid="
.
getmypid
();
$anonId
=
md5
(
"MySeCrEtSeEdFoRmd5"
.
$this
->
request
->
header
(
'Accept'
)
.
$this
->
request
->
header
(
'Accept-Charset'
)
.
$this
->
request
->
header
(
'Accept-Encoding'
)
.
$this
->
request
->
header
(
'HTTP_LANGUAGE'
)
.
$this
->
request
->
header
(
'User-Agent'
)
.
$this
->
request
->
header
(
'Keep-Alive'
)
.
$this
->
request
->
header
(
'X-Forwarded-For'
));
$logEntry
.
=
" anonId=
$anonId
"
;
$logEntry
.
=
" ref="
.
$this
->
request
->
header
(
'Referer'
);
$useragent
=
$this
->
request
->
header
(
'User-Agent'
);
$useragent
=
str_replace
(
"("
,
" "
,
$useragent
);
$useragent
=
str_replace
(
")"
,
" "
,
$useragent
);
$useragent
=
str_replace
(
" "
,
""
,
$useragent
);
$logEntry
.
=
" ua="
.
$useragent
;
$logEntry
.
=
" iter= mm= time="
.
round
((
microtime
(
true
)
-
$this
->
starttime
),
2
)
.
" serv="
.
$this
->
fokus
.
" which= hits= stringSearch= QuickTips= SSS= check="
;
$logEntry
.
=
" search="
.
$this
->
eingabe
;
$redis
->
rpush
(
'logs.search'
,
$logEntry
);
}
}
public
function
removeInvalids
()
public
function
removeInvalids
()
{
{
$results
=
[];
$results
=
[];
...
@@ -432,13 +466,8 @@ class MetaGer
...
@@ -432,13 +466,8 @@ class MetaGer
$this
->
q
=
$this
->
eingabe
;
$this
->
q
=
$this
->
eingabe
;
# IP:
# IP:
if
(
isset
(
$_SERVER
[
'HTTP_FROM'
])
)
$this
->
ip
=
$request
->
ip
();
{
$this
->
ip
=
$_SERVER
[
'HTTP_FROM'
];
}
else
{
$this
->
ip
=
"127.0.0.1"
;
}
# Language:
# Language:
if
(
isset
(
$_SERVER
[
'HTTP_LANGUAGE'
])
)
if
(
isset
(
$_SERVER
[
'HTTP_LANGUAGE'
])
)
{
{
...
...
config/database.php
View file @
7cadc449
...
@@ -114,6 +114,12 @@ return [
...
@@ -114,6 +114,12 @@ return [
'port'
=>
env
(
'REDIS_PORT'
,
6379
),
'port'
=>
env
(
'REDIS_PORT'
,
6379
),
'database'
=>
0
,
'database'
=>
0
,
],
],
'redisLogs'
=>
[
'host'
=>
env
(
'REDIS_LOGS_HOST'
,
'localhost'
),
'password'
=>
env
(
'REDIS_LOGS_PASSWORD'
,
null
),
'port'
=>
env
(
'REDIS_MAIN_PORT'
,
6379
),
'database'
=>
1
,
],
],
],
...
...
resources/views/layouts/resultPage.blade.php
View file @
7cadc449
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<body
id=
"resultBody"
>
<body
id=
"resultBody"
>
@if( isset($header) )
@if(
!
isset($
suspend
header) )
@include('layouts.researchandtabs')
@include('layouts.researchandtabs')
@else
@else
<div
class=
"tab-content container-fluid"
>
<div
class=
"tab-content container-fluid"
>
...
...
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