[TYPO3-german] CAPTCHA - Lesbarkeit der Bilder verbesserbar?

Maik Ernemann m.ernemann at ordana.de
Thu Apr 13 09:16:33 CEST 2006


Moin,Moin dieses script sollte das Problem lösen. 
Es werden nunmehr Zahlen statt Buchstaben 
angezeigt.

$imgHeight = 30;
$imgWidth = 120;
$str = "";

srand((double)microtime()*1000000);
for ($i = 0; $i < 5; $i++) {
    $cnum[$i] = rand(0,9);
    $str .= $cnum[$i];
}

$text = $_SESSION['tx_captcha_string'] = $str;
$img_number = imagecreate($imgWidth,$imgHeight);
$backcolor = imagecolorallocate($img_number,244,244,244);
$textcolor = imagecolorallocate($img_number,0,0,0);
$white = imagecolorallocate($img_number, 0xFF, 0xFF, 0xFF);
$gray    = imagecolorallocate($img_number, 0xC0, 0xC0, 0xC0);
$darkgray = imagecolorallocate($img_number, 0x50, 0x50, 0x50);

imagefill($img_number,0,0,$backcolor);


for ($i = 0; $i < 30; $i++) {
   $x1 = rand(0,$imgWidth);
   $y1 = rand(0,$imgHeight);
   $x2 = rand(0,$imgWidth);
   $y2 = rand(0,$imgHeight);
   imageline($img_number, $x1, $y1, $x2, $y2 , $gray);
}

for ($i = 0; $i < 5; $i++) {
  $fnt = rand(4,6);
  $x = $x + rand(12 , 20);
  $y = rand(7 , 12);
  imagestring($img_number, $fnt, $x, $y, $cnum[$i] , $darkgray);
}

header("Content-type: image/png");
imagepng($img_number);

-- 
Guß
Maik



More information about the TYPO3-german mailing list