冰楓論壇

 找回密碼
 立即註冊
ads_sugarbook
搜索
查看: 3215|回覆: 0

[心得] 教你如何實現不支持HTM格式的留言本

[複製鏈接]

219

主題

1

好友

579

積分

高級贊助會員

Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20

UID
173947
帖子
263
主題
219
精華
0
積分
579
楓幣
2849
威望
198
存款
20
贊助金額
1500
推廣
0
GP
194
閱讀權限
150
性別
保密
在線時間
113 小時
註冊時間
2017-1-1
最後登入
2018-10-13

高級客戶 論壇支持王 貢獻王 VIP會員

發表於 2017-6-12 17:57:07 |顯示全部樓層

該程序教你如何實現不支持的htm格式的留言本,運行留言,加入留言後會顯示信息
  1. <%dim input()

  2. '讀取guestadd.htm表單中的各項內容
  3. name = Request.Form("name")
  4. from = Request.Form("from")
  5. email = Request.Form("email")
  6. homename = Request.Form("homename")
  7. url = Request.Form("url")
  8. ly = Request.Form("ly")
  9. ip = Request.ServerVariables("REMOTE_ADDR")

  10. '取得伺服器上當前日期和時間
  11. n=Year(date())
  12. y=Month(date())
  13. r=Day(date())
  14. t=formatdatetime(time(),3)
  15. if len(y)=1 then y="0" & y
  16. if len(r)=1 then r="0" & r
  17. sj=n & "-" & y & "-" & r & " " & t

  18. '檢查姓名、主頁名稱、地址、留言是否為空。
  19. if name = "" then
  20. Response.write "<p align='center'>你不會沒有名字吧</p>"
  21. Response.write "<p align='center'><a href='javascript:history.go(-1);'>點擊這裡進行修改</a></p>"
  22. Response.end
  23. end if
  24. if homename <> "" and (url = "http://" or url = "") then
  25. Response.write "<p align='center'>沒地址我無法看你的網站</p>"
  26. Response.write "<p align='center'><a href='javascript:history.go(-1);'>點擊這裡進行修改</a></p>"
  27. Response.end
  28. end if
  29. if ly = "" then
  30. Response.write "<p align='center'>寫一句留言也好呀</p>"
  31. Response.write "<p align='center'><a href='javascript:history.go(-1);'>點擊這裡進行修改</a></p>"
  32. Response.end
  33. end if

  34. '格式化留言使其不支持HTML,使留言薄支持HTML,可刪除此段代碼
  35. name=server.HTMLEncode(name)
  36. from=server.HTMLEncode(from)
  37. email=server.HTMLEncode(email)
  38. homename=server.HTMLEncode(homename)
  39. url=server.HTMLEncode(url)
  40. ly=server.HTMLEncode(ly)
  41. lytemp = ""
  42. for i = 1 to len(ly)
  43. zh = mid(ly,i,1)
  44. if zh=" " then zh = " "
  45. if asc(zh)=10 then zh = "
  46. "
  47. if asc(zh)=13 then zh = ""
  48. lytemp = lytemp + zh
  49. next
  50. ly = lytemp


  51. '把檔內容讀到 input() 陣列中
  52. lyfile = server.mappath("guestbook.htm") '此處的 guestbook.htm 即為留言薄,可按需修改
  53. Set fs = CreateObject("Scripting.FileSystemObject")
  54. Set thisfile = fs.OpenTextFile(lyfile,1,False)
  55. counter = 0
  56. do while not thisfile.AtEndOfStream
  57. thisline = thisfile.readline
  58. Redim preserve input(counter)
  59. input(counter) = thisline
  60. counter = counter + 1
  61. loop
  62. thisfile.Close
  63. '創建新檔,保存留言資料,本段中的<p><!--insert here--></p>不能更改,否則不能工作
  64. Set outfile = fs.CreateTextFile(lyfile)
  65. for each item in input
  66. if item = "<p><!--insert here--></p>" then
  67.   outfile.WriteLine "<p><!--insert here--></p>"
  68.   outfile.WriteLine "<b>" & name & "</b> "
  69.   if from <> "" then outfile.WriteLine "<font color=#FF0000>來自:</font><font color=#9900FF>" & ip & " " & from & "</font>"
  70.   outfile.WriteLine "<font color=#8000FF>(" & sj & ")</font>"
  71.   if homename <> "" then outfile.WriteLine "
  72. <font color=#FF00FF>主頁:</font><a href='" & url & "' target=_blank>" & homename & "</a>"
  73.   if url <> "" and url <> "http://" and homename = "" then outfile.WriteLine "
  74. <font color=#FF00FF>主頁:</font><a href='" & url & "' target=_blank>" & url & "</a>"
  75.   if email <> "" then outfile.WriteLine "
  76. <font color=#009900>信箱:</font><a href='mailto:" & email & "'>" & email & "</a>"
  77.   outfile.WriteLine "<p>" & ly
  78.   outfile.WriteLine "<hr noshade size=1 color=#009900>"
  79. else
  80.   outfile.WriteLine item
  81. end if
  82. next
  83. outfile.close
  84. set fs = nothing
  85. Response.Redirect "guestbook.htm" '返回到留言薄觀看留言
  86. Response.end
  87. %>
複製代碼
099.PNG

留言板.rar

2.78 KB, 下載次數: 0

售價: 3 楓幣  [記錄]  [購買]

[發帖際遇]: KinKALaw 看了電視節目「大腦生了沒」,智商瞬間驟降 2 幸運榜 / 衰神榜
複製連結並發給好友,以賺取推廣點數
簡單兩步驟,註冊、分享網址,即可獲得獎勵! 一起推廣文章換商品、賺$$
高級模式
B Color Image Link Quote Code Smilies |上傳

廣告刊登意見回饋關於我們職位招聘本站規範DMCA隱私權政策

Copyright © 2011-2024 冰楓論壇, All rights reserved

免責聲明:本網站是以即時上載留言的方式運作,本站對所有留言的真實性、完整性及立場等,不負任何法律責任。

而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。

小黑屋|手機版|冰楓論壇

GMT+8, 2024-3-28 22:15

回頂部