Hi
nach dem reload der seite erscheint der sicherheitscode, vorher - beim erstaufruf - war er jedoch nicht zu sehen.
phänomen nach cache-löschung reproduzierbar.
Was kann ich da machen?
Wo liegt die Ursache?
Hier mal mein Script:
session_start();
/* Code to create an image resource with a random X digit code on it, typed in a random font.
Useful for validating against bots in signup forms. Feel free to use,as long as proper credit
is given. By Chuck Harmstoncharmston(at)gmail(dot)com
Last modified: July 25,2004 */
/*
Defines headers to be sent to browser */
header("Content-Type: image/png");
/* User-changable paramaters - colors, shown later on, may also be changed */
$image_height = 25;
$image_width = 80;
$characters = 8;
$font_size = 12;
$font_path = "./";
$font_array = array("arial.ttf","tahoma.ttf","times.ttf","verdana.ttf","trebuc.ttf");
/* Selects a random font to use from the fonts in the array */
shuffle($font_array);$font = $font_path.$font_array[0];
/* Obtains random 8 digit character by encoding (through md5) the current Unix timestamp,and then grabbing a random 8-character string from within the 32-character encoded string */
// $start = mt_rand(1,32-$characters);
// $string = substr(md5(time()),$start,$characters);$string = $_SESSION['string'];
/* Creates blank image */
$output_image = imagecreatetruecolor($image_width,$image_height);
/* Defines colors to be used in the image - Change ###, ###, ### to the 'red, green, blue' values of the color that you wish to use */
$backgroundcolor = imagecolorallocate($output_image,255,255,255);
$textcolor = imagecolorallocate($output_image,0,0,0);
$bordercolor = imagecolorallocate($output_image,0,0,0);
/* Colors & creates borders of image */
imagefilledrectangle ($output_image,0,0,$image_width,$image_height,$backgroundcolor);
/*imageline($output_image,0,0,$image_width,0,$bordercolor);
imageline($output_image,0,0,0,$image_height,$bordercolor);
imageline($output_image,$image_width-1,0,$image_width-1,$image_height,$bordercolor);
imageline($output_image,0,$image_height-1,$image_width,$image_height-1,$bordercolor);*/
/* Credits for this handy function go to 'LB' from http://us3.php.net/manual/en/function.imagettfbbox.php - I use it to find the width & height of the will-be text box*/
function fixbbox($bbox){
$tmp_bbox["width"] = max($bbox[0],$bbox[2],$bbox[4],$bbox[6])-min($bbox[0],$bbox[2],$bbox[4],$bbox[6]) + 1;
$tmp_bbox["height"] = max($bbox[1],$bbox[3],$bbox[5],$bbox[7])-min($bbox[1],$bbox[3],$bbox[5],$bbox[7]);
return $tmp_bbox;
}
/* Writes string on image */
$bbox = fixbbox(imagettfbbox($font_size,0,$font,$string));
$font_x = ($image_width-$bbox["width"])/2;
$font_y = (($image_height-$bbox["height"])/2)+$font_size;
imagettftext($output_image,$font_size,0,$font_x,$font_y,$textcolor,$font,$string);
/* Creates and destroys image */
imagepng($output_image);
imagedestroy($output_image);
Gruß Andreas