HTML interesse |
|
hoe kan ik normale htmlcodes weer omzetten naar ubb iemand enig idee?
Ik zou dus eigenlijk mijn adere script moeten "omdraaien" denk ik, maar hoe.
Dit is mijn replace script, zet dus ubb code om in html:
<?
function replace($text){
$text = htmlspecialchars(stripslashes($text));
$text = nl2br($text);
$text = preg_replace("#\[b\](.*?)\[/b\]#si","<b>\\1</b>", $text);
$text = preg_replace("#\[u\](.*?)\[/u\]#si","<u>\\1</u>", $text);
$text = preg_replace("#\[i\](.*?)\[/i\]#si","<i>\\1</i>", $text);
$text = preg_replace("#\[link\](.*?)\[/link\]#si","<a href=\"\\1\" target=\"_blank\">\\1</a>", $text);
$text = preg_replace("#\[link=(.*?)\](.*?)\[/link\]#si","<a href=\"\\1\" target=\"_blank\">\\2</a>", $text);
$text = preg_replace("#\[img\](.*?)\[/img\]#si","<img src=\"\\1\">", $text);
$text = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color=\\1>\\2</font>", $text);
$text = preg_replace("#\[move\](.*?)\[/move\]#si","<marquee>\\1</marquee>", $text);
$text = preg_replace("#\[edit\](.*?)\[/edit\]#si","<font color=orange><b>Edit</b></font>: \\1", $text);
$text = preg_replace("#\[quote\](.*?)\[/quote\]#si","<div style=\"margin-left:10px; padding-left:2px; border-left: 1px solid #666666\"><span class=\"opmerking\"><strong>Quote:</strong></span><br />\\1</div>", $text);
$sqles = mysql_query("SELECT * FROM `smileys`");
while($for = mysql_fetch_object($sqles)){
$text = str_replace($for->tag, "<img src=\"/_images/smileys/".$for->name.".gif\" alt=\"".$for->tag."\">", $text);
}
return $text;
}
$text = replace($msg);
?>
<? function replace($text){ $text = preg_replace("#\[b\](.*?)\[/b\]#si","<b>\\1</b>", $text); $text = preg_replace("#\[u\](.*?)\[/u\]#si","<u>\\1</u>", $text); $text = preg_replace("#\[i\](.*?)\[/i\]#si","<i>\\1</i>", $text); $text = preg_replace("#\[link\](.*?)\[/link\]#si","<a href=\"\\1\" target=\"_blank\">\\1</a>", $text); $text = preg_replace("#\[link=(.*?)\](.*?)\[/link\]#si","<a href=\"\\1\" target=\"_blank\">\\2</a>", $text); $text = preg_replace("#\[img\](.*?)\[/img\]#si","<img src=\"\\1\">", $text); $text = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color=\\1>\\2</font>", $text); $text = preg_replace("#\[move\](.*?)\[/move\]#si","<marquee>\\1</marquee>", $text); $text = preg_replace("#\[edit\](.*?)\[/edit\]#si","<font color=orange><b>Edit</b></font>: \\1", $text); $text = preg_replace("#\[quote\](.*?)\[/quote\]#si","<div style=\"margin-left:10px; padding-left:2px; border-left: 1px solid #666666\"><span class=\"opmerking\"><strong>Quote:</strong></span><br />\\1</div>", $text); $text = str_replace($for->tag, "<img src=\"/_images/smileys/".$for->name.".gif\" alt=\"".$for->tag."\">", $text); } return $text; } $text = replace($msg); ?>
iemand een idee?
|