php图像验证代码
发布:smiling 来源: PHP粉丝网 添加日期:2014-08-19 10:34:15 浏览: 评论:0
- <?php
- session_start();
- header("content-type: image/png");
- $str = "的一是在了不和有大这主中人上为们地个用工时要动国产以我到绳穷塘燥泡袋朗喂铝软渠颗惯贸粪综墙趋彼届墨碍启逆卸航雾冠丙街莱";
- $imgwidth = 110;
- $imgheight = 24;
- $authimg = imagecreate($imgwidth,$imgheight);
- $bgcolor = imagecolorallocate($authimg,255,255,255);
- $fontfile = "wrzc_net.ttf";
- $white=imagecolorallocate($authimg,234,185,95);
- imagearc($authimg, 150, 8, 20, 20, 75, 170, $white);
- imagearc($authimg, 100, 7,50, 22, 75, 175, $white);
- imageline($authimg,20,20,180,30,$white);
- imageline($authimg,20,18,170,50,$white);
- imageline($authimg,25,50,80,50,$white);
- $noise_num = 100;
- $line_num = 5;
- imagecolorallocate($authimg,0xff,0xff,0xff);
- $rectangle_color=imagecolorallocate($authimg,0xaa,0xaa,0xaa);
- $noise_color=imagecolorallocate($authimg,0x33,0x33,0x33);
- $font_color=imagecolorallocate($authimg,0x00,0x00,0x00);
- $line_color=imagecolorallocate($authimg,0x00,0x00,0x00);
- for($i=0;$i<$noise_num;$i++){
- imagesetpixel($authimg,mt_rand(0,$imgwidth),mt_rand(0,$imgheight),$noise_color);
- }
- for($i=0;$i<$line_num;$i++){
- imageline($authimg,mt_rand(0,$imgwidth),mt_rand(0,$imgheight),mt_rand(0,$imgwidth),mt_rand(0,$imgheight),$line_color);
- }//开源代码phpfensi.com
- $randnum=rand(0,strlen($str)-4);
- if($randnum%2)$randnum+=1;
- $str = substr($str,$randnum,8);
- $_session['supdesverify'] = $str;
- $str = iconv("gb2312","utf-8",$str);
- imagettftext($authimg, 20, 0, 0, 21, $font_color, $fontfile, $str);
- imagepng($authimg);
- imagedestroy($authimg);
- ?>
Tags: php图像验证代码
- 上一篇:php大图生成缩略图实现代码
- 下一篇:php gd库函数生成高清缩略图程序
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)