Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][AJAX]Token, Zrobiony na AJAX
Night123
post
Post #1





Grupa: Zarejestrowani
Postów: 27
Pomógł: 2
Dołączył: 21.01.2013

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


Token się nie pokazuje, jak powinien. Wziąłem go na test i po podaniu ścieżki do niego nic nie ma.

Token:
  1. <?
  2. $pool = '123456789'; //liczby z których bedziemy losować
  3. $img_width = 100; //wymiary
  4. $img_height = 16;
  5.  
  6. $str = ''; //wyzerowanie
  7. for ($i = 0; $i < 5; $i++){ // losowanie
  8. $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
  9. }
  10.  
  11. $string = $str;
  12. $_SESSION['captcha'] = $string; //tworzymy sesje
  13.  
  14. $im = imagecreate($img_width, $img_height); //tworzymy
  15.  
  16. $bg_color = imagecolorallocate($im,255,255,255); // kolor tła
  17. $font_color = imagecolorallocate($im,0,0,0); // kolor czcionki
  18. $grid_color = imagecolorallocate($im,246,246,246); // kolor lini
  19. $border_color = imagecolorallocate ($im, 246, 246, 246); // kolor ramki
  20.  
  21. // Tworzenie tokena
  22.  
  23. imagefill($im,1,1,$bg_color);
  24.  
  25.  
  26. ImageLine($im,90,0,90,30,$grid_color); //1
  27. ImageLine($im,10,0,10,30,$grid_color); //2
  28. ImageLine($im,20,0,20,30,$grid_color); //1
  29. ImageLine($im,30,0,30,30,$grid_color); //1
  30. ImageLine($im,40,0,40,30,$grid_color); //1
  31. ImageLine($im,50,0,50,30,$grid_color); //1
  32. ImageLine($im,60,0,60,30,$grid_color); //1
  33. ImageLine($im,70,0,70,30,$grid_color); //1
  34. ImageLine($im,80,0,80,30,$grid_color); //1
  35.  
  36. ImageLine($im,0,5,100,5,$grid_color); //1
  37. ImageLine($im,0,10,100,10,$grid_color); //1
  38. ImageLine($im,0,15,100,15,$grid_color); //1
  39.  
  40.  
  41. $x = rand(5, $img_width/(7/2)); // pozycja liczb w tokenie
  42.  
  43. imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
  44.  
  45. for($a=0; $a < 7; $a++){
  46.  
  47. imagestring($im, 3, $x, 1, substr($string, $a, 1), $font_color);
  48. $x += (5*2); #odstęp
  49.  
  50. }
  51.  
  52. header("Content-type: image/gif");
  53. imagegif($im);
  54. imagedestroy($im);
  55.  
  56. ?>


Ten post edytował Night123 23.01.2013, 16:41:33
Go to the top of the page
+Quote Post
CuteOne
post
Post #2





Grupa: Zarejestrowani
Postów: 2 958
Pomógł: 574
Dołączył: 23.09.2008
Skąd: wiesz, że tu jestem?

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


Włącz raportowanie błędów (jak znajdziesz w podczepionych) a zapewne wywali błąd związany z wysłaniem nagłówka.

Jeżeli błąd się pojawi poszukaj info o ob_start i header already send
Go to the top of the page
+Quote Post

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: 21.08.2025 - 00:39