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
|
<?php
//image.php
if (!isset($_SESSION)) {
session_start();
}
srand((float)microtime()*1000000);
$longueurTexte = 4;
$caracteres = array("1", "2", "3", "4", "5", "6", "7", "8", "9");
$compteur = 1;
$_SESSION['texte'] = "";
while ($compteur <= $longueurTexte) {
$_SESSION['texte'] = $_SESSION['texte'] . $caracteres[rand(0,count($caracteres)-1)];
$compteur = $compteur + 1;
}
header("Content-type: image/png");
$image = imagecreatetruecolor(90,40);
$color = "FFFFFF";
$rouge = hexdec(substr($color,0,2));
$vert = hexdec(substr($color,2,4));
$bleu = hexdec(substr($color,4,6));
$couleur = imagecolorallocate($image,$rouge,$vert,$bleu);
imagefill($image,0,0,$couleur);
$color = "000000";
$rouge = hexdec(substr($color,0,2));
$vert = hexdec(substr($color,2,4));
$bleu = hexdec(substr($color,4,6));
$black = imagecolorallocate($image,$rouge,$vert,$bleu);
imagettftext($image, 25, 0, 8, 30, $black, './arial.ttf', $_SESSION['texte']);
imageline($image,0,0,90,0,$black);
imageline($image,0,0,0,40,$black);
imageline($image,0,39,89,39,$black);
imageline($image,89,0,89,39,$black);
imageline($image,0,10,90,10,$black);
imageline($image,0,11,90,11,$black);
imageline($image,0,25,90,25,$black);
imageline($image,0,26,90,26,$black);
imageline($image,15,0,15,40,$black);
imageline($image,16,0,16,40,$black);
imageline($image,40,0,40,40,$black);
imageline($image,41,0,41,40,$black);
imageline($image,70,0,70,40,$black);
imageline($image,71,0,71,40,$black);
imagepng($image);
imagedestroy($image);
?> |
Partager