From a8ccf60181373b68ca8bb77ca45f879e1aea9c0b Mon Sep 17 00:00:00 2001
From: maddinxx <maddinxx@ispconfig3>
Date: Wed, 15 Aug 2012 05:22:04 -0400
Subject: [PATCH] auth.log e.g. for fail2ban - install: touch auth.log - login: write success/fail to auth.log - cron: log rotation for auth.log
---
interface/web/login/index.php | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/interface/web/login/index.php b/interface/web/login/index.php
index c2cbe62..458f77a 100644
--- a/interface/web/login/index.php
+++ b/interface/web/login/index.php
@@ -78,7 +78,6 @@
$passwort = $app->db->quote($_POST['passwort']);
$loginAs = false;
$time = time();
- $logging = 'Failed login for user '. $username .' from '. long2ip($ip) .' at '. date('Y-m-d H:i:s');
if($username != '' && $passwort != '' && $error == '') {
/*
@@ -200,6 +199,12 @@
$app->plugin->raiseEvent('login',$this);
+ //* Save successfull login message to var
+ $authlog = 'Successful login for user \''. $username .'\' from '. long2ip($ip) .' at '. date('Y-m-d H:i:s');
+ $authlog_handle = fopen($conf['ispconfig_log_dir'].'/auth.log', 'a');
+ fwrite($authlog_handle, $authlog ."\n");
+ fclose($authlog_handle);
+
/*
* We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
* new theme, if the logged-in user has another
@@ -211,6 +216,7 @@
} else {
$error = $app->lng('error_user_blocked');
}
+
} else {
if(!$alreadyfailed['times'] )
{
@@ -228,10 +234,14 @@
$app->plugin->raiseEvent('login_failed',$this);
- //* write to log (e.g. for fail2ban)
- exec('echo '. $logging .' >> /tmp/login.log');
+ //* Save failed login message to var
+ $authlog = 'Failed login for user \''. $username .'\' from '. long2ip($ip) .' at '. date('Y-m-d H:i:s');
+ $authlog_handle = fopen($conf['ispconfig_log_dir'].'/auth.log', 'a');
+ fwrite($authlog_handle, $authlog ."\n");
+ fclose($authlog_handle);
}
}
+
} else {
//* Username or password empty
if($error == '') $error = $app->lng('error_user_password_empty');
--
Gitblit v1.9.1