<%@ Language=vbscript%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
</HEAD>
<BODY>
<%
If Request.Form ("submit") = "Update voting results" and Request.Form ("PSW") = "ZJ" Then
' Select the best article according to the result of the poll as a follow-up chapter of the Story
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)
' Open File Read header
Mcontent=mfile2.readall
' Get the title of the article
Pos1=instr (1,mcontent, "<title>", 1)
Pos2=instr (pos1,mcontent, "</title>", 1)
Title=mid (mcontent,pos1+7,pos2-pos1-7)
' Get the author of the article
Pos1=instr (1,mcontent, "Author:", 1)
Pos2=instr (Pos1,mcontent, "<", 1)
Author=mid (Mcontent,pos1+3,pos2-pos1-3)
Mfile.writeline "/project4_local" & Destfname & "&" "& I &" chapter: "& Title &" (Author: "& Author & ")"
Mfile2.close
Mfile.close
' Delete the article all
Fsys. DeleteFile Phypath & "/new1/*.*"
Set fsys=nothing
' Erase all content in the database
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 "Update poll results <br>"
Response.Write "The new article with the most votes added to the new chapter."
Else
' Update poll results if no password is entered, the prompt is displayed
Response.Write "<font size=4><strong>"
Response.Write "Note:<br> only managers can update articles based on voting results"
Response.Write "</strong></font>"
End If
%>
</BODY>
</HTML>