<!--#include file="../../lib/base.asp"-->
<!--#include file="../../theme/admin_leo/config.asp"-->
<!--#include file="../../lib/cmd.asp"-->
<!--#include file="../../lib/class/eycms.clsxml.asp"-->
<!--#include file="base.asp"-->
<%
''' EYCMS 站点抓取插件
''' ==================================================================
eycms.stophack
'注释：插件是否安装
is_plug_install "eycms.plug.downsite"

'注释：管理权限检查
is_plug_login

'注释：定义插件模板路径
dim plug_theme,plug_theme_wap
plug_theme="module/plug_downsite/list.html"
plug_theme_wap="module/plug_downsite/wap.html"


'记录已存文件
dim savedfiles

sub chgtheme()
	dim theme,t1
	if eycms.isfile(webroot & "plug/downsite/theme.txt") then
		theme=eycms.loadfile(webroot & "plug/downsite/theme.txt")
		t1="cms0" & CStr(CLng(theme)+1)
		eycms.newfile webroot & "plug/downsite/", "theme.txt", CStr(CLng(theme)+1), "utf-8"
	else
		eycms.newfile webroot & "plug/downsite/", "theme.txt", "10001", "utf-8"
		t1="cms010001"
	end If
	eycms.echo t1
end Sub

'注释：分析目标网站
sub resolvedb()
	session("encodeing")=""
	dim t0:t0=eycms.enhtml(eycms.fget("t0",0))
	if eycms.strlen(t0)=0 Then
		eycms.echo "0请输入目标网站"
		exit sub
	end If
	if Left(LCase(t0),7)<>"http://" Then t0="http://"&t0
	If Right(t0,1)="/" Then t0 = Left(t0,Len(t0)-1)
	dim t1
	't1=Replace(LCase(t0),"http://","")
	'If InStr(t1,".")>0 Then t1="cms" & Right(Split(t1,".")(0),6)
	If eycms.strlen(t1)<9 Then 
		dim theme
		If eycms.isfile(webroot & "plug/downsite/theme.txt") then
			theme=eycms.loadfile(webroot & "plug/downsite/theme.txt")
			t1="cms0" & CStr(CLng(theme)+1)
			'eycms.newfile webroot & "plug/downsite/", "theme.txt", CStr(CLng(theme)+1), "utf-8"
		Else
			eycms.newfile webroot & "plug/downsite/", "theme.txt", "50001", "utf-8"
			t1="cms050001"
		End If
	End if
	dim str:str=getxmlhttp(t0,"auto")
	dim head:head=GetBody(str,"<head>","</head>",true,true,0)
	dim body:body=GetBody(str,"<body>","</body>",true,true,0)
	if len(body)=0 then body=GetBody(str,"</head>","</body>",false,true,0)
	body=Replace(body,t0&"/","")
	if eycms.strlen(head)>0 and eycms.strlen(body)>0 then
		dim t2,t3,t4,t5,t6
		dim regex,matches,match,url,urlstr,urlstr2,uarr,i
		set regex = new regexp
		regex.IgnoreCase = true
		regex.Global = true
		regex.pattern="href=('|"")([^>+""+']+)('|"")"
		set matches = regex.execute(body)
		if matches.count>0 Then
			for each match in matches
				url = match.submatches(1)
				if InStr(url,"?")=0 and eycms.strlen(url)>0 and url<>"/" and Left(LCase(url),7)<>"http://" and Left(LCase(url),4)<>"www." and InStr(url,"javascript:")=0 then 
					if left(url,1)="/" Then url=Right(url,Len(url)-1)
					if InStr(urlstr,url)=0 And GetCount(url,"/")<2 Then urlstr = urlstr & url & ","
					if InStr(urlstr2,url)=0 Then urlstr2 = urlstr2 & url & ","
				end If
			Next
			If Right(urlstr,1)="," Then urlstr=Left(urlstr,Len(urlstr)-1)
			If Right(urlstr2,1)="," Then urlstr2=Left(urlstr2,Len(urlstr2)-1)
		end If

		If InStr(urlstr,",")>0 then
			uarr=Split(urlstr,",")
			For i=0 To UBound(uarr)
			  If t2="" And (InStr(LCase(uarr(i)),"about") Or InStr(LCase(uarr(i)),"company")) Then t2=uarr(i)
			  If t3="" And (InStr(LCase(uarr(i)),"msg") Or InStr(LCase(uarr(i)),"message") Or InStr(LCase(uarr(i)),"guest") Or InStr(LCase(uarr(i)),"book") Or InStr(LCase(uarr(i)),"online") Or InStr(LCase(uarr(i)),"fankui") Or InStr(LCase(uarr(i)),"feedback")) Then t3=uarr(i)
			  If t4="" And InStr(LCase(uarr(i)),"product") Then t4=uarr(i)
			  If t5="" And (InStr(LCase(uarr(i)),"news") Or InStr(LCase(uarr(i)),"new/") Or InStr(LCase(uarr(i)),"new.")) Then t5=uarr(i)
			  If t6="" And (InStr(LCase(uarr(i)),"hot") Or InStr(LCase(uarr(i)),"case") Or InStr(LCase(uarr(i)),"equipment")) Or InStr(LCase(uarr(i)),"honor") Then t6=uarr(i)
			Next
		End If
		If t2="" And t4="" Then
			uarr=Split(urlstr2,",")
			For i=0 To UBound(uarr)
			  If t2="" And InStr(LCase(uarr(i)),"about") Then t2=uarr(i)
			  If t3="" And (InStr(LCase(uarr(i)),"msg") Or InStr(LCase(uarr(i)),"message") Or InStr(LCase(uarr(i)),"guest") Or InStr(LCase(uarr(i)),"book") Or InStr(LCase(uarr(i)),"online") Or InStr(LCase(uarr(i)),"fankui")) Then t3=uarr(i)
			  If t4="" And InStr(LCase(uarr(i)),"product") Then t4=uarr(i)
			  If t5="" And (InStr(LCase(uarr(i)),"news") Or InStr(LCase(uarr(i)),"new/") Or InStr(LCase(uarr(i)),"new.")) Then t5=uarr(i)
			  If t6="" And (InStr(LCase(uarr(i)),"hot") Or InStr(LCase(uarr(i)),"case") Or InStr(LCase(uarr(i)),"equipment")) Or InStr(LCase(uarr(i)),"honor") Then t6=uarr(i)
			Next
		End If
		eycms.echo "1" & t1 & t2 & "_" & t3 & "_" & t4 & "_" & t5 & "_" & t6
	else
		eycms.echo "0抓取站点站失败，或者目标站点结构不规范！"
	end If
	if err Then
		eycms.echo "0发生错误:"&err.description
	End If
end Sub

