Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Captcha
john_doe
post 30.04.2010, 21:43:11
Post #1





Grupa: Zarejestrowani
Postów: 873
Pomógł: 25
Dołączył: 24.07.2005

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


Witam, zrobiłem sobie captche
  1. function _generateRandomString($length=6)
  2. {
  3. $_rand_src = array(
  4. array(48,57)
  5. , array(97,122)
  6. // , array(65,90)
  7. );
  8. srand ((double) microtime() * 1000000);
  9. $random_string = "";
  10. for( $i = 0 ; $i < $length ; $i++)
  11. {
  12. $i1 = rand(0,sizeof($_rand_src)-1);
  13. $random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));
  14. }
  15. return $random_string;
  16. }
  17.  
  18. $im = @imagecreatefromjpeg("captcha.jpg");
  19.  
  20. $rand = _generateRandomString(3);
  21.  
  22. $_SESSION['captcha'] = $rand;
  23.  
  24. ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0));
  25.  
  26. $rand = _generateRandomString(3);
  27.  
  28. ImageString($im, 5, 2, 2, " ".$rand[0]." ".$rand[1]." ".$rand[2], ImageColorAllocate ($im, 255, 0, 0));
  29.  
  30. Header ('Content-type: image/jpeg');
  31.  
  32. imagejpeg( $im, NULL, 100 );
  33.  
  34. ImageDestroy($im);


nie potrafię zwiększyć czcionki. Wg dokumentacji funkcja imageString i jej drugi parametr.
Co robię nie tak??
Go to the top of the page
+Quote Post
Wicepsik
post 30.04.2010, 21:51:07
Post #2





Grupa: Zarejestrowani
Postów: 1 575
Pomógł: 299
Dołączył: 26.03.2009

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


imagestring, 2 parametr - czcionka może przyjąć 1, 2, 3, 4, 5 dla wbudowanych czcionek w kodowaniu latin2

Jeśli chcesz skorzystać z większej czcionki użyj imagettftext


--------------------
Go to the top of the page
+Quote Post
varez
post 30.04.2010, 21:54:06
Post #3





Grupa: Zarejestrowani
Postów: 275
Pomógł: 32
Dołączył: 17.06.2007

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


sprawdz sobie roznice miedzy 1, a 5.. jest roznica.. nieduza, bo nieduza ale jest..
wiec wszystko dziala jak nalezy
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: 13.07.2025 - 21:08