So, ich habe z. B. den Code für einen Badword-Filter gefunden, aber wie bekomme ich den nun in mein Kommentarscript? Wohin wird das eingefügt?
<?php
// Badwordfilter
$badwords = array(
"Wort1", "Wort2", "Wort3", "Wort4", "Wort5", "Wort6", "Wort7", "Wort8", "Wort9", "Wort10",
"Wort11","Wort12", "Wort13", "Wort14", "Wort15", "Wort16", "Wort17", "Wort18", "Wort19",
"Wort20"
);
function badwords($text) {
global $badwords;
foreach ($badwords as $b) {
$r = $b[0].str_repeat("*", strlen($b)-2).$b[strlen($b)-1];
if (function_exists("str_ireplace")) {
$text = str_ireplace($b, $r, $text);
}
else {
$text = str_replace($b, $r, $text);
}
}
return $text;
}
?>
Aufruf der Funktion mit:
<?php
$Kommentar = badwords($Kommentar);
?>
Der ist von dieser Seite:
https://www.homepage-total.de/bausteine ... 4.php#bs_4
Und das ist mein Kommentarscript. Es wurde mir freundlicherweise kostenlos und ohne Werbung zur Verfügung gestellt von
https://www.e-hahn.de/
Könnte mir jemand zumindest einen Tipp geben, wohin das obere hier eingefügt wird?
<form name="Form" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" onSubmit="return checkform();">
<?php
// Erstellen einer Rechenaufgabe
$Zahl_1 = intval(rand(1, 5));
$Zahl_2 = intval(rand(1, 5));
$mailto = "@";
if ($_POST) {
$Page = $_POST["Page"];
$datum = date("d.m.y, H:i",time());
$User = addslashes($_POST["User"]);
$Mail = addslashes($_POST["eMail"]);
$Comment = addslashes($_POST["Comment"]);
// ... und die Rechenaufgabe FALSCH geloest wurde...
if ($_POST['number'] != md5($_POST['arithmetic'])) {
// ...dann eine Fehlermeldung ausgeben!
echo "<p style=\"text-align: center\"><strong><span class=\"fc4\">Die Rechenaufgabe wurde falsch gelöst!</span></strong></p>";
}
// Ansonsten, wenn die Rechenaufgabe RICHTIG geloest wurde stimmt...
if ($_POST['number'] == md5($_POST['arithmetic'])) {
if ($Page !="" && $User !="" && $Comment !="") {
$file = "comments/".$Page.".txt";
// Kommentar schreiben
$fp = fopen($file,"a+");
fputs($fp,"<p><strong>$User</strong> ($datum):<br />$Comment</p>\n");
fclose($fp);
}
// E-Mail versenden
$betreff = "Neuer Kommentar";
$text = "Datum: $datum - Seite: \"$Page\" - Autor: $User\nE-Mail: $eMail\n\nKommentar: $Comment\r";
@mail($mailto,$betreff,$text,"From: ".$mailto);
}
}
?>
<table style="margin-top: 10px">
<tr>
<td colspan="2"><strong>Kommentar schreiben:</strong><br /><br />
<textarea style="width: 99%" rows="4" cols="21" name="Comment"></textarea>
</td>
</tr>
<tr>
<td style="width: 25%"><input type="text" name="User" size="28"></td>
<td style="width: 75%">Name</td>
</tr>
<tr>
<td style="width: 25%">
<input name="number" type="hidden" id="number" value="<?php echo md5(( $Zahl_1 + $Zahl_2 )); ?>"/>
<input name="arithmetic" type="text" id="arithmetic" size="28" />
</td>
<td style="width: 75%">Spamschutz (Wieviel ist <?php echo $Zahl_1; ?>+<?php echo $Zahl_2; ?>?)</td>
</tr>
<tr>
<td style="width: 25%"><input type="text" name="eMail" size="28"></td>
<td style="width: 75%">E-Mail (Optional, wird nicht veröffentlicht)</td>
</tr>
<tr>
<td style="width: 25%">
<p style="margin-top:22;">
<?php
// Wenn KEIN Cookie gegen Spam gesetzt wurde, dann soll der "Senden"-Button anklickbar sein
if ($_COOKIE["spam_protection"] != "spam_protection") {
?>
<input class="button" type="submit" name="sendfeedback" value="Speichern" />
<?php
}
// Wenn aber ein Cookie gegen Spam gesetzt wurde, dann soll der "Senden"-Button blockiert werden
if ($_COOKIE["spam_protection"] == "spam_protection") {
?>
<input class="button" type="submit" name="sendfeedback" value="Speichern" disabled="true" />
<?php
}
?>
</p>
</td>
<td style="width: 75%" align="right">[Kommentare <a href="" onclick="javascript:switchlayer('Comments'); return false;" title="">ein- oder ausblenden</a>]</td>
</tr>
</table>
<?php
// Dateiname ermitteln
$titel=explode("/","$_SERVER[PHP_SELF]");
$file=explode('.',$titel[count($titel)-1]);
echo " <input type='hidden' name='Page' value='".$file[0]."'>\r";
?>
<div id="Comments" onclick="javascript:switchlayer('Comments'); return false;">
<?php
// Kommentarausgabe
$ausgabe = "comments/".$file[0].".txt";
if(file_exists($ausgabe)) {
htmlentities(readfile($ausgabe));
}
else {
echo "Es sind noch keine Kommentare vorhanden.";
}
?>
</div>
</form>