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
c1fc15da
Commit
c1fc15da
authored
Jun 16, 2017
by
Dominik Hebeler
Browse files
Anpassungen an der Count Statistik
parent
8f7f8784
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/AdminInterface.php
View file @
c1fc15da
...
...
@@ -82,8 +82,10 @@ class AdminInterface extends Controller
return
$names
;
}
public
function
count
()
public
function
count
(
Request
$request
)
{
$days
=
intval
(
$request
->
input
(
'days'
,
28
));
if
(
!
is_int
(
$days
)
||
$days
<=
0
)
$days
=
28
;
$logToday
=
"mg3.log"
;
if
(
file_exists
(
"/var/log/metager/"
.
$logToday
))
{
$logToday
=
file
(
"/var/log/metager/"
.
$logToday
);
...
...
@@ -96,7 +98,7 @@ class AdminInterface extends Controller
$rekordTagDate
=
""
;
$size
=
0
;
$count
=
0
;
for
(
$i
=
1
;
$i
<=
28
;
$i
++
)
{
for
(
$i
=
1
;
$i
<=
$days
;
$i
++
)
{
$logDate
=
"/var/log/metager/archive/mg3.log.
$i
"
;
if
(
file_exists
(
$logDate
))
{
$sameTime
=
exec
(
"grep -n '"
.
date
(
'H'
)
.
":"
.
date
(
'i'
)
.
":'
$logDate
| tail -1 | cut -f1 -d':'"
);
...
...
@@ -118,13 +120,28 @@ class AdminInterface extends Controller
}
}
return
view
(
'admin.count'
)
->
with
(
'title'
,
'Suchanfragen - MetaGer'
)
->
with
(
'today'
,
number_format
(
floatval
(
sizeof
(
$logToday
)),
0
,
","
,
"."
))
->
with
(
'oldLogs'
,
$oldLogs
)
->
with
(
'rekordCount'
,
number_format
(
floatval
(
$rekordTag
),
0
,
","
,
"."
))
->
with
(
'rekordTagSameTime'
,
number_format
(
floatval
(
$rekordTagSameTime
),
0
,
","
,
"."
))
->
with
(
'rekordDate'
,
$rekordTagDate
);
if
(
$request
->
input
(
'out'
,
'web'
)
===
"web"
){
return
view
(
'admin.count'
)
->
with
(
'title'
,
'Suchanfragen - MetaGer'
)
->
with
(
'today'
,
number_format
(
floatval
(
sizeof
(
$logToday
)),
0
,
","
,
"."
))
->
with
(
'oldLogs'
,
$oldLogs
)
->
with
(
'rekordCount'
,
number_format
(
floatval
(
$rekordTag
),
0
,
","
,
"."
))
->
with
(
'rekordTagSameTime'
,
number_format
(
floatval
(
$rekordTagSameTime
),
0
,
","
,
"."
))
->
with
(
'rekordDate'
,
$rekordTagDate
)
->
with
(
'days'
,
$days
);
}
else
{
$result
=
""
;
foreach
(
$oldLogs
as
$key
=>
$value
){
$result
.
=
'"'
.
date
(
"D, d M y"
,
mktime
(
date
(
"H"
),
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"d"
)
-
$key
,
date
(
"Y"
)))
.
'",'
;
$result
.
=
'"'
.
$value
[
'sameTime'
]
.
'",'
;
$result
.
=
'"'
.
$value
[
'insgesamt'
]
.
'",'
;
$result
.
=
'"'
.
$value
[
'median'
]
.
'"'
.
"
\r\n
"
;
}
return
response
(
$result
,
200
)
->
header
(
'Content-Type'
,
'text/csv'
)
->
header
(
'Content-Disposition'
,
'attachment; filename="count.csv"'
);
}
}
public
function
check
()
{
...
...
app/Http/Middleware/RefererCheck.php
View file @
c1fc15da
...
...
@@ -17,7 +17,7 @@ class RefererCheck
{
$refererCorrect
=
env
(
'referer_check'
);
$referer
=
$request
->
server
(
'HTTP_REFERER'
);
if
(
$refererCorrect
!==
$referer
)
{
if
(
$refererCorrect
!==
$referer
&&
"https://metager.de/admin/count"
!==
$referer
)
{
abort
(
403
,
'Unauthorized'
);
}
else
{
return
$next
(
$request
);
...
...
resources/views/admin/count.blade.php
View file @
c1fc15da
...
...
@@ -4,8 +4,9 @@
@
section
(
'content'
)
<
h2
>
{{
exec
(
"uptime"
)
}}
</
h2
>
<
h2
>
<
table
class
=
"table table-striped"
>
<
caption
>
Daten
der
letzten
Tage
</
caption
>
<
caption
>
Daten
der
letzten
<
form
method
=
"POST"
><
input
type
=
"number"
name
=
"days"
value
=
"
{
{days}
}
"
/>
Tage
<
button
type
=
"submit"
class
=
"btn btn-sm btn-default"
>
Aktualisieren
</
button
><
button
type
=
"submit"
name
=
"out"
value
=
"csv"
class
=
"btn btn-sm btn-default"
>
Als
CSV
exportieren
</
button
></
form
>
</
caption
>
<
tr
>
<
th
>
Datum
</
th
>
<
th
>
Suchanfragen
zur
gleichen
Zeit
</
th
>
...
...
routes/web.php
View file @
c1fc15da
...
...
@@ -129,9 +129,9 @@ Route::group(
Route
::
get
(
'zitat-suche'
,
'ZitatController@zitatSuche'
);
Route
::
group
([
'middleware'
=>
[
'referer.check'
],
'prefix'
=>
'admin'
],
function
()
{
Route
::
group
([
/*
'middleware' => ['referer.check'],
*/
'prefix'
=>
'admin'
],
function
()
{
Route
::
get
(
'/'
,
'AdminInterface@index'
);
Route
::
get
(
'count'
,
'AdminInterface@count'
);
Route
::
match
([
'get'
,
'post'
],
'count'
,
'AdminInterface@count'
);
Route
::
get
(
'check'
,
'AdminInterface@check'
);
Route
::
get
(
'engines'
,
'AdminInterface@engines'
);
});
...
...
Write
Preview
Supports
Markdown
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