X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FUtils.php;h=a9a10ece572a02e36c151931c719be739894faaa;hb=1abe655597da7b3c5b59146c4351eef59f69514c;hp=f84f70e44a7f8662f136bd19909b35f338796cbd;hpb=b16e3dc5903e23ac653d0de4e3bffc3d1e529a89;p=github%2Fshaarli%2FShaarli.git diff --git a/application/Utils.php b/application/Utils.php index f84f70e4..a9a10ece 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -3,6 +3,19 @@ * Shaarli utilities */ +/** + * Logs a message to a text file + * + * @param string $logFile where to write the logs + * @param string $clientIp the client's remote IPv4/IPv6 address + * @param string $message the message to log + */ +function logm($logFile, $clientIp, $message) +{ + $line = strval(date('Y/m/d_H:i:s')).' - '.$clientIp.' - '.strval($message).'\n'; + file_put_contents($logFile, $line, FILE_APPEND); +} + /** * Returns the small hash of a string, using RFC 4648 base64url format * @@ -72,12 +85,14 @@ function sanitizeLink(&$link) /** * Checks if a string represents a valid date + + * @param string $format The expected DateTime format of the string + * @param string $string A string-formatted date + * + * @return bool whether the string is a valid date * - * @param string a string-formatted date - * @param format the expected DateTime format of the string - * @return whether the string is a valid date - * @see http://php.net/manual/en/class.datetime.php - * @see http://php.net/manual/en/datetime.createfromformat.php + * @see http://php.net/manual/en/class.datetime.php + * @see http://php.net/manual/en/datetime.createfromformat.php */ function checkDateFormat($format, $string) {