<!--#include file="../../lib/base.asp"-->
<!--#include file="../../theme/admin_leo/config.asp"-->
<!--#include file="../../lib/cmd.asp"-->
<%
''' EYCMS 标签生成插件
''' ==================================================================
	eycms.stophack
	'注释：插件是否安装
	is_plug_install "eycms.plug.lable"
	
	'注释：管理权限检查
	is_plug_login
	
	'注释：定义插件模板路径
	dim plug_theme, plug_theme_add, plug_theme_add_none, plug_theme_edit, plug_theme_edit_none, plug_theme_creat
	plug_theme="module/plug_lable/list.html"
	plug_theme_add="module/plug_lable/add.html"
	plug_theme_add_none="module/plug_lable/add_none.html"
	plug_theme_edit="module/plug_lable/edit.html"
	plug_theme_edit_none="module/plug_lable/edit_none.html"
	plug_theme_creat="module/plug_lable/creat.html"

	dim hackstr
	function chkhack(byval t0)
		dim ishack:ishack=False
		dim t1:t1=t0
		t1=Replace(t1,"eval(rsshow[piclist])","")
		t1=Replace(t1,"request.servervariables","")
	    If Instr(Lcase(t1), Lcase("clsid:")) then ishack=true:hackstr="clsid:"
		If instr(Lcase(t1), Lcase(".loadfile")) then ishack=true:hackstr="eycms.loadfile"
		If instr(Lcase(t1), Lcase(".copyfile")) then ishack=true:hackstr="eycms.copyfile"
		If instr(Lcase(t1), Lcase(".newfile")) then ishack=true:hackstr="eycms.newfile"
		If instr(Lcase(t1), Lcase(".editfile")) then ishack=true:hackstr="eycms.editfile"
		If instr(Lcase(t1), Lcase(".copyfolder")) then ishack=true:hackstr="eycms.copyfolder"
		If instr(Lcase(t1), Lcase(".editfolder")) then ishack=true:hackstr="eycms.editfolder"
		If instr(Lcase(t1), Lcase(".newfolder")) then ishack=true:hackstr="eycms.newfolder"
		If instr(Lcase(t1), Lcase(".delfolder")) then ishack=true:hackstr="eycms.delfolder"
		If instr(Lcase(t1), Lcase(".delfile")) then ishack=true:hackstr="eycms.delfile"
		If instr(Lcase(t1), Lcase(".save_outfile")) then ishack=true:hackstr="eycms.save_outfile"
		If instr(Lcase(t1), Lcase(".newavatar")) then ishack=true:hackstr="eycms.newavatar"
		If instr(Lcase(t1), Lcase(".gethttp")) then ishack=true:hackstr="eycms.gethttp"
		If instr(Lcase(t1), Lcase(".save_outfile")) then ishack=true:hackstr="eycms.save_outfile"
		If instr(Lcase(t1), Lcase(".sendhttp")) then ishack=true:hackstr="eycms.sendhttp"
		If instr(Lcase(t1), Lcase(".sethttp")) then ishack=true:hackstr="eycms.sethttp"
		If instr(Lcase(t1), Lcase(".fget")) then ishack=true:hackstr="eycms.fget"
		If instr(Lcase(t1), Lcase(".fpost")) then ishack=true:hackstr="eycms.fpost"
		If instr(Lcase(t1), Lcase(".fquery")) then ishack=true:hackstr="eycms.fquery"
		If instr(Lcase(t1), Lcase("runat=server")) then ishack=true:hackstr="runat=server"
		If instr(Lcase(t1), Lcase("eycms_function")) then ishack=true:hackstr="eycms_function"
		If instr(Lcase(t1), Lcase("eycms_upload")) then ishack=true:hackstr="eycms_upload"
		If instr(Lcase(t1), Lcase("eycms_template")) then ishack=true:hackstr="eycms_template"
		If instr(Lcase(t1), Lcase("cookie")) then ishack=true:hackstr="cookie"
		If instr(Lcase(t1), Lcase("session")) then ishack=true:hackstr="session"
		If instr(Lcase(t1), Lcase(".shell")) then ishack=true:hackstr="wscript.shell"
		dim regEx,Matches,Match,FileExt
		set regEx = New RegExp
		regEx.IgnoreCase = true
		regEx.Global = True
		FileExt="gif|jpg|jpeg|png|doc|docx|xls|xlsx|ppt|pptx|rar|zip|7z|pdf|txt|flv|mp4|rm|rmvb|wmv|3gp|avi|mpeg|swf"
		regEx.pattern="eycms:include\(['""](.+?)[.]{1}(" & FileExt & ")['""]\)"
		If regEx.Test(t1) Then ishack=true:hackstr="eycms:include(非法文件)"
		regEx.pattern="<" & "!--#include file=""(../)*(.+?)[.]{1}(" & FileExt & ")""-->"
		If regEx.Test(t1) Then ishack=true:hackstr="eycms:include(非法文件)"
		regEx.pattern="runat[\s]*=[\s]*(?:""|')server(?:""|')"
		If regEx.Test(t1) Then ishack=true:hackstr="runat=server"
		regEx.Pattern = "rsshow\[piclist\]"
		If regEx.Test(t1) Then ishack=true:hackstr="rsshow[piclist]"
		regEx.Pattern = "\bRequest\b"
		If regEx.Test(t1) Then ishack=true:hackstr="request"
		regEx.Pattern = "\bExecute\b"
		If regEx.Test(t1) Then ishack=true:hackstr="execute"
		regEx.Pattern = "\bEv"&"al\b"
		If regEx.Test(t1) Then ishack=true:hackstr="eval"
		regEx.Pattern = "Server.(Exec"&"ute|Transfer)([ \t]*|\()[^""]\)"
		If regEx.Test(t1) then ishack=true:hackstr="transfer"
		regEx.Pattern = "CreateO"&"bject[ |\t]*\(.*\)"
		If regEx.Test(t1) then ishack=true:hackstr="createobject"
		set matches = nothing
		set regex = nothing
		chkhack = ishack
	end Function


	dim get_model_cate
	function get_modelcate(byval t0)
		dim data:data=eycms.categorydata
		getmodelcate 0,t0,data
		get_modelcate="<select name=""t2"" id=""t2"" class=""ip"">" & vbcrlf & _
					"<option value=""0"">选择栏目</option>" & vbcrlf & _
					get_model_cate & _
					"</select>"
	end function
	
	sub getmodelcate(byval t0,byval t1,byval t2)
		dim data:data=t2
		dim i
		if not(isarray(data)) then
			exit sub
		end if
		for i=0 to ubound(data,2)
			if t0=data(3,i) and t1=data(10,i) then
				get_model_cate=get_model_cate&"<option value="""&data(0,i)&""">"&string(data(4,i)-1,"　")&eycms.iif(data(3,i)>0,"├ ","")&""&data(1,i)&"</option>"& vbcrlf
				getmodelcate data(0,i),t1,data
			end if
		next
	end sub

	sub loadmodelcate()
		dim t0:t0=eycms.getint(eycms.fget("t0",0),0)		'模型ID
		dim mycateoption
		mycateoption=get_modelcate(t0)
		eycms.echo mycateoption
	end sub

	sub loadcate()
		dim data,mycate,i
		mycate="<select name=""t2"" id=""t2"" class=""ip"">" & vbcrlf & _
			   "<option value=""0"">不指定栏目</option>" & vbcrlf
		data=eycms.db.dbload("","cateid,catename","view_category","followid=0 and modeid<>-2","ordnum,cateid")
		if isarray(data) then
			for i=0 to ubound(data,2)
				mycate=mycate&"<option value="""&data(0,i)&""">"&data(1,i)&"</option>"& vbcrlf
			next
		end if
		mycate=mycate&"</select>"
		eycms.echo mycate
	end sub

	sub loadexpandcate()
		dim t0:t0=eycms.enhtml(eycms.fget("t0",0))      '附加表
		dim expandid
		if t0="ey_expand_link" then expandid=1
		if t0="ey_expand_ad" then expandid=3
		dim data,mycate,i
		mycate="<select name=""t2"" id=""t2"" class=""ip"">" & vbcrlf & _
			   "<option value=""0"">选择栏目</option>" & vbcrlf
		data=eycms.db.dbload("","classid,classname","ey_expand_class","followid="&expandid,"ordnum,classid")
		if isarray(data) then
			for i=0 to ubound(data,2)
				mycate=mycate&"<option value="""&data(0,i)&""">"&data(1,i)&"</option>"& vbcrlf
			next
		end if
		mycate=mycate&"</select>"
		eycms.echo mycate
	end sub

	'=============================================================================================
	'注释：生成参考标签
	sub lable()
		On Error Resume next
		dim t0:t0=eycms.getint(eycms.fpost("t0",0),0)    '模型
		dim t1:t1=eycms.getint(eycms.fpost("t1",0),0)    '页面：0=首页  1=频道页  2=列表页  3=内容页
		dim t2:t2=eycms.getint(eycms.fpost("t2",0),0)    '栏目ID
		dim t3:t3=eycms.enhtml(eycms.fpost("t3",0))      '附加表
		dim t5:t5=eycms.enhtml(eycms.fpost("t5",0))			'调用条件
		dim t6:t6=eycms.enhtml(eycms.fpost("t6",0))			'排序方式
		dim t7:t7=eycms.getint(eycms.fpost("t7",0),0)		'返回行数top
		dim t8:t8=eycms.getint(eycms.fpost("t8",0),0)		'分页显示pagesize
		dim t9:t9=eycms.getint(eycms.fpost("t9",0),0)		'包含子类
		dim t10:t10=eycms.enhtml(eycms.fpost("t10",0))		'定义变量var="sonid:id"
		dim t11:t11=eycms.enhtml(eycms.fpost("t11",0))		'自增变量auto="j"
		dim t12:t12=eycms.getint(eycms.fpost("t12",0),0)	'是否缓存
		dim varname
		If t0=0 Then eycms.echo "模型错误":Exit sub
		If Not IsNumeric(t7) Then eycms.echo "返回行数必须是数字":Exit sub
		If Not IsNumeric(t8) Then eycms.echo "分页必须是数字":Exit sub
		If eycms.strlen(t10)>0 then
			if InStr(t10,":")=0 Then
				eycms.echo "定义变量格式错误，例：sonid : id":Exit Sub
			End If
			varname=split(t10,":")(0)
		End If
		If t11="i" Then t11=""

		dim str01,str02,str03
		str01="{eycms:rs"
		str03="{/eycms:rs}"
		dim classid,field,table,where,order,top,pagesize,auto,var,iscache,isadminurl
		dim joinstr
		select case t0
			case -1   '单页模型
				if t1=0 then   '首页
					if t2=0 then eycms.echo "请选择栏目":Exit sub
					if t9=0 then   '不含子类 
						classid="classid="&t2
					else    	   '含子类
						classid="classid in([eycms.get_sonid("&t2&")])"
					end if
				else  '内容页
					t7=1
					if instr(t5,"[classid]") then t6=""
					t9=0
					classid="classid=[classid]"
				end if
				t3="ey_model_page"
				t8="" 
			case -3   '其他
				t9=0
				if t3="ey_expand_ad" Or t3="ey_expand_link" Or t3="ey_category" then
					isadminurl=""
					t8=0
					if t3="ey_expand_ad" then 
						if t2=0 then eycms.echo "请选择栏目":Exit sub
						if t2>0 then classid="classid="&t2
						t8=0
					end if
					if t3="ey_expand_link" then
						select case t1
						case 0   '首页 
							t8=0
							if t2>0 then classid="classid="&t2
						case 2   '列表页
							t8=20
						end select
					end if
					if t3="ey_category" then
						t8=0
						if eycms.strlen(t5)=0 then eycms.echo "请选择调用条件":Exit sub
						if t2>0 then
							if instr(t5,"[classid]") then t5=replace(t5,"[classid]",t2)
						end if
					end if
				else
					isadminurl=" isadminurl=""0"""
					t8=20
					if t3="ey_expand_vote" Then t7="1"
				end if
			case else   '常用模型
				Select Case t1
				Case 0   	'首页
					if t2=0 then eycms.echo "请选择栏目":Exit sub
					t3=eycms.db.dbloadone("tablename","ey_model","modelid="&clng(t0))
					If eycms.strlen(t3)=0 then eycms.echo "模型参数错误":Exit sub
					joinstr=" join=""left join ey_content on "&t3&".cid=ey_content.id"""
					t8=""
					if t9=0 then   '不含子类 
						classid="classid="&t2
					else    	   '含子类
						classid="classid in([eycms.get_sonid("&t2&")])"
					end if
				Case 1   	'专题页
					t3="ey_content"
					if t9=0 then   '不含子类 
						classid="classid=[classid]"
					else    	   '含子类
						classid="classid in([sonid])"
					end if
				Case 2   	'列表页
					t3="ey_content"
					t7=0
					t8="{var pagenum}"
					classid="classid in([sonid])"
				Case else   '内容页
					t3="ey_content"
					if t7=0 then 
						eycms.echo "请设置返回行数（上一篇、下一篇：设置为“1”）（相关阅读：根据页面情况设置）"
						Exit sub
					end if
					if eycms.strlen(t5)=0 then eycms.echo "请设置调用条件":Exit sub
					if eycms.strlen(t6)=0 then eycms.echo "请设置排序方式":Exit sub
					t8=""
					classid=""
				End Select
		end select

		If t3<>"" Then table=" table="""&t3&""""
		If t5<>"" Then where=" where="""&t5&""""
		If t6<>"" Then order=" order="""&t6&""""
		If t7<>"" Then top=" top="""&t7&""""
		If t8<>"" Then 
			If t8>0 Then pagesize=" pagesize="""&t8&""""
		End if
		If t10<>"" Then var=" var="""&t10&""""
		If t11<>"" Then auto=" auto="""&t11&""""
		If t12 = 1 Then iscache=" iscache=""true"""

		If classid<>"" Then
			If where<>"" Then
				If InStr(where,"classid")<=0 Then
					where=Left(where,Len(where)-1) & " and " & classid & """"
				End If
			Else
				where=" where=""" & classid & """"
			End If
		End if

		Select Case t3
		Case "ey_model_page"
			If t1=0 Then   '首页
				str02=str02&"　　{eycms.dishtml($rs[content])}　　　　　　　　　　　　　-- 调用单页内容，去除HTML标签" &"<BR>"
				str02=str02&"　　{eycms.cutstr(eycms.dishtml($rs[content]),200,1)}　　-- 调用单页内容，截取" &"<BR>"  
			Else
				if instr(t5,"[classid]") then str02=str02&"　　{eycms.get_content_split($rs[content],htmlrule)}  　-- 调用单页内容" &"<BR>"
				if instr(t5,"[classid]")=0 then 
					str02=str02&"　　{$rs[title]}  　　　　　　　　　　　-- 标题" &"<BR>"
					str02=str02&"　　{eycms.cutstr($rs[title],30,1)}  　-- 截取标题" &"<BR>"
				end if
			End if
		Case "ey_category"
			str02=str02&"　　{rs:eof}&#60;li&#62;没有分类&#60;/li&#62;{/rs:eof}  　-- 记录为空时显示" &"<BR>"
			str02=str02&"　　{$rs[link]}  　-- 类别URL" &"<BR>"
			str02=str02&"　　{$rs[catename]}  　-- 类别名称" &"<BR>"
			str02=str02&"　　{eycms.cutstr($rs[catename],30,1)}  　-- 截取名称" &"<BR>"
			if eycms.strlen(varname)>0 then
				str02=str02&"　　<BR>"
				str02=str02&"　　{eycms:rt top=""0"" table=""ey_category"" where=""followid=["&varname&"]"" order=""ordnum,cateid""}  　-- 二级分类" &"<BR>"
				str02=str02&"　　　　{$rt[link]}" &"<BR>"
				str02=str02&"　　　　{$rt[catename]}" &"<BR>"
				str02=str02&"　　{/eycms:rt}" &"<BR>"
			end if
		Case "ey_theme_block"
			str02=str02&"　　{eycms.get_content_split($rs[content],htmlrule)}  　-- 调用区块内容" &"<BR>"
		Case "ey_expand_keyword"
			str02=str02&"　　{webroot}plug/search.asp?key={server.urlencode($rs[title])}  　-- 搜索链接" &"<BR>"
			str02=str02&"　　{$rs[title]}  　-- 关键字" &"<BR>"
			str02=str02&"　　{eycms.cutstr($rs[title],30,1)}  　-- 截取关键字" &"<BR>"
		Case "ey_expand_comment"
			str02=str02&"　　{webroot}upfile/avatar/{$rs[avatar]}/normal.jpg  　-- 默认头像" &"<BR>"
			str02=str02&"　　{$rs[createdate]}  　-- 评论时间" &"<BR>"
			str02=str02&"　　{$rs[username]}  　-- 昵称" &"<BR>"
			str02=str02&"　　{$rs[content]}  　-- 评论内容" &"<BR>"
			str02=str02&"　　{if eycms.strlen($rs[reply])>0} 管理员回复：{$rs[reply]} {/if}  　-- 回复" &"<BR>"
		Case "ey_expand_vote"
			str02=str02&"　　{$rs[title]}  　-- 投票主题" &"<BR>"

			str02=str02&"　　{dim voteitem_arr:voteitem_arr=split($rs[voteitem],"","")}  　-- 输入选项" &"<BR>"
			str02=str02&"　　{dim voteresult_arr:voteresult_arr=split($rs[voteresult],"","")}" &"<BR>"
			str02=str02&"　　{dim votepercent_arr:votepercent_arr=split($rs[votepercent],"","")}" &"<BR>"
			str02=str02&"　　{for i=0 to ubound(voteitem_arr)}" &"<BR>"
			str02=str02&"　　　　{asp i+1}. {voteitem_arr(i)}" &"<BR>"
			str02=str02&"　　　　&lt;span style='width:0%;' point='{replace(votepercent_arr(i),""%"","""")}' class='active'&gt;" &"<BR>"
			str02=str02&"　　　　{votepercent_arr(i)} ({voteresult_arr(i)}人)" &"<BR>"
			str02=str02&"　　{/for}" &"<BR>"
		Case "ey_expand_tags"
			str02=str02&"　　{eycms.gurl(""tags.asp?tag="",server.urlencode($rs[title]))}  　-- 标签链接" &"<BR>"
			str02=str02&"　　{$rs[title]}  　-- 标签名" &"<BR>"
			str02=str02&"　　{$rs[hits]}  　-- 点击量" &"<BR>"
		Case "ey_expand_link"
			str02=str02&"　　{$rs[weburl]}  　-- 链接" &"<BR>"
			str02=str02&"　　{eycms.cutstr($rs[webname],20,0)}  　-- 链接名" &"<BR>"
		Case "ey_expand_book"
			str02=str02&"　　{webroot}upfile/avatar/{$rs[avatar]}/normal.jpg  　-- 默认头像" &"<BR>"
			str02=str02&"　　{$rs[createdate]}  　-- 留言时间" &"<BR>"
			str02=str02&"　　{$rs[username]}  　-- 昵称" &"<BR>"
			str02=str02&"　　{$rs[content]}  　-- 留言内容" &"<BR>"
			str02=str02&"　　{if eycms.strlen($rs[reply])>0} 管理员回复：{$rs[reply]} {/if}  　-- 回复" &"<BR>"
		Case "ey_expand_ad"
			str02=str02&"　　{$rs[adtype]}  　-- 广告类型" &"<BR>"
			str02=str02&"　　{$rs[title]}  　-- 广告标题" &"<BR>"
			str02=str02&"　　{$rs[url]}  　-- 链接" &"<BR>"
			str02=str02&"　　{$rs[fileurl]}  　-- 图片地址" &"<BR>"
			str02=str02&"　　{$rs[width]}  　-- 图片宽度" &"<BR>"
			str02=str02&"　　{$rs[height]}  　-- 图片高度" &"<BR>"
		Case else   '常用模型
			str02=str02&"　　{rs:eof}&#60;li&#62;没有资料&#60;/li&#62;{/rs:eof}  　-- 记录为空时显示" &"<BR>"
			str02=str02&"　　{eycms.getcateinfo($rs[classid])}  　-- 获取所属分类链接" &"<BR>"
			str02=str02&"　　{eycms.getcatename($rs[classid])}  　-- 获取所属分类名" &"<BR>"
			str02=str02&"　　{$rs[link]}  　-- 链接" &"<BR>"
			str02=str02&"　　{if $rs[isurl]=1} target=""_blank""{/if}  　-- 外部链接以新窗口打开" &"<BR>"
			str02=str02&"　　{$rs[style]}  　-- 链接样式" &"<BR>"
			str02=str02&"　　{$rs[title]}  　-- 标题" &"<BR>"
			str02=str02&"　　{eycms.cutstr($rs[title],30,1)}  　-- 截取标题" &"<BR>"
			str02=str02&"　　{eycms.getdate($rs[createdate],""."",0)}  　-- 创建时间" &"<BR>"
			
			str02=str02&"　　{if $rs[ispic]=1}{$rs[pic]}{else}{skins}/images/nophoto.jpg{/if}  　-- 显示缩略图" &"<BR>"
			str02=str02&"　　{eycms.cutstr(eycms.nohtml($rs[intro]),40,1)}  　-- 截取显示简介" &"<BR>"
			str02=str02&"　　{$rs[hits]}  　-- 人气" &"<BR>"
			if t0=5 then
				str02=str02&"　　{eycms.getmoney($rs[mprice])}  　-- 原价" &"<BR>"
				str02=str02&"　　{eycms.getmoney($rs[uprice])}  　-- 现价" &"<BR>"
				str02=str02&"　　{eycms.get_discount($rs[uprice],$rs[mprice])}  　-- 折扣" &"<BR>"
				str02=str02&"　　{asp $rs[soldnum]+$rs[appnum]}  　-- 购买人数" &"<BR>"
			end if
			if t0=6 then
				str02=str02&"　　{eycms.getmoney($rs[mprice])}  　-- 原价" &"<BR>"
				str02=str02&"　　{eycms.getmoney($rs[uprice])}  　-- 现价" &"<BR>"
				str02=str02&"　　{$rs[mpoint]}  　-- 需积分" &"<BR>"
			end if
			if t0=4 then
				str02=str02&"　　{$rs[softsize]}{$rs[sizeunit]}  　-- 大小" &"<BR>"
			end if
		End Select
		str01=str01 & top & field & table & where & joinstr & order & pagesize & auto & var & iscache & isadminurl & "}" & "<BR>"
		eycms.echo "<div style='line-height:180%;font-size:14px;font-family:Verdana;'>"&str01&str02&str03&"</div>"
	end Sub
	'===============================================================================================================


	'*****************************
	'注释：获取常用条件
	'*****************************
	sub loadwhere()
		dim t0:t0=eycms.getint(eycms.fget("t0",0),0)
		dim t1:t1=eycms.getint(eycms.fget("t1",0),0)    '页面：0=首页  1=频道页  2=列表页  3=内容页
		dim t2:t2=eycms.getint(eycms.fget("t2",0),0)    '栏目ID
		dim t3:t3=eycms.enhtml(eycms.fget("t3",0))      '附加表

		If t0=0 Then eycms.echo "":Exit sub

		Dim modeid
		modeid=t0

		dim str01,str02,str03
		str01="&nbsp;<select onchange=""setUsedwhere('#t5',this.value)"" class=""ip"">" & vbcrlf & _
			  "<option value="""">常用条件</option>" & vbcrlf
		str03="</select>"
		select case modeid
		case -1   '单页模型
			if t1=0 then 
			else
				str02=str02&"<option value=""0|classid=[classid]"">调用内容</option>"&vbcrlf
				str02=str02&"<option value=""0|classid in([sonid]) and islock=1"">调用子类</option>"&vbcrlf
			end if
		case -3   '其他模块
			Select Case t3
			Case "ey_category"
				str02=str02&"<option value=""0|followid=[classid]"">子栏目</option>"&vbcrlf
				str02=str02&"<option value=""0|followid=[rootid]"">一级栏目(仅内页用)</option>"&vbcrlf
			Case "ey_expand_comment"
				str02=str02&"<option value=""1|islock=1 [sqlwhere]"">已审核</option>"&vbcrlf
			Case "ey_expand_vote"
				str02=str02&"<option value=""1|islock=1"">已审核</option>"&vbcrlf
				str02=str02&"<option value=""1|id=[id]"">查看[id]投票</option>"&vbcrlf
			Case "ey_expand_tags"
				str02=str02&"<option value=""1|hits>0"">访问量>0</option>"&vbcrlf
			Case "ey_expand_link","ey_expand_book","ey_expand_ad","ey_expand_keyword"
				str02=str02&"<option value=""1|islock=1"">已审核</option>"&vbcrlf
			End Select
		case else '常用模型
			Select Case t1
			Case 0,1   	'首页、专题页
				str02=str02&"<option value=""1|islock=1"">已发布</option>"&vbcrlf
				str02=str02&"<option value=""1|isnice=1"">推荐</option>"&vbcrlf
				str02=str02&"<option value=""1|ispic=1"">缩图</option>"&vbcrlf
				str02=str02&"<option value=""1|ontop=1"">置顶</option>"&vbcrlf
			Case 2   	'列表页
				str02=str02&"<option value=""1|islock=1"">已发布</option>"&vbcrlf
			Case else   '内容页
				str02=str02&"<option value=""0|islock=1 and classid=[classid] and id<[id] and isurl=0"">上一篇</option>"&vbcrlf
				str02=str02&"<option value=""0|islock=1 and classid=[classid] and id>[id] and isurl=0"">下一篇</option>"&vbcrlf
				str02=str02&"<option value=""0|id in([likeid])"">相关阅读</option>"&vbcrlf
			End Select
		end select
		eycms.echo str01&str02&str03
	end Sub

	'*****************************
	'注释：获取排序方式
	'*****************************
	sub loadorder()
		dim t0:t0=eycms.getint(eycms.fget("t0",0),0)
		dim t1:t1=eycms.getint(eycms.fget("t1",0),0)    '页面：0=首页  1=频道页  2=列表页  3=内容页
		dim t2:t2=eycms.getint(eycms.fget("t2",0),0)    '栏目ID
		dim t3:t3=eycms.enhtml(eycms.fget("t3",0))      '附加表

		If t0=0 Then eycms.echo "":Exit sub

		Dim modeid
		modeid=t0

		dim str01,str02,str03
		str01="&nbsp;<select onchange=""$('#t6').val(this.value)"" class=""ip"">" & vbcrlf & _
			  "<option value="""">常用排序方式</option>" & vbcrlf
		str03="</select>"
		select case modeid
		case -1   '单页模型
			str02=str02&"<option value=""id desc"">按ID降序</option>"&vbcrlf
			str02=str02&"<option value=""id asc"">按ID升序</option>"&vbcrlf
			str02=str02&"<option value=""ontop desc,id desc"">置顶、ID降序</option>"&vbcrlf
		case -3   '其他模块
			Select Case t3
			Case "ey_category"
				str02=str02&"<option value=""ordnum,cateid"">按排序值</option>"&vbcrlf
			Case "ey_expand_comment"
				str02=str02&"<option value=""commentid desc"">按ID降序</option>"&vbcrlf
			Case "ey_expand_tags","ey_expand_keyword"
				str02=str02&"<option value=""hits desc,id desc"">热门排行</option>"&vbcrlf
			Case "ey_expand_link","ey_expand_book","ey_expand_ad","ey_expand_vote"
				str02=str02&"<option value=""id desc"">按ID降序</option>"&vbcrlf
				str02=str02&"<option value=""id asc"">按ID升序</option>"&vbcrlf
			End Select
		case else '常用模型
			Select Case t1
			Case 0,1   	'首页、专题页
				str02=str02&"<option value=""hits desc,id desc"">热门排行</option>"&vbcrlf
				str02=str02&"<option value=""ontop desc,id desc"">置顶、ID降序</option>"&vbcrlf
				str02=str02&"<option value=""rnd"">随机</option>"&vbcrlf
				str02=str02&"<option value=""id desc"">按ID降序</option>"&vbcrlf
			Case 2   	'列表页
				str02=str02&"<option value=""ontop desc,id desc"">置顶、ID降序</option>"&vbcrlf
				str02=str02&"<option value=""ontop desc,createdate desc"">置顶、时间降序</option>"&vbcrlf
			Case else   '内容页
				str02=str02&"<option value=""id desc"">上一篇</option>"&vbcrlf
				str02=str02&"<option value=""id asc"">下一篇</option>"&vbcrlf
				str02=str02&"<option value=""ontop desc,id desc"">相关阅读</option>"&vbcrlf
			End Select
		end select
		eycms.echo str01&str02&str03
	end Sub


	'*****************************
	'注释：获取标签类型名
	'*****************************
	function plug_class(cid)
		Select Case cid
		Case 1
			plug_class="<font color=#336600>全局标签</font>"
		Case 2
			plug_class="<font color=#990000>列表页标签</font>"
		Case 3
			plug_class="<font color=#3366FF>内容页标签</font>"
		Case 4
			plug_class="自定义标签"
		Case Else
			plug_class="未知"
		End select
	end Function
	
	sub adddb()
		dim t0,t1,t2,t3
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.fpost("t3",1)
		If t2=4 Then t0="my:"&t0
		t0="{"&t0&"}"
		'木马检测开始************************************************
		if chkhack(t3) Then
			eycms.ajaxjson "模板内容含有疑似木马的代码" & hackstr,0:exit sub
		end If
		'木马检测结束************************************************

		if eycms.strlen(t0)=0 then eycms.echo "0&#21306;&#22359;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;":exit sub
		dim data
		data=array(array("title",t0,52,1),array("shuomin",t1,255,1),array("classid",t2,0,0),array("content",t3,0,1))
		eycms.db.insert "ey_plug_lable",data
		dim cid:cid=eycms.db.insertid("id","ey_plug_lable")
		eycms.ajaxjson "保存成功",1
	end sub
	
	sub editdb()
		dim t0,t1,t2,t3
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.fpost("t3",0)
		If t2=4 Then t0="my:"&t0
		t0="{"&t0&"}"
		'木马检测开始************************************************
		if chkhack(t3) Then
			eycms.ajaxjson "模板内容含有疑似木马的代码" & hackstr,0:exit sub
		end If
		'木马检测结束************************************************

		if eycms.strlen(t0)=0 then eycms.echo "0&#21306;&#22359;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;":exit sub
		dim data,id
		id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("title",t0,50,1),array("shuomin",t1,255,1),array("classid",t2,0,0),array("content",t3,0,1))
		if eycms.db.dbupdate("ey_plug_lable","id="&id&"",data)=1 then
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub deldb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		eycms.db.dbdel "ey_plug_lable","id="&id&""
		eycms.echo "1"
	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_plug_lable","id="&idarr(i)&""
				end if
			next
			eycms.echo "1"
		end if
	end sub
	
	dim act:act=lcase(eycms.fget("act",0))
	dim sqlwhere,classid
	classid=eycms.getint(eycms.fget("classid",0),-1)
	select case act
		case "loadcate":loadcate
		case "loadmodelcate":loadmodelcate
		case "loadexpandcate":loadexpandcate
		case "loadwhere":loadwhere
		case "loadorder":loadorder
		case "loadallfield":loadallfield
		case "add","add_none":load eval("plug_theme_"&act)
		case "adddb":adddb
		case "edit","edit_none","call"
			dim datadb,id,title
			id=eycms.getint(eycms.fget("id",0),0)
			datadb=eycms.db.dbload("","title,shuomin,classid,content","ey_plug_lable","id="&id&"","")
			title=datadb(0,0)
			title=Replace(title,"my:","")
			title=Replace(title,"{","")
			title=Replace(title,"}","")
			load eval("plug_theme_"&act)
		case "editdb":editdb
		case "del":deldb
		case "delsome":delsome
		case "lable":lable
		case "list"
			if classid<>-1 then
				sqlwhere=" and classid="&classid
			end if
			load plug_theme
		case else:load plug_theme_creat
	end select
	eycms.db.dbclose
%>
