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

PHP
PHP函数:php中rename()函数的妙用
PHP实例:PHP验证码
PHP实例:PHP无限极分类
PHP实例:PHP操作文件类
PHP实例 PHP实现定时生成HTML网站首页
php脚本中include文件报错解决方法
在PHP中显示格式化的用户输入
PHP教程:在PHP中将图片存放ORACLE中
PHP5中的this,self和parent关键字详解
PHP实例:PHP的拼写检查函数库
PHP教程实例:用PHP打造动态聊天室系统
PHP基础:PHP4和PHP5的配置异同比较
使用PHP4.2.0及以后版本的注意事项
一个非常全面获取图象信息的PHP函数
比较测试PHP+MYSQL分页机制两种方案
PHP中用正则表达式验证中文的问题
php程序如何生成验证码图片
用php或js获取图片大小高宽尺寸
phpMyAdmin2.6以上版本数据乱码问题
巧学巧用:如何使用PHP中的字符串函数

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 110 ::
收藏到网摘: 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));
?>