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
| <?php
session_start();
$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$chaine = '';
for( $i = 0; $i < 5; $i++ ){
$tab[$i] = $string[ mt_rand( 0, 35 ) ];
$chaine .= $tab[$i] ;
}
$_SESSION['verif'] = $chaine;
header ("Content-type: image/png");
$image = @Imagecreate (500 , 150);
$couleur = ImageColorAllocate($image,0 ,0 ,0 );
$couleur1 = ImageColorAllocate ($image, mt_rand(1, 255), mt_rand(1, 255), mt_rand(1, 255));
$couleur2 = ImageColorAllocate ($image, mt_rand(1, 255), mt_rand(1, 255), mt_rand(1, 255));
$couleur3 = ImageColorAllocate ($image, mt_rand(1, 255), mt_rand(1, 255), mt_rand(1, 255));
$couleur4 = ImageColorAllocate ($image, mt_rand(1, 255), mt_rand(1, 255), mt_rand(1, 255));
$couleur5 = ImageColorAllocate ($image, mt_rand(1, 255), mt_rand(1, 255), mt_rand(1, 255));
ImageTTFText($image,mt_rand(15, 30),mt_rand(-30, 30),(150+6*5),80, $couleur1,"newsflashbb.ttf","$tab[0]");
ImageTTFText($image,mt_rand(15, 30),mt_rand(-30, 30),(150+10*6),80, $couleur2,"newsflashbb.ttf","$tab[1]");
ImageTTFText($image,mt_rand(15, 30),mt_rand(-30, 30),(150+15*7),80, $couleur3,"newsflashbb.ttf","$tab[2]");
ImageTTFText($image,mt_rand(15, 30),mt_rand(-30, 30),(150+20*8),80, $couleur4,"newsflashbb.ttf","$tab[3]");
ImageTTFText($image,mt_rand(15, 30),mt_rand(-30, 30),(150+25*9),80, $couleur5,"newsflashbb.ttf","$tab[4]");
ImageColorTransparent($image, $couleur);
ImagePng ($image);
?> |
Partager