ASP program for generating images from webpages (telephone, QQ, and other numbers)

Source: Internet
Author: User

Purpose: use ASP Program Generate an image format for the phone number on the page. CopyCode The Code is as follows: <%
Call com_creatvalidcode (request. querystring ("tel "))
Public sub com_creatvalidcode (ptel)
'---------- Disable caching
Response. expires = 0
Response. addheader "Pragma", "No-Cache"
Response. addheader "cache-ctrol", "No-Cache"
Response. contenttype = "image/BMP"
Randomize
Dim I, II, III, rndcolor, strlen, SQL, RS
Const codds = 5' ------------ probability of occurrence of miscellaneous
Const STR = "0123456789 -"
Strlen = Len (ptel)
Rndcolor = chrb (CINT (RND * 255) & chrb (CINT (RND * 255) & chrb (CINT (RND * 255 ))
'----------- Color data (character, background)
Dim vcolordata (1)
'Vcolordata (0) = chrb (0) & chrb (0) & chrb (0) '---- blue 0, green 0, red 0 (black)
'Vcolordata (1) = chrb (255) & chrb (255) & chrb (255) '---- blue 250, green 236, red 211 (light blue)
'Vcolordata (0) = chrb (197) & chrb (106) & chrb (49) '---- blue 0, green 0, red 0 (black)
'Vcolordata (1) = chrb (238) & chrb (210) & chrb (193) '----- blue 250, green 236, red 211 (light blue)
Vcolordata (0) = chrb (0) & chrb (0) & chrb (0) '--------- blue 0, green 0, red 0 (black)
Vcolordata (1) = chrb (205) & chrb (237) & chrb (245) '------------ blue 250, green 236, red 211 (light blue)
'-------------------- Randomly generated characters
Randomize
Dim vcode ()
Redim vcode (strLen-1)
For I = 0 to strLen-1
Vcode (I) = instr (1, STR, mid (ptel, I + 1,1), 1)-1
Next
'----------- Character data
Dim vnumberdata (11)
'Verdana font
Vnumberdata (0) = "11111111111000111101110111011101110111011101110111011101110111011110001111111111"
Vnumberdata (1) = "11111111111101111110011111110111111101111111011111110111111101111110001111111111"
Vnumberdata (2) = "11111111111000111101110111011101111110111111011111101111110111111100000111111111"
Vnumberdata (3) = "11111111111000111101110111111101111100111111110111111101110111011110001111111111"
Vnumberdata (4) = "11111111111110111111001111101011111010111101101111100001111110111111100111111111"
Vnumberdata (5) = "11111111110000011101111111011111110000111111110111111101110111011110001111111111"
Vnumberdata (6) = "11111111111000111101101111011111110000111101110111011101110111011110001111111111"
Vnumberdata (7) = "11111111110000011101101111111011111101111111011111110111111101111111011111111111"
Vnumberdata (8) = "11111111111000111101110111011101111000111101110111011101110111011110001111111111"
Vnumberdata (9) = "11111111111000111101110111011101110111011110000111111101111011011110000111111111"
Vnumberdata (10) = "11111111111111111111111111111111111111111100000111111111111111111111111111111111"
Vnumberdata (11) = "11111111111111111111111111111111111111111111111111111111111111111111111111111111"
'--------------- Output image file header <br>
Response. binarywrite chrb (66) & chrb (77) & chrb (strlen * 8*10*3 + 54) mod 256 )) & chrb (strlen * 8*10*3 + 54) \ 256) mod 256) & chrb (strlen * 8*10*3 + 54) \ 256) \ 256) mod 256) & chrb (strlen * 8*10*3 + 54) \ 256) \ 256) mod 256) & chrb (0) & chrb (0 )&_
Chrb (0) & chrb (0) & chrb (54) & chrb (0) & chrb (0) & chrb (0) & chrb (40) & chrb (0) &_
Chrb (0) & chrb (0) & chrb (strlen * 8) & chrb (0) & chrb (0) & chrb (0) & chrb (10) & chrb (0 )&_
Chrb (0) & chrb (0) & chrb (1) & chrb (0)
'---------------- Output image information Header
Response. binarywrite chrb (24) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0 )&_
Chrb (strlen * 8*10*3) mod 256) & chrb (strlen * 8*10*3) \ 256) mod 256) & chrb (strlen * 8*10*3) \ 256) \ 256) mod 256) & chrb (strlen * 8*10*3) \ 256) \ 256) \ 256) mod 256 )&_
Chrb (196) & chrb (14) & chrb (0) & chrb (0) & chrb (196) & chrb (14) & chrb (0) & chrb (0) &_
Chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0)
For I = 9 to 0 step-1 '---------- go through all rows
For II = 0 to strLen-1 '------- go through all words
For IIi = 1 to 8' -------- go through all pixels
'--------- Output image data row by row, word by word, and pixel by Pixel
If RND * 99 + 1 <codds then '--------- randomly generate a noise
Response. binarywrite rndcolor
Else
Response. binarywrite vcolordata (mid (vnumberdata (vcode (II), I * 8 + III, 1 ))
End if
Next
Next
Next
End sub
%>

Save the above Code as IMG. asp and insert .

Related Article

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.