tkiela
Hüüüüäääh? :):)
- 25 August 2007
- 634
- 44
Moin.
Ich hab gerad mal versucht ein Captcha mit PHP zu machen.
Folgenden Code habe ich verwendet:
Zu finden ist eine Demo unter:
https://www.paid4-szene.de/test.php
Nur jetzt kommt da manchmal noch
Wodran liegt das?
Ich hab gerad mal versucht ein Captcha mit PHP zu machen.
Folgenden Code habe ich verwendet:
PHP:
<?php
error_reporting(E_ALL);
function createcaptcha() {
$captcha = array();
$letters = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9");
$string_letters = array();
srand ((double)microtime()*1000000);
for($i=0;$i<=8;$i++) {
$random = rand(1, 36);
$string_letters[$i] = $letters[$random];
}
$string = $string_letters[1];
$string .= $string_letters[2];
$string .= $string_letters[3];
$string .= $string_letters[4];
$string .= $string_letters[5];
$string .= $string_letters[6];
$string .= $string_letters[7];
$string .= $string_letters[8];
unset($string_letters);
$randcol0=rand(1,255);
$randcol1=rand(1,255);
$randcol2=rand(1,255);
$randcol3=rand(1,255);
$randcol4=rand(1,255);
$randcol5=rand(1,255);
$randcol6=rand(1,255);
$randcol7=rand(1,5);
$randcol8=rand(1,255);
$randcol9=rand(1,255);
$randcol10=rand(1,255);
$fontWidth = imagefontwidth($randcol7);
$im = @imagecreatetruecolor((8*$fontWidth)+10, 20) OR die("Es konnte leider kein Captcha erstellt werden!");
imagecolorallocate($im, 220, 220, 220);
$text_color = imagecolorallocate($im, $randcol2, $randcol5, $randcol0);
$line_color = imagecolorallocate($im, rand(1,155), rand(1,155), rand(1,155));
$line_color2 = imagecolorallocate($im, rand(1,155), rand(1,155), rand(1,155));
$line_color3 = imagecolorallocate($im, rand(1,155), rand(1,155), rand(1,155));
$line_color4 = imagecolorallocate($im, rand(1,155), rand(1,155), rand(1,155));
$line_color5 = imagecolorallocate($im, rand(1,155), rand(1,155), rand(1,155));
$line_color6 = imagecolorallocate($im, rand(1,155), rand(1,155), rand(1,155));
$line_color7 = imagecolorallocate($im, rand(1,155), rand(1,155), rand(1,155));
imageline($im, 0, 0, (8*$fontWidth)+10, 20, $line_color);
imageline($im, 0, 20, (8*$fontWidth)+10, 0, $line_color2);
/* imageline($im, 0, 10, (8*$fontWidth)+10, 0, $line_color3);
imageline($im, 0, 0, (8*$fontWidth)+10, 10, $line_color4);
imageline($im, 0, 10, (8*$fontWidth)+10, 10, $line_color5); */
imageline($im, 0, 15, (8*$fontWidth)+10, 2, $line_color6);
imageline($im, 0, 1, (8*$fontWidth)+10, 9, $line_color7);
imagestring($im, $randcol7, 5, 5, $string, $text_color);
imagepng($im);
$captcha['string'] = $string;
return $captcha;
};
header("Content-type: image/png");
$img = createcaptcha();
echo $img['string'];
?>
Zu finden ist eine Demo unter:
https://www.paid4-szene.de/test.php
Nur jetzt kommt da manchmal noch
PHP:
Die Grafik "https://www.paid4-szene.de/test.php" kann nicht angezeigt werden, weil sie Fehler enthält.
Wodran liegt das?