'注释：分析目标网站内容页
sub resolvedb2()
	On Error Resume next
	dim t0:t0=eycms.enhtml(eycms.fget("t0",0))
	dim t1:t1=eycms.enhtml(eycms.fget("t1",0))
	dim t2:t2=t1
	if eycms.strlen(t0)=0 Then
		eycms.echo "0请输入目标网站"
		exit sub
	end If
	if eycms.strlen(t1)=0 Then
		eycms.echo "0请输入目标网站列表页"
		exit sub
	end If
	If Left(t1,1)="/" Then t1 = Right(t1,Len(t1)-1)
	if Left(LCase(t0),7)<>"http://" Then t0 = "http://" & t0
	If Right(t0,1)<>"/" Then t0 = t0 & "/"
	dim str:str=getxmlhttp(t0 & t1, "auto")
	Dim ulen:ulen=eycms.strlen(t1)
	If InStr(t1,".")>0 Then t1=Split(t1,".")(0)
	If InStr(t1,"/")>0 Then t1=Split(t1,"/")(0)
	dim body:body=GetContent(str,"<body>","</body>",0)
	if len(body)=0 then body=GetContent(str,"</head>","</body>",0)
	if eycms.strlen(body)=0 then body=str
	body=Replace(body,t0,"")
	if eycms.strlen(body)>0 Then
		body=Replace(body,t2&"?","")
		dim regex,matches,match,url,urlstr1,urlstr2,urlstr3,urlstr
		set regex = new regexp
		regex.IgnoreCase = true
		regex.Global = true
		regex.pattern="href=('|"")([^>+""+']+)('|"")"
		set matches = regex.execute(body)
		if matches.count>0 Then
			for each match in matches
				url = match.submatches(1)
				If Left(url,1)="/" Then url = Right(url,Len(url)-1)
				If Left(url,3)="../" Then url = Right(url,Len(url)-3)
				if InStr(url,"view") Or InStr(url,"show") then
					urlstr1 = url
				elseif InStr(url,"?") or (GetCount(t1,"/")=0 and GetCount(url,"/")>=1) then
					urlstr2 = url
				elseif InStr(url,t1) And eycms.strlen(url)>ulen then
					urlstr3 = url
				end If
			next
		end If
		urlstr=urlstr1
		if eycms.strlen(urlstr)=0 then urlstr=urlstr2
		if eycms.strlen(urlstr)=0 then urlstr=urlstr3
		if eycms.strlen(urlstr)>0 Then
			eycms.echo "1" & urlstr
		else
			eycms.echo "0获取失败1！"&t1
		end if
	else
		eycms.echo "0获取失败2！"
	end If
	if err Then
		eycms.echo "0发生错误:"&err.description
	End If
end Sub

sub dodb()
	On Error Resume Next
	dim t0,t1,t2,t3,t4,t5,t6,t60,t7,auto,setmore
	dim t8b,t8b_0,t8e,t8e_0
	dim t9b,t9b_0,t9e,t9e_0
	dim t10b,t10b_0,t10e,t10e_0
	dim t11b,t11b_0,t11e,t11e_0
	t0=eycms.enhtml(eycms.fpost("t0",0))
	t1=eycms.enhtml(eycms.fpost("t1",0))
	t2=eycms.enhtml(eycms.fpost("t2",0))
	t3=eycms.enhtml(eycms.fpost("t3",0))
	t4=eycms.enhtml(eycms.fpost("t4",0))
	t5=eycms.enhtml(eycms.fpost("t5",0))
	t6=eycms.enhtml(eycms.fpost("t6",0))
	t60=eycms.enhtml(eycms.fpost("t60",0))
	t7=eycms.enhtml(eycms.fpost("t7",0))

	t8b=eycms.fpost("t8b",1)
	t8b_0=eycms.getint(eycms.fpost("t8b_0",0),0)
	t8e=eycms.fpost("t8e",1)
	t8e_0=eycms.getint(eycms.fpost("t8e_0",0),0)

	t9b=eycms.fpost("t9b",1)
	t9b_0=eycms.getint(eycms.fpost("t9b_0",0),0)
	t9e=eycms.fpost("t9e",1)
	t9e_0=eycms.getint(eycms.fpost("t9e_0",0),0)

	t10b=eycms.fpost("t10b",1)
	t10b_0=eycms.getint(eycms.fpost("t10b_0",0),0)
	t10e=eycms.fpost("t10e",1)
	t10e_0=eycms.getint(eycms.fpost("t10e_0",0),0)

	t11b=eycms.fpost("t11b",1)
	t11b_0=eycms.getint(eycms.fpost("t11b_0",0),0)
	t11e=eycms.fpost("t11e",1)
	t11e_0=eycms.getint(eycms.fpost("t11e_0",0),0)

	auto=eycms.getint(eycms.fpost("auto",0),0)
	setmore=eycms.getint(eycms.fpost("setmore",0),0)

	If eycms.isfolder(webroot&"theme/"&t1&"/") Then
		If eycms.isfile(webroot & "plug/downsite/cssjs.xml") Then
			dim oxml,d0
			set oxml = new eycms_clsxml
			oxml.file = webroot & "plug/downsite/cssjs.xml"
			d0 = oxml.getfield("item//css",1) 
			set oxml = nothing
			If InStr(d0,t0)<=0 Then
				eycms.echo "模板目录已存在，请更换吧！"
				exit Sub
			End if
		else
			eycms.echo "模板目录已存在，请更换！<a href='javascript:parent.tosetp2("&auto&");'>下一步</a>"
			exit Sub
		End If
	Else
		eycms.newfolder webroot&"theme/"&t1&"/"
	End If
	eycms.copyfolder webroot&"theme/common/",webroot&"theme/"&t1&"/"
	dim objxml
	set objxml = new eycms_clsxml
	objxml.createfile webroot&"plug/downsite/site.xml", "config"
	objxml.createrootchild "item"
	objxml.createchildnode "item","site",t0,1
	objxml.createchildnode "item","theme",t1,1
	objxml.createchildnode "item","page",t2,1
	objxml.createchildnode "item","book",t3,1
	objxml.createchildnode "item","photolist",t4,1
	objxml.createchildnode "item","photoshow",t5,1
	objxml.createchildnode "item","newslist",t6,1
	objxml.createchildnode "item","newslistpic",t60,1
	objxml.createchildnode "item","newsshow",t7,1
	objxml.createchildnode "item","auto",auto,1
	objxml.createchildnode "item","setmore",setmore,1

	if setmore=1 then
	objxml.createchildnode_cdata "item","head_b",t8b,1
	objxml.createchildnode_cdata "item","head_b_0",t8b_0,1
	objxml.createchildnode_cdata "item","head_e",t8e,1
	objxml.createchildnode_cdata "item","head_e_0",t8e_0,1

	objxml.createchildnode_cdata "item","foot_b",t9b,1
	objxml.createchildnode_cdata "item","foot_b_0",t9b_0,1
	objxml.createchildnode_cdata "item","foot_e",t9e,1
	objxml.createchildnode_cdata "item","foot_e_0",t9e_0,1

	objxml.createchildnode_cdata "item","left_b",t10b,1
	objxml.createchildnode_cdata "item","left_b_0",t10b_0,1
	objxml.createchildnode_cdata "item","left_e",t10e,1
	objxml.createchildnode_cdata "item","left_e_0",t10e_0,1

	objxml.createchildnode_cdata "item","nav_b",t11b,1
	objxml.createchildnode_cdata "item","nav_b_0",t11b_0,1
	objxml.createchildnode_cdata "item","nav_e",t11e,1
	objxml.createchildnode_cdata "item","nav_e_0",t11e_0,1
	end if
	objxml.save()
	set objxml = Nothing

	eycms.echo "初始化完毕<br>"
	eycms.echo "<script>parent.tosetp2("&auto&");window.scroll(0,99999)</script><br>"
	response.flush()
	if err then
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		response.flush()
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	end if
end Sub

