PHP beginner |
|
Bij mijn UBB werken de smillies niet als ik die als eerst in het bericht gebruik. als ik eerst wat voor de smillie type dan werkt hij wel
function ubb($bericht) {
$bericht = trim($_POST['bericht']);
$bericht = wordwrap($bericht, 100, "\n", true);
$bericht = mysql_real_escape_string($bericht);
$bericht = htmlentities($bericht);
$bericht = wordwrap($bericht, 100, "\n", true);
$bericht = mysql_real_escape_string($bericht);
$bericht = htmlentities($bericht);
$bericht = str_replace(" :O"," <img src=\"img/smilies/ohmy.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" #wink"," <img src=\"img/smilies/wink.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :P"," <img src=\"img/smilies/tongue.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :D"," <img src=\"img/smilies/biggrin.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" #cool"," <img src=\"img/smilies/cool.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" #rol"," <img src=\"img/smilies/rolleyes.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" #lol"," <img src=\"img/smilies/lol.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :|"," <img src=\"img/smilies/blink.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :S"," <img src=\"img/smilies/boos.gif\" alt=\"Smilie\" />",$bericht);
$bericht = preg_replace("#\[url\](http|ftp)(.+?)\[/url\]#is","<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>",$bericht);
$bericht = preg_replace("#\[url\](mailto:)(.+?)\[/url]#is","<a href=\"\\1\\2\" target=\"_blank\">\\2</a>",$bericht);
$bericht = preg_replace("#\[mail\](.+?)\[/mail\]#is","\\1",$bericht);
$bericht = preg_replace("#\[url\](.+?)\[/url\]#is","<a href=\"http://\\1\" target=\"_blank\">\\1</a>",$bericht);
$bericht = preg_replace("#\[url=(http|ftp|mailto)(.+?)\](.+?)\[/url\]#is","<a href=\"\\1\\2\" target=\"_blank\">\\3</a>",$bericht);
$bericht = preg_replace("#\[url=(.+?)\](.+?)\[/url\]#is","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$bericht);
// Automatisch URLs
$bericht = eregi_replace("(^|[ \n\r\t])((http(s?)://)(www\.)?([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1<a href=\"\\2\" target=\"_blank\">\\2</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);
// Cursief
$bericht = preg_replace("#\[i\](.+?)\[/i\]#is","<i>\\1</i>",$bericht);
// Onderstreept
$bericht = preg_replace("#\[u\](.+?)\[/u\]#is","<u>\\1</u>",$bericht);
// Vetgedrukt
$bericht = preg_replace("#\[b\](.+?)\[/b\]#is","<b>\\1</b>",$bericht);
// Doorstreept
$bericht = preg_replace("#\[s\](.+?)\[/s\]#is","<s>\\1</s>",$bericht);
// Quote
$bericht = preg_replace("#\[quote\](.+?)\[/quote\]#is","<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"3%\"> </td><td><small>Quote</small></td></tr><tr><td width=\"3%\"> </td><td style=\"border: 1px solid #232850;\"><table><tr><td>\\1</td></tr></table></td></tr></table>",$bericht);
$bericht = preg_replace("#\[quote=(.+?)\](.+?)\[/quote\]#is","<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"3%\"> </td><td><small>Quote: <b>\\1</b></small></td></tr><tr><td width=\"3%\"> </td><td style=\"border: 1px solid #232850;\"><table><tr><td>\\2</td></tr></table></td></tr></table>",$bericht);
// Plaatjes
$bericht = preg_replace("#\[img\](http)(.+?)\[/img\]#is","<img src=\"\\1\\2\" alt=\"Plaatje\" />",$bericht);
$bericht = preg_replace("#\[img\](.+?)\[/img\]#is","<img src=\"http://\\1\" alt=\"Plaatje\" />",$bericht);
// Kleur
$bericht = preg_replace("#\[color=(.+?)\](.+?)\[/color\]#is","<font color=\"\\1\">\\2</font>",$bericht); return $bericht;
}
function ubb($bericht) { $bericht = trim($_POST['bericht']); $bericht = wordwrap($bericht, 100, "\n", true); $bericht = wordwrap($bericht, 100, "\n", true); $bericht = str_replace(" :O"," <img src=\"img/smilies/ohmy.gif\" alt=\"Smilie\" />",$bericht); $bericht = str_replace(" #wink"," <img src=\"img/smilies/wink.gif\" alt=\"Smilie\" />",$bericht); $bericht = str_replace(" :P"," <img src=\"img/smilies/tongue.gif\" alt=\"Smilie\" />",$bericht); $bericht = str_replace(" :D"," <img src=\"img/smilies/biggrin.gif\" alt=\"Smilie\" />",$bericht); $bericht = str_replace(" #cool"," <img src=\"img/smilies/cool.gif\" alt=\"Smilie\" />",$bericht); $bericht = str_replace(" #rol"," <img src=\"img/smilies/rolleyes.gif\" alt=\"Smilie\" />",$bericht); $bericht = str_replace(" #lol"," <img src=\"img/smilies/lol.gif\" alt=\"Smilie\" />",$bericht); $bericht = str_replace(" :|"," <img src=\"img/smilies/blink.gif\" alt=\"Smilie\" />",$bericht); $bericht = str_replace(" :S"," <img src=\"img/smilies/boos.gif\" alt=\"Smilie\" />",$bericht); $bericht = preg_replace("#\[url\](http|ftp)(.+?)\[/url\]#is","<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>",$bericht); $bericht = preg_replace("#\[url\](mailto:)(.+?)\[/url]#is","<a href=\"\\1\\2\" target=\"_blank\">\\2</a>",$bericht); $bericht = preg_replace("#\[mail\](.+?)\[/mail\]#is","\\1",$bericht); $bericht = preg_replace("#\[url\](.+?)\[/url\]#is","<a href=\"http://\\1\" target=\"_blank\">\\1</a>",$bericht); $bericht = preg_replace("#\[url=(http|ftp|mailto)(.+?)\](.+?)\[/url\]#is","<a href=\"\\1\\2\" target=\"_blank\">\\3</a>",$bericht); $bericht = preg_replace("#\[url=(.+?)\](.+?)\[/url\]#is","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$bericht); // Automatisch URLs $bericht = eregi_replace("(^|[ \n\r\t])((http(s?)://)(www\.)?([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1<a href=\"\\2\" target=\"_blank\">\\2</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); // Cursief $bericht = preg_replace("#\[i\](.+?)\[/i\]#is","<i>\\1</i>",$bericht); // Onderstreept $bericht = preg_replace("#\[u\](.+?)\[/u\]#is","<u>\\1</u>",$bericht); // Vetgedrukt $bericht = preg_replace("#\[b\](.+?)\[/b\]#is","<b>\\1</b>",$bericht); // Doorstreept $bericht = preg_replace("#\[s\](.+?)\[/s\]#is","<s>\\1</s>",$bericht); // Quote $bericht = preg_replace("#\[quote\](.+?)\[/quote\]#is","<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"3%\"> </td><td><small>Quote</small></td></tr><tr><td width=\"3%\"> </td><td style=\"border: 1px solid #232850;\"><table><tr><td>\\1</td></tr></table></td></tr></table>",$bericht); $bericht = preg_replace("#\[quote=(.+?)\](.+?)\[/quote\]#is","<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"3%\"> </td><td><small>Quote: <b>\\1</b></small></td></tr><tr><td width=\"3%\"> </td><td style=\"border: 1px solid #232850;\"><table><tr><td>\\2</td></tr></table></td></tr></table>",$bericht); // Plaatjes $bericht = preg_replace("#\[img\](http)(.+?)\[/img\]#is","<img src=\"\\1\\2\" alt=\"Plaatje\" />",$bericht); $bericht = preg_replace("#\[img\](.+?)\[/img\]#is","<img src=\"http://\\1\" alt=\"Plaatje\" />",$bericht); // Kleur $bericht = preg_replace("#\[color=(.+?)\](.+?)\[/color\]#is","<font color=\"\\1\">\\2</font>",$bericht); return $bericht; }
|