Implementation of verification code without the need of GD library
Source: Internet
Author: User
KeywordsImplementation of verification code without the need of GD library
Implementation of verification code without the need of GD library
//+-------------------------------------------------
//| * 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]
//| * How to use:
//| In advance in support of the GD library to do some of the pictures, we recommend the use of GIF format, file name and image
//| The number in the face is the same, put the picture in a folder. Set the data inside the CONFIG.
//| Reference
//| Verify page comparison
//| $_cookie[' Validate '] = = MD5 ($_post[' input '])
|==================config start===================
$image _path= "numimage";//The picture file path does not have a '/'
$image _ext = "gif";//Picture 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//| Reference
//| Verify page comparison
//| $_cookie[' Validate '] = = MD5 ($_post[' input '])
|==================config start===================
$image _path= "numimage";//The picture file path does not have a '/'
$image _ext = "gif";//Picture 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));
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.