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
 
Start new topic
Odpowiedzi (1 - 11)
qqrq
post
Post #2





Grupa: Zarejestrowani
Postów: 418
Pomógł: 8
Dołączył: 16.11.2006

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


A masz ustawione session.auto_start na 1, ewentualnie wcześniej wywołałeś session_start() (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
ChowiX
post
Post #3





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

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


ale jak wywołuje session_start() to wyskakuje błąd

"
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home.2/p/o/r/portalgi/www/index.php:11) in /home.2/p/o/r/portalgi/www/wiad99628366611a/show.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home.2/p/o/r/portalgi/www/index.php:11) in /home.2/p/o/r/portalgi/www/wiad99628366611a/show.php on line 2
"
Go to the top of the page
+Quote Post
bim2
post
Post #4





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


nie możesz nic innego wyświetlić przed wywołaniem funkcji session_start() Nawet spacji!
Go to the top of the page
+Quote Post
ChowiX
post
Post #5





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

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


tz ze mam to walnąc do index.php ?
a nie w show.php ?

początek kodu
<?
session_start();

Ten post edytował ChowiX 29.08.2007, 13:00:08
Go to the top of the page
+Quote Post
bim2
post
Post #6





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


Jeśli w indexie includujesz show.php. Nie znam psnews

@moderatorzy
Może warto przenieść topic do gotowe skrypty, bo chodzi o psnews (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
ChowiX
post
Post #7





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

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


Zrobiłem takw index.php
  1. <?php session_start();?>

reszta strony

i nadal nie idzie dodac komentarzu (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) w show.php usunalem session_start();



Ma ktoś jeszcze jakies pomysły ?

Ten post edytował ChowiX 29.08.2007, 16:06:51
Go to the top of the page
+Quote Post
bim2
post
Post #8





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


daj nad
  1. <?php
  2. ?>
to:
  1. <?php
  2. ?>


czyli ma być:
  1. <?php
  2. ?>
Go to the top of the page
+Quote Post
ChowiX
post
Post #9





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

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


Nadal nie działa :/

Prosze zobaczyc ...

Kod
http://portalgier.info/index.html?function=add_kom&no=9
Go to the top of the page
+Quote Post
bim2
post
Post #10





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


Pokaż mi górę index.php od lini 1 do ~30. (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
ChowiX
post
Post #11





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

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


Prosze
index.php
  1. <?php ob_start();
  2. session_start();
  3. ?>
  4. <!-- desing by ChowiX -->
  5. <!-- Wszelkie prawa kopiowania kodu oraz grafiki portalu ZABRONIONE -->
  6. <title>Strona Główna - PortalGier.info - Internetowy Portal Gier</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
  8. <meta name="robots" content="all">
  9. <meta name="keywords" content="<? echo $slowakluczowe ?>">
  10. <meta name="description" content="<? echo $opisstrony ?>">
  11. <meta http-equiv="Content-Language" content="pl">
  12. <meta name= "reply-to" content="admin@portalgier.info">
  13. <meta name="author" content="ChowiX [Dawid]">
  14. <link rel="stylesheet" href="/style/class.css" type="text/css">
  15. <script language="JavaScript" type="text/javascript" src="/js/gora.js"></script>
  16. <script type="text/javascript" language="javascript" src="/js/behavior.js"></script>
  17. <script type="text/javascript" language="javascript" src="/js/rating.js"></script>
  18. <link rel="stylesheet" type="text/css" href="/css/rating.css" />
  19. <link rel="shortcut icon" href="http://www.portalgier.info/favicon.ico" />
  20. <link rel="bookmark icon" href="http://www.portalgier.info/favicon.ico" />
  21. </head>
  22. <div align="center">
  23. <table class="glowna">
  24. <tr>
  25. <td><img border="0" src="/desing/logo.gif"></td>
  26. </tr>


Lecz gdy odlacze tokena tz skasuje go z kodu wszystko smiga...

Ten post edytował ChowiX 30.08.2007, 13:53:08
Go to the top of the page
+Quote Post
bim2
post
Post #12





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


Eeee... to powinno działać (IMG:http://forum.php.pl/style_emoticons/default/sciana.gif) Nie mam pomysłu. Może ktos bardziej doświadczony w problemach z sesjami będzie wiedział. (IMG:http://forum.php.pl/style_emoticons/default/party.gif)
Go to the top of the page
+Quote Post

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: 23.08.2025 - 19:39