<!--#include file="../../../inc/cms_admin.asp" -->
<%
dim act : act=getForm("act","both")
dim CID, C_LID, C_SID,SID,C_GID, C_exc, C_Title, C_Title2, C_Color, C_Link, C_Tag, C_Content, C_OnOff, IsTop,IsPic, Isgood, isoffer, C_Order, issell, C_Visits, C_AddTime, C_Picsurl, C_Picsname,  C_Pic, C_DownUrl, C_DownName,C_PageTitle, C_PageKey, C_PageDesc, C_PageName, Custom, C_EditTime,Ishtml,C_Star,sql,C_Brand
dim SType,keyword, page, psize, orderby, ordsc, STypeName,moveSortID,moveID,whereStr,rs,result,table,col,colval,idval,id,pytitle
SType=getForm("SType","both")
STypename=dbselect("[dbpre]Model","Model_Name","Model_type='"&SType&"'")
SID=getForm("SID","both")
CID=getForm("CID","both")
col=getForm("col","both")
colval=getForm("colval","both")
idval=getForm("idval","post")
idval=endstr(idval,",")
id=getForm("id","both")
keyword=getForm("keyword","both")
page=getForm("page","get")
psize=getForm("psize","get")
orderby=getForm("orderby","get")
ordsc=getForm("ordsc","get")
pytitle=getForm("pytitle","both")
'echo "update [dbpre]content set "&col&"="&colval&"  where  "&id&"="&idval&""
Select  case act
	case "setcol"	:	dbsql("update [dbpre]content set "&col&"="&colval&"  where CID="&idval&"")
	case "delcol"	:	dbconn("update [dbpre]content set C_OnOff=2  where CID in ("&idval&")")
	case "recycle"	:	dbconn("update [dbpre]content set C_OnOff=1  where CID in ("&idval&")")
	case "truedel"	:	delContent
	case "allclear"	:	if idval="all" then dbconn("delete from [dbpre]content  where C_onoff=2")
	case "add"		:	addContent	
	case "edit"		:	editContent
	case "saveid"	:	saveid	
	case "savetitle":	savetitle
	case "moveid"	:	moveContent
	case "copyid" 	: 	copyContent
	case "Loadsort"	:	Loadsort SID,Stype
	case "Loadsortlist"	:	Loadsortlist
	case "checkPageName"	:		if dbcount("[dbpre]content","C_PageName='"&pytitle&"'")>0 then echo "err"
End Select

function Loadsort()
	sname=dbselect("[dbpre]sort","s_name","sid="&sid&"")
	echo "<option value='"&sid&"' selected='selected'>"&sname&"</option>"
end function

function Loadsortlist()
	Loadsortlist=getsortOption(0,SID,Stype,"")		
end function

sub savetitle
	dim colval		:	colval=getForm("colval","both")
	dim colid		:	colid=getForm("colid","both")
	dbconn "update [dbpre]Content Set C_title='"&colval&"' Where CID="&colid
	echo leftstr(colval,40)
end sub

Sub saveid
	dim colid		:	colid=getForm("colid","both")
	dim colname		:	colname=getForm("colname","both")
	dim colval		:	colval=getForm("colval","both")
	dim sql1 		:	sql1="update [dbpre]Content Set "&colname&"='"&colval&"' Where CID="&colid
	dim sql2 		:	sql2="update [dbpre]Content Set "&colname&"="&colval&" Where CID="&colid	
	dbconn(sql1)	:	if err then dbconn(sql2)
End Sub

