<% Response.Charset="UTF-8"%>
<!--#include file="../manager/conn.asp"-->
<%
Function iGetType(Tid)
	Set RsGet=Server.CreateObject("Adodb.Recordset")
	sql="select * from UsCMSType Where Typeid="&Tid
	RsGet.open sql,conn,1,1
	iGetType=RsGet("TypeTitle")
	RsGet.close
	Set RsGet=Nothing
	Response.write iGetType
End Function


Function PreviewIndex
         PreviewIndex=Openfile(Server.MapPath("../"&GetConfigs(6)&"/default/Youindex.htm"))
		 PreviewIndex=indexs(PreviewIndex,1,"default")
		 WhileStart=split(PreviewIndex,"{us:Type}")
		   if ubound(WhileStart)=1 then
		     WhileEnd=split(WhileStart(1),"{/us}")
			 if ubound(WhileEnd)=1 then
			   TypeArr=WhileEnd(0)
			   set rs=server.CreateObject("adodb.recordset")
			   sql="select * from UsCMSType order by TypeSN asc"
			   rs.open sql,conn,1,1
			   do while not rs.eof
			     page=""
				 artdate=""
				 TypeArrs=replace(TypeArr,"{us:Typeid}","../"&Rs("TypeDir"))	  
				 TypeArrs=replace(TypeArrs,"{us:Typetitle}",rs("TypeTitle"))
				 typex=rs("typex")
				 Typeid=rs("Typeid")
				 Typexid=rs("Typexid")
				 str = TypeArrs
				 k = InStr(str, "{uspage:")
				 i = InStr(k, str, "}")
				 B = replace(Trim(Mid(str, k + 8, i - k - 8)),"<","")
				 pages=left(page,B)
				 set rs1=server.CreateObject("adodb.recordset")
				 sql1="select top 5 * from UsCMSArticle where ArticleDisplay=true And ArticleTypexid="&Typeid&" order by Articleid desc"
				 rs1.open sql1,conn,1,1
				 do while not rs1.eof
				   artdate=artdate&Rs1("ArticleAddDate")&"<br>"
				   if rs1("ArticleBuild")=0 then
				   page=page&"<a href='../../plus/View.asp?aid="&rs1("Articleid")&"'><font color="&rs1("ArticleColor")&">"&left(rs1("articletitle"),B)&"</font></a><br>"		 			
				   else
				   page=page&"<a href='../"&rs1("ArticleDir")&"'><font color="&rs1("ArticleColor")&">"&left(rs1("articletitle"),B)&"</font></a><br>"
				   end if
				 rs1.movenext
				 loop
				 rs1.close
				 set rs1=nothing
				 TypeArrs=replace(TypeArrs,"{uspage:"&B&"}",page)
				 TypeArrs=replace(TypeArrs,"{uspage:date}",artdate)	 
				 TypeArr2=TypeArr2&TypeArrs
			   rs.movenext
			   loop
			   rs.close
			   set rs=nothing	
			   PreviewIndex=WhileStart(0)&TypeArr2&WhileEnd(1)
			   PreviewIndex=Replace(PreviewIndex,"{us:ver}",Ver)
			 end if
		   end if  
		 createfiles server.MapPath("../index.htm"),PreviewIndex
End Function

