<!--#include file="conn.asp"-->
<!--#include file="inc/cookies_check.asp"-->
<!--#include file="inc/Page_cls.asp"-->
<!--#include file="inc/asptar.asp"-->
<!--#include file="../include/Lebi_XML_Cls.asp"-->
<!--#include file="../include/config.inc"-->
<%
'*****************************************
'* 软件名称 乐彼网上开店软件(56770 EShop)
'* 软件开发 http://www.56770.com
'* 版权所有 http://www.56770.com
'* 文件名称 Admin_adv.asp
'* 最后更新 2012-11-25 by 56770.kingdge
'*****************************************
Dim admin_flag
admin_flag=",8.13,"
include "lang/"& LangFilePath &"/lang_sys.inc"
include "lang/"& LangFilePath &"/lang_menu.inc"
include "lang/"& LangFilePath &"/lang_adv.inc"
CurrentId = 5
CurrentUrl = "admin_gug.asp"
LB_Head()
LB_Menu()
action = request("action")
%>
<div class="tabmenu mainwidth">
	  <ul>
		<li><a href="Admin_gug.asp"><span><%=Lang_Menu(141)%></span></a></li>
		<li <%If action = "" Or action = "code" Or action = "edit" Then Response.Write("class=""current""") End If%>><a href="Admin_adv.asp"><span><%=Lang_Menu(142)%></span></a></li>
		<li <%If action = "ducting" Or action = "ducting_ok" Then Response.Write("class=""current""") End If%>><a href="?action=ducting"><span><%=Lang_Adv(61)%></span></a></li>
		<li <%If action = "add" Or action = "add_ok" Then Response.Write("class=""current""") End If%>><a href="?action=add"><span><%=Lang_Adv(7)%></span></a></li>
	  </ul>
</div>
<%
Response.Write("<div class=""tab-mainbody"">")
Response.Write("<div class=""tab-mainbody2"">")
If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
        adminflag()
Else
		If OutSubmit = 1 Then CheckOutSubmit()
        Select Case action
		       Case "add" : add()
			   Case "add_ok" : add_ok()
			   Case "edit" : edit()
			   Case "edit_ok" : edit_ok()
			   Case "del" : del()
			   Case "list" : list()
			   Case "code" : showcode()
			   Case "update" : update()
			   Case "lead" : lead()
			   case "ducting" : ducting()
			   Case Else
			        list()
		End Select
End If
Response.Write("</div>")
Response.Write("</div>")
LB_Footer()

Sub del()
        If OnlyRead = 1 Then OnlyReadMessage()
        '删除图片
		On Error Resume Next
        del_id= Replace(safereplace(Trim(request("id"))),"，",",")
		If Right(del_id,1) = "," Then del_id = Left(del_id,Len(del_id)-1)
        if del_id="" then
                response.write"<SCRIPT language=JavaScript>alert('"& Lang_sys(41) &"');javascript:history.go(-1)</SCRIPT>"
                response.end
        end If
		set rs=server.createobject("adodb.recordset")
		sql="select a_pic,a_tag from [Lebi_Ad] where a_id in ("& del_id &") "
		rs.open sql, conn, 1, 3
		Do While Not rs.eof
				path= server.MapPath("../"& rs(0))
				jspath= server.MapPath("../include/lebi_html/SiteRandAdv-"& rs(1) &".js")
				set objfso = server.createobject("scripting.FileSystemObject")
				if objfso.FileExists(path) Then
						Set checkdel = conn.execute("select a_id from [Lebi_Ad] where a_pic = '"& rs(0) &"' and a_id not in("& del_id &")")
						If checkdel.eof Then 
							response.write "111"
							response.End 
							objfso.DeleteFile(path)
						End If 
						checkdel.close : Set checkdel = Nothing 
				End If
				if objfso.FileExists(jspath) then
						objfso.DeleteFile(jspath)
				End If
				rs.delete
				rs.update
				set objfso = nothing
		rs.movenext
		loop
		rs.close : Set rs = Nothing
		If Config_Lebi_Eshop(17)="1" Then
				Application.Contents.RemoveAll
		Else
				NewEvent "0"
		End If
		ManageLog Lang_Adv(1)
	    m_t=Lang_sys(43)
        m_s="·"& Lang_sys(42)
        m_u="?a_type="& request("a_type") &"&category="& request("category") &"&state="& request("state") &"&keyword="& request("keyword") &"&pagenum="& request("pagenum") &"&page="& request("page")
		m_time="2"
        Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
End Sub

Sub add_ok()
        If OnlyRead = 1 Then OnlyReadMessage()
        a_tag=Safereplace(Trim(request("a_tag")))
        a_info=Safereplace(Trim(request("a_info")))
		a_fontcolor=Safereplace(Trim(request("a_fontcolor")))
        a_pic=Safereplace(Trim(request("a_pic")))
		a_url=replace(Trim(request("a_url")),"'","&#180;")
        a_width=CheckNum(Trim(request("a_width")),0)
        a_height=CheckNum(Trim(request("a_height")),0)
		a_size = a_width &"|"& a_height
		a_type = CheckNum(request("a_type"),0)
		a_state = CheckNum(request("a_state"),0)
		a_category = safereplace(Replace(request("a_category")," ",""))
        a_hits=CheckNum(Trim(request("a_hits")),0)
        a_days=CheckNum(Trim(request("a_days")),0)
		If a_tag = "" Then
		        Iserror = 1
				Err_msg = Err_msg &"·"& Lang_Adv(2) &"<br>"
		End If
		Set rs = conn.execute("select a_tag from Lebi_Ad where a_tag = '"& a_tag &"'")
		If Not rs.eof Then
		        Iserror = 1
				Err_msg = Err_msg &"·"& Lang_Adv(3) &"<br>"
		End If
		rs.close : Set rs = Nothing
		If a_info = "" And a_pic = "" Then
		        Iserror = 1
				Err_msg = Err_msg &"·"& Lang_Adv(4) &"<br>"
		End If
