日期:2013-06-13  浏览次数:21260 次

库名 vote

表 tbcomment
userip 文本
comment 文本

表 tbvote
voteid 自动编号
votechapter 文本
votecount 数字

afterpost.asp
<%@ Language=VBScript %>
<%
'这个asp文件的作用是将用户续写的新文章用文本文件的形式存起来
'新文章统一放在相对路径为new1/的文件夹之下,新文章名有一定的规则
'第一篇为newchapter1.html,第二篇为newchapter2.html按照文章发表的先后
'顺序,考虑到不能无限的让网上用户续写文章,最多能生成100篇
'新文章含有一些html标签,这样在制作连接时可以直接与该文件相连
'而不用使用程序读取文件再控制输出格式,制作连接是利用contentlink组件,
'这种组件的应用方法如后面所示,
'要利用到一个有一定格式描述连接的文本文件,这个文本文件名为new.txt
'也是存放在相对目录new1/下
if Request.ServerVariables("http_method")="POST" then
    set fsys=server.CreateObject("Scripting.filesystemobject")
    '取得文件夹的物理路径
    phypath=server.MapPath("/project4_local")
    if not fsys.FolderExists(phypath & "/new1") then
        '如果存放新故事章节的文件夹不存在,则创建该文件夹
        fsys.CreateFolder(phypath & "/new1")
    end if
    for i=1 to 100
        '每天接收的新的故事章节不大于100
        if not fsys.FileExists(phypath & "/new1/newchapter" & i &".html") then
            fsys.CreateTextFile("newchapter" & i & ".html")
            set txtfile=fsys.OpenTextFile(phypath & "/new1/newchapter" & i & ".html",2,true)
            exit for
        end if
    next
    '向文件写提交的内容
    '将该文本文件写成html格式,浏览器能够直接读取该文件并按一定的格式显示
    title=Request.Form("title")
    author=Request.Form("author")
    content=Request.Form("content")
    txtfile.writeline "<html>"
    txtfile.writeline "<head>"
    txtfile.writeline "<title>" & title & "</title>"
    txtfile.writeline "</head>"
    txtfile.writeline "<body>"
    txtfile.writeline "<p align=center><font size=4 color=red>" & title & "</font>"
    txtfile.writeline "<font size=2 color=blue>作者:" & author & "</font></p>"
    txtfile.writeline "<pre>" & content & "</pre>"
    txtfile.writeline "</body>"
    txtfile.writeline "</html>"
    '关闭文件
    txtfile.close
    set txtfile=nothing
    '以下为添加新故事的目录到连接文件中
    set txtfile=fsys.OpenTextFile(phypath & "/new1/new.txt",8,true)
    txtfile.writeline  "new1/newchapter"  & i & ".html    "&"第" & i & "篇:" & Request.Form("title") & "(" & Request.Form("author") & ")"
    txtfile.close
    '打开刚写的文件
    set txtfile=fsys.OpenTextFile(phypath & "/new1/newchapter" & i & ".html",1)
    '读入文件的所有内容
    txtall=txtfile.readall