Function indexs(str,str2,str3)
  SiteConfig=openfile(server.MapPath("../manager/site/config.asp"))
  SiteArr=split(SiteConfig,chr(13))
   sitename=SiteArr(0)
    siteurl=SiteArr(1)
    sitekey=SiteArr(2)
    sitedis=SiteArr(3)
   siteinfo=SiteArr(4)
   webhtml=SiteArr(5)
   webtemp=SiteArr(6)
  str=replace(str,"{us:sitename}",sitename)
  str=replace(str,"{us:siteurl}",siteurl)
  str=replace(str,"{us:sitekey}",sitekey)
  str=replace(str,"{us:sitedis}",sitedis)
  str=replace(str,"{us:siteinfo}",siteinfo)
  str=replace(str,"{us:global webhtml}",webhtml)
  str=replace(str,"{us:sitetemp}","../"&webtemp&"/"&str3)    

  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
  top_list=top_list&"<li><a href='"&rstop("TypeDir")&"' >"&rstop("TypeTitle")&"</a></li>"  
   rstop.movenext
  loop
  rstop.close
  set rstop=nothing
  str=replace(str,"{us:TopMenu}",top_list)
  
  set rs=server.CreateObject("adodb.recordset")
  sql="select * from UsCMSLink where SiteDisplay=True And isdel=false order by Siteid asc"
  rs.open sql,conn,1,1
  do while not rs.eof

  sitelink=sitelink&" <a href='"&rs("siteurl")&"' >"&rs("sitetitle")&"</a>"  
   rs.movenext
  loop
  rs.close
  set rs=nothing
  str=replace(str,"{us:sitelink}",sitelink)  
  
  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
  if rs(5)="0" then
  hot=hot&"<a href=../plus/view.asp?aid="&rs(0)&">"&rs("ArticleTitle")&"</a><br>"
  else
  hot=hot&"<a href="&rs("ArticleDir")&">"&rs("ArticleTitle")&"</a><br>"
  end if  
  rs.movenext
  loop
  rs.close
  set rs=nothing
  str=replace(str,"{us:hot}",hot)

  set rs=server.CreateObject("adodb.recordset")
  sql="select top 10 * from UsCMSArticle where  ArticleDisplay=True order by Articleid desc"
  rs.open sql,conn,1,1
  do while not rs.eof
  if rs(5)="0" then
  news=news&"<a href=../plus/view.asp?aid="&rs(0)&">"&rs("ArticleTitle")&"</a><br>"
  else
  news=news&"<a href="&rs("ArticleDir")&">"&rs("ArticleTitle")&"</a><br>"
  end if  
  rs.movenext
  loop
  rs.close
  set rs=nothing
  str=replace(str,"{us:new}",news)

  set rs=server.CreateObject("adodb.recordset")
  sql="select top 10 * from UsCMSArticle where ArticleRecommend=True order by Articleid desc"
  rs.open sql,conn,1,1
  do while not rs.eof
  if rs(5)="0" then
  Recommend=Recommend&"<a href=../plus/view.asp?aid="&rs(0)&">"&rs("ArticleTitle")&"</a><br>"
  else
  Recommend=Recommend&"<a href="&rs("ArticleDir")&">"&rs("ArticleTitle")&"</a><br>"
  end if  
  rs.movenext
  loop
  rs.close
  set rs=nothing
  str=replace(str,"{us:recommend}",Recommend)  
  
  
  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

  hotdate=hotdate&rs("ArticleAddDate")&"<br>"

  rs.movenext
  loop
  rs.close
  set rs=nothing
  str=replace(str,"{us:hotdate}",hotdate)   

  set rs=server.CreateObject("adodb.recordset")
  sql="select top 10 * from UsCMSArticle where  ArticleDisplay=True order by Articleid desc"
  rs.open sql,conn,1,1
  do while not rs.eof

  newdate=newdate&rs("ArticleAddDate")&"<br>"

  rs.movenext
  loop
  rs.close
  set rs=nothing
  str=replace(str,"{us:newdate}",newdate)  
  
  set rs=server.CreateObject("adodb.recordset")
  sql="select top 10 * from UsCMSArticle where  ArticleRecommend=True order by Articleid desc"
  rs.open sql,conn,1,1
  do while not rs.eof

  Recommenddate=Recommenddate&rs("ArticleAddDate")&"<br>"

  rs.movenext
  loop
  rs.close
  set rs=nothing
  str=replace(str,"{us:recommenddate}",Recommenddate)   

  str=replace(str,"{us:ver}",ver)   
  	  
  indexs=str
End Function

function Gettemp()
  set fso=server.CreateObject("scripting.filesystemobject")
  set ff=fso.getfolder(server.MapPath("../"&GetConfigs(6)))
  set openfs=ff.subfolders
  for each openf in openfs
  Gettemp=Gettemp&"<option value='"&openf.name&"'>"&openf.name&"</option>"
  next
  set fso=nothing
  set ff=nothing
  set openfs=nothing
end function

