xoligy Posted September 18, 2008 Share Posted September 18, 2008 ok ive just decided to check the bbcode i added to a premade forum on a game and noticed two small issues that i need a hand fixing which are as follows: when a person types the link works but it tries to run from the directory that the game is in which brings up a not found page lol the next is if i type the link with http:// the link come out as follows www.google.co.uk [/ url] anyone know how i would fix these issues? function replace(txt){ $txt = str_replace("[b]", "<b>", $txt); $txt = str_replace("[/b]", "</b>", $txt); $txt = str_replace("[i]", "<i>", $txt); $txt = str_replace("[/i]", "</i>", $txt); $txt = str_replace("[u]", "<u>", $txt); $txt = str_replace("[/u]", "</u>", $txt); $txt = preg_replace("#\[color=(.+?)\](.+?)\[/color\]#is","<font color=\"\\1\">\\2</font>",$txt); // Set up the parameters for a URL search string // $URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'"; // Set up the parameters for a MAIL search string // $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@"; // URL string // $txt = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="_blank">$1</a>', $txt); // Mail string // $txt = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $txt); // end // return $txt; } Link to comment https://forums.phpfreaks.com/topic/124790-solved-bbcodeforum-issues/ Share on other sites More sharing options...
dave_sticky Posted September 18, 2008 Share Posted September 18, 2008 when a person types the link works but it tries to run from the directory that the game is in which brings up a not found page // URL string // $txt = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="_blank">$1</a>', $txt); } This part should be fixable just by changing the code to: // URL string // $txt = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="http://$1" target="_blank">$1</a>', $txt); } Actually, If i've understood your second problem, it should fix both. Link to comment https://forums.phpfreaks.com/topic/124790-solved-bbcodeforum-issues/#findComment-644668 Share on other sites More sharing options...
xoligy Posted September 18, 2008 Author Share Posted September 18, 2008 Thanks dave seems to of done the trick Link to comment https://forums.phpfreaks.com/topic/124790-solved-bbcodeforum-issues/#findComment-644670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.