New asp gif verification code available in Z-BLOG [V70404]

Source: Internet
Author: User

Copy the following code and save it as c_validcode.asp and upload it to the function. Copy codeThe Code is as follows: <% @ CODEPAGE = 65001%>
<%
'/////////////////////////////////////// ////////////////////////////////////////
'// Z-Blog
'// OPERATOR: Zhu Xi (zx. asd), sipo
'// Copyright: RainbowSoft Studio
'// Technical support: rainbowsoft@163.com
'// Unit name: c_validcode.asp
'// Start time: 2007-4-4
'// Last modified: 2007-4-4
'// Standby Note: www.dc9.cn
'/////////////////////////////////////// ////////////////////////////////////////
%>
<% Option Explicit %>
<% On Error Resume Next %>
<! -- # Include file = "../c_option.asp" -->
<! -- # Include file = "../function/c_function.asp" -->
<%
'. VerifyCode GetVerifyNumber, False
Class Com_GifCode_Class
Public Noisy, Count, Width, Height, Angle, Offset, Border
Private Graph (), Margin (3)
Private Sub Class_Initialize ()
Randomize
Noisy = 7' probability of occurrence of interference points
Count = 5'
Width = 60' Image Width
Height = 20' Image Height
Angle = 3' random Angle variation
Offset = 10' Offset random variation
Border = 2' Border size
End Sub
Public Function Create (str)
Dim I
Dim vIndex
ReDim Graph (Width-1, Height-1)
For I = 0 To Count-1
VIndex = CInt (Mid (str, I + 1, 1)
SetDraw vIndex, I
Next
End Function

Sub SetDot (pX, pY)
If pX * (Width-pX-1)> = 0 And pY * (Height-pY-1)> = 0 Then
Graph (pX, pY) = 1
End If
End Sub

Public Sub SetDraw (pIndex, pNumber)
'Character Data Dictionary
If pIndex =-1 Then pIndex = 9
Dim DotData (9)
DotData (0) = Array (30, 15, 50, 1, 50,100)
DotData (1) = Array (1, 34, 30, 1, 71, 1,100, 34, 1,100, 93,100,100, 86)
DotData (2) = Array (1, 1,100, 1, 42, 42,100, 70, 50,100, 1, 70)
DotData (3) = Array (100, 73, 6, 73, 75, 6, 75,100)
DotData (4) = Array (100, 1, 1, 1, 1, 50, 50, 35,100, 55,100, 80, 50,100, 1, 95)
DotData (5) = Array (100, 20, 70, 1, 20, 1, 1, 30, 1, 80, 30,100, 70,100,100, 80,100, 60, 70, 50, 30, 50, 1, 60)
DotData (6) = Array (6, 26, 6, 6,100, 6, 53,100)
DotData (7) = Array (100, 30,100, 20, 70, 1, 30, 1, 1, 20, 1, 30,100, 70,100, 80, 70,100, 30,100, 1, 80, 1, 70,100, 30)
DotData (8) = Array (1, 80, 30,100, 80,100,100, 70,100, 20, 70, 1, 30, 1, 1, 20, 1, 40, 30, 50, 70, 50,100, 40)
DotData (9) = Array (100, 20, 70, 1, 20, 1, 1, 30, 1, 80, 30,100, 70,100,100, 80,100, 60, 90, 20, 80, 3)

Dim vExtent: vExtent = Width/Count
Margin (0) = Border + vExtent * (Rnd * Offset)/100 + Margin (1)
Margin (1) = vExtent * (pNumber + 1)-Border-vExtent * (Rnd * Offset)/100
Margin (2) = Border + Height * (Rnd * Offset)/100
Margin (3) = Height-Border-Height * (Rnd * Offset)/100

Dim vStartX, vEndX, vStartY, vEndY
Dim vWidth, vHeight, vDX, vDY, vDeltaT
Dim vAngle, vLength

VWidth = Int (Margin (1)-Margin (0 ))
VHeight = Int (Margin (3)-Margin (2 ))
VStartX = Int (DotData (pIndex) (0)-1) * vWidth/100)
VStartY = Int (DotData (pIndex) (1)-1) * vHeight/100)

