Commit 9cfd4c2a authored by Dominik Hebeler's avatar Dominik Hebeler

Logs für eine durchgeführte MetaGer-Suche eingebaut. Diese wird im Redis-System hinterlegt

parent fed7821a
......@@ -7,6 +7,7 @@ use App;
use Storage;
use Log;
use Config;
use Redis;
use App\lib\TextLanguageDetect\TextLanguageDetect;
use App\lib\TextLanguageDetect\LanguageDetect\TextLanguageDetectException;
use Illuminate\Pagination\LengthAwarePaginator;
......@@ -50,7 +51,7 @@ class MetaGer
function __construct()
{
$this->time = microtime();
$this->starttime = microtime(true);
define('CRLF', "\r\n");
define('BUFFER_LENGTH', 8192);
if( file_exists(config_path() . "/blacklistDomains.txt") && file_exists(config_path() . "/blacklistUrl.txt") )
......@@ -87,6 +88,9 @@ class MetaGer
$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" )
{
switch ($this->out)
......@@ -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 ()
{
$results = [];
......@@ -432,13 +466,8 @@ class MetaGer
$this->q = $this->eingabe;
# IP:
if( isset($_SERVER['HTTP_FROM']) )
{
$this->ip = $_SERVER['HTTP_FROM'];
}else
{
$this->ip = "127.0.0.1";
}
$this->ip = $request->ip();
# Language:
if( isset($_SERVER['HTTP_LANGUAGE']) )
{
......
......@@ -114,6 +114,12 @@ return [
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
'redisLogs' => [
'host' => env('REDIS_LOGS_HOST', 'localhost'),
'password' => env('REDIS_LOGS_PASSWORD', null),
'port' => env('REDIS_MAIN_PORT', 6379),
'database' => 1,
],
],
......
......@@ -19,7 +19,7 @@
<body id="resultBody">
@if( isset($header) )
@if( !isset($suspendheader) )
@include('layouts.researchandtabs')
@else
<div class="tab-content container-fluid">
......
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