sub dodb2()
	On Error Resume Next
	'eycms.echo "<script>parent.locksetp(2);</script>"
	eycms.echo "正在抓取css、js，请耐心等待......<br>"
	response.flush()
	dim t0,t1,pages(7),j,str,auto
	dim t0_new
	t0=eycms.enhtml(eycms.fpost("t0",0))
	t1=eycms.enhtml(eycms.fpost("t1",0))
	pages(0)="首页"
	pages(1)=eycms.enhtml(eycms.fpost("t2",0))
	pages(2)=eycms.enhtml(eycms.fpost("t3",0))
	pages(3)=eycms.enhtml(eycms.fpost("t4",0))
	pages(4)=eycms.enhtml(eycms.fpost("t5",0))
	pages(5)=eycms.enhtml(eycms.fpost("t6",0))
	pages(6)=eycms.enhtml(eycms.fpost("t7",0))
	pages(7)=eycms.enhtml(eycms.fpost("t60",0))
	auto=eycms.getint(eycms.fpost("auto",0),0)

	if Left(LCase(t0),7)<>"http://" Then t0="http://"&t0
	If Right(t0,1)="/" Then t0=left(t0,Len(t0)-1)

	If GetCount(t0,"/")>=2 Then
		t0_new="http://"&Split(t0,"/")(2)
	End if

	dim regex,matches,match,url,urlstr,uarr,i
	dim objxml,strfext

	If eycms.isfile(webroot&"theme/"&t1&"/config.xml") Then 
		set objxml = new eycms_clsxml
		objxml.file = webroot&"theme/"&t1&"/config.xml"
		objxml.updatefield "Name", t1&"模板", 0
		objxml.save()
		set objxml = Nothing
	End If

	for j=0 To 7
		If pages(j)<>"" then
			str=getxmlhttp(t0 & "/" & Replace(pages(j),"首页",""),"auto")
			str=Replace(str,t0 & "/","")
			if eycms.strlen(str)>0 Then
				set regex = new regexp
				regex.IgnoreCase = true
				regex.Global = true
				regex.pattern="href=('|"")*([^>+""+']+)[.]{1}(css)('|"")*"
				set matches = regex.execute(str)
				if matches.count>0 then
					for each match in matches
						url = match.submatches(1) & ".css"
						if left(url,1)="/" or InStr(url,t0) or left(url,7)<>"http://" then 
							if left(url,1)="/" Then 
								url = t0_new & url
							Else
								url = t0 & "/" & Replace(url,"../","")
							end if
							url=replace(url,"https://","http://")
							if InStr(urlstr,url)=0 Then 
								urlstr = urlstr & url & ","
								eycms.echo url&"<br>"
								eycms.echo "<script>window.scroll(0,99999)</script>"
								response.flush()
							end if
						end if
					next
				end If
				regex.pattern="src=('|"")*([^>+""+']+)[.]{1}(js)('|"")*"
				set matches = regex.execute(str)
				if matches.count>0 then
					for each match in matches
						url = match.submatches(1) & ".js"
						if left(url,1)="/" or InStr(url,t0) or left(url,7)<>"http://" then 
							if left(url,1)="/" Then 
								url = t0_new & url
							Else
								url = t0 & "/" & Replace(url,"../","")
							end if
							url=replace(url,"https://","http://")
							if InStr(urlstr,url)=0 Then 
								urlstr = urlstr & url & ","
								eycms.echo url&"<br>"
								eycms.echo "<script>window.scroll(0,99999)</script>"
								response.flush()
							end If
						end if
					next
				end If
			Else
				eycms.echo "<script>parent.opensetp(2);</script>"
				eycms.echo "分析页面" & pages(j) & "失败！<br>"
				response.flush()
			end If
		End if
	next
	if Right(urlstr,1)="," Then urlstr=Left(urlstr,Len(urlstr)-1)
	if InStr(urlstr,",")>0 then
		uarr=Split(urlstr,",")
		set objxml = new eycms_clsxml
		objxml.createfile webroot&"plug/downsite/cssjs.xml", "config"
		for i=0 To UBound(uarr)
			strfext=mid(uarr(i),instrrev(uarr(i),".")+1)
			objxml.createrootchild "item"
			objxml.createchildnode_cdata "item",strfext,uarr(i),i+1
		next
		objxml.save()
		set objxml = nothing
	End If

	eycms.echo "抓取css、js完毕<br>"
	eycms.echo "<script>parent.tosetp3("&auto&");window.scroll(0,99999)</script><br>"
	response.flush()
	if err then
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		response.flush()
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	end if
end Sub

sub dodb3()
	On Error Resume Next
	'eycms.echo "<script>parent.locksetp(3);</script>"
	eycms.echo "正在提取css图片，请耐心等待......<br>"
	response.flush()
	dim t0:t0=eycms.enhtml(eycms.fpost("t0",0))
	dim t1:t1=eycms.enhtml(eycms.fpost("t1",0))
	dim auto:auto=eycms.getint(eycms.fpost("auto",0),0)
	if Left(LCase(t0),7)<>"http://" Then t0="http://"&t0
	If Right(t0,1)<>"/" Then t0=t0 & "/"
	session("encodeing")=""
	Dim temp:temp=getxmlhttp(t0,"auto")
	dim objxml, str, html, css, js
	set objxml = new eycms_clsxml
	objxml.file = webroot & "plug/downsite/cssjs.xml"
	If Not eycms.isfolder(webroot&"theme/"&t1&"/images/") Then eycms.newfolder webroot&"theme/"&t1&"/images/"
	If Not eycms.isfolder(webroot&"theme/"&t1&"/css/") Then eycms.newfolder webroot&"theme/"&t1&"/css/"
	for each str in objxml.getfield("item//css",0) 
		If eycms.strlen(str)>0 then
			eycms.echo "正在提取" & str & "<br>"
			eycms.echo "<script>window.scroll(0,99999)</script>"
			response.flush()
			c_replace t0, str, webroot&"theme/"&t1&"/images/", "gif|jpg|png|cur"
			c_replace t0, str, webroot&"theme/"&t1&"/font/", "woff|ttf|eot|svg"
		End if
	next
	eycms.newfolder webroot&"theme/"&t1&"/js/"
	for each str in objxml.getfield("item//js",0) 
		If eycms.strlen(str)>0 then
			eycms.echo "正在提取" & str & "<br>"
			eycms.echo "<script>window.scroll(0,99999)</script>"
			response.flush()
			js = mid(str,instrrev(str,"/")+1)
			html = getxmlhttp(str,"auto")
			eycms.newfile webroot&"theme/"&t1&"/js/", js, html, "utf-8"
		End if
	next
	set objxml = Nothing
	eycms.echo "提取css图片、js完毕<br>"
	eycms.echo "<script>parent.tosetp4("&auto&");window.scroll(0,99999)</script><br>"
	response.flush()
	if err then
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		response.flush()
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	end if
end Sub

