Lille problem med smiley's
Davs eksperter.I et script jeg har fundet er den nedenstående kode inkluderet i, der er dog bare det problem at når man så skriver og laver en smiley forsøger den at linke til xxx.gif=align... og derved ikke til selve smiley'en
Jeg har forsøgt mig dog uden held.
Her er koden til det omtalte stykke af scriptet:
// Function: parseBBCode
// -> Returns: String
// -> Comment: Not using an array like parseSmileys because there is a mixture of
// str_replace and eregi_replace
function parseBBCode($strText)
{
$strText = str_replace("[sub]","<sub>",$strText);
$strText = str_replace("[/sub]","</sub>",$strText);
$strText = str_replace("[sup]","<sup>",$strText);
$strText = str_replace("[/sup]","</sup>",$strText);
$strText = str_replace("[s]","<s>",$strText);
$strText = str_replace("[/s]","</s>",$strText);
$strText = str_replace("","<b>",$strText);
$strText = str_replace("","</b>",$strText);
$strText = str_replace("","<i>",$strText);
$strText = str_replace("","</i>",$strText);
$strText = str_replace("","<u>",$strText);
$strText = str_replace("","</u>",$strText);
$strText = str_replace("
- ","<ul>",$strText);
$strText = str_replace("
$strText = str_replace("[code]","<table border=\"0\" align=\"center\" width=\"95%\" cellpadding=\"3\" cellspacing=\"1\"><tbody><tr><td id=\"smallcode\">CODE</td></tr><tr><td id=\"code\"><br>",$strText);
$strText = str_replace("[/code]","</td></tr></tbody></table>",$strText);
$strText = eregi_replace("\\[img]([^\\[]*)\\[/img\\]","<img src=\"\\1\">",$strText);
$strText = eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\1</a>",$strText);
$strText = eregi_replace("\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\2</a>",$strText);
$strText = eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]", "<a href=\"http://www.\\1\" target=\"_blank\">\\1</a>",$strText);
$strText = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\1</a>",$strText);
$strText = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\2</a>",$strText);
return $strText;
}
function parseSmileys($strText)
{
$rgEmoticons[] = array(":mellow:","mellow");
$rgEmoticons[] = array(":huh:","huh.gif");
$rgEmoticons[] = array("^_^","happy.gif");
$rgEmoticons[] = array(":o", "ohmy.gif");
$rgEmoticons[] = array(":P","ongue.gif");
$rgEmoticons[] = array(":D","biggrin.gif");
$rgEmoticons[] = array(":lol:","laugh.gif");
$rgEmoticons[] = array("B)","cool.gif");
$rgEmoticons[] = array(":rolleyes:","rolleyes.gif");
$rgEmoticons[] = array("-_-","sleep.gif");
$rgEmoticons[] = array("<_<","dry.gif");
$rgEmoticons[] = array(":)","smile.gif");
$rgEmoticons[] = array(":wub:","wub.gif");
$rgEmoticons[] = array(":angry:","mad.gif");
$rgEmoticons[] = array(":(","sad.gif");
$rgEmoticons[] = array(":unsure:","unsure.gif");
$rgEmoticons[] = array(":S","wacko.gif");
$rgEmoticons[] = array("O_o","blink.gif");
$rgEmoticons[] = array(":ph34r:","ph34r.gif");
$rgEmoticons[] = array(";)","wink.gif");
$rgEmoticons[] = array(":'(","crying.gif");
$rgEmoticons[] = array(":$","blushing.gif");
foreach ($rgEmoticons as $rgEmoticon)
{
$strText = str_replace($rgEmoticon[0],"<img src=\"images/smileys/".$rgEmoticon[1]." align=\"absmiddle\">",$strText);
}
return $strText;
}