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:
<?
function ubb_bericht($bericht)
{
## Geen [ dan word de rest niet geladen (sneller)
if (strpos($bericht, "[") === false)
{
return $bericht;
}
$bericht = str_replace("<", "<", $bericht);
$bericht = str_replace(">", ">", $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"> </td>
</tr>
<tr>
<td height="43" width="110"> </td>
<td height="43" width="189">';
print ubb_bericht($bericht);
echo '</td>
</tr>
</table>';
}else{
}
}
// er is nog meer! :)
?>
1.104 views