sub dodb4()
	On Error Resume Next
	'eycms.echo "<script>parent.locksetp(4);</script>"
	eycms.echo "正在提取页面，请耐心等待......<br>"
	response.flush()
	On Error Resume Next
	dim t0,t0_new,t1,pages(7),setmore
	dim t8b,t8b_0,t8e,t8e_0
	dim t9b,t9b_0,t9e,t9e_0
	dim t10b,t10b_0,t10e,t10e_0
	dim t11b,t11b_0,t11e,t11e_0
	t0=eycms.enhtml(eycms.fpost("t0",0))
	t1=eycms.enhtml(eycms.fpost("t1",0))
	pages(0)="首页"
	pages(1)=eycms.enhtml(eycms.fpost("t2",0))
	pages(2)=eycms.enhtml(eycms.fpost("t3",0))
	pages(3)=eycms.enhtml(eycms.fpost("t4",0))
	pages(4)=eycms.enhtml(eycms.fpost("t5",0))
	pages(5)=eycms.enhtml(eycms.fpost("t6",0))
	pages(6)=eycms.enhtml(eycms.fpost("t7",0))
	pages(7)=eycms.enhtml(eycms.fpost("t60",0))

	setmore=eycms.getint(eycms.fpost("setmore",0),0)
	if setmore=1 then
		t8b=eycms.fpost("t8b",1)
		t8b_0=eycms.getint(eycms.fpost("t8b_0",0),0)
		if t8b_0=1 Then t8b_0=true else t8b_0=false
		t8e=eycms.fpost("t8e",1)
		t8e_0=eycms.getint(eycms.fpost("t8e_0",0),0)
		if t8e_0=1 Then t8e_0=true else t8e_0=false

		t9b=eycms.fpost("t9b",1)
		t9b_0=eycms.getint(eycms.fpost("t9b_0",0),0)
		if t9b_0=1 Then t9b_0=true else t9b_0=false
		t9e=eycms.fpost("t9e",1)
		t9e_0=eycms.getint(eycms.fpost("t9e_0",0),0)
		if t9e_0=1 Then t9e_0=true else t9e_0=false

		t10b=eycms.fpost("t10b",1)
		t10b_0=eycms.getint(eycms.fpost("t10b_0",0),0)
		if t10b_0=1 Then t10b_0=true else t10b_0=false
		t10e=eycms.fpost("t10e",1)
		t10e_0=eycms.getint(eycms.fpost("t10e_0",0),0)
		if t10e_0=1 Then t10e_0=true else t10e_0=false

		t11b=eycms.fpost("t11b",1)
		t11b_0=eycms.getint(eycms.fpost("t11b_0",0),0)
		if t11b_0=1 Then t11b_0=true else t11b_0=false
		t11e=eycms.fpost("t11e",1)
		t11e_0=eycms.getint(eycms.fpost("t11e_0",0),0)
		if t11e_0=1 Then t11e_0=true else t11e_0=false
	end if
	
	dim is_end:is_end="<%"
	is_end=is_end&"if not in_eycms then response.write(""template load fail""):response.end() end if"
	is_end=is_end&"%"
	is_end=is_end&">"

	eycms.echo "提取准备中，请稍后...<br>"
	response.flush()

	if Left(LCase(t0),7)<>"http://" Then t0="http://"&t0
	If Right(t0,1)="/" Then t0=left(t0,Len(t0)-1)
	If GetCount(t0,"/")>=2 Then
		t0_new="http://"&Split(t0,"/")(2)
	End if
	If Not eycms.isfolder(webroot&"theme/"&t1&"/upfile/") Then eycms.newfolder webroot&"theme/"&t1&"/upfile/"
	Dim remote, local
	dim regex, matches, match, url, j
	dim head, head_css, head_js, head_ie6, head_script, head_style
	dim body, bodyL, bodyR, imgext, fpath
	dim head_html, foot_html, left_html, nav_html
	set regex = new regexp
	regex.IgnoreCase = true
	regex.Global = True
	savedfiles=""

	if setmore=1 then
		for j=0 To 7
			If pages(j)<>"" then
				remote=getxmlhttp(t0 & "/" & Replace(pages(j),"首页",""),"auto")
				remote=Replace(remote,"../","")
				local=eycms.loadfile(webroot&"theme/"&t1&"/"&getlocal(j))

				if eycms.strlen(remote)>0 And eycms.strlen(local)>0 Then
					head=GetBody(remote,"<head>","</head>",true,true,0)
					head_ie6=""
					head_script=""
					head_style=""
					head_css=""
					head_js=""
					dim css3
					regex.pattern="href=('|"")*([^>+""+']+)[.]{1}(css)('|"")*"
					set matches = regex.execute(head)
					if matches.count>0 then
						for each match in matches
							css3 = ""
							url = match.submatches(1) & ".css"
							if left(url,1)="/" or InStr(url,t0) or left(url,7)<>"http://" then 
								if InStr(urlstr,url)=0 Then
									url = mid(url,instrrev(url,"/")+1)
									If url="metinfo_ui.css" Then css3 = " id=""metuimodule"" data-module =""10001"""
									head_css = head_css & "<LINK href=""{skins}/css/"&url&""" rel=stylesheet"&css3&">" & vbcrlf
								end If
							end if
						next
					end If

					head_ie6=GetContent(head,"<!--[if IE","<![endif]-->",1)
					If head_ie6<>"" Then head=GetContent(head,"<!--[if IE","<![endif]-->",6)

					regex.pattern="src=('|"")*([^>+""+']+)[.]{1}(js)('|"")*"
					set matches = regex.execute(head)
					if matches.count>0 then
						for each match in matches
							url = match.submatches(1) & ".js"
							if left(url,1)="/" or InStr(url,t0) or left(url,7)<>"http://" then 
								if InStr(urlstr,url)=0 Then
									url = mid(url,instrrev(url,"/")+1)
									head_js = head_js & "<script language=""JavaScript"" type=""text/javascript"" src=""{skins}/js/"&url&"""></script>" & vbcrlf
								end If
							end if
						next
					end If

					regex.pattern="src=('|"")*([^>+""+']+)[.]{1}(js)('|"")*"
					set matches = regex.execute(head_ie6)
					if matches.count>0 then
						for each match in matches
							url = match.submatches(1) & ".js"
							if left(url,1)="/" or InStr(url,t0) or left(url,7)<>"http://" then 
								fpath = mid(url,instrrev(url,"/")+1)
								head_ie6 = Replace(head_ie6, url, "{skins}/js/"&fpath)
							end if
						next
					end If
					head_script=GetContent(head,"<script>","</script>",1)
					head_style=GetContent(head,"<style>","</style>",1)
					local=Replace(local,"<!--[head]-->",head_css & head_js & head_ie6 & head_script & head_style)

					body=GetContent(remote,"<body>","</body>",1)

					regex.pattern="\{([a-zA-Z0-9_()/.,"" >]*)\}"
					set matches = regex.execute(body)
					if matches.count>0 Then
						for each match in matches
							body=Replace(body, match.value, Replace(match.value,"{","{" & vbcrlf))
						next
					end If

					if setmore=1 then
						If eycms.strlen(t8b)>0 and eycms.strlen(t8e)>0 Then
							If j=0 Then head_html=GetBody(body, t8b, t8e, t8b_0, t8e_0, 0)
							bodyL=GetBody(body, head_html, "", false, false, 1)
							bodyR=GetBody(body, head_html, "", false, false, 2)
							If eycms.strlen(bodyL)>0 And eycms.strlen(bodyR) then
								If InStr(getlocal(j),"model/") Then
									body = bodyL & "{eycms:include(""../../eycms_head.asp"")}" & bodyR
								Else
									body = bodyL & "{eycms:include(""eycms_head.asp"")}" & bodyR
								End If
							End If
						End If

						If eycms.strlen(t9b)>0 and eycms.strlen(t9e)>0 Then
							If j=0 Then foot_html=GetBody(body, t9b, t9e, t9b_0, t9e_0, 0)
							bodyL=GetBody(body, foot_html, "", false, false, 1)
							bodyR=GetBody(body, foot_html, "", false, false, 2)
							If eycms.strlen(bodyL)>0 And eycms.strlen(bodyR) then
								If InStr(getlocal(j),"model/") Then
									body = bodyL & "{eycms:include(""../../eycms_foot.asp"")}" & bodyR
								Else
									body = bodyL & "{eycms:include(""eycms_foot.asp"")}" & bodyR
								End If
							End If
						End If
						If eycms.strlen(t10b)>0 and eycms.strlen(t10e)>0 Then
							left_html=GetBody(body, t10b, t10e, t10b_0, t10e_0, 0)
							bodyL=GetBody(body, left_html, "", false, false, 1)
							bodyR=GetBody(body, left_html, "", false, false, 2)
							If eycms.strlen(bodyL)>0 And eycms.strlen(bodyR) then
								If InStr(getlocal(j),"model/") Then
									body = bodyL & "{eycms:include(""../../eycms_left.asp"")}" & bodyR
								Else
									body = bodyL & "{eycms:include(""eycms_left.asp"")}" & bodyR
								End If
							End If
						End If
					End If

					body=getremote_img(body,t0,t1)
					body=GetContent(body,"<body>","</body>",0)
					if setmore=0 then
						If InStr(getlocal(j),"model/") Then
							body = body & vbcrlf & "{eycms:include(""../../eycms_foot.asp"")}"
						Else
							body = body & vbcrlf & "{eycms:include(""eycms_foot.asp"")}"
						End If
					End If
					dim other:other=GetBody(remote,"</head>","<body>",false, false,0)
					other=getremote_img(other,t0,t1)
					If other<>"" Then local=Replace(local,"</head>","</head>" & vbcrlf & other)
					local=Replace(local,"<!--[body]-->",body)
					eycms.echo "正在生成页面" & getlocal(j) & "<br>"
					response.flush()
					eycms.newfile webroot&"theme/"&t1&"/", getlocal(j), local, "utf-8"
				Else
					eycms.echo "<script>parent.opensetp(4);</script>"
					eycms.echo "生成页面" & getlocal(j) & "失败！<br>"
					response.flush()
				end If
			End if
		Next


		dim menu, menu_class, menu_index, menu_index_class, menustr
		dim menu_last, menu_last_class, mu
		If eycms.strlen(t11b)>0 and eycms.strlen(t11e)>0 Then
			nav_html=GetBody(head_html, t11b, t11e, t11b_0, t11e_0, 0)
			bodyL=GetBody(head_html, nav_html, "", false, false, 1)
			bodyR=GetBody(head_html, nav_html, "", false, false, 2)
			If eycms.strlen(bodyL)>0 And eycms.strlen(bodyR) then
				head_html = bodyL & "<!--{nav}-->" & bodyR
			End If
			nav_html=getremote_img(nav_html,t0,t1)

			regex.pattern="\<(li|td|dt)([^<>]*)\>(.+?)\<\/(li|td|dt)\>"
			set matches = regex.execute(nav_html)
			if matches.count>0 Then
				mu = 0
				for each match in matches
					If InStr(match.value,"首页") Then
						menu_index = match.value
					Else
						If mu = 0 then
							menu = match.value
						Else
							menu_last = match.value
						End if
						mu = mu + 1
					End If
				Next
			Else
				regex.pattern="\<a([^<>]*)\>(.+?)\<\/a\>"
				set matches = regex.execute(nav_html)
				if matches.count>0 Then
					mu = 0
					for each match in matches
						If InStr(match.value,"首页") Then
							menu_index = match.value
						Else
							If mu = 0 then
								menu = match.value
							Else
								menu_last = match.value
							End if
							mu = mu + 1
						End If
					Next
				end If
			end If

			regex.pattern="([a-zA-Z0-9_]*)[\s]*=[\s]*['|""](.+?)['|""]"
			set matches=regex.execute(menu_index)
			if matches.count>0 then
				for each match in matches
					Select Case match.submatches(0)
					Case "href"
						If match.submatches(1)="/" Then
							menu_index=Replace(menu_index,"""/""","""{webroot}""")
							menu_index=Replace(menu_index,"'/'","'{webroot}'")
						else
							menu_index=Replace(menu_index,match.submatches(1),"{webroot}")
						End if
					Case "class"
						menu_index_class=match.submatches(1)
					End select
				Next
			end If

			regex.pattern="([a-zA-Z0-9_]*)[\s]*=[\s]*['|""](.+?)['|""]"
			set matches=regex.execute(menu_last)
			if matches.count>0 then
				for each match in matches
					If match.submatches(0) = "class" Then 
						menu_last_class = match.submatches(1)
						Exit For
					End if
				Next
			end If

			regex.pattern="([a-zA-Z0-9_]*)[\s]*=[\s]*['|""](.+?)['|""]"
			set matches=regex.execute(menu)
			if matches.count>0 then
				for each match in matches
					Select Case match.submatches(0)
					Case "title"
						menu=Replace(menu,match.submatches(1),"{$rs[catename]}")
						menu=Replace(menu,">{$rs[catename]}<",">{eycms.cutstr($rs[catename],10,0)}<")
					Case "href"
						menu=Replace(menu,match.submatches(1),"{$rs[link]}")
					Case "class"
						menu_class=match.submatches(1)
					End select
				Next
			end If

			'If eycms.strlen(menu_index_class)>0 And eycms.strlen(menu_class)>0 then
			'	If menu_index_class<>menu_class Then
			'		menu_index=Replace(menu, menu_index_class, "{if isindex=""yes""}"&menu_index_class&"{else}"&menu_class&"{/if}")
			'		menu=Replace(menu, menu_class, "{if instr(parentid,$rs[cateid])}"&menu_index_class&"{else}"&menu_class&"{/if}")
			'	End If
			'End If
			'If eycms.strlen(menu_index_class)>0 And eycms.strlen(menu_class)=0 Then
			'	menu_index=Replace(menu, menu_index_class, "{if isindex=""yes""}"&menu_index_class&"{/if}")
			'End If
			'If eycms.strlen(menu_last_class)>0 Then
			'	If menu_last_class<>menu_class Then
			'		If eycms.strlen(menu_class)>0 Then
			'			menu=Replace(menu, menu_class, menu_class & "{if i=8} "& menu_last_class & "{/if}")
			'		End If
			'	End if
			'End if

			menu = menu_index & vbcrlf & "{eycms:rs top=""8"" table=""ey_category"" where=""followid=0 and ismenu=1"" order=""ordnum,cateid"" var=""eycms_rp:cateid""}" & vbcrlf & menu & vbcrlf & "{/eycms:rs}" & vbcrlf
		End If
	else
		for j=0 To 7
			If pages(j)<>"" then
				remote=getxmlhttp(t0 & "/" & Replace(pages(j),"首页",""),"auto")
				remote=Replace(remote,"../","")

				local=eycms.loadfile(webroot&"theme/"&t1&"/"&getlocal(j))
				if eycms.strlen(remote)>0 And eycms.strlen(local)>0 Then
					body=remote
					body=getremote_img(body,t0,t1)
					local=is_end & vbcrlf & body
					eycms.echo "正在生成页面" & getlocal(j) & "<br>"
					response.flush()
					eycms.newfile webroot&"theme/"&t1&"/", getlocal(j), local, "utf-8"
				Else
					eycms.echo "<script>parent.opensetp(4);</script>"
					eycms.echo "生成页面" & getlocal(j) & "失败！<br>"
					response.flush()
				end If
			End if
		Next
	End If
	Set regex=Nothing

	if setmore=1 then
		head_html="<"&"%if not in_eycms then response.write(""template load fail""):response.end() end if%"&">" & vbcrlf & getremote_img(head_html,t0,t1)
		head_html = Replace(head_html,"<!--{nav}-->",menu)
		eycms.newfile webroot&"theme/"&t1&"/", "eycms_head.asp", head_html, "utf-8"
		eycms.echo "正在生成页面eycms_head.asp<br>"
		response.flush()

		foot_html="<"&"%if not in_eycms then response.write(""template load fail""):response.end() end if%"&">" & vbcrlf & getremote_img(foot_html,t0,t1)
		eycms.newfile webroot&"theme/"&t1&"/", "eycms_foot.asp", foot_html, "utf-8"
		eycms.echo "正在生成页面eycms_foot.asp<br>"
		response.flush()

		If eycms.strlen(left_html)>0 Then
			left_html="<"&"%if not in_eycms then response.write(""template load fail""):response.end() end if%"&">" & vbcrlf & getremote_img(left_html,t0,t1)
			eycms.newfile webroot&"theme/"&t1&"/", "eycms_left.asp", left_html, "utf-8"
			eycms.echo "正在生成页面eycms_left.asp<br>"
			response.flush()
		End if
	End If
	
	if err Then
		eycms.echo "<script>parent.opensetp(4);</script>"
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	Else
		'eycms.delfile webroot & "plug/downsite/site.xml"
		eycms.delfile webroot & "plug/downsite/cssjs.xml"
		if eycms.isfile(webroot & "plug/downsite/theme.txt") then
			'dim theme:theme=eycms.loadfile(webroot & "plug/downsite/theme.txt")
			't1="cms0" & CStr(CLng(theme)+1)
			'eycms.newfile webroot & "plug/downsite/", "theme.txt", CStr(CLng(theme)+1), "utf-8"
		end If
		eycms.echo "提取页面完毕<br>"
		eycms.echo "<script>parent.opensetp(4);window.scroll(0,99999)</script><br>"
		response.flush()
	end if
	if err then
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		response.flush()
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	end if
end Sub

