<% Response.Charset="UTF-8"%>
<!--#include file="conn.asp"-->
<%
if Request.QueryString("action")="w" then
strs= "../"&request.QueryString("str")&".html"
    Set Rs=Server.CreateObject("Adodb.Recordset")
      Sql="select * from UsCMSArticle where ArticleDir='"&strs&"'"
        Rs.Open Sql,Conn,1,1
		
	    If Not Rs.Eof Then
    	  Articlex=Rs("Articlex")
		  Articleid=Rs("Articleid")
		  If Aritclex=1 Then
		   Typeid=Rs("ArticleTypeid")
		  Else
		   Typeid=Rs("ArticleTypexid")	  
		  End If		  
  		Rs.close
  	set Rs=Nothing
	Response.Write PreviewArticle(Articleid,Typeid)	
	    Else
		Response.write "没有这篇文章"	
	  End If
End if

if Request.QueryString("aid")<>"" then
if IsNumeric(Request.QueryString("aid")) then
  Articleid=Funstr(Request.QueryString("aid"))
    Set Rs=Server.CreateObject("Adodb.Recordset")
      Sql="select * from UsCMSArticle where Articleid="&Articleid
        Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then
    	  Articlex=Rs("Articlex")
		  If Aritclex=1 Then
		   Typeid=Rs("ArticleTypeid")
		  Else
		   Typeid=Rs("ArticleTypexid")	  
		  End If		  
  		Rs.close
  	set Rs=Nothing
	Response.Write PreviewArticle(Articleid,Typeid)	
	    Else
		Response.write "没有这篇文章"	
	  End If
End if
End if

Function PreviewArticle(Articleid,Typeid)
  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSType Where Typeid="&Typeid
      Rs.Open Sql,Conn,1,1
	  TypeArticle=Rs("TypeArticle")
	  Typex=Rs("Typex")	  

  TypeArticle="../"&GetConfigs(6)&"/"&rs("TypeTemp")&"/"&TypeArticle
  PreviewArticle=openfile(server.MapPath(TypeArticle))
  if typex=1 then
  PreviewArticle=globals(PreviewArticle,1,rs("TypeTemp"))	  
  else
  PreviewArticle=globals(PreviewArticle,2,rs("TypeTemp"))	 
  end if   
  

	  Rs.Close
  Set Rs=Nothing

  
  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSArticle Where Articleid="&Articleid
      Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then
		
			      ArticleContent=Rs("ArticleContent")	
  set rsstr=server.CreateObject("adodb.recordset")
  sqlstr="select * from UsCMSKeyword order by Keywordid desc"
  rsstr.open sqlstr,conn,1,1
  do while not rsstr.eof
    str1=rsstr("KeywordTitle")
	str2="<a href="&rsstr("KeywordUrl")&">"&str1&"</a>"
   'ArticleContent=replace(Replace(ArticleContent,str1,str1,1,-1,1),str1,str2)