'		If a_category = "" Then
'		        Iserror = 1
'				Err_msg = Err_msg &"·"& Lang_Adv(5) &"<br>"
'		End If
		If Len(a_category)>255 Then
		        Iserror = 1
				Err_msg = Err_msg &"·"& Lang_Adv(6) &"<br>"
		End If
        If Iserror = 1 Then
	            m_t=Lang_sys(46)
                m_s=Err_msg
                m_u="javascript:history.back()"
	            m_time="2"
                Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,0)
		Else
		        set rs=server.createobject("adodb.recordset")
		        sql="select * from [Lebi_Ad]"
		        rs.open sql, conn, 1, 3
		        rs.addnew
				rs("a_tag") = a_tag
		        rs("a_info") = a_info
		        rs("a_fontcolor") = a_fontcolor
		        rs("a_pic") = a_pic
		        rs("a_url") = a_url
		        rs("a_size") = a_size
		        rs("a_category") = a_category
				rs("a_type") = a_type
				rs("a_state") = a_state
				rs("a_hits") = a_hits
				rs("a_days") = a_days
				rs("a_date") = Date()
		        rs.update
		        rs.close:set rs=Nothing
				If Config_Lebi_Eshop(17)="1" Then
						Application.Contents.RemoveAll
				Else
						NewEvent "0"
				End If
				ManageLog Lang_Adv(7) & a_info
				If a_days = 0 Then 
						enddate = "2099-12-30"
				Else
						enddate = Date() + a_days
				End If 
				Call SavaAdvJs(a_tag,a_width,a_height,a_pic,a_url,a_info,a_fontcolor,enddate,a_type,a_state)
	            m_t=Lang_sys(45)
                m_s="·"& Lang_sys(44)
                m_u="?"
	            m_time="2"
                Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
		End If
End Sub

Sub edit_ok()
        If OnlyRead = 1 Then OnlyReadMessage()
        id = CheckNum(request("id"),0)
        a_tag=Safereplace(Trim(request("a_tag")))
        a_info=Safereplace(Trim(request("a_info")))
		a_fontcolor=Safereplace(Trim(request("a_fontcolor")))
        a_pic=Safereplace(Trim(request("a_pic")))
		a_url=replace(Trim(request("a_url")),"'","&#180;")
        a_width=CheckNum(Trim(request("a_width")),0)
        a_height=CheckNum(Trim(request("a_height")),0)
		a_size = a_width &"|"& a_height
		a_type = CheckNum(request("a_type"),0)
		a_state = CheckNum(request("a_state"),0)
		a_category = safereplace(Replace(request("a_category")," ",""))
        a_hits=CheckNum(Trim(request("a_hits")),0)
        a_days=CheckNum(Trim(request("a_days")),0)
		If a_tag = "" Then
		        Iserror = 1
				Err_msg = Err_msg &"·"& Lang_Adv(2) &"<br>"
		End If
		Set rs = conn.execute("select a_tag from Lebi_Ad where a_tag = '"& a_tag &"' and a_id <> "& id &"")
		If Not rs.eof Then
		        Iserror = 1
				Err_msg = Err_msg &"·"& Lang_Adv(3) &"<br>"
		End If
		rs.close : Set rs = Nothing
		If a_info = "" And a_pic = "" Then
		        Iserror = 1
				Err_msg = Err_msg &"·"& Lang_Adv(4) &"<br>"
		End If
'		If a_category = "" Then
'		        Iserror = 1
'				Err_msg = Err_msg &"·"& Lang_Adv(5) &"<br>"
'		End If
		If Len(a_category)>255 Then
		        Iserror = 1
				Err_msg = Err_msg &"·"& Lang_Adv(6) &"<br>"
		End If
        If Iserror = 1 Then
	            m_t=Lang_sys(46)
                m_s=Err_msg
                m_u="javascript:history.back()"
	            m_time="2"
                Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,0)
		Else
		        set rs=server.createobject("adodb.recordset")
		        sql="select * from [Lebi_Ad] where a_id = "& id &""
		        rs.open sql, conn, 1, 3
				rs("a_tag") = a_tag
		        rs("a_info") = a_info
		        rs("a_fontcolor") = a_fontcolor
		        rs("a_pic") = a_pic
		        rs("a_url") = a_url
		        rs("a_size") = a_size
		        rs("a_category") = a_category
				rs("a_type") = a_type
				rs("a_state") = a_state
				rs("a_hits") = a_hits
				rs("a_days") = a_days
		        rs.update
		        rs.close:set rs=Nothing
				If Config_Lebi_Eshop(17)="1" Then
						Application.Contents.RemoveAll
				Else
						NewEvent "0"
				End If
				ManageLog Lang_Adv(8) & a_tag
				If a_days = 0 Then 
						enddate = "2099-12-30"
				Else
						enddate = Date() + a_days
				End If 
				Call SavaAdvJs(a_tag,a_width,a_height,a_pic,a_url,a_info,a_fontcolor,enddate,a_type,a_state)
	            m_t=Lang_sys(48)
                m_s="·"& Lang_sys(47)
                m_u="?category="& request("category") &""
	            m_time="2"
                Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
		End If
End Sub

Sub lead()
        If OnlyRead = 1 Then OnlyReadMessage()
		On Error Resume Next
		i = 0
		Randomize
		RanNum = Int(90000000*rnd)+10000000
        id= Replace(safereplace(Trim(request("id"))),"，",",")
		If Right(id,1) = "," Then id = Left(id,Len(id)-1)
        if id="" then
                response.write"<SCRIPT language=JavaScript>alert('"& Lang_Adv(58) &"');javascript:history.go(-1)</SCRIPT>"
                response.end
        end If
		set fs=server.createobject("scripting.filesystemobject")
		if fs.folderexists(server.mappath("../pic/gg/temp/")) = False Then 
			fs.createfolder(server.mappath("../pic/gg/temp/"))
		end If
		if fs.folderexists(server.mappath("../pic/gg/temp/pic/")) = False Then 
			fs.createfolder(server.mappath("../pic/gg/temp/pic/"))
		end If
		if fs.folderexists(server.mappath("../pic/gg/temp/pic/gg/")) = False Then 
			fs.createfolder(server.mappath("../pic/gg/temp/pic/gg/"))
		end if		
		Set LB_XML = new ASPXML
		Temp = "<?xml version=""1.0"" encoding=""utf-8""?>"& vbcrlf
		Temp = Temp & "<data>"& vbcrlf
		set rs=server.createobject("adodb.recordset")
		sql="select a_pic,a_tag,a_info,a_fontcolor,a_url,a_type,a_size,a_state,a_hits,a_days,a_date from [Lebi_Ad] where a_id in ("& id &") "
		rs.open sql, conn, 1, 3
		Do While Not rs.eof
				If InStr(rs(0),"pic/gg/") > 0 Then 
					Call CopyFiles(server.mappath("../"& rs(0)),server.mappath("../pic/gg/temp/"& rs(0)))
				End If 
				Temp = Temp & "<adv>"& vbcrlf
				Temp = Temp & "<ID>"& i &"</ID>"& vbcrlf
				Temp = Temp & "<a_tag>"& rs(1) &"</a_tag>"& vbcrlf
				Temp = Temp & "<a_pic>"& rs(0) &"</a_pic>"& vbcrlf
				Temp = Temp & "<a_info>"& rs(2) &"</a_info>"& vbcrlf
				Temp = Temp & "<a_fontcolor>"& rs(3) &"</a_fontcolor>"& vbcrlf
				Temp = Temp & "<a_url>"& rs(4) &"</a_url>"& vbcrlf
				Temp = Temp & "<a_type>"& rs(5) &"</a_type>"& vbcrlf
				Temp = Temp & "<a_size>"& rs(6) &"</a_size>"& vbcrlf
				Temp = Temp & "<a_state>"& rs(7) &"</a_state>"& vbcrlf
				Temp = Temp & "<a_hits>"& rs(8) &"</a_hits>"& vbcrlf
				Temp = Temp & "<a_days>"& rs(9) &"</a_days>"& vbcrlf
				Temp = Temp & "<a_date>"& rs(10) &"</a_date>"& vbcrlf
				Temp = Temp & "</adv>"& vbcrlf
				i = i + 1
		rs.movenext
		Loop
		rs.close : Set rs = Nothing
		Temp = Temp & "</data>"
		Savehtml "../pic/gg/temp/pic/gg/data.xml",Temp
		Set objTar = New Tarball
		objTar.TarFilename= "temp.rar"
		objTar.Path="../pic/gg/temp"
		objtar.pack(1)
		set objtar = Nothing
		Call CopyFiles(server.mappath("../pic/gg/temp/temp.rar"),server.mappath("../pic/gg/"& RanNum &".rar"))
		fs.DeleteFile(server.MapPath("../pic/gg/temp/temp.rar"))
		fs.DeleteFolder(server.MapPath("../pic/gg/temp/pic/gg/"))
		Set fs = Nothing 
		ManageLog Lang_Adv(60)
	    m_t=Lang_Adv(60)
        m_s="·"& Lang_Adv(59)
        m_u="?page="& request("page") &"&file=../pic/gg/"& RanNum &".rar"
		m_time="2"
        Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
End Sub 

Sub ducting()
		If OnlyRead = 1 Then OnlyReadMessage()
		On Error resume Next 
		set fs=server.createobject("scripting.filesystemobject")
		if fs.fileexists(Server.MapPath("../pic/gg/data.xml")) = False Then 
			Call Up_mes(Lang_Adv(61),"·"& Lang_Adv(62),0,"javascript:history.back();",0,0,2,0)
		end If
		Set fs = Nothing 
		Set objXML = Server.CreateObject("Microsoft.XMLDOM") 
		objXML.load(Server.MapPath("../pic/gg/data.xml"))
		set mydoms = objXML.getElementsByTagName("adv")
		For i = 0 To mydoms.length-1
		        set rs=server.createobject("adodb.recordset")
		        sql="select * from [Lebi_Ad] where a_tag = '"& safereplace(mydoms(i).selectSingleNode("a_tag").Text) &"'"
		        rs.open sql, conn, 1, 3
				If rs.eof Then 
					rs.addnew()
					rs("a_tag") = safereplace(mydoms(i).selectSingleNode("a_tag").Text)
				End If 
		        rs("a_info") = safereplace(mydoms(i).selectSingleNode("a_info").Text)
		        rs("a_fontcolor") = safereplace(mydoms(i).selectSingleNode("a_fontcolor").Text)
		        rs("a_pic") = safereplace(mydoms(i).selectSingleNode("a_pic").Text)
		        rs("a_url") = safereplace(mydoms(i).selectSingleNode("a_url").Text)
		        rs("a_size") = safereplace(mydoms(i).selectSingleNode("a_size").Text)
		        rs("a_category") = safereplace(mydoms(i).selectSingleNode("a_category").Text)
				rs("a_type") = safereplace(mydoms(i).selectSingleNode("a_type").Text)
				rs("a_state") = safereplace(mydoms(i).selectSingleNode("a_state").Text)
				rs("a_hits") = safereplace(mydoms(i).selectSingleNode("a_hits").Text)
				rs("a_days") = safereplace(mydoms(i).selectSingleNode("a_days").Text)
		        rs.update
		        rs.close:set rs=Nothing
		Next 
		ManageLog Lang_Adv(61)
	    m_t=Lang_Adv(61)
        Call Up_mes(Lang_Adv(61),"·"& Lang_Adv(63),0,"?action=update",0,0,2,1)
