Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Obrazki- jak zrobić
-Getog-
post 11.03.2008, 15:56:25
Post #1





Goście







Witam. Mam pytanie. Jak zrobić obrazki na stronie żeby można było zabezpieczyć się przed botami. Do tego jest jakaś funkcja w php? Proszę o pomoc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
Piniek
post 11.03.2008, 15:58:53
Post #2





Grupa: Przyjaciele php.pl
Postów: 463
Pomógł: 49
Dołączył: 27.12.2007
Skąd: Warszawa

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


zainteresuj sie biblioteką GD


--------------------
Go to the top of the page
+Quote Post
l0ud
post 11.03.2008, 15:59:37
Post #3





Grupa: Zarejestrowani
Postów: 1 387
Pomógł: 273
Dołączył: 18.02.2008

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


To się nazywa token, wpisz to słowo w wyszukiwarce tego forum, a gdzie szukać wskaż forum 'gotowe rozwiązania'. Powinieneś otrzymać sporo rozwiązań smile.gif


--------------------
XMPP: l0ud@chrome.pl
Go to the top of the page
+Quote Post
marcio
post 11.03.2008, 16:04:28
Post #4





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Ze jestem dobry dam ci klase
  1. <?php 
  2.  
  3.  
  4. class Token 
  5. { 
  6.  
  7. var $token; 
  8.  
  9. function GetSessionVars() 
  10. { 
  11. $this->token = $_SESSION['randtoken']; 
  12. } 
  13.  
  14. function RandToken()
  15. { 
  16.  
  17. $RandNumber = rand(1,1000); 
  18. $this->token = substr(md5($RandNumber), 0,6); 
  19. $_SESSION['randtoken'] = $this->token; 
  20.  
  21. } 
  22.  
  23.  
  24. function ReturnToken() 
  25. { 
  26.  
  27. return $this->token; 
  28. } 
  29.  
  30. function Reset() 
  31. { 
  32.  
  33. $_SESSION['randtoken'] = ""; 
  34. $this->token = "";  
  35. } 
  36.  
  37. function ReturnDrawToken() 
  38. { 
  39.  
  40. // header("Content-type: image/png"); 
  41. $image = @imagecreate(100,20); 
  42.  
  43. if($image) 
  44. { 
  45. $background = imagecolorallocate($image, 0,0,0); 
  46. $text = imagecolorallocate($image, 255,255,235); 
  47. imagestring($image, 4, 25,5, $this->token, $text); 
  48. header("Content-type: image/png"); 
  49. imagepng($image); 
  50. imagedestroy($image);
  51. }
  52. }
  53. } 
  54.  ?>


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
Go to the top of the page
+Quote Post
-Getog-
post 11.03.2008, 16:15:42
Post #5





Goście







Ok, dzięki ale jak teraz wyświetlić tokena tak żeby był widoczny na stronie?
Go to the top of the page
+Quote Post
marcio
post 11.03.2008, 16:24:02
Post #6





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Jako ze ja to sobie przerobilem na funckje to nie jestem pewny czy dobrze robie tworzysz drugi plik token.php z taka zawartoscia
  1. <?php
  2. //przyklad uzycia
  3. include('klasa_tokena.php');
  4. $token = new Token();
  5. $token -> GetSessionVars($token);
  6. $token -> ReturnDrawToken($token);
  7. ?>

I poptem w glownym pliku includujesz plik token.php o tak
  1. <?php
  2. include('token.php');
  3. ?>

I na glownej stronie robisz cos takiego
  1. <?php
  2. include('klasa_tokena.php');
  3. $token = new Token();
  4. $token -> RandToken($token);
  5. $token -> ReturnToken($token);
  6. //i dajesz obrazek
  7. echo('<img src="token.php">');
  8. ?>

Jakos tak smile.gif


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
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 Wersja Lo-Fi Aktualny czas: 19.07.2025 - 17:11