From fb7a7d6f4cfc42d4c607ebf6440b8c71a5792950 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Sat, 14 Aug 2021 08:10:15 +0000 Subject: [PATCH] Improve link highlight for links in messages if bbcode --- Rocksolid_Light/rocksolid/newsportal.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index e973715..6ddbedd 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -880,15 +880,20 @@ function html_parse($text) { // split every line into it's words $words=explode(" ",$text); $n=count($words); + $is_link = 0; for($i=0; $i<$n; $i++) { $word=$words[$i]; if(preg_match('/(https?|ftp|news|gopher|telnet)\:\/\/[^\",]+/i', $word)) { + $is_link = 1; $nlink = trim($word, '().,'); $nlink = preg_replace('/(\<|\>|\ );/', '', $nlink); $nlink = preg_replace('/\[url=/', '', $nlink); $bbnlink = explode(']', $nlink); $nlink = $bbnlink[0]; - $nword = ''.$word.''; + $nword = ''.$nlink.''; + if(isset($bbnlink[1])) { + $nword.=' '.$bbnlink[1]; + } if($nword!=$word && substr($nlink, strlen($nlink) - 3) != "://") { $word=$nword; } @@ -896,6 +901,9 @@ function html_parse($text) { // add the spaces between the words if($i>0) $ntext.=" "; + if($is_link) { + $word = preg_replace('/\[\/url\]/', '', $word); + } $ntext.=$word; } return($ntext);