ArticleContent=replace(ArticleContent,str1,str2)   

  rsstr.movenext
  loop
  rsstr.close
  set rsstr=nothing		
		

	      PreviewArticle=Replace(PreviewArticle,"{us:ArticleTitle}",Rs("ArticleTitle"))
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleDescription}",Rs("ArticleDescription"))
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleContent}",ArticleContent)	
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleKeyword}",Rs("ArticleKeyword"))	
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleDescription}",Rs("ArticleDescription"))
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleAuthor}",Rs("ArticleAuthor"))
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleAddDate}",Rs("ArticleAddDate"))
	      PreviewArticle=Replace(PreviewArticle,"{us:Articleid}",Rs("Articleid"))
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleFrom}",Rs("ArticleFrom"))	
		  ArticleSN=Rs("ArticleSN")	  
		  Articlex=Rs("Articlex")
			
		  If Rs("Articlex")=1 Then
		  Typeid=Rs("ArticleTypeid")
		  Else
		  Typeid=Rs("ArticleTypexid")
		  End if
		Else
		  Response.Write("错误")  
		End If
	  Rs.Close
  Set Rs=Nothing


  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSArticle Where ArticleTypexid="&Typeid&" And ArticleSn="&ArticleSN+1
      Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then	  
		  if rs("ArticleBuild")=0 Then
	  	  PreviewArticle=Replace(PreviewArticle,"{us:next}","<a href='../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")
		  else
		   If Articlex=1 then
	  	  PreviewArticle=Replace(PreviewArticle,"{us:next}","<a href='"&Rs("Articledir")&"'>"&Rs("ArticleTitle")&"</a>")
		    else
	  	  PreviewArticle=Replace(PreviewArticle,"{us:next}","<a href='"&Rs("Articledir")&"'>"&Rs("ArticleTitle")&"</a>")			
		    End if
		  end if
		Else
	  	  PreviewArticle=Replace(PreviewArticle,"{us:next}","没有了")		
		End if
	  Rs.Close
  Set Rs=Nothing	
 
  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSArticle Where ArticleTypexid="&Typeid&" And ArticleSn="&ArticleSN-1

      Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then	  
		  if rs("ArticleBuild")=0 Then
	  	  PreviewArticle=Replace(PreviewArticle,"{us:prev}","<a href='../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")
		  else
		   If Articlex=1 then
	  	  PreviewArticle=Replace(PreviewArticle,"{us:prev}","<a href='"&Rs("Articledir")&"'>"&Rs("ArticleTitle")&"</a>")
		    else
	  	  PreviewArticle=Replace(PreviewArticle,"{us:prev}","<a href='"&Rs("Articledir")&"'>"&Rs("ArticleTitle")&"</a>")			
		    End if
		  end if
		Else
	  	  PreviewArticle=Replace(PreviewArticle,"{us:prev}","没有了")		
		End if
	  Rs.Close
  Set Rs=Nothing	
      
  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSType Where Typeid="&Typeid
      Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then
		  If Articlex=1 then
	  	  PreviewArticle=Replace(PreviewArticle,"{us:TypeNav}","<a href="&Rs("TypeDIr")&">"&Rs("TypeTitle")&"</a>")			
		  Else
	  	  PreviewArticle=Replace(PreviewArticle,"{us:TypeNav}","<a href="&Rs("TypeDIr")&">"&Rs("TypeTitle")&"</a>")					  
		  End if
		ELse
		  Response.Write("错误") 		
		End if
	  Rs.Close
  Set Rs=Nothing


  set rs=server.CreateObject("adodb.recordset")
  sqlvip="select top 10 * from UsCMSArticle where ArticleRecommend=true and ArticleDisplay=true order by Articleid desc"
  rs.open sqlvip,conn,1,1
  do while not rs.eof
  vip=vip&"<li>"&rs("ArticleTitle")&"</li>"
  rs.movenext
  loop
  rs.close
  set rs=nothing
  PreviewArticle=replace(PreviewArticle,"{us:vip}",vip)	


  set rs=server.CreateObject("adodb.recordset")
  sql="select top 10 * from UsCMSArticle where ArticleDisplay=true order by ArticleCount desc"  
  rs.open sql,conn,1,1
  do while not rs.eof
  hot=hot&"<li>"&rs("ArticleTitle")&"</li>"
  rs.movenext
  loop
  rs.close
  set rs=nothing
  PreviewArticle=replace(PreviewArticle,"{us:hot}",hot)	  
  

  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSOnePage where PageDisplay=True order by Pageid asc"
      Rs.open Sql,Conn,1,1
	    Do While Not Rs.Eof
          If Rs("PageStatus")="3" Then
		    Footer=Footer&"<a href=/Manager/Preview.asp?Action=Preview&Pageid="&Rs("Pageid")&">"&Rs("PageName")&"</a>"
		  Else
		    if Typex=1 then 
		      Footer=Footer&"<a href='../"&GetConfigs(5)&"/"&Rs("PageUrl")&"' >"&Rs("PageName")&"</a>"  
			else
			  Footer=Footer&"<a href='../"&GetConfigs(5)&"/"&Rs("PageUrl")&"' >"&Rs("PageName")&"</a>"
			end if 
		  End If
		Rs.MoveNext
	  Loop
	Rs.Close
  Set Rs=Nothing
    PreviewArticle=Replace(PreviewArticle,"{us:footer}",Footer)  
    PreviewArticle=Replace(PreviewArticle,"{us:ver}",Ver)	

		
End Function 

