diff options
author | VirtualTam <virtualtam@flibidi.net> | 2016-01-16 15:48:26 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2016-01-16 16:07:16 +0100 |
commit | 1abe655597da7b3c5b59146c4351eef59f69514c (patch) | |
tree | bbd00b908dcfc329eea37ac32839f63044ceec3d /application/Utils.php | |
parent | 92ba7b573f2833bd35c7eb2fc7fdbeb1a0ac7b44 (diff) | |
download | Shaarli-1abe655597da7b3c5b59146c4351eef59f69514c.tar.gz Shaarli-1abe655597da7b3c5b59146c4351eef59f69514c.tar.zst Shaarli-1abe655597da7b3c5b59146c4351eef59f69514c.zip |
Logging: move logm() from index.php to application/Utils.php
Relates to #436
Modifications:
- inject dependencies to global variables ($_SERVER, $GLOBALS)
- apply coding conventions
- add test coverage
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'application/Utils.php')
-rw-r--r-- | application/Utils.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/application/Utils.php b/application/Utils.php index aeaef9ff..a9a10ece 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -4,6 +4,19 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | /** | 6 | /** |
7 | * Logs a message to a text file | ||
8 | * | ||
9 | * @param string $logFile where to write the logs | ||
10 | * @param string $clientIp the client's remote IPv4/IPv6 address | ||
11 | * @param string $message the message to log | ||
12 | */ | ||
13 | function logm($logFile, $clientIp, $message) | ||
14 | { | ||
15 | $line = strval(date('Y/m/d_H:i:s')).' - '.$clientIp.' - '.strval($message).'\n'; | ||
16 | file_put_contents($logFile, $line, FILE_APPEND); | ||
17 | } | ||
18 | |||
19 | /** | ||
7 | * Returns the small hash of a string, using RFC 4648 base64url format | 20 | * Returns the small hash of a string, using RFC 4648 base64url format |
8 | * | 21 | * |
9 | * Small hashes: | 22 | * Small hashes: |