Function PreviewType(Typeid)

  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSType Where Typeid="&Typeid
    Rs.open Sql,Conn,1,1
      If Not Rs.Eof Then
		Page2=Rs.PageCount
		Dir=Rs("TypeDIr")
		IF Rs("Typex")="1" then
		  TypeNav="<a href='../"&rs("TypeDir")&"'>"&rs("TypeTitle")&"</a>"
          TypeUrl="../"&GetConfigs(6)&"/"&rs("TypeTemp")&"/"&rs("TypeIndex")
		  Preview=1		  
		Else
		  Set Rs1=Server.CreateObject("Adodb.Recordset")
		  Sql1="select * from UsCMSType where Typeid="&rs("Typexid")
			Rs1.Open Sql1,Conn,1,1
			  If Not Rs1.Eof Then
			    TypeNav="<a href='../../"&rs1("TypeDir")&"'>"&rs1("TypeTitle")&"</a>>"
			  End If
  			Rs1.Close
		  Set Rs1=Nothing
          TypeNav=TypeNav&"<a href='../../"&rs("TypeDir")&"'>"&rs("TypeTitle")&"</a>"
          TypeUrl="../"&GetConfigs(6)&"/"&rs("TypeTemp")&"/"&rs("TypeList")
		  Preview=2		  				
		End if

 		  PreviewType=Openfile(Server.MapPath(TypeUrl))
		  
          PreviewType=globals(PreviewType,Preview,rs("TypeTemp"))	
		  	
	  	  PreviewType=replace(PreviewType,"{us:TypeNav}",TypeNav)
	   	  PreviewType=Replace(PreviewType,"{us:TypeTitle}",rs("TypeTitle"))
		  PreviewType=Replace(PreviewType,"{us:TypeKeyword}",rs("TypeKeyword"))
		  PreviewType=Replace(PreviewType,"{us:TypeDescription}",rs("TypeDescription"))
 		  PreviewType=Replace(PreviewType,"{us:Typeid]}",rs("Typeid"))
	  	  PreviewType=Replace(PreviewType,"{us:TypeDir}",rs("TypeDir"))	
      Else
		  Response.Write("错误2")  
	  End If
    Rs.Close
  Set Rs=Nothing

  set rs=server.CreateObject("adodb.recordset")
  sql="select top 10 * from UsCMSArticle where  ArticleDisplay=True and ArticleTypeid="&Typeid&" order by ArticleCount desc"
  rs.open sql,conn,1,1
  do while not rs.eof
  if rs(5)="0" then
  hot=hot&"<a href=../../../plus/view.asp?aid="&rs(0)&">"&rs("ArticleTitle")&"</a><br>"
  else
  hot=hot&"<a href=../../"&rs("ArticleDir")&">"&rs("ArticleTitle")&"</a><br>"
  end if  
  rs.movenext
  loop
  rs.close
  set rs=nothing
  PreviewType=replace(PreviewType,"{us:hot}",hot)
    

 if Preview=1 Then

  WhileStart=split(PreviewType,"{us:Type}")
    if ubound(WhileStart)=1 then
	  WhileEnd=split(WhileStart(1),"{/us}")
	if ubound(WhileEnd)=1 then
	  TypeArr=WhileEnd(0)
	set rs=server.CreateObject("adodb.recordset")
	  sql="select * from UsCMSType where Typexid="&Typeid&" order by TypeSN asc"
	  rs.open sql,conn,1,1
	    do while not rs.eof
		page=""
		artdate=""
	    TypeArrs=replace(TypeArr,"{us:Typeid}","../"&Rs("TypeDir"))	  
  	    TypeArrs=replace(TypeArrs,"{us:Typetitle}",rs("TypeTitle"))
		typex=rs("typex")
		Typeid=rs("Typeid")
		Typexid=rs("Typexid")
		str = TypeArrs
        k = InStr(str, "{uspage:")
        i = InStr(k, str, "}")
        B = replace(Trim(Mid(str, k + 8, i - k - 8)),"<","")
		pages=left(page,B)		
        set rs1=server.CreateObject("adodb.recordset")
	    sql1="select top 10 * from UsCMSArticle where ArticleDisplay=true And ArticleTypexid="&Typeid&" order by Articleid desc"
	      rs1.open sql1,conn,1,1
	      do while not rs1.eof
		    artdate=artdate&Rs1("ArticleAddDate")&"<br>"
			if rs1("ArticleBuild")=0 then
			page=page&"<a href='../../plus/View.asp?aid="&rs1("Articleid")&"'><font color="&rs1("ArticleColor")&">"&left(rs1("articletitle"),B)&"</font></a><br>"		 			
			else
			page=page&"<a href='../"&rs1("ArticleDir")&"'><font color="&rs1("ArticleColor")&">"&left(rs1("articletitle"),B)&"</font></a><br>"
			end if
		  rs1.movenext
		  loop
		rs1.close
		set rs1=nothing	
				
	    TypeArrs=replace(TypeArrs,"{uspage:"&B&"}",page)
		TypeArrs=replace(TypeArrs,"{uspage:date}",artdate)	 
		TypeArr2=TypeArr2&TypeArrs
	  rs.movenext
	loop
	rs.close
	set rs=nothing	
  	PreviewType=WhileStart(0)&TypeArr2&WhileEnd(1)
	PreviewType=Replace(PreviewType,"{us:ver}",Ver)
    end if 
    end if
	
  Else
  
