使用php生成验证码
来源:互联网 发布:日本动漫 知乎 编辑:程序博客网 时间:2024/06/05 10:16
{
}
function HsvToRgb($H, $S, $V)
{
}
$size = 20;
$width = 80;
$height = 25;
// 产生4个随机字符
$randStr =array(rand(0, 9), rand(0, 9), rand(0, 9), rand(0, 9));
// 生成数字旋转角度
$degrees = array(rand(0, 45), rand(0, 45), rand(0, 45), rand(0, 45));
for($i = 0; $i < 4; ++$i)
{
}
$image = imagecreatetruecolor($size, $size);
$validate = imagecreatetruecolor($width, $height);
$back = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 0, 0, 0);
// 数字颜色
for($i = 0; $i < 4; ++$i)
{
}
imagefilledrectangle($validate, 0, 0, $width - 1, $height - 1, $back);
imagefilledrectangle($image, 0, 0, $size, $size, $back);
imagestring($image, 5, 6, 2, $randStr[0], $textcolor[0]);
$image = imagerotate($image, $degrees[0], $back);
imagecopy($validate, $image, 1, 4, 4, 5, imagesx($image) - 10, imagesy($image) - 10);
$image = imagecreatetruecolor($size, $size);
imagefilledrectangle($image, 0, 0, $size, $size, $back);
imagestring($image, 5, 6, 2, $randStr[1], $textcolor[1]);
$image = imagerotate($image, $degrees[1], $back);
imagecopy($validate, $image, 21, 4, 4, 5, imagesx($image) - 10, imagesy($image) - 10);
$image = imagecreatetruecolor($size, $size);
imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back);
imagestring($image, 5, 6, 2, $randStr[2], $textcolor[2]);
$image = imagerotate($image, $degrees[2], $back);
imagecopy($validate, $image, 41, 4, 4, 5, imagesx($image) - 10, imagesy($image) - 10);
$image = imagecreatetruecolor($size, $size);
imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back);
imagestring($image, 5, 6, 2, $randStr[3], $textcolor[3]);
$image = imagerotate($image, $degrees[3], $back);
imagecopy($validate, $image, 61, 4, 4, 5, imagesx($image) - 10, imagesy($image) - 10);
imagerectangle($validate, 0, 0, $width - 1, $height - 1, $border);
for($i = 0; $i < 200; ++$i) //加入干扰象素
{
}
// 干扰线使用颜色较明亮的颜色
$temp = RgbToHsv(rand(0, 255), rand(0, 255), rand(0, 255));
if($temp[2] < 200)
$temp = HsvToRgb($temp[0], $temp[1], $temp[2]);
$randlinecolor = imagecolorallocate($image, $temp[0], $temp[1], $temp[2]);
// 画5条干扰线
for ($i = 0;$i < 5; $i ++)
header('Content-type: image/png');
imagepng($validate);
imagedestroy($validate);
最后讨论一下新浪博客中的“收听验证码”,呵呵,看起来好像很复杂,考虑了一下,其实要实现也挺简单的,将单个数字录成mp3格式的声音文件,使用windows media player根据产生的数字播放出来(网页中嵌入个object)。考虑兼容问题最好使用flash播放。
提示一下:程序中有Rgb到Hsv颜色互换函数。
- 使用php生成验证码
- php 使用GD库生成验证码
- php 使用GD库生成验证码
- php使用GD库生成验证码
- 使用PHP实现自动生成验证码
- PHP之验证码生成和使用
- PHP生成验证码
- PHP 生成验证码
- PHP验证码生成
- PHP生成验证码
- php 生成验证码
- php 生成验证码
- php:生成验证码
- php验证码生成
- php生成验证码
- PHP 生成验证码
- PHP生成验证码
- php 生成验证码
- C++进阶小程序(画菱形)
- java从入门到高级的学习全攻略
- Manifest文件实战
- 关于线程和进程间的同步
- PC Camera开发日志(二十一)---- 窗口透明化处理
- 使用php生成验证码
- TOMCAT集群配置
- 商务智能相关技术_个人学习进度
- SVM图像识别界面
- fedora 8 硬盘安装
- 图形与图像的区别
- 35个专业设计的公司网站
- shell编程中如何计算使用除法
- C++科学计算库GSL及其配置