Jump to content

[SOLVED] bbcode/forum issues


xoligy

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.