标题:[求助]如何实现验证码的调用?如何将它的图片插入到表单里面呢?
只看楼主
枫吹过的季节
Rank: 1
等 级:新手上路
帖 子:120
专家分:0
注 册:2007-7-8
 问题点数:0 回复次数:1 
[求助]如何实现验证码的调用?如何将它的图片插入到表单里面呢?
<%@ language="VBScript" %>
<%
Dim DEF_MasterCookies, DEF_BBS_HomeUrl
Dim RndNumber,RndNumberStr,N,Rs
DEF_MasterCookies = ""
DEF_BBS_HomeUrl = "../"

Response.Expires = 0 ' 过期时间

Randomize
Session("CheckCode") = Fix(rnd*10000) mod 9999

' 从 Session 中得到随机数
RndNumber = Left(Session( "CheckCode") ,4)
If RndNumber = "" or isNumeric(RndNumber) = 0 Then RndNumber = 0
If RndNumber = 0 Then
RndNumber = (Fix(rnd*10000) mod 9999)
Session("CheckCode") = RndNumber
End If
RndNumberStr = Right("000" & RndNumber,4)

If DEF_EnableGFL = 1 and (DEF_EnableAttestNumber = 1 or DEF_EnableAttestNumber = 3) Then
DisplayGflSDK
Else
DisplayBMP
End If

Sub DisplayBMP

'Author: Layen
'QQ: 84815733
'E-mail: support@ssaw.net

Response.Expires = -9999
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
Response.ContentType = "Image/BMP"

Randomize

Dim i, ii, iii

Const cOdds = 8
Const cAmount = 36
Const cCode = "0123456789"

Dim vColorData(1)
vColorData(0) = ChrB(0) & ChrB(0) & ChrB(0)
vColorData(1) = ChrB(255) & ChrB(255) & ChrB(255)

Dim vCode(4)
For i = 0 To 3
vCode(i) = Mid(RndNumberStr,i + 1,1)
Next

Dim ND(35)
ND(0) = "1110000111110111101111011110111101001011110100101111010010111101001011110111101111011110111110000111"
ND(1) = "1111011111110001111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
ND(2) = "1110000111110111101111011110111111111011111111011111111011111111011111111011111111011110111100000011"
ND(3) = "1110000111110111101111011110111111110111111100111111111101111111111011110111101111011110111110000111"
ND(4) = "1111101111111110111111110011111110101111110110111111011011111100000011111110111111111011111111000011"
ND(5) = "1100000011110111111111011111111101000111110011101111111110111111111011110111101111011110111110000111"
ND(6) = "1111000111111011101111011111111101111111110100011111001110111101111011110111101111011110111110000111"
ND(7) = "1100000011110111011111011101111111101111111110111111110111111111011111111101111111110111111111011111"
ND(8) = "1110000111110111101111011110111101111011111000011111101101111101111011110111101111011110111110000111"
ND(9) = "1110001111110111011111011110111101111011110111001111100010111111111011111111101111011101111110001111"
ND(10) = "1111011111111101111111101011111110101111111010111111101011111100000111110111011111011101111000100011"
ND(11) = "1000000111110111101111011110111101110111110000111111011101111101111011110111101111011110111000000111"
ND(12) = "1110000011110111101110111110111011111111101111111110111111111011111111101111101111011101111110001111"
ND(13) = "1000001111110111011111011110111101111011110111101111011110111101111011110111101111011101111000001111"
ND(14) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011110111000000111"
ND(15) = "1000000111110111101111011011111101101111110000111111011011111101101111110111111111011111111000111111"
ND(16) = "1110000111110111011110111101111011111111101111111110111111111011100011101111011111011101111110001111"
ND(17) = "1000100011110111011111011101111101110111110000011111011101111101110111110111011111011101111000100011"
ND(18) = "1100000111111101111111110111111111011111111101111111110111111111011111111101111111110111111100000111"
ND(19) = "1110000011111110111111111011111111101111111110111111111011111111101111111110111110111011111000011111"
ND(20) = "1000100011110111011111011011111101011111110001111111010111111101101111110110111111011101111000100011"
ND(21) = "1000111111110111111111011111111101111111110111111111011111111101111111110111111111011110111000000011"
ND(22) = "1000100011110010011111001001111100100111110101011111010101111101010111110101011111010101111001010011"
ND(23) = "1000100011110011011111001101111101010111110101011111010101111101100111110110011111011001111000110111"
ND(24) = "1110001111110111011110111110111011111011101111101110111110111011111011101111101111011101111110001111"
ND(25) = "1000000111110111101111011110111101111011110000011111011111111101111111110111111111011111111000111111"
ND(26) = "1110001111110111011110111110111011111011101111101110111110111011111011101001101111011001111110001011"
ND(27) = "1000001111110111011111011101111101110111110000111111010111111101101111110110111111011101111000110011"
ND(28) = "1110000011110111101111011110111101111111111001111111111001111111111011110111101111011110111100000111"
ND(29) = "1000000011101101101111110111111111011111111101111111110111111111011111111101111111110111111110001111"
ND(30) = "1000100011110111011111011101111101110111110111011111011101111101110111110111011111011101111110001111"
ND(31) = "1000100011110111011111011101111101110111111010111111101011111110101111111010111111110111111111011111"
ND(32) = "1001010011110101011111010101111101010111110101011111001001111110101111111010111111101011111110101111"
ND(33) = "1000100011110111011111101011111110101111111101111111110111111110101111111010111111011101111000100011"
ND(34) = "1000100011110111011111011101111110101111111010111111110111111111011111111101111111110111111110001111"
ND(35) = "1100000011110111011111111101111111101111111110111111110111111111011111111011111111101110111100000011"

