Implement verification code without the need for the GD library

Source: Internet
Author: User
Tags config explode md5 reference
<?php
//+-------------------------------------------------
//| * File validate_image.php
//| * Function Realization Site Login authentication Code
//| * Version 1.0.0
//| * Date 2005-4-1
//| * Author of Northwest Wolf QQ 500784 Cokeyang at hotmail.com
//| * Copyright http://www.adibaby.com[temporarily closed]
//| * Use method:
//| In advance to support the GD library to do some pictures, recommend the use of GIF format, file name and pictures
//| The number in the face is consistent, put the picture into a folder. Set the data inside CONFIG.
//| Reference
//| Verify page Contrast
//| $_cookie[' Validate '] = = MD5 ($_post[' input ')
|==================config start===================
$image _path= "numimage";//Picture file path not followed by '/'
$image _ext = "gif";//Picture file name 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 Contrast
//| $_cookie[' Validate '] = = MD5 ($_post[' input ')
|==================config start===================
$image _path= "numimage";//Picture file path not followed by '/'
$image _ext = "gif";//Picture file name 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));
?>

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.