Sub copyContent
	moveID=getform("moveID","both")
	moveSortID=getform("moveSortID","both")	
	dim copyid,i
	copyid=split(moveID,",")
		sql = "select custom from [dbpre]Content_custom where customType not in('about','brand','gbook') order by customID"
		dim rsObj	:	Set rsObj=Conn.Exec(sql,"r1")
		Do While not rsObj.Eof 		
			custom = custom & ","&rsObj(0)			
			rsObj.MoveNext
		Loop		
		rsObj.Close	:	set rsObj=Nothing	
	for i=0 to ubound(copyid)-1	
	dbconn"insert into [dbpre]Content (C_Title,C_LID,C_Brand,C_Type,C_GID,C_Exc,C_Title2,C_Color,C_Link,C_Tag,C_Content,C_OnOff,C_Order,IsOutLink,IsTop,Isgood,IsPic,isoffer,issell,Ishtml,C_Visits,C_Star,C_AddTime,C_EditTime,C_Picsurl,C_Picsname,C_pic,C_DownURL,C_DownName,C_PageName,C_PageTitle,C_PageKey,C_PageDesc"&custom&",C_SID) select C_Title,C_LID,C_Brand,C_Type,C_GID,C_Exc,C_Title2,C_Color,C_Link,C_Tag,C_Content,C_OnOff,C_Order,IsOutLink,IsTop,Isgood,IsPic,isoffer,issell,Ishtml,C_Visits,C_Star,C_AddTime,C_EditTime,C_Picsurl,C_Picsname,C_pic,C_DownURL,C_DownName,C_PageName,C_PageTitle,C_PageKey,C_PageDesc"&custom&","&moveSortID&" from [dbpre]Content where CID="&copyid(i)&""
	next	
End Sub

Sub moveContent
	moveID=endstr(getform("moveID","both"),",")
	moveSortID=getform("moveSortID","both")
	dbconn("update cms_content set C_sid="&movesortid&" where CID in ("&moveID&")")
end Sub

Sub delContent
	dim filepath
	if runMode>0 or IsCache=1 then
	sql="select * from [dbpre]Content as a, cms_Sort as b where a.C_SID=b.SID and C_OnOff<>1 and CID in("&idval&")"
	set rs=dbsql(sql)
		do while not rs.eof	
		if runMode=1 or runMode=3 then		 
			filepath=getContentLink(rs("C_SID"),rs("CID"),rs("C_link"),rs("C_PageName"),rs("S_Type"),0)		
		elseif IsCache=1 then	
			filepath=sitepath&CachePath&Cachepre&rs("C_SID")&"_"&rs("CID")&"_1.html"
		end if
		delfile filepath
	rs.movenext
	loop
	end if
	dbconn("delete from [dbpre]Content  where  CID in ("&idval&")")	
	closers rs
end Sub

