100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > php实现生成验证码实例分享 php验证码实例分享

php实现生成验证码实例分享 php验证码实例分享

时间:2018-10-10 18:00:53

相关推荐

php实现生成验证码实例分享 php验证码实例分享

php教程|php手册

php,生成验证码,

php教程-php手册

php实现生成验证码实例分享,php验证码实例分享

吸粉游戏源码,ubuntu没有账户界面,幼犬身上有爬虫,php是不是前后端都可以做,装饰方面seolzw

image.func.php

c mvc后端服务开发源码,vscode如何切换面板,ubuntu打开trash,tomcat上传bug,sqlite3使用实例,一个项目引入多个前端框架可行吗,爬虫爬取特定企业数据违法,php 参数引用传递,荆州网络推广seo,简单个人博客模板网站,头像抽奖网页,jsp个人博客网站模板lzw

<?php require_once(string.func.php); function verifyImage( $type=1,$length=4,$pixel=0,$line=0,$sess_name="verify"){ session_start(); /*定义长度和宽度*/$width=80;$height=30;/* 创建画布*/$image=imagecreatetruecolor($width, $height); /*本函数用来匹配图形的颜色,供其它绘图函数使用。参数 image 表示图形的 handle。参数 red、green、blue 是色彩三原色,其值从 0 至 255....我在此定义黑色和白色*/$white=imagecolorallocate($image, 255, 255, 255);$black=imagecolorallocate($image,0,0,0); /*本函数将图片的封闭长方形区域着色。参数 x1、y1 及 x2、y2 分别为矩形对角线的坐标。参数 col 表示欲涂上的颜色*/imagefilledrectangle($image, 1, 1, $width-2, $height-2, $white); /*buildRandomString函数用来生成一个验证码*/$chars=buildRandomString($type,$length); /*将验证码给session以便用来判断用户输入是否正确*/$_SESSION[$sess_name]=$chars; /*定义字体库*/$fontfiles=array(msyh.ttf,msyhbd.ttf,simsun.ttc,SIMYOU.TTF,STHUPO.TTF,STKAITI.TTF,STLITI.TTF); /*用循环来将验证码一个一个的写入图片中*/for($i=0;$i<$length;$i++){ $size=mt_rand(14,18); $angle=mt_rand(-15,15); /*验证码的横坐标与纵坐标*/ $x=5+$i*$size; $y=mt_rand(20,26); $color=imagecolorallocate($image,mt_rand(50,190),mt_rand(50,200),mt_rand(50,90)); $fontfile="../font/".$fontfiles[mt_rand(0,count($fontfiles)-1)]; $text=substr($chars,$i,1); /*本函数将 TTF (TrueType Fonts) 字型文字写入图片*/ imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text);}if($pixel){for($i=0;$i<50;$i++){ /*本函数可在图片上绘出一点。参数 x、y 为欲绘点的坐标,参数 col 表示该点的颜色*/ imagesetpixel($image, mt_rand(0,$width-1), mt_rand(0,$height-1), $black);}}if($line){ for($i=0;$i<10;$i++) { $color=imagecolorallocate($image,mt_rand(50,90),mt_rand(50,200),mt_rand(50,90)); /*画线段*/ imageline($image, mt_rand(0,$width-1), mt_rand(0,$height-1), mt_rand(0,$width-1), mt_rand(0,$height-1), $color);}}/*以gif形式输出*/header("content-type:image/gif");/*建立GIF图 并输出到网页*/imagegif($image);/*释放与 image 关联的内存*/imagedestroy($image);}

string.func.php

小程序免费源码下载网站,ubuntu命令卸载硬盘,哪种虫子是爬虫,php打包项目,正华SEOlzw

strlen($chars)){ exit("字符串长度不够");}/*打乱字符串*/$chars=str_shuffle($chars);return substr($chars,0,$length); } ?>

您可能感兴趣的文章:

php图片验证码代码PHP 动态随机生成验证码类代码PHP验证码类代码( 最新修改,完全定制化! )一个漂亮的php验证码类(分享)PHP生成验证码时“图像因其本身有错无法显示”的解决方法PHP生成图片验证码、点击切换实例php生成验证码函数thinkphp3.2点击刷新生成验证码php生成验证码,缩略图及水印图的类分享

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。