中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

生成驗(yàn)證碼 隨機(jī)干擾php實(shí)現(xiàn)

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
<?php
session_start ();
header ( 'Content-type: image/png' );
//創(chuàng)建圖片
$im = imagecreate($x=130,$y=45 );
$bg = imagecolorallocate($im,rand(50,200),rand(0,155),rand(0,155)); //第一次對(duì) imagecolorallocate() 的調(diào)用會(huì)給基于調(diào)色板的圖像填充背景色
$fontColor = imageColorAllocate ( $im, 255, 255, 255 );   //字體顏色
$fontstyle = 'rock.ttf';     //字體樣式,這個(gè)可以從c:\windows\Fonts\文件夾下找到,我把它放到和authcode.php文件同一個(gè)目錄,這里可以替換其他的字體樣式
//產(chǎn)生隨機(jī)字符
for($i = 0; $i < 4; $i ++) {
	$randAsciiNumArray = array (rand(48,57),rand(65,90));
	$randAsciiNum = $randAsciiNumArray [rand ( 0, 1 )];
	$randStr = chr ( $randAsciiNum );
	imagettftext($im,30,rand(0,20)-rand(0,25),5+$i*30,rand(30,35),$fontColor,$fontstyle,$randStr);
	$authcode .= $randStr;
}
$_SESSION['authcode'] = $randFourStr;//用戶和用戶輸入的驗(yàn)證碼做比較

//干擾線
for ($i=0;$i<8;$i++){
	$lineColor        = imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
	imageline ($im,rand(0,$x),0,rand(0,$x),$y,$lineColor);
}

//干擾點(diǎn)
for ($i=0;$i<250;$i++){
	imagesetpixel($im,rand(0,$x),rand(0,$y),$fontColor);
}
imagepng($im);
imagedestroy($im);
?>

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:載入圖像時(shí)顯示正在載入中的jQuery實(shí)現(xiàn)

下一篇:給現(xiàn)有的圖片加文字水印php代碼