现在的位置: 首页 > 综合 > 正文

t0nsha’s留言板 v1.0

2012年08月23日 ⁄ 综合 ⁄ 共 2430字 ⁄ 字号 评论关闭

本留言板以ASP编写,需要FSO组件支持,最大的特点就是简单易用。她采用单文本文件(Content.txt,第一次留言后产生)来保存留言,程序本身(MsgBoard.asp,文件名请勿随意修改)也只有一个文件,可将最近发表的留言显示在最上面,适合于像我一样的初学者学习,希望你喜欢。版权没有,翻版不究。^_^

 


<center>
  
<h2><a href="http://blog.csdn.net/t0nsha/" target="_blank">t0nsha</a>'s<a href="#留言">留言</a>板 v1.0 </h2>
</center>
<hr color="#00FF00">

<%
'Get the total lines of a file.
Function GetLine (filename)
   
Const ForReading = 1, ForWriting = 2
   
Dim fso, f, ra
   
Set fso = Server.CreateObject("Scripting.FileSystemObject")
   
Set f = fso.OpenTextFile(filename, ForReading)
   ra 
=   f.ReadAll
   GetLine 
= f.Line
   f.Close()
End Function
%
>

<%
'Show the file bottom up
Function    ShowRev(filename)
'    Set    fso=Server.CreateObject("Scripting.FileSystemObject")
'
    Set    f=fso.OpenTextFile(filename,1)
    i=GetLine(filename)-1
    
While i>0
        i
=i-3
        j
=i
        
Set fso=Server.CreateObject("Scripting.FileSystemObject")
        
Set f=fso.OpenTextFile(filename,1)
        
While j>0
            f.SkipLine()
            j
=j-1
        
Wend
        
For k=1 To 3
            rl
=f.ReadLine()
            rl
=Server.HTMLEncode(rl)
            Response.Write(rl
&"<br>")
        
Next
        f.Close()
    
Wend
End    Function    
%
>

<%
Dim    fso
Set    fso=CreateObject("Scripting.FileSystemObject")
If    Request.Form("szName"= "" Then
    Response.Write ( 
"<font color='#FF0000'>"&"昵称不能为空!"&"</font>"&"<br>")
ElseIf    Request.Form("szContent"= "" Then
    Response.Write (
"<font color='#FF0000'>"&"内容不能为空!"&"</font>"&"<br>")
Else
    
If    Not    fso.FileExists(Server.MapPath("Content.txt")) Then    
        
Set    fil=fso.CreateTextFile(Server.MapPath("Content.txt"),True    )
    
Else    
        
Set    fil=fso.OpenTextFile(Server.MapPath("Content.txt"),8)
    
End If
    fil.WriteLine(
Now & " 来自:" & Request.ServerVariables("REMOTE_ADDR"& " 的 " & Request.Form("szName"& " 说:")
    fil.WriteLine(Request.Form(
"szContent"))
    fil.WriteBlankLines(
1)
    fil.Close
End    If
If    fso.FileExists(Server.MapPath("Content.txt"))    Then
Call ShowRev(Server.MapPath("Content.txt"))    
End If
%
>

<hr color="#00FF00">

<form name="form1" method="post" action="MsgBoard.asp">
  昵称(限字20):
<input type="text" maxlength=20 size='20%' name="szName"><br>
  内容(限字80):<input type="text" maxlength=80 size='80%' name="szContent">
  <input type="submit" name="Submit" value="发表留言">
</form>

<a name="#留言"></a>

 

下载地址1:http://down.chinaz.com/soft/21102.htm

下载地址2:http://www.fs2you.com/files/2167af14-9c93-11dc-8f79-00142218fc6e/ 

抱歉!评论已关闭.