WhileStart=split(PreviewType,"{us:ArticleList}")
WhileEnd=split(WhileStart(1),"{/us:ArticleList}")
TypeArr=WhileEnd(0)

sql="select * from Uscmsarticle where articletypexid="&Typeid&" and articleDisplay=true order by articleid desc"

set rs=server.createObject("ADODB.Recordset")    
rs.open sql,conn,1,1    
rs.pagesize=10
totalpage=rs.pagecount    
rs.close    
set rs=nothing 	

for j=1 to totalpage    
sql="select * from Uscmsarticle where articletypexid="&Typeid&" and articleDisplay=true  order by articleid desc" 
set rs=server.createObject("ADODB.Recordset")    
rs.open sql,conn,1,1    
   
whichpage=j    
rs.pagesize=10
totalpage=rs.pagecount    
rs.absolutepage=whichpage    
howmanyrecs=0    
str0=""   
do while not rs.eof and howmanyrecs<rs.pagesize    
if rs(5)="0" then
url="../../../plus/view.asp?aid="&rs(0)
else
url="../../"&rs(5)
end if
str0=str0&replace(replace(replace(replace(replace(TypeArr,"{us:ArticleTitle}",rs(1)),"{us:ArticleInfo}",rs(0)),"{us:ArticleDescription}",left(rs(3),150)),"{[us:ArticleUrl}",url),"{us:ArticleAddDate}",rs(6))
rs.movenext    
howmanyrecs=howmanyrecs+1    
loop    
rs.close    
set rs=nothing    
PreviewType= WhileStart(0)&str0&WhileEnd(1)
page=""
for counter=1 to totalpage   
if counter=1 then
page=page&"<a href=index.htm>["&counter&"]</a>"   
else 
page=page&"<a href=index_"&counter&".htm>["&counter&"]</a>"   
end if
page=page& " "   
if counter mod 10 = 0 then    
page=page& "<br>"   
end if    
next
	PreviewType=Replace(PreviewType,"{us:ArticlePage}",page)
	PreviewType=Replace(PreviewType,"{us:ver}",Ver)	
if j=1 then
 createfiles server.MapPath(Dir&"/index.htm"),PreviewType
else
 createfiles server.MapPath(Dir&"/index_"&j&".htm"),PreviewType
end if
next
  End if  
   
End function