End Sub 

Sub update()
        If OnlyRead = 1 Then OnlyReadMessage()
		set rs = conn.execute("select * from [Lebi_Ad]")
		Do While Not rs.eof 
		If rs("a_days") = 0 Then 
				enddate = "2099-12-30"
		Else
				enddate = Date() + rs("a_days")
		End If 
		Call SavaAdvJs(rs("a_tag"),Split(rs("a_size"),"|")(0),Split(rs("a_size"),"|")(1),rs("a_pic"),rs("a_url"),rs("a_info"),rs("a_fontcolor"),enddate,rs("a_type"),rs("a_state"))
		rs.movenext 
		Loop 
		rs.close:set rs=Nothing
		Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,"?",0,0,2,1)
End Sub

Sub add()
%>
<script language="javascript" src="inc/js/dialog.js"></script>
<script language="javascript" src="Upfile/js/Upload_Other.js"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="classtable" class="classtable">
<form name="sort_gug_add" method="post" action="?">
<tr>
	<td height="30" align="left" colspan="2" class="classhead"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" border="0" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle"><input type="hidden" name="action" value="add_ok"></td>
	<td height="30" align="right" class="classhead">
	<%=QuickMenu("Admin_adv.asp|"& Lang_Menu(142) &"","Admin_footer.asp|"& Lang_Menu(143) &"")%>
	</td>
 </tr>
  <tr>
     <td height="30" colspan="3" class="classtop"><%=Lang_Adv(7)%></td>
  </tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Adv(9)%></td>
<td class="classrow"><input name="a_tag" id="a_tag" type="text" size="40" maxlength="20" class="form">
</td>
<td class="classrow" rowspan="9">
<div style="width:100%;border-left:#CCC 1px solid;background:#FAFAFA;text-align:center">
<%=Lang_Adv(10)%><br /><select name="a_category" id="a_category" size="18" multiple="multiple" style="width:200px;" id="b_class">
<option value="a"><%=Lang_Adv(13)%></option>
<option value="b"><%=Lang_Adv(14)%></option>
<% check_sort (0),ii,0 %></select>
</div>
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(11)%></td>
<td class="classrow"><input name="a_info" id="a_info" type="text" size="40" maxlength="100" class="form"> <%=Lang_Adv(12)%><input id="a_fontcolor" name="a_fontcolor" type="text" size="7" class="form"> <img id="s_a_fontcolor" border="0" src="Images/rect.gif" width="18" align="absmiddle" style="cursor:pointer" onclick="colorcd('sort_gug_add','a_fontcolor','a_fontcolor')">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(15)%></td>
<td class="classrow"><input name="a_url" id="a_url" type="text" size="40" class="form">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(16)%></td>
<td class="classrow"><input id="a_pic" name="a_pic" type="text" size="20" class="form"> <input type="button" id="Upload_a_pic" name="Submit" value="<%=Lang_sys(52)%>" onclick="uploadpanel('sort_gug_add','a_pic','gg')" class="btn_upload">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(17)%></td>
<td class="classrow"><%=Lang_Adv(18)%><input name="a_width" id="a_width" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');" class="form" style="width:40px;">  <%=Lang_Adv(19)%><input name="a_height" id="a_height" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');" class="form" style="width:40px;">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(20)%></td>
<td class="classrow"><select name="a_type" id="a_type">
<option value="1"><%=Lang_Adv(21)%></option>
<option value="0"><%=Lang_Adv(22)%></option>
<option value="2"><%=Lang_Adv(23)%></option>
</select>
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(24)%></td>
<td class="classrow"><input name="a_hits" id="a_hits" type="text" size="5" class="form" value="0">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(25)%></td>
<td class="classrow"><input name="a_days" id="a_days" type="text" size="5" class="form" value="0"> <%=Lang_Adv(26)%>
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(27)%></td>
<td class="classrow"><select name="a_state" id="a_state">
<option value="1"><%=Lang_Adv(28)%></option>
<option value="0"><%=Lang_Adv(29)%></option>
</select>
</td>
</tr>
<tr>
<td class="classfooter" colspan="3" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" border="0" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
</td>
</tr>
</form>
<tr>
<td colspan="3" class="classfaq">
  <div class="faq_main">
  <p class="faq_title"><%=Lang_sys(49)%></p>
   <%=Lang_Adv(30)%>
   </div>
</td>
</tr>
</table>
<script>tdshow("classtable");</script>
<%
End Sub

