<!--#include file="base.asp"-->
<%
''' EYCMS 链接
''' ==================================================================

	sub getclass()
		get_class=""
		dim data:data=eycms.db.dbload("","classid,classname","ey_expand_class","followid=1","ordnum,classid")
		if ubound(data)>=0 then
			dim i
			for i=0 to ubound(data,2)
				get_class=get_class&"<option value="""&data(0,i)&""">"&data(1,i)&"</option>"
			next
		end if
	end sub
	
	sub adddb()
		dim t0,t1,t2,t3,t4,t5
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.getint(eycms.fpost("t3",0),0)
		t4=eycms.getint(eycms.fpost("t4",0),0)
		t5=eycms.is_pic(t2)
		t2=eycms.iif(t5=1,t2,"")
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#32593;&#31449;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t1)=0 then eycms.ajaxjson "&#32593;&#31449;&#22495;&#21517;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		dim data
		data=array(array("webname",t0,52),array("weburl",t1,255),array("weblogo",t2,255),array("islogo",t5,255),array("classid",t3,0),array("islock",t4,0))
		if eycms.db.dbnew("ey_expand_link",data,"weburl='"&t1&"'")=0 then
			eycms.ajaxjson "0&#32593;&#31449;&#21517;&#31216;&#24050;&#23384;&#22312;&#65292;&#35831;&#25442;&#20010;&#35797;&#35797;",0
		else
			dim cid:cid=eycms.db.insertid("id","ey_expand_link")
			deal_file cid,5
			delall t2,cid,5
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub editdb()
		dim t0,t1,t2,t3,t4,t5
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.getint(eycms.fpost("t3",0),0)
		t4=eycms.getint(eycms.fpost("t4",0),0)
		t5=eycms.is_pic(t2)
		t2=eycms.iif(t5=1,t2,"")
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#32593;&#31449;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t1)=0 then eycms.ajaxjson "&#32593;&#31449;&#22495;&#21517;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		dim data,id
		id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("webname",t0,50,1),array("weburl",t1,255,1),array("weblogo",t2,255,1),array("islogo",t5,255,0),array("classid",t3,0,0),array("islock",t4,0,0))
		if eycms.db.dbupdate("ey_expand_link","id="&id&"",data)=1 Then
			delall t2,id,5
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub deldb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		eycms.db.dbdel "ey_expand_link","id="&id
		deal_del_file id,5
		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_link","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_link","id="&idarr(i)&""
					deal_del_file idarr(i),5
				end if
			next
			eycms.echo "1"
		end if
	end sub
	
	sub movedb()
		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
			eycms.db.dbupdate "ey_expand_link","id in("&id&")",array(array("classid",go,0,0))
			eycms.echo "1"
		end if
	end sub
	
	sub movecate()
		dim comecate:comecate=eycms.getint(eycms.fget("comecate",0),0)
		dim gocate:gocate=eycms.getint(eycms.fget("gocate",0),0)
		eycms.db.dbupdate "ey_expand_link","classid="&comecate&"",array(array("classid",gocate,0,0))
		eycms.echo "1"
	end sub
	
	islogin
	checkpagelever 33
	dim act:act=lcase(eycms.fget("act",0))
	dim sqlwhere,nattitle,nat,classid
	classid=eycms.getint(eycms.fget("classid",0),-1)
	nat=eycms.getint(eycms.fget("nat",0),0)
	select case act
		case "add":load eval("theme_expand_link_"&act)
		case "adddb":adddb
		case "edit"
			dim datadb,id
			id=eycms.getint(eycms.fget("id",0),0)
			datadb=eycms.db.dbload("","webname,weburl,weblogo,classid,islock","ey_expand_link","id="&id&"","")
			load eval("theme_expand_link_"&act)
		case "editdb":editdb
		case "del":deldb
		case "doset":doset
		case "delsome":delsome
		case "move":movedb
		case "movecate":movecate
		case else
			if classid<>-1 then
				sqlwhere=" and ey_expand_link.classid="&classid
			end if
			select case nat
				case "1":sqlwhere=sqlwhere&" and islock=0":nattitle="性质:未审"
				case "2":sqlwhere=sqlwhere&" and islock=1":nattitle="性质:已审"
				case "3":sqlwhere=sqlwhere&" and islogo=0":nattitle="性质:文字链接"
				case "4":sqlwhere=sqlwhere&" and islogo=1":nattitle="性质:图片链接"
				case else:nattitle="按性质↓"
			end select
			dim get_class:getclass
			load theme_expand_link
	end select
	
	eycms.db.dbclose
%>
