php生成图片验证码
<?php
$string = "012efghnopq67ijklm89abcdr345stuvw34VJKL56xyz012789ABCDOPQRS678TUMN34WXYZ12EFGHI590";
for($i=1;$i<5;$i++){
$j = rand(0,81);
$rand.=substr($string,$j,1);
}
$im = imagecreatetruecolor(50,21);
$gdcolor = imagecolorallocate($im,205,205,205);
$red=imagecolorallocate($im,255,0,0);
$blue = imagecolorallocate($im,0,0,255);
$green = imagecolorallocate($im,0,255,0);
$randcolor = imagecolorallocate($im,rand(100,255),rand(100,255),rand(100,255));
imagefill($im,0,0,$gdcolor);
//imagestring($im,12,10,2,$rand,$red);
for($i=0;$i<300;$i++){
imagesetpixel($im,rand(0,50),rand(0,20),$randcolor);
}
imagestring($im,rand(5,9),rand(0,12),rand(0,5),$rand,$red);
//imageline($im,0,0,60,10,$green);
//imageline($im,0,20,50,5,$blue);
session_start();
$_SESSION['image']=strtolower($rand);
header("content_type: image/jpeg");
imagejpeg($im);
// imagedestroy($im);
?>
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(18)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(37)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(72)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)