Implement verification code without GD library_PHP tutorial

WBOY
Release: 2016-07-13 17:32:32
Original
921 people have browsed it

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

truehttp: //www.bkjia.com/PHPjc/508692.htmlTechArticleImplementing verification code without GD library?php (as the current mainstream development language) //+ --------------------------------------------------/ /| * File validate_image.php (as the current...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template