'.htmlentities($result).''; } } public static function getLogPath($filename, $create = false) { $filename = basename(trim(html_entity_decode((string)$filename))); $reportPath = File::cleanPath(ACYC_ROOT.ACYC_LOGS_FOLDER.$filename); if ($create) { FileService::createDir(dirname($reportPath), true, true); } return $reportPath; } public static function logMessage($file, $message) { $reportPath = self::getLogPath($file, true); $lr = "\r\n"; file_put_contents( $reportPath, $lr.DateService::getDate(time()).' - '.self::maskEmails($message), FILE_APPEND ); } /** * Redact email addresses in the log file. */ private static function maskEmails($message) { if (!is_string($message) || $message === '') { return $message; } return preg_replace_callback( '/([a-zA-Z0-9._%+-])[a-zA-Z0-9._%+-]*(@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/', static function ($matches) { return $matches[1].'***'.$matches[2]; }, $message ); } }