Fout bij filter

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Bart

Bart

31/01/2006 17:04:00
Quote Anchor link
Hallo allemaal!

Ja, ik heb een vraag.
Ik heb een gastenboek daarin zit een scheldwoorden filter. Maar hij filter de tekst niet :( maar de andere dingen zoals bijv. Ubb code bijv. Php Hulp.
Dat geeft hij wel goed. Zou iemand mij kunnen helpen? Maar oja wat zo vaag is: Als ik bijv. een aparte tekst doe met een scheldwoord erin word hij wel gefilterd maar de tekst die ik met een while uit me DB haal niet. Wat is het probleem? Kunnen jullie mij helpen?

Hier het script:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?
function ubb_bericht($bericht)
{

   ## Geen [ dan word de rest niet geladen (sneller)
   if (strpos($bericht, "[") === false)
   {

      return $bericht;
   }


   $bericht = str_replace("<", "&lt;", $bericht);
   $bericht = str_replace(">", "&gt;", $bericht);

   ## De smilies
   $smiliesDir = "http://www.flashnews.nl/smilies/smilies/"; // locatie van de smilies, verander het naar jouw website url!!!
   $smilies = array(':)'    =>    "icon_smile.gif"       ,
                    ':-)'   =>    "icon_smile.gif"       ,

                    ':('    =>    "icon_sad.gif"         ,
                    ':-('   =>    "icon_sad.gif"         ,

                    ':S'    =>    "icon_confused.gif"    ,
                    ':s'    =>    "icon_confused.gif"    ,
                    ':-S'   =>    "icon_confused.gif"    ,
                    ':-s'   =>    "icon_confused.gif"    ,

                    ':D'    =>    "icon_biggrin.gif"     ,
                    ':d'    =>    "icon_biggrin.gif"     ,
                    ':-D'   =>    "icon_biggrin.gif"     ,
                    ':-d'   =>    "icon_biggrin.gif"     ,

                    ':O'    =>    "icon_surprised.gif"   ,
                    ':o'    =>    "icon_surprised.gif"   ,
                    ':-O'   =>    "icon_surprised.gif"   ,
                    ':-o'   =>    "icon_surprised.gif"   ,

                    ':|'    =>    "icon_neutral.gif"     ,
                    ':-|'   =>    "icon_neutral.gif"     ,
                    ':P'    =>    "icon_razz.gif"        ,
                    ':p'    =>    "icon_razz.gif"        ,
                    ':-P'   =>    "icon_razz.gif"        ,
                    ':-p'   =>    "icon_razz.gif"        ,

                    '(6)'   =>    "icon_twisted.gif"     ,

                    ':@'    =>    "icon_mad.gif"         ,
                    ':-@'   =>    "icon_mad.gif"         ,

                    ':$'    =>    "icon_redface.gif"     ,
                    ':-$'   =>    "icon_redface.gif"     ,

                    '(H)'   =>    "icon_cool.gif"        ,
                    '(h)'   =>    "icon_cool.gif"        ,

                    ';)'    =>    "icon_wink.gif"        ,
                    ';-)'   =>    "icon_wink.gif"        ,

                    ':*('   =>    "icon_cry.gif"         ,
                    ':-\'(' =>    "icon_cry.gif"         ,

                    '8)'    =>    "icon_rolleyes.gif"    ,
                    '8-)'   =>    "icon_rolleyes.gif"    ,

                    ':A'    =>    "icon_evil.gif"        ,
                    ':a'    =>    "icon_evil.gif"        ,
                    ':-A'   =>    "icon_evil.gif"        ,
                    ':-a'   =>    "icon_evil.gif"        ,

                    ':L'    =>    "icon_lol.gif"         ,
                    ':l'    =>    "icon_lol.gif"         ,
                    ':-L'   =>    "icon_lol.gif"         ,
                    ':-l'   =>    "icon_lol.gif"         ,

                    ':X'    =>    "icon_eek.gif"         ,
                    ':x'    =>    "icon_eek.gif"         ,
                    ':-X'   =>    "icon_eek.gif"         ,
                    ':-x'   =>    "icon_eek.gif"         ,

                    '(Y)'   =>    "icon_yes.gif"         ,
                    '(y)'   =>    "icon_yes.gif"         ,
                    '(N)'   =>    "icon_no.gif"          ,
                    '(n)'   =>    "icon_no.gif"          ,

                    '(})'   =>    "icon_arrow.gif"       ,
                    ':}'    =>    "icon_arrow.gif"       ,
                    '(!)'   =>    "icon_exclaim.gif"     ,
                    '(?)'   =>    "icon_question.gif"    ,
                    '(%)'   =>    "icon_idea.gif"        ,

                    '(mr)'  =>    "icon_mrgreen.gif"     ,
                    ':-#'   =>    "icon_silent.gif"      ,
                    '(cyc)' =>    "icon_cyclops.gif"     ,
                    '(sick)'=>    "icon_sick.gif"
                   );

                    foreach ($smilies AS $find => $character)
                    {

                       $bericht = str_replace(htmlentities($find), "<img src=\"". $smiliesDir . $character ."\" alt=\"\" />", $bericht);
                    }


   ## Standaard ubb functies
   $bericht = preg_replace("#\[b\](.*?)\[/b\]#si", "<b>\\1</b>", $bericht); // dikke tekst
   $bericht = preg_replace("#\[i\](.*?)\[/i\]#si", "<i>\\1</i>", $bericht); // schuine tekst
   $bericht = preg_replace("#\[u\](.*?)\[/u\]#si", "<u>\\1</u>", $bericht); // onderstreepte tekst
   $bericht = preg_replace("#\[s\](.*?)\[/s\]#si", "<s>\\1</s>", $bericht); // doorstreepte tekst
   $bericht = preg_replace("#\[sub\](.*?)\[/sub\]#si", "<sub>\\1</sub>", $bericht); // sub font [sub][/sub]
   $bericht = preg_replace("#\[sup\](.*?)\[/sup\]#si", "<sup>\\1</sup>", $bericht); // sup font [sup][/sup]
   $bericht = preg_replace("#\[center\](.*?)\[/center\]#si", "<center>\\1</center>", $bericht); // center text [center][/center]

   ## Plaatje

   $bericht = preg_replace("_\[img\](.*?)\[\/img\]_ise", "resizeIMG('\\1')", $bericht);

   ## Bewerk functie
   $bericht = preg_replace("#\[bewerkt\](.*?)\[/bewerkt\]#si", "<span class=\"kleurgrijs\">Bewerkt:<br />\\1</span>", $bericht);
   $bericht = preg_replace("#\[edit\](.*?)\[/edit\]#si", "<span class=\"kleurgrijs\"><br /><br />\\1</span>", $bericht);
   ## Offtopic functie
   $bericht = preg_replace("#\[off\](.*?)\[/off\]#si", "<span class=\"kleurgrijs\">Offtopic:<br />\\1</span>", $bericht);
   $bericht = preg_replace("#\[offtopic\](.*?)\[/offtopic\]#si", "<span class=\"kleurgrijs\">Offtopic:<br />\\1</span>", $bericht);

   ## Url
   $bericht = eregi_replace("\[url\][[:space:]]*(http://)?([^\\[]*)[[:space:]]*\[/url\]","<a href=\"http://\\2\" target=\"_blank\">http://\\2</a>", $bericht);
   $bericht = eregi_replace("\\[url=(http://)?([^\\[]*)\\][[:space:]]*([^\\[]*)[[:space:]]*\\[/url\\]","<a href=\"http://\\2\" target=\"_blank\">\\3</a>", $bericht);

   ## Email
   $bericht = preg_replace("#(\[email\])(.*)(\[\/email\])#i","<a href=\"mailto:\\2\">\\2</a>", $bericht);

   ## Zorgt voor automatische link die met www begint.
   $bericht = preg_replace("#(^|[ \n\r\t])www.([a-z\-0-9]+).([a-z]{2,4})($|[ \n\r\t])#i", "\\1<a href=\"http://www.\\2.\\3\" target=\"_blank\">www.\\2.\\3</a>\\4", $bericht);

   ## Zorgt voor automatische links die met ftp://, http://, https:// beginnen
   $bericht = preg_replace("#(^|[ \n\r\t])(((ftp://)|(http://)|(https://))([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+))#i", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $bericht);

   ## Zorgt voor automatische email; typ je gewoon [email protected] word het een email link
   $bericht = preg_replace("#(^|[ \n\r\t])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1<a href='mailto:\\2@\\3'>\\2@\\3</a>", $bericht);

   ## Kleuren
   $bericht = preg_replace ("#\[kleur=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/kleur\]#si", "<font color=\"\\1\">\\2</font>", $bericht);
   ## Lettertype instellen
   $bericht = preg_replace ("#\[font=(.*)\](.*)\[/font\]#si", "<font face=\"\\1\">\\2</font>", $bericht);
   ## Groote instellen
   $bericht = preg_replace ("#\[size=(.*)\](.*)\[/size\]#si", "<font size=\"\\1\">\\2</font>", $bericht);

   ## Balkje
   $bericht = str_replace("[hr]", "<hr width=\"75%\" size=\"1\" align=\"left\" />", $bericht);
   $bericht = str_replace("[line]", "<hr width=\"75%\" size=\"1\" align=\"left\" />", $bericht);

   ## Maakt lijst met rondje
   $bericht = preg_replace("#\[list\](.*?)\[/list\]#si", "<ul>\\1</ul>", $bericht);
   ## Maakt lijst met getallen
   $bericht = preg_replace("#\[list=1\](.*?)\[/list\]#si", "<ol type=\"1\">\\1</ol>", $bericht);
   ## Maakt lijst met letters
   $bericht = preg_replace("#\[list=a\](.*?)\[/list\]#si", "<ol type=\"a\">\\1</ol>", $bericht);
   ## Dit zorgt ervoor dat er telkens een optie bij komt
   $bericht = preg_replace("#\[li\](.*?)\[/li\]#si", "<li>\\1</li>", $bericht); // <li> maken met [li]

   ## Scheldwoorden filter


   $scheldwoord =   array('bagger'    ,
                          'beflap'    ,
                          'dildo'     ,
                          'f*ck'      ,
                          'fack'      ,
                          'fuck'      ,
                          'hoer'      ,
                          'joden'     ,
                          'kanker'    ,
                          'kut'       ,
                          'k*t'       ,
                          'l*l'       ,
                          'lul'       ,
                          'hoer'      ,
                          'neuk'      ,
                          'neuken'    ,
                          'pijpen'    ,
                          'rotjong'   ,
                          'shit'      ,
                          'slet'      ,
                          'sloerie'   ,
                          'snol'      ,
                          'tering'    ,
                          'teef'      ,
                          'trut'      ,
                          'uilebek'   ,
                          'viswijf'   ,
                          'waterhoofd',
                          'zeiklul'
                         );



                           $bericht = str_replace($scheldwoord, '***', $bericht);  

       $bericht = nl2br( stripslashes($bericht) );

return $bericht;
}

$max   = 2;
$page  = $_GET['page'];
$begin = $page * $max;
$sql = "SELECT * FROM *** ORDER BY id DESC LIMIT ".$begin.", ".$max."";
$res = mysql_query($sql)or die(mysql_error());
$countqry = "SELECT id as total FROM sony_gb";
$countrec = mysql_query($countqry) or die("Error");
$paantalb = mysql_num_rows($countrec);  
$pages    = $paantalb / $max;

   if( $pages == 0)
    {

    $error = "Er zijn geen berichten geplaatst!<br><a href=gastenboek2.php?create=yes>Maak bericht</a>";
    echo error($error);
    }
else{

 while ($obj = mysql_fetch_object($res))
  {

$show = $obj->show;
if($show == 1)
{

$bericht = $obj['bericht'];
    echo '<table border="0" width="315" height="129" cellspacing="0" cellpadding="0" style="border: 1px solid #000000; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px">
    <tr>
        <td height="9" width="110">Geplaatst op:</td>
        <td height="9" width="189">'
.$obj->datum.'</td>
    </tr>
    <tr>
        <td height="21" width="110">Naam:</td>
        <td height="21" width="189">'
.$obj->naam.'</td>
    </tr>
    <tr>
        <td height="21" width="110">Email:</td>
        <td height="21" width="189">'
.$obj->email.'</td>
    </tr>
    <tr>
        <td height="21" width="110">Reactie</td>
        <td height="21" width="189">&nbsp;</td>
    </tr>
    <tr>
        <td height="43" width="110">&nbsp;</td>
        <td height="43" width="189">'
;
print ubb_bericht($bericht);
echo '</td>
    </tr>
</table>'
;
}
else{
}
    }

// er is nog meer! :)
?>
 
PHP hulp

PHP hulp

08/09/2024 02:30:15
 
Niek Berckmans

Niek Berckmans

31/01/2006 17:42:00
Quote Anchor link
vervang dit:

$bericht = str_replace($scheldwoord, '***', $bericht);

eens voor:

for($i = 0; $i < count($scheldwoord); $i++){

$bericht = str_replace($scheldwoord[$i], '***', $bericht);

}
 
Bart

Bart

31/01/2006 18:11:00
Quote Anchor link
Nee helaas werkt niet :(
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.