function_wap.asp
上传用户:rblchem
上传日期:2022-04-27
资源大小:1941k
文件大小:10k
- <%
- Function ReadfileByStream(path)
- Set objStream = Server.CreateObject("ADODB.Stream")
- With objStream
- .Type = 2
- .Mode = 3
- .Open
- .Charset="utf-8"
- .Position = objStream.Size
- .LoadFromFile Server.MapPath(path)
- ReadfileByStream=.ReadText
- .Close
- End With
- Set objStream=nothing
- End Function
- Function ExportStatistics()
- If not isempty(Application(SessionStr&"WAPStatistics")) then
-
- Application.Lock
- ExportStatistics=Application(SessionStr&"WAPStatistics")
- Application.UnLock
- Else
- If not isempty(Application(SessionStr&"WAPTemplateStatistics")) then
-
- Application.Lock
- Statistics=Application(SessionStr&"WAPTemplateStatistics")
- Application.UnLock
- Else
-
- Statistics=ReadfileByStream("TEMPLATE/"&TFolder&"/Statistics.html")
- Application.Lock
- Application(SessionStr&"WAPTemplateStatistics")=Statistics
- Application.UnLock
- End If
-
-
- set conn=connectdb()
- Set objRS=Server.CreateObject("ADODB.Recordset")
- objRS.CursorType = 1
- objRS.LockType = 1
- objRS.ActiveConnection=conn
- objRS.Source="select xmlid from Article"
- objRS.open()
- If (Not objRS.bof) And (Not objRS.eof) Then
- ArticleCount=objRS.RecordCount
- Else
- ArticleCount=0
- End IF
- objRS.Close()
- objRS.Source="select ShenHe from LinkXML WHERE ShenHe=1"
- objRS.open()
- If (Not objRS.bof) And (Not objRS.eof) Then
- XMLCount=objRS.RecordCount
- Else
- XMLCount=0
- End IF
- objRS.Close()
- objRS.Source="select ShenHe from LinkXML WHERE ShenHe=0"
- objRS.open()
- If (Not objRS.bof) And (Not objRS.eof) Then
- XMLNotShenHeCount=objRS.RecordCount
- Else
- XMLNotShenHeCount=0
- End IF
- objRS.Close()
- Set objRS=Nothing
- CloseDb(conn)
- Statistics2=Replace(Statistics,"<#siteNumber#>",XMLCount)
- Statistics2=Replace(Statistics2,"<#NotShenHeNumber#>",XMLNotShenHeCount)
- Statistics2=Replace(Statistics2,"<#ArticleNumber#>",ArticleCount)
- Application.Lock
- Application(SessionStr&"WAPStatistics")=Statistics2
- Application.UnLock
- ExportStatistics=Statistics2
- End If
- End Function
- Function Export(intPage,intCateId,intWebSiteId,dtmYearMonth,strTagsName,intType)
- If Request.querystring("List")="True" Then
- session(SessionStr&"WAPDisplayMode")="List"
- End If
- If Request.querystring("List")="False" Then
- session(SessionStr&"WAPDisplayMode")="Standard"
- End If
- If isempty(session(SessionStr&"WAPDisplayMode")) then
- session(SessionStr&"WAPDisplayMode")=DisplayMode
- End If
- If session(SessionStr&"WAPDisplayMode")="List" then
- If not isempty(Application(SessionStr&"WAPTemplateListMulti")) then
- Application.Lock
- txtcontent=Application(SessionStr&"WAPTemplateListMulti")
- Application.UnLock
- Else
- txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/List_Multi.html")
- Application.Lock
- Application(SessionStr&"WAPTemplateListMulti")=txtcontent
- Application.UnLock
- End If
- Else
- If not isempty(Application(SessionStr&"WAPTemplateArticleMulti")) then
- Application.Lock
- txtcontent=Application(SessionStr&"WAPTemplateArticleMulti")
- Application.UnLock
- Else
- txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/Article_Multi.html")
- Application.Lock
- Application(SessionStr&"WAPTemplateArticleMulti")=txtcontent
- Application.UnLock
- End If
- End If
-
- set conn=connectdb()
- Dim i
- Dim aryListExport()
- Dim objRS
-
- Call CheckParameter(intPage,"int",1)
- Call CheckParameter(intCateId,"int",Empty)
- Call CheckParameter(intWebSiteId,"int",Empty)
- Call CheckParameter(dtmYearMonth,"dtm",Empty)
- Set objRS=Server.CreateObject("ADODB.Recordset")
- objRS.CursorType = 1
- objRS.LockType = 1
- objRS.ActiveConnection=conn
- objRS.Source="select * from Article "
- If Not IsEmpty(intCateId) Then
- objRS.Source=objRS.Source & "where Category_id="&intCateId
- End if
- If Not IsEmpty(intWebSiteId) Then
- objRS.Source=objRS.Source & "where [xmlid]="&intWebSiteId
- End if
- objRS.Source=objRS.Source & " order by pubDate desc"
- objRS.Open()
- If (Not objRS.bof) And (Not objRS.eof) Then
- objRS.PageSize = DISPLAY_COUNT
- intPageCount=objRS.PageCount
- objRS.AbsolutePage = intPage
- PageCount=intPageCount
- ReDim aryListExport(objRS.PageSize)
- For i = 1 To objRS.PageSize
- txtcontent2=Replace(txtcontent,"<#title#>",TU(objRS("title")))
- txtcontent2=Replace(txtcontent2,"<#link#>",objRS("link"))
- txtcontent2=Replace(txtcontent2,"<#pubDate#>",Formattimea(objRS("pubDate")))
- txtcontent2=Replace(txtcontent2,"<#site#>",objRS("site"))
- txtcontent2=Replace(txtcontent2,"<#Author#>",TU(objRS("Author")))
- txtcontent2=Replace(txtcontent2,"<#description#>",TU(objRS("description")))
- txtcontent2=Replace(txtcontent2,"<#URLEncodeTitle#>",Server.URLEncode(objRS("title")))
- txtcontent2=Replace(txtcontent2,"<#ArticleID#>","ArticleID"&i)
- aryListExport(i-1)=txtcontent2
- objRS.MoveNext
- If objRS.EOF Then Exit For
- Next
- 'aryListExport(objRS.PageSize)= ExportBar(intPage,intPageCount,intCateId,intWebSiteId,dtmYearMonth,strTagsName)
- Else
- Exit Function
- End If
- objRS.Close()
- Set objRS=Nothing
- closedb(conn)
- Export=Join(aryListExport)
- End Function
- Function ExportBar(intNowPage,intAllPage,intCateId,intWebSiteId,dtmYearMonth,strTagsName)
- If not isempty(Application(SessionStr&"WAPTemplatePageBar")) then
-
- Application.Lock
- txtcontent=Application(SessionStr&"WAPTemplatePageBar")
- Application.UnLock
- Else
-
- txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/pagebar.html")
- Application.Lock
- Application(SessionStr&"WAPTemplatePageBar")=txtcontent
- Application.UnLock
- End If
- Dim i
- Dim s
- Dim t
- Dim strPageBar
- If Not IsEmpty(intCateId) Then t=t & "cate=" & intCateId & "&"
- If Not IsEmpty(dtmYearMonth) Then t=t & "date=" & Year(dtmYearMonth) & "-" & Month(dtmYearMonth) & "&"
- If Not IsEmpty(intWebSiteId) Then t=t & "site=" & intWebSiteId & "&"
- If Not IsEmpty(strTagsName) Then t=t & "tags=" & Server.URLEncode(strTagsName) & "&"
-
- If intAllPage>0 Then
- Dim a,b
- txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page=1")
- txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>","<<")
- strPageBar=strPageBar & txtcontent2
- If intAllPage>PAGEBAR_COUNT Then
- a=intNowPage
- b=intNowPage+PAGEBAR_COUNT
- If a>PAGEBAR_COUNT Then a=a-1:b=b-1
- If b>intAllPage Then b=intAllPage:a=intAllPage-PAGEBAR_COUNT
- Else
- a=1:b=intAllPage
- End If
- For i=a to b
- txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page="& i )
- txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>",i)
- s=s+ txtcontent2
- Next
- strPageBar=strPageBar+s
- txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page=" & intAllPage)
- txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>",">>")
- strPageBar=strPageBar+ txtcontent2
- End If
- ExportBar=strPageBar
- End Function
- Function Formattimea(Stime)
- If isdate(Stime) then
- Formattimea=formatdatetime(Stime,2)&" "&formatdatetime(Stime,4)
- end if
- End Function
- Function ExportCatelog()
- If not isempty(Application(SessionStr&"WAPTemplateCatelog")) then
-
- Application.Lock
- ExportCatelog=Application(SessionStr&"WAPTemplateCatelog")
- Application.UnLock
- Else
- catelog1=ReadfileByStream("TEMPLATE/"&TFolder&"/catelog1.html")
- catelog2=ReadfileByStream("TEMPLATE/"&TFolder&"/catelog2.html")
- set conn=connectdb()
- Set objRS=Server.CreateObject("ADODB.Recordset")
- objRS.CursorType = 1
- objRS.LockType = 1
- objRS.ActiveConnection=conn
- objRS.Source="SELECT * FROM [Category] WHERE [Category_ParentID]=0 ORDER BY [Category_Order] ASC,[Category_ID] ASC"
- objRS.Open()
- If (Not objRS.bof) And (Not objRS.eof) Then
- For i=1 to objRS.recordcount
- catelog1_1=Replace(catelog1,"<#CatelogID#>",objRS("Category_ID"))
- catelog1_1=Replace(catelog1_1,"<#CatelogName#>",TU(objRS("Category_Name")))
- catelog1_1=Replace(catelog1_1,"<#CatelogArticleNumber#>",ArticleInCate(objRS("Category_ID"),conn))
- catelog1_1=Replace(catelog1_1,"<#CatelogIntro#>",TU(objRS("Category_Intro")))
- catelog1_1=Replace(catelog1_1,"<#SiteListOrder#>",SiteListOrder)
- catelog1_1=Replace(catelog1_1,"<#SiteListLeftNumber#>",SiteListLeftNumber)
-
-
- cache_category=cache_category & catelog1_1
- '如果有二级分类,显示!
- set rs1=conn.execute ("SELECT * FROM [Category] WHERE [Category_ParentID]="&objRS("Category_ID")&" ORDER BY [Category_Order] ASC,[Category_ID] ASC")
- while not rs1.eof
-
- catelog2_1=Replace(catelog2,"<#CatelogID#>",rs1("Category_ID"))
- catelog2_1=Replace(catelog2_1,"<#CatelogName#>",TU(rs1("Category_Name")))
- catelog2_1=Replace(catelog2_1,"<#CatelogArticleNumber#>",ArticleInCate(rs1("Category_ID"),conn))
- catelog2_1=Replace(catelog2_1,"<#CatelogIntro#>",TU(rs1("Category_Intro")))
- catelog2_1=Replace(catelog2_1,"<#SiteListOrder#>",SiteListOrder)
- catelog2_1=Replace(catelog2_1,"<#SiteListLeftNumber#>",SiteListLeftNumber)
- cache_category=cache_category & catelog2_1
- rs1.movenext
- wend
- rs1.close:set rs1=nothing
- objRS.MoveNext
- If objRS.eof Then Exit For
- Next
- End If
- objRS.Close
- Set objRS=Nothing
- CloseDb(conn)
- ExportCatelog=cache_category
-
- Application.Lock
- Application(SessionStr&"WAPTemplateCatelog")=cache_category
- Application.UnLock
- End If
- End Function
- Function ArticleInCate(ID,conn)
- Set OBJRS1=Server.CreateObject("ADODB.Recordset")
- OBJRS1.CursorType = 1
- OBJRS1.LockType = 1
- OBJRS1.ActiveConnection=conn
- OBJRS1.Source="SELECT * FROM [Article] WHERE [Category_ID]="&ID
- OBJRS1.Open()
- If OBJRS1.recordcount=0 then
- ArticleInCate=0
- else
- ArticleInCate=OBJRS1.recordcount
- end if
- OBJRS1.close
- set OBJRS1=nothing
- End Function
- %>