<%
   dim conn   
   dim connstr

   on error resume next
   connstr="DBQ="+server.mappath("database/w163_data.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
   set conn=server.createobject("ADODB.CONNECTION")
   if err then 
      err.clear
   else
        conn.open connstr 
        if err then 
           err.clear
        end if
   end if
%><%
function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function

MaxPerPage=30
Server.ScriptTimeOut=9999999

mingchen=trim(request("mingcheng"))
path=trim(request("path"))
path=Replace(path, """", "")
ClassID=request("ClassID")

response.write ClassID

dim fso,CateRs,rs_8,sql_8,okfile,sql
   Set fso = Server.CreateObject("Scripting.FileSystemObject")
   Set Rs=server.createobject("adodb.recordset")
   Set CateRs=server.createobject("adodb.recordset")
'取模版开始
dim HtmlTemplate

set rs_8 = server.CreateObject ("Adodb.recordset")
sql_8="select * from demo where ifuse=1 and demoid="&request("demoid")
rs_8.open sql_8,conn,1,1
HtmlTemplate=rs_8("demohtml")
rs_8.close


'取整体,头,尾模版
set rs_8 = server.CreateObject ("Adodb.recordset")
sql_8="select * from demo where ifuse=1 and demoid=27"
rs_8.open sql_8,conn,1,1
tophtml=rs_8("demohtml")
tophtml = replace(tophtml,"$gonggao$",gonggao)
tophtml = replace(tophtml,"$webname$",webname)
tophtml = replace(tophtml,"$weburl$",weburl)
		tophtml=replace(tophtml,"images","../images")
		tophtml=replace(tophtml,"href=","href=../")

rs_8.close
class1=class1 & "<TABLE width=100% border=0 id=table1  cellspacing=0 cellpadding=0>"
	class1=class1 & "<tr>"
	class1=class1 & "<td class=td1>"
    class1=class1 & "	 <TABLE align=center cellSpacing=0 cellPadding=0 width=100%  border=0>" 


		dim rss,rs2,ii,i
		set rss = server.CreateObject ("adodb.recordset")
		set rs2 = server.CreateObject ("adodb.recordset")
		sql="select anclassid,anclassidorder,anclass,mingcheng from w163_sort order by anclassidorder"
		rss.open sql,conn,1,1
		if rss.eof and rss.bof then 
		else
		i=1
		do while not rss.eof
		
	class1=class1 & "<TR >"
 	class1=class1 & " <TD height=31 >"
 	class1=class1 & " <font color=#000000>"
 	class1=class1 & " 　<a href=http://www.chinanr.cn/"
 	class1=class1 & rss("mingcheng")
 	class1=class1 & ">"
 	class1=class1 & rss("anclass")
 	class1=class1 & "</a></font>"
 	class1=class1 & "(<font color=""#FF6317"">"
             
             	set rss2 = server.CreateObject ("adodb.recordset")
             	sql2="select anclassid from w163_books where anclassid="&rss("anclassid")
             	rss2.open sql2,conn,1,1
             	class1=class1 &  rss2.recordcount
             	rss2.close
             	set rss2=nothing
             	
             class1=class1 & "</font>)</TD></TR>"
 	class1=class1 & "<TR>"	 
	 
 class1=class1 & " </TD>"
     class1=class1 & "</TR><tr>" 
          class1=class1 & "<td height=1 bgcolor=#dcdcdc></td>" 
          class1=class1 & "</tr>"  		
      rss.movenext
		i=i+1
		loop
		end if
		rss.close
  		set rss=nothing

      class1=class1 & "<tr><td height=20 ></td></tr>"
     class1=class1 & "</TABLE>" 
          class1=class1 & "</td>" 
          class1=class1 & "</tr>" 
     class1=class1 & "</TABLE>" 

response.write class1
set rs_8 = server.CreateObject ("Adodb.recordset")
sql_8="select * from demo where ifuse=1 and demoid=30"
rs_8.open sql_8,conn,1,1
endhtml=rs_8("demohtml")
rs_8.close
'取模版结束






if isDepth=0 then	
	sql= "select * from w163_books where mingcheng=mingchen order by adddate desc "
else
	sql= "select * from w163_books where mingcheng=mingchen order by adddate desc "
end if


'response.write sql
'response.write "<br>"
'response.end
set rs = server.CreateObject ("Adodb.recordset")
rs.open "select * from w163_Article where ClassID='"&ClassID&"' order by UpdateTime desc",conn,1,1
if rs.eof and rs.bof then 
		
    HtmlContent=HtmlTemplate


if adbanner="" then
adbanner=""
end if

if classjs="" then
classjs="暂无分类"
end if

if strSoftList="" then
strSoftList="暂无产品"
end if
	tophtml=replace(tophtml,"$webname$",""&CatalogName&"")
	tophtml=replace(tophtml,"$keyword$",""&keyw163&"")
	tophtml=replace(tophtml,"art",""&art&"")

    HtmlContent=replace(HtmlContent,"class1",""&class1&"")
	HtmlContent=replace(HtmlContent,"$SoftList$",""&strSoftList&"")
    HtmlContent=replace(HtmlContent,"$Title$",""&strTitle&"")
    HtmlContent=replace(HtmlContent,"$ClassList$",""&classjs&"")
     HtmlContent=replace(HtmlContent,"$top$",""&tophtml&"")
    HtmlContent=replace(HtmlContent,"$end$",""&endhtml&"")
	HtmlFileName=Server.MapPath("../class/big"&CatalogID&"_1.htm")
    Set fout = fso.CreateTextFile(HtmlFileName)
    fout.WriteLine HtmlContent 
    fout.close:set fout = nothing 
else

totalPut=rs.recordcount  '商品数
	        
			if (totalPut mod MaxPerPage)=0 then 
	     			tempPcount= totalPut \ MaxPerPage 
	   		else 
	      			tempPcount= totalPut \ MaxPerPage + 1 
	   		end if 
			
'''dim CurrentPage			
		for CurrentPage=1 to tempPcount
		
		    if (totalPut mod MaxPerPage)=0 then 
	     			Pcount= totalPut \ MaxPerPage 
	   		else 
	      			Pcount= totalPut \ MaxPerPage + 1 
	   		end if 
			
rs.AbsolutePage=CurrentPage
	



    RS.MoveFirst
	if currentpage > Pcount then currentpage = Pcount
   	if currentpage<1 then currentpage=1
	RS.Move (currentpage-1) * MaxPerPage
	




page_count=0	
j=1
  listContent=listContent & ""

<!--类-->
do while not rs.eof and page_count < Clng(MaxPerPage)
 listContent=listContent & "<table width=390 border=0 cellpadding=0 cellspacing=0    id=table1 style=border-collapse: collapse><tr><td width=390 align=left>"
    listContent=listContent & "·<a target=""_blank"" href="
                             listContent=listContent & "w163"
                           listContent=listContent & rs("ArticleID")
       listContent=listContent & ".asp>"
        listContent=listContent & replace(trim(rs("Title")),"<br>","")
         listContent=listContent & "</a><br>"
 listContent=listContent & "</td>"

  listContent=listContent & "</table>"

 			rs.MoveNext
j=j+1
page_count=page_count+1
loop
  listContent=listContent & ""


listD = listD & "$showPage$" & vbcrlf
strSoftList=replace(listD,"$showPage$",""&showPage(CatalogID,CatalogName,strOrderName,strBy2,totalput,MaxPerPage,CurrentPage,looktype,tuijian)&"") 
	


'banner广告开始
'response.write adbanner
response.write "<br>"
'banner广告结束

	tophtml=replace(tophtml,"$Title1$",""&CatalogName&"")
	tophtml=replace(tophtml,"$keyword$",""&keyw163&"")
	tophtml=replace(tophtml,"art",""&art&"")



    HtmlContent=HtmlTemplate
 HtmlContent = replace(HtmlContent,"$class1$",class1)

    HtmlContent=replace(HtmlContent,"class1",""&class1&"")
    HtmlContent=replace(HtmlContent,"$Title$",""&strTitle&"")
	HtmlContent=replace(HtmlContent,"$ClassList$",""&classjs&"")
	HtmlContent=replace(HtmlContent,"$tuijian$",""&tuijian&"")
	    HtmlContent=replace(HtmlContent,"$listContent$",""&listContent&"")
    HtmlContent=replace(HtmlContent,"$SoftList$",""&strSoftList&"")
    HtmlContent=replace(HtmlContent,"$top$",""&tophtml&"")
    HtmlContent=replace(HtmlContent,"$end$",""&endhtml&"")
    HtmlFileName=Server.MapPath(path&"/"&"default"&CatalogID&"_"&(CurrentPage)&".asp")
    Set fout = fso.CreateTextFile(HtmlFileName)
    fout.WriteLine HtmlContent 
  

	'response.write CurrentPage
	response.write "<br>"	
'变量清空，避免多次循环开始
listContent=""			
'adbanner1=""
'变量清空，避免多次循环结束
		next 
end if
rs.close

'分页函数
function showPage(CatalogID,CatalogName,strOrderName,strBy2,TotalNumber,MaxPerPage,CurrentPage,looktype,tuijian)
showPage=""
  	if totalnumber mod maxperpage=0 then
     		n= totalnumber \ maxperpage
  	else
     		n= totalnumber \ maxperpage+1
  	end if
  	showPage=showPage & "<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"" class=word align=""left"">"
	showPage=showPage & "<tr><td> "
	response.write CurrentPage
  	if CurrentPage<2 then
    	showPage=showPage &" 合计<font color=""red""><b>"&totalnumber&"</b></font>个 |　首页 上一页"
  	else
    	showPage=showPage &" 合计<font color=""red""><b>"&totalnumber&"</b></font>个 |　<a  target=""_blank"" href=""default_1.asp"">首页</a>"
    	showPage=showPage &" <a target=""_blank"" href=""default"&CatalogID&"_"&(CurrentPage-1)&".asp"">上一页</a>"
  	end if

  	if n-currentpage<1 then
    	showPage=showPage &" 下一页 尾页"
  	else
    	showPage=showPage &" <a target=""_blank"" href=""default"&CatalogID&"_"&(CurrentPage+1)&".asp"">"
    	showPage=showPage &" 下一页</a> <a href=""default"&CatalogID&"_"&n&".asp"">尾页</a>"
  	end if
   	showPage=showPage &"　页次：<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
    showPage=showPage &"<b>"&maxperpage&"</b>个/页</td>"
	showPage=showPage &"<form action="""" method=post onChange=""submit()""><td>Go:<select name=""select"" onChange='javascript:window.open(this.options[this.selectedIndex].value,""_blank"")'>"
	for intPage=1 to n
	showPage=showPage &"<option value=""default"&CatalogID&"_"&intPage&".asp"""
	if intPage=CurrentPage then showPage=showPage &" selected"
	showPage=showPage &">第"&intPage&"页</option>"
	next
	showPage=showPage &"</select></td></FORM></tr></table>"
end function
%>