added loginLogging - jsonVersion

This commit is contained in:
marko
2021-12-20 16:26:42 +01:00
parent 45fac66184
commit 0abfd49781
2 changed files with 16 additions and 8 deletions

View File

@@ -0,0 +1,7 @@
# Url-Rewriting aktivieren
RewriteEngine on
# Wenn * angefordert wurde und *.php existiert
RewriteCond %{REQUEST_FILENAME}.php -f
# Hänge ein \.php an
RewriteRule ^(.*)$ $1\.php

View File

@@ -36,14 +36,15 @@ function checkCredentials($username, $password, $db_server, $db_user, $db_passwo
$message['success'] = 'Anmeldung erfolgreich, <a href="index.php">weiter zum Inhalt</a>.'; $message['success'] = 'Anmeldung erfolgreich, <a href="index.php">weiter zum Inhalt</a>.';
PHPCount::AddHit("participo-Login-".$_POST['f']['username']); PHPCount::AddHit("participo-Login-".$_POST['f']['username']);
$lastLogins=file("logins.txt"); // Logging Logins
$file = fopen("logins.txt", "w"); $userName = $_SESSION['user']['username'];
fwrite($file, $_POST['f']['username']."\n"); $lastLogins = json_decode(file_get_contents("lastLogins.json"), true);
for ( $i=0;i<30;++$i) if(!array_key_exists($userName, $lastLogins))
{ $lastLogins[$userName] = [];
fwrite($file, $lastLoggins."\n"); if(!array_key_exists('lastLogins', $lastLogins[$userName]))
} $lastLogins[$userName]['lastLogins'] = [];
fclose($file); $lastLogins[$userName]['lastLogins'] = array_merge( array( date('Y-m-d H:i:s') ), $lastLogins[$userName]['lastLogins'] );
file_put_contents("lastLogins.json", json_encode($lastLogins));
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/participo?user=' . $_POST['f']['username']); header('Location: http://' . $_SERVER['HTTP_HOST'] . '/participo?user=' . $_POST['f']['username']);
} else { } else {