Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: usunięcie wiadomości w księdze gości
Forum PHP.pl > Forum > PHP
pszczepan
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ź:
  1. <?php
  2.  
  3. // You can customize the date and time format using php. As they are set now,
  4. // the date will appear in the form "Sunday, January 11, 2004" and the time in
  5. // the form "1:04 pm". Another common date format would be 01.11.04; to change
  6. // it to this, replace 'l, F j, Y' with 'm.d.y'. More info can be found at
  7. // <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">http://us2.php.net/manual/en/function.date.php</a>.
  8.  
  9. $dateFormat = 'd.m.Y';
  10. $timeFormat = 'H:i:s';
  11.  
  12.  
  13. if (empty($_POST['message'])) {
  14. header('Location: '.$_POST['bookurl'].'?contents=blank');
  15. }
  16.  
  17. else {
  18. $entryFile = 'entries.txt';
  19. $formatFile = 'format.php';
  20.  
  21. $message = stripslashes($_POST['message']);
  22.  
  23. $allowedTags = '<a><em><strong><b><i><img>';
  24.  
  25. $stripAttrib = 'java script:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|on
    mouseout|onkeypress|onkeydown|onkeyup|style|class|id'
    ;
  26.  
  27. function removeEvilTags($source)
  28. {
  29.  global $allowedTags;
  30.  $source = strip_tags($source, $allowedTags);
  31.  return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('1').'>'", $source);
  32. }
  33. function removeEvilAttributes($tagSource)
  34. {
  35. global $stripAttrib;
  36. return stripslashes(preg_replace("/$stripAttrib/i", 'forbidden', $tagSource));
  37. }
  38.  
  39. function word_wrap($message)
  40. {
  41. $maxLength = 60;
  42. $cut = ' ';
  43. $result = '';
  44. $wordlength = 0;
  45.  
  46. $length = strlen($message);
  47.  
  48. $tag = FALSE;
  49. for ($i = 0; $i < $length; $i++)
  50. {
  51. $char = substr($message, $i, 1);
  52. if ($char == '<') { $tag = TRUE; }
  53. elseif ($char == '>') { $tag = FALSE; }
  54. elseif (!$tag && $char == ' ') { $wordlength = 0; }
  55. elseif (!$tag) { $wordlength++; }
  56. if (!$tag && !($wordlength%$maxLength)) { $char .= $cut; }
  57. $result .= $char;
  58. }
  59. return $result;
  60. }
  61.  
  62. $message = word_wrap(removeEvilTags($message));
  63. $message = str_replace(array('&', "rnrn"), array('&', '</p><p>'), $message);
  64. $message = str_replace(array('&gt;', '&lt;', "rn"), array('>', '<', '<br />'), $message);
  65.  
  66. $signername = strip_tags(stripslashes($_POST['signername']));
  67.  
  68.  
  69. $formatted = file_get_contents($formatFile);
  70. $variables = array("n", '%%signername%%', '%%message%%', '%%date%%', '%%time%%');
  71. $inputs = array('', $signername, $message, date($dateFormat), date($timeFormat));
  72.  
  73. $formatted = str_replace($variables, $inputs, $formatted);
  74.  
  75. $oldEntries = fopen($entryFile, 'r');
  76. $content = fread($oldEntries, filesize($entryFile));
  77. fclose($oldEntries);
  78.  
  79. $newContent = $formatted."n".$content;
  80.  
  81. $allEntries = fopen($entryFile, 'w');
  82. fwrite($allEntries, $newContent);
  83. fclose($allEntries);
  84.  
  85. header('Location: '.$_POST['bookurl']);
  86.  
  87. }
  88.  
  89. ?>
Cysiaczek
Wyjaśnij raz jeszcze. Jak rozumiem masz liste słów, które skrypt powinien usuwać tak?
Nie zrozumiałem też, czy te słowa były wcześniej w tym skrypcie, czy nie (bo piszesz, że jakieś usunąłeś).

Możesz mi podać zawartość pliku format.php questionmark.gif?
pszczepan
Witam !

Ten kto pisał skrypt tłumaczył gdzie należy wpisać zakazane słowa, ale link do twórcy nie działa, a ja nie bardzo pamiętam gdzie to było.
Niewiem, czy to dokładnie tak działało jak jabym chciał - Ja chciałbym , żeby to działało tak - jeżeli wpisany tekst zawiera jakieś zakazane ( wcześniej zdefiniowane przeze mnie słowo zapisane w pliku php) wtedy ten cały post nie powinien być dodany do treści forum, która jest w pliku entries.txt

format. php jest taki:
  1. <?php
  2. <div class="entry">
  3. <div class="name">%%signername%%</div>
  4. <div class="date">%%date%% @ %%time%%</div>
  5.  
  6. <p>%%message%%</p>
  7.  
  8. </div>
  9. ?>


Dzięki za zainteresowanie
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.