是个人才网站,招聘单位的各后台有个刷新广告到最前一排(求职的容易看见)的功能,由于单位日益增加,现在每天成千的单位上来刷广告,每刷一次,文本文件要重新写一次,服务器经常被瘫痪,但是又必须保留这个刷广高的功能,我都试了很多方法,但是效果都不好,求各位大侠有什么好方法,指点下,或者修改下程序,小弟感激不尽。(其实就是帖子置顶(同一帖子重复刷新到第一个算法),不想写成直接读数据库,而是先写成静态文本文件,这样用户浏览出错少,稳定)附程序代码:
Dim xh,con,rs,sqlstr,k,bz,adbz,inputName,oper,adrq1,adrq2,outStr,j,dwstr,gwstr
if session("xh") = "" then
response.redirect("/scrcdw/treemenu/err01.htm")
response.End()
else
xh = session("xh")
end if
set con = application("cn")
sub writeToFile(oper,adrq1,adrq2)
Dim fname,logname,fs,f,f1,dwxh,f2,dwstr2
Const ForReading = 1, ForWriting = 2, ForAppending = 3
dwxh = session("xh")
fname = "dwad.txt"
logname="box3.jpg"
if oper = "add" then
sqlstr = "update dw set adbz = '3',adkind='3',adrq='" & adrq1 & "',adrq2='" & adrq2 & "' where xh='" & dwxh & "'"
elseif oper = "del" then
sqlstr = "update dw set adbz = '0',adkind = '0' where xh='" & dwxh & "'"
end if
con.execute (sqlstr)
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(application("rootpath") & "include/" & fname, ForWriting ,true)
Set f1 = fs.OpenTextFile(application("rootpath") & "include/indexdwad.txt" , ForWriting ,true)
Set f2 = fs.OpenTextFile(application("rootpath") & "include/newdwad.txt" , ForWriting ,true)
sqlstr="select xh,dw,adrq from dw where adbz='3' order by adrq desc"
Dim rq,PrtNum,rs1
set rs = con.execute(sqlstr)
PrtNum = 0
while not rs.eof
rq = rs("adrq")
sqlstr = "select zpgw from condition where dw_xh='" & rs.fields("xh") &"' order by djrq desc"
set rs1 = con.execute(sqlstr)
if rs1.eof = false then
gwstr = ""
j = 0
while not rs1.eof
if j = 0 then
gwstr = gwstr & rs1("zpgw")
else
gwstr = gwstr & "," & rs1("zpgw")
end if
j = j+ 1
rs1.movenext
wend
dwstr2 = rs("dw")
if len(dwstr2) >14 then
dwstr = left(dwstr2,14) & "..."
else
dwstr = dwstr2
end if
if PrtNum mod 2 = 0 then
f.WriteLine "<TR><TD width=50% vAlign=center height=10>· <a href="&chr(34)& "/dw/dw_condition_view.asp?xh="&rs("xh")& chr(34) & " ONMOUSEOVER=""popup('<font color=#3B99CF size=2><b>诚聘:</b></font>"& gwstr & "')"" ONMOUSEOUT=""kill()""" & " target=_blank>" & dwstr & "</a><font color=#C6C3C6>" & month(rq) & "-" & day(rq) & "</font></TD>"
else
f.WriteLine "<TD width=50% vAlign=center height=10>· <a href="&chr(34)& "/dw/dw_condition_view.asp?xh="&rs("xh")& chr(34) & " ONMOUSEOVER=""popup('<font color=#3B99CF size=2><b>诚聘:</b></font>"& gwstr & "')"" ONMOUSEOUT=""kill()""" & " target=_blank>" & dwstr & "</a><font color=#C6C3C6>" & month(rq) & "-" & day(rq) & "</font></TD></TR>"
end if
if PrtNum mod 3 = 0 then
f1.WriteLine "<TR><TD width=248 vAlign=center height=20 class=td1>·<a href="&chr(34)& "/dw/dw_condition_view.asp?xh="&rs("xh")& chr(34) & " ONMOUSEOVER=""popup('<font color=#3B99CF size=2><b>诚聘:</b></font>"& gwstr & "')"" ONMOUSEOUT=""kill()""" & " target=_blank>" & dwstr & "</a><font color=#C6C3C6>" & month(rq) & "." & day(rq) & "</font></TD>"
elseif PrtNum mod 3 = 1 then
f1.WriteLine "<TD width=248 vAlign=center height=20 class=td1>·<a href="&chr(34)& "/dw/dw_condition_view.asp?xh="&rs("xh")& chr(34) & " ONMOUSEOVER=""popup('<font color=#3B99CF size=2><b>诚聘:</b></font>"& gwstr & "')"" ONMOUSEOUT=""kill()""" & " target=_blank>" & dwstr & "</a><font color=#C6C3C6>" & month(rq) & "." & day(rq) & "</font></TD>"
else
f1.WriteLine "<TD width=248 vAlign=center height=20 class=td1>·<a href="&chr(34)& "/dw/dw_condition_view.asp?xh="&rs("xh")& chr(34) & " ONMOUSEOVER=""popup('<font color=#3B99CF size=2><b>诚聘:</b></font>"& gwstr & "')"" ONMOUSEOUT=""kill()""" & " target=_blank>" & dwstr & "</a><font color=#C6C3C6>" & month(rq) & "." & day(rq) & "</font></TD></TR>"
end if
f2.WriteLine "<li><a href="&chr(34)& "/dw/dw_condition_view.asp?xh="&rs("xh")& chr(34) & " target=_blank title='诚聘:" & gwstr & "'>" & dwstr2 & "</a><font color=#C6C3C6>" & month(rq) & "." & day(rq) & "</font></li>"
PrtNum = PrtNum + 1
end if
rs.movenext
wend
f.close
f1.close
f2.close
rs.close
rs1.close
set rs = nothing
set rs1 = nothing
set f1 = nothing
set f2 = nothing
set f = nothing
set fs = nothing
end sub
inputName = "生成广告"
oper = Request.QueryString("oper")
if oper <> "" then
adrq1 = cdate(Trim(Request.Form("adrq")))+time()
adrq2 = Trim(Request.Form("adtime"))
Call writeToFile(oper,adrq1,adrq2)
outStr = "<font color=#cc3300>操作成功!</font>"
else
outStr = ""
end if
sqlstr = "select adbz,adrq,adrq2,clicked from dw where xh = '" & xh & "'"
set rs = con.Execute(sqlstr)
if not rs.eof then
adbz = rs.fields("adbz")
if adbz = "3" then
inputName = "更新广告"
k = "1、广告正在发布中....<br>"
k = k & "2、广告发布日期是:" & rs.fields("adrq") & ",截止日期至:" & rs.fields("adrq2") & "<br>"
k = k & "3、贵单位发布过的所有广告共被<font color=red><b>" & rs.fields("clicked") & "</b></font>人次查看过。"
else
k = "贵单位目前没有发布广告!"
end if
end if
rs.close
set rs = nothing
set con = nothing