' 输出图像文件头
Response.BinaryWrite ChrB(66) & ChrB(77) & ChrB(230) & ChrB(4) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(54) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(40) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(10) & ChrB(0) &_
ChrB(0) & ChrB(0) & ChrB(1) & ChrB(0)

' 输出图像信息头
Response.BinaryWrite ChrB(24) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(176) & ChrB(4) & ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) & ChrB(0) & ChrB(0) & ChrB(18) & ChrB(11) &_
ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) &_
ChrB(0) & ChrB(0)

For i = 9 To 0 Step -1
For ii = 0 To 3
For iii = 1 To 10
If Rnd * 99 + 1 < cOdds Then
Response.BinaryWrite vColorData(0)
Else
Response.BinaryWrite vColorData(Mid(ND(vCode(ii)), i * 10 + iii, 1))
End If
Next
Next
Next

End Sub

Sub DisplayGflSDK

Dim MyObj
Set MyObj = Server.CreateObject("GflAx190.GflAx")
MyObj.EnableLZW = True
MyObj.LoadBitmap(server.mappath(DEF_BBS_HomeUrl & "images/null.gif"))

MyObj.NewBitmap 32, 12
MyObj.FontBold = True
MyObj.FontName = "宋体"
MyObj.FontSize = 12

Dim c
For N = 1 to 4
c = Rnd*255
MyObj.TextOut Mid(RndNumberStr,N,1),2+7*N-7,-1,c
Next

MyObj.UseTransparency = true
MyObj.ChangeColorDepth 8
Response.ContentType="image/gif"
MyObj.SaveFormat = 2
MyObj.MaskColor = 255*256*256+255*256+255
Response.BinaryWrite MyObj.SendBinary
Set MyObj = Nothing

End Sub%>
应该如何实现它的递交的时候显示图片呢?
搜索更多相关主题的帖子: 表单 RndNumber DEF Session 
2007-11-21 18:13
永夜的极光
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2721
专家分:1
注 册:2007-10-9
得分:0 
一般是用<img src='XXXX.asp' />

从BFS(Breadth First Study)到DFS(Depth First Study)
2007-11-22 08:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-187659-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.054596 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved