<%
'**************************************
'* 最后更新 2012-06-18 by 56770.kingdge
'* Copyright www.56770.com
'*************************************
Dim Thisurl,weburl,recom,sale,category,title,sql,product_url,product_price,showpic_width,showpic_height
response.charset = "UTF-8"
Response.contentType = "application/xml"
Response.Expires = 0
Response.Write("<?xml version=""1.0"" encoding=""UTF-8""?>")
If request.ServerVariables("SERVER_PORT") <> "80" Then
		Thisurl = "http://"&Request.ServerVariables("SERVER_NAME") &":"& request.ServerVariables("SERVER_PORT") & Eshop_url
Else
		Thisurl = "http://"&Request.ServerVariables("SERVER_NAME") & Eshop_url
End If
Function Getcategory(id)
         Set category = conn.execute("select c_name"& LangTxt &" from [Lebi_category] where c_id = "& id &"")
		 If category.eof Then
		         Getcategory = "分类不详"
		 Else
				 If Not IsNull(category(0)) Then 
						Getcategory = Replace(category(0),"&","/")
				 End If 
		 End If
		 category.close : Set category = Nothing
End Function
Function GetEnweekdayname(str)
         Select Case str
		        Case "1" : GetEnweekdayname = "Mon"
				Case "2" : GetEnweekdayname = "Tue"
				Case "3" : GetEnweekdayname = "Wed"
				Case "4" : GetEnweekdayname = "Thu"
				Case "5" : GetEnweekdayname = "Fri"
				Case "6" : GetEnweekdayname = "Sat"
				Case "7" : GetEnweekdayname = "Sun"
		 End Select
End Function
Function GetEnmonthname(str)
         Select Case str
		        Case "1" : GetEnmonthname = "Jan"
				Case "2" : GetEnmonthname = "Feb"
				Case "3" : GetEnmonthname = "Mar"
				Case "4" : GetEnmonthname = "Apr"
				Case "5" : GetEnmonthname = "May"
				Case "6" : GetEnmonthname = "Jun"
				Case "7" : GetEnmonthname = "Jul"
				Case "8" : GetEnmonthname = "Aug"
				Case "9" : GetEnmonthname = "Sep"
				Case "10" : GetEnmonthname = "Oct"
				Case "11" : GetEnmonthname = "Nov"
				Case "12" : GetEnmonthname = "Dec"
		 End Select
End Function
Function Changetime(str)
         Dim strday,strhour,strMinute,strSecond
         strday = Day(str)
		 If Len(strday) = 1 Then strday = "0"& strday
         strhour = hour(str)
		 If Len(strhour) = 1 Then strhour = "0"& strhour
         strMinute = Minute(str)
		 If Len(strMinute) = 1 Then strMinute = "0"& strMinute
         strSecond = Day(str)
		 If Len(strSecond) = 1 Then strSecond = "0"& strSecond
         Changetime = GetEnweekdayname(weekday(str)) &", "& strday &" "& GetEnmonthname(Month(str)) &" "& Year(str) &" "& strhour &":"& strMinute &":"& strSecond &" GMT"
End Function
sort_id = checknum(request("sort_id"),0)
If sort_id = 0 Then '兼容c_id
		sort_id = checknum(request("c_id"),0)
End If
recom = checknum(request("recom"),0)
sale = checknum(request("sale"),0)
If sort_id <> 0 Then title = Getcategory(sort_id) &" - "
If sale <> 0 Then title = title & Lebi_word(16) &" - "
If recom <> 0 Then title = title & Lebi_word(15) &" - "
%>
<rss version="2.0">
  <channel>
    <title><%= title & site_name %></title>
    <link><%= Thisurl %></link>
    <description><%= Replace(trim(Sys_description),chr(13),"") %></description>
    <language>ZH-CN</language>
    <generator>56770.com</generator>
    <webMaster>56770.com</webMaster>
	<%
	  sql = "select top 50 p.product_name"& LangTxt &",p.id,p.sj,p.briefed"& LangTxt &",p.cx,s.price as price,p.cprice,p.pic,p.pic_size,p.p_filename from [Lebi_product] as p,[Lebi_product_price] as s where s.product_id=p.id and s.grade_id="&Lebi_UserGrade
      if sort_id<>"0" And IsSqlDataBase =1 then sql=sql+" and CharIndex(',"& sort_id &",',p.categoryid)>0"
	  if sort_id<>"0" And IsSqlDataBase =0 then sql=sql+" and instr(p.categoryid,',"& sort_id &",')>0"
	  If recom <> 0 Then sql = sql &" and (p.stj = 1 or p.ytj =1)"
	  If sale <> 0 Then sql = sql &" and p.cx = 1"
	  sql = sql &" order by p.p_order desc,p.id desc"
	  Set rs=conn.execute(sql)
	  If rs.eof Then
	         response.write"<item>No Data</item>"
	  Else
	         Do While Not rs.eof
		     Select Case show_html
                    Case "0"
						Select Case ISAPI_Rewrite
							   Case "0" product_url = PagePath(10) &"?id="& rs(1)
							   Case "1" product_url = LangPath &"product-"& rs(1) &".html"
						End Select
		            Case "1" : product_url = LangPath & Folder(0) & rs(9) &".1."& Sys_Ext
		     End Select
			 Select Case rs(4)
			        Case "0" : product_price = rs(5)
					Case "1" : product_price = rs(6)
			 End Select
			 rem 兼容其他阅读器 在描述中写入产品小图
			 response.write"<image>"&vbcrlf
			 response.write"<title>"& Trim(rs(0)) &" - "& dw & formatnumber2(product_price) & dw2 &"</title>"&vbcrlf
			 response.write"<url>"& Thisurl & PicturePath & rs(7) &"</url>"&vbcrlf
			 response.write"<link>"& Thisurl & product_url &"</link>"&vbcrlf
			 response.write"<width>"& showpic_width &"</width>"&vbcrlf
			 response.write"<height>"& showpic_height &"</height>"&vbcrlf
			 response.write"</image>"&vbcrlf
			 response.write"<item>"&vbcrlf
			 response.write"<title>"& Trim(rs(0)) &" - "& dw & formatnumber2(product_price) & dw2 &"</title>"&vbcrlf
			 response.write"<link>"& Thisurl & product_url &"</link>"&vbcrlf
			 response.write"<pubDate>"& Changetime(rs(2)) &"</pubDate>"&vbcrlf
			 response.write"<description><![CDATA[<div style=""vertical-align:middle;width:"& Upload_SPicWidth+8 &"px;height:"& Upload_SPicHeight+8 &"px;border:1px solid #f2f2f2;float:left;""><a href="""& Thisurl & product_url &"""><img src="""& Thisurl & PicturePath & rs(7) &""" width="""& Upload_SPicWidth &""" height="""& Upload_SPicHeight &""" border=""0"" alt="""& Trim(rs(0)) &"""></a></div><div style=""padding-left:10px;"">"& rs(3) &"</div>]]></description>"
			 response.write"</item>"
	         rs.movenext
			 Loop
	  End If
	  rs.close:Set rs=Nothing
     %>
  </channel>
</rss>