Commit 155cc432 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Skripte für Check & Count hinzugefügt

parent 5c457ce9
......@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
use App\Http\Requests;
use Redis;
use Response;
class AdminInterface extends Controller
{
......@@ -36,9 +37,104 @@ class AdminInterface extends Controller
}
#$data = [ 5 => "majm", 2 => "mngsn", 7 => "akljsd"];
#arsort($data);
return view('admin')
return view('admin.admin')
->with('data', $data)
->with('title', "Admin-Interface-MetaGer")
->with('time', $time);
}
public function count()
{
$logToday = date("Y-m-d", mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))) . "_mg3.log";
if(file_exists("/var/log/metager/".$logToday))
{
$logToday = file("/var/log/metager/".$logToday);
}else
{
return redirect('');
}
$oldLogs = [];
$yesterday = 0;
$rekordTag = 0;
$rekordTagDate = "";
for($i = 1; $i <= 28; $i ++ )
{
$logDate = "/var/log/metager/archive/" . date("Y-m-d", mktime(date("H"),date("i"), date("s"), date("m"), date("d")-$i, date("Y"))) . "_mg3.log";
if( file_exists($logDate) )
{
$sameTime = exec("grep -n '" . date('H') . ":" . date('i') . ":' $logDate | tail -1 | cut -f1 -d':'");
$insgesamt = exec("wc -l $logDate | cut -f1 -d' '");
if($insgesamt > $rekordTag)
{
$rekordTag = $insgesamt;
$rekordTagSameTime = $sameTime;
$rekordTagDate = date("d.m.Y", mktime(date("H"),date("i"), date("s"), date("m"), date("d")-$i, date("Y")));
}
$oldLogs[$i]['sameTime'] = $sameTime;
$oldLogs[$i]['insgesamt'] = $insgesamt;
}
}
$median = [];
# Median für 7 Tage:
$size = 0;
$count = 0;
for($i = 1; $i <= 7; $i++)
{
$count += $oldLogs[$i]['insgesamt'];
$size++;
}
$median[7] = ($count/$size);
# Median für 14 Tage:
$size = 0;
$count = 0;
for($i = 1; $i <= 14; $i++)
{
$count += $oldLogs[$i]['insgesamt'];
$size++;
}
$median[14] = ($count/$size);
# Median für 21 Tage:
$size = 0;
$count = 0;
for($i = 1; $i <= 21; $i++)
{
$count += $oldLogs[$i]['insgesamt'];
$size++;
}
$median[21] = ($count/$size);
# Median für 28 Tage:
$size = 0;
$count = 0;
for($i = 1; $i <= 28; $i++)
{
$count += $oldLogs[$i]['insgesamt'];
$size++;
}
$median[28] = ($count/$size);
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('median', $median);
}
public function check ()
{
$q = "";
$logFile = "/var/log/metager/" . date("Y-m-d", mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))) . "_mg3.log";
if( file_exists($logFile) )
{
$q = exec("tail -n 1 $logFile");
$q = substr($q, strpos($q, "search=")+7);
}
return view('admin.check')
->with('title', 'Wer sucht was? - MetaGer')
->with('q', $q);
}
}
......@@ -115,6 +115,8 @@
});
Route::get('admin', 'AdminInterface@index');
Route::get('admin/count', 'AdminInterface@count');
Route::get('admin/check', 'AdminInterface@check');
Route::get('settings', 'StartpageController@loadSettings');
......
@extends('layouts.subPages')
@section('title', $title )
@section('content')
<h1>Die letzte durchgeführte Suchanfrage bei MetaGer war:</h1>
<h2><span class="text-danger">{{ $q }}</span></h2>
<h3>Die gleiche Suche auf <a href="{{ action('MetaGerSearch@search') }}?eingabe={{ urlencode($q) }}&encoding=utf8&focus=web&lang=all" target="_blank">MetaGer</a>, oder <a href="https://www.google.de/?gws_rd=ssl#q={{ urlencode($q) }}" target="_blank">Google</a> durchführen.</h3>
@endsection
\ No newline at end of file
@extends('layouts.subPages')
@section('title', $title )
@section('content')
<h2>{{ date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))) }}</h2>
<h3>Heute haben wir bis jetzt => <span class="text-info">{{ $today }}</span> Abfragen</h3>
<h3>Gestern zur gleichen Zeit <span class="text-info">{{ $oldLogs[1]['sameTime'] }}</span> - insgesamt <span class="text-danger">{{ $oldLogs[1]['insgesamt'] }}</span></h3>
<h3>Vorgestern zur gleichen Zeit <span class="text-info">{{ $oldLogs[2]['sameTime'] }}</span> - insgesamt <span class="text-danger">{{ $oldLogs[2]['insgesamt'] }}</span></h3>
<h3>Vorvorgestern zur gleichen Zeit <span class="text-info">{{ $oldLogs[3]['sameTime'] }}</span> - insgesamt <span class="text-danger">{{ $oldLogs[3]['insgesamt'] }}</span></h3>
<ul class="list-unstyled" style="text-align:left;">
@foreach($median as $time => $value)
<li><h4>Mittelwert der letzten {{ $time }} Tage: <span class="text-danger">{{ number_format($value, 0, ",", ".") }}</span> Abfragen pro Tag</h4></li>
@endforeach
</ul>
<h3>Rekord am {{ $rekordDate }} zur gleichen Zeit <span class="text-info">{{ $rekordTagSameTime }}</span> - insgesamt <span class="text-danger">{{ $rekordCount }}</span></h3>
@endsection
\ 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