Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Blokada dodawania wpisu.
moto0095
post
Post #1





Grupa: Zarejestrowani
Postów: 247
Pomógł: 9
Dołączył: 12.03.2010

Ostrzeżenie: (0%)
-----


Witam. Szukam w google i nic nie mogę znaleźć.
Więc mój problem wygląda tak że mam sobie skrypt komentarzy [ oparty na plikach *.txt ] i ostatnio pojawili się SPAMERZY.
I mam takie pytanie jak zablokować (zbanować) IP ale tylko np na 5 min (IMG:style_emoticons/default/questionmark.gif)
Albo czego mam w google szukać(IMG:style_emoticons/default/questionmark.gif)
(IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
moto0095
post
Post #2





Grupa: Zarejestrowani
Postów: 247
Pomógł: 9
Dołączył: 12.03.2010

Ostrzeżenie: (0%)
-----


Zrobiłem coś takiego ale nie działa (IMG:style_emoticons/default/sad.gif)
Nie wyświetla się żaden błąd, ale też nie zapisuje do pliku.
  1. <?php
  2. $pole1 = trim($_POST['pole1']);
  3. $pole2 = trim($_POST['pole2']);
  4.  
  5. $file = "fip.txt";
  6. $time_5_min_ago = date("Y-m-d H:i:s", strtotime("-5 min"));
  7. $rows = explode("\n", $file);
  8.  
  9.  
  10. if(empty($pole1) and empty($pole2)) {
  11.  
  12. // prosty formularz zawierający dwa pola
  13. echo '<form action="?dod" method="post">
  14. <input type="text" name="pole1" style="width: 200px;" /><br />
  15. <textarea name="pole2" style="width: 200px; height: 100px;">
  16. </textarea><br />
  17. <input type="submit" value="Zapisz" />
  18. </form>';
  19. }else
  20. if(isset($_GET['dod'])){
  21.  
  22. foreach($rows as $value)
  23. {
  24. $one_row = explode('-', $value);
  25. if($one_row[0] == $_SERVER['REMOTE_ADDR'] && $one_row[1] > $time_5_min_ago)
  26. {
  27. echo "Komentować można tylko raz na 5min.";
  28. }
  29. }
  30. }else{
  31. $dane = $_SERVER['REMOTE_ADDR']."-".date("Y-m-d H:i:s", time())."-".$pole1."-".$pole2."\n";
  32. $file = "fip.txt";
  33. $fp = fopen($file, "a");
  34. flock($fp, 2);
  35. fwrite($fp, $dane);
  36. flock($fp, 3);
  37. fclose($fp);
  38.  
  39. echo "Dane zostały zapisane!<br />";
  40. echo "<a href=\"podglad.php\">Zobacz wpisane dane</a>";
  41. }
  42. ?>



(IMG:style_emoticons/default/questionmark.gif) (IMG:style_emoticons/default/questionmark.gif)

Ja nie wiem gdzie jest błąd (IMG:style_emoticons/default/sad.gif) .

(IMG:style_emoticons/default/questionmark.gif) (IMG:style_emoticons/default/questionmark.gif)

Ten post edytował moto0095 14.04.2010, 17:47:49
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 10.10.2025 - 21:11