From bf837b1dbdba6ff3221efdfd300815ea8717355e Mon Sep 17 00:00:00 2001
From: Dominik Hebeler <dominik@suma-ev.de>
Date: Mon, 11 Jan 2021 15:01:43 +0100
Subject: [PATCH] removed taz logging

---
 app/Console/Commands/AppendLogs.php          | 43 --------------------
 app/Http/Controllers/StartpageController.php | 15 -------
 2 files changed, 58 deletions(-)

diff --git a/app/Console/Commands/AppendLogs.php b/app/Console/Commands/AppendLogs.php
index 5042aca3d..73d24c8fc 100644
--- a/app/Console/Commands/AppendLogs.php
+++ b/app/Console/Commands/AppendLogs.php
@@ -16,7 +16,6 @@ class AppendLogs extends Command
      */
     protected $signature = 'logs:gather';
     const LOGKEY = "metager.logs";
-    const LOGKEYTAZ = "metager.tazlogs";
 
     /**
      * The console command description.
@@ -43,7 +42,6 @@ class AppendLogs extends Command
     public function handle()
     {
         $this->handleMGLogs();
-        $this->handleTazLogs();
     }
 
     private function handleMGLogs()
@@ -76,45 +74,4 @@ class AppendLogs extends Command
             Log::info("Added " . sizeof($elements) . " lines to todays log!");
         }
     }
-
-    private function handleTazLogs()
-    {
-        $redis = null;
-        
-        if (env("REDIS_CACHE_DRIVER", "redis") === "redis") {
-            $redis = Redis::connection('cache');
-        } elseif (env("REDIS_CACHE_DRIVER", "redis") === "redis-sentinel") {
-            $redis = RedisSentinel::connection('cache');
-        }
-        if ($redis === null) {
-            Log::error("No valid Redis Connection specified");
-            return;
-        }
-
-        $elements = [];
-        $reply = $redis->pipeline(function ($pipe) use ($elements) {
-            $pipe->lrange(\App\Console\Commands\AppendLogs::LOGKEYTAZ, 0, -1);
-            $pipe->del(\App\Console\Commands\AppendLogs::LOGKEYTAZ);
-        });
-        $elements = $reply[0];
-        if (!is_array($elements) || sizeof($elements) <= 0) {
-            return;
-        }
-        if (file_put_contents(\App\Console\Commands\AppendLogs::getTazLogFile(), implode(PHP_EOL, $elements) . PHP_EOL, FILE_APPEND) === false) {
-            Log::error("Konnte Log Zeile(n) nicht schreiben");
-            $redis->lpush(\App\Console\Commands\AppendLogs::LOGKEYTAZ, array_reverse($elements));
-        } else {
-            Log::info("Added " . sizeof($elements) . " lines to todays TAZ log!");
-        }
-    }
-
-    public static function getTazLogFile()
-    {
-        $logpath = storage_path("logs/metager/taz/" . date("Y") . "/" . date("m") . "/");
-        if (!file_exists($logpath)) {
-            mkdir($logpath, 0777, true);
-        }
-        $logpath .= date("d") . ".log";
-        return $logpath;
-    }
 }
diff --git a/app/Http/Controllers/StartpageController.php b/app/Http/Controllers/StartpageController.php
index 28701194d..6369c87ad 100644
--- a/app/Http/Controllers/StartpageController.php
+++ b/app/Http/Controllers/StartpageController.php
@@ -44,21 +44,6 @@ class StartpageController extends Controller
             $lang = 'all';
         }
 
-        /**
-         * Logging Requests from Taz advertisement
-         */
-        if ($request->filled("key") && $request->input("key", "") === "taz") {
-            $logEntry = date("H:i:s");
-            $referer = request()->headers->get('referer');
-            $logEntry .= " ref=$referer";
-
-            if (env("REDIS_CACHE_DRIVER", "redis") === "redis") {
-                Redis::connection('cache')->rpush(\App\Console\Commands\AppendLogs::LOGKEYTAZ, $logEntry);
-            } elseif (env("REDIS_CACHE_DRIVER", "redis") === "redis-sentinel") {
-                RedisSentinel::connection('cache')->rpush(\App\Console\Commands\AppendLogs::LOGKEYTAZ, $logEntry);
-            }
-        }
-
         return view('index')
             ->with('title', trans('titles.index'))
             ->with('homeIcon')
-- 
GitLab