備忘錄_20160105(定位)
修改
回首頁
程式 2021-04-09 17:26:58 1617960418 100
captcha 核心
captcha 核心
captcha_core.php
<?php
$iTotalWidth=130;
$iTotalHeight=50;
$strNumber=substr('0000' . rand(0,9999), -4);
$fontfile = realpath('OpenSans-Bold.ttf');
$image = imagecreatetruecolor($iTotalWidth,$iTotalHeight);
$backgroundcolor = imagecolorallocate($image,60,60,60);
$textColor = imagecolorallocate($image,155,155,155);
$fontsize1=rand(23,30);
$fontsize2=rand(23,30);
imagefill($image,0,0,$backgroundcolor);
for($i=0, $iMax=rand(5,10); $i<$iMax; $i++)
{
$lineColor = imagecolorallocate($image,rand(0,255),rand(0,255),rand(0,255));
$x1=rand(0, $iTotalWidth);
$x2=rand(0, $iTotalWidth);
$y1=rand(0, $iTotalHeight);
$y2=rand(0, $iTotalHeight);
imageline($image, $x1, $y1, $x2, $y2, $lineColor);
}
imagettftext($image, $fontsize1, rand(-15,15), 20, 40, $textColor, $fontfile, substr($strNumber,0,2));
imagettftext($image, $fontsize2, rand(-15,15), 65, 40, $textColor, $fontfile, substr($strNumber,2,2));
header("Content-Type: image/png");
imagepng($image);
exit;
?>