当前位置: 首页 > 图文教程 > 网络编程 > PHP > 不需要GD库的情况下实现验证码

PHP
XML轻松学习总节篇(转贴搜集)
XML轻松学习手册(2)XML概念
XML的术语
菜鸟的PHP笔记(1,2)
菜鸟的PHP笔记3
菜鸟的PHP笔记(4)
PHP的安装与配置
APACHE中 httpd.conf 的中文详解
php5.0.4配置文件简体中文版php.ini
LIUNX9+MYSQL4.1+GD2.0+TRUETYPE+GIF SUPPORT + APACHE2.0+ + P
apache的静态/动态编译在apache+php+mysql+gd中的应用
使用PHP 5.0 轻松解析XML文档
使用PHP 5.0 轻松解析XML文档(2)
使用PHP 5.0 轻松解析XML文档(3)
使用PHP 5.0 轻松解析XML文档(4)
使用PHP 5.0 轻松解析XML文档(5)
使用PHP 5.0 轻松解析XML文档(6)
PHP程序之服务器负载测试
ORACLE PHP教程--您了解 PHP 吗?
ORACLE PHP教程--从原型到产品的最短距离

PHP 中的 不需要GD库的情况下实现验证码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 82 ::
收藏到网摘: n/a

 

以下为引用的内容:

<?php
//+-------------------------------------------------
//| * 文件  validate_image.php
//| * 功能  实现网站登陆验证码
//| * 版本  1.0.0
//| * 日期  2005-4-1
//| * 作者  西北狼 QQ 500784 cokeyang at hotmail.com
//| * 版权  http://www.adibaby.com[暂时关闭]
//| * 使用方法:
//| 预先在支持GD库的做好一些图片,推荐使用GIF格式,文件名与图片里
//| 面的里面的数字一致,将图片放入一个文件夹。设置CONFIG里面的数据.
//| 引用 <IMG SRC="{ filepath }/validate_image.php">
//| 验证页面对比
//| $_COOKIE['validate'] == md5($_POST['input'])
//|==================CONFIG START===================
$image_path="numimage";// 图片文件路径 后面没有'/'
$image_ext ="gif";// 图片文件扩展名
//===================CONFIG END=====================
$imagelist = array();
if ($handle =opendir($image_path)) {
while (false !== ($file =readdir($handle))) {
$filename =explode(".",$file);
$imagelist[] = $filename[0];
unset($filename);
}
closedir($handle);
unset($imagelist[0]);
unset($imagelist[1]);
}
srand((float)microtime()*103E//| 引用 <IMG SRC="{ filepath }/validate_image.php">
//| 验证页面对比
//| $_COOKIE['validate'] == md5($_POST['input'])
//|==================CONFIG START===================
$image_path="numimage";// 图片文件路径 后面没有'/'
$image_ext ="gif";// 图片文件扩展名
//===================CONFIG END=====================
$imagelist = array();
if ($handle =opendir($image_path)) {
while (false !== ($file =readdir($handle))) {
$filename =explode(".",$file);
$imagelist[] = $filename[0];
unset($filename);
}
closedir($handle);
unset($imagelist[0]);
unset($imagelist[1]);
}
srand((float)microtime()*10000000);
$filename=$imagelist[array_rand($imagelist)];
setcookie("validate",md5($filename));
header('Content-type: application/'.$image_ext);
echo implode('',file($image_path."/".$filename.".".$image_ext));
?>