'注释：分析目标WAP网站
sub resolvedb_wap()
	session("encodeing")=""
	dim t0:t0=eycms.enhtml(eycms.fget("t0",0))
	if eycms.strlen(t0)=0 Then
		eycms.echo "0请输入目标WAP网站"
		exit sub
	end If
	if Left(LCase(t0),7)<>"http://" Then t0="http://"&t0
	If Right(t0,1)="/" Then t0 = Left(t0,Len(t0)-1)

	dim str:str=getxmlhttp_wap(t0,"auto")
	dim head:head=GetBody(str,"<head>","</head>",true,true,0)
	dim body:body=GetBody(str,"<body>","</body>",true,true,0)
	if len(body)=0 then body=GetBody(str,"</head>","</body>",false,true,0)
	body=Replace(body,t0&"/","")

	if eycms.strlen(head)>0 and eycms.strlen(body)>0 then
		dim t2,t4,t5
		dim regex,matches,match,url,urlstr,urlstr2,uarr,i
		set regex = new regexp
		regex.IgnoreCase = true
		regex.Global = true
		regex.pattern="href=('|"")([^>+""+']+)('|"")"
		set matches = regex.execute(body)
		if matches.count>0 Then
			for each match in matches
				url = match.submatches(1)
				if InStr(url,"?")=0 and eycms.strlen(url)>0 and url<>"/" and Left(LCase(url),7)<>"http://" and Left(LCase(url),4)<>"www." and InStr(url,"javascript:")=0 then 
					if left(url,1)="/" Then url=Right(url,Len(url)-1)
					if InStr(urlstr,url)=0 Then urlstr = urlstr & url & ","
					if InStr(urlstr2,url)=0 Then urlstr2 = urlstr2 & url & ","
				end If
			Next
			If Right(urlstr,1)="," Then urlstr=Left(urlstr,Len(urlstr)-1)
			If Right(urlstr2,1)="," Then urlstr2=Left(urlstr2,Len(urlstr2)-1)
		end If

		If InStr(urlstr,",")>0 then
			uarr=Split(urlstr,",")
			For i=0 To UBound(uarr)
			  If t2="" And (InStr(LCase(uarr(i)),"about") Or InStr(LCase(uarr(i)),"company")) Then t2=uarr(i)
			  If t4="" And InStr(LCase(uarr(i)),"product") Then t4=uarr(i)
			  If t5="" And (InStr(LCase(uarr(i)),"child/") Or InStr(LCase(uarr(i)),"news") Or InStr(LCase(uarr(i)),"new/") Or InStr(LCase(uarr(i)),"new.")) Then t5=uarr(i)
			Next
		End If
		If t2="" And t4="" Then
			uarr=Split(urlstr2,",")
			For i=0 To UBound(uarr)
			  If t2="" And InStr(LCase(uarr(i)),"about") Then t2=uarr(i)
			  If t4="" And InStr(LCase(uarr(i)),"product") Then t4=uarr(i)
			  If t5="" And (InStr(LCase(uarr(i)),"child/") Or InStr(LCase(uarr(i)),"news") Or InStr(LCase(uarr(i)),"new/") Or InStr(LCase(uarr(i)),"new.")) Then t5=uarr(i)
			Next
		End If
		eycms.echo "1" & t2 & "_" & t4 & "_" & t5
	else
		eycms.echo "0抓取站点站失败，或者目标站点结构不规范！"
	end If
	if err Then
		eycms.echo "0发生错误:"&err.description
	End If
