<%
'##################################################################                                                                 
'★         web08.net - 威博购物系统                                              
'★  版权所有: web08.net                                                                                                       
'★  程序制作: 威博网络技术公司                                     
'★           email:web08net@hotmail.com                           
'★            Q Q :645095280,475980829
'★	       电话:021-55520018                                                                                                         
'★  相关网址: [产品介绍] http://www.021web.com.cn/gwxt.html
'★            [支持论坛] http://bbs.web08.net/                                                                                     
'★  主页地址: http://www.web08.net/  
'★		http://www.021web.com.cn/			                                                                 
'###################################################################
%>
<%
 Function OpenRs()
	conndb
	SET rs=server.createobject("adodb.recordset")
 End Function

 Function closeRs()
	rs.close : set rs=nothing
	closedb
 End Function

 Function Web_Get_RootDir(v_dir)
	If v_dir="" then
		v_dir="/"
	elseif v_dir="/" then
		v_dir="/"
	elseif v_dir="\" then
		v_dir="/"
	Else
		if left(v_dir,1)="/" or left(v_dir,1)="\" then
			v_dir=replace(v_dir,left(v_dir,1),"")
		end if
		if right(v_dir,1)="/" or right(v_dir,1)="\" then
			v_dir=replace(v_dir,right(v_dir,1),"")
		end if
		v_dir="/"&v_dir&"/"
	End If
	Web_Get_RootDir=v_dir
 End Function

 Function Web_select_one(tabname,fldname,strwhere,strorder,ordertype)
	openrs
	sql="select "&fldname&" from "&tabname&""
	if strwhere<>"" then
		sql=sql&" where "&strwhere
	end if 
	if strorder<>"" then
		sql=sql&" order by "&strorder&" "&ordertype
	end if
	'response.write sql
	rs.open sql,conn,3,1
	web_select_one=Rs.GetRows()
	closers
 End Function 

 Function Web_DelData(tabname,strwhere)
	on error resume next
	conndb
	sql="delete from "&tabname&" where "&strwhere
	'response.write sql
	conn.execute(sql)
	if err.number<>0 then
		web_deldata="删除失败,错误描述如下：\n"&replace(err.description,"'","")
		err.clear
	else
		web_deldata="数据已删除"
	end if 
	closedb
 End Function

 Function web_l_ChkIsnull(chkvalue,numflag)
	
	rem chk this value is null
	if chkvalue="" or isnull(chkvalue)=true then 
		Web_l_ChkIsNull=true
	else
		Web_l_ChkIsNull=false
	end if

	if web_l_chkisnull=false then
		if numflag=1 then
			rem chk this value is num
			if isnumeric(chkvalue)=false then
				web_l_chkisnull=true
			end if 
		end if 
	end if

 End Function

 Function Get_style_List(Byval val)
	OpenRs()
	if session("kkshopid")<>"" then
		sql="select * from web_style where s_class='"&val&"' and shopid='"&session("kkshopid")&"' or s_used='Store' order by id asc"
		if val="" then
			sql="select * from web_style where shopid='"&session("kkshopid")&"' or s_used='Store' order by id asc"
		end if 
	else
	
		sql="select * from web_style where s_class='"&val&"'  order by id asc"
		if val="" then
			sql="select * from web_style order by id asc"
		end if 
	end if
	
	rs.open sql,conn
	if rs.eof then
		str=str&"<option value=''>没有样式</option>"
		
	else
		do while not rs.eof 
			str=str&"<option value='"&rs("onlyid")&"'>"&rs("s_name")&"</option>"
		rs.movenext
		loop
	end if
	CloseRs
	Get_style_List=str
 End Function

 Function Get_MClass_List()
	OpenRs()
	
		tablename="web_proclass"
		fldname="id,name,fid,[level],v_order"
		sql="select "&fldname&" from web_proclass where fid=0 order by v_order asc"
	
	rs.open sql,conn
	
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
		
		call nolevel_list(tablename,iRs(0,i),1)
	next

 End Function

 Function Get_MSClass_List()
	OpenRs()
	fldname="id,name,fid,[level],v_order"
	sql="select "&fldname&" from web_proclass where fid=0 order by v_order asc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 dim v_a1,v_a2,v_a3,v_a4,v_a5,v_a6,v_a7,v_a8,v_a9
 Function Get_ShopMClass_List()
	OpenRs()
	if session("kkshopid")="" then
		fldname="id,name,fid,[level],v_order"
		sql="select "&fldname&" from web_shopproclass where fid=0 and shopid='0' order by v_order asc"
	else
		fldname="id,name,fid,level,v_order"
		sql="select "&fldname&" from web_shopproclass where fid=0 and shopid='"&session("kkshopid")&"' order by v_order asc"
	end if 

	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
		call nolevel_list("web_shopproclass",iRs(0,i),1)
	next
 End Function

 Function Web_IsChecked(byval val,flag)
	If flag=0 Then
		if val=1 then
			Web_IsChecked="checked"
		else
			Web_IsChecked=""
		end if 
	ElseIf flag=1 then
		If val="" Then
			Web_IsChecked=0
		else
			Web_IsChecked=1	
		End If		
	End If
 End Function

 Function Get_AClass_List()
	OpenRs()
	
		fldname="id,name,fid,[level],v_order"
		sql="select "&fldname&" from web_Articleclass where fid=0  order by v_order asc"
	
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
		call nolevel_list("web_Articleclass",iRs(0,i),1)
	next
 End Function

 Function Get_GSClass_List()
	OpenRs()
	sql="select id,name,fid,[level] from Web_BuyClass where fid=0  order by v_order asc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
		call nolevel_list("web_Articleclass",iRs(0,i),1)
	next
 End Function

 Function Get_AAClass_List()
	OpenRs()
		fldname="id,name,fid,[level],v_order"
		sql="select "&fldname&" from web_Articleclass where fid=0  order by v_order asc"
	
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
		call nolevel_list("web_Articleclass",iRs(0,i),1)
	next
 End Function

 Function Get_GClass_List()
	OpenRs()
	if IsSqlDataBase = 1 then
		sql="select id,name,fid,level,v_order from web_Buyclass where fid=0 order by v_order asc"
	else
		sql="select id,name,fid,[level],v_order from web_Buyclass where fid=0 order by v_order asc"
	end if 
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
		call nolevel_list("web_Buyclass",iRs(0,i),1)
	next
 End Function

 Function Get_Province_List()
	OpenRs()
	sql="select id,shengname,shengorder,shengno from web_province order by shengorder asc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function Get_area_List()
	OpenRs()
	if IsSqlDataBase = 1 then
		sql="select id,name,fid,level,v_order from web_area where fid=0 order by v_order asc"
	else
		sql="select id,name,fid,[level],v_order from web_area where fid=0 order by v_order asc"
	end if 
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
		call nolevel_list("web_area",iRs(0,i),1)
	next
 End Function


 Function Get_Self_Subject(sys_id,s_flag)
	OpenRs()
	if sys_id=1 then
		'str_where=" and flag=1"
	else
		'str_where=" and flag=0"
	end if
	str_where=str_where & " and isurl=0"
	select case Ucase(s_flag)
		case "SYS":
			str_where=str_where &" and classtype=0"
		case "MS":
			str_where=str_where &" and classtype=1"
		case "GS":
			str_where=str_where &" and classtype=2"
	end select
	str_where=str_where &Web_Get_ShopSQL("shopid")
	sql="select * from web_systemsubject where 1=1 "&str_where
	response.write sql
	rs.open sql,conn
	do while not rs.eof
	 	response.write "<option value='"&rs("id")&"'>"&rs("classname")&"</option>"
	rs.movenext
	loop 
	CloseRs
 End Function

 Function Get_Label_List()
	OpenRs()
	sql="select * from web_lable where 1=1 "
	if session("kkshopid")<>"" then
		w_where=" and shopid='"&session("kkshopid")&"'"
		sql=sql&w_where
		rs.open sql,conn
		response.write "<option value='' style='background:#CCCCCC;color:000000'>----自建标签----</option>"
		do while not rs.eof
		 	name=replace(rs("l_lablename"),"web_","")
		 	name=replace(name,"{","")
		 	name=replace(name,"}","")
		 	response.write "<option value='"&rs("l_lablename")&"'>&nbsp;&nbsp;├"&name&"</option>"
		rs.movenext
		loop
		rs.close
		sql="select * from web_lable where l_used='Store'"
		rs.open sql,conn
		response.write "<option value='' style='background:#CCCCCC;color:000000'>----系统标签----</option>"
		do while not rs.eof
		 	name=replace(rs("l_lablename"),"web_","")
		 	name=replace(name,"{","")
		 	name=replace(name,"}","")
		 	response.write "<option value='"&rs("l_lablename")&"'>&nbsp;&nbsp;├"&name&"</option>"
		rs.movenext
		loop
		rs.close
	else
		set web_rs=conn.execute("select * from web_labletype where shopid='0'")
		do while not web_rs.eof 	
			response.write "<option value='' style='background:#CCCCCC;color:000000'>----"&web_rs("typename")&"----</option>"
			sql="select * from web_lable where l_type="&web_rs("id")
			rs.open sql,conn
			do while not rs.eof
			 	name=replace(rs("l_lablename"),"web_","")
			 	name=replace(name,"{","")
			 	name=replace(name,"}","")
			 	response.write "<option value='"&rs("l_lablename")&"'>&nbsp;&nbsp;├"&name&"</option>"
			rs.movenext
			loop
			rs.close
		web_rs.movenext
		loop
		web_rs.close : set web_rs=nothing
		sql="select * from web_lable where l_used='Store'"
		rs.open sql,conn
		response.write "<option value='' style='background:#CCCCCC;color:000000'>----店铺标签----</option>"
		do while not rs.eof
		 	name=replace(rs("l_lablename"),"web_","")
		 	name=replace(name,"{","")
		 	name=replace(name,"}","")
		 	response.write "<option value='"&rs("l_lablename")&"'>&nbsp;&nbsp;├"&name&"</option>"
		rs.movenext
		loop
		rs.close
	end if 
	sql="select * from web_lable where l_used='Pub'"
	rs.open sql,conn
	response.write "<option value='' style='background:#CCCCCC;color:000000'>----公用标签----</option>"
	do while not rs.eof
	 	name=replace(rs("l_lablename"),"web_","")
	 	name=replace(name,"{","")
	 	name=replace(name,"}","")
	 	response.write "<option value='"&rs("l_lablename")&"'>&nbsp;&nbsp;├"&name&"</option>"
	rs.movenext
	loop
	CloseRs
 End Function

 Function DelHeadAndEndDot(Str)
	Dim StrLen
	StrLen=Len(Str)
	if StrLen>0 then
		if instr(str,",")=1 then
			Str=right(str,StrLen-1)
		end if
		StrLen=Len(Str)
		if instrrev(str,",")=StrLen then
			Str=left(str,StrLen-1)
		end if
	end if
	DelHeadAndEndDot=Str
 End Function

 Function Web_Get_ShopSQL(shopid)
	If trim(session("kkshopid"))<>"" then
		Web_Get_ShopSQL=" and "&shopid&"='"&trim(session("kkshopid"))&"'"
	Else
		Web_Get_ShopSQL=""
	End if 
 End Function

 Function Get_shop_List()
	OpenRs()
	sql="select id,s_shopid,s_name from web_shop order by s_rank desc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&irs(1,i)&"'>├"&iRs(2,i)&"</option>"
	next
 End Function

 Function Lose_Html(w_Str)
	Dim regEx
	if Not IsNull(w_Str) Then
		w_Str=w_Str&""
		Set regEx = New RegExp
		regEx.Pattern = "<\/*[^<>]*>"
		regEx.IgnoreCase = True
		regEx.Global = True
		w_Str = regEx.Replace(w_Str,"")
		Lose_Html = w_Str
	Else
		Lose_Html=""
	End If
 End Function

 Function web_deletehtml_class(byval w_flag,byval w_id)
	
	w_id_i=split(w_id,",")
	select case ucase(w_flag)
		case "MS":
			for w_i_i=0 to ubound(w_id_i)
				call web_deletefile_class(server.mappath("../../html/category/class_"&trim(w_id_i(w_i_i))),0)
			next 
		case "MSEXT":
			for w_i_i=0 to ubound(w_id_i)
				call web_deletefile_class(server.mappath("../../html/category/class_ext_"&trim(w_id_i(w_i_i))),0)
			next 
		case "AS":
			for w_i_i=0 to ubound(w_id_i)
				call web_deletefile_class(server.mappath("../../html/as/class/class_"&trim(w_id_i(w_i_i))),0)
			next 
	end select 
 End Function

 Function web_deletefile_class(byval w_file,w_i)
	w_j=w_i	
	if w_j=0 then
		w_filename=w_file&".html"
	else
		w_filename=w_file&"_"&w_i&".html"
	end if

	Dim fso, MyFile
	Set fso = CreateObject("Scripting.FileSystemObject")
  	If (fso.FileExists(w_filename)) Then
		Set MyFile = fso.GetFile(w_filename)
		response.write w_filename&"<br>"
		MyFile.Delete 
  	Else
		exit function
  	End If
	if w_j=0 then
		w_j=2
	else
		w_j=w_j+1
	end if
	call web_deletefile_class(w_file,w_j)
 End Function

