Smileys niet in codevelden
Ik wil dat in mij
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
[/ code] geen [b ][/b ] als <b></b> komt maar gewoon echt zoals het er staat, en netzoals smilies :)..
De code die ik nu heb:
<?
// Functies
function unhtmlentities ($string) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$ret = strtr ($string, $trans_tbl);
return preg_replace('/&#(\d+);/me',"chr('\\1')",$ret);
}
function br2nl ($data) {
return preg_replace( '!<br.*>!iU', "\n", $data );
}
function showcode ($code) {
$code = stripslashes($code);
$code = unhtmlentities($code);
$code = highlight_string($code, TRUE);
$code = br2nl($code);
return $code;
}
// UBB functie
function ubb($bericht) {
// HTML wegwerken
$bericht = htmlspecialchars($bericht);
// Code
$bericht = preg_replace("_\[code\](.*?)\[/code\]_ise","showcode ('\\1')",$bericht);
// Enters maken
$bericht = nl2br($bericht);
// URLs met tags maken
$url = array("#\[url\](http:\/\/|ftp:\/\/)(.+?)\[/url\]#is","#\[url\](mailto:)(.+?)\[/url]#is","#\[mail\](.+?)\[/mail\]#is","#\[url\](.+?)\[/url\]#is","#\[url=(http:\/\/|ftp:\/\/|mailto:)(.+?)\](.+?)\[/url\]#is","#\[url=(.+?)\](.+?)\[/url\]#is");
$url2 = array("<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>","<a href=\"\\1\\2\" target=\"_blank\">\\2</a>","\\1","<a href=\"http://\\1\" target=\"_blank\">\\1</a>","<a href=\"\\1\\2\" target=\"_blank\">\\3</a>","<a href=\"http://\\1\" target=\"_blank\">\\2</a>");
$bericht = preg_replace($url, $url2, $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);
// Grootte
$bericht = preg_replace("#\[size=(.+?)\](.+?)\[/size\]#is","<font size=\"\\1\">\\2</font>",$bericht);
// Smileys
$smiley = array(" :)"," 8|"," :o"," ;)"," :P"," :D"," 8)"," *-)"," :?"," :@"," :("," 8-)"," :|"," |:-|"," :/"," |-)"," (l)"," :s");
$img1 = "<img src=\"images/smilies/";
$img2 = "\" alt=\"Smilie\" border=\"0\" />";
$smiley2 = array($img1."smile.gif".$img2,$img1."huh.gif".$img2,$img1."ohmy.gif".$img2,$img1."wink.gif".$img2,$img1."tongue.gif".$img2,$img1."biggrin.gif".$img2,$img1."cool.gif".$img2,$img1."rolleyes.gif".$img2,$img1."dry.gif".$img2,$img1."mad.gif".$img2,$img1."sad.gif".$img2,$img1."unsure.gif".$img2,$img1."blink.gif".$img2,$img1."ph34r.gif".$img2,$img1."happy.gif".$img2,$img1."sleep.gif".$img2,$img."wub.gif".$img2,$img1."wacko.gif".$img2);
$bericht = str_replace($smiley, $smiley2, $bericht);
return $bericht;
}
?>
dus de smileys enzo moeten tegengehouden worden als de code er is..
Iemand een idee?
De code die ik nu heb:
<?
// Functies
function unhtmlentities ($string) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$ret = strtr ($string, $trans_tbl);
return preg_replace('/&#(\d+);/me',"chr('\\1')",$ret);
}
function br2nl ($data) {
return preg_replace( '!<br.*>!iU', "\n", $data );
}
function showcode ($code) {
$code = stripslashes($code);
$code = unhtmlentities($code);
$code = highlight_string($code, TRUE);
$code = br2nl($code);
return $code;
}
// UBB functie
function ubb($bericht) {
// HTML wegwerken
$bericht = htmlspecialchars($bericht);
// Code
$bericht = preg_replace("_\[code\](.*?)\[/code\]_ise","showcode ('\\1')",$bericht);
// Enters maken
$bericht = nl2br($bericht);
// URLs met tags maken
$url = array("#\[url\](http:\/\/|ftp:\/\/)(.+?)\[/url\]#is","#\[url\](mailto:)(.+?)\[/url]#is","#\[mail\](.+?)\[/mail\]#is","#\[url\](.+?)\[/url\]#is","#\[url=(http:\/\/|ftp:\/\/|mailto:)(.+?)\](.+?)\[/url\]#is","#\[url=(.+?)\](.+?)\[/url\]#is");
$url2 = array("<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>","<a href=\"\\1\\2\" target=\"_blank\">\\2</a>","\\1","<a href=\"http://\\1\" target=\"_blank\">\\1</a>","<a href=\"\\1\\2\" target=\"_blank\">\\3</a>","<a href=\"http://\\1\" target=\"_blank\">\\2</a>");
$bericht = preg_replace($url, $url2, $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);
// Grootte
$bericht = preg_replace("#\[size=(.+?)\](.+?)\[/size\]#is","<font size=\"\\1\">\\2</font>",$bericht);
// Smileys
$smiley = array(" :)"," 8|"," :o"," ;)"," :P"," :D"," 8)"," *-)"," :?"," :@"," :("," 8-)"," :|"," |:-|"," :/"," |-)"," (l)"," :s");
$img1 = "<img src=\"images/smilies/";
$img2 = "\" alt=\"Smilie\" border=\"0\" />";
$smiley2 = array($img1."smile.gif".$img2,$img1."huh.gif".$img2,$img1."ohmy.gif".$img2,$img1."wink.gif".$img2,$img1."tongue.gif".$img2,$img1."biggrin.gif".$img2,$img1."cool.gif".$img2,$img1."rolleyes.gif".$img2,$img1."dry.gif".$img2,$img1."mad.gif".$img2,$img1."sad.gif".$img2,$img1."unsure.gif".$img2,$img1."blink.gif".$img2,$img1."ph34r.gif".$img2,$img1."happy.gif".$img2,$img1."sleep.gif".$img2,$img."wub.gif".$img2,$img1."wacko.gif".$img2);
$bericht = str_replace($smiley, $smiley2, $bericht);
return $bericht;
}
?>
dus de smileys enzo moeten tegengehouden worden als de code er is..
Iemand een idee?
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$codes= preg_replace("_\[code\](.*?)\[/code\]_ise","showcode ('\\1')",$bericht);
$bericht = preg_replace("_\[code\](.*?)\[/code\]_ise","",$bericht);
$bericht=preg_replace('()', $codes, $bericht);
?>
Of ztoch zoiets in die richting
$codes= preg_replace("_\[code\](.*?)\[/code\]_ise","showcode ('\\1')",$bericht);
$bericht = preg_replace("_\[code\](.*?)\[/code\]_ise","",$bericht);
$bericht=preg_replace('()', $codes, $bericht);
?>
Of ztoch zoiets in die richting
Wat doet dat scriptstukje van jou dan?..
voor
krijg ik nu
<>
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
$codes= preg_replace("_\[code\](.*?)\[/code\]_ise","showcode ('\\1')",$bericht);
//Hier alle andere ubb codes die niet er in mogen
$bericht = preg_replace("_\[code\](.*?)\[/code\]_ise","",$bericht);
$bericht=preg_replace('()', $codes, $bericht);
?>
$codes= preg_replace("_\[code\](.*?)\[/code\]_ise","showcode ('\\1')",$bericht);
//Hier alle andere ubb codes die niet er in mogen
$bericht = preg_replace("_\[code\](.*?)\[/code\]_ise","",$bericht);
$bericht=preg_replace('()', $codes, $bericht);
?>
Fatal error: preg_replace() [function.preg-replace]: Failed evaluating code: