diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df9225a187abd80797c6ed7609ad840bbcde2972..4ac272802aa9967f58cf1476844e94ab6fed3f95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,6 +51,39 @@ prepare_secrets: - cp $SPAM config/spam.txt - cp $USERSSEEDER database/seeds/UsersSeeder.php - cp database/useragents.sqlite.example database/useragents.sqlite + - sed -i 's/^APP_ENV=.*/APP_ENV=production/g' .env + - sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env + artifacts: + paths: + - .env + - config/sumas.json + - config/sumasEn.json + - config/blacklistUrl.txt + - config/blacklistDomains.txt + - config/adBlacklistUrl.txt + - config/adBlacklistDomains.txt + - config/spam.txt + - database/seeds/UsersSeeder.php + - database/useragents.sqlite + only: + refs: + - master + +prepare_secrets: + stage: prepare + image: alpine:latest + script: + - cp $ENVFILE .env + - cp $SUMAS config/sumas.json + - cp $SUMASEN config/sumasEn.json + - cp $BLACKLISTURL config/blacklistUrl.txt + - cp $BLACKLISTDOMAINS config/blacklistDomains.txt + - cp $ADBLACKLISTURL config/adBlacklistUrl.txt + - cp $ADBLACKLISTDOMAINS config/adBlacklistDomains.txt + - cp $SPAM config/spam.txt + - cp $USERSSEEDER database/seeds/UsersSeeder.php + - cp database/useragents.sqlite.example database/useragents.sqlite + - sed -i 's/^APP_ENV=.*/APP_ENV=development/g' .env - sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env artifacts: paths: @@ -67,6 +100,9 @@ prepare_secrets: only: - branches - tags + except: + refs: + - master prepare_node: stage: prepare @@ -163,4 +199,4 @@ production: HELM_UPGRADE_VALUES_FILE: .gitlab/production-values.yaml ROLLOUT_RESOURCE_TYPE: deployment environment: - url: https://metager.de \ No newline at end of file + url: https://metager.de diff --git a/app/Http/Controllers/AdminInterface.php b/app/Http/Controllers/AdminInterface.php index 4cbd7e9adbd43d5887de8d0e3ff1b86644c2ef93..63e4b7d71f4a6b4f53a0ba60b542cd878c842674 100644 --- a/app/Http/Controllers/AdminInterface.php +++ b/app/Http/Controllers/AdminInterface.php @@ -144,11 +144,6 @@ class AdminInterface extends Controller $size = 0; $count = 0; - $now = Carbon::now()->subMinutes(Carbon::now()->minute % 5)->format('H:i'); - if ($now === "00:00") { - $now = "00:05"; - } - foreach ($logs as $key => $stats) { if ($key === 0) { // Log for today @@ -156,7 +151,16 @@ class AdminInterface extends Controller continue; } $insgesamt = empty($stats->insgesamt->{$interface}) ? 0 : $stats->insgesamt->{$interface}; - $sameTime = empty($stats->time->{$now}->{$interface}) ? 0 : $stats->time->{$now}->{$interface}; + $sameTime = 0; + $now = Carbon::now(); + $now->hour = 0; + $now->minute = 0; + $now->second = 0; + + while($now->lessThanOrEqualTo(Carbon::now())){ + $sameTime += empty($stats->time->{$now->format('H:i')}->{$interface}) ? 0 : $stats->time->{$now->format('H:i')}->{$interface}; + $now->addMinutes(5); + } if ($insgesamt > $rekordTag) { $rekordTag = $insgesamt; diff --git a/app/Http/Controllers/StartpageController.php b/app/Http/Controllers/StartpageController.php index 21eca379ec0d9e17ae55c32e4804ff83b9f43764..e2763fd434d6a5cfba978c95075e6f9b78933dd9 100644 --- a/app/Http/Controllers/StartpageController.php +++ b/app/Http/Controllers/StartpageController.php @@ -83,7 +83,6 @@ class StartpageController extends Controller $response = Response::make( view('plugin') ->with('link', $link) - ->with('hostname', gethostname()) , "200"); $response->header('Content-Type', "application/opensearchdescription+xml"); return $response; diff --git a/app/Jobs/ConvertCountFile.php b/app/Jobs/ConvertCountFile.php index bdab84173eeea32572d3159bc948fabb99d963e0..3813381e3c5cb6b22784f9a17d7a0dc88abe9625 100644 --- a/app/Jobs/ConvertCountFile.php +++ b/app/Jobs/ConvertCountFile.php @@ -43,28 +43,37 @@ class ConvertCountFile implements ShouldQueue try { $fh = fopen($this->files["logFile"], "r"); $currentLogTime = Carbon::now()->hour(0)->minute(0)->second(0)->addMinutes(5); - while ($fh !== false && ($line = fgets($fh)) !== false) { $logTime = []; $interface = ""; // i.e. [Wed Apr 17 00:00:01] ref=https://metager.de/ time=0.51 serv=web interface=de if (preg_match('/(\d{2}:\d{2}:\d{2}).*?\sinterface=(\S+)/', $line, $matches)) { // Create Date Object - $logTime = explode(":", $matches[1]); + $logTime = $matches[1]; $interface = $matches[2]; - } else if (preg_match('/\[[a-zA-z]{3},\s\d{2}\s[a-zA-Z]{3}\s\d{2}\s(\d{2}:\d{2}:\d{2})/', $line, $matches)) { - $logTime = explode(":", $matches[1]); - } else if (preg_match('/\[\d{2}\/\d{2}\/\d{4}:(\d{2}:\d{2}:\d{2})/', $line, $matches)) { - $logTime = explode(":", $matches[1]); } else { continue; } + $thatTime = \DateTime::createFromFormat('H:i:s', $logTime); + $thatTime->sub(new \DateInterval("PT" . ($thatTime->format('i') % 5) . "M")); - while (!$fullRound && ((intval($logTime[0]) * 60) + intval($logTime[1])) > (($currentLogTime->hour * 60) + $currentLogTime->minute)) { - $result["time"][$currentLogTime->format('H:i')] = $result["insgesamt"]; - $currentLogTime->addMinutes(5); - if ($currentLogTime->hour === 0 && $currentLogTime->minute === 0) { - $fullRound = true; + if(empty($result["time"][$thatTime->format('H:i')])){ + $result["time"][$thatTime->format('H:i')] = [ + "insgesamt" => [ + "all" => 0, + ], + ]; + } + if(empty($result["time"][$thatTime->format('H:i')]["all"])){ + $result["time"][$thatTime->format('H:i')]["all"] = 1; + }else{ + $result["time"][$thatTime->format('H:i')]["all"]++; + } + if (!empty($interface)) { + if(empty($result["time"][$thatTime->format('H:i')][$interface])){ + $result["time"][$thatTime->format('H:i')][$interface] = 1; + }else{ + $result["time"][$thatTime->format('H:i')][$interface]++; } } // Update the total statistics @@ -81,10 +90,6 @@ class ConvertCountFile implements ShouldQueue } } } - - if (empty($result["time"][$currentLogTime->format('H:i')])) { - $result["time"][$currentLogTime->format('H:i')] = $result["insgesamt"]; - } } catch (\ErrorException $e) { $error = true; } finally { diff --git a/resources/views/plugin.blade.php b/resources/views/plugin.blade.php index cf85ddec5c244a319e52eb41fb9b42f575fcf512..12ea7e01562f019ad36f31e8f0ed1d21d382b2cb 100644 --- a/resources/views/plugin.blade.php +++ b/resources/views/plugin.blade.php @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" ?> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> - <ShortName>MetaGer ({{ $hostname }})</ShortName> + <ShortName>@if(env('APP_ENV', '') === "production") MetaGer @else MetaGer (Entwicklungsversion) @endif</ShortName> <Description>{{ trans('plugin.description') }}</Description> <Contact>office@suma-ev.de</Contact> <Image width="16" height="16" type="image/x-icon">{{ url('/favicon.ico') }}</Image>