MSG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
D:\Temp\找图片图标\验证码\Code_1.asp 编码GB2312   函数中有无用变量[2]
<%  '************************************************************  '作者:云端  '版权:源代码公开,各种用途均可免费使用。  '创建:2013-11-16  '联系:QQ313801120 交流群35915100 邮箱313801120@qq.com  '* Powered By 云端  '************************************************************  Option Explicit  Class com_gifcode_class Public noisy, Count, Width, Height, Angle, OffSet, Border, bc  Private Graph(), Margin(3) 
Private Sub Class_Initialize() Randomize  noisy = 6 '干扰点出现的概率  Count = 4 '字符数量  Width = 50 '图片宽度  Height = 15 '图片高度  Angle = 4 '角度随机变化量  OffSet = 8 '偏移随机变化量  Border = 1 '边框大小  bc = Request("bc")  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) '字符数据 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, 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)  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 * 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("a"))  '逻辑屏幕宽度 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)  '全局颜色列表 If bc = "white" Then Response.BinaryWrite ChrB(255) & ChrB(255) & ChrB(255)  Else Response.BinaryWrite ChrB(252) & ChrB(251) & ChrB(230)  End If  Response.BinaryWrite ChrB(40) & ChrB(118) & ChrB(164)  '图象标识符 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))  Else If X * (X - Width) = 0 Or Y * (Y - Height) = 0 Then Response.BinaryWrite ChrB(Graph(X, Y))  Else If 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  End If  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  Set mCode = New com_gifcode_class Session("getcode") = mCode.Create()  mCode.OutPut()  Set mCode = Nothing  %>
 
隐藏注释
正常版
简洁版
简洁去注释
代码不变版
复制代码