function getCustom(CID,Stype)	
		Dim rs,CustomFields,rs1,i,CustomNames,splitValue,checkstr,selectstr,valstr,topstr,endstr,filetype,fileview,filescript
		CustomFields=""		
		Set rs=dbsqlr1("select CustomName,Custom,customValues,customOptions,customClass,customplace from [dbpre]Content_custom where  customOnOff=1 and (Customtype like '%"&stype&"%' or Customtype='all')  order by CustomOrder asc,CustomID asc")		
		if not rs.eof then topstr= "<div class='col-sm-12'><div class='ibox float-e-margins'> <a class='collapse-link'><div class='ibox-title'><h5>自定义参数</h5><div class='ibox-tools'><i class='fa fa-chevron-up'></i> </div></div></a><div class='ibox-content'>"  	
		if not rs.eof then endstr= "</div></div></div>"		
		Do While not rs.Eof 			
			if CID=0 then 	
				valstr=rs(2)
			 else 
				valstr=dbselect("[dbpre]content",""&rs(1)&"","CID="&CID&"")
			end if
				select case rs(4)
				case 0,1	
				getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
                     "<label class='col-sm-2 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
                     "<div class='col-sm-8'><input name='"&rs(1)&"' id='"&rs(1)&"' type='text' class='form-control' placeholder='"&rs(5)&"' value='"&valstr&"'>"&vbcrlf& _	
                     "</div> </div>"&vbcrlf
				case 2
				getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
					"<label class='col-sm-2 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
					"<div class='col-sm-8'> <textarea class='textarea form-control'   name='"&rs(1)&"' id='"&rs(1)&"'  placeholder='"&rs(5)&"'>"&valstr&"</textarea>"&vbcrlf& _	
					"</div></div>"&vbcrlf
				case 3
				getCustom= getCustom&"<div class='ibox-title'><h5>"&rs(0)&"</h5></div>"&vbcrlf& _					
				"<div class='form-group'>"&vbcrlf& _
					"<div class='col-sm-12'> <textarea class='textarea textarea-editor'   name='"&rs(1)&"' id='"&rs(1)&"'>"&decode(valstr)&"</textarea>"&vbcrlf& _	
					"</div></div> <script>var $ZZZEditor = new UE.getEditor('"&rs(1)&"');</script>"&vbcrlf
				case 4,5,6
					if ifstrin(rs(3),",") then
					getCustom= getCustom&"<div class='form-group'><label class='col-sm-2 control-label'>"&rs(0)&"</label>"&vbcrlf	
					if rs(4)=6 then getCustom= getCustom&"<div class='col-sm-10'><select name='"&rs(1)&"' id='"&rs(1)&"' class='form-control'>" else getCustom= getCustom&"<div class='col-sm-10'>"
					splitValue=split(rs(3),",")
						for i=0 to ubound(splitValue)
						if ifstrin(valstr,splitValue(i)) then
						  checkstr="checked"
						  selectstr="selected"
						  else 
						  checkstr=""
						  selectstr=""
						end if
						if rs(4)=4	then getCustom= getCustom& "<div class='radio radio-inline'><input type=""radio"" id='"&rs(1)&i&"' name='"&rs(1)&"' "&checkstr&" value='"&splitValue(i)&"'/><label for='"&rs(1)&i&"'>"&splitValue(i)&"</label></div>"&vbcrlf
						if rs(4)=5	then getCustom= getCustom& "<div class='checkbox radio-inline'><input type=""checkbox"" id='"&rs(1)&i&"' name='"&rs(1)&"' "&checkstr&" value='"&splitValue(i)&"'/><label for='"&rs(1)&i&"'>"&splitValue(i)&"</label></div>"&vbcrlf
						if rs(4)=6	then getCustom= getCustom& " <option value='"&splitValue(i)&"' "&selectstr&">"&splitValue(i)&"</option>"
						next
					if rs(4)=6 then getCustom= getCustom&" </select>"
					getCustom=  getCustom&"</div></div>"&vbcrlf
					end if
				case 7,8,9
					if rs(4)=7 then	filetype="file"	 :	filescript="<script>$(function(){fileuploader("""&rs(1)&"_upload"","""&iif(isnul(rs(3)),"file",rs(3))&""","""&Stype&""","""&rs(1)&""","""")}) </script>"
					if rs(4)=8 then	filetype="pic"	 :  filescript="<script>$(function(){fileuploader("""&rs(1)&"_upload"",""image"","""&Stype&""","""&rs(1)&""","""")}) </script>" :	fileview=" <div class='col-sm-1'><img src='"&valstr&"' height='30' id='img_"&rs(1)&"'></div>"	
					if rs(4)=9 then	filetype="video" :	filescript="<script>$(function(){fileuploader("""&rs(1)&"_upload"",""video"","""&Stype&""","""&rs(1)&""","""")}) </script>"
					getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
						 "<label class='col-sm-2 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
						  "<div class='col-sm-7'><input id='"&rs(1)&"' name='"&rs(1)&"' class='form-control' value='"&valstr&"'/></div>"&vbcrlf& _	
						 "<div class='col-sm-2'><div id='"&rs(1)&"_upload'>上传</div></div>"&fileview&" </div>"&vbcrlf& _	
						 filescript&vbcrlf
				case 10			
				getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
                     "<label class='col-sm-2 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
					  "<div class='col-sm-4'><div class='input-group'>"&vbcrlf& _	
                  		"<input type='text' id='"&rs(1)&"' class='form-control time'  name='"&rs(1)&"'  placeholder='"&rs(5)&"'  value='"&valstr&"'>"&vbcrlf& _	
                  		"<span class='input-group-addon'>  <i class='fa fa-calendar'></i></span> </div></div></div>"&vbcrlf& _	
						"<script> $('#"&rs(1)&"').jeDate({"&rs(3)&"})</script>"&vbcrlf
				end select
			rs.MoveNext
		Loop
		getCustom=topstr&getCustom&endstr
End function



