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

PHP
PHP中上传大体积文件时需要的设置
用PHP生成PDF文件 with FPDF
在同一窗体中使用PHP来处理多个提交任务
PHP经验交流:php访问access的方法
PHP实用手册:PHP常用正则表达式收集
也用PHP来实现网页静态发布的两种方法
PHP使用zlib扩展实现页面GZIP压缩输出
PHP的语言层面的优化以及代码优化技巧
PHP实例:上传多个图片并校验的代码
用php+odbc+access数据库来操作函数
用PHP来实现页面GZIP的压缩输出教程
PHP进阶技巧:php用流方式制作缩略图
使用php 5时MySQL返回乱码的解决办法
新手如何使用PHP来创建RSS的阅读器
PHP实用:用PHP来实现图片的简单上传
利用php和js来轻松实现页面数据的刷新
在PHP中使用随机数的三个步骤详细代码
PHP进阶技巧:如何避免表单的重复提交
PHP技术进阶 PHP SOCKET 技术研究
PHP技术进阶:php用流方式制作缩略图

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


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