<!--#include file="conn.asp"-->
<!--#include file="inc/cookies_check.asp"-->
<!--#include file="../include/config.inc"-->
<%
'*****************************************
'* 软件名称 乐彼网上开店软件(56770 EShop)
'* 软件开发 http://www.56770.com
'* 版权所有 http://www.56770.com
'* 文件名称 Admin_update.asp
'* 最后更新 2011-08-21 by 56770.kingdge
'*****************************************
Server.ScriptTimeout=3000
include "lang/"& LangFilePath &"/lang_sys.inc"
include "lang/"& LangFilePath &"/lang_menu.inc"
include "lang/"& LangFilePath &"/lang_sort.inc"
u_type = request("u_type")
startid = checknum(request("startid"),0)
Endid = checknum(request("endid"),200)
prev = request("prev")
If u_type = "1" Or u_type = "all" Then
		CurrentId = 1
		CurrentUrl = "admin_sort.asp"
		LB_Head()
		LB_Menu()%>
		<div class="tabmenu mainwidth">
			  <ul>
				<li><a href="admin_sort.asp"><span><%=Lang_Menu(75)%></span></a></li>
				<li><a href="admin_sort.asp?action=rate"><span><%=Lang_Sort(74)%></span></a></li>
				<li class="current"><a href="admin_update.asp?u_type=1&prev=<%=server.urlencode(Backurl())%>"><span><%=Lang_Sort(8)%></span></a></li>
				<li><a href="admin_sort.asp?action=add"><span><%=Lang_Sort(22)%></span></a></li>
				<li><a href="admin_sort.asp?action=unite"><span><%=Lang_Sort(70)%></span></a></li>
			  </ul>
		</div>
		<%
		Response.Write("<div class=""tab-mainbody"">")
		Response.Write("<div class=""tab-mainbody2"">")
		If Eshop_Lebi_name="" Then
				adminflag()
		End If 
		Set GetLast = Conn.execute("select top 1 c_id from [Lebi_category] order by c_id desc")
		If Not GetLast.eof Then
				LastId = GetLast(0)
		End If
		GetLast.close
		rem <-{检测是否有父级错乱的类别 2011-08-21 by 56770.kingdge
		Set rs = server.CreateObject("adodb.recordset")
		rs.open "select c_parentid,c_id,c_father from [Lebi_category] where (c_father = 1 and c_parentid <> 0) or c_parentid = c_id",conn,1,3
		Do While Not rs.eof 
				If rs(0) = rs(1) Then 
						rs(2) = 1
				End If 
				rs(0) = 0
				rs.update 
		rs.movenext 
		Loop
		rs.close : Set rs = Nothing
		rem }->
		Set rs = server.CreateObject("adodb.recordset")
		sql = "select c_id,c_pronum from [Lebi_category] where 1=1"
		If endid > 0 Then
				sql = sql &" and (c_id > "& startid &" and c_id < "& endid &")"
		End If
		sql = sql &" order by c_id asc"
		rs.open sql,conn,1,3
		Do While Not rs.eof
			  rem 增加sql server数据库支持 2007-3-24 by 56770.kingdge
			  If IsSqlDataBase = 1 Then
					  num1=conn.execute("select count(id) from [Lebi_product] where zhuangtai=1 and charindex(',"&rs("c_id")&",',categoryid)>0")(0)
			  Else
					  num1=conn.execute("select count(id) from [Lebi_product] where zhuangtai=1 and instr(categoryid,',"&rs("c_id")&",')>0")(0)
			  End If
			  ChildCount=conn.execute("select count(*) from [lebi_category] where c_parentid="& rs("c_id"))(0)
			  conn.execute("update Lebi_category set c_pronum = "& num1 &",c_child = "& ChildCount &" where c_id = "& rs("c_id") &"")
'					  rs("c_pronum") = num1
'					  rs.update
		rs.movenext
		Loop
		rs.close:Set rs=Nothing
		If CLng(LastId) > CLng(startid) Then
				Call Up_mes(Lang_sys(69),"·"& Replace(Lang_sys(83),"[time]",3) &"<br/>·"& Lang_sys(84) &""& endid-1 &" - "& CLng(endid) + CLng(endid) - CLng(startid) - 1 &"",0,"?u_type="& u_type &"&startid="& endid-1 &"&endid="& CLng(endid) + CLng(endid) - CLng(startid) - 1 &"&prev="& server.urlencode(prev) &"",0,0,3,1)
		Else
				If Config_Lebi_Eshop(17)="1" Then
						Application.Contents.RemoveAll
				Else
						NewEvent "0"
				End If
				Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,prev,0,0,2,1)
		End If
		Response.Write("</div>")
		Response.Write("</div>")
		LB_Footer()
End If

If u_type = "2" Or u_type = "all" Then
		CurrentId = 1
		CurrentUrl = "admin_tags.asp"
		LB_Head()
		LB_Menu()
		Response.Write("<div class=""tab-mainbody"">")
		Response.Write("<div class=""tab-mainbody2"">")
		Set GetLast = Conn.execute("select top 1 tags_id from [Lebi_tags] order by tags_id desc")
		If Not GetLast.eof Then
				LastId = GetLast(0)
		End If
		GetLast.close
		Set rs = server.CreateObject("adodb.recordset")
		sql = "select tags_id,tags_name,tags_num from [Lebi_tags] where 1=1"
		If endid > 0 Then
				sql = sql &" and (tags_id > "& startid &" and tags_id < "& endid &")"
		End If
		sql = sql &" order by tags_id asc"
		rs.open sql,conn,1,3
		Do While Not rs.eof
				If IsSqlDataBase = 1 Then
						Tags_count = conn.execute("select count(id) from [Lebi_product] where charindex('"& rs("tags_name") &"',p_tags)>0")(0)
				Else
						Tags_count = conn.execute("select count(id) from [Lebi_product] where instr(p_tags,'"& rs("tags_name") &"')>0")(0)
				End If
				rs("tags_num") = Tags_count
				rs.update
		rs.movenext
		Loop
		rs.close:Set rs=Nothing
		If CLng(LastId) > CLng(startid) Then
				Call Up_mes(Lang_sys(69),"·"& Replace(Lang_sys(83),"[time]",3) &"<br/>·"& Lang_sys(84) &""& endid-1 &" - "& CLng(endid) + CLng(endid) - CLng(startid) - 1 &"",0,"?u_type="& u_type &"&startid="& endid-1 &"&endid="& CLng(endid) + CLng(endid) - CLng(startid) - 1 &"&prev="& server.urlencode(prev) &"",0,0,3,1)
		Else
				Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,prev,0,0,2,1)
		End If
		Response.Write("</div>")
		Response.Write("</div>")
		LB_Footer()
End If
If u_type = "3" Or u_type = "all" Then
		Set rs = conn.execute("select a_id,a_date,a_days from [Lebi_ad] where a_state = 1")
		If Not rs.eof Then
				Do While Not rs.eof
				If rs("a_days") > 0 Then
						conn.execute("update [Lebi_ad] set a_state=0 where (a_date+a_days)<"& sqlnowstring &" and a_id = "& rs("a_id") &"")
				End If
				rs.movenext
				Loop
		End If
		rs.close:Set rs=Nothing
		If Config_Lebi_Eshop(17)="1" Then
				Application.Contents.RemoveAll
		Else
				NewEvent "0"
		End If
		Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,"javascript:history.back()",0,0,2,1)
End If
%>