First commit

This commit is contained in:
pezcurrel 2024-08-22 11:20:54 +02:00
parent 9def51b8ec
commit 09ac498c80

12
web/lib/text2html.php Normal file
View file

@ -0,0 +1,12 @@
<?php
function text2html($text,$ifnoe) {
if (is_null($text) || preg_match('#^\s*$#',$text)===1)
return $ifnoe;
$text=htmlspecialchars($text,ENT_QUOTES|ENT_HTML5,'UTF-8');
$text=preg_replace('#(https?://.+?)(\n|\s|\W\s|\W\n)#','<a href="$1" target="_blank">$1</a>$2',$text);
$text=nl2br($text);
return $text;
}
?>