1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
<?php
session_start();
$liste = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$code = '';
while(strlen($code) != 6) {
$code .= $liste[mt_rand(0,36)];
}
$_SESSION['code']=$code;
$img = imageCreate(70, 20) or die ("Problème de création GD");
$background_color = imagecolorallocate ($img, 238, 238, 238);
$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);
header("Content-type: image/jpeg");
imageString($img, $code_police,(70-imageFontWidth($code_police) * strlen("".$code.""))/2,0, $code,$ecriture_color);
imagejpeg($img,'',20);
imagedestroy($img);
?> |
Partager