if Request.QueryString("action")="PreviewArticle" then
  Articleid=Funstr(Request.QueryString("Articleid"))
    Set Rs=Server.CreateObject("Adodb.Recordset")
      Sql="select * from UsCMSArticle where Articleid="&Articleid
        Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then
    	  Articlex=Rs("Articlex")
		  If Aritclex=1 Then
		   Typeid=Rs("ArticleTypeid")
		  Else
		   Typeid=Rs("ArticleTypexid")	  
		  End If		  
  		Rs.close
  	set Rs=Nothing
	Response.Write PreviewArticle(Articleid,Typeid)	
	    Else
		Response.write "没有这篇文章"	
	  End If
End if


Function GetConfigs(num)
str=openfile(server.MapPath("../Manager/Site/config.asp"))
web=split(str,chr(13))
GetConfigs=web(num)

End Function


function globals(str,str2,str3)

webfp=openfile(server.MapPath("../manager/site/config.asp"))
webarr=split(webfp,chr(13))
webname=webarr(0)
weburl=webarr(1)
webkey=webarr(2)
webdis=webarr(3)
webend=webarr(4)
webhtml=webarr(5)
webtemp=webarr(6)
  str=replace(str,"{us:sitename}",webname)
  str=replace(str,"{us:siteurl}",weburl)
  str=replace(str,"{us:sitekey}",webkey)
  str=replace(str,"{us:global webdis}",webdis)
  str=replace(str,"{us:global webend}",webend)
  str=replace(str,"{us:global webhtml}",webhtml)
  

if str2=1 then  
  str=replace(str,"{us:sitetemp}","../"&webtemp&"/"&str3)    
else
  str=replace(str,"{us:sitetemp}","../"&webtemp&"/"&str3)    
end if    

  set rstop=server.CreateObject("adodb.recordset")
  sqltop="select * from UsCMSType where Typexid=0 order by TypeSN asc"
  rstop.open sqltop,conn,1,1
  do while not rstop.eof
  if rstop("TypeBuild")=0 then
  top_list=top_list&"<li><a href='plus/Preview.asp?action=PreviewType&Typeid="&rstop("Typeid")&"' >"&rstop("TypeTitle")&"</a></li>"  

  elseif rstop("TypeBuild")=1 then

  if str2=1 then  
  top_list=top_list&"<li><a href='"&rstop("TypeDir")&"' >"&rstop("TypeTitle")&"</a></li>"  
  else
  top_list=top_list&"<li><a href='"&rstop("TypeDir")&"' >"&rstop("TypeTitle")&"</a></li>"    
  end if
  
  else
  if str2=1 then  
  top_list=top_list&"<li><a href='../../"&rstop("TypeDir")&"' >"&rstop("TypeTitle")&"</a></li>"  
  else
  top_list=top_list&"<li><a href='../../../"&rstop("TypeDir")&"' >"&rstop("TypeTitle")&"</a></li>"    
  end if
  end if
  rstop.movenext
  loop
  rstop.close
  set rstop=nothing
  str=replace(str,"{us:TopMenu}",top_list)
  
    Set RsAd=Server.CreateObject("Adodb.Recordset")
      SqlAd="select * from UsCMSAd"
        RsAd.Open SqlAd,Conn,1,1
		  Do while Not RsAd.eof
		    Ad=AD&"<li>"&RsAd("Adcode")&"</li>"
		  RsAd.MoveNext
		  Loop
		RsAd.Close
    Set RsAd=Nothing  
  str=replace(str,"{us:ad}",Ad)   
  
  
  
if instr(str,"{us:ad ")>0 then 
abctext=split(str,"{us:ad ") 
for j=0 to ubound(abctext) 
next 
end if 

  
  for z=1 to j-1  
        k = InStr(str, "{us:ad ")
        i = InStr(k, str, "}")
        B = replace(Trim(Mid(str, k + 7, i - k - 7)),"<","")

    Set RsAds=Server.CreateObject("Adodb.Recordset")
       SqlAds="select * from UsCMSAd where Adid="&B
        RsAds.Open SqlAds,Conn,1,1
	
		    Ads="<li>"&RsAds("Adcode")&"</li>"
		  
		RsAds.Close
    Set RsAds=Nothing  


  str=replace(str,"{us:ad "&B&"}",Ads) 
	next

   
  globals=str
  
end function


%>