function_default.asp
上传用户:rblchem
上传日期:2022-04-27
资源大小:1941k
文件大小:16k
- <%
- 'ON Error Resume Next
- 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&"Statistics")) then
-
- Application.Lock
- ExportStatistics=Application(SessionStr&"Statistics")
- Application.UnLock
- Else
- If not isempty(Application(SessionStr&"TemplateStatistics")) then
-
- Application.Lock
- Statistics=Application(SessionStr&"TemplateStatistics")
- Application.UnLock
- Else
-
- Statistics=ReadfileByStream("TEMPLATE/"&TFolder&"/Statistics.html")
- Application.Lock
- Application(SessionStr&"TemplateStatistics")=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)
- If not isempty(ZblogCSS) then Statistics2=Replace(Statistics2,"<#ZblogCSS#>",Replace(Lcase(ZblogCSS),".css",""))
- If not isempty(LBSCSSFolder) then Statistics2=Replace(Statistics2,"<#LBSCSSFolder#>",LBSCSSFolder)
- If not isempty(PjStyleFolder) then Statistics2=Replace(Statistics2,"<#PjStyleFolder#>",PjStyleFolder)
-
- Application.Lock
- Application(SessionStr&"Statistics")=Statistics2
- Application.UnLock
- ExportStatistics=Statistics2
- End If
- End Function
- Function Export(intPage,intCateId,intWebSiteId)
-
- If trim(Request.querystring)="" then
- If not isempty(Application(SessionStr&"SXNAindex")) and not isempty(Application(SessionStr&"SXNAintPageCount")) then
- intPageCount=Application(SessionStr&"SXNAintPageCount")
- Export=Application(SessionStr&"SXNAindex")
- Exit Function
- End IF
- End IF
- If validate_string(Lcase(Request.QueryString))=False then
- response.write "Don't try to hack."
- Response.end
- End If
-
- Select case Request.querystring("action")
- Case "AdvanceSearch"
- Export=ExportSearchForm
- Exit Function
- Case "ShowList"
- session(SessionStr&"DisplayMode")="List"
- Case "ShowStandard"
- session(SessionStr&"DisplayMode")="Standard"
- Case "AddFeed"
- Export=ExportAdd_Xml()
- Exit Function
- Case Else
- If isempty(session(SessionStr&"DisplayMode")) then
- session(SessionStr&"DisplayMode")=DisplayMode
- End If
- End Select
-
- If session(SessionStr&"DisplayMode")="List" then
- If not isempty(Application(SessionStr&"TemplateListMulti")) then
- Application.Lock
- txtcontent=Application(SessionStr&"TemplateListMulti")
- Application.UnLock
- Else
- If IsAjaxListMulti=1 then
- txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/List_Multi.html")
- Else
- txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/List_Multi_ajax.html")
- End If
- Application.Lock
- Application(SessionStr&"TemplateListMulti")=txtcontent
- Application.UnLock
- End If
- DISPLAYCOUNT=DISPLAY_COUNT2
- Else
- If not isempty(Application(SessionStr&"TemplateArticleMulti")) then
- Application.Lock
- txtcontent=Application(SessionStr&"TemplateArticleMulti")
- Application.UnLock
- Else
-
- txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/Article_Multi.html")
- Application.Lock
- Application(SessionStr&"TemplateArticleMulti")=txtcontent
- Application.UnLock
- End If
- DISPLAYCOUNT=DISPLAY_COUNT
- 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)
- Set objRS=Server.CreateObject("ADODB.Recordset")
- objRS.CursorType = 1
- objRS.LockType = 1
- objRS.ActiveConnection=conn
-
- If Request.querystring("HiddenSearchFlag")="1" then
- MakeStronString1=FilterSQL2(Request.querystring("s_title"))
- MakeStronString2=FilterSQL2(Request.querystring("s_title"))
- objRS.Source="SELECT * FROM [Article] INNER JOIN [LinkXML] ON Article.xmlid=LinkXML.id WHERE Article.title LIKE '%"&MakeStronString2&"%' or Article.description LIKE '%"&MakeStronString2&"%' or author LIKE '%"&MakeStronString2&"%' order by pubdate desc"
- StrongFlag=1
- Elseif Request.querystring("HiddenSearchFlag")="2" then
- MakeStronString1=FilterSQL2(Request.querystring("s_title"))
- MakeStronString2=FilterSQL2(Request.querystring("s_description"))
- Call SearchRequestAction
- 'response.write NewsSql: response.end
- objRS.Source=NewsSql
- StrongFlag=1
- Else
- objRS.Source="select * from (([Article] INNER JOIN [LinkXML] ON Article.xmlid=LinkXML.id)INNER JOIN [Category] ON Article.Category_id = Category.Category_id) "
- If Not IsEmpty(intCateId) Then
- objRS.Source=objRS.Source & "where (Category.Category_id="&intCateId&" or Category.Category_id in (select Category.Category_id from Category where Category_parentID="&intCateId&")) and ([other]='Y' or Isnull(other) or [other]='')"
- End if
- If Not IsEmpty(intWebSiteId) Then
- objRS.Source=objRS.Source & " where [xmlid]="&intWebSiteId
- ElseIF IsEmpty(intCateId) then
- objRS.Source=objRS.Source & " where ([other]='Y' or Isnull(other) or [other]='') "
- End if
- objRS.Source=objRS.Source & " order by pubDate desc"
- StrongFlag=0
- End IF
- objRS.Open()
- If (Not objRS.bof) And (Not objRS.eof) Then
- objRS.PageSize = DISPLAYCOUNT
- intPageCount=objRS.PageCount
- if intPage<=0 then intPage=1
- objRS.AbsolutePage = intPage
- PageCount=intPageCount
- ReDim aryListExport(objRS.PageSize)
- For i = 1 To objRS.PageSize
- If DisplayDescriptionType=2 then
- Description=objRS("Article.description")
- Title=objRS("Article.title")
- Else
- Title=objRS("Article.title")
- elements=split(objRS("Elements"),"|||")
- '先判断转化模式
- If Elements(11)="0" Then
- '应用全局设定转化模式
- Description=RegExpHtml(objRS("Article.description"),RegExpType_Discription)
- Else
- '应用特定转化模式
- Description=RegExpHtml(objRS("Article.description"),Elements(11))
- End If
- '截取字符
- If Elements(12)="" Then
- '应用全局设定截取字符
- IF isIntercept_description=0 then
- Description=Description
- Else
- Description=Left(Description,cint(InterceptDescriptin))
- End If
- Else
- '应用特定截取字符
- Description=Left(Description,cint(Elements(12)))
- End If
- End If
- If StrongFlag=1 then
- txtcontent2=Replacestr(txtcontent,"<#title#>",Replace(Title,MakeStronString1,"<b style='color:#FF0000'>"&MakeStronString1&"</b>"))
- txtcontent2=Replacestr(txtcontent2,"<#description#>",Replace(Description,MakeStronString2,"<b style='color:#FF0000'>"&MakeStronString2&"</b>"))
- Else
- txtcontent2=Replace(txtcontent,"<#title#>",Title)
- txtcontent2=Replace(txtcontent2,"<#description#>",Description)
- End If
- txtcontent2=Replace(txtcontent2,"<#link#>",objRS("link"))
- txtcontent2=Replace(txtcontent2,"<#pubDate#>",Formattimea(objRS("pubDate")))
- txtcontent2=Replace(txtcontent2,"<#site#>",objRS("site"))
- txtcontent2=Replace(txtcontent2,"<#Author#>",objRS("Author"))
- txtcontent2=Replace(txtcontent2,"<#URLEncodeTitle#>",Server.URLEncode(Title))
- txtcontent2=Replace(txtcontent2,"<#ArticleID#>","ArticleID"&i)
- txtcontent2=Replace(txtcontent2,"<#XmlUrl#>",objRS("linkxml"))
- If IsAjaxListMulti=2 then
- txtcontent2=Replace(txtcontent2,"<#EncodeURL#>",Server.URLEncode(objRS("link")))
- End If
- aryListExport(i-1)=txtcontent2
- objRS.MoveNext
- If objRS.EOF Then Exit For
- Next
- 'aryListExport(objRS.PageSize)= ExportBar(intPage,intPageCount,intCateId,intWebSiteId)
- Else
- Exit Function
- End If
- objRS.Close()
- Set objRS=Nothing
- closedb(conn)
- If trim(Request.querystring)="" then
- Export=Join(aryListExport)
- Application.Lock
- Application(SessionStr&"SXNAindex")=Join(aryListExport)
- Application(SessionStr&"SXNAintPageCount")=intPageCount
- Application.UnLock
- Else
- Export=Join(aryListExport)
- End If
- End Function
- Function ExportBar(intNowPage,intAllPage,intCateId,intWebSiteId)
- If not isempty(Application(SessionStr&"TemplatePageBar")) then
- Application.Lock
- txtcontent=Application(SessionStr&"TemplatePageBar")
- Application.UnLock
- Else
- txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/pagebar.html")
- Application.Lock
- Application(SessionStr&"TemplatePageBar")=txtcontent
- Application.UnLock
- End If
- Dim i
- Dim s
- Dim t
- Dim strPageBar
- If Not IsEmpty(Request.Querystring("s_title")) then
- t=t&Request.Querystring&"&"
- t=ReplaceStr(t,"page=(d*)&","")
- End If
- If Not IsEmpty(intCateId) Then t=t & "cate=" & intCateId & "&"
- If Not IsEmpty(intWebSiteId) Then t=t & "site=" & intWebSiteId & "&"
-
- 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 session(SessionStr&"DisplayMode")="List" then
- PAGEBARCOUNT=PAGEBAR_COUNT2
- Else
- PAGEBARCOUNT=PAGEBAR_COUNT
- End If
- If intAllPage>PAGEBARCOUNT Then
- a=intNowPage
- b=intNowPage+PAGEBARCOUNT
- If a>PAGEBARCOUNT Then a=a-1:b=b-1
- If b>intAllPage Then b=intAllPage:a=intAllPage-PAGEBARCOUNT
- If a<=0 Then a=1
- If a>intAllPage Then a=1
- 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 ExportAdd_Xml()
- If not isempty(Application(SessionStr&"TemplateAdd_Xml")) then
- Application.Lock
- ExportAdd_Xml1=Application(SessionStr&"TemplateAdd_Xml")
- Application.UnLock
- Else
- ExportAdd_Xml1=ReadfileByStream("TEMPLATE/"&TFolder&"/Add_xml.html")
- Application.Lock
- Application(SessionStr&"TemplateAdd_Xml")=ExportAdd_Xml1
- Application.UnLock
- End If
- ExportAdd_Xml=ExportAdd_Xml1
- End Function
- Function ExportSearchForm()
- If not isempty(Application(SessionStr&"TemplateSearchForm")) then
-
- Application.Lock
- ExportSearchForm1=Application(SessionStr&"TemplateSearchForm")
- Application.UnLock
- Else
- ExportSearchForm1=ReadfileByStream("TEMPLATE/"&TFolder&"/Search.html")
- Application.Lock
- Application(SessionStr&"TemplateSearchForm")=ExportSearchForm1
- Application.UnLock
- End If
- Response.write ReplaceStr(ExportSearchForm1,"<!--MARK2-->(s*|.*?)*<!--MARK3-->","")
- SearchTable 2,""
- Response.write ReplaceStr(ExportSearchForm1,"<!--MARK1-->(s*|.*?)*<!--MARK2-->","")
- End Function
- Function ExportCatelog()
- If not isempty(Application(SessionStr&"Catelog")) then
- Application.Lock
- ExportCatelog=Application(SessionStr&"Catelog")
- Application.UnLock
- Else
- If not isempty(Application(SessionStr&"TemplateCatelog1")) then
-
- catelog1=Application(SessionStr&"TemplateCatelog1")
- catelog2=Application(SessionStr&"TemplateCatelog2")
- Else
- catelog1=ReadfileByStream("TEMPLATE/"&TFolder&"/catelog1.html")
- catelog2=ReadfileByStream("TEMPLATE/"&TFolder&"/catelog2.html")
- Application.Lock
- Application(SessionStr&"TemplateCatelog1")=catelog1
- Application(SessionStr&"TemplateCatelog2")=catelog2
- 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 * 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#>",objRS("Category_Name"))
- catelog1_1=Replace(catelog1_1,"<#CatelogArticleNumber#>",ArticleInCate(objRS("Category_ID"),conn))
- catelog1_1=Replace(catelog1_1,"<#CatelogIntro#>",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#>",rs1("Category_Name"))
- catelog2_1=Replace(catelog2_1,"<#CatelogArticleNumber#>",ArticleInCate(rs1("Category_ID"),conn))
- catelog2_1=Replace(catelog2_1,"<#CatelogIntro#>",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&"Catelog")=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
- Function FilterSQL2(strSQL)
- If not isnull(strSQL) then
- FilterSQL2=CStr(Replace(strSQL,chr(39),chr(39)&chr(39)))
- end if
- End Function
- Function ReplaceStr(source,para,str)
- Set objRegExp=New RegExp
- objRegExp.IgnoreCase =True
- objRegExp.Global=True
- objRegExp.Pattern=para
- ReplaceStr= objRegExp.Replace(source,str)
- Set objRegExp=Nothing
- End Function
- function validate_string(input)
- known_bad=array("select","insert","update","delete","drop","—","'",";","#")
- validate_string=true
- for i=lbound(known_bad) to ubound(known_bad)
- if(instr(1,input,known_bad(i),vbtextcompare)<>0) then
- validate_string=false
- exit function
- end if
- next
- end function
- %>