end Sub

'注释：分析目标WAP网站内容页
sub resolvedb2_wap()
	On Error Resume next
	dim t0:t0=eycms.enhtml(eycms.fget("t0",0))
	dim t1:t1=eycms.enhtml(eycms.fget("t1",0))
	dim t2:t2=t1
	if eycms.strlen(t0)=0 Then
		eycms.echo "0请输入目标网站"
		exit sub
	end If
	if eycms.strlen(t1)=0 Then
		eycms.echo "0请输入目标网站列表页"
		exit sub
	end If
	If Left(t1,1)="/" Then t1 = Right(t1,Len(t1)-1)
	if Left(LCase(t0),7)<>"http://" Then t0 = "http://" & t0
	If Right(t0,1)<>"/" Then t0 = t0 & "/"
	if GetCount(t0,"/")>3 then t0="http://" & split(t0,"/")(2) & "/"
	dim str:str=getxmlhttp_wap(t0 & t1, "auto")
	Dim ulen:ulen=eycms.strlen(t1)
	If InStr(t1,".")>0 Then t1=Split(t1,".")(0)
	If InStr(t1,"/")>0 Then t1=Split(t1,"/")(0)
	dim body:body=GetContent(str,"<body>","</body>",0)
	if len(body)=0 then body=GetContent(str,"</head>","</body>",0)
	if eycms.strlen(body)=0 then body=str
	body=Replace(body,t0,"")

	if eycms.strlen(body)>0 Then
		body=Replace(body,t2&"?","")
		dim regex,matches,match,url,urlstr1,urlstr2,urlstr
		set regex = new regexp
		regex.IgnoreCase = true
		regex.Global = true
		regex.pattern="href=('|"")([^>+""+']+)('|"")"
		set matches = regex.execute(body)
		if matches.count>0 Then
			for each match in matches
				url = match.submatches(1)
				If Left(url,1)="/" Then url = Right(url,Len(url)-1)
				If Left(url,3)="../" Then url = Right(url,Len(url)-3)
				if InStr(url,"view") Or InStr(url,"show") then
					urlstr1 = url
				elseif InStr(url,"?") then
					urlstr2 = url
				end If
			next
		end If
		urlstr=urlstr1
		if eycms.strlen(urlstr)=0 then urlstr=urlstr2
		if eycms.strlen(urlstr)>0 Then
			eycms.echo "1" & urlstr
		else
			eycms.echo "0获取失败，请手动输入！"
		end if
	else
		eycms.echo "0获取失败，请手动输入！！"
	end If
	if err Then
		eycms.echo "0发生错误:"&err.description
	End If
end Sub

sub wapdodb()
	On Error Resume Next
	dim t0,t1,t2,t4,t5,t6,t7,auto
	t0=eycms.enhtml(eycms.fpost("t0",0))
	t1=eycms.enhtml(eycms.fpost("t1",0))
	t2=eycms.enhtml(eycms.fpost("t2",0))
	t4=eycms.enhtml(eycms.fpost("t4",0))
	t5=eycms.enhtml(eycms.fpost("t5",0))
	t6=eycms.enhtml(eycms.fpost("t6",0))
	t7=eycms.enhtml(eycms.fpost("t7",0))
	auto=eycms.getint(eycms.fpost("auto",0),0)
	dim objxml
	set objxml = new eycms_clsxml
	objxml.createfile webroot&"plug/downsite/site_wap.xml", "config"
	objxml.createrootchild "item"
	objxml.createchildnode "item","site",t0,1
	objxml.createchildnode "item","theme",t1,1
	objxml.createchildnode "item","page",t2,1
	objxml.createchildnode "item","photolist",t4,1
	objxml.createchildnode "item","photoshow",t5,1
	objxml.createchildnode "item","newslist",t6,1
	objxml.createchildnode "item","newsshow",t7,1
	objxml.createchildnode "item","auto",auto,1
	objxml.save()
	set objxml = Nothing

	eycms.echo "初始化完毕<br>"
	eycms.echo "<script>parent.tosetp2("&auto&");window.scroll(0,99999)</script><br>"
	response.flush()
	if err then
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		response.flush()
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	end if
end Sub

