復制下面代碼,存為c_validcode.asp上傳到function下就可以了
復制代碼 代碼如下:
<%@ CODEPAGE=65001 %>
<%
'///////////////////////////////////////////////////////////////////////////////
'// Z-Blog
'// 作 者: 朱煊(zx.asd),sipo
'// 版權所有: RainbowSoft Studio
'// 技術支持: rainbowsoft@163.com
'// 單元名稱: c_validcode.asp
'// 開始時間: 2007-4-4
'// 最后修改: 2007-4-4
'// 備 注: 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 ' 干擾點出現的概率
Count = 5 ' 字符數量
Width = 60 ' 圖片寬度
Height = 20 ' 圖片高度
Angle = 3 ' 角度隨機變化量
Offset = 10 ' 偏移隨機變化量
Border = 2 ' 邊框大小
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)-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)
' 字符數據字典
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)