1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <?php
session_start();
header("Content-type: image/png");
$liste = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$code = '';
while(strlen($code) != 6) {
$code .= $liste[rand(0,36)];
}
$_SESSION['code']=$code;
$img = imageCreate(70, 20) or die ("Problème de création GD");
$background_color = imagecolorallocate ($img, 255, 255, 255);
$ecriture_color = imagecolorallocate ($img, 0, 0, 0);
$code_police=5;
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
imageString($img, $code_police,(70-imageFontWidth($code_police) * strlen("".$code.""))/2,0, $code,$ecriture_color);
imagepng($img,'',30);
imageDestroy($img);
?> |
Partager