Dim I, j
For I = 1 To UBound (DotData (pIndex), 1)/2
If DotData (pIndex) (2 * I-2) <> 0 And DotData (pIndex) (2 * I) <> 0 Then
VEndX = (DotData (pIndex) (2 * I)-1) * vWidth/100
VEndY = (DotData (pIndex) (2 x I + 1)-1) * vHeight/100
VDX = vEndX-vStartX
VDY = vEndY-vStartY
If vDX = 0 Then
VAngle = Sgn (vDY) * 3.14/2
Else
VAngle = Atn (vDY/vDX)
End If
If Sin (vAngle) = 0 Then
VLength = vDX
Else
VLength = vDY/Sin (vAngle)
End If
VAngle = vAngle + (Rnd-0.5) * 2 * Angle * 3.14*2/100
VDX = Int (Cos (vAngle) * vLength)
VDY = Int (Sin (vAngle) * vLength)
If Abs (vDX)> Abs (vDY) Then vDeltaT = Abs (vDX) Else vDeltaT = Abs (vDY)
For j = 1 To vDeltaT
SetDot Margin (0) + vStartX + j * vDX/vDeltaT, Margin (2) + vStartY + j * vDY/vDeltaT
Next
VStartX = vStartX + vDX
VStartY = vStartY + vDY
End If
Next
End Sub

Public Sub Output ()
Response. Expires =-9999
Response. AddHeader "pragma", "no-cache"
Response. AddHeader "cache-ctrol", "no-cache"
Response. ContentType = "image/gif"
Response. BinaryWrite ChrB (Asc ("G") & ChrB (Asc ("I") & ChrB (Asc ("F "))
Response. BinaryWrite ChrB (Asc ("8") & ChrB (Asc ("9") & ChrB (Asc (""))
Response. BinaryWrite ChrB (Width Mod 256) & ChrB (Width \ 256) Mod 256)
Response. BinaryWrite ChrB (Height Mod 256) & ChrB (Height \ 256) Mod 256)
Response. BinaryWrite ChrB (128) & ChrB (0) & ChrB (0)
Response. BinaryWrite ChrB (250) & ChrB (250) & ChrB (250)
Response. BinaryWrite ChrB (0) & ChrB (0) & ChrB (0)
Response. BinaryWrite ChrB (Asc (","))
Response. BinaryWrite ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0)
Response. BinaryWrite ChrB (Width Mod 256) & ChrB (Width \ 256) Mod 256)
Response. BinaryWrite ChrB (Height Mod 256) & ChrB (Height \ 256) Mod 256)
Response. BinaryWrite ChrB (0) & ChrB (7) & chrb( 255)

Dim x, y, I: I = 0
For y = 0 To Height-1
For x = 0 To Width-1
If Rnd <Noisy/100 Then
Response. BinaryWrite ChrB (1-Graph (x, y ))
ElseIf x * (x-Width) = 0 Or y * (y-Height) = 0 Then
Response. BinaryWrite ChrB (Graph (x, y ))
ElseIf Graph (x-1, y) = 1 Or Graph (x, y) Or Graph (x, Y-1) = 1 Then
Response. BinaryWrite ChrB (1)
Else
Response. BinaryWrite ChrB (0)
End If

If (y * Width + x + 1) Mod 126 = 0 Then
Response. BinaryWrite chrb( 128)
I = I + 1
End If
If (y * Width + x + I + 1) Mod 255 = 0 Then
If (Width * Height-y * Width-x-1)> 255 Then
Response. BinaryWrite chrb( 255)
Else
Response. BinaryWrite ChrB (Width * Height Mod 255)
End If
End If
Next
Next
Response. BinaryWrite ChrB (128) & ChrB (0) & ChrB (129) & ChrB (0) & ChrB (59)
End Sub
End Class
Dim mCode
Dim code
Set mCode = New Com_GifCode_Class
MCode. Create (GetVerifyNumber)
MCode. Output ()
Set mCode = Nothing
%>

Because the original verification code is too simple, zblogger suffers from spam comments and references. This verification code will be integrated in the next version.
The verification code is modified based on a source code circulating on the network.
In addition, new anti-spam comments and reference tools will be available soon.

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.