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>.';
PHPCount::AddHit("participo-Login-".$_POST['f']['username']);
$lastLogins=file("logins.txt");
$file = fopen("logins.txt", "w");
fwrite($file, $_POST['f']['username']."\n");
for ( $i=0;i<30;++$i)
{
fwrite($file, $lastLoggins."\n");
}
fclose($file);
// Logging Logins
$userName = $_SESSION['user']['username'];
$lastLogins = json_decode(file_get_contents("lastLogins.json"), true);
if(!array_key_exists($userName, $lastLogins))
$lastLogins[$userName] = [];
if(!array_key_exists('lastLogins', $lastLogins[$userName]))
$lastLogins[$userName]['lastLogins'] = [];
$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']);
} else {