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

PHP
PHP实例教程:网页登陆验证码
PHP教程:研究批量删除数据的方法
PHP教程:PHP函数简单中文说明
PHP教程:几段值得初学者研究的PHP代码段
PHP端口扫描器
Apache负载均衡设置方法: mod_proxy
PHP教程:PHP代码中的名称空间
PHP实例教程(1):构建基于PHP的微博客服务
PHP实例教程(4):构建基于PHP的微博客服务
PHP教程:PHP框架论述
PHP教程:Magic quotes
PHP实例教程:天气预报小偷PHP代码
PHP实例说明编写PHP代码的5个好习惯
PHP教程:网站开发编程中的特殊符号处理
PHP教程:php调用fckeditor函数
Apache安装配置和虚拟主机配置教程
PHP5安装配置和Zend Optimizer安装教程
.htaccess文件设置技巧16则
Apache的Rewrite和404错误页面
有关数据检索的更多内容

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


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