Witam!
Na mojej stronie używam darmowej księgi gości. W jednym pliku jest możliwe sprawdzenie czy treść wiadomości jest OK - jeśli są tam użyte słowa zdefiniowane jako nieakceptowalne ta informacja nie powinna być wstawiona do forum.
Jak wklejałem te stronę wszystkie słowa zakazane usunąłem. Teraz ludzie ładują mi spam i chcę to trochę zabezpieczyć, ale nie znając php nie wiem, gdzie mam definiować te słowa. Poniżej cytuję treść tego skryptu.
Ktoś kto zna php będzie wiedzieć gdzie jest spradzane słowo - proszę o podpowiedź:
<?php
// You can customize the date and time format using php. As they are set now,
// the date will appear in the form "Sunday, January 11, 2004" and the time in
// the form "1:04 pm". Another common date format would be 01.11.04; to change
// it to this, replace 'l, F j, Y' with 'm.d.y'. More info can be found at
// <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">http://us2.php.net/manual/en/function.date.php</a>.
$dateFormat = 'd.m.Y';
$timeFormat = 'H:i:s';
if (empty($_POST['message'])) { header('Location: '.$_POST['bookurl'].'?contents=blank'); }
else {
$entryFile = 'entries.txt';
$formatFile = 'format.php';
$allowedTags = '<a><em><strong><b><i><img>';
$stripAttrib = 'java script:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|on
mouseout|onkeypress|onkeydown|onkeyup|style|class|id';
function removeEvilTags($source)
{
return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('1').'>'", $source); }
function removeEvilAttributes($tagSource)
{
}
function word_wrap($message)
{
$maxLength = 60;
$cut = ' ';
$result = '';
$wordlength = 0;
$tag = FALSE;
for ($i = 0; $i < $length; $i++)
{
$char = substr($message, $i, 1
); if ($char == '<') { $tag = TRUE; }
elseif ($char == '>') { $tag = FALSE; }
elseif (!$tag && $char == ' ') { $wordlength = 0; }
elseif (!$tag) { $wordlength++; }
if (!$tag && !($wordlength%$maxLength)) { $char .= $cut; }
$result .= $char;
}
return $result;
}
$message = word_wrap(removeEvilTags($message));
$variables = array("n", '%%signername%%', '%%message%%', '%%date%%', '%%time%%'); $inputs = array('', $signername, $message, date($dateFormat), date($timeFormat));
$formatted = str_replace($variables, $inputs, $formatted);
$oldEntries = fopen($entryFile, 'r');
$newContent = $formatted."n".$content;
$allEntries = fopen($entryFile, 'w'); fwrite($allEntries, $newContent);
header('Location: '.$_POST['bookurl']);
}
?>