PHP without components to generate BMP verification code source code

Source: Internet
Author: User

<? PHP
// This is a PHP source code for generating BMP verification code without components, which is changed from the Program for generating BMP verification code without components in ASP
// Author: Wilson Chen
// QQ: 36935338
// Email: oeichenwei@yahoo.com

// Use the BMP library embedded in the program "0-9a-z" to generate real-color BMP (of course, it is also very small)
// To avoid crack, we recommend that you dynamically change the background color.
// For ease of processing, the number of digits of the verification code must be an even number, for example, 4, 6, 8 ....
// Save the file as test. php and reference .
// Original Author: layen
// QQ: 84815733
// E-mail: support@ssaw.net
Function validation ($ PSN)
{
// Disable caching
Header ("expires:-9999 ");
Header ("Pragma: No-Cache ");
Header ("cache-ctrol: No-Cache ");
// Header ("contenttype: image/BMP ");
Header ("contenttype: image/BMP ");

$ Codds = 8; // probability of occurrence of a noise
$ Camount = 36; // number of texts
$ CCode = "0123456789 abcdefghijklmnopqrstuvwxyz ";

// Color data (character, background)
$ Vcolordata [0] = "/X0/X0/x0"; // blue 0, green 0, red 0 (black)
$ Vcolordata [1] = "/xfa/xec/xD3"; // blue 250, green 236, red 211 (light blue)
$ Num = strlen ($ PSN );

// Generate random characters
For ($ I = 0; $ I <$ num; $ I ++)
{
$ Vcode [$ I] = strpos ($ cCode, $ PSN {$ I });
}

// Character data
$ Vnumberdata [0] = "1110000111110111101111011110111101001011110100101111010010111101001011110111101111011110111110000111 ";
$ Vnumberdata [1] = "1111011111110001111111110111111111011111111101111111110111111111011111111101111111110111111100000111 ";
$ Vnumberdata [2] = "1110000111110111101111011110111111111011111111011111111011111111011111111011111111011110111100000011 ";
$ Vnumberdata [3] = "1110000111110111101111011110111111110111111100111111111101111111111011110111101111011110111110000111 ";
$ Vnumberdata [4] = "1111101111111110111111110011111110101111110110111111011011111100000011111110111111111011111111000011 ";
$ Vnumberdata [5] = "1100000011110111111111011111111101000111110011101111111110111111111011110111101111011110111110000111 ";
$ Vnumberdata [6] = "1111000111111011101111011111111101111111110100011111001110111101111011110111101111011110111110000111 ";
$ Vnumberdata [7] = "1100000011110111011111011101111111101111111110111111110111111111011111111101111111110111111111011111 ";
$ Vnumberdata [8] = "1110000111110111101111011110111101111011111000011111101101111101111011110111101111011110111110000111 ";
$ Vnumberdata [9] = "1110001111110111011111011110111101111011110111001111100010111111111011111111101111011101111110001111 ";
$ Vnumberdata [10] = "1111011111111101111111101011111110101111111010111111101011111100000111110111011111011101111000100011 ";
$ Vnumberdata [11] = "1000000111110111101111011110111101110111110000111111011101111101111011110111101111011110111000000111 ";
$ Vnumberdata [12] = "1110000011110111101110111110111011111111101111111110111111111011111111101111101111011101111110001111 ";
$ Vnumberdata [13] = "1000001111110111011111011110111101111011110111101111011110111101111011110111101111011101111000001111 ";
$ Vnumberdata [14] = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011110111000000111 ";
$ Vnumberdata [15] = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011111111000111111 ";
$ Vnumberdata [16] = "1110000111110111011110111101111011111111101111111110111111111011100011101111011111011101111110001111 ";
$ Vnumberdata [17] = "1000100011110111011111011101111101110111110000011111011101111101110111110111011111011101111000100011 ";
$ Vnumberdata [18] = "1100000111111101111111110111111111011111111101111111110111111111011111111101111111110111111100000111 ";
$ Vnumberdata [19] = "1110000011111110111111111011111111101111111110111111111011111111101111111110111110111011111000011111 ";
$ Vnumberdata [20] = "1000100011110111011111011011111101011111110001111111010111111101101111110110111111011101111000100011 ";
$ Vnumberdata [21] = "1000111111110111111111011111111101111111110111111111011111111101111111110111111111011110111000000011 ";
$ Vnumberdata [22] = "1000100011110010011111001001111100100111110101011111010101111101010111110101011111010101111001010011 ";
$ Vnumberdata [23] = "1000100011110011011111001101111101010111110101011111010101111101100111110110011111011001111000110111 ";
$ Vnumberdata [24] = "1110001111110111011110111110111011111011101111101110111110111011111011101111101111011101111110001111 ";
$ Vnumberdata [25] = "1000000111110111101111011110111101111011110000011111011111111101111111110111111111011111111000111111 ";
$ Vnumberdata [26] = "1110001111110111011110111110111011111011101111101110111110111011111011101001101111011001111110001011 ";
$ Vnumberdata [27] = "1000001111110111011111011101111101110111110000111111010111111101101111110110111111011101111000110011 ";
$ Vnumberdata [28] = "1110000011110111101111011110111101111111111001111111111001111111111011110111101111011110111100000111 ";
$ Vnumberdata [29] = "1000000011101101101111110111111111011111111101111111110111111111011111111101111111110111111110001111 ";
$ Vnumberdata [30] = "1000100011110111011111011101111101110111110111011111011101111101110111110111011111011101111110001111 ";
$ Vnumberdata [31] = "1000100011110111011111011101111101110111111010111111101011111110101111111010111111110111111111011111 ";
$ Vnumberdata [32] = "1001010011110101011111010101111101010111110101011111001001111110101111111010111111101011111110101111 ";
$ Vnumberdata [33] = "1000100011110111011111101011111110101111111101111111110111111110101111111010111111011101111000100011 ";
$ Vnumberdata [34] = "1000100011110111011111011101111110101111111010111111110111111111011111111101111111110111111110001111 ";
$ Vnumberdata [35] = "1100000011110111011111111101111111101111111110111111110111111111011111111011111111101110111100000011 ";

// Output Image File Header
$ Nfilesize = 54 + $ num * 300;
Print ("/x42/x4d". CHR ($ nfilesize & 0xff). CHR ($ nfilesize> 8 ));
Print ("/X0/X0/X0/X0/X0/X0/x36/X0/X0/X0/x28/X0/X0/x0 ". CHR ($ num * 10 ). "/X0/X0/X0/XA/X0/X0/X0/x1/x0 ");

// Output image information Header
Print ("/X18/X0/X0/X0/X0/X0/xb0/X4/X0/X0/X12/XB/X0/X0/X12/XB/X0/X0/ x0/X0/X0/X0/X0/X0/X0/x0 ");

For ($ I = 9; $ I> = 0; $ I --) // goes through all rows
{
For ($ II = 0; $ II <$ num; $ II ++) // goes through all words
{
// Output image data row by row, word, and pixel
For ($ IIi = 0; $ III <10; $ III ++) // goes through all pixels
{
If (RAND (0,100) <$ codds)
{
// Generate random vertices
Print ($ vcolordata [0]);
}
Else
{
Print ($ vcolordata [$ vnumberdata [$ vcode [$ II] {$ I * 10 + $ III}]);
}
}
}
}
}
Validation ("123hem ");
?>

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.