<!--#include file="../../connshop.asp"-->
<!--#include file="../config.Inc"-->
<!--#include file="../Lebi_db_cls.asp"-->
<!--#include file="../Lebi_cache_cls.asp"-->
<!--#include file="../Lebi_cache.asp"-->
<!--#include file="../Lebi_LangInfo.asp"-->
<!--#include file="../Lebi_main.asp"-->
<!--#include file="../Lebi_function.asp"-->
<!--#include file="../Lebi_Word.asp"-->
<%
'**************************************
'* 最后更新 2012-06-08 by 56770.Kingdge
'* 历史更新 2008-6-5 by 56770.WangLei
'* Copyright www.56770.com
'**************************************
'**** Wanglei 2008-4-30 ******
'**** 浏览记录表 Lebi_lsview 添加 product_type,lsv_pic 的字段，
Dim Js_cookiesid
Js_cookiesid = CheckNum(request.cookies(cookiesname&"_user")("cookiesid"),GetUserId())
IsSearch = False 
Agent = Request.ServerVariables("HTTP_USER_AGENT") 
botlist = "Google,Isaac,Webdup,SurveyBot,Baiduspider,ia_archiver,P.Arthur,FAST-WebCrawler,Java,Microsoft-ATL-Native,TurnitinBot,WebGather,Sleipnir,Sogou web spider,JikeSpider,spider.html" 
botlist = Split(botlist, ",") 
For i = 0 To UBound(botlist) 
	If InStr(Agent, botlist(i)) > 0 Then 
		IsSearch = True 
		Exit For 
	End If
Next 
If IsSearch = True Then response.End 
Select Case request("do")
       Case "list" list()
	   Case Else
	        main()
End Select

Sub main()
		Dim rslv,rslv1,id,product_type,product_name,ranNum,userip,pic
		id = CheckNum(request("id"),0)
		product_name=SafeReplace(request("product_name"))
		product_type=SafeReplace(request("product_type"))
		pic = SafeReplace(request("pic"))
		If id<>0 Then
		set rslv = conn.execute("select * from [Lebi_lsview] where lsv_product_id="&id&" and sessionid="& Js_cookiesid &"")
		if rslv.eof Then
				conn.execute("Insert into [Lebi_lsview](lsv_product_id,lsv_product_name,lsv_sj,sessionid,product_type,lsv_pic)values("&id&",'"&product_name&"',"&sqlnowstring&","& Js_cookiesid &",'"&product_type&"','"&pic&"')")
				set rslv1 = conn.execute("select * from [Lebi_lshy] where sessionid="& Js_cookiesid &"")
						if rslv1.eof then
								conn.execute("Insert into [Lebi_lshy](sessionid,basket_date)values("& Js_cookiesid &","&sqlnowstring&")")
						else
								conn.execute("Update [Lebi_lshy] set basket_date="&sqlnowstring&" where sessionid="& Js_cookiesid &"")
						end if
				rslv1.close:Set rslv1=Nothing
		Else
				conn.execute("Update [Lebi_lsview] set lsv_sj="&sqlnowstring&",lsv_pic='"&pic&"' where lsv_product_id="&id&" and sessionid="& Js_cookiesid &"")
				conn.execute("Update [Lebi_lshy] set basket_date="&sqlnowstring&" where sessionid="& Js_cookiesid &"")
		end if
		rslv.close:set rslv=Nothing
		End If
		If product_type = "unite" Then
				conn.execute("Update [Lebi_product_unite] set views=views+1 where id="&id&"")
		Else
				conn.execute("Update [Lebi_product] set views=views+1 where id="&id&"")
		End If
End Sub

Sub list()
		Dim topnum,linenum,length,lsv,strFile,RloadstrFile(2),Temp_ProductViewHistory,List_style,Temp_list,i
		topnum = CheckNum(request("topnum"),5)
		linenum = CheckNum(request("linenum"),1)
		length = CheckNum(request("len"),10)
		LangPath = SafeReplace(request("LangPath"))
		set lsv = conn.execute("select top "& topnum &" lsv_product_name,lsv_product_id,product_type,lsv_pic,(select p_filename from [Lebi_Product] where id = lsv_product_id and product_type='') as pfilename,(select p_filename from [Lebi_Product_unite] where id = lsv_product_id and product_type='unite') as unitefilename from [Lebi_lsview] where sessionid="& Js_cookiesid &" order by lsv_sj desc")
		strFile = Eshop_url& Style_Folder &"Lebi.ProductViewHistory."
		RloadstrFile(0) = LoadStyle(strFile&"0.style")
		RloadstrFile(1) = LoadStyle(strFile&"1.style")
		RloadstrFile(2) = LoadStyle(strFile&"2.style")
		Temp_ProductViewHistory = RloadstrFile(0)
		i = 0
		do while not lsv.eof
				List_style = RloadstrFile(1)
				If lsv(2)="unite" Then
						ReplaceStyle "url",Eshop_url & LangPath & Folder(9) & lsv(5) &".1."& Sys_Ext &"",List_style
				Else
						ReplaceStyle "url",Eshop_url & LangPath & Folder(0) & lsv(4) &".1."& Sys_Ext &"",List_style
				End If
				ReplaceStyle "target",Config_Lebi_Eshop(9),List_style
				ReplaceStyle "name",cutchar(lsv(0),length),List_style
				ReplaceStyle "pic_url",Eshop_url & PicPath &"/"&lsv(3),List_style
				Temp_list = Temp_list & List_style
				lsv.movenext
				i = i + 1
		Loop
		lsv.close:set lsv = nothing
		Temp_ProductViewHistory = Temp_ProductViewHistory & Temp_list & RloadstrFile(2)
		response.write htmltojs(Temp_ProductViewHistory)
End Sub
%>