wapview.asp
上传用户:dragonczj
上传日期:2013-07-05
资源大小:56k
文件大小:4k
源码类别:

手机WAP编程

开发平台:

Java

  1. <!--#include file="wapconn.asp"-->
  2. <!--#include file="wapstr.asp"-->
  3. <!--#include file="inc/md5.asp"-->
  4. <%
  5. response.ContentType="text/vnd.wap.wml;charset=utf-8"
  6. Response.Expires = -1
  7. Response.AddHeader "Pragma", "no-cache"
  8. Response.AddHeader "Cache-Control", "no-cache, must-revalidate"
  9. %><?xml version="1.0" encoding="UTF-8"?>
  10. <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
  11. "http://www.wapforum.org/DTD/wml_1.1.xml">
  12. <wml>
  13. <card id="wapview" title="<%=converttowide("日志内容")%>">
  14. <%
  15. dim show_logid
  16. dim topicx,usernamex,addtimex,logtextx,ispassword
  17. show_logid=Clng(request("id"))
  18. Dim logpassword,showlogpass
  19. logpassword=request("logpassword")
  20. if logpassword<>"" then
  21. logpassword=md5(logpassword)
  22. set rs=conn.execute("select id from blog where id="&show_logid&" and ispassword='"&logpassword&"'")
  23. if rs.eof then
  24. Response.write "<p>"
  25. Response.Write (converttowide("对不起,日志密码错误!"))
  26. Response.write "</p>"
  27. else
  28. showlogpass=true
  29. end if
  30. end if
  31. dim sql,rs
  32. sql="select topic,id,username,addtime,logtext,ispassword from blog where passcheck<>'false' and id="&show_logid
  33. Set rs=conn.execute(SQL)
  34. If not(rs.bof and rs.eof) then
  35. topicx=rs(0)
  36. usernamex=rs(2)
  37. addtimex=rs(3)
  38. logtextx=cutStr(rs(4),5000)
  39. ispassword=rs(5)
  40. end if
  41. rs.close:Set rs=Nothing
  42. dim msql,rsmain,userid
  43. msql="select userid,username from [user] where username='"&usernamex&"'"
  44. Set rsmain=Server.CreateObject("Adodb.RecordSet")
  45. rsmain.Open msql,Conn,1,1
  46. userid=rsmain(0)
  47. dim page,PageLength,CLength,PageCount,wen,a
  48. if Request("Page")<>"" then Page = CLng(Request("Page"))
  49. PageLength = 500
  50. CLength = Len(logtextx)
  51. PageCount = Int(Clength/PageLength) + 1
  52. if Page < 1 or IsNull(Page) Then    Page = 1
  53. if Page > PageCount Then  Page = PageCount
  54. if page=1 then
  55. a=1
  56. elseif page>1 then
  57. a=(Page-1)*PageLength
  58. end if
  59. wen=Mid(logtextx,a,PageLength)
  60. if ispassword<>"" and showlogpass<>true then
  61. Response.write "<p align=""center"">"
  62. Response.write (converttowide("本日志需要密码访问!"))&"<br/>"
  63. Response.write (converttowide("请输入日志密码:"))&"<br/>"
  64. Response.write "<input name=""logpassword"" type=""text""/>"&"<br/>"
  65. Response.write "<anchor>"
  66. Response.write (converttowide("提交"))
  67. Response.write "<go href=""wapview.asp?ID="&show_logid&""" method=""post"">"
  68. Response.write "<postfield name=""logpassword"" value=""$(logpassword)""/>"
  69. Response.write "</go></anchor></p>"
  70. else
  71. if page="" or page=1 then
  72. Response.write (converttowide("作者:"))
  73. Response.write (converttowide(usernamex))&"<br/>"
  74. Response.write (converttowide("发表时间:"))
  75. Response.write addtimex&"<br/>"
  76. Response.write (converttowide("标题:"))
  77. Response.write (converttowide(topicx))&"<br/>"
  78. Response.write (converttowide("内容:"))
  79. end if
  80. Response.write (converttowide(wen))
  81. Response.write "<br/>"
  82. Response.write (converttowide("本文字数:")) & CLength &"<br/>"
  83. Response.write (converttowide("共分")) & PageCount & (converttowide("页"))&"<br/>"
  84. if PageCount >1 and page <> 1 then
  85. Response.write "<a href=""wapview.asp?ID="&show_logid&"&amp;Page=1"">"&(converttowide("首页"))&"</a><br/>"
  86. end if
  87. dim j
  88. For j=Page+1 To Page+10
  89. if j <= PageCount-1 then
  90. Response.write "<a href=""wapview.asp?ID="&show_logid&"&amp;Page="&j&""">"&j&"</a><br/>"
  91. end if
  92. next
  93. if PageCount >1 and Page <> PageCount then
  94. Response.write "<a href=""wapview.asp?ID="&show_logid&"&amp;Page="&PageCount&""">"&(converttowide("尾页"))&"</a><br/>"
  95. End if
  96. End if
  97. Response.Write "<a href=""wapuser.asp?id="&userid&""">"&(converttowide("返还作者首页"))&"</a><br/>"
  98. Response.Write "<a href=""wapblog.asp"">"&(converttowide("返还最新日志"))&"</a><br/>"
  99. Response.Write "<a href=""wapuserlist.asp"">"&(converttowide("返还博客排行"))&"</a><br/>"
  100. Response.Write"<a href=""wap.asp"">"&(converttowide("返还博客首页"))&"</a>"
  101. %>
  102. </p>
  103. </card>
  104. </wml>
  105. <%
  106. Function cutStr(str,strlen)
  107. '去掉所有HTML标记
  108. Dim re
  109. Set re=new RegExp
  110. re.IgnoreCase =True
  111. re.Global=True
  112. re.Pattern="<(.[^>]*)>"
  113. str=re.Replace(str,"")
  114. set re=Nothing
  115. Dim l,t,c,i
  116. l=Len(str)
  117. t=0
  118. For i=1 to l
  119. c=Abs(Asc(Mid(str,i,1)))
  120. If c>255 Then
  121. t=t+2
  122. Else
  123. t=t+1
  124. End If
  125. If t>=strlen Then
  126. cutStr=left(str,i)&"..."
  127. Exit For
  128. Else
  129. cutStr=str
  130. End If
  131. Next
  132. cutStr=Replace(cutStr,chr(10),"")
  133. cutStr=Replace(cutStr,chr(13),"")
  134. End Function
  135. %>