<%
dim iid

dbpath = server.mappath("data/iluck.asa")
connstr = "driver={microsoft access driver (*.mdb)};dbq="& dbpath
set conn = server.createobject("adodb.connection")
conn.open connstr



if request("id") > 0 and request("id") < 13 then
iid = request("id")
else
iid = 1
end if

sql = "select * from luck where id = " & iid
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,3,2

if rs("date") = date then
istar = rs("star")
iall = rs("all")
ilove = rs("love")
iwork = rs("work")
ibusiness = rs("business")
ihealth = rs("health")
italk = rs("talk")
icolor = rs("color")
inumber = rs("number")
isoon = rs("soon")
imain = rs("main")
else

iurl = "http://astro.sina.com.cn/aries.html"
istar = "白羊座"

select case iid
case 1
iurl = "http://astro.sina.com.cn/aries.html"
istar = "白羊座"
case 2
iurl = "http://astro.sina.com.cn/taurus.html"
istar = "金牛座"
case 3
iurl = "http://astro.sina.com.cn/gemini.html"
istar = "双子座"
case 4
iurl = "http://astro.sina.com.cn/cancer.html"
istar = "巨蟹座"
case 5
iurl = "http://astro.sina.com.cn/leo.html"
istar = "狮子座"
case 6
iurl = "http://astro.sina.com.cn/virgo.html"
istar = "处女座"
case 7
iurl = "http://astro.sina.com.cn/libra.html"
istar = "天秤座"
case 8
iurl = "http://astro.sina.com.cn/scorpio.html"
istar = "天蝎座"
case 9
iurl = "http://astro.sina.com.cn/sagittarius.html"
istar = "射手座"
case 10
iurl = "http://astro.sina.com.cn/capricorn.html"
istar = "摩羯座"
case 11
iurl = "http://astro.sina.com.cn/aquarius.html"
istar = "水瓶座"
case 12
iurl = "http://astro.sina.com.cn/pisces.html"
istar = "双鱼座"
end select

function ichange(str)
finalstr = ""
for i = 1 to lenb(str)
icharcode = ascb(midb(str,i,1))
if icharcode < &H80 then
finalstr = finalstr & chr(icharcode)
else
inextcode = ascb(midb(str,i+1,1))
finalstr = finalstr & chr(clng(icharcode) * &H100 + cint(inextcode))
i = i + 1
end if
next
ichange = finalstr
end function

set iconnect = createobject("Microsoft.XMLHTTP")
icode = iconnect.open ("GET",iurl,false) 
iconnect.send()

icode = ichange(iconnect.responsebody)

if icode <> "" then
inum = len(icode) - instr(icode,"<font color=000000 size=3>") - 25
if inum < len(icode) - 25 then
imain = right(icode,inum)
inum = instr(imain,"</font><p>") - 1
imain = left(imain,inum)
end if

inum = len(icode) - instr(icode,"综合运势：</font><font color=6666CC size=3>") - 38
if inum < len(icode) - 38 then
iall = right(icode,inum)
inum = instr(iall,"</font><p>") - 1
iall = len(left(iall,inum))
end if

inum = len(icode) - instr(icode,"爱情运势：</font><font color=6666CC size=3>") - 38
if inum < len(icode) - 38 then
ilove = right(icode,inum)
inum = instr(ilove,"</font><p>") - 1
ilove = len(left(ilove,inum))
end if

inum = len(icode) - instr(icode,"工作状况：</font><font color=6666CC size=3>") - 38
if inum < len(icode) - 38 then
iwork = right(icode,inum)
inum = instr(iwork,"</font><p>") - 1
iwork = len(left(iwork,inum))
end if

inum = len(icode) - instr(icode,"理财投资：</font><font color=6666CC size=3>") - 38
if inum < len(icode) - 38 then
ibusiness = right(icode,inum)
inum = instr(ibusiness,"</font><p>") - 1
ibusiness = len(left(ibusiness,inum))
end if

inum = len(icode) - instr(icode,"健康指数：</font><font color=6666CC size=3>") - 37
if inum < len(icode) - 37 then
ihealth = right(icode,inum)
inum = instr(ihealth,"</font><p>") - 1
ihealth = left(ihealth,inum)
end if

inum = len(icode) - instr(icode,"商谈指数：</font><font color=6666CC size=3>") - 37
if inum < len(icode) - 37 then
italk = right(icode,inum)
inum = instr(italk,"</font><p>") - 1
italk = left(italk,inum)
end if

inum = len(icode) - instr(icode,"Lucky Color：</font><font color=6666CC size=3>") - 44
if inum < len(icode) - 44 then
icolor = right(icode,inum)
inum = instr(icolor,"</font><p>") - 1
icolor = left(icolor,inum)
end if

inum = len(icode) - instr(icode,"Lucky Number：</font><font color=6666CC size=3>") - 45
if inum < len(icode) - 45 then
inumber = right(icode,inum)
inum = instr(inumber,"</font><p>") - 1
inumber = left(inumber,inum)
end if

inum = len(icode) - instr(icode,"速配星座：</font><font color=6666CC size=3>") - 37
if inum < len(icode) - 37 then
isoon = right(icode,inum)
inum = instr(isoon,"</font><p>") - 1
isoon = left(isoon,inum)
end if

rs("all") = iall
rs("love") = ilove
rs("work") = iwork
rs("business") = ibusiness
rs("health") = ihealth
rs("talk") = italk
rs("color") = icolor
rs("number") = inumber
rs("soon") = isoon
rs("main") = imain
rs("date") = date
rs.update

end if

end if

rs.close
set rs = nothing
conn.close
set conn = nothing
%>