WICHTIGER HINWEIS!!!
Der von mir im ersten Teil angezeigte Code für die Datei captcha.php ist nicht ganz vollständig, hier der korrekte und vollständige Code:
<?php
session_start();
function strrand($length)
{
$str = "";
while(strlen($str)<$length){
$random=rand(48,122);
#if( ($random>47 && $random<58-) ){
if (ereg('[A-Za-z]',chr($random)))
$str.=chr($random);
#}
}
return $str;
}
$imgHeight = 20;
$imgWidth = 50;
$text = $_SESSION['tx_captcha_string'] = strrand(5);
$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);
imagefill($img_number,0,0,$backcolor);
Imagestring($img_number,5,1,1,$text,$textcolor);
//some obfuscation
for ($i=0; $i<2; $i++) {
$x1 = rand(0, $imgWidth - 1);
$y1 = rand(0, round($imgHeight / 10, 0));
$x2 = rand(0, round($imgWidth / 10, 0));
$y2 = rand(0, $imgHeight - 1);
imageline($img_number, $x1, $y1, $x2, $y2, $white);
$x1 = rand(0, $imgWidth - 1);
$y1 = $imgHeight - rand(1, round($imgHeight / 10, 0));
$x2 = $imgWidth - rand(1, round($imgWidth / 10, 0));
$y2 = rand(0, $imgHeight - 1);
imageline($img_number, $x1, $y1, $x2, $y2, $white);
}
header("Content-type: image/png");
imagepng($img_number);
?>
Besten Dank an latschma der mich hierauf hinwiesen hat 🙂