Function PreviewArticle(Articleid,Typeid,ArticleDir)
  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

	  strTemp=openfile(server.MapPath(TypeArticle))
	    if typex=1 then
		  strTemp=globals(strTemp,1,rs("TypeTemp"))
		else
		  strTemp=globals(strTemp,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")
		  ArticleSN=Rs("ArticleSN")	  
		  Articlex=Rs("Articlex")		  
		  sArticleTitle=Rs("ArticleTitle")
		  sArticleDescription=Rs("ArticleDescription")
		  sArticleKeyword=Rs("ArticleKeyword")
		  sArticleDescription=Rs("ArticleDescription")
		  sArticleAuthor=Rs("ArticleAuthor")
		  sArticleAddDate=Rs("ArticleAddDate")
		  sArticleid=Rs("Articleid")
		  sArticleFrom=Rs("ArticleFrom")
		  If Rs("Articlex")=1 Then
		  Typeid=Rs("ArticleTypeid")
		  Else
		  Typeid=Rs("ArticleTypexid")
		  End if
		Else
		  Response.Write("错误")  
		End If
	  Rs.Close
  Set Rs=Nothing


  if Instr(ArticleContent,"<p>#uspage#</p>") then
		arrcontent=split(ArticleContent,"<p>#uspage#</p>")
		InnerPageNum=ubound(arrcontent)

		pagelist=" "
		for rollnum=0 to InnerPageNum
	     f=Right(ArticleDir,   Len(ArticleDir)-InStrRev(ArticleDir,"/"))   
		 f=left(f,instrrev(f,".")-1)
		  if rollnum=0 then
			f=f&".html"	
			  else
			f=f&"_"&(rollnum+1)&".html"	
			end if		
		  pagelist=pagelist & "<a href="&f&">["&(rollnum+1)&"]</a> "
		next

	

		for rollnum=0 to InnerPageNum
		
		  PreviewArticle=strTemp
		  ArticleContent=arrcontent(rollnum)


         set rsstr=server.CreateObject("adodb.recordset")
		  sqlstr="select * from UsCMSKeyword"
		  rsstr.open sqlstr,conn,1,1
		  do while not rsstr.eof
		  str1=rsstr("KeywordTitle")
		  str2="<a href="&rsstr("KeywordUrl")&">"&str1&"</a>"
		  ArticleContent=replace(ArticleContent,str1,str2)
		  rsstr.movenext
		  loop

 	      PreviewArticle=Replace(PreviewArticle,"{us:ArticleContent}",ArticleContent&"<br><center>分页："&pagelist&"</center>")
	      PreviewArticle=Replace(PreviewArticle,"{us:ArticleTitle}",sArticleTitle)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleDescription}",sArticleDescription)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleKeyword}",sArticleKeyword)	
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleDescription}",sArticleDescription)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleAuthor}",sArticleAuthor)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleAddDate}",sArticleAddDate)
	      PreviewArticle=Replace(PreviewArticle,"{us:Articleid}",sArticleid)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleFrom}",sArticleFrom)	
		  Fnames=left(ArticleDir,instrrev(ArticleDir,".")-1) 
		  if rollnum=0 then
			Fname=Fnames&".html"	
			  else
			Fname=Fnames&"_"&(rollnum+1)&".html"	
     	  end if	
			
	  
  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSArticle Where ArticleDisplay=true And ArticleTypexid="&Typeid&" And ArticleSn="&ArticleSN+1
      Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then	  
		  if rs("ArticleBuild")=0 Then
		    If Articlex=1 then
	  	    PreviewArticle=Replace(PreviewArticle,"{us:next}","<a href='../../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")			
			else
	  	    PreviewArticle=Replace(PreviewArticle,"{us:next}","<a href='../../../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")
		    End if
		  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 ArticleDisplay=true And ArticleTypexid="&Typeid&" And ArticleSn="&ArticleSN-1

      Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then	  
		  if rs("ArticleBuild")=0 Then
		    If Articlex=1 then
	  	    PreviewArticle=Replace(PreviewArticle,"{us:prev}","<a href='../../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")			
			else
	  	    PreviewArticle=Replace(PreviewArticle,"{us:prev}","<a href='../../../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")
		    End if
		  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>"&left(rs("ArticleTitle"),15)&"</li>"
		rs.movenext
		loop
      rs.close
  set rs=nothing
  PreviewArticle=replace(PreviewArticle,"{us:hot}",hot)	  
  PreviewArticle=Replace(PreviewArticle,"{us:ver}","UsCMS"&Ver)	
  createfiles server.MapPath(Fname),PreviewArticle		  

    next	
  else
		  PreviewArticle=strTemp
         set rsstr=server.CreateObject("adodb.recordset")
		  sqlstr="select * from UsCMSKeyword"
		  rsstr.open sqlstr,conn,1,1
		  do while not rsstr.eof
		  str1=rsstr("KeywordTitle")
		  str2="<a style='text-decoration: underline;' href="&rsstr("KeywordUrl")&">"&str1&"</a>"
		  ArticleContent=replace(ArticleContent,str1,str2)
		  rsstr.movenext
		  loop

 	      PreviewArticle=Replace(PreviewArticle,"{us:ArticleContent}",ArticleContent)
	      PreviewArticle=Replace(PreviewArticle,"{us:ArticleTitle}",sArticleTitle)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleDescription}",sArticleDescription)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleKeyword}",sArticleKeyword)	
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleDescription}",sArticleDescription)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleAuthor}",sArticleAuthor)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleAddDate}",sArticleAddDate)
	      PreviewArticle=Replace(PreviewArticle,"{us:Articleid}",sArticleid)
	  	  PreviewArticle=Replace(PreviewArticle,"{us:ArticleFrom}",sArticleFrom)  
  Set Rs=Server.CreateObject("Adodb.Recordset")
    Sql="Select * From UsCMSArticle Where ArticleDisplay=true And ArticleTypexid="&Typeid&" And ArticleSn="&ArticleSN+1
      Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then	  
		  if rs("ArticleBuild")=0 Then
		    If Articlex=1 then
	  	    PreviewArticle=Replace(PreviewArticle,"{us:next}","<a href='../../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")			
			else
	  	    PreviewArticle=Replace(PreviewArticle,"{us:next}","<a href='../../../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")
		    End if
		  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 ArticleDisplay=true And ArticleTypexid="&Typeid&" And ArticleSn="&ArticleSN-1

      Rs.Open Sql,Conn,1,1
	    If Not Rs.Eof Then	  
		  if rs("ArticleBuild")=0 Then
		    If Articlex=1 then
	  	    PreviewArticle=Replace(PreviewArticle,"{us:prev}","<a href='../../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")			
			else
	  	    PreviewArticle=Replace(PreviewArticle,"{us:prev}","<a href='../../../plus/View.asp?aid="&Rs("Articleid")&"'>"&Rs("ArticleTitle")&"</a>")
		    End if
		  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>"&left(rs("ArticleTitle"),15)&"</li>"
		rs.movenext
		loop
      rs.close
  set rs=nothing
  PreviewArticle=replace(PreviewArticle,"{us:hot}",hot)
  PreviewArticle=Replace(PreviewArticle,"{us:ver}",Ver)
  createfiles server.MapPath(ArticleDir),PreviewArticle	
  end if
		
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"))
str=split(str,chr(13))
GetConfigs=str(num)
End Function

