<%
sub getsafecode
dim test,result
on error resume next
set test=server.createobject("adodb.stream")
set test=nothing
if err then
dim znum
randomize timer
znum=cint(8999*rnd+1000)
session("safecode")=znum
result=session("safecode")
else
result="<img src="" safecode.asp"" align="" absmiddle"">"
end if
response.write result
end sub
%>
safecode.asp文件代码如下
<%
dim objcanvas
dim pointx,pointy,pointcolor
dim itemp
dim safecode
dim r,g,b,cc,kk
cc=80
kk=30
safecode = ""
session("safecode") = ""
bgcolor = "ffffff"
r = mid(bgcolor,1,2)
g = mid(bgcolor,3,2)
b = mid(bgcolor,5,2)
r = dechex(r)
g = dechex(g)
b = dechex(b)
set objcanvas = new canvas
objcanvas.globalcolourtable(0) = rgb(255,255,255) ' white
objcanvas.globalcolourtable(1) = rgb(0,0,0) ' black
objcanvas.globalcolourtable(2) = rgb(255,0,0) ' red
objcanvas.globalcolourtable(3) = rgb(0,255,0) ' green
objcanvas.globalcolourtable(4) = rgb(0,0,255) ' blue
objcanvas.globalcolourtable(5) = rgb(128,0,0)
objcanvas.globalcolourtable(6) = rgb(0,128,0)
objcanvas.globalcolourtable(7) = rgb(0,0,128)
objcanvas.globalcolourtable(8) = rgb(128,128,0)
objcanvas.globalcolourtable(9) = rgb(0,128,128)
objcanvas.globalcolourtable(10) = rgb(128,0,128)
objcanvas.globalcolourtable(11) = rgb(r,g,b)objcanvas.backgroundcolourindex = 11
objcanvas.resize cc,kk,false
randomize timer
safecode = cint(8999*rnd+1000)
for itemp = 0 to 30
randomize timer
pointx = int(rnd * cc)
pointy = int(rnd * kk)
pointcolor = int(rnd * 3)+2
objcanvas.foregroundcolourindex = pointcolor
objcanvas.line pointx,pointy,pointx,pointy
next
objcanvas.foregroundcolourindex = 1
objcanvas.line 1,1,cc,1
objcanvas.line 1,kk,1,1
objcanvas.line 1,kk,cc,kk
objcanvas.line cc,1,cc,kk
session("safecode") = safecode
dim sc,sk
randomize timer
sc = cint(24*rnd)
sk = cint(11*rnd)
objcanvas.drawtextwe sc,sk,safecode
objcanvas.write
function dechex (hstr)
dim result
dim i,l
result = 0
l = len(hstr)
for i = l-1 to 0 step -1
result = result + (16 ^ i)*getdecbit(mid(hstr,i+1,1))
next
dechex = result
end functionfunction getdecbit (hstr)
dim result
dim r(16)
dim i
result = 0
r(0) = "0"
r(1) = "1"
r(2) = "2"
r(3) = "3"
r(4) = "4"
r(5) = "5"
r(6) = "6"
r(7) = "7"
r(8) = "8"
r(9) = "9"
r(10) = "a"
r(11) = "b"
r(12) = "c"
r(13) = "d"
r(14) = "e"
r(15) = "f"
for i = 0 to 15
if hstr=r(i) then result = i : exit for
next
getdecbit = result
end function
%>