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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| <?php
// start session
session_start();
// ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnpqrstwxyz123456789
$liste = 'abcdefghkmnpqrstwxyz23456789';
$code_now = '';
// =5
while(strlen($code_now) != 5)
{
$code_now .= $liste[rand(0, 63)];
}
$_SESSION['image'] = $code_now;
header('Content-type: image/jpeg');
header('Cache-Control: no-store, no-cache, must-revalidate');
// 40, 15
$img = imageCreate(50, 20);
$bc = imageColorAllocate($img, 51, 51, 51);
$texte = imageColorAllocate($img, 254, 255, 240);
// 2, 5, 1.875,
imageString($img, '4', 5, 2.875, $code_now, $texte);
// 30
imagejpeg($img, '', 30);
imageDestroy($img);
?> |
Partager