Sub getContent
	if not isnul(CID) then		
		Dim rs : Set rs = dbsql("select * from [dbpre]Content where CID="&CID)
		if not rs.eof then	
			CID			=rs("CID")
			C_LID		=rs("C_LID")
			SID			=rs("C_SID")
			C_GID		=rs("C_GID")
			stype=		rs("C_Type")
			C_exc		=rs("C_exc")
			C_Title		=rs("C_Title")
			C_Title2	=rs("C_Title2")
			C_brand		=rs("C_brand")
			C_Color		=rs("C_Color")			
			C_Link		=rs("C_Link")		
			C_Content	=decode(rs("C_Content"))
			C_OnOff		=rs("C_OnOff")		
			IsTop		=rs("IsTop")	
			IsPic		=rs("IsPic")		
			Isgood		=rs("Isgood")		
			isoffer		=rs("isoffer")		
			C_Order		=rs("C_Order")		
			issell		=rs("issell")		
			C_Visits	=rs("C_Visits")		
			C_AddTime	=rs("C_AddTime")	
			C_edittime	=rs("C_edittime")	
			C_pic		=rs("C_Pic")	
			C_Picsurl	=rs("C_Picsurl")	
			C_Picsname	=rs("C_Picsname")	
			C_Tag		=rs("C_Tag")	
			C_DownUrl	=rs("C_DownUrl")
			C_DownName	=rs("C_DownName")		
			C_PageTitle	=rs("C_PageTitle")
			C_PageKey	=rs("C_PageKey")		
			C_PageDesc	=rs("C_PageDesc")		
			C_PageName	=rs("C_PageName")		
			Ishtml		=rs("Ishtml")			
			C_Star		=rs("C_Star")							
		end if
	else		
		alertgo "没有这条记录","-1"
	end if
End Sub

Sub addContent
	C_LID=zset.Lid
	SID=getForm("SID", "post")
	C_GID=isnum(getForm("C_GID", "post"))
	C_exc=getForm("C_exc", "post")	
	C_Color=getForm("C_Color", "post")
	C_Title=getForm("C_Title", "post")	
	C_Content=encode(request.form("C_Content"))	
	C_PageTitle=getForm("C_PageTitle", "post")
	C_PageKey=getForm("C_PageKey", "post")
	C_PageDesc=leftStr(encode(request.form("C_PageDesc")),255)
	C_Link=getForm("C_Link", "post")	
	C_OnOff=1
	IsTop=getCheck(getForm("IsTop", "post"))	
	IsPic=getCheck(getForm("IsPic", "post"))
	Isgood=getCheck(getForm("Isgood", "post"))
	isoffer=getCheck(getForm("isoffer", "post"))
	issell=getCheck(getForm("issell", "post"))
	Ishtml=getCheck(getForm("Ishtml", "post"))		
	C_Brand=getForm("C_Brand", "post")	
	C_Star=isnum(getForm("C_Star", "post"))
	C_Order=isnum(getForm("C_Order", "post"))
	C_Visits=isnum(getForm("C_Visits", "post"))
	C_AddTime=getForm("C_AddTime", "post")
	C_Picsurl=getForm("picsurl", "post")
	C_Picsname=getForm("picsname", "post")
	C_Pic=getForm("pic", "post")
	C_DownURL=getForm("C_DownURL", "post")
	C_DownName=getForm("C_DownName", "post")
	C_PageName=getForm("C_PageName", "post")
	Custom=split(getForm("Custom","post"),",")		
	if not isnul(C_Pic) then IsPic=1
	if not isnul(C_Pic) and isnul(C_Picsurl) then C_Picsurl=C_Pic
	if not isnum(C_LID) then C_LID=1
	if isnul(C_Title) then back "请填写标题"
	if not ifnum(SID) or SID="0" then back "请选择分类"
	if isnul(C_AddTime) then C_AddTime=now()
	C_Tag=getForm("C_Tag", "post")	
	if isnul(C_PageTitle) then C_PageTitle=C_Title
	if isnul(C_PageKey) then C_PageKey=autokeys(C_Title)
	if isnul(C_PageDesc) then C_PageDesc=leftStr(drophtml(request.form("C_Content")),255)
	C_Tag=replacestr(replacestr(replacestr(C_Tag,"，",","),"|",","),";",",")
	set rs=dbsqlr1("select custom,customClass from [dbpre]content_custom where customType like '%"&Stype&"%' or customType='all'")
	dim customStr,customval
	Do While not rs.Eof 
		customStr=customStr&","&rs(0)
		if rs(1)=1 then 
		customval=customval&","&isnum(getForm(rs(0),"post"))& ""
		elseif rs(1)=3 then 
		customval=customval&",'"&encode(request.form(rs(0)))& "'"
		elseif rs(1)=10 then 
			if isnul(getForm(rs(0),"post")) then 
				customval=customval&",null"
			else
				customval=customval&",'"&getForm(rs(0),"post")&"'"
			end if
		else
			customval=customval&",'"&getForm(rs(0),"post")&"'"
		end if
	rs.MoveNext
	Loop
	closers rs	
	sql = "insert into [dbpre]Content(C_Title,C_LID,C_SID,C_OnOff,IsTop,Isgood,IsPic,isoffer,issell,C_GID,C_Order,Ishtml,C_Visits,C_Star,C_Brand,C_Type,C_Exc,C_Color,C_Link,C_Tag,C_Content,C_AddTime,C_picsurl,C_picsname,C_pic,C_DownUrl,C_DownName,C_PageName,C_PageTitle,C_PageKey,C_PageDesc"&customStr&") values('"&C_Title&"',"&C_LID&","&SID&","&C_OnOff&","&IsTop&","&Isgood&","&IsPic&","&isoffer&","&issell&","&C_GID&","&C_Order&","&Ishtml&","&C_Visits&","&C_Star&",'"&C_Brand&"','"&Stype&"','"&C_Exc&"','"&C_Color&"','"&C_Link&"','"&C_Tag&"','"&C_Content&"','"&C_AddTime&"','"&C_Picsurl&"','"&C_Picsname&"','"&C_pic&"','"&C_DownUrl&"','"&C_DownName&"','"&C_PageName&"','"&C_PageTitle&"','"&C_PageKey&"','"&C_PageDesc&"'"&customval&")"
	dbconn(sql)
	cid=dbmaxid("[dbpre]content","cid")
	if not isnul(C_Pic) and smallMark=1 then
		smallimg C_Pic,sitepath&uploadpath&"images/"&cid&".jpg"
	end if	
	addTags C_Tag
	layernext "添加成功,可继续添加"
