<%
'*******************************************************
'易达CMS中小企业快速建站系统
'软件开发 黑龙江省世纪伟成网络科技有限公司
'网址：http://yidacms.com
'软件享有著作权，未经公司或开发者同意禁止更改以下代码。
'*******************************************************
function Products(str)
	set reg=new regexp
	reg.IgnoreCase = False 
	reg.Global = True 
	reg.Pattern = "<Products:\{(.+?)\}>([\s\S]*?)<Products>"
	set aa=reg.execute(str)
	for each match in aa
	bq=match.submatches(0)
	nr=match.submatches(1)
	Language=nbq(bq,"Language")
	Row=nbq(bq,"Row")
	leixing=nbq(bq,"leixing")
	Tlen=nbq(bq,"Tlen")
	str=replace(str,match,chanpin(Language,Row,nr,leixing,Tlen))
	next
	Products=str
end function

Function chanpin(Language,Row,yida_cms,leixing,Tlen)

if leixing = 1 then
	yidacms_shuxing = "01,"
		elseif leixing = 2 then
	yidacms_shuxing = "02,"
		elseif leixing = 3 then
	yidacms_shuxing = "03,"
		elseif leixing = 4 then
	yidacms_shuxing = "04,"
end if

set rs = server.createobject("adodb.recordset")
sql="select top "&Row&" * from shuaiweb_products where Instr(shuaiweb_productsstate,'"&yidacms_shuxing&"') and yida_language = '" & Language & "' ORDER BY id DESC"
rs.open sql,dbok,1,1
if rs.eof then
	yida_cms = zanwugeichanpinfenlei
		else
 Do While Not rs.EOF

