Guten Morgen zusammen!
Ich habe bis vor kurzem noch auf der PHP-Version 5.1.1 gearbeitet, mit der folgender Code funktionierte:
Aufgerufen wird die Datei folgendermaßen:
Das hat in Version 5.1.1 noch funktioniert. Seit meine HP auf einem Server mit PHP 5.1.4 liegt (und ich ebenfalls 5.1.4 nutze) funktioniert der Aufruf nicht mehr. Die Ausgabe sieht immer so aus:

Ich bin da jetzt ziemlich ratlos. Hat einer 'nen Tip woran es liegen könnte? Oder etwas wonach ich Suchen kann?
Ich habe bis vor kurzem noch auf der PHP-Version 5.1.1 gearbeitet, mit der folgender Code funktionierte:
Code:
class Captcha
{
private $captchaImg = NULL;
private $backgroundcolor = array ();
private $fontcolor = array ();
private $str = '';
public function __construct ()
{
session_start ();
$this->str = $this->generateNumber ();
$this->createCaptchaImgage ();
}
private function generateNumber ()
{
$num = mt_rand (microtime (), microtime ()*1000);
return substr (md5 ($num), 0, 6);
}
private function drawBackground ()
{
for ($i = 0; $i<10; $i++)
{
$bgcol = mt_rand (200, 255); # Nur Grautöne für Hintergrund
$this->backgroundcolor[] = imagecolorallocate ($this->captchaImg, $bgcol, $bgcol, $bgcol);
$this->fontcolor[] = imagecolorallocate ($this->captchaImg, mt_rand (0, 150), mt_rand (0, 150), mt_rand (0, 150));
}
imagefilledrectangle ($this->captchaImg, 0, 0, 195, 30, $this->backgroundcolor[array_rand ($this->backgroundcolor)]);
for ($j = 0; $j<20; $j++)
imageline ($this->captchaImg, mt_rand (0, 195), mt_rand (0, 25), mt_rand (0, 195), mt_rand (0, 25), $this->backgroundcolor[array_rand ($this->backgroundcolor)]);
}
private function createCaptchaImgage ()
{
$this->captchaImg = @imagecreatetruecolor (195, 30);
if (!$this->captchaImg)
throw new Exception ('Initialisierung des GD-Bild-Streams fehlgeschlagen!', 1);
$this->drawBackground ();
$_SESSION['pass'] = strtoupper ($this->str);
$x = 15;
$y = mt_rand (25, 20);
for ($i = 0; $i < 6; $i++)
{
$font = mt_rand (6, 16);
if (function_exists ('imagettftext'))
imagettftext ($this->captchaImg, 20, mt_rand(-13, 13), $x, $y, $this->fontcolor[array_rand ($this->fontcolor)], 'acquaintance.ttf', $this->str{$i});
else
imagestring ($this->captchaImg, $font, $x, $y, $this->str{$i}, $this->fontcolor[array_rand ($this->fontcolor)]);
$x = $x + 30;
$y = mt_rand (25, 20);
}
}
public function show ()
{
header("Content-type: image/png");
imagepng ($this->captchaImg);
imagedestroy ($this->captchaImg);
}
}
$class = new Captcha ();
$class->show ();
Code:
[img]includes/class.captcha.php[/img]

Ich bin da jetzt ziemlich ratlos. Hat einer 'nen Tip woran es liegen könnte? Oder etwas wonach ich Suchen kann?

Kommentar