End Sub

Sub editContent
	CID=isnum(getForm("CID", "both"))
	C_LID=zset.Lid
	C_SID=isnum(getForm("SID", "post"))
	C_GID=isnum(getForm("C_GID", "post"))
	C_exc=getForm("C_exc", "post")	
	C_Color=getForm("C_Color", "post")
	C_Title=getForm("C_Title", "post")	
	C_Content=encode(request.form("C_Content"))	
	C_PageTitle=getForm("C_PageTitle", "post")
	C_PageKey=getForm("C_PageKey", "post")
	C_PageDesc=leftStr(encode(request.form("C_PageDesc")),255)
	C_Link=getForm("C_Link", "post")	
	C_OnOff=1
	IsTop=getCheck(getForm("IsTop", "post"))	
	IsPic=getCheck(getForm("IsPic", "post"))
	Isgood=getCheck(getForm("Isgood", "post"))
	isoffer=getCheck(getForm("isoffer", "post"))
	issell=getCheck(getForm("issell", "post"))
	isoffer=getCheck(getForm("isoffer", "post"))
	Ishtml=getCheck(getForm("Ishtml", "post"))	
	C_Star=isnum(getForm("C_Star", "post"))	
	C_Order=isnum(getForm("C_Order", "post"))
	C_Visits=isnum(getForm("C_Visits", "post"))
	C_AddTime=getForm("C_AddTime", "post")
	C_Picsurl=getForm("picsurl", "post")
	C_Picsname=getForm("picsname", "post")
	C_Pic=getForm("Pic", "post")
	C_DownUrl=getForm("C_DownUrl", "post")
	C_DownName=getForm("C_DownName", "post")
	C_PageName=getForm("C_PageName", "post")	
	C_Brand=getForm("C_Brand", "post")
	C_Tag=getForm("C_Tag", "post")
	if isnul(C_PageTitle) then C_PageTitle=C_Title
	if isnul(C_PageKey) then C_PageKey=autokeys(C_Title)
	if isnul(C_PageDesc) then C_PageDesc=leftStr(drophtml(request.form("C_Content")),255)
	set rs=dbsqlr1("select custom,customClass from [dbpre]content_custom where customType = '"&Stype&"' or customType='all'")
	dim customStr
	Do While not rs.Eof 	
		if rs(1)=1 then 
		customStr=customStr&","&rs(0)&"="&isnum(getForm(rs(0),"post"))& ""
		elseif rs(1)=3 then 
		customStr=customStr&","&rs(0)&"='"&encode(request.form(rs(0)))& "'"
		elseif rs(1)=10 then 
		if not isnul(getForm(rs(0),"post")) then customStr=customStr&","&rs(0)&"='"&getForm(rs(0),"post")&"'"
		else
		customStr=customStr&","&rs(0)&"='"&getForm(rs(0),"post")&"'"
		end if
	rs.MoveNext
	Loop
	closers rs
	
	if not isnul(C_Pic) then IsPic=1
	if not isnul(C_Pic) and isnul(C_Picsurl) then C_Picsurl=C_Pic
	if not isnum(C_LID) then C_LID=1
	if isnul(C_Title) then back"请填写标题"
	if not ifnum(C_SID) or C_SID="0" then back"请选择分类"
	C_Tag=replacestr(replacestr(replacestr(C_Tag,"，",","),"|",","),";",",")	
	sql = "update [dbpre]Content  set C_SID="&C_SID&", C_GID="&C_GID&", C_Exc='"&C_Exc&"', C_Color='"&C_Color&"', C_Title='"&C_Title&"', [C_Content]='"&C_Content&"', C_Tag='"&C_Tag&"', C_PageTitle='"&C_PageTitle&"', C_PageKey='"&C_PageKey&"', C_PageDesc='"&C_PageDesc&"', C_Link='"&C_Link&"',  C_OnOff="&C_OnOff&", IsTop="&IsTop&", IsGood="&IsGood&", IsPic="&IsPic&", IsSell="&IsSell&",isoffer="&isoffer&",C_Brand='"&C_Brand&"', C_Order="&C_Order&", C_Visits="&C_Visits&", C_AddTime='"&C_AddTime&"', C_EditTime='"&sqltime&"', C_Picsurl='"&C_Picsurl&"', C_Picsname='"&C_Picsname&"', C_Pic='"&C_Pic&"',C_DownUrl='"&C_DownUrl&"',C_DownName='"&C_DownName&"', C_PageName='"&C_PageName&"', C_Star="&C_Star&""&customStr&" where CID="&CID	
	dbconn(sql)
	if not isnul(C_Pic) and smallMark=1 then
		smallimg C_Pic,sitepath&uploadpath&"images/"&cid&".jpg"
	end if	
	addTags C_Tag
	layertrue("保存成功")	
