function_wap.asp
上传用户:rblchem
上传日期:2022-04-27
资源大小:1941k
文件大小:10k
源码类别:

编辑器/阅读器

开发平台:

C#

  1. <%
  2. Function ReadfileByStream(path)
  3.         Set objStream = Server.CreateObject("ADODB.Stream")
  4. With objStream
  5. .Type = 2
  6. .Mode = 3
  7. .Open
  8. .Charset="utf-8"
  9. .Position = objStream.Size
  10. .LoadFromFile Server.MapPath(path)
  11. ReadfileByStream=.ReadText
  12. .Close
  13. End With
  14. Set objStream=nothing
  15. End Function
  16. Function ExportStatistics()
  17.         If not isempty(Application(SessionStr&"WAPStatistics")) then
  18.         
  19. Application.Lock
  20. ExportStatistics=Application(SessionStr&"WAPStatistics")
  21. Application.UnLock
  22. Else
  23. If not isempty(Application(SessionStr&"WAPTemplateStatistics")) then
  24. Application.Lock
  25. Statistics=Application(SessionStr&"WAPTemplateStatistics")
  26. Application.UnLock
  27. Else
  28. Statistics=ReadfileByStream("TEMPLATE/"&TFolder&"/Statistics.html")
  29. Application.Lock
  30. Application(SessionStr&"WAPTemplateStatistics")=Statistics
  31. Application.UnLock
  32. End If
  33.         
  34. set conn=connectdb()
  35.         Set objRS=Server.CreateObject("ADODB.Recordset")
  36. objRS.CursorType = 1
  37. objRS.LockType = 1
  38. objRS.ActiveConnection=conn
  39. objRS.Source="select xmlid from Article"
  40. objRS.open()
  41. If (Not objRS.bof) And (Not objRS.eof) Then
  42. ArticleCount=objRS.RecordCount
  43. Else
  44. ArticleCount=0
  45. End IF
  46. objRS.Close()
  47.         objRS.Source="select ShenHe from LinkXML WHERE ShenHe=1"
  48. objRS.open()
  49. If (Not objRS.bof) And (Not objRS.eof) Then
  50. XMLCount=objRS.RecordCount
  51. Else
  52. XMLCount=0
  53. End IF
  54. objRS.Close()
  55. objRS.Source="select ShenHe from LinkXML WHERE ShenHe=0"
  56. objRS.open()
  57. If (Not objRS.bof) And (Not objRS.eof) Then
  58. XMLNotShenHeCount=objRS.RecordCount
  59. Else
  60. XMLNotShenHeCount=0
  61. End IF
  62. objRS.Close()
  63. Set objRS=Nothing
  64.         CloseDb(conn)
  65. Statistics2=Replace(Statistics,"<#siteNumber#>",XMLCount)
  66. Statistics2=Replace(Statistics2,"<#NotShenHeNumber#>",XMLNotShenHeCount)
  67.     Statistics2=Replace(Statistics2,"<#ArticleNumber#>",ArticleCount)
  68. Application.Lock
  69. Application(SessionStr&"WAPStatistics")=Statistics2
  70. Application.UnLock
  71. ExportStatistics=Statistics2
  72. End If
  73. End Function
  74. Function Export(intPage,intCateId,intWebSiteId,dtmYearMonth,strTagsName,intType)
  75.    If Request.querystring("List")="True" Then
  76.     session(SessionStr&"WAPDisplayMode")="List"
  77.    End If
  78.    If Request.querystring("List")="False" Then
  79.     session(SessionStr&"WAPDisplayMode")="Standard"
  80.    End If
  81.    If isempty(session(SessionStr&"WAPDisplayMode")) then
  82.    session(SessionStr&"WAPDisplayMode")=DisplayMode
  83.    End If
  84. If session(SessionStr&"WAPDisplayMode")="List" then
  85.     If not isempty(Application(SessionStr&"WAPTemplateListMulti")) then
  86. Application.Lock
  87. txtcontent=Application(SessionStr&"WAPTemplateListMulti")
  88. Application.UnLock
  89. Else
  90. txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/List_Multi.html")  
  91. Application.Lock
  92. Application(SessionStr&"WAPTemplateListMulti")=txtcontent
  93. Application.UnLock
  94. End If
  95. Else
  96. If not isempty(Application(SessionStr&"WAPTemplateArticleMulti")) then
  97. Application.Lock
  98. txtcontent=Application(SessionStr&"WAPTemplateArticleMulti")
  99. Application.UnLock
  100. Else
  101. txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/Article_Multi.html")    
  102. Application.Lock
  103. Application(SessionStr&"WAPTemplateArticleMulti")=txtcontent
  104. Application.UnLock
  105. End If
  106. End If     
  107.         set conn=connectdb()
  108. Dim i
  109. Dim aryListExport()
  110. Dim objRS
  111. Call CheckParameter(intPage,"int",1)
  112. Call CheckParameter(intCateId,"int",Empty)
  113. Call CheckParameter(intWebSiteId,"int",Empty)
  114. Call CheckParameter(dtmYearMonth,"dtm",Empty)
  115. Set objRS=Server.CreateObject("ADODB.Recordset")
  116. objRS.CursorType = 1
  117. objRS.LockType = 1
  118. objRS.ActiveConnection=conn
  119. objRS.Source="select * from Article "
  120. If Not IsEmpty(intCateId) Then
  121. objRS.Source=objRS.Source & "where Category_id="&intCateId
  122. End if
  123. If Not IsEmpty(intWebSiteId) Then
  124. objRS.Source=objRS.Source & "where [xmlid]="&intWebSiteId
  125. End if
  126. objRS.Source=objRS.Source & " order by pubDate desc"
  127. objRS.Open()
  128. If (Not objRS.bof) And (Not objRS.eof) Then
  129. objRS.PageSize = DISPLAY_COUNT
  130. intPageCount=objRS.PageCount
  131. objRS.AbsolutePage = intPage
  132. PageCount=intPageCount
  133. ReDim aryListExport(objRS.PageSize)
  134. For i = 1 To objRS.PageSize
  135.     txtcontent2=Replace(txtcontent,"<#title#>",TU(objRS("title")))
  136. txtcontent2=Replace(txtcontent2,"<#link#>",objRS("link"))
  137. txtcontent2=Replace(txtcontent2,"<#pubDate#>",Formattimea(objRS("pubDate")))
  138. txtcontent2=Replace(txtcontent2,"<#site#>",objRS("site"))
  139. txtcontent2=Replace(txtcontent2,"<#Author#>",TU(objRS("Author")))
  140. txtcontent2=Replace(txtcontent2,"<#description#>",TU(objRS("description")))
  141. txtcontent2=Replace(txtcontent2,"<#URLEncodeTitle#>",Server.URLEncode(objRS("title")))
  142. txtcontent2=Replace(txtcontent2,"<#ArticleID#>","ArticleID"&i)
  143.      aryListExport(i-1)=txtcontent2
  144. objRS.MoveNext
  145. If objRS.EOF Then Exit For
  146. Next
  147. 'aryListExport(objRS.PageSize)= ExportBar(intPage,intPageCount,intCateId,intWebSiteId,dtmYearMonth,strTagsName)
  148. Else
  149. Exit Function
  150. End If
  151. objRS.Close()
  152. Set objRS=Nothing
  153. closedb(conn)
  154. Export=Join(aryListExport)
  155. End Function
  156. Function ExportBar(intNowPage,intAllPage,intCateId,intWebSiteId,dtmYearMonth,strTagsName)
  157.         If not isempty(Application(SessionStr&"WAPTemplatePageBar")) then
  158.         
  159. Application.Lock
  160. txtcontent=Application(SessionStr&"WAPTemplatePageBar")
  161. Application.UnLock
  162. Else
  163.         
  164. txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/pagebar.html")
  165. Application.Lock
  166. Application(SessionStr&"WAPTemplatePageBar")=txtcontent
  167. Application.UnLock
  168. End If
  169. Dim i
  170. Dim s
  171. Dim t
  172. Dim strPageBar
  173. If Not IsEmpty(intCateId) Then t=t & "cate=" & intCateId & "&amp;"
  174. If Not IsEmpty(dtmYearMonth) Then t=t & "date=" & Year(dtmYearMonth) & "-" & Month(dtmYearMonth) & "&amp;"
  175. If Not IsEmpty(intWebSiteId) Then t=t & "site=" & intWebSiteId & "&amp;"
  176. If Not IsEmpty(strTagsName) Then t=t & "tags=" & Server.URLEncode(strTagsName) & "&amp;"
  177. If intAllPage>0 Then
  178. Dim a,b
  179.         txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page=1")
  180. txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>","&lt;&lt;")
  181. strPageBar=strPageBar & txtcontent2
  182. If intAllPage>PAGEBAR_COUNT Then
  183. a=intNowPage
  184. b=intNowPage+PAGEBAR_COUNT
  185. If a>PAGEBAR_COUNT Then a=a-1:b=b-1
  186. If b>intAllPage Then b=intAllPage:a=intAllPage-PAGEBAR_COUNT
  187. Else
  188. a=1:b=intAllPage
  189. End If
  190. For i=a to b
  191.             txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page="& i )
  192. txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>",i)
  193. s=s+ txtcontent2
  194. Next
  195. strPageBar=strPageBar+s
  196. txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page=" & intAllPage)
  197. txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>","&gt;&gt;")
  198. strPageBar=strPageBar+ txtcontent2
  199. End If
  200. ExportBar=strPageBar
  201. End Function
  202. Function Formattimea(Stime)
  203. If isdate(Stime) then
  204. Formattimea=formatdatetime(Stime,2)&" "&formatdatetime(Stime,4)
  205. end if
  206. End Function
  207. Function ExportCatelog()
  208.         If not isempty(Application(SessionStr&"WAPTemplateCatelog")) then
  209.         
  210. Application.Lock
  211. ExportCatelog=Application(SessionStr&"WAPTemplateCatelog")
  212. Application.UnLock
  213. Else
  214. catelog1=ReadfileByStream("TEMPLATE/"&TFolder&"/catelog1.html")
  215. catelog2=ReadfileByStream("TEMPLATE/"&TFolder&"/catelog2.html")
  216.             set conn=connectdb()
  217. Set objRS=Server.CreateObject("ADODB.Recordset")
  218. objRS.CursorType = 1
  219. objRS.LockType = 1
  220. objRS.ActiveConnection=conn
  221. objRS.Source="SELECT * FROM [Category] WHERE [Category_ParentID]=0  ORDER BY [Category_Order] ASC,[Category_ID] ASC"
  222. objRS.Open()
  223. If (Not objRS.bof) And (Not objRS.eof) Then
  224. For i=1 to objRS.recordcount
  225.                 catelog1_1=Replace(catelog1,"<#CatelogID#>",objRS("Category_ID"))
  226. catelog1_1=Replace(catelog1_1,"<#CatelogName#>",TU(objRS("Category_Name")))
  227. catelog1_1=Replace(catelog1_1,"<#CatelogArticleNumber#>",ArticleInCate(objRS("Category_ID"),conn))
  228. catelog1_1=Replace(catelog1_1,"<#CatelogIntro#>",TU(objRS("Category_Intro")))
  229.       catelog1_1=Replace(catelog1_1,"<#SiteListOrder#>",SiteListOrder)
  230.   catelog1_1=Replace(catelog1_1,"<#SiteListLeftNumber#>",SiteListLeftNumber)
  231.                 
  232. cache_category=cache_category & catelog1_1
  233. '如果有二级分类,显示!
  234. set rs1=conn.execute ("SELECT * FROM [Category] WHERE [Category_ParentID]="&objRS("Category_ID")&"  ORDER BY [Category_Order] ASC,[Category_ID] ASC")
  235. while not rs1.eof
  236. catelog2_1=Replace(catelog2,"<#CatelogID#>",rs1("Category_ID"))
  237. catelog2_1=Replace(catelog2_1,"<#CatelogName#>",TU(rs1("Category_Name")))
  238. catelog2_1=Replace(catelog2_1,"<#CatelogArticleNumber#>",ArticleInCate(rs1("Category_ID"),conn))
  239. catelog2_1=Replace(catelog2_1,"<#CatelogIntro#>",TU(rs1("Category_Intro")))
  240. catelog2_1=Replace(catelog2_1,"<#SiteListOrder#>",SiteListOrder)
  241.     catelog2_1=Replace(catelog2_1,"<#SiteListLeftNumber#>",SiteListLeftNumber)
  242.                     cache_category=cache_category & catelog2_1
  243. rs1.movenext
  244. wend
  245. rs1.close:set rs1=nothing
  246. objRS.MoveNext
  247. If objRS.eof Then Exit For
  248. Next
  249. End If
  250. objRS.Close
  251. Set objRS=Nothing
  252. CloseDb(conn)
  253. ExportCatelog=cache_category
  254.     
  255. Application.Lock
  256. Application(SessionStr&"WAPTemplateCatelog")=cache_category
  257. Application.UnLock
  258. End If
  259. End Function
  260. Function ArticleInCate(ID,conn)
  261.     Set OBJRS1=Server.CreateObject("ADODB.Recordset")
  262. OBJRS1.CursorType = 1
  263. OBJRS1.LockType = 1
  264. OBJRS1.ActiveConnection=conn
  265. OBJRS1.Source="SELECT * FROM [Article] WHERE [Category_ID]="&ID
  266. OBJRS1.Open()
  267. If OBJRS1.recordcount=0 then
  268. ArticleInCate=0
  269. else
  270. ArticleInCate=OBJRS1.recordcount
  271. end if
  272. OBJRS1.close
  273. set OBJRS1=nothing
  274. End Function
  275. %>