1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?php error_reporting(E_ALL); session_start(); header('content-type: image/png'); $imgC = rand(1,4); $imgS = "./images/captcha/captcha00".$imgC.".png"; if(!isset($_SESSION['code_captcha'])){ $numbers = rand(100, 9999); } else { $numbers = $_SESSION['code_captcha']; } $font = './images/captcha/Comic_Andy.ttf'; $color = ImageColorAllocate($imgS, 255, 255, 255); $size = 5; ImageString($imgS, $size, rand(3, 12), rand(5, 7), $numbers, $color); imagepng($imgS); imagedestroy($imgS);