Function nolevel_tree2(tabname,id,level)
	set rec=server.createobject("adodb.recordset")
	sql="select * from "&tabname&" where fid="& id
	rec.open sql,conn
	if rec.eof then
		rec.close : set rec=nothing
		exit function
	end if
	for ii=1 to level
		name=name&"&nbsp;"
	next
	do while not rec.eof
		level=rec("level")
		namestr=name&"┝"&rec("name")
		tmplist=rec("id")&","&namestr&","&rec("v_order")&","&rec("smallpic")&","&rec("bigpic")
		v_classlist=v_classlist&"$$"&tmplist
		call nolevel_tree2(tabname,rec("id"),level)
	rec.movenext
	loop
	rec.close : set rec=nothing
	name="&nbsp;"
	nolevel_tree2=classlist
End Function

Function w_GetRootId(tabname,id)
	set ojbrss=server.createobject("adodb.recordset")
	sql="select * from "&tabname&" where id="& id
	ojbrss.open sql,conn
	fid=ojbrss("fid")
	id=ojbrss("id")
	classrootid=id

	if fid=0 then exit function
	call getrootid(tabname,fid)
	ojbrss.close : set objrss=nothing
End Function

 Function web_ImStr(str1,str2)
	str1=lcase(str1)	
	str2=lcase(str2)
	web_ImStr=iNStr(str1,str2)
 End Function

 Sub showsuccess(msg,url)
	Response.Write "<script language='javascript'>alert('" & msg & "');window.location.href='"&url&"';</script>"
	response.end 
 End Sub

 Sub showsuccess_1(msg)
	Response.Write "<script language='javascript'>alert('" & msg & "');opener.location.reload();window.close();</script>"
	response.end 
 End Sub

 Sub WriteErrMsg(errmsg)
	Response.Write "<script language='javascript'>alert('" & errmsg & "');history.go(-1);</script>"
	response.end 
 End Sub
%> 