ASP programs that generate pictures of phone numbers in a Web page

Source: Internet
Author: User
Tags header strlen

The following is a reference fragment:

<%
Call Com_creatvalidcode (Request.QueryString ("tel"))
Public Sub Com_creatvalidcode (Ptel)
'----------Prohibit 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 the occurrence of the miscellaneous points of the------------
Const str= "0123456789-"
StrLen = Len (Ptel)
Rndcolor = ChrB (CInt (rnd*255)) & ChrB (CInt (rnd*255)) & ChrB (CInt (rnd*255))
'-----------The color of the 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 (0) & ChrB () '----blue 0, Green, 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 (& ChrB) &AMP;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 (a) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB () & ChrB (0) &_
ChrB (0) & ChrB (0) & ChrB (strlen*8) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (a) & ChrB (0) &_
ChrB (0) & ChrB (0) & ChrB (1) & ChrB (0)
'------------------output Image information header
Response.BinaryWrite ChrB & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) &_
ChrB ((strlen*8*10*3) mod 256) &AMP;CHRB (((strlen*8*10*3) \256) mod 256) &AMP;CHRB ((((strlen*8*10*3) \256) \256) mod 256) &AMP;CHRB ((((strlen*8*10*3) \256 \256) \256) mod 256) &_
ChrB (196) & ChrB (a) & ChrB (0) & ChrB (0) & ChrB (196) & ChrB (0) & &AMP;CHRB (0) ChrB
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 the lines
For II = 0 to strLen-1 '-------after all the words
For III = 1 to 8 '--------after all the pixels
'---------output image data line by row, verbatim, and pixel-by-byte
If Rnd * + 1 < codds Then '---------randomly generated miscellaneous points
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.