- UID
- 173947
- 帖子
- 263
- 主題
- 219
- 精華
- 0
- 積分
- 579
- 楓幣
- 2853
- 威望
- 198
- 存款
- 20
- 贊助金額
- 1500
- 推廣
- 0
- GP
- 194
- 閱讀權限
- 150
- 性別
- 保密
- 在線時間
- 113 小時
- 註冊時間
- 2017-1-1
- 最後登入
- 2018-10-13
|
該程序教你如何實現不支持的htm格式的留言本,運行留言,加入留言後會顯示信息- <%dim input()
- '讀取guestadd.htm表單中的各項內容
- name = Request.Form("name")
- from = Request.Form("from")
- email = Request.Form("email")
- homename = Request.Form("homename")
- url = Request.Form("url")
- ly = Request.Form("ly")
- ip = Request.ServerVariables("REMOTE_ADDR")
- '取得伺服器上當前日期和時間
- n=Year(date())
- y=Month(date())
- r=Day(date())
- t=formatdatetime(time(),3)
- if len(y)=1 then y="0" & y
- if len(r)=1 then r="0" & r
- sj=n & "-" & y & "-" & r & " " & t
- '檢查姓名、主頁名稱、地址、留言是否為空。
- if name = "" then
- Response.write "<p align='center'>你不會沒有名字吧</p>"
- Response.write "<p align='center'><a href='javascript:history.go(-1);'>點擊這裡進行修改</a></p>"
- Response.end
- end if
- if homename <> "" and (url = "http://" or url = "") then
- Response.write "<p align='center'>沒地址我無法看你的網站</p>"
- Response.write "<p align='center'><a href='javascript:history.go(-1);'>點擊這裡進行修改</a></p>"
- Response.end
- end if
- if ly = "" then
- Response.write "<p align='center'>寫一句留言也好呀</p>"
- Response.write "<p align='center'><a href='javascript:history.go(-1);'>點擊這裡進行修改</a></p>"
- Response.end
- end if
- '格式化留言使其不支持HTML,使留言薄支持HTML,可刪除此段代碼
- name=server.HTMLEncode(name)
- from=server.HTMLEncode(from)
- email=server.HTMLEncode(email)
- homename=server.HTMLEncode(homename)
- url=server.HTMLEncode(url)
- ly=server.HTMLEncode(ly)
- lytemp = ""
- for i = 1 to len(ly)
- zh = mid(ly,i,1)
- if zh=" " then zh = " "
- if asc(zh)=10 then zh = "
- "
- if asc(zh)=13 then zh = ""
- lytemp = lytemp + zh
- next
- ly = lytemp
- '把檔內容讀到 input() 陣列中
- lyfile = server.mappath("guestbook.htm") '此處的 guestbook.htm 即為留言薄,可按需修改
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set thisfile = fs.OpenTextFile(lyfile,1,False)
- counter = 0
- do while not thisfile.AtEndOfStream
- thisline = thisfile.readline
- Redim preserve input(counter)
- input(counter) = thisline
- counter = counter + 1
- loop
- thisfile.Close
- '創建新檔,保存留言資料,本段中的<p><!--insert here--></p>不能更改,否則不能工作
- Set outfile = fs.CreateTextFile(lyfile)
- for each item in input
- if item = "<p><!--insert here--></p>" then
- outfile.WriteLine "<p><!--insert here--></p>"
- outfile.WriteLine "<b>" & name & "</b> "
- if from <> "" then outfile.WriteLine "<font color=#FF0000>來自:</font><font color=#9900FF>" & ip & " " & from & "</font>"
- outfile.WriteLine "<font color=#8000FF>(" & sj & ")</font>"
- if homename <> "" then outfile.WriteLine "
- <font color=#FF00FF>主頁:</font><a href='" & url & "' target=_blank>" & homename & "</a>"
- if url <> "" and url <> "http://" and homename = "" then outfile.WriteLine "
- <font color=#FF00FF>主頁:</font><a href='" & url & "' target=_blank>" & url & "</a>"
- if email <> "" then outfile.WriteLine "
- <font color=#009900>信箱:</font><a href='mailto:" & email & "'>" & email & "</a>"
- outfile.WriteLine "<p>" & ly
- outfile.WriteLine "<hr noshade size=1 color=#009900>"
- else
- outfile.WriteLine item
- end if
- next
- outfile.close
- set fs = nothing
- Response.Redirect "guestbook.htm" '返回到留言薄觀看留言
- Response.end
- %>
複製代碼
|
|