read()) { if(stristr($font,'.ttf')) { // Check GD Version 2.4.0 or later if (version_compare(GD_VERSION, '2.4.0', '>=')) { $fontList[] = "cFonts/".str_replace(".ttf", "", $font); } else { $fontList[] = "cFonts/".$font; } } } for ($i = 0; $i < 5; $i++) { $cnum[$i] = rand(0,9); $rC = rgb_rand(0, 175); $rColors[$i] = imagecolorallocate($image, $rC['r'], $rC['g'], $rC['b']); for ($x = 0; $x < 2; $x++) { $x1 = rand(0,280); $y1 = rand(0,80); $x2 = rand(0,280); $y2 = rand(0,80); imageline($image, $x1, $y1, $x2, $y2 , $rColors[$i]); } } /* generate random dots in background */ for( $i=0; $i<(280*80)/3; $i++ ) { imagefilledellipse($image, mt_rand(0,280), mt_rand(0,80), 1, 1, $gray); } for ($i = 0; $i < 5; $i++) { $x = $x + mt_rand(32, 48); $y = mt_rand(52, 64); $angle = mt_rand(-30, 30); $fnt = mt_rand(0, sizeof($fontList) - 1); $colori = $rColors[$i]; imagettftext($image, mt_rand(40, 48), $angle, $x, $y, $colori, $fontList[$fnt], $cnum[$i]); } $digit = "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]"; $_SESSION[$sitekey.'_digit'] = md5($sitekey.$digit); header("Expires: Tue, 11 Jun 1985 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header('Content-type: image/png'); imagepng($image); imagedestroy($image); exit( ); ?>