<?php
if (version_compare(PHP_VERSION, '5.0.0') >= 0) {
	date_default_timezone_set("Europe/Berlin");
}
session_start();
$size_x = 70;
$size_y = 25;
$zufallszahl = mt_rand("100000", "999999");
$_SESSION["captcha_code"] = $zufallszahl;
$bild = imageCreate($size_x, $size_y);
imageColorAllocate($bild, 255, 255, 255);
$farbe1 = mt_rand("0", "175");
$farbe2 = mt_rand("0", "175");
$farbe3 = mt_rand("0", "175");
$rahmen = imageColorAllocate($bild, 0, 0, 0); // Rahmenfarbe
$farbe  = imageColorAllocate($bild, $farbe1, $farbe2, $farbe3); // Textfarbe
$alle_punkte = ($size_x * $size_y)/15;
for ($zaehler = 0; $zaehler < $alle_punkte; $zaehler++) {
 $pos_x = mt_rand("0", $size_x);
 $pos_y = mt_rand("0", $size_y);
 imageSetPixel($bild, $pos_x, $pos_y, $farbe);
};
imageRectangle($bild, 0, 0, $size_x-1, $size_y-1, $rahmen);
$pos_x = 8; // links
$pos_y = 5; // oben
imageString($bild, 5, $pos_x, $pos_y, $zufallszahl, $farbe);
header("Content-Type: image/png");
echo imagePNG($bild);
imageDestroy($bild);
?>