if Language = "ch" then
 if yida_url = "asp" then
  Productsurl = webpath & "zh_products_view.asp?id=" & rs("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  Productsurl = webpath & "html/products/products_"&rs("id")&".html"
 end if
elseif Language = "en" then
 if yida_url = "asp" then
  Productsurl = webpath & "en_products_view.asp?id=" & rs("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  Productsurl = webpath & "html/en_products/products_"&rs("id")&".html"
 end if
end if

if trim(rs("shuaiweb_productsminpic")) <> "" then
 productsxiaotu = sw_dizhi & rs("shuaiweb_productsminpic")
  else
 productsxiaotu = sw_dizhi & "images/Without.gif"
end if

if trim(rs("shuaiweb_productsmaxpic")) <> "" then
 productsdatu = sw_dizhi & rs("shuaiweb_productsmaxpic")
  else
 productsdatu = sw_dizhi & "images/Without.gif"
end if

yida_cms1=replace(yida_cms,"{Products:name}",left(rs("shuaiweb_productsname"),Tlen))
yida_cms2=replace(yida_cms1,"{Products:name_color}","<font color='"&rs("wait_prer")&"'>" & left(rs("shuaiweb_productsname"),Tlen) & "</font>")
yida_cms3=replace(yida_cms2,"{Products:id}",rs("id"))
yida_cms4=replace(yida_cms3,"{Products:riqi}",FormatDate(rs("time"),4))
yida_cms5=replace(yida_cms4,"{Products:bianhao}",rs("shuaiweb_productsno"))
yida_cms6=replace(yida_cms5,"{Products:xinghao}",rs("shuaiweb_productsmodel"))
yida_cms7=replace(yida_cms6,"{Products:caizhi}",rs("wait_pryi"))
yida_cms8=replace(yida_cms7,"{Products:biaozhunjia}",rs("shuaiweb_productsbprice"))
yida_cms9=replace(yida_cms8,"{Products:youhuijia}",rs("shuaiweb_productsprice"))
yida_cms10=replace(yida_cms9,"{Products:kucunliang}",rs("shuaiweb_productsLibrary"))
yida_cms11=replace(yida_cms10,"{Products:jijiadanwei}",rs("shuaiweb_productsunits"))
yida_cms12=replace(yida_cms11,"{Products:chupingongsi}",rs("shuaiweb_productsco"))
yida_cms13=replace(yida_cms12,"{Products:xiaotu}",productsxiaotu)
yida_cms14=replace(yida_cms13,"{Products:datu}",productsdatu)
yida_cms15=replace(yida_cms14,"{Products:url}",Productsurl)
yida_cms16=replace(yida_cms15,"{Products:neirong}",left(RemoveHTML(rs("shuaiweb_productscontent")),30))
tt=tt+yida_cms16
    rs.movenext
  Loop
end if	
rs.Close
set rs=nothing
chanpin = tt	
End Function

function Productsclass(str)
	set reg=new regexp
	reg.IgnoreCase = False 
	reg.Global = True 
	reg.Pattern = "<Productsclass:\{(.+?)\}>([\s\S]*?)<Productsclass>"
	set aa=reg.execute(str)
	for each match in aa
	bq=match.submatches(0)
	nr=match.submatches(1)
	Language=nbq(bq,"Language")
	Quanbu=nbq(bq,"Quanbu")
	Row=nbq(bq,"Row")
	Lanmu=nbq(bq,"Lanmu")
	Leixing=nbq(bq,"Leixing")
	str=replace(str,match,chanpinfenlei(Language,Quanbu,Row,Lanmu,Leixing,nr))
	next
	Productsclass=str
end function

Function chanpinfenlei(Language,Quanbu,Row,Lanmu,Leixing,yida_cms)
set rs = server.createobject("adodb.recordset")
   if Quanbu = 0 then
	sql="select top "&Row&" * from shuaiweb_productsclass where wait_pcsi = 1 and wait_pcyi = '0' and yida_language='" & Language & "' ORDER BY shuaiweb_classsort ASC"
          elseif Quanbu = 1 then
	sql="select * from shuaiweb_productsclass where wait_pcsi = 1 and id = " & Leixing & " and yida_language='" & Language & "' ORDER BY shuaiweb_classsort ASC"
   end if
rs.open sql,dbok,1,1
if rs.eof then
 zanwu = zanwufenlei
  else
   Do While Not rs.EOF

if Language = "ch" then
 if yida_url = "asp" then
  Productsclassurl = webpath & "zh_products.asp?id=" & rs("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  Productsclassurl = webpath & "html/products/productslist_"&rs("id")&".html"
 end if
elseif Language = "en" then
 if yida_url = "asp" then
  Productsclassurl = webpath & "en_products.asp?id=" & rs("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  Productsclassurl = webpath & "html/en_products/productslist_"&rs("id")&".html"
 end if
end if

if Lanmu = 1 then
  yida_cms1=replace(yida_cms,"{Products:name}",rs("shuaiweb_classname"))
  yida_cms2=replace(yida_cms1,"{Products:id}",rs("id"))
  yida_cms3=replace(yida_cms2,"{Productsclass:url}",Productsclassurl)
  tt=tt+yida_cms3
end if
	set rss = server.createobject("adodb.recordset")
         if Quanbu = 0 then
	sql2="select * from shuaiweb_productsclass where wait_pcsi = 1 and wait_pcyi = '"&rs("id")&"' ORDER BY shuaiweb_classsort ASC"
         elseif Quanbu = 1 then
	sql2="select * from shuaiweb_productsclass where wait_pcsi = 1 and wait_pcyi = '" & Leixing & "' ORDER BY shuaiweb_classsort ASC"
         end if
	rss.open sql2,dbok,1,1
	Do While Not rss.EOF

if Language = "ch" then
 if yida_url = "asp" then
  Productsclassurl1 = webpath & "zh_products.asp?id=" & rss("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  Productsclassurl1 = webpath & "html/products/productslist_"&rss("id")&".html"
 end if
elseif Language = "en" then
 if yida_url = "asp" then
  Productsclassurl1 = webpath & "en_products.asp?id=" & rss("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  Productsclassurl1 = webpath & "html/en_products/productslist_"&rss("id")&".html"
 end if
end if

 if Lanmu = 1 then
  yida_cms1=replace(yida_cms,"{Products:name}","┝ " & rss("shuaiweb_classname"))
   else
  yida_cms1=replace(yida_cms,"{Products:name}",rss("shuaiweb_classname"))
 end if
 
  yida_cms2=replace(yida_cms1,"{Products:id}",rss("id"))
  yida_cms3=replace(yida_cms2,"{Productsclass:url}",Productsclassurl1)
  tt=tt+yida_cms3
    rss.movenext
    Loop
    rss.close
    set rss = nothing
	
  rs.movenext
  Loop
  end if	
  rs.Close
  set rs=nothing

chanpinfenlei = tt & zanwu
End Function

function Productslist(str)
	set reg=new regexp
	reg.IgnoreCase = False 
	reg.Global = True 
	reg.Pattern = "<Productslist:\{(.+?)\}>([\s\S]*?)<Productslist>"
	set aa=reg.execute(str)
	for each match in aa
	bq=match.submatches(0)
	nr=match.submatches(1)
	Language=nbq(bq,"Language")
	Tlen=nbq(bq,"Tlen")
	str=replace(str,match,chanpinliebiao(nr,Language,Tlen))
	next
	Productslist=str
end function

Function chanpinliebiao(yida_cms,Language,Tlen)  
set rs = server.createobject("adodb.recordset")
if request("id") = "" then
 sql="select * from shuaiweb_products where yida_language = '" & Language & "' ORDER BY id DESC"
  else
 yidacms_productslist = cint(request("id"))
 sql="select * from shuaiweb_products where shuaiweb_productsclass = "&yidacms_productslist&" or shuaiweb_productsclass2 = "&yidacms_productslist&" and yida_language = '" & Language & "' ORDER BY id DESC"
end if
rs.open sql,dbok,1,1
if rs.eof then
	zanwu = zanwuchanpin
		else
			rs.PageSize = vipproductslist
				iCount=rs.RecordCount 
					iPageSize=rs.PageSize
						maxpage=rs.PageCount 
							page=request("page")
								if Not IsNumeric(page) or page="" then
page=1
	else
		page=cint(page)
			end if
				if page<1 then
					page=1
						elseif  page>maxpage then
								page=maxpage
									end if
rs.AbsolutePage=Page
	if page=maxpage then
		x=iCount-(maxpage-1)*iPageSize
			else
				x=iPageSize
					end if
For i=1 To x

if Language = "ch" then
 if yida_url = "asp" then
  chanpinxunhuanurl = webpath & "zh_products_view.asp?id=" & rs("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  chanpinxunhuanurl = webpath & "html/products/products_"&rs("id")&".html"
 end if
elseif Language = "en" then
 if yida_url = "asp" then
  chanpinxunhuanurl = webpath & "en_products_view.asp?id=" & rs("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  chanpinxunhuanurl = webpath & "html/en_products/products_"&rs("id")&".html"
 end if
end if

if trim(rs("shuaiweb_productsminpic")) <> "" then
xiaotu = sw_dizhi & rs("shuaiweb_productsminpic")
else
xiaotu = sw_dizhi & "images/Without.gif"
end if

if trim(rs("shuaiweb_productsmaxpic")) <> "" then
datu = sw_dizhi & rs("shuaiweb_productsmaxpic")
else
datu = sw_dizhi & "images/Without.gif"
end if

yida_cms1=replace(yida_cms,"{Products:name}",left(rs("shuaiweb_productsname"),Tlen))
yida_cms2=replace(yida_cms1,"{Products:name_color}","<font color='"&rs("wait_prer")&"'>" & left(rs("shuaiweb_productsname"),Tlen) & "</font>")
yida_cms3=replace(yida_cms2,"{Products:id}",rs("id"))
if Language = "ch" then
yida_cms4=replace(yida_cms3,"{Products:riqi}",FormatDate(rs("time"),4))
else
yida_cms4=replace(yida_cms3,"{Products:riqi}",FormatDate(rs("time"),12))
end if

yida_cms5=replace(yida_cms4,"{Products:bianhao}",rs("shuaiweb_productsno"))
yida_cms6=replace(yida_cms5,"{Products:xinghao}",rs("shuaiweb_productsmodel"))
yida_cms7=replace(yida_cms6,"{Products:caizhi}",rs("wait_pryi"))
yida_cms8=replace(yida_cms7,"{Products:biaozhunjia}",rs("shuaiweb_productsbprice"))
yida_cms9=replace(yida_cms8,"{Products:youhuijia}",rs("shuaiweb_productsprice"))
yida_cms10=replace(yida_cms9,"{Products:kucunliang}",rs("shuaiweb_productsLibrary"))
yida_cms11=replace(yida_cms10,"{Products:jijiadanwei}",rs("shuaiweb_productsunits"))
yida_cms12=replace(yida_cms11,"{Products:chupingongsi}",rs("shuaiweb_productsco"))
yida_cms13=replace(yida_cms12,"{Products:xiaotu}",xiaotu)
yida_cms14=replace(yida_cms13,"{Products:datu}",datu)
yida_cms15=replace(yida_cms14,"{Products:url}",chanpinxunhuanurl)
yida_cms16=replace(yida_cms15,"{Products:neirong}",left(RemoveHTML(rs("shuaiweb_productscontent")),30))
tt=tt+yida_cms16
rs.movenext
next
end if
rs.Close
 set rs=nothing
if Language = "ch" then
  chanpinliebiao = tt & zanwu & PageControl(iCount,maxpage,page,"<p align=center>",2)
else
  chanpinliebiao = tt & zanwu & PageControl1(iCount,maxpage,page,"<p align=center>",2)
end if
End Function

function Productsxunhuan(str)
	set reg=new regexp
	reg.IgnoreCase = False
	reg.Global = True 
	reg.Pattern = "<Productsxunhuan:\{(.+?)\}>([\s\S]*?)<Productsxunhuan>"
	set aa=reg.execute(str)
	for each match in aa
	bq=match.submatches(0)
	nr=match.submatches(1)
	Row=nbq(bq,"Row")
	leixing=nbq(bq,"leixing")
	Tlen=nbq(bq,"Tlen")
	str=replace(str,match,chanpinxunhuan(Row,nr,leixing,Tlen))
	next
	Productsxunhuan=str
end function

Function chanpinxunhuan(Row,yida_cms,leixing,Tlen)
set rs = server.createobject("adodb.recordset")
sql="select top "&Row&" * from shuaiweb_products where shuaiweb_productsclass = "&leixing&" or shuaiweb_productsclass2 = "&leixing&" ORDER BY id DESC"
rs.open sql,dbok,1,1
Do While Not rs.EOF

if Language = "ch" then
 if yida_url = "asp" then
  chanpinxunhuanurl = webpath & "zh_products_view.asp?id=" & rs("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  chanpinxunhuanurl = webpath & "html/products/products_"&rs("id")&".html"
 end if
elseif Language = "en" then
 if yida_url = "asp" then
  chanpinxunhuanurl = webpath & "en_products_view.asp?id=" & rs("id")
   elseif yida_url = "html" or yida_url = "asphtml" then
  chanpinxunhuanurl = webpath & "html/en_products/products_"&rs("id")&".html"
 end if
end if

if trim(rs("shuaiweb_productsminpic")) <> "" then
 productsxiaotu = sw_dizhi & rs("shuaiweb_productsminpic")
  else
 productsxiaotu = sw_dizhi & "images/Without.gif"
end if

if trim(rs("shuaiweb_productsmaxpic")) <> "" then
 productsdatu = sw_dizhi & rs("shuaiweb_productsmaxpic")
  else
 productsdatu = sw_dizhi & "images/Without.gif"
end if

yida_cms1=replace(yida_cms,"{Products:name}",left(rs("shuaiweb_productsname"),Tlen))
yida_cms2=replace(yida_cms1,"{Products:name_color}","<font color='"&rs("wait_prer")&"'>" & left(rs("shuaiweb_productsname"),Tlen) & "</font>")
yida_cms3=replace(yida_cms2,"{Products:id}",rs("id"))
yida_cms4=replace(yida_cms3,"{Products:riqi}",FormatDate(rs("time"),4))
yida_cms5=replace(yida_cms4,"{Products:bianhao}",rs("shuaiweb_productsno"))
yida_cms6=replace(yida_cms5,"{Products:xinghao}",rs("shuaiweb_productsmodel"))
yida_cms7=replace(yida_cms6,"{Products:caizhi}",rs("wait_pryi"))
yida_cms8=replace(yida_cms7,"{Products:biaozhunjia}",rs("shuaiweb_productsbprice"))
yida_cms9=replace(yida_cms8,"{Products:youhuijia}",rs("shuaiweb_productsprice"))
yida_cms10=replace(yida_cms9,"{Products:kucunliang}",rs("shuaiweb_productsLibrary"))
yida_cms11=replace(yida_cms10,"{Products:jijiadanwei}",rs("shuaiweb_productsunits"))
yida_cms12=replace(yida_cms11,"{Products:chupingongsi}",rs("shuaiweb_productsco"))
yida_cms13=replace(yida_cms12,"{Products:xiaotu}",productsxiaotu)
yida_cms14=replace(yida_cms13,"{Products:datu}",productsdatu)
yida_cms15=replace(yida_cms14,"{Products:url}",chanpinxunhuanurl)
yida_cms16=replace(yida_cms15,"{Products:neirong}",left(RemoveHTML(rs("shuaiweb_productscontent")),30))
tt=tt+yida_cms16
			rs.movenext
		Loop
	rs.Close
	set rs=nothing
chanpinxunhuan = tt
End Function

function Productsview(a)
	products_id = cint(request("id"))
	set rs = server.createobject("adodb.recordset")
	sql="select * from shuaiweb_products WHERE id= "&products_id&""
	rs.open sql,dbok,1,3

	yidacms_tag_products = yidacms_tag_products &_ 

	(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(rs("shuaiweb_productscontent"),"{sys:weburl}",sw_dizhi),"{sys:title}",sw_webtitle),"{sys:gongsibiaoti}",co_name),"{sys:gongsidizhi}",sw_gongsidizhi),"{sys:dianhua}",sw_dianhua),"{sys:yidongdianhua}",sw_yidongdianhua),"{sys:chuanzhen}",sw_chuanzhen),"{sys:qq}",sw_qq),"{sys:lianxiren}",sw_lianxiren),"{sys:beian}",sw_beian),"{sys:youxiang}",sw_youxiang),"{sys:youbian}",sw_youbian))

        If Not(rs.bof and rs.eof) Then
        a = replace(a,"{Products:liulan}",rs("wait_prliu"))
        rs("wait_prliu") =rs("wait_prliu") +1
        Rs.UPDATE
        end if

        if trim(rs("shuaiweb_productsprice")) <> "" then
	  chanpinbiaozhunjia="<strike>"&rs("shuaiweb_productsbprice")&"</strike>"
           else
	  chanpinbiaozhunjia=rs("shuaiweb_productsbprice")     
        end if

	if trim(rs("shuaiweb_productsminpic")) <> "" then
	  chanpinxiaotu = sw_dizhi & rs("shuaiweb_productsminpic")
	   else
	  chanpinxiaotu= sw_dizhi & "images/Without.gif"
	end if

	if trim(rs("shuaiweb_productsmaxpic")) <> "" then
	  chanpindatu = sw_dizhi & rs("shuaiweb_productsmaxpic")
	   else
	  chanpindatu= sw_dizhi & "images/Without.gif"
	end if

        a = replace(a,"{Products:id}",rs("id"))
        a = replace(a,"{Products:name}",rs("shuaiweb_productsname"))
        a = replace(a,"{Products:bianhao}",rs("shuaiweb_productsno"))
        a = replace(a,"{Products:xinghao}",rs("shuaiweb_productsmodel"))
        a = replace(a,"{Products:biaozhunjia}",chanpinbiaozhunjia)
        a = replace(a,"{Products:youhuijia}",rs("shuaiweb_productsprice"))
        a = replace(a,"{Products:kucunliang}",rs("shuaiweb_productsLibrary"))
        a = replace(a,"{Products:jijiadanwei}",rs("shuaiweb_productsunits"))
        a = replace(a,"{Products:chupingongsi}",rs("shuaiweb_productsco"))
        a = replace(a,"{Products:neirong}",yidacms_tag_products)
        a = replace(a,"{Products:riqi}",FormatDate(rs("time"),4))
        a = replace(a,"{Products:caizhi}",rs("wait_pryi"))
        a = replace(a,"{Products:xiaotu}",chanpinxiaotu)
        a = replace(a,"{Products:datu}",chanpindatu)
        a = replace(a,"{yidacms:picmax1}",yidacms_picmax1())
        a = replace(a,"{yidacms:picmax2}",yidacms_picmax2())
	rs.Close
	set rs=nothing
Productsview = a
end function

	Function Products_classhtml(a)
        productsclass_id = cint(request("id"))
	if request("id") = "" then
		a = replace(a,"{Productsclass:html}"," ")
			else
		set rs = server.createobject("adodb.recordset")
		sql="select * from shuaiweb_productsclass WHERE id = "&productsclass_id&""
		rs.open sql,dbok,1,1
			if rs("shuaiweb_productshtml") = "" then
        			a = replace(a,"{Productsclass:html}","无栏目自定义html")
					else
        			a = replace(a,"{Productsclass:html}",rs("shuaiweb_productshtml"))
			end if
		rs.Close
		set rs=nothing
	end if
        Products_classhtml = a
	End Function
%>