Implement verification code without GD library
Author:Eve Cole
Update Time:2009-06-01 17:49:03
Implement verification code without GD library
<?php
//+-------------------------------------------------- --
//| * File validate_image.php
//| * Function to implement website login verification code
//| * Version 1.0.0
//| * Date 2005-4-1
//| * Author Northwest Wolf QQ 500784 cokeyang at hotmail.com
//| * Copyright http://www.adibaby.com [Temporarily closed]
//| * Usage:
//| Prepare some pictures in advance that support the GD library. It is recommended to use GIF format. File name and picture
//| If the numbers inside are consistent, put the pictures into a folder. Set the data in CONFIG.
//| Reference <IMG SRC="{ filepath }/validate_image.php">
//| Verification page comparison
//| $_COOKIE['validate'] == md5($_POST['input'])
//|==================CONFIG START====================
$image_path="numimage";//There is no '/' after the image file path
$image_ext = "gif"; // Image file extension
//====================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//| Quote<IMG SRC="{ filepath }/validate_image.php">
//| Verification page comparison
//| $_COOKIE['validate'] == md5($_POST['input'])
//|==================CONFIG START====================
$image_path="numimage";//There is no '/' after the image file path
$image_ext = "gif"; // Image file extension
//====================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));
?>