sub wapdodb2()
	On Error Resume Next
	'eycms.echo "<script>parent.locksetp(2);</script>"
	eycms.echo "正在抓取css、js，请耐心等待......<br>"
	response.flush()
	dim t0,t0_2,t1,pages(6),j,str,auto
	t0=eycms.enhtml(eycms.fpost("t0",0))
	t1=eycms.enhtml(eycms.fpost("t1",0))
	pages(0)=t0
	pages(1)=eycms.enhtml(eycms.fpost("t2",0))
	pages(3)=eycms.enhtml(eycms.fpost("t4",0))
	pages(4)=eycms.enhtml(eycms.fpost("t5",0))
	pages(5)=eycms.enhtml(eycms.fpost("t6",0))
	pages(6)=eycms.enhtml(eycms.fpost("t7",0))
	auto=eycms.getint(eycms.fpost("auto",0),0)

	if Left(LCase(t0),7)<>"http://" Then t0="http://"&t0
	If Right(t0,1)="/" Then t0=left(t0,Len(t0)-1)
	If GetCount(t0,"/")>2 Then t0_2="http://"&Split(t0,"/")(2)
	pages(0)=Replace(pages(0),t0 & "/","")

	dim regex,matches,match,url,urlstr,uarr,i
	dim objxml,strfext

	for j=0 To 6
		If pages(j)<>"" then
			str=getxmlhttp_wap(t0 & "/" & pages(j),"auto")
			str=Replace(str,t0 & "/","")
			if eycms.strlen(str)>0 Then
				set regex = new regexp
				regex.IgnoreCase = true
				regex.Global = true
				regex.pattern="href=('|"")*([^>+""+']+)[.]{1}(css)('|"")*"
				set matches = regex.execute(str)
				if matches.count>0 then
					for each match in matches
						url = match.submatches(1) & ".css"
						if left(url,1)="/" or InStr(url,t0) or left(url,7)<>"http://" then 
							if left(url,1)="/" Then 
								url = t0_2 & url
							Else
								url = t0 & "/" & Replace(url,"../","")
							end if
							if InStr(urlstr,url)=0 Then 
								urlstr = urlstr & url & ","
								eycms.echo url&"<br>"
								eycms.echo "<script>window.scroll(0,99999)</script>"
								response.flush()
							end if
						end if
					next
				end If
				regex.pattern="src=('|"")*([^>+""+']+)[.]{1}(js)('|"")*"
				set matches = regex.execute(str)
				if matches.count>0 then
					for each match in matches
						url = match.submatches(1) & ".js"
						if left(url,1)="/" or InStr(url,t0) or left(url,7)<>"http://" then 
							if left(url,1)="/" Then 
								url = t0_2 & url
							Else
								url = t0 & "/" & Replace(url,"../","")
							end if
							if InStr(urlstr,url)=0 Then 
								urlstr = urlstr & url & ","
								eycms.echo url&"<br>"
								eycms.echo "<script>window.scroll(0,99999)</script>"
								response.flush()
							end If
						end if
					next
				end If
			Else
				eycms.echo "<script>parent.opensetp(2);</script>"
				eycms.echo "分析页面" & pages(j) & "失败！<br>"
				response.flush()
			end If
		End if
	next
	if Right(urlstr,1)="," Then urlstr=Left(urlstr,Len(urlstr)-1)
	if InStr(urlstr,",")>0 then
		uarr=Split(urlstr,",")
		set objxml = new eycms_clsxml
		objxml.createfile webroot&"plug/downsite/cssjs_wap.xml", "config"
		for i=0 To UBound(uarr)
			strfext=mid(uarr(i),instrrev(uarr(i),".")+1)
			objxml.createrootchild "item"
			objxml.createchildnode_cdata "item",strfext,uarr(i),i+1
		next
		objxml.save()
		set objxml = nothing
	End If

	eycms.echo "抓取css、js完毕<br>"
	eycms.echo "<script>parent.tosetp3("&auto&");window.scroll(0,99999)</script><br>"
	response.flush()
	if err then
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		response.flush()
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	end if
end Sub

sub wapdodb3()
	On Error Resume Next
	'eycms.echo "<script>parent.locksetp(3);</script>"
	eycms.echo "正在提取css图片，请耐心等待......<br>"
	response.flush()
	dim t0:t0=eycms.enhtml(eycms.fpost("t0",0))
	dim t1:t1=eycms.enhtml(eycms.fpost("t1",0))
	dim auto:auto=eycms.getint(eycms.fpost("auto",0),0)
	if Left(LCase(t0),7)<>"http://" Then t0="http://"&t0
	If Right(t0,1)<>"/" Then t0=t0 & "/"
	'If GetCount(t0,"/")>3 Then t0_2="http://"&Split(t0,"/")(2) & "/"
	session("encodeing")=""
	Dim temp:temp=getxmlhttp_wap(t0,"auto")
	dim objxml, str, html, css, js
	set objxml = new eycms_clsxml
	objxml.file = webroot & "plug/downsite/cssjs_wap.xml"
	If Not eycms.isfolder(webroot&"theme/"&t1&"/mobile/images/") Then eycms.newfolder webroot&"theme/"&t1&"/mobile/images/"
	If Not eycms.isfolder(webroot&"theme/"&t1&"/mobile/css/") Then eycms.newfolder webroot&"theme/"&t1&"/mobile/css/"
	If Not eycms.isfolder(webroot&"theme/"&t1&"/mobile/font/") Then eycms.newfolder webroot&"theme/"&t1&"/mobile/font/"
	for each str in objxml.getfield("item//css",0) 
		If eycms.strlen(str)>0 then
			eycms.echo "正在提取" & str & "<br>"
			eycms.echo "<script>window.scroll(0,99999)</script>"
			response.flush()
			c_replace t0, str, webroot&"theme/"&t1&"/mobile/images/", "gif|jpg|png|cur"
			c_replace t0, str, webroot&"theme/"&t1&"/mobile/font/", "woff|ttf|eot|svg"
		End if
	next
	eycms.newfolder webroot&"theme/"&t1&"/mobile/js/"
	for each str in objxml.getfield("item//js",0) 
		If eycms.strlen(str)>0 then
			eycms.echo "正在提取" & str & "<br>"
			eycms.echo "<script>window.scroll(0,99999)</script>"
			response.flush()
			js = mid(str,instrrev(str,"/")+1)
			html = getxmlhttp_wap(str,"auto")
			eycms.newfile webroot&"theme/"&t1&"/mobile/js/", js, html, "utf-8"
		End if
	next
	set objxml = Nothing
	eycms.echo "提取css图片、js完毕<br>"
	eycms.echo "<script>parent.tosetp4("&auto&");window.scroll(0,99999)</script><br>"
	response.flush()
	if err then
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		response.flush()
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	end if
end Sub