End Sub

Sub listContent
	dim i,byStr,whereStr,Sql,rs,allPage,allRecordset,numPerPage
	numPerPage=psize
	if isnum(numPerPage) =0 then numPerPage=10
	if ordsc="1" then byStr="desc" else byStr="asc"
	if isNul(page) then page=1 else page=clng(page)
	if page=0 then page=1
	if isnul(orderby) then  byStr=" order by istop desc,Isgood desc,C_order asc,cid desc" else byStr=" order by "&orderby&" "&byStr &",cid desc"
	whereStr=" where C_LID="&zset.lid
	if not isNul(SID) and SID<>"0" then  whereStr=whereStr&" and  ','+S_path+',' like '%,"&sid&",%'"
	if not isNul(keyword) then whereStr = whereStr&" and C_Title like '%"&keyword&"%'"
	Sql = "select CID,C_Title,C_visits,C_OnOff,C_SID,C_AddTime,IsTop,C_pic,C_picsname,C_picsurl,C_Order,S_Name,Isgood,IsPic,isoffer,issell,IsOutLink,C_Link,C_Color,S_Folder,C_GID,C_Folder,C_FileName,C_PageName,S_GID,S_Type from [dbpre]Content as a, [dbpre]Sort as b"&whereStr&" and C_SID=SID and C_OnOff<>2 and S_type='"&Stype&"' "&byStr
	dim templateobj,templatePath
	set rs = conn.Exec(Sql,"r1")
	rs.pagesize = numPerPage
	allRecordset = rs.recordcount : allPage= rs.pagecount
	if page>allPage then page=allPage
	if allRecordset=0 then
		if not isNul(keyword) then
		    echo "<tr align=""center""><td colspan='9' height=""28"">关键字 <font color=red>"""&keyword&"""</font> 没有记录</td></tr>" 
		else
		    echo "<tr align=""center""><td colspan='9' height=""28"">还没有记录!</td></tr>"
		end if
	else
		rs.absolutepage = page
		for i = 1 to numPerPage
			 echo "<tr>"&vbcrlf
			echo "<td><input type=""checkbox"" name=""id"" value="""&rs(0)&""" class=""checkbox"" /></td>"&vbcrlf& _
				"<td>"&rs(0)&"</td>"&vbcrlf
			echo "<td><a class='caname' id='"&rs(0)&"' title='"&rs(1)&"'><font  color="""&rs("C_Color")&""">"&leftstr(rs(1),40)&"</font></a>　<a title='编辑内容' onclick=opennew('"&sitepath&adminpath&"cms_Content/Content/Content_Edit.asp?CID="&rs("CID")&"')><i class='fa fa-edit'></i></a> "&iif(rs("IsOutLink"),"<a href="""&rs("C_Link")&""" target=""_blank"" title=""查看""><img src=""../../images/view.gif"" border=0 /></a>","<a href="""&getContentLink(rs("C_SID"),rs("CID"),rs("C_link"),rs("C_PageName"),rs("S_Type"),0)&""" target=""_blank"" title=""查看""><i class='fa fa-link'></i></a>")&""&vbcrlf
			if rs("ispic") then echo "<a onclick=""$.fancybox(['"&repkong(replacestr(rs("C_picsurl"),",","','"))&"']);"" class='lightbox'><i class='fa fa-photo'></i></a>"&vbcrlf		
			echo "</td>"&vbcrlf			
			echo "<td><a href='Content_List.asp?Stype="&stype&"&SID="&rs("C_SID")&"'>"&rs("S_name")&"</a> <a href='"&sitepath&"list/?"&rs("C_SID")&"_1.html'  target=""_blank""><i class='fa fa-link'></i></a></td>"&vbcrlf& _			
				"<td><input type='text' readonly onclick='setjeDate(this,"&rs(0)&");' title='双击修改时间' value='"&rs("C_AddTime")&"'></td>"&vbcrlf& _
				"<td><input type='number' class='order' placeholder='"&rs("C_Order")&"' value='"&rs("C_Order")&"' id='C_Order-"&rs(0)&"'/></td>"&vbcrlf			
			
			echo "<td><button type='button' id='"&rs("CID")&"C_OnOff' onclick=setcontent('C_OnOff','"&rs("CID")&"') class='btn btn-"&rs("C_OnOff")&"  dim'><i class='fa fa-toggle-on'></i></button></td>"&vbcrlf& _
				"<td>"				
				echo"<button type='button' class='btn btn-info dim' title='编辑内容' onclick=opennew('"&sitepath&adminpath&"cms_Content/Content/Content_Edit.asp?CID="&rs("CID")&"')><i class='fa fa-edit'></i></button> <button type='button'  onclick=delcontent('"&rs("CID")&"') title='删除内容到回收站' class='btn btn-danger dim'><i class='fa fa-times'></i></button></td>"&vbcrlf& _
			  "</tr>"&vbcrlf
			rs.movenext
			if rs.eof then exit for
		next
		echo"<tr class=""pagenavi"">"&vbcrlf& _
			"<td colspan=""9"" height=""28"" style=""padding-left:20px;"">"&vbcrlf& _			
			"页数："&page&"/"&allPage&"  每页"&numPerPage &" 总记录数"&allRecordset&"条 <a href=""?Stype="&Stype&"&SID="&SID&"&keyword="&keyword&"&page=1&psize="&psize&"&orderby="&orderby&"&ordsc="&ordsc&"""><i class='fa fa-step-backward'></i></a> <a href=""?Stype="&Stype&"&SID="&SID&"&keyword="&keyword&"&page="&(page-1)&"&psize="&psize&"&orderby="&orderby&"&ordsc="&ordsc&"""><i class='fa fa-chevron-left'></i></a> "&vbcrlf
			echo getadminpage(page, 10, allPage, "list",sid, keyword)
		echo"<a href=""?Stype="&Stype&"&SID="&SID&"&keyword="&keyword&"&page="&(page+1)&"&psize="&psize&"&orderby="&orderby&"&ordsc="&ordsc&"""><i class='fa fa-chevron-right'></i></a> <a href=""?Stype="&Stype&"&SID="&SID&"&keyword="&keyword&"&page="&allPage&"&psize="&psize&"&orderby="&orderby&"&ordsc="&ordsc&"""><i class='fa fa-step-forward'></i></a>"&vbcrlf
			
		echo"每页显示"&getPageSize("10",psize)&getPageSize("20",psize)&getPageSize("50",psize)&getPageSize("100",psize)
				
		echo"条"&vbcrlf& _	
		"</td>"&vbcrlf& _
		"</tr>"&vbcrlf
	end if
	rs.close : set rs = nothing	
