Ik heb al meerdere malen gezocht, maar het is me vooralsnog niet gelukt; het weghalen van [quote] tags binnen een andere quote tag. Want als ik dat probeer gaat m'n layout de mist in...
M'n UBB code/parser is als volgt:
Maar ik krijg dus die overbodige quotes er niet uit...
Hoe moet/kan ik dit oplossen?
Alvast bedankt.
M'n UBB code/parser is als volgt:
PHP:
1
| <?## code tags functiesfunction bboff($bboff, $nr){ global $c; global $nr; $c[$nr] = $bboff; $bboff = ("[code]" . $nr . "[/code]"); $nr++; return $bboff;}function bbon($bbon){ global $c; ob_start(); $c[$bbon] = str_replace(" &lt;?", "&lt;?", $c[$bbon]); $c[$bbon] = str_replace("<br>", "", $c[$bbon]); $c[$bbon] = str_replace("<br />", "", $c[$bbon]); $c[$bbon] = str_replace("&lt;", "<", $c[$bbon]); $c[$bbon] = str_replace("&gt;", ">", $c[$bbon]); $c[$bbon] = str_replace("&quot;", "\"", $c[$bbon]); highlight_string($c[$bbon]); $c[$bbon] = ob_get_contents(); ob_end_clean(); $c[$bbon] = str_replace("<code>", "", $c[$bbon]); $c[$bbon] = str_replace("</code>", "", $c[$bbon]); $bbon = ("Code: <HTML TAGS>" . $c[$bbon] . "<HTML TAGS>"); return $bbon;}## opmaak voor berichtenfunction opmaak($bericht, $website, $html, $ubb){ if($html == "1") { $bericht = stripslashes($bericht); $bericht = str_replace(">:)", "&gt;:)", $bericht); $bericht = str_replace(">:-)", "&gt;:-)", $bericht); } else { $bericht = htmlspecialchars(stripslashes($bericht)); } if($ubb == "0") { $bericht = preg_replace("/\\[code\]((.|\n)*?)\\[\/code\]/ise", "bboff('\\1', '$nr')", $bericht); $bericht = str_replace("[img]javascript:", "&#91;img&#93;javascript&#58;", $bericht); $ubbcode = array( "'\n'", "'\\[img\](.*?)\\[\/img\]'i", "'\\[b\](.*?)\\[\/b\]'i", "'\\[i\](.*?)\\[\/i\]'i", "'\\[u\](.*?)\\[\/u\]'i", "'\\[s\](.*?)\\[\/s\]'i", "'\\[small\](.*?)\\[\/small\]'i", ); $html = array( "<br>", "\\1", "<b>\\1</b>", "<i>\\1</i>", "<u>\\1</u>", "<s>\\1</s>", "<small>\\1</small>", ); $bericht = preg_replace($ubbcode, $html, $bericht); $bericht = eregi_replace("(http://[^ )\r\n]+)", "<a href=\"\\1\" target=\"_blank\">\\1</a>", $bericht); $bericht = eregi_replace("(^|[ \n\r\t])((ftp://)(www\.)?([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $bericht); $bericht = eregi_replace("([a-z_-][a-z0-9\._-]*@[a-z0-9_-]+(\.[a-z0-9_-]+)+)","<a href=\"mailto:\\1\">\\1</a>", $bericht); $bericht = eregi_replace("(^|[ \n\r\t])(www\.([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $bericht); $bericht = eregi_replace("(^|[ \n\r\t])(ftp\.([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1<a href=\"ftp://\\2\" target=\"_blank\">\\2</a>", $bericht); $stripped = strip_tags($bericht); $explode = explode("[", $stripped); $q = 0; $qq = 0; $w = 0; for($x = 0; $x < count($explode); $x++) { $explode[$x] = strtolower($explode[$x]); if(substr($explode[$x], 0, 6) == "quote]") { $q++; } elseif(substr($explode[$x], 0, 7) == "/quote]") { $qq++; } else { $w++; } } if($q != "0" && $qq != "0") { if($q/$qq == "1") { for($x = 0; $x < $q; $x++) { $bericht = preg_replace("'\\[quote\](.*?)\\[\/quote\]'i", "Quote:<TAGS>\\1</TAGS>", $bericht); } } else { for($x = 0; $x < ($q-$qq); $x++) { $bericht = preg_replace("'\\[quote\](.*?)\\[\/quote\]'i", "Quote:<TAGS>\\1</TAGS>", $bericht); } } } $s_query = mysql_query("SELECT code, img FROM smileys ORDER BY id DESC")or die(mysql_error()); $url = $website[url]; while($s_list = mysql_fetch_object($s_query)) { $bericht = eregi_replace("$s_list->code", "[img]\"$url/img/smileys/$s_list->img\">",[/img] |
Maar ik krijg dus die overbodige quotes er niet uit...
Hoe moet/kan ik dit oplossen?
Alvast bedankt.