diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/Utils.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/application/Utils.php b/application/Utils.php index a9a10ece..cb30595f 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -6,14 +6,19 @@ | |||
6 | /** | 6 | /** |
7 | * Logs a message to a text file | 7 | * Logs a message to a text file |
8 | * | 8 | * |
9 | * The log format is compatible with fail2ban. | ||
10 | * | ||
9 | * @param string $logFile where to write the logs | 11 | * @param string $logFile where to write the logs |
10 | * @param string $clientIp the client's remote IPv4/IPv6 address | 12 | * @param string $clientIp the client's remote IPv4/IPv6 address |
11 | * @param string $message the message to log | 13 | * @param string $message the message to log |
12 | */ | 14 | */ |
13 | function logm($logFile, $clientIp, $message) | 15 | function logm($logFile, $clientIp, $message) |
14 | { | 16 | { |
15 | $line = strval(date('Y/m/d_H:i:s')).' - '.$clientIp.' - '.strval($message).'\n'; | 17 | file_put_contents( |
16 | file_put_contents($logFile, $line, FILE_APPEND); | 18 | $logFile, |
19 | date('Y/m/d H:i:s').' - '.$clientIp.' - '.strval($message).'\n', | ||
20 | FILE_APPEND | ||
21 | ); | ||
17 | } | 22 | } |
18 | 23 | ||
19 | /** | 24 | /** |