Home >Backend Development >PHP Tutorial >Implement verification code without GD library_PHP tutorial
Implement verification code without GD library
(as the current mainstream development language)
//+------------ -------------------------------------
//| * File validate_image.php(As the current mainstream development language)
//| * Function Implement website login verification code
//| * Version 1.0.0
//|
//| * Author Northwest Wolf QQ 500784 cokeyang at hotmail.com
//| >//| Prepare some pictures in advance that support the GD library. It is recommended to use GIF format. The file name should be consistent with the number in the picture
//|. Put the pictures into a folder. Set the data in CONFIG.
//| Reference//| 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//| Validation page comparison//| $_COOKIE[validate] == md5($_POST[input ])
//|==================CONFIG START===================
$image_path="numimage";//There is no /
$image_ext="gif";//The 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));
?>
http://www.bkjia.com/PHPjc/508692.html