PHP基于GD库验证码的制作
来源:互联网 发布:电脑软件管家 编辑:程序博客网 时间:2024/06/10 06:55
<?php
$count = 4;$type = 2;
$code = getCode($count, $type);
$height = 30;
$img = imagecreatetruecolor($width, $height);
$bg = imagecolorallocate($img, 200, 200, 200);
imagefill($img, 0, 0, $bg);
$color[] = imagecolorallocate($img, 54, 37, 52);
$color[] = imagecolorallocate($img, 27, 22, 69);
$color[] = imagecolorallocate($img, 124, 119, 22);
$color[] = imagecolorallocate($img, 23, 79, 16);
$color[] = imagecolorallocate($img, 10, 14, 91);
imagerectangle($img, 0, 0, $width-1, $height-1, $color[rand(0,count($color)-1)]);
for($i = 0; $i < $count; $i++){
imagettftext($img, 18, rand(-40,40), 8+(18*$i), 24, $color[rand(0,count($color)-1)], 'msyh.ttc', $code[$i]);
}
for($i = 0; $i < 200; $i++){
$randColor = imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255));
imagesetpixel($img, rand(0,$width), rand(0,$height), $randColor);
}
for($i = 0; $i < 5; $i++){
$randColor = imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255));
imageline($img, rand(0,$width), rand(0,$height), rand(0,$width), rand(0,$height), $randColor);
}
header("Content-Type:image/png");
imagepng($img);
imagedestroy($img);
function getCode($count=4, $type=0){
$str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$code = null;
$end = array(9,35,61);
for($i = 0; $i < $count; $i++){
$code .= $str[rand(0,$end[$type])];
}
return $code;
}
// echo getCode();
0 0
- PHP基于GD库验证码的制作
- php 基于GD库验证码
- 运用php GD库的图像函数制作登录验证码图片
- php使用GD库制作验证码,点击验证码或看不清会刷新验证码
- 使用GD库制作验证码
- PHP使用GD库画简单的验证码
- 利用php的GD库生成验证码
- PHP生成图像验证码(GD库的使用)
- PHP学习笔记之使用GD库制作验证码(一)
- 应用PHP GD库中图像处理函数制作验证码
- php 使用GD库生成验证码
- php 使用GD库生成验证码
- php GD库生成验证码
- php 简易验证码(GD库)
- php通过GD库实现验证码
- php GD库画图 验证码
- php使用GD库生成验证码
- php验证码 GD库生成验证码
- MongoDB学习
- MyBaits-sql简单操作
- Echarts简介
- jvm参数
- 【附源码】搭建spring mvc +freemarker
- PHP基于GD库验证码的制作
- April English Summary
- SSH三大框架的工作原理及流程
- C语言-零散的笔记
- 网络基本功:TCP拥塞控制机制
- 我是如何走上Android开发的道路的
- linux 静态库与动态库 博客汇集
- 网络编程( BIO )
- Android-通知Notification、Notification.Builder和NotificationCompat.Builder兼容