Sample Verification Code:
<%
If IsEmpty ("GetCode")) or session ("GetCode") <> UCase (Request.Form ("Form_code")) Then
Response.Write "Authentication Code input Error"
Response.End
Else
Session ("GetCode") = Empty "Empty session
Response.Write "Verify code input is correct"
Response.End
End If
%>
Verification Code Code:
<%
Option Explicit "Display declaration
Class Com_gifcode_class
"""""""""""""""""""""""""""""""""""""""""""""
"Author:layen support@ssaw.net 84815733 (QQ)
"Thanks:laomi, Laomiao, Netrube
"2006-01-02
"""""""""""""""""""""""""""""""""""""""""""""
Public noisy, count, width, height, angle, offset, border
Private graph (), margin (3)
Private Sub Class_Initialize ()
Randomize
Noisy = 16 "The probability of a disturbance point appearing
Count = 4 "Number of characters"
width = 80 "Picture widths"
Height = 20 "Picture Heights"
Angle = 2 "angle Random change Amount
offset = 20 "offsets random variance
border = 1 "border size
End Sub
Public Function Create ()
Const CCHARSET = "123456789"
Dim i, X, y
Dim Vvalidcode:vvalidcode = ""
Dim Vindex
ReDim Graph (Width-1, height-1)
For i = 0 to Count-1
Vindex = Int (rnd * len (Ccharset))
Vvalidcode = Vvalidcode + mid (Ccharset, vindex+1, 1)
Setdraw Vindex, I
Next
Create = Vvalidcode
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
Dim Dotdata (8)
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, 60L
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)
Dim Vextent:vextent = Width/count
Margin (0) = border + vextent * (RND * offset)/MB + 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))
The start coordinate
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
"Endpoint coordinates
Vendx = (Dotdata (pindex) (2*i)-1) * vwidth/100
Vendy = (Dotdata (pindex) (2*i+1)-1) * vheight/100
"Horizontal gap
VDX = Vendx-vstartx
"Vertical gap
Vdy = Vendy-vstarty
"Tilt angle
If vdx = 0 Then
Vangle = SGN (vdy) * 3.14/2
Else
Vangle = ATN (VDY/VDX)
End If
"Two coordinate distance
If sin (vangle) = 0 Then
Vlength = VDX
Else
Vlength = Vdy/sin (vangle)
End If
"Random Rotation angle
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