<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
if Request.Form("submit")="更新投票结果" and Request.Form("psw")="zj" then
'根据投票结果选定最好的文章作为故事的后续章节
phypath=server.MapPath("/project4_local")
if Request.Form("selchap")<>"" then
mfilename=Request.Form("selchap")
set fsys=server.CreateObject("scripting.filesystemobject")
for i=1 to 100
if not fsys.FileExists(phypath & "/chapter" & i & ".html") then
destfname="/chapter" & i & ".html"
exit for
end if
next
if fsys.FileExists(phypath & "/new1/" & mfilename) then
sourcename="/new1/" & mfilename
fsys.CopyFile phypath & "/" & sourcename,phypath & "/" & destfname
end if
end if
set mfile=fsys.OpenTextFile(phypath & "/story.txt",8,true)
set mfile2=fsys.OpenTextFile(phypath & "/" & destfname,1,true)
'打开文件读取标题
mcontent=mfile2.readall
'取得文章的标题
pos1=instr(1,mcontent,"<title>",1)
pos2=instr(pos1,mcontent,"</title>",1)
title=mid(mcontent,pos1+7,pos2-pos1-7)
'取得文章的作者
pos1=instr(1,mcontent,"作者:",1)
pos2=instr(pos1,mcontent,"<",1)
author=mid(mcontent,pos1+3,pos2-pos1-3)
mfile.writeline "/project4_local" & destfname & " " & "第" & i & "章:" & title & "(作者:" & author & ")"
mfile2.close
mfile.close
'将文章全部删除
fsys.DeleteFile phypath & "/new1/*.*"
set fsys=nothing
'清除数据库里所有的内容
set conn=server.CreateObject("adodb.connection")
conn.ConnectionString="dsn=vote"
conn.Open
conn.Execute("delete * from tbvote")
conn.Execute("delete * from tbcomment")
conn.Close
set conn=nothing
Response.Write "更新投票结果<br>"
Response.Write "得票最多的新文章加入到新的一章中去了"
else
'更新投票结果如果没有输入口令,则显示提示信息
Response.Write "<font size=4><strong>"
Response.Write "注意:<br>只有管理者才能根据投票结果更新文章"
&nb