Hallo @ All!
Ich habe folgende Function.
wie kann ich verhindern, dass bereits formatierte links <a href='>bla</a> nochmal verlinkt werden?
Ich habe folgende Function.
PHP Code:
function replaceLinks($text)
{
$pfad = aktueller_pfad();
$urlsearch[] = "/([^]_a-z0-9-=\"'\/])((https?|ftp):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)/si";
$urlsearch[] = "/^((https?|ftp):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)/si";
$urlreplace[]= "\\1[URL]\\2\\4[/URL]";
$urlreplace[]= "[URL]\\1\\3[/URL]";
$text = preg_replace($urlsearch, $urlreplace, $text);
$text = preg_replace("/\[URL\](.*?)\[\/URL\]/si", "<a href=\"".$pfad."/out.php?url=\\1\" target=\"_blank\">\\1</a>", $text);
$text = preg_replace("/\[URL=(.*?)\](.*?)\[\/URL\]/si", "<a href=\"".$pfad."/out.php?url=\\1\"target=\"_blank\">\\2</a>", $text);
$text = str_replace("href=\"http://","href=\"http://www",$text);
$text = str_replace("href=\"www","href=\"http://www",$text);
return($text);
}
Comment