If Request.QueryString("Action")="PreviewType" Then

  Typeid=Funstr(Request.QueryString("Typeid"))
  IsDir=Request.QueryString("IsDir")
  TypeDir="../"&GetConfigs(5)&"/"&Request.QueryString("TypeDir") 
  Set Rs=Server.CreateObject("Adodb.Recordset")
    If IsDir=0 Then
      Sql="Select top 1 * from UsCMSType where Typeid="&Typeid
    Else
      Sql="Select top 1 * from UsCMSType where TypeDir='"&TypeDir&"'"
    End if	
    Rs.Open Sql,Conn,1,1
	  If Not Rs.Eof Then
        Typeid=rs("Typeid")
    Rs.Close
  Set Rs=nothing
	    Response.Write PreviewType(Typeid)
	  Else
		Response.write "没有这个分类"	
	  End If
End if

If Request.QueryString("Action")="PreviewType2" Then
  Typeid=Funstr(Request.QueryString("Typeid"))
  IsDir=Request.QueryString("IsDir")
  TypeDir="../"&GetConfigs(5)&"/"&Request.QueryString("TypeDir") 
  
  Set Rs=Server.CreateObject("Adodb.Recordset")
    If IsDir=0 Then
      Sql="Select top 1 * from UsCMSType where Typeid="&Typeid
    Else
      Sql="Select top 1 * from UsCMSType where TypeDir='"&TypeDir&"'"
    End if	
    Rs.Open Sql,Conn,1,1
	  If Not Rs.Eof Then
        Typeid=rs("Typeid")
    Rs.Close
  Set Rs=nothing
	    Response.Write PreviewType(Typeid)
	  Else
		Response.write "OK"	
	  End If
End if

if Request.QueryString("Action")="PreviewOnePage" then
  Pageid=Funstr(Request.QueryString("Pageid"))
    Set Rs=Server.CreateObject("Adodb.Recordset")
      Sql="select top 1 * from UsCMSOnePage where Pageid="&Pageid
        Rs.Open Sql,Conn,1,1
    	  Pageid=Rs("Pageid")
		  PageUrls=Rs("PageUrl")
  		Rs.close
  	set Rs=Nothing
	Response.Write "<div class=list><table width='100%'><tr><th>预览页面</th></tr><tr><td>"
	Response.Write PreviewOnePage(Pageid)
	Response.Write "</td></tr></table></div>" 
End if



Function globals(str,str2,str3)
  SiteConfig=openfile(server.MapPath("../manager/site/config.asp"))
  SiteArr=split(SiteConfig,chr(13))
   sitename=SiteArr(0)
    siteurl=SiteArr(1)
    sitekey=SiteArr(2)
    sitedis=SiteArr(3)
   siteinfo=SiteArr(4)
   webhtml=SiteArr(5)
   webtemp=SiteArr(6)
  str=replace(str,"{us:sitename}",sitename)
  str=replace(str,"{us:siteurl}",siteurl)
  str=replace(str,"{us:sitekey}",sitekey)
  str=replace(str,"{us:sitedis}",sitedis)
  str=replace(str,"{us:siteinfo}",siteinfo)
  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
%>
