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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.