sub wapdodb4()
	On Error Resume Next
	'eycms.echo "<script>parent.locksetp(4);</script>"
	eycms.echo "正在提取页面，请耐心等待......<br>"
	response.flush()
	On Error Resume Next
	dim t0,t1,pages(6)
	t0=eycms.enhtml(eycms.fpost("t0",0))
	t1=eycms.enhtml(eycms.fpost("t1",0))
	pages(0)="首页"
	pages(1)=eycms.enhtml(eycms.fpost("t2",0))
	pages(3)=eycms.enhtml(eycms.fpost("t4",0))
	pages(4)=eycms.enhtml(eycms.fpost("t5",0))
	pages(5)=eycms.enhtml(eycms.fpost("t6",0))
	pages(6)=eycms.enhtml(eycms.fpost("t7",0))

	eycms.echo "提取准备中，请稍后...<br>"
	response.flush()

	if Left(LCase(t0),7)<>"http://" Then t0="http://"&t0
	If Right(t0,1)="/" Then t0=left(t0,Len(t0)-1)
	'If GetCount(t0,"/")>2 Then t0="http://"&Split(t0,"/")(2)
	pages(0)=Replace(pages(0),t0 & "/","")
	session("encodeing")=""
	Dim remote, local
	dim regex, matches, match, url, j
	dim body, imgext, fpath
	set regex = new regexp
	regex.IgnoreCase = true
	regex.Global = True
	savedfiles=""
	dim is_end:is_end="<%"
	is_end=is_end&"if not in_eycms then response.write(""template load fail""):response.end() end if"
	is_end=is_end&"%"
	is_end=is_end&">"

	for j=0 To 6
		If pages(j)<>"" then
			remote=getxmlhttp_wap(t0 & "/" & Replace(pages(j),"首页",""),"auto")
			remote=Replace(remote,"../","")
			local=eycms.loadfile(webroot&"theme/"&t1&"/mobile/"&getlocal(j))
			if eycms.strlen(remote)>0 And eycms.strlen(local)>0 Then
				body=remote
				body=getremote_img(body,t0,t1)
				local=is_end & vbcrlf & body
				eycms.echo "正在生成页面" & getlocal(j) & "<br>"
				response.flush()
				eycms.newfile webroot&"theme/"&t1&"/mobile/", getlocal(j), local, "utf-8"
			Else
				eycms.echo "<script>parent.opensetp(4);</script>"
				eycms.echo "生成页面" & getlocal(j) & "失败！<br>"
				response.flush()
			end If
		End if
	Next
	Set regex=Nothing
	
	if err Then
		eycms.echo "<script>parent.opensetp(4);</script>"
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	Else
		eycms.delfile webroot & "plug/downsite/cssjs_wap.xml"
		if eycms.isfile(webroot & "plug/downsite/theme.txt") then
			'dim theme:theme=eycms.loadfile(webroot & "plug/downsite/theme.txt")
			't1="cms0" & CStr(CLng(theme)+1)
			'eycms.newfile webroot & "plug/downsite/", "theme.txt", CStr(CLng(theme)+1), "utf-8"
		end If
		eycms.echo "提取页面完毕<br>"
		eycms.echo "<script>parent.opensetp(4);window.scroll(0,99999)</script><br>"
		response.flush()
	end if
	if err then
		eycms.echo "发生错误，错误内容为：<span>"&err.description&"</span><br>"
		response.flush()
		eycms.echo "<script>window.scroll(0,99999)</script><br>"
	end if
end Sub

Function getlocal(page)
	Select Case page
	Case 0
		getlocal="eycms_index.asp"
	Case 1
		getlocal="model/page/eycms_page.asp"
	Case 2
		getlocal="eycms_book.asp"
	Case 3
		getlocal="model/photo/eycms_list.asp"
	Case 4
		getlocal="model/photo/eycms_show.asp"
	Case 5
		getlocal="model/news/eycms_list.asp"
	Case 6
		getlocal="model/news/eycms_show.asp"
	Case 7
		getlocal="model/news/eycms_list_pic.asp"
	End select
End Function

dim act:act=lcase(eycms.fget("act",0))
select case act
	case "resolve":resolvedb
	case "resolve2":resolvedb2
	case "chgtheme":chgtheme
	case "do":dodb
	case "do2":dodb2
	case "do3":dodb3
	case "do4":dodb4
	case "resolve_wap":resolvedb_wap
	case "resolve2_wap":resolvedb2_wap
	case "wapdo":wapdodb
	case "wapdo2":wapdodb2
	case "wapdo3":wapdodb3
	case "wapdo4":wapdodb4
	case "wap"
		dim w0,w1,w2,w3,w4,w5,auto_wap,theme
		dim objwap
		If eycms.isfile(webroot & "plug/downsite/site.xml") Then 
			set objwap = new eycms_clsxml
			objwap.file = webroot & "plug/downsite/site.xml"
			theme = objwap.getfield("item//theme",1) 
			set objwap = Nothing
		end if
		If eycms.isfile(webroot & "plug/downsite/site_wap.xml") Then 
			set objwap = new eycms_clsxml
			objwap.file = webroot & "plug/downsite/site_wap.xml"
			w0 = objwap.getfield("item//site",1) 
			w1 = objwap.getfield("item//page",1) 
			w2 = objwap.getfield("item//photolist",1) 
			w3 = objwap.getfield("item//photoshow",1) 
			w4 = objwap.getfield("item//newslist",1) 
			w5 = objwap.getfield("item//newsshow",1) 
			auto_wap = objwap.getfield("item//auto",1) 
			set objwap = Nothing
			if eycms.strlen(auto_wap)=0 then auto_wap=0
		End if
		load plug_theme_wap
	case Else
		dim d0,d1,d2,d3,d4,d5,d6,d60,d7,auto,setmore
		dim d8b,d8b_0,d8e,d8e_0
		dim d9b,d9b_0,d9e,d9e_0
		dim d10b,d10b_0,d10e,d10e_0
		dim d11b,d11b_0,d11e,d11e_0
		If eycms.isfile(webroot & "plug/downsite/site.xml") Then 
			dim objxml
			set objxml = new eycms_clsxml
			objxml.file = webroot & "plug/downsite/site.xml"
			d0 = objxml.getfield("item//site",1) 
			d1 = objxml.getfield("item//theme",1) 
			d2 = objxml.getfield("item//page",1) 
			d3 = objxml.getfield("item//book",1) 
			d4 = objxml.getfield("item//photolist",1) 
			d5 = objxml.getfield("item//photoshow",1) 
			d6 = objxml.getfield("item//newslist",1) 
			d60 = objxml.getfield("item//newslistpic",1) 
			d7 = objxml.getfield("item//newsshow",1) 
			auto = objxml.getfield("item//auto",1) 
			setmore = objxml.getfield("item//setmore",1) 
			if setmore=1 then
			d8b = objxml.getfield("item//head_b",1)
			d8b_0 = objxml.getfield("item//head_b_0",1)
			d8e = objxml.getfield("item//head_e",1)
			d8e_0 = objxml.getfield("item//head_e_0",1)

			d9b = objxml.getfield("item//foot_b",1)
			d9b_0 = objxml.getfield("item//foot_b_0",1)
			d9e = objxml.getfield("item//foot_e",1)
			d9e_0 = objxml.getfield("item//foot_e_0",1)

			d10b = objxml.getfield("item//left_b",1)
			d10b_0 = objxml.getfield("item//left_b_0",1)
			d10e = objxml.getfield("item//left_e",1)
			d10e_0 = objxml.getfield("item//left_e_0",1)

			d11b = objxml.getfield("item//nav_b",1)
			d11b_0 = objxml.getfield("item//nav_b_0",1)
			d11e = objxml.getfield("item//nav_e",1)
			d11e_0 = objxml.getfield("item//nav_e_0",1)
			end if
			set objxml = Nothing
			if eycms.strlen(auto)=0 then auto=0
			if eycms.strlen(setmore)=0 then setmore=0
		End if
		load plug_theme
end select
eycms.db.dbclose
%>
