<?php
//session_start();

// Envoie les headers appropriés pour l'affichage de l'image
header('Content-type: image/png');
//header('Cache-control: no-cache, no-store');
//header('Expires: 0');

//global $config;

// Crée une image blanche de 200x50 pixels
$image = imagecreatefrompng("./www/captcha.png");
//$color = imagecolorallocate($image, 255, 255, 255);
//imagefill($image, 0, 0, $color);

// Génère un texte aléatoire à afficher
$random_text = rand(1000,9999);

// Enregistre le texte dans la variable de session pour la vérification ultérieure
//$_SESSION['captcha'] = $random_text;

// Ajoute le texte sur l'image
/*
putenv('GDFONTPATH=' . realpath('.'));
$font = "desyrel";
$text_color = imagecolorallocate($image, 0, 0, 0);
imagettftext($image, 20, 5, 50, 30, $text_color, $font, $random_text);

imagestring($im, 3, $px, 9, $string, $orange);
*/
// Affiche l'image PNG générée
imagepng($image);

// Détruit l'image pour libérer la mémoire
imagedestroy($image);