Smilies in Gastenboek
Hieronder is een stuk van mijn ubb met smilies.
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
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
<?php
// UBB functie
function ubb($bericht) {
// Code
$GLOBALS['phphighlite'] = array("dummy");
$bericht = preg_replace("_<\?(.*?)\?>_ise","phphighlite_replace('<? \\1 ?>')",$bericht);
// HTML wegwerken
$bericht = htmlspecialchars($bericht);
// Enters maken
$bericht = nl2br($bericht);
// URLs met tags maken
$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);
// Grootte
$bericht = preg_replace("#\[size=(.+?)\](.+?)\[/size\]#is","<font size=\"\\1\">\\2</font>",$bericht);
// Smileys
$bericht = str_replace(" :)"," <img src=\"images/smilies/smiley.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" 8|"," <img src=\"images/smilies/huh.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :o"," <img src=\"images/smilies/ohmy.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" ;)"," <img src=\"images/smilies/wink.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :P"," <img src=\"images/smilies/tongue.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :D"," <img src=\"images/smilies/biggrin.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" 8)"," <img src=\"images/smilies/cool.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" *-)"," <img src=\"images/smilies/rolleyes.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :?"," <img src=\"images/smilies/dry.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :@"," <img src=\"images/smilies/mad.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :("," <img src=\"images/smilies/sad.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" 8-)"," <img src=\"images/smilies/unsure.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :|"," <img src=\"images/smilies/blink.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" |:-|"," <img src=\"images/smilies/ph34r.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :/"," <img src=\"images/smilies/happy.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" |-)"," <img src=\"images/smilies/sleep.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" (l)"," <img src=\"images/smilies/wub.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :s"," <img src=\"images/smilies/wacko.gif\" alt=\"Smilie\" />",$bericht);
// Code
$bericht = preg_replace("_\[code\]([0-9])\[/code\]_ise", "phphighlite('\\1')", $bericht);
return $bericht;
}
?>
// UBB functie
function ubb($bericht) {
// Code
$GLOBALS['phphighlite'] = array("dummy");
$bericht = preg_replace("_<\?(.*?)\?>_ise","phphighlite_replace('<? \\1 ?>')",$bericht);
// HTML wegwerken
$bericht = htmlspecialchars($bericht);
// Enters maken
$bericht = nl2br($bericht);
// URLs met tags maken
$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);
// Grootte
$bericht = preg_replace("#\[size=(.+?)\](.+?)\[/size\]#is","<font size=\"\\1\">\\2</font>",$bericht);
// Smileys
$bericht = str_replace(" :)"," <img src=\"images/smilies/smiley.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" 8|"," <img src=\"images/smilies/huh.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :o"," <img src=\"images/smilies/ohmy.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" ;)"," <img src=\"images/smilies/wink.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :P"," <img src=\"images/smilies/tongue.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :D"," <img src=\"images/smilies/biggrin.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" 8)"," <img src=\"images/smilies/cool.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" *-)"," <img src=\"images/smilies/rolleyes.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :?"," <img src=\"images/smilies/dry.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :@"," <img src=\"images/smilies/mad.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :("," <img src=\"images/smilies/sad.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" 8-)"," <img src=\"images/smilies/unsure.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :|"," <img src=\"images/smilies/blink.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" |:-|"," <img src=\"images/smilies/ph34r.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :/"," <img src=\"images/smilies/happy.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" |-)"," <img src=\"images/smilies/sleep.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" (l)"," <img src=\"images/smilies/wub.gif\" alt=\"Smilie\" />",$bericht);
$bericht = str_replace(" :s"," <img src=\"images/smilies/wacko.gif\" alt=\"Smilie\" />",$bericht);
// Code
$bericht = preg_replace("_\[code\]([0-9])\[/code\]_ise", "phphighlite('\\1')", $bericht);
return $bericht;
}
?>
Dit is een stuk wat het bericht in mijn gastenboek plaatst...
Ik krijg het nu alleen niet voor elkaar om die smileys te laten werken. Als ik namelijk in mijn gastenboek :) intyp gebeurd er niets.
De ubb werkt wel goed!!
Wat moet ik nu doen?
Joeri schreef op 17.09.2009 23:48:
Als ik namelijk in mijn gastenboek :) intyp gebeurd er niets.
De ubb werkt wel goed!!
De ubb werkt wel goed!!
Wat nou? Doet ie het nou wel of doet ie het nou niet. Omschrijf duidelijk je probleem.
ontopic; is het path naar je smilies wel correct? Staan je smilies wel in "images/smilies/" ?
Paradox™ schreef op 18.09.2009 01:04:
@SanThe hij bedoeld dat de ubbcodes zoals vet schuin enz wel werken maar de smilies niet.
ontopic; is het path naar je smilies wel correct? Staan je smilies wel in "images/smilies/" ?
ontopic; is het path naar je smilies wel correct? Staan je smilies wel in "images/smilies/" ?
Bekijk dus het path even in de broncode.