Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Probelem z Tokenem na psnews, psnews [show.php]
ChowiX
post
Post #1





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 15.12.2006

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


Witam !

Zrobiłem token na skrypcie psnews i mam pewnien problem moj kod show.php

  1. <?php
  2. .../
  3. /* TOKEN ZABEZPIECZAJĄCY */
  4.  
  5. $_SESSION['token'] = '';
  6. for($i=0;$i<5;$i++) {
  7.  $liczba = rand(0,9);
  8.  $_SESSION['token'] .= $liczba;
  9.  $img .= '<img src="http://portalgier.info/token/'.$liczba.'.gif" />';
  10. }
  11.  
  12. /* TOKEN ZABEZPIECZAJĄCY */
  13.  
  14.  
  15. if ($pos === false) {
  16.  
  17. $banfile = file("$newspath/ban.txt");
  18. $ip = $_SERVER["REMOTE_ADDR"];
  19. $ban = "false";
  20. foreach($banfile as $linia){
  21. $linia = explode("||", $linia);
  22. if($linia[0] == $ip){ $ban = "true"; }
  23. }
  24. if($ban == "true"){
  25. $print_center = news_wiadomosc("Przepraszamy, ale nie masz zezwolenia na dodanie komentarza, ponieważ twoje IP ($ip) zostało zablokowane przez administratora.<br>[<a href=\"".$config["adres"]."\">wróć do newsów</a>]");
  26. }
  27. else{
  28. if($_SESSION['token'] == $_POST['token'])
  29. {
  30. if($_GET["do"] == "save")
  31. {
  32. $filename = "$newspath/komentarze/".$_GET["no"];
  33. if(file_exists($filename)){
  34. $kom_autor = $_POST["kom_autor"];
  35. $kom_email = $_POST["kom_email"];
  36. $komentarz = $_POST["komentarz"];
  37. $kom_autor = strip_tags($kom_autor);
  38. $kom_email = strip_tags($kom_email);
  39. $komentarz = strip_tags($komentarz);
  40. $kom_autor = str_replace("|", "|", $kom_autor);
  41. $kom_email = str_replace("|", "|", $kom_email);
  42. $komentarz = str_replace("|", "|", $komentarz);
  43. $kom_autor = preg_replace("'\n|r\n|r'si", "", $kom_autor);
  44. $kom_email = preg_replace("'\n|r\n|r'si", "", $kom_email);
  45. $komentarz = preg_replace("'\n|r\n|r'si", "<br>", $komentarz);
  46. $numer = max_l_plik(0, "||", $filename)+1;
  47.  
  48. $file = fopen($filename, "a+");
  49. flock($file, 2);
  50. $puts = "$numer||$komentarz||$kom_autor||$kom_email||".time()."||$ip||\n";
  51. fputs($file, $puts);
  52. flock($file, 3);
  53. fclose($file);
  54. $print_center = news_wiadomosc("Twój komentarz został dodany.<br>[<a href=".$config["adres"].">wróć do newsów</a>]");
  55. }else{
  56. $print_center = news_wiadomosc("Nie można dodać komentarza - brak pliku z bazą danych do tego newsa.<br>[<a href=".$config["adres"].">wróć do newsów</a>]");
  57. }
  58. }else{
  59. $print_center = news_wiadomosc("Nie można dodać komentarza - Nieprawidłowy Token.<br>[<a href=".$config["adres"].">wróć do newsów</a>]");
  60. }
  61.  
  62. }
  63. else{
  64. $print_center.= "
  65. <form action=\"". $config["adres"]."function=add_kom&no=".$_GET["no"]."&do=save\" method=post name=formularz>
  66. Autor:<br><input type=text name=\"kom_autor\"><br>
  67. Email:<br><input type=text name=\"kom_email\"><br>
  68. Komentarz:<br>";
  69. if($config["emoty_kom"] == "tak"){ $print_center.= list_emots($newspath,"komentarz")."<br>"; }
  70. $print_center.= "<textarea style=\"width:300; height:150\" name=\"komentarz\"></textarea><br>
  71. $img<br>Przepisz kod<br>
  72. <input type=text name=\"token\"><br>
  73. <input type=submit value=\"dodaj\">
  74. <br><a href=\"".$config["adres"]."\">[rezygnuj]</a>
  75. </form>
  76. ";
  77. }
  78. }
  79. .../
  80. ?>


i mam problem tutaj

  1. <?php
  2. if($_SESSION['token'] == $_POST['token'])
  3. {
  4. if($_GET["do"] == "save")
  5. {
  6. ?>


Nie wiem czy to prawidłowo

Prosze o pomoc

Gdy pisze komentarz to zamiast go dodać pokazuje sie znowu formularz komentowania..

Gdy podamy zly token takze pokazuje sie formularz komentowania..

Ten post edytował ChowiX 29.08.2007, 11:59:42
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 19.08.2025 - 20:00