Generate Image Verification with PHP
Generate Image Verification is usually used to stop brute force attack in web application …
This code show how Generate Image Verification with PHP
<?
$str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO1234567890";
$randkey = substr(str_shuffle($str),0,7);
$image = imagecreatefromjpeg("./image/test.jpg");
$font = 9 ;
$black = imagecolorallocate($image,0,0,0);
$red = imagecolorallocate($image,100,0,0);
$y = (imagesy($image)-imagefontheight($font))/2;
$x = ((imagesx($image))/4);
imagestring($image,$font,$x,$y,$randkey,$black);
$font =3;
imagestring($image,$font,7,$y+20,”www.gunungpring.com”,$red);
header(”Content-type: image/jpeg”);
imagejpeg($image);
imagedestroy($image);
?>
Tags: PHP, programming