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

编辑器/阅读器

开发平台:

C#

  1. <%
  2. 'ON Error Resume Next
  3. Function ReadfileByStream(path)
  4.         Set objStream = Server.CreateObject("ADODB.Stream")
  5. With objStream
  6. .Type = 2
  7. .Mode = 3
  8. .Open
  9. .Charset="utf-8"
  10. .Position = objStream.Size
  11. .LoadFromFile Server.MapPath(path)
  12. ReadfileByStream=.ReadText
  13. .Close
  14. End With
  15. Set objStream=nothing
  16. End Function
  17. Function ExportStatistics()
  18.         If not isempty(Application(SessionStr&"Statistics")) then
  19.         
  20. Application.Lock
  21. ExportStatistics=Application(SessionStr&"Statistics")
  22. Application.UnLock
  23. Else
  24. If not isempty(Application(SessionStr&"TemplateStatistics")) then
  25. Application.Lock
  26. Statistics=Application(SessionStr&"TemplateStatistics")
  27. Application.UnLock
  28. Else
  29. Statistics=ReadfileByStream("TEMPLATE/"&TFolder&"/Statistics.html")
  30. Application.Lock
  31. Application(SessionStr&"TemplateStatistics")=Statistics
  32. Application.UnLock
  33. End If
  34.         
  35. set conn=connectdb()
  36.         Set objRS=Server.CreateObject("ADODB.Recordset")
  37. objRS.CursorType = 1
  38. objRS.LockType = 1
  39. objRS.ActiveConnection=conn
  40. objRS.Source="select xmlid from Article"
  41. objRS.open()
  42. If (Not objRS.bof) And (Not objRS.eof) Then
  43. ArticleCount=objRS.RecordCount
  44. Else
  45. ArticleCount=0
  46. End IF
  47. objRS.Close()
  48.         objRS.Source="select ShenHe from LinkXML WHERE ShenHe=1"
  49. objRS.open()
  50. If (Not objRS.bof) And (Not objRS.eof) Then
  51. XMLCount=objRS.RecordCount
  52. Else
  53. XMLCount=0
  54. End IF
  55. objRS.Close()
  56. objRS.Source="select ShenHe from LinkXML WHERE ShenHe=0"
  57. objRS.open()
  58. If (Not objRS.bof) And (Not objRS.eof) Then
  59. XMLNotShenHeCount=objRS.RecordCount
  60. Else
  61. XMLNotShenHeCount=0
  62. End IF
  63. objRS.Close()
  64. Set objRS=Nothing
  65.         CloseDb(conn)
  66. Statistics2=Replace(Statistics,"<#siteNumber#>",XMLCount)
  67. Statistics2=Replace(Statistics2,"<#NotShenHeNumber#>",XMLNotShenHeCount)
  68.     Statistics2=Replace(Statistics2,"<#ArticleNumber#>",ArticleCount)
  69. If not isempty(ZblogCSS) then Statistics2=Replace(Statistics2,"<#ZblogCSS#>",Replace(Lcase(ZblogCSS),".css",""))
  70. If not isempty(LBSCSSFolder) then Statistics2=Replace(Statistics2,"<#LBSCSSFolder#>",LBSCSSFolder)
  71. If not isempty(PjStyleFolder) then Statistics2=Replace(Statistics2,"<#PjStyleFolder#>",PjStyleFolder)
  72. Application.Lock
  73. Application(SessionStr&"Statistics")=Statistics2
  74. Application.UnLock
  75. ExportStatistics=Statistics2
  76. End If
  77. End Function
  78. Function Export(intPage,intCateId,intWebSiteId)
  79.            
  80.    If trim(Request.querystring)="" then
  81.  If not isempty(Application(SessionStr&"SXNAindex")) and not isempty(Application(SessionStr&"SXNAintPageCount")) then 
  82.  intPageCount=Application(SessionStr&"SXNAintPageCount")
  83.  Export=Application(SessionStr&"SXNAindex")  
  84.       Exit Function
  85.  End IF
  86.    End IF
  87.            If validate_string(Lcase(Request.QueryString))=False then
  88.        response.write "Don't try to hack."
  89.        Response.end
  90.        End If
  91.            
  92.            Select case Request.querystring("action")
  93.    Case "AdvanceSearch"
  94.    Export=ExportSearchForm
  95.         Exit Function
  96.    Case "ShowList"
  97.            session(SessionStr&"DisplayMode")="List"
  98.    Case "ShowStandard"
  99.    session(SessionStr&"DisplayMode")="Standard"
  100.    Case "AddFeed"
  101.    Export=ExportAdd_Xml()
  102.            Exit Function
  103.    Case Else
  104.    If isempty(session(SessionStr&"DisplayMode")) then
  105.    session(SessionStr&"DisplayMode")=DisplayMode
  106.    End If
  107.    End Select
  108.    
  109. If session(SessionStr&"DisplayMode")="List" then
  110.     If not isempty(Application(SessionStr&"TemplateListMulti")) then
  111. Application.Lock
  112. txtcontent=Application(SessionStr&"TemplateListMulti")
  113. Application.UnLock
  114. Else
  115.   If IsAjaxListMulti=1 then
  116.   txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/List_Multi.html")  
  117.   Else
  118.   txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/List_Multi_ajax.html") 
  119.   End If
  120. Application.Lock
  121. Application(SessionStr&"TemplateListMulti")=txtcontent
  122. Application.UnLock
  123. End If
  124. DISPLAYCOUNT=DISPLAY_COUNT2
  125. Else
  126. If not isempty(Application(SessionStr&"TemplateArticleMulti")) then
  127. Application.Lock
  128. txtcontent=Application(SessionStr&"TemplateArticleMulti")
  129. Application.UnLock
  130. Else
  131. txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/Article_Multi.html")    
  132. Application.Lock
  133. Application(SessionStr&"TemplateArticleMulti")=txtcontent
  134. Application.UnLock
  135. End If
  136. DISPLAYCOUNT=DISPLAY_COUNT
  137. End If     
  138.         set conn=connectdb()
  139. Dim i
  140. Dim aryListExport()
  141. Dim objRS
  142. Call CheckParameter(intPage,"int",1)
  143. Call CheckParameter(intCateId,"int",Empty)
  144. Call CheckParameter(intWebSiteId,"int",Empty)
  145. Set objRS=Server.CreateObject("ADODB.Recordset")
  146. objRS.CursorType = 1
  147. objRS.LockType = 1
  148. objRS.ActiveConnection=conn
  149.     
  150. If Request.querystring("HiddenSearchFlag")="1" then     
  151. MakeStronString1=FilterSQL2(Request.querystring("s_title"))
  152. MakeStronString2=FilterSQL2(Request.querystring("s_title"))
  153. 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"
  154. StrongFlag=1
  155. Elseif Request.querystring("HiddenSearchFlag")="2" then
  156. MakeStronString1=FilterSQL2(Request.querystring("s_title"))
  157. MakeStronString2=FilterSQL2(Request.querystring("s_description"))
  158. Call SearchRequestAction
  159. 'response.write NewsSql: response.end
  160. objRS.Source=NewsSql
  161. StrongFlag=1
  162. Else
  163.             objRS.Source="select * from (([Article] INNER JOIN [LinkXML] ON Article.xmlid=LinkXML.id)INNER JOIN [Category] ON Article.Category_id = Category.Category_id) "
  164. If Not IsEmpty(intCateId) Then
  165. 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]='')" 
  166. End if
  167. If Not IsEmpty(intWebSiteId) Then
  168. objRS.Source=objRS.Source & " where [xmlid]="&intWebSiteId
  169. ElseIF IsEmpty(intCateId) then
  170.     objRS.Source=objRS.Source & " where ([other]='Y' or Isnull(other) or [other]='') "
  171. End if
  172. objRS.Source=objRS.Source & " order by pubDate desc"
  173. StrongFlag=0
  174. End IF
  175. objRS.Open()
  176. If (Not objRS.bof) And (Not objRS.eof) Then
  177. objRS.PageSize = DISPLAYCOUNT
  178. intPageCount=objRS.PageCount
  179. if intPage<=0 then intPage=1
  180. objRS.AbsolutePage = intPage
  181. PageCount=intPageCount
  182. ReDim aryListExport(objRS.PageSize)
  183. For i = 1 To objRS.PageSize
  184.     If DisplayDescriptionType=2 then
  185.    Description=objRS("Article.description")
  186.    Title=objRS("Article.title")
  187. Else
  188. Title=objRS("Article.title")
  189.                 elements=split(objRS("Elements"),"|||")
  190. '先判断转化模式
  191. If Elements(11)="0" Then
  192. '应用全局设定转化模式
  193. Description=RegExpHtml(objRS("Article.description"),RegExpType_Discription)
  194. Else
  195. '应用特定转化模式
  196. Description=RegExpHtml(objRS("Article.description"),Elements(11))
  197. End If
  198. '截取字符
  199. If Elements(12)="" Then
  200. '应用全局设定截取字符
  201. IF isIntercept_description=0 then
  202. Description=Description
  203. Else
  204. Description=Left(Description,cint(InterceptDescriptin))
  205. End If
  206. Else
  207. '应用特定截取字符
  208. Description=Left(Description,cint(Elements(12)))
  209. End If
  210. End If
  211. If StrongFlag=1 then     
  212. txtcontent2=Replacestr(txtcontent,"<#title#>",Replace(Title,MakeStronString1,"<b style='color:#FF0000'>"&MakeStronString1&"</b>"))
  213.     txtcontent2=Replacestr(txtcontent2,"<#description#>",Replace(Description,MakeStronString2,"<b style='color:#FF0000'>"&MakeStronString2&"</b>"))
  214.     Else
  215. txtcontent2=Replace(txtcontent,"<#title#>",Title)
  216. txtcontent2=Replace(txtcontent2,"<#description#>",Description)
  217. End If
  218. txtcontent2=Replace(txtcontent2,"<#link#>",objRS("link"))
  219. txtcontent2=Replace(txtcontent2,"<#pubDate#>",Formattimea(objRS("pubDate")))
  220. txtcontent2=Replace(txtcontent2,"<#site#>",objRS("site"))
  221. txtcontent2=Replace(txtcontent2,"<#Author#>",objRS("Author"))
  222. txtcontent2=Replace(txtcontent2,"<#URLEncodeTitle#>",Server.URLEncode(Title))
  223. txtcontent2=Replace(txtcontent2,"<#ArticleID#>","ArticleID"&i)
  224. txtcontent2=Replace(txtcontent2,"<#XmlUrl#>",objRS("linkxml"))
  225. If IsAjaxListMulti=2 then
  226. txtcontent2=Replace(txtcontent2,"<#EncodeURL#>",Server.URLEncode(objRS("link")))
  227. End If
  228.      aryListExport(i-1)=txtcontent2
  229. objRS.MoveNext
  230. If objRS.EOF Then Exit For
  231. Next
  232. 'aryListExport(objRS.PageSize)= ExportBar(intPage,intPageCount,intCateId,intWebSiteId)
  233. Else
  234. Exit Function
  235. End If
  236. objRS.Close()
  237. Set objRS=Nothing
  238. closedb(conn)
  239.       If trim(Request.querystring)="" then
  240.         Export=Join(aryListExport)
  241. Application.Lock
  242.         Application(SessionStr&"SXNAindex")=Join(aryListExport)
  243. Application(SessionStr&"SXNAintPageCount")=intPageCount
  244. Application.UnLock
  245. Else
  246. Export=Join(aryListExport)
  247.         End If
  248. End Function
  249. Function ExportBar(intNowPage,intAllPage,intCateId,intWebSiteId)
  250. If not isempty(Application(SessionStr&"TemplatePageBar")) then
  251.         Application.Lock
  252. txtcontent=Application(SessionStr&"TemplatePageBar")
  253. Application.UnLock
  254. Else        
  255. txtcontent=ReadfileByStream("TEMPLATE/"&TFolder&"/pagebar.html")
  256. Application.Lock
  257. Application(SessionStr&"TemplatePageBar")=txtcontent
  258. Application.UnLock
  259. End If
  260. Dim i
  261. Dim s
  262. Dim t
  263. Dim strPageBar
  264. If Not IsEmpty(Request.Querystring("s_title")) then
  265. t=t&Request.Querystring&"&"
  266. t=ReplaceStr(t,"page=(d*)&","")
  267. End If
  268. If Not IsEmpty(intCateId) Then t=t & "cate=" & intCateId & "&amp;"
  269. If Not IsEmpty(intWebSiteId) Then t=t & "site=" & intWebSiteId & "&amp;"
  270. If intAllPage>0 Then
  271. Dim a,b
  272.         txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page=1")
  273. txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>","&lt;&lt;")
  274. strPageBar=strPageBar & txtcontent2
  275. If session(SessionStr&"DisplayMode")="List" then
  276. PAGEBARCOUNT=PAGEBAR_COUNT2
  277. Else
  278. PAGEBARCOUNT=PAGEBAR_COUNT
  279. End If
  280. If intAllPage>PAGEBARCOUNT Then
  281. a=intNowPage
  282. b=intNowPage+PAGEBARCOUNT
  283. If a>PAGEBARCOUNT Then a=a-1:b=b-1
  284. If b>intAllPage Then b=intAllPage:a=intAllPage-PAGEBARCOUNT
  285. If a<=0 Then a=1
  286. If a>intAllPage Then a=1
  287. Else
  288. a=1:b=intAllPage
  289. End If
  290. For i=a to b
  291.             txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page="& i )
  292. txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>",i)
  293. s=s+ txtcontent2
  294. Next
  295. strPageBar=strPageBar+s
  296. txtcontent2=Replace(txtcontent,"<#pagebar/page/url#>","?"& t &"page=" & intAllPage)
  297. txtcontent2=Replace(txtcontent2,"<#pagebar/page/number#>","&gt;&gt;")
  298. strPageBar=strPageBar+ txtcontent2
  299. End If
  300. ExportBar=strPageBar
  301. End Function
  302. Function Formattimea(Stime)
  303. If isdate(Stime) then
  304. Formattimea=formatdatetime(Stime,2)&" "&formatdatetime(Stime,4)
  305. end if
  306. End Function
  307. Function ExportAdd_Xml()
  308.         If not isempty(Application(SessionStr&"TemplateAdd_Xml")) then       
  309. Application.Lock
  310. ExportAdd_Xml1=Application(SessionStr&"TemplateAdd_Xml")
  311. Application.UnLock
  312. Else
  313. ExportAdd_Xml1=ReadfileByStream("TEMPLATE/"&TFolder&"/Add_xml.html")  
  314. Application.Lock
  315. Application(SessionStr&"TemplateAdd_Xml")=ExportAdd_Xml1
  316. Application.UnLock
  317. End If
  318. ExportAdd_Xml=ExportAdd_Xml1
  319. End Function
  320. Function ExportSearchForm()
  321.         If not isempty(Application(SessionStr&"TemplateSearchForm")) then
  322.         
  323. Application.Lock
  324. ExportSearchForm1=Application(SessionStr&"TemplateSearchForm")
  325. Application.UnLock
  326. Else
  327. ExportSearchForm1=ReadfileByStream("TEMPLATE/"&TFolder&"/Search.html")  
  328. Application.Lock
  329. Application(SessionStr&"TemplateSearchForm")=ExportSearchForm1
  330. Application.UnLock
  331. End If
  332. Response.write ReplaceStr(ExportSearchForm1,"<!--MARK2-->(s*|.*?)*<!--MARK3-->","")
  333. SearchTable 2,""
  334. Response.write ReplaceStr(ExportSearchForm1,"<!--MARK1-->(s*|.*?)*<!--MARK2-->","")
  335. End Function
  336. Function ExportCatelog()
  337.         If not isempty(Application(SessionStr&"Catelog")) then
  338.         Application.Lock
  339. ExportCatelog=Application(SessionStr&"Catelog")
  340. Application.UnLock
  341. Else            
  342. If not isempty(Application(SessionStr&"TemplateCatelog1")) then
  343.             catelog1=Application(SessionStr&"TemplateCatelog1")
  344. catelog2=Application(SessionStr&"TemplateCatelog2")
  345. Else
  346. catelog1=ReadfileByStream("TEMPLATE/"&TFolder&"/catelog1.html")
  347. catelog2=ReadfileByStream("TEMPLATE/"&TFolder&"/catelog2.html")
  348. Application.Lock
  349. Application(SessionStr&"TemplateCatelog1")=catelog1
  350. Application(SessionStr&"TemplateCatelog2")=catelog2
  351. Application.UnLock
  352. End If
  353.             set conn=connectdb()
  354. Set objRS=Server.CreateObject("ADODB.Recordset")
  355. objRS.CursorType = 1
  356. objRS.LockType = 1
  357. objRS.ActiveConnection=conn
  358. objRS.Source="SELECT * FROM [Category] WHERE [Category_ParentID]=0  ORDER BY [Category_Order] ASC,[Category_ID] ASC"
  359. objRS.Open()
  360. If (Not objRS.bof) And (Not objRS.eof) Then
  361. For i=1 to objRS.recordcount
  362.                 catelog1_1=Replace(catelog1,"<#CatelogID#>",objRS("Category_ID"))
  363. catelog1_1=Replace(catelog1_1,"<#CatelogName#>",objRS("Category_Name"))
  364. catelog1_1=Replace(catelog1_1,"<#CatelogArticleNumber#>",ArticleInCate(objRS("Category_ID"),conn))
  365. catelog1_1=Replace(catelog1_1,"<#CatelogIntro#>",objRS("Category_Intro"))
  366.       catelog1_1=Replace(catelog1_1,"<#SiteListOrder#>",SiteListOrder)
  367.   catelog1_1=Replace(catelog1_1,"<#SiteListLeftNumber#>",SiteListLeftNumber)
  368.                 
  369. cache_category=cache_category & catelog1_1
  370. '如果有二级分类,显示!
  371. set rs1=conn.execute ("SELECT * FROM [Category] WHERE [Category_ParentID]="&objRS("Category_ID")&"  ORDER BY [Category_Order] ASC,[Category_ID] ASC")
  372. while not rs1.eof
  373. catelog2_1=Replace(catelog2,"<#CatelogID#>",rs1("Category_ID"))
  374. catelog2_1=Replace(catelog2_1,"<#CatelogName#>",rs1("Category_Name"))
  375. catelog2_1=Replace(catelog2_1,"<#CatelogArticleNumber#>",ArticleInCate(rs1("Category_ID"),conn))
  376. catelog2_1=Replace(catelog2_1,"<#CatelogIntro#>",rs1("Category_Intro"))
  377. catelog2_1=Replace(catelog2_1,"<#SiteListOrder#>",SiteListOrder)
  378.     catelog2_1=Replace(catelog2_1,"<#SiteListLeftNumber#>",SiteListLeftNumber)
  379.                     cache_category=cache_category & catelog2_1
  380. rs1.movenext
  381. wend
  382. rs1.close:set rs1=nothing
  383. objRS.MoveNext
  384. If objRS.eof Then Exit For
  385. Next
  386. End If
  387. objRS.Close
  388. Set objRS=Nothing
  389. CloseDb(conn)
  390. ExportCatelog=cache_category
  391.     
  392. Application.Lock
  393. Application(SessionStr&"Catelog")=cache_category
  394. Application.UnLock
  395. End If
  396. End Function
  397. Function ArticleInCate(ID,conn)
  398.     Set OBJRS1=Server.CreateObject("ADODB.Recordset")
  399. OBJRS1.CursorType = 1
  400. OBJRS1.LockType = 1
  401. OBJRS1.ActiveConnection=conn
  402. OBJRS1.Source="SELECT * FROM [Article] WHERE [Category_ID]="&ID
  403. OBJRS1.Open()
  404. If OBJRS1.recordcount=0 then
  405. ArticleInCate=0
  406. else
  407. ArticleInCate=OBJRS1.recordcount
  408. end if
  409. OBJRS1.close
  410. set OBJRS1=nothing
  411. End Function
  412. Function FilterSQL2(strSQL)
  413.     If not isnull(strSQL) then
  414. FilterSQL2=CStr(Replace(strSQL,chr(39),chr(39)&chr(39)))
  415. end if
  416. End Function
  417. Function ReplaceStr(source,para,str)
  418.   Set objRegExp=New RegExp
  419.   objRegExp.IgnoreCase =True
  420.   objRegExp.Global=True
  421.   objRegExp.Pattern=para
  422.   ReplaceStr= objRegExp.Replace(source,str)
  423.   Set objRegExp=Nothing
  424. End Function
  425. function validate_string(input) 
  426. known_bad=array("select","insert","update","delete","drop","—","'",";","#") 
  427. validate_string=true 
  428. for i=lbound(known_bad) to ubound(known_bad) 
  429. if(instr(1,input,known_bad(i),vbtextcompare)<>0) then 
  430. validate_string=false 
  431. exit function 
  432. end if 
  433. next 
  434. end function 
  435. %>