<!--#include file="base.asp"-->
<%
''' EYCMS 广告
''' ==================================================================

	sub add_text_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,code
		dim style:style=""
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.fpost("t4",0)
		t5=eycms.fpost("t5",0)
		t6=eycms.enhtml(eycms.fpost("t6",0))
		t7=eycms.getint(eycms.fpost("t7",0),12)
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.getint(eycms.fpost("t9",0),0)
		t10=eycms.getint(eycms.fpost("t10",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#38142;&#25509;&#25991;&#23383;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t5)=0 then eycms.ajaxjson "&#38142;&#25509;&#32593;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		if eycms.strlen(t7)>0 then
			style=style&"font-size:"&t7&"px;"
		end if
		if eycms.strlen(t6)>0 then
			style=style&"color:"&t6&";"
		end if
		if style<>"" then
			style="style="""&style&""""
		end if
		code="<a href="""&t5&""" target=""_blank"" "&style&">"&t4&"</a>"
		dim data:data=array(array("title",t0,255),array("classid",t1,0),array("begindate",t2,0),array("overdate",t3,0),array("text",t4,0),array("url",t5,0),array("style",style,255),array("note",t8,0),array("ordnum",t9,10),array("islock",t10,0),array("code",code,0),array("adtype",1,0))
		if eycms.db.dbnew("ey_expand_ad",data,"")=1 Then
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub add_pic_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,code
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.fpost("t4",0)
		t5=eycms.fpost("t5",0)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		t7=eycms.getint(eycms.fpost("t7",0),0)
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.getint(eycms.fpost("t9",0),0)
		t10=eycms.getint(eycms.fpost("t10",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#22270;&#29255;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t5)=0 then eycms.ajaxjson "&#38142;&#25509;&#32593;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		code="<a href="""&t5&""" target=""_blank""><img src="""&t4&""" width="""&t6&""" height="""&t7&""" border=""0""></a>"
		dim data:data=array(array("title",t0,255),array("classid",t1,0),array("begindate",t2,0),array("overdate",t3,0),array("fileurl",t4,0),array("url",t5,0),array("width",t6,4),array("height",t7,4),array("note",t8,0),array("ordnum",t9,10),array("islock",t10,0),array("code",code,0),array("adtype",2,0))
		if eycms.db.dbnew("ey_expand_ad",data,"")=1 then
			dim cid:cid=eycms.db.insertid("id","ey_expand_ad")
			deal_file cid,6
			delall t4,cid,6
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub add_flash_db()
		dim t0,t1,t2,t3,t4,t6,t7,t8,t9,t10,code
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.fpost("t4",0)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		t7=eycms.getint(eycms.fpost("t7",0),0)
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.getint(eycms.fpost("t9",0),0)
		t10=eycms.getint(eycms.fpost("t10",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#70;&#108;&#97;&#115;&#104;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		code="<embed src="""&t4&""" width="""&t6&""" height="""&t7&""" wmode=""transparent""></embed>"
		dim data:data=array(array("title",t0,255),array("classid",t1,0),array("begindate",t2,0),array("overdate",t3,0),array("fileurl",t4,0),array("width",t6,4),array("height",t7,4),array("note",t8,0),array("ordnum",t9,10),array("islock",t10,0),array("code",code,0),array("adtype",3,0))
		if eycms.db.dbnew("ey_expand_ad",data,"")=1 then
			dim cid:cid=eycms.db.insertid("id","ey_expand_ad")
			deal_file cid,6
			delall t4,cid,6
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub add_code_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.fpost("t4",0)
		t5=eycms.fpost("t5",0)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		t7=eycms.getint(eycms.fpost("t7",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#24191;&#21578;&#20869;&#23481;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		dim data:data=array(array("title",t0,255),array("classid",t1,0),array("begindate",t2,0),array("overdate",t3,0),array("code",t4,0),array("note",t5,0),array("ordnum",t6,10),array("islock",t7,0),array("adtype",4,0))
		if eycms.db.dbnew("ey_expand_ad",data,"")=1 then
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub edit_text_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,code
		dim style:style=""
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.fpost("t4",0)
		t5=eycms.fpost("t5",0)
		t6=eycms.enhtml(eycms.fpost("t6",0))
		t7=eycms.getint(eycms.fpost("t7",0),12)
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.getint(eycms.fpost("t9",0),0)
		t10=eycms.getint(eycms.fpost("t10",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#38142;&#25509;&#25991;&#23383;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t5)=0 then eycms.ajaxjson "&#38142;&#25509;&#32593;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		if eycms.strlen(t7)>0 then
			style=style&"font-size:"&t7&"px;"
		end if
		if eycms.strlen(t6)>0 then
			style=style&"color:"&t6&";"
		end if
		if style<>"" then
			style="style="""&style&""""
		end if
		code="<a href="""&t5&""" target=""_blank"" "&style&">"&t4&"</a>"
		dim data,id
		id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("title",t0,255,1),array("classid",t1,0,0),array("begindate",t2,0,1),array("overdate",t3,0,1),array("text",t4,0,1),array("url",t5,0,1),array("style",style,255,1),array("note",t8,0,1),array("ordnum",t9,10,0),array("islock",t10,0,0),array("code",code,0,1))
		if eycms.db.dbupdate("ey_expand_ad","id="&id&"",data)=1 then
			eycms.delcache "plug_ad_"&id
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub edit_pic_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,code
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.fpost("t4",0)
		t5=eycms.fpost("t5",0)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		t7=eycms.getint(eycms.fpost("t7",0),0)
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.getint(eycms.fpost("t9",0),0)
		t10=eycms.getint(eycms.fpost("t10",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#22270;&#29255;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t5)=0 then eycms.ajaxjson "&#38142;&#25509;&#32593;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		code="<a href="""&t5&""" target=""_blank""><img src="""&t4&""" width="""&t6&""" height="""&t7&""" border=""0""></a>"
		dim data,id
		id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("title",t0,255,1),array("classid",t1,0,0),array("begindate",t2,0,1),array("overdate",t3,0,1),array("fileurl",t4,0,1),array("url",t5,0,1),array("width",t6,6,0),array("height",t7,6,0),array("note",t8,0,1),array("ordnum",t9,10,0),array("islock",t10,0,0),array("code",code,0,1))
		if eycms.db.dbupdate("ey_expand_ad","id="&id&"",data)=1 then
			eycms.delcache "plug_ad_"&id
			delall t4,id,6
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub edit_flash_db()
		dim t0,t1,t2,t3,t4,t6,t7,t8,t9,t10,code
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.fpost("t4",0)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		t7=eycms.getint(eycms.fpost("t7",0),0)
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.getint(eycms.fpost("t9",0),0)
		t10=eycms.getint(eycms.fpost("t10",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#70;&#108;&#97;&#115;&#104;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		code="<embed src="""&t4&""" width="""&t6&""" height="""&t7&""" wmode=""transparent""></embed>"
		dim data,id
		id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("title",t0,255,1),array("classid",t1,0,0),array("begindate",t2,0,1),array("overdate",t3,0,1),array("fileurl",t4,0,1),array("width",t6,6,0),array("height",t7,6,0),array("note",t8,0,1),array("ordnum",t9,10,0),array("islock",t10,0,0),array("code",code,0,1))
		if eycms.db.dbupdate("ey_expand_ad","id="&id&"",data)=1 then
			eycms.delcache "plug_ad_"&id
			delall t4,id,6
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub edit_code_db()
		dim t0,t1,t2,t3,t4,t5,t6,t7
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.fpost("t4",0)
		t5=eycms.fpost("t5",0)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		t7=eycms.getint(eycms.fpost("t7",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#24191;&#21578;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#24191;&#21578;&#20869;&#23481;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if t2="" then t2="1753-01-01"
		if t3="" then t3="9999-12-31"
		dim data,id
		id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("title",t0,255,1),array("classid",t1,0,0),array("begindate",t2,0,1),array("overdate",t3,0,1),array("code",t4,0,1),array("note",t5,0,1),array("ordnum",t6,10,0),array("islock",t7,0,0))
		if eycms.db.dbupdate("ey_expand_ad","id="&id&"",data)=1 then
			eycms.delcache "plug_ad_"&id
			eycms.ajaxjson "保存成功",1
		end if
	end sub

	sub deldb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		eycms.db.dbdel "ey_expand_ad","id="&id
		deal_del_file id,6
		eycms.delcache "plug_ad_"&id
		eycms.echo "1"
	end sub
	
	sub doset()
		dim id:id=eycms.enhtml(eycms.fget("id",0))
		dim go:go=eycms.enhtml(eycms.fget("go",0))
		dim idarr:idarr=split(id,",")
		if ubound(idarr)<0 then
			eycms.echo "0&#33267;&#23569;&#36873;&#25321;&#19968;&#26465;&#20449;&#24687;"
		else
			dim i
			for i=0 to ubound(idarr)
				if not isnumeric(idarr(i)) then
					eycms.echo "0&#21442;&#25968;&#65306;"&id(i)&"&#19981;&#27491;&#30830;&#65292;&#35831;&#30830;&#35748;&#21518;&#20877;&#25805;&#20316;"
					exit sub
				end if
			next
			dim filed,result
			select case go
				case "islock":filed="islock":result=0
				case "nolock":filed="islock":result=1
				case else:eycms.echo "0&#21442;&#25968;&#38169;&#35823;":exit sub
			end select
			eycms.db.dbupdate "ey_expand_ad","id in("&id&")",array(array(filed,result,2,0))
			eycms.echo "1"
		end if
	end sub
	
	sub delsome()
		dim id:id=eycms.enhtml(eycms.fget("id",0))
		dim idarr:idarr=split(id,",")
		if ubound(idarr)<0 then
			eycms.echo "0&#33267;&#23569;&#36873;&#25321;&#19968;&#26465;&#20449;&#24687;"
		else
			dim i
			for i=0 to ubound(idarr)
				if not isnumeric(idarr(i)) then
					eycms.echo "0&#21442;&#25968;&#65306;"&id(i)&"&#19981;&#27491;&#30830;&#65292;&#35831;&#30830;&#35748;&#21518;&#20877;&#25805;&#20316;"
					exit sub
				else
					eycms.db.dbdel "ey_expand_ad","id="&idarr(i)&""
					deal_del_file idarr(i),6
				end if
			next
			eycms.echo "1"
		end if
	end sub
	
	function ad_type(byval t0)
		select case t0
			case "1":ad_type="文字"
			case "2":ad_type="图片"
			case "3":ad_type="Flash"
			case else:ad_type="代码"
		end select
	end function
	
	function ad_url(byval t0)
		select case t0
			case "1":ad_url="text"
			case "2":ad_url="pic"
			case "3":ad_url="flash"
			case else:ad_url="code"
		end select
	end function
	
	function getclassname(byval t0)
		dim datadb
		datadb=eycms.db.dbload("","classname","ey_expand_class","classid="&t0&"","")
		if ubound(datadb)>=0 then
			getclassname=datadb(0,0)
		end if
	end Function

	islogin
	checkpagelever 41
	dim act:act=lcase(eycms.fget("act",0))
	select case act
		case "add_text","add_pic","add_flash","add_code"
			dim get_tree,cdata,ji
			cdata=eycms.categorydata
			if isarray(cdata) then
				if ubound(cdata)>=0 then
					for ji=0 to ubound(cdata,2)
						get_tree=get_tree&""&eycms.iif(ji=0,"",",")&"{"
						get_tree=get_tree&"id:"&cdata(0,ji)&""
						get_tree=get_tree&",pId:"&cdata(3,ji)&""
						get_tree=get_tree&",name:"""&cdata(1,ji)&""""
						get_tree=get_tree&"}"
					next
				end if
			end if
			load eval("theme_expand_ad_"&act)
		case "add_text_db":add_text_db
		case "add_pic_db":add_pic_db
		case "add_flash_db":add_flash_db
		case "add_code_db":add_code_db
		case "edit_text","edit_pic","edit_flash","edit_code","call"
			dim get_tree2,cdata2,ji2
			cdata2=eycms.categorydata
			if isarray(cdata2) then
				if ubound(cdata2)>=0 then
					for ji2=0 to ubound(cdata2,2)
						get_tree2=get_tree2&""&eycms.iif(ji2=0,"",",")&"{"
						get_tree2=get_tree2&"id:"&cdata2(0,ji2)&""
						get_tree2=get_tree2&",pId:"&cdata2(3,ji2)&""
						get_tree2=get_tree2&",name:"""&cdata2(1,ji2)&""""
						get_tree2=get_tree2&"}"
					next
				end if
			end if
			dim datadb,id,ad_style,thisdata
			id=eycms.getint(eycms.fget("id",0),0)
			datadb=eycms.db.dbload("","title,classid,islock,ordnum,adtype,text,url,style,fileurl,width,height,code,begindate,overdate,note","ey_expand_ad","id="&id&"","")
			ad_style=datadb(7,0)
			thisdata=date()
			if eycms.strlen(ad_style)>0 then
				ad_style=replace(ad_style,"style=""","")
				ad_style=replace(ad_style,"""","")
				if instr(ad_style,"font-size:")>0 then
					dim fontsize
					fontsize=left(mid(ad_style,11),2)
				end if
				if instr(ad_style,"color:")>0 then
					dim fontcolor
					fontcolor=replace(right(ad_style,8),";","")
				end if
			end if
			load eval("theme_expand_ad_"&act)
		case "edit_text_db":edit_text_db
		case "edit_pic_db":edit_pic_db
		case "edit_flash_db":edit_flash_db
		case "edit_code_db":edit_code_db
		case "del":deldb
		case "doset":doset
		case "delsome":delsome
		case else
			dim sqlwhere,nattitle,nat
			nat=eycms.getint(eycms.fget("nat",0),0)
			select case nat
				case "1":sqlwhere=" and islock=0":nattitle="性质:未审"
				case "2":sqlwhere=" and islock=1":nattitle="性质:已审"
				case "3":sqlwhere=" and not(date() between begindate and overdate)":nattitle="性质:过期"
				case "4":sqlwhere=" and adtype=1":nattitle="性质:文字广告"
				case "5":sqlwhere=" and adtype=2":nattitle="性质:图片广告"
				case "6":sqlwhere=" and adtype=3":nattitle="性质:Flash广告"
				case "7":sqlwhere=" and adtype=4":nattitle="性质:代码广告"
				case else:nattitle="按性质↓"
			end select
			load theme_expand_ad
	end select
	eycms.db.dbclose
%>
