Verification code without the GD Library

Source: Internet
Author: User
The verification code is implemented without the GD Library. What is the verification code when the GD library is not required? Php (as the mainstream development language) + ------------------------------------------------- | * file validate_image.php (as the current verification code without the GD Library)
// + -------------------------------------------------
// | * File validate_image.php (as the mainstream development language)
// | * Function to implement the website login verification code
// | * Version 1.0.0
// | * Date: 2005-4-1
// | * Author: QQ 500784 cokeyang at hotmail.com
// | * Copyright http://www.adibaby.com [temporarily closed]
// | * Usage:
// | Some images can be prepared in the GD Library in advance. the GIF format, file name, and image are recommended.
// | The numbers in the image are the same. put the image in a folder. Set the data in CONFIG.
// | Reference
// | Verification page Comparison
// | $ _ COOKIE [validate] = md5 ($ _ POST [input])
// | ============================== Config start ============================ =
$ Image_path = "numimage"; // The image file path is not followed/
$ 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 // | reference
// | Verification page Comparison
// | $ _ COOKIE [validate] = md5 ($ _ POST [input])
// | ============================== Config start ============================ =
$ Image_path = "numimage"; // The image file path is not followed/
$ 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 ));
?>

Why? Php (as the mainstream development language) // + --------------------------------------------------- // | * file validate_image.php (as the current...

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.