login  Naam:   Wachtwoord: 
Registreer je!
 Forum

UBB-systeem doet van alles verkeerd

Offline DeviLGuY - 07/12/2005 16:19 (laatste wijziging 07/12/2005 20:37)
Avatar van DeviLGuYNieuw lid Probleem opgelost!
Hoi,
Ik heb een UBB-systeem gemaakt, alleen daarbij heb ik een probleempje: de highlight voor codes returned niet goed (zie hier voor de fout)
  1. <?php
  2. function code($code) {
  3. $code = str_replace("&amp;", "&", $code);
  4. $code = str_replace("&lt;", "<", $code);
  5. $code = str_replace("&gt;", ">", $code);
  6. $code = str_replace(" &lt;?", "&lt;?", $code);
  7. $code = str_replace("<br>", "", $code);
  8. $code = str_replace("<br />", "", $code);
  9. $code = str_replace("&quot; ", "\"", $code);
  10. $code = str_replace("&quot;", "\"", $code);
  11. if (!strpos($code,"<?") and substr($code,0,2)!="<?") {
  12. $code="<?".trim($code)."?>";
  13. $addedtags=1;
  14. }
  15. $oldlevel=error_reporting(0);
  16. error_reporting($oldlevel);
  17. $buffer = ob_get_contents();
  18. if(!empty($addedtags)) {
  19. $openingpos = strpos($buffer,'&lt;?');
  20. $closingpos = strrpos($buffer, '?');
  21. $buffer = substr($buffer, 0, $openingpos).substr($buffer, $openingpos+5, $closingpos-($openingpos+5)).substr($buffer, $closingpos+5);
  22. }
  23. return "<TABLE width=\"100%\">
  24. <TR>
  25. <TH>Code</TH>
  26. </TR>
  27. <TR>
  28. <TD>".$buffer."</TD>
  29. </TR>
  30. </TABLE>";
  31. }
  32. function ubb($t) {
  33. $t = htmlspecialchars($t);
  34. $t = trim($t);
  35. $t = nl2br($t);
  36. $t = preg_replace('_\[b\](.*?)\[\/b\]_is', '<b>\\1</b>', $t);
  37. $t = preg_replace('_\[u\](.*?)\[\/u\]_is', '<u>\\1</u>', $t);
  38. $t = preg_replace('_\[i\](.*?)\[\/i\]_is', '<i>\\1</i>', $t);
  39. $t = preg_replace('_\[s\](.*?)\[\/s\]_is', '<s>\\1</s>', $t);
  40. $t = preg_replace('_\[small\](.*?)\[\/small\]_is', '<small>\\1</small>', $t);
  41. $t = preg_replace('_\[url\](.*?)\[\/url\]_is', '<a href="\\1" target="_blank">\\1</a>', $t);
  42. $t = preg_replace('_\[url=(.*?)\](.*?)\[\/url\]_is', '<a href="\\1" target="_blank">\\2</a>', $t);
  43. $t = preg_replace("_\[php=(.*?)\](.*?)\[\/php\]_is", "<A href=\"http://www.php.net/\\1\" target=\"_php\">\\2</A>", $t);
  44. $t = preg_replace("_\[img\](.*?)\[\/img\]_is", "<IMG src=\"\\1\" border=\"0\">", $t);
  45. $t = preg_replace("_\[font=(.*?)\](.*?)\[\/font\]_is", "<FONT style=\"font-family: \\1\">\\2</FONT>", $t);
  46. $t = preg_replace("_\[color=(.*?)\](.*?)\[\/color\]_is", "<FONT style=\"color: \\1\">\\2</FONT>", $t);
  47. $t = preg_replace("_\[size=(.*?)\](.*?)\[\/size\]_is", "<FONT style=\"font-size: \\1px\">\\2</FONT>", $t);
  48. $t = preg_replace("_\[img=(.*?)\]_is", "<IMG src=\"\\1\" alt=\"AFBEELDING\" border=\"0\">", $t);
  49. $t = preg_replace("_\[code](.*?)
_is", code('\\1'), $t);
$t = str_replace("
Citaat:
", "<TABLE width="100%" class="quote">
<TR>
<TH class="quote">Quote</small></TH>
</TR>
<TR>
<TD>", $t);
$t = str_replace("
", " </TD>
</TR>
</TABLE><br />", $t);
$smilies = Array (
":@" => "smilie_boos",
":-@" => "smilie_boos",
"[afgestudeerd]" => "smilie_afgestudeerd",
"&lt;:o)" => "smilie_feest",
":)" => "smilie_blij",
":-)" => "smilie_blij",
";-)" => "smilie_knipoog",
";)" => "smilie_knipoog",
"(y)" => "smilie_duim",
"(Y)" => "smilie_duim",
"(n)" => "smilie_duimomlaag",
"(N)" => "smilie_duimomlaag",
"(6)" => "smilie_duivels",
"(A)" => "smilie_engel",
"(a)" => "smilie_engel",
":D" => "smilie_ergblij",
":d" => "smilie_ergblij",
":-D" => "smilie_ergblij",
":-d" => "smilie_ergblij",
":O" => "smilie_geschokt",
":o" => "smilie_geschokt",
":-O" => "smilie_geschokt",
":-o" => "smilie_geschokt",
":P" => "smilie_grappig",
":p" => "smilie_grappig",
":-p" => "smilie_grappig",
":-P" => "smilie_grappig",
":'(" => "smilie_huilen",
"(i)" => "smilie_idee",
"(I)" => "smilie_idee",
"[kerstman]" => "smilie_kerstman",
"(C)" => "smilie_koffie",
"(c)" => "smilie_koffie",
"lol" => "smilie_lachen",
":|" => "smilie_neutraal",
":-|" => "smilie_neutraal",
":(" => "smilie_nietblij",
":-(" => "smilie_nietblij",
"[nieuwjaar]" => "smilie_nieuwjaar",
"[piet]" => "smilie_piet",
":$" => "smilie_schamen",
":-$" => "smilie_schamen",
"[sint]" => "smilie_sint",
":S" => "smilie_verward",
":-S" => "smilie_verward",
":s" => "smilie_verward",
":-s" => "smilie_verward",
"(H)" => "smilie_zon",
"(h)" => "smilie_zon"
);
foreach ($smilies as $code => $image) {
$t = str_replace($code, "<IMG src=\"smilies/".$image.".gif\" border=\"0\">", $t);
}
return $t;
}
?>[/code]

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.246s