Sub list()
		file = request("file")
		If file <> "" Then 
				Response.write("<iframe src="""& file &""" width=""0"" height=""0""></iframe>")
		End If 
		category = safereplace(request("category"))
		a_type = safereplace(request("a_type"))
		state = safereplace(request("state"))
		page = checknum(request("page"),1)
		pagenum = CheckNum(request("pagenum"),15)
		keyword = safereplace(Trim(request("keyword")))
		Dim ors
		Set ors=new Cls_vbsPage
		Set ors.Conn=conn
		With ors
		.PageSize=pagenum
		.PageName="Page"
		If IsSqlDataBase = 0 Then
				.DbType="AC"
		Else
				.DbType="MSSQL"
		End If
		.RecType=-1
		.Pkey="a_id"
		.Field="a_id,a_tag,a_info,a_fontcolor,a_url,a_type,a_pic,a_size,a_state,a_hits,a_days,a_date"
		.Table="[Lebi_Ad]"
		sql = "1=1"
		If category = "0" And IsSqlDataBase ="1" Then sql = sql &" and charindex('a',a_category)>0"
		If category = "0" And IsSqlDataBase ="0" Then sql = sql &" and instr(a_category,'a')>0"
		If category = "1" And IsSqlDataBase ="1" Then sql = sql &" and (charindex('0',a_category)>0 or charindex('1',a_category)>0 or charindex('2',a_category)>0 or charindex('3',a_category)>0 or charindex('4',a_category)>0 or charindex('5',a_category)>0 or charindex('6',a_category)>0 or charindex('7',a_category)>0 or charindex('8',a_category)>0 or charindex('9',a_category)>0)"
		If category = "1" And IsSqlDataBase ="0" Then sql = sql &" and (instr(a_category,'0')>0 or instr(a_category,'1')>0 or instr(a_category,'2')>0 or instr(a_category,'3')>0 or instr(a_category,'4')>0 or instr(a_category,'5')>0 or instr(a_category,'6')>0 or instr(a_category,'7')>0 or instr(a_category,'8')>0 or instr(a_category,'9')>0)"
		If category = "2" And IsSqlDataBase ="1" Then sql = sql &" and charindex('b',a_category)>0"
		If category = "2" And IsSqlDataBase ="0" Then sql = sql &" and instr(a_category,'b')>0"
		If a_type <> "" Then sql = sql &" and a_type = "& CLng(a_type) &""
		If state <> "" Then sql = sql &" and a_state = "& CLng(state) &""
		If keyword <> "" Then sql = sql &" and (a_tag like '%"& keyword &"%' or a_info like '%"& keyword &"%')"
		.Condition=sql
		.OrderBy="a_id desc"
		End With
		DataCount=ors.RecCount()
		DataList=ors.ResultSet()
%>
<script language="javascript" src="inc/js/js_link.js"></script>
<script language="javascript">
function tolead()
{
   var i = 0;
   var chkArr = document.getElementsByTagName("input");
   var page = document.getElementById("page").value;
   var a_type = document.getElementById("a_type").value;
   var keyword = document.getElementById("keyword").value;
   var category = document.getElementById("category").value;
   var state = document.getElementById("state").value;
   var pagenum = document.getElementById("pagenum").value;
   var param = "";
   for (i=0;i<chkArr.length;i++)
   if (chkArr[i].checked)
   param+=chkArr[i].value +",";
   if (param.length == 0)
   {
       alert("<%=Lang_Adv(58)%>");
   }else{
       document.location.href="?action=lead&id="+param+"&keyword="+escape(keyword)+"&a_type="+a_type+"&category="+category+"&state="+state+"&pagenum="+pagenum+"&page="+page;
   }
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable-top">
<tbody>
<tr>
<form method="get" action="?">
<td height="30" align="left" class="classhead">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<select name="a_type" id="a_type">
<option value="" selected>┌ <%=Lang_Adv(31)%></option>
<option value="0" <%=judge2("0",a_type)%>>├ <%=Lang_Adv(22)%></option>
<option value="1" <%=judge2("1",a_type)%>>├ <%=Lang_Adv(21)%></option>
<option value="2" <%=judge2("2",a_type)%>>├ <%=Lang_Adv(23)%></option>
</select>
<select name="category" id="category">
<option value="" selected>┌ <%=Lang_Adv(32)%></option>
<option value="0" <%=judge2("0",category)%>>├ <%=Lang_Adv(13)%></option>
<option value="1" <%=judge2("1",category)%>>├ <%=Lang_Adv(34)%></option>
<option value="2" <%=judge2("2",category)%>>├ <%=Lang_Adv(14)%></option>
</select>
<select name="state" id="state">
<option value="" selected>┌ <%=Lang_Adv(33)%></option>
<option value="0" <%=judge2("0",state)%>>├ <%=Lang_Adv(29)%></option>
<option value="1" <%=judge2("1",state)%>>├ <%=Lang_Adv(28)%></option>
</select></td>
<td style="padding-left:5px;"><input name="keyword" id="keyword" type="text" class="form_query" size="15"><input name="Submit" type="submit" value="" title="<%=Lang_sys(25)%>" align="absmiddle" class="btn_query"><input type="hidden" name="action" value="list"><input type="hidden" name="pagenum" id="pagenum" value="<%= pagenum %>">
</td>
</tr>
</table>
</td>
</form>
<td height="30" align="right" class="classhead">
<%=QuickMenu("Admin_gug.asp|"& Lang_Menu(141) &"","?action=add|"& Lang_Adv(7) &"")%>
</td>
</tr>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="classtable" class="classtable2">
<tbody>
<tr>
<form name="form" action="?" method="post">
<td height="30" class="classhead" align="left" colspan="3">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_delete.gif" value=" <%=Lang_sys(15)%> " align="absmiddle">
<input type="image" border="0" title=" <%=Lang_sys(23)%> " onclick="location.href='javascript:tolead();';return false;" src="lang/<%=LangFilePath%>/images/bt_out.gif" align="absmiddle">
<input name="update" type="image" src="lang/<%=LangFilePath%>/images/bt_update.gif" value=" <%=Lang_sys(33)%> " align="absmiddle" onclick="location.href='?action=update';return false;">
<input type="hidden" name="page" id="page" value="<%=page%>">
<input type="hidden" name="a_type" id="a_type" value="<%=a_type%>">
<input type="hidden" name="category" id="category" value="<%=category%>">
<input type="hidden" name="state" id="state" value="<%=state%>">
<input type="hidden" name="keyword" id="keyword" value="<%=keyword%>">
<input type="hidden" name="pagenum" id="pagenum" value="<%= pagenum %>">
<input type="hidden" name="action" value="del">
</td>
<td height="30" class="classhead" align="right" colspan="6"><%=ors.ShowPageHead(page)%></td>
  </tr>
<tr>
<td height="30" class="classtop" width="5%" title="<%=Lang_sys(4)%>" style="cursor:pointer;" onclick="location.href='javascript:selectall();';return false;"><%=Lang_sys(50)%></td>
<td class="classtop" height="30" width="12%"><%=Lang_Adv(35)%></td>
<td class="classtop" height="30" width="20%"><%=Lang_Adv(36)%></td>
<td class="classtop" height="30" width="21%"><%=Lang_Adv(37)%></td>
<td class="classtop" height="30" width="8%"><%=Lang_Adv(38)%></td>
<td class="classtop" height="30" width="8%"><%=Lang_Adv(33)%></td>
<td class="classtop" height="30" width="8%"><%=Lang_Adv(39)%></td>
<td class="classtop" height="30" width="10%"><%=Lang_Adv(40)%></td>
<td class="classtop" height="30" width="8%"><%=Lang_Adv(41)%></td>
</tr>
<%
If DataCount >0 Then
		For i = 0 To Ubound(DataList,2)
		If InStr(DataList(7,i),"|")>0 Then
		        a_pic_width = Split(DataList(7,i),"|")(0)
				a_pic_height = Split(DataList(7,i),"|")(1)
		Else
		        a_pic_width = 0
				a_pic_height = 0
		End If
%>
<tr class="classrow">
<td height="30" class="classrow"><input name="id" id="id" type="checkbox" value="<%=DataList(0,i)%>"></td>
<td class="classrow"><%=DataList(1,i)%>
</td>
<td class="classrow">
<%If DataList(2,i) <> "" Then%>
<span style="color:<%= DataList(3,i) %>;"><%=DataList(2,i)%></span>
<%Else%>
&nbsp;
<%End If%>
</td>
<td class="classrow">
<%If DataList(4,i) <> "" Then%>
<%=DataList(4,i)%>
<%Else%>
&nbsp;
<%End If%>
</td>
<td class="classrow">
<%
If DataList(5,i) = 1 Then
        response.write("<img src='images/img.gif' align='absmiddle' onMouseover=""javascript:ddrivetip('<img src=../"& DataList(6,i) &"")
		If a_pic_width <> "0" Then Response.Write(" width="& a_pic_width &"")
		If a_pic_height <> "0" Then Response.Write(" height="& a_pic_height &"")
		Response.Write(">', '#ffffff', '200')"" onMouseout=""hideddrivetip()"">")
ElseIf DataList(5,i) = 0 Then
        response.write(Lang_Adv(22))
Else
        response.write(Lang_Adv(23))
End If
%>
</td>
<td class="classrow">
<%
If DataList(8,i) = 1 Then
        response.write(Lang_Adv(28))
Else
        response.write("<font color=red>"& Lang_Adv(29) &"</font>")
End If
%>
</td>
<td class="classrow"><%=DataList(9,i)%></td>
<td class="classrow">
<%
If DataList(10,i) = 0 Then
        response.write(Lang_Adv(42))
Else
        If DataList(10,i)+DataList(11,i) > Date() Then
                response.write DataList(10,i)+DataList(11,i)
		Else
                response.write("<font color=red>"& Lang_Adv(43) &"</font>")
		End If
End If
%>
</td>
<td class="classrow">
<a href="?action=code&id=<%=DataList(1,i)%>"><img src="images/icon_config.gif" title=" <%=Lang_Adv(44)%> " border="0"></a>&nbsp;&nbsp;<a href="?action=edit&id=<%=DataList(0,i)%>&category=<%=category%>"><img src="images/icon_edit.gif" title=" <%=Lang_sys(51)%> " border="0"></a>
</td>
</tr>
<%
        Next
End If
%>
</form>
<tr>
	<td height="30" class="classfooter" colspan="2"><%=GetPageNum(15,pagenum)%></td>
	<td height="30" class="classfooter" align="right" colspan="7"><%=ors.ShowPageFoot(page)%></td>
</tr>
</table>
<script>tdshow("classtable");</script>
<%
end Sub

Sub edit()
id = CheckNum(request("id"),0)
sql = "select * from [Lebi_Ad] where a_id = "& id &""
set rs = conn.execute(sql)
If Not rs.eof Then
		a_size = rs("a_size")
		If InStr(a_size,"|")>0 Then
		        a_pic_width = Split(a_size,"|")(0)
				a_pic_height = Split(a_size,"|")(1)
		Else
		        a_pic_width = 0
				a_pic_height = 0
		End If
%>
<script language="javascript" src="inc/js/js_link.js"></script>
<script language="javascript" src="inc/js/dialog.js"></script>
<script language="javascript" src="Upfile/js/Upload_Other.js"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="classtable" class="classtable">
<form name="sort_gug_add" method="post" action="?">
<tr>
	<td height="30" align="left" colspan="2" class="classhead"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" border="0" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle"><input type="hidden" name="id" id="id" value="<%= id %>"><input type="hidden" name="category" id="category" value="<%= request("category") %>"><input type="hidden" name="action" value="edit_ok">
	</td>
	<td height="30" align="right" class="classhead">
	<%=QuickMenu("","")%>
	</td>
 </tr>
  <tr>
     <td class="classtop" height="30" colspan="3"><%=Lang_Adv(8)%></td>
  </tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(9)%></td>
<td class="classrow"><input name="a_tag" id="a_tag" type="text" value="<%= rs("a_tag") %>" size="40" maxlength="20" class="form">
</td>
<td class="classrow" rowspan="9">
<div style="width:100%;border-left:#CCC 1px solid;background:#FAFAFA;text-align:center">
<%=Lang_Adv(10)%><br /><select name="a_category" size="18" style="width:200px;" multiple="multiple" id="a_category">
<option value="a" <%If InStr(","& rs("a_category") &",","a")>0 Then response.write("selected")%>><%=Lang_Adv(13)%></option>
<option value="b" <%If InStr(","& rs("a_category") &",","b")>0 Then response.write("selected")%>><%=Lang_Adv(14)%></option>
<% check_sort (0),ii,","& rs("a_category") &"," %></select>
</div>
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(11)%></td>
<td class="classrow"><input name="a_info" id="a_info" type="text" value="<%= rs("a_info") %>" size="40" maxlength="100" class="form"> <%=Lang_Adv(12)%><input id="a_fontcolor" name="a_fontcolor" type="text" value="<%= rs("a_fontcolor") %>" size="7" class="form"> <img id="s_a_fontcolor" border="0" src="Images/rect.gif" width="18" align="absmiddle" style="cursor:pointer;background:<%= rs("a_fontcolor") %>;" onclick="colorcd('sort_gug_add','a_fontcolor','a_fontcolor')">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(15)%></td>
<td class="classrow"><input name="a_url" id="a_url" type="text" value="<%= rs("a_url") %>" size="40" class="form">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(16)%></td>
<td class="classrow"><%
If Trim(rs("a_pic"))<>"" And Right(LCase(Trim(rs("a_pic"))),3)<>"swf" Then
        response.write("<img src='images/img.gif' align='absmiddle' onMouseover=""javascript:ddrivetip('<img src=../"& trim(rs("a_pic")) &"")
		If a_pic_width <> "0" Then Response.Write(" width="& a_pic_width &"")
		If a_pic_height <> "0" Then Response.Write(" height="& a_pic_height &"")
		Response.Write(">', '#ffffff', '"& a_pic_width + 10 &"')"" onMouseout=""hideddrivetip()"">")
End If
%>
<input id="a_pic" name="a_pic" type="text" size="20" class="form" value="<%= rs("a_pic") %>"> <input type="button" id="Upload_a_pic" name="Submit" value="<%=Lang_sys(52)%>" onclick="uploadpanel('sort_gug_add','a_pic','gg')" class="btn_upload">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(17)%></td>
<td class="classrow"><%=Lang_Adv(18)%><input name="a_width" id="a_width" type="text" size="5" class="form" style="width:40px;" value="<%= a_pic_width %>">  <%=Lang_Adv(19)%><input name="a_height" id="a_height" type="text" size="5" class="form" style="width:30px;" value="<%= a_pic_height %>">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(20)%></td>
<td class="classrow"><select name="a_type" id="a_type">
<option value="1" <%If rs("a_type") = 1 Then response.write("selected")%>><%=Lang_Adv(21)%></option>
<option value="0" <%If rs("a_type") = 0 Then response.write("selected")%>><%=Lang_Adv(22)%></option>
<option value="2" <%If rs("a_type") = 2 Then response.write("selected")%>><%=Lang_Adv(23)%></option>
</select>
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(24)%></td>
<td class="classrow"><input name="a_hits" id="a_hits" type="text" size="5" class="form" value="<%= rs("a_hits") %>">
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><%=Lang_Adv(25)%></td>
<td class="classrow"><input name="a_days" id="a_days" type="text" size="5" class="form" value="<%= rs("a_days") %>"> <%=Lang_Adv(26)%>
</td>
</tr>
<tr>
<td class="classrow" height="25" width="15%"><%=Lang_Adv(27)%></td>
<td class="classrow"><select name="a_state" id="a_state">
<option value="1" <%If rs("a_state") = 1 Then response.write("selected")%>><%=Lang_Adv(28)%></option>
<option value="0" <%If rs("a_state") = 0 Then response.write("selected")%>><%=Lang_Adv(29)%></option>
</select>
</td>
</tr>
<tr>
<td class="classfooter" colspan="3" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" border="0" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
</td>
</tr>
</form>
<tr>
<td colspan="3" class="classfaq">
  <div class="faq_main">
  <p class="faq_title"><%=Lang_sys(49)%></p>
   <%=Lang_Adv(30)%>
   </div>
</td>
</tr>
</table>
<script>tdshow("classtable");</script>
<%
End If
rs.close : Set rs = Nothing
End Sub

Sub showcode()
	id = Safereplace(request("id"))
	sql = "select * from [Lebi_Ad] where a_tag = '"& id &"'"
	set rs = conn.execute(sql)
	If Not rs.eof Then
		a_size = rs("a_size")
		If InStr(a_size,"|")>0 Then
			a_width = Split(a_size,"|")(0)
			a_height = Split(a_size,"|")(1)
		Else
			a_width = 0
			a_height = 0
		End If
		If rs("a_days") = 0 Then 
				enddate = "2099-12-30"
		Else
				enddate = rs("a_date")+rs("a_days")
		End If 

%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable">
<tr>
  <td height="30" class="classhead"><input type="image" src="images/bt_copy.gif" border="0" title=" <%=Lang_Adv(46)%> " onclick="copy_clip(document.getElementById('code').value)" align="absmiddle"></td>
  <td align="right" class="classhead"><%=QuickMenu("","")%> </td>
 </tr>
  <tr>
     <td class="classtop" height="30" colspan="2"><%=Lang_Adv(45)%></td>
  </tr>
<tr class="classrow">
<td class="classrow" colspan="2"><textarea id="code" cols="88" rows="3" class="text"><script src="Include/Lebi_Html/SiteRandAdv-<%=Id%>.js"></script></textarea>
</td>
</tr>
  <tr>
     <td class="classtop" height="30" colspan="2"><%=Lang_Adv(47)%></td>
  </tr>
<tr class="classrow">
<td class="classrow" colspan="2"><script src="<%= Eshop_url %>Include/Lebi_Html/SiteRandAdv-<%=Id%>.js"></script>
</td>
</tr>
</table>
<SCRIPT LANGUAGE="JavaScript">
function copy_clip(copy){
if (window.clipboardData){
window.clipboardData.setData("Text", copy);}
else if (window.netscape){
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;
var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans) return;
trans.addDataFlavor('text/unicode');
var str = new Object();
var len = new Object();
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
var copytext=copy;
str.data=copytext;
trans.setTransferData("text/unicode",str,copytext.length*2);
var clipid=Components.interfaces.nsIClipboard;
if (!clip) return false;
clip.setData(trans,null,clipid.kGlobalClipboard);}
alert("<%=Lang_Adv(48)%>"+copy)
return false;
}
</SCRIPT>
<%
	End If 
	rs.close : Set rs = Nothing
End Sub

Function SavaAdvJs(id,width,height,pic,url,text,color,enddate,jtype,state)
		filebody = "var Now = new Date();"
		filebody = filebody &"var ThisDate = Now.getYear() +""-""+ Now.getMonth() +""-""+ Now.getDate();"
		filebody = filebody &"if (ThisDate < '"& enddate &"'){"
		If jtype = 0 Then
				AdId = Replace(Replace(Id,"-",""),"_","")
				filebody = filebody &"function AdClick"& AdId &"(){window.open("""& Eshop_url &"Include/Lebi_Html/SiteRandAdv.asp?do=redirect&id="& Id &""");}"& vbcrlf
				filebody = filebody &"document.write('<button style=""width:"& width &"px;height:"& a_height &"px;background:transparent;border:0;padding:0;cursor:pointer;"" onclick=""AdClick"& AdId &"()""><object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"" width="""& width &""" height="""& height &"""><param name=""movie"" value="""& Eshop_url & pic &"""><param name=""quality"" value=""high""><param name=""wmode"" value=""transparent""><embed src="""& Eshop_url & pic &""" quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" type=""application/x-shockwave-flash"" width="""& width &""" height="""& height &"""></embed></object></button>');"
		End If
		If jtype = 1 Then
				If url<>"" then
						filebody = filebody &"document.write('<a href="""& Eshop_url &"Include/Lebi_Html/SiteRandAdv.asp?do=redirect&id="& Id &""" target=""_blank""><img src="""& Eshop_url & pic &""" border=""0"""
						If width <> "0" Then filebody = filebody &" width="""& width &""""
						If height <> "0" Then filebody = filebody &" height="""& height &""""
						filebody = filebody &" alt="""& text &"""></a>');"
				Else
						filebody = filebody &"document.write('<img src="""& Eshop_url & pic &""""
						If width <> "0" Then filebody = filebody &" width="""& width &""""
						If height <> "0" Then filebody = filebody &" height="""& height &""""
						filebody = filebody &" alt="""& text &""">');"
				End If
		End If
		If jtype = 2 Then
				If url<>"" then
						filebody = filebody &"document.write('<a href="""& Eshop_url &"Include/Lebi_Html/SiteRandAdv.asp?do=redirect&id="& Id &""" target=""_blank""><font color="""& color &""">"& text &"</font></a>');"
				Else
						filebody = filebody &"document.write('<font color="""& color &""">"& text &"</font>');"
				End If
		End If
		filebody = filebody &"}"
		If state = 0 Then filebody = ""
		Savehtml "../include/Lebi_html/SiteRandAdv-"& id &".js",filebody
End Function 

Function CopyFiles(TempSource,TempEnd)
		On Error Resume Next
		Dim FSOCopyFiles
		Set FSOCopyFiles = Server.CreateObject("Scripting.FileSystemObject")
		IF FSOCopyFiles.FileExists(TempEnd) then '目标备份文件已存在
			   Set FSOCopyFiles=Nothing
			   Exit Function
		End IF
		IF FSOCopyFiles.FileExists(TempSource) Then
		Else '要复制的源数据库文件不存在
			   Set FSOCopyFiles=Nothing
			   Exit Function
		End If
		FSOCopyFiles.CopyFile TempSource,TempEnd
		Set FSOCopyFiles = Nothing
End Function
%>