Skip to content
Snippets Groups Projects
Commit b2dc6d64 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch 'development' into 'master'

Development

See merge request !1568
parents 22f74181 b047ee06
No related branches found
No related tags found
3 merge requests!1645Development,!1641Development,!1568Development
......@@ -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
......@@ -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;
......
......@@ -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;
......
......@@ -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 {
......
<?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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment