aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php30
1 files changed, 25 insertions, 5 deletions
diff --git a/application/Utils.php b/application/Utils.php
index ac8bfbfc..10d60698 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -4,6 +4,24 @@
4 */ 4 */
5 5
6/** 6/**
7 * Logs a message to a text file
8 *
9 * The log format is compatible with fail2ban.
10 *
11 * @param string $logFile where to write the logs
12 * @param string $clientIp the client's remote IPv4/IPv6 address
13 * @param string $message the message to log
14 */
15function logm($logFile, $clientIp, $message)
16{
17 file_put_contents(
18 $logFile,
19 date('Y/m/d H:i:s').' - '.$clientIp.' - '.strval($message).PHP_EOL,
20 FILE_APPEND
21 );
22}
23
24/**
7 * Returns the small hash of a string, using RFC 4648 base64url format 25 * Returns the small hash of a string, using RFC 4648 base64url format
8 * 26 *
9 * Small hashes: 27 * Small hashes:
@@ -64,12 +82,14 @@ function sanitizeLink(&$link)
64 82
65/** 83/**
66 * Checks if a string represents a valid date 84 * Checks if a string represents a valid date
85
86 * @param string $format The expected DateTime format of the string
87 * @param string $string A string-formatted date
88 *
89 * @return bool whether the string is a valid date
67 * 90 *
68 * @param string a string-formatted date 91 * @see http://php.net/manual/en/class.datetime.php
69 * @param format the expected DateTime format of the string 92 * @see http://php.net/manual/en/datetime.createfromformat.php
70 * @return whether the string is a valid date
71 * @see http://php.net/manual/en/class.datetime.php
72 * @see http://php.net/manual/en/datetime.createfromformat.php
73 */ 93 */
74function checkDateFormat($format, $string) 94function checkDateFormat($format, $string)
75{ 95{