End Sub

Function getPageSize(ps,nps)
	if isnul(nps) then nps="10"
	if ps=nps then 
		getPageSize="<a class='active'>"&ps&"</span>"
	else
		getPageSize="<a href=""?SType="&SType&"&SID="&SID&"&keyword="&keyword&"&page="&page&"&psize="&ps&"&orderby="&orderby&"&ordsc="&ordsc&""">"&ps&"</a>"
	end if
End Function

Function addTags(tags)
	dim sql,rs,tag,tagIDs,T_enName	,T_AddTime
	T_AddTime=now()
	tags=split(tags,",")
	
	for each tag in tags
		if not isnul(tag) then 				
			if dbcount("[dbpre]Tag","T_Name='"&tag&"'")=0 then				
				T_enName=pinYin(tag)			
				dbsql("insert into [dbpre]Tag(T_Name,T_enName, T_Type,  T_Visits, T_LID, T_AddTime,T_OnOff,T_order) values('"&tag&"','"&T_enName&"','"&SType&"',9,"&C_LID&",'"&T_AddTime&"',1,9)")
			end if
		end if		
	next	
End Function


Function getTopType(SID)	
	on error resume next
	if isnum(SID)>0 then
		Dim tempStr,rs
		set rs = dbsql("select SID,S_TID,S_PID,S_name from [dbpre]Sort where SID="&SID&"")		
		tempStr=" <a href='Content_List.asp?Stype="&Stype&"&amp;SID="&rs("SID")&"'>"&rs("S_name")&"</a> >"&tempStr
		if rs("S_PID")<>0 then tempStr=getTopType(rs("S_PID"))&tempStr
		closers rs
		getTopType=tempStr
	end if
End Function 

                
Function getbrand(stype,this)
	dim rs,sel,sql,brandoption,brandname
	if isnul(this) then this=""
	brandoption=""
	brandname=dbselect("[dbpre]Model","Model_Name","Model_type='brand'")
	sql="select B_Name from [dbpre]brand  where B_OnOff=1 and (B_type like '%"&stype&"%' or B_type='')"	
	set rs=dbsql(sql)
	if not rs.Eof then 
		getbrand="<label class='col-sm-2 control-label'>"&brandname&"</label><div class='col-sm-4'><select class='form-control m-b col-sm-2' name='C_brand'> <option></option>"	
		Do While Not rs.Eof	
			IF CSTR(this)=CSTR(rs("B_Name")) Then sel = "selected=""selected""" else sel="" end if			
			brandoption= brandoption&"<option value="""& rs("B_Name") &""" "&sel&">"&rs("B_Name")&"</option>" & vbcr				
		rs.MoveNext
		Loop 
		getbrand=getbrand&brandoption&"</select> </div>"
	else
		getbrand=""
	end if 
	Closers rs
end Function
               
%>