<%
''' EYCMS common
''' ==================================================================
dim ajaxUrl:ajaxUrl="http://cdn.eycms.cn"
dim hackstr
function chkhack(byval t0)
	dim ishack:ishack=False
	dim t1:t1=t0
	t1=Replace(t1,"addCookie","")
    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(".ffpost")) then ishack=true:hackstr="eycms.ffpost"
	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|css|js|bak"
	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

function getRemoteTheme(t0,t1)
	dim url
	url=ajaxUrl&"/plug/checksite/gettheme.asp?file="&t0&"&theme="&t1&"&url="&http_host
	getRemoteTheme=getxmlhttp(url)
end function

function getRemoteEncry_new(t0,t1,t2)
	dim url,mtheme
	mtheme=webroot&"theme/"&t1
	url=ajaxUrl&"/plug/checksite/getencry_new.asp?file=city&theme="&mtheme&"&folder="&t2&"&url=localhost"
	getRemoteEncry_new=sendhttp(url,t0)
end function

function getxmlhttp(byval t0)
	on error resume next
	dim http
	set http=server.createobject("MSXML2.ServerXMLHTTP")
		http.SetTimeOuts 20000, 20000, 30000, 30000
		http.open "GET",t0,false
		'http.setRequestHeader "If-Modified-Since","0"
		http.send()
		if http.readyState=4 Then
			if http.status=200 then
				getxmlhttp=http.responsetext
			else
				getxmlhttp="ERR"
			end if
		else
			getxmlhttp="ERR"
		end if
	set http=nothing
	If Err Then
		err.Clear
		getxmlhttp="ERR"
	End If
end function

function sendhttp(byval t0,byval t1)
	on error resume next
	dim http
	set http=server.createobject("MSXML2.ServerXMLHTTP")
		http.SetTimeOuts 20000, 20000, 30000, 30000
		http.open "POST",t0,False
		http.setrequestheader "Referer",t0
		http.setrequestheader "User-Agent", "Mozilla/4.0"
		http.setrequestheader "Connection", "Keep-Alive"
		http.setrequestheader "Content-Length",len(t1)
		http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"			
		http.send(t1)
		If http.Readystate<>4 then
			Set http=nothing
			sendhttp="ERR"
			Exit function
		End if
		if http.status=200 then
			sendhttp=http.responsetext
		else
			sendhttp="ERR"
			Set http=nothing
			Exit function
		end if
	set http=nothing
	if err then 
		sendhttp="ERR"
		eycms.errlog "网址："&t0&"<br>函数：sendhttp<br>详情："&err.description,1
		err.clear
	end if
end Function

function lablename(t0)
	if eycms.strlen(t0)=0 then lablename="":exit function
	select case t0
	case 1
		lablename="全局标签"
	case 2
		lablename="列表页标签"
	case 3
		lablename="内容页标签"
	case 4
		lablename="自定义标签"
	end select
end function

function filterCode(t0)
	if eycms.strlen(t0)=0 then filterCode="":exit function
	dim t1:t1=t0
	t1=replace(t1,"{","")
	t1=replace(t1,"}","")
	t1=replace(t1,"[","(")
	t1=replace(t1,"]",")")
	filterCode=t1
end function

function get_tree()
	dim mdata,jj,ji
	if eycms.strlen(eycms.getsys("eycms.plug.lable"))>0 then
		for jj=1 to 4
			get_tree=get_tree&""&eycms.iif(jj=1,"",",")
			get_tree=get_tree&"{id:"&jj&",pId:0,name:"""&lablename(jj)&""",val:""""}"
			mdata=eycms.db.dbload("","id,shuomin,title","ey_plug_lable","classid="&jj&"","")
			if ubound(mdata)>=0 then
				for ji=0 to ubound(mdata,2)
					get_tree=get_tree&",{"
					get_tree=get_tree&"id:"&mdata(0,ji)+4&""
					get_tree=get_tree&",pId:"&jj&""
					get_tree=get_tree&",name:"""&mdata(1,ji)&""""
					get_tree=get_tree&",val:"""&filterCode(mdata(2,ji))&""""
					get_tree=get_tree&"}"
				next
			end if
		next
	end if
end function
%>
