<%
function getxmlhttp(byval t0,byval t1)
	on error resume next
	dim http
	'Set http=server.createobject("microsoft.xmlhttp")
	'Set Http=server.createobject("MSXML2.XMLHTTP.6.0")
	'Set Http=server.createobject("MSXML2.XMLHTTP.5.0")
	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 InStr(t0,".jpg") or InStr(t0,".jpeg") or InStr(t0,".png") or InStr(t0,".gif") Then
				getxmlhttp=http.responsetext
			Else
				If session("encodeing")<>"" Then t1=session("encodeing")
				if t1="auto" Or t1="" then 
					if eycms.strlen(http.responsetext)>10 then
						t1=getEncodeing(http.responseText)
					end if
				end if
				if len(t1)=0 then t1="utf-8"

				If t1="utf-8" Then 
					getxmlhttp=http.responsetext
				else
					getxmlhttp=BytesToBstr(Http.ResponseBody,t1)
				End if
				getxmlhttp=replace(getxmlhttp,"https://","http://")
				getxmlhttp=replace(getxmlhttp,"show.metinfo.cn","images.metinfo.cn")
			End if
		else
			getxmlhttp=""
		end if
	set http=nothing
	If Err Then
		err.Clear
		getxmlhttp=""
	End If
end function

function getxmlhttp_wap(byval t0,byval t1)
	on error resume next
	dim http
	'Set http=server.createobject("microsoft.xmlhttp")
	'Set Http=server.createobject("MSXML2.XMLHTTP.6.0")
	'Set Http=server.createobject("MSXML2.XMLHTTP.5.0")
	set http=server.createobject("MSXML2.ServerXMLHTTP")
		http.SetTimeOuts 20000, 20000, 30000, 30000
		http.open "GET","http://api.eycms.cn/getwap.php?url="&replace(t0,"&","*"),false
		'http.setRequestHeader "If-Modified-Since","0"
		http.send()
		if http.readyState=4 Then
			If InStr(t0,".jpg") or InStr(t0,".jpeg") or InStr(t0,".png") or InStr(t0,".gif") Then
				getxmlhttp_wap=http.responsetext
			Else
				If session("encodeing")<>"" Then t1=session("encodeing")
				if t1="auto" Or t1="" then 
					if eycms.strlen(http.responsetext)>10 then
						t1=getEncodeing(http.responseText)
					end if
				end if
				if len(t1)=0 then t1="utf-8"

				If t1="utf-8" Then 
					getxmlhttp_wap=http.responsetext
				else
					getxmlhttp_wap=BytesToBstr(Http.ResponseBody,t1)
				End if
				getxmlhttp_wap=replace(getxmlhttp_wap,"https://","http://")
				getxmlhttp_wap=replace(getxmlhttp_wap,"show.metinfo.cn","images.metinfo.cn")
			End if
		else
			getxmlhttp_wap=""
		end if
	set http=nothing
	If Err Then
		err.Clear
		getxmlhttp_wap=""
	End If
end function

'自动取得编码格式
function getEncodeing(stext)
	On Error Resume Next
	dim re, encodeing, shtml
	shtml=stext
	Set re=new RegExp
	re.IgnoreCase =True
	re.Global=True

	re.pattern ="<script(.|\n)*?\/script>"
	shtml=re.replace(shtml,"")
	re.pattern ="<iframe(.|\n)*?\/iframe>"
	shtml=re.replace(shtml,"")

	re.Pattern="encoding=\""utf-8"
	if re.test(shtml) then
		encodeing="utf-8"
	else
		re.Pattern="charset=('|"")*utf-8('|"")*"
		if re.test(shtml) then
			encodeing="utf-8"
		else
			encodeing="gb2312"
		end if
	end if
	set re=nothing
	If Err Then
		err.Clear
		getEncodeing="utf-8"
	else
		getEncodeing=encodeing
	End If
	session("encodeing")=encodeing
end function

Function BytesToBstr(Body, Cset)
   Dim Objstream
   Set Objstream = Server.CreateObject("adodb.stream")
   Objstream.Type = 1
   Objstream.Mode = 3
   Objstream.Open
   Objstream.Write Body
   Objstream.Position = 0
   Objstream.Type = 2
   Objstream.Charset = Cset
   BytesToBstr = Objstream.ReadText
   Objstream.Close
   Set Objstream = Nothing
End Function

Function GetCount(Strs,Word)
	Dim N1,N2,N3
	N1=Len(Strs)
	N2=Len(Replace(Strs,Word,""))
	N3=Len(Word)
	GetCount=Clng(((N1-N2)/N3))
End Function

'==================================================
'函数名：GetContent
'作  用：截取字符串
'参  数：str   ------将要截取的字符串
'参  数：start ------开始字符串
'参  数：last  ------结束字符串
'参  数：n     ------模式
'==================================================
Function GetContent(str,start,last,n)
	If Instr(lcase(str),lcase(start))>0 then
		select case n
		case 0	'截取区间内（去除关键字）
			GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
			GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))-1)
		case 1	'截取区间内（保留关键字）
			GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))+1)
			GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))+Len(last)-1)
		case 2	'从开始标记往 右 截取（去除关键字）
			GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
		case 3	'从开始标记往 右 截取（包含关键字）
			GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))+1)
		case 4	'从开始标记往 左 截取（包含关键字）
			GetContent=Left(str,Instr(lcase(str),lcase(start))+Len(start)-1)
		case 5	'从开始标记往 左 截取（去除关键字）
			GetContent=Left(str,Instr(lcase(str),lcase(start))-1)
		case 6	'截取区间以外（去除关键字）
			GetContent=Left(str,Instr(lcase(str),lcase(start))-1) & Right(str,Len(str)-Instr(lcase(str),lcase(last))-Len(last)+1)
		end select
	Else
		GetContent=""
	End if
End Function

'==================================================
'函数名：GetBody
'作  用：以字节模式截取字符串
'参  数：ConStr   ------将要截取的字符串
'参  数：StartStr ------开始字符串
'参  数：OverStr  ------结束字符串
'参  数：IncluL   ------是否包含StartStr
'参  数：IncluR   ------是否包含OverStr
'参  数：Mode     ------模式  0=取区间内   1=往左截取   2=往右截取  3=取区间以外（去除关键字）
'==================================================
Function GetBody(Constr, StartStr, OverStr, IncluL, IncluR, Mode)
	If Constr = "" Or IsNull(Constr) = True Or StartStr = "" Or IsNull(StartStr) = True Then
		GetBody = ""
		Exit Function
	End If
	Dim ConstrTemp,StartTemp,OverTemp
	Dim Start, Over
	ConstrTemp = LCase(Constr)
	StartTemp = LCase(StartStr)
	OverTemp = LCase(OverStr)
	Start = InStrB(1, ConstrTemp,StartTemp, vbBinaryCompare)
	If Start <= 0 Then
		GetBody = ""
		Exit Function
	Else
		If Mode = 0 then
			If IncluL = False Then
				Start = Start + LenB(StartTemp)
			End If
		End If
	End If
	Over = InStrB(Start, ConstrTemp, OverTemp, vbBinaryCompare)
	If Mode = 0 then
		If Over <= 0 Or Over <= Start Then
			GetBody = ""
			Exit Function
		Else
			If IncluR = True Then
				Over = Over + LenB(OverTemp)
			End If
		End If
	End If
	select case Mode
	Case 0
		GetBody = MidB(Constr, Start, Over - Start)
	Case 1
		Start = InStrB(1, ConstrTemp,StartTemp, vbBinaryCompare)
		If IncluL = True Then Start = Start + LenB(StartTemp)
		GetBody = LeftB(Constr, Start - 1)
	Case 2
		Start = InStrB(1, ConstrTemp,StartTemp, vbBinaryCompare)
		If IncluL = False Then Start = Start + LenB(StartTemp)
		GetBody = MidB(Constr, Start, LenB(Constr))
	Case 3
		Start = InStrB(1, ConstrTemp,StartTemp, vbBinaryCompare) + LenB(StartTemp)
		Over = InStrB(Start, ConstrTemp, OverTemp, vbBinaryCompare) + LenB(OverTemp)
		GetBody = LeftB(Constr, Start - 1) & MidB(Constr, Start + LenB(StartTemp), LenB(Constr))
	End select
End Function

'================================================
'函数名：CutFixed
'作  用：截取固定的字符串
'参  数：strHTML ---- 原字符串
'        start   ---- 开始字符串
'        last    ---- 结束字符串
'================================================
Function CutFixed(ByVal strHTML, ByVal start, ByVal last)
	Dim s, Match, strPattern, strContent, t, l
	t = Len(start): l = Len(last)
	If t = 0 Or l = 0 Then Exit Function
	strPattern = "(" & CorrectPattern(start) & ")(.+?)(" & CorrectPattern(last) & ")"
	On Error Resume Next
	Dim re
	Set re = New RegExp
	re.IgnoreCase = False
	re.Global = False
	re.Pattern = strPattern
	Set s = re.Execute(strHTML)
	For Each Match In s
		strContent = Match.Value
	Next
	Set s = Nothing
	Set re = Nothing
	CutFixed = Mid(strContent, t + 1, Len(strContent) - l - t)
End Function

'================================================
'函数名：FindMatch
'作  用：截取相匹配的内容
'返回值：截取后的字符串
'================================================
Function FindMatch(ByVal str, ByVal start, ByVal last)
	Dim Match, s, FilterStr, MatchStr, strContent, ArrayFilter(), i, n, bRepeat
	If Len(start) = 0 Or Len(last) = 0 Then Exit Function
	On Error Resume Next
	MatchStr = "(" & CorrectPattern(start) & ")(.+?)(" & CorrectPattern(last) & ")"
	Dim re
	Set re = New RegExp
	re.IgnoreCase = True
	re.Global = True
	re.Pattern = MatchStr
	Set s = re.Execute(str)
	n = 0
	For Each Match In s
		If n = 0 Then
			n = n + 1
			ReDim ArrayFilter(n)
			ArrayFilter(n) = Match
		Else
			bRepeat = False
			For i = 0 To UBound(ArrayFilter)
				If UCase(Match) = UCase(ArrayFilter(i)) Then
					bRepeat = True
					Exit For
				End If
			Next
			If bRepeat = False Then
				n = n + 1
				ReDim Preserve ArrayFilter(n)
				ArrayFilter(n) = Match
			End If
		End If
	Next
	Set s = Nothing
	Set re = Nothing
	strContent = Join(ArrayFilter, "|||")
	strContent = Replace(strContent, start, "")
	strContent = Replace(strContent, last, "")
	FindMatch  = Replace(strContent, "|||", vbNullString, 1, 1)
End Function

'================================================
'函数名：CutFixate
'返回值：截取后的字符串
'================================================
Function CutFixate(ByVal strHTML, ByVal start, ByVal last)
	Dim s, Match, strPattern, strContent, t, l
	t = Len(start): l = Len(last)
	If t = 0 Or l = 0 Then Exit Function
	strPattern = "(" & CorrectPattern(start) & ")(.+?)(" & CorrectPattern(last) & ")"
	On Error Resume Next
	Dim re
	Set re = New RegExp
	re.IgnoreCase = False
	re.Global = False
	re.Pattern = strPattern
	Set s = re.Execute(strHTML)
	For Each Match In s
		strContent = Match.Value
	Next
	Set s = Nothing
	Set re = Nothing
	CutFixate = Trim(strContent)
End Function

'================================================
'函数名：CorrectPattern
'作  用：格式化字符串符合正则规则
'================================================
Function CorrectPattern(ByVal str)
	str = Replace(str, "\", "\\")
	str = Replace(str, "~", "\~")
	str = Replace(str, "!", "\!")
	str = Replace(str, "@", "\@")
	str = Replace(str, "#", "\#")
	str = Replace(str, "%", "\%")
	str = Replace(str, "^", "\^")
	str = Replace(str, "&", "\&")
	str = Replace(str, "*", "\*")
	str = Replace(str, "(", "\(")
	str = Replace(str, ")", "\)")
	str = Replace(str, "-", "\-")
	str = Replace(str, "+", "\+")
	str = Replace(str, "[", "\[")
	str = Replace(str, "]", "\]")
	str = Replace(str, "<", "\<")
	str = Replace(str, ">", "\>")
	str = Replace(str, ".", "\.")
	str = Replace(str, "/", "\/")
	str = Replace(str, "?", "\?")
	str = Replace(str, "=", "\=")
	str = Replace(str, "|", "\|")
	str = Replace(str, "$", "\$")
	CorrectPattern = str
End Function

function getremote_img(body,t0,t1)
	dim regex, matches, match, url, url2, fpath, imgext, t0_new
	dim images, imgs, i

	If GetCount(t0,"/")>=2 Then
		t0_new="http://"&Split(t0,"/")(2)
	else
		t0_new=t0
	End If
	
	set regex = new regexp
	regex.IgnoreCase = true
	regex.Global = True
	getremote_img = body

	regex.pattern="files=('|"")([^>+""+']+)('|"")"
	set matches = regex.execute(getremote_img)
	if matches.count>0 then
		for each match in matches
			images = match.submatches(1)
			If InStr(images,"|")>0 Then
				imgs=split(images,"|")
				for i=0 To UBound(imgs)
					fpath = mid(imgs(i), instrrev(imgs(i),"/")+1)
					If InStr(savedfiles,fpath)=0 then
						savedfiles = savedfiles & "[" & fpath & "]"
						if left(imgs(i),1)="/" Then 
							save_img t0_new&imgs(i), webroot&"theme/"&t1&"/upfile/", fpath
						Else
							if InStr(lcase(imgs(i)),t0) then
								save_img imgs(i), webroot&"theme/"&t1&"/upfile/", fpath
							else
								save_img t0&"/"&imgs(i), webroot&"theme/"&t1&"/upfile/", fpath
							end if
						End if
					End if
					getremote_img = Replace(getremote_img, imgs(i), "{skins}/upfile/"&fpath)
				next
			end if
		next
	end If

	regex.pattern="href=('|"")*([^>+""+']+)[.]{1}(css)('|"")*"
	set matches = regex.execute(getremote_img)
	if matches.count>0 then
		for each match in matches
			url = match.submatches(1) & ".css"
			if left(url,1)="/" or InStr(lcase(url),t0_new) or left(lcase(url),7)<>"http://" then 
				fpath = mid(url,instrrev(url,"/")+1)
				getremote_img = Replace(getremote_img, url, "{skins}/css/"&fpath)
			end if
		next
	end If
	
	regex.pattern="src=('|"")*([^>+""+']+)[.]{1}(js)('|"")*"
	set matches = regex.execute(getremote_img)
	if matches.count>0 then
		for each match in matches
			url = match.submatches(1) & ".js"
			if left(url,1)="/" or InStr(lcase(url),t0_new) or left(lcase(url),7)<>"http://" then 
				fpath = mid(url,instrrev(url,"/")+1)
				getremote_img = Replace(getremote_img, url, "{skins}/js/"&fpath)
			end if
		next
	end If

	imgext="gif|jpg|jpeg|png"
	regex.pattern="(src|data-bg|data-original)=('|"")*([^>+""+']+)[.]{1}("&imgext&")([^""+']*)('|"")*"
	set matches = regex.execute(getremote_img)
	if matches.count>0 then
		for each match in matches
			url = match.submatches(2) & "." & match.submatches(3)
			url = replace(url,"url(","")
			url = replace(url,")","")
			'if left(url,1)="/" or InStr(lcase(url),t0_new) or left(lcase(url),7)="http://" then 
				fpath = mid(url,instrrev(url,"/")+1)
				If InStr(lcase(url),"upfile/") or InStr(lcase(url),"upload/") or InStr(lcase(url),"upfiles/") or InStr(lcase(url),"uploadfile/")  or InStr(lcase(url),"uploadfiles/") Then
					If InStr(savedfiles,fpath)=0 Then
						savedfiles = savedfiles & "[" & fpath & "]"
						if left(url,1)="/" Then 
							save_img t0_new&url, webroot&"theme/"&t1&"/upfile/", fpath
						else
							if InStr(lcase(url),lcase(t0)) or left(lcase(url),7)="http://" then
								save_img url, webroot&"theme/"&t1&"/upfile/", fpath
							else
								url2 = Replace(url,"include/thumb.php?dir=","")
								save_img t0&"/"&url2, webroot&"theme/"&t1&"/upfile/", fpath
							end if
						End if
					End if
					getremote_img = Replace(getremote_img, url & match.submatches(4), "{skins}/upfile/"&fpath)
				Else
					If InStr(savedfiles,fpath)=0 Then
						savedfiles = savedfiles & "[" & fpath & "]"
						if left(url,1)="/" Then
							save_img t0_new&url, webroot&"theme/"&t1&"/images/", fpath
						else
							if InStr(lcase(url),lcase(t0)) or left(lcase(url),7)="http://" then
								save_img url, webroot&"theme/"&t1&"/images/", fpath
							else
								url2 = Replace(url,"include/thumb.php?dir=","")
								save_img t0&"/"&url2, webroot&"theme/"&t1&"/images/", fpath
							end if
						End if
					End if
					getremote_img = Replace(getremote_img, url & match.submatches(4), "{skins}/images/"&fpath)
				End If
			'end if
		next
	end If

	regex.pattern=":url\(('|"")*([^\)+""+']+)[.]{1}("&imgext&")('|"")*\)"
	set matches = regex.execute(getremote_img)
	if matches.count>0 then
		for each match in matches
			url = match.submatches(1) & "." & match.submatches(2)
			'if left(url,1)="/" or InStr(url,t0_new) or left(lcase(url),7)="http://" then 
				fpath = mid(url,instrrev(url,"/")+1)
				If InStr(lcase(url),"upfile/") or InStr(lcase(url),"upload/") or InStr(lcase(url),"upfiles/") or InStr(lcase(url),"uploadfile/") or InStr(lcase(url),"uploadfiles/") Then
					If InStr(savedfiles,fpath)=0 Then
						savedfiles = savedfiles & "[" & fpath & "]"
						if left(url,1)="/" Then
							save_img t0_new&url, webroot&"theme/"&t1&"/upfile/", fpath
						else
							if InStr(lcase(url),lcase(t0)) or left(lcase(url),7)="http://" then
								save_img url, webroot&"theme/"&t1&"/upfile/", fpath
							else
								save_img t0&"/"&url, webroot&"theme/"&t1&"/upfile/", fpath
							end if
						End if
					End if
					getremote_img = Replace(getremote_img, url, "{skins}/upfile/"&fpath)
				Else
					If InStr(savedfiles,fpath)=0 Then
						savedfiles = savedfiles & "[" & fpath & "]"
						if left(url,1)="/" Then
							save_img t0_new&url, webroot&"theme/"&t1&"/images/", fpath
						else
							if InStr(lcase(url),lcase(t0)) or left(lcase(url),7)="http://" then
								save_img url, webroot&"theme/"&t1&"/images/", fpath
							else
								save_img t0&"/"&url, webroot&"theme/"&t1&"/images/", fpath
							end if
						End if
					End if
					getremote_img = Replace(getremote_img, url, "{skins}/images/"&fpath)
				End If
			'end if
		next
	end If

	regex.pattern="=('|"")(upload|upfile)([^""+']+)[.]{1}("&imgext&")('|"")"
	set matches = regex.execute(getremote_img)
	if matches.count>0 then
		for each match in matches
			url = match.submatches(1) & match.submatches(2) & "." & match.submatches(3)
			'if left(lcase(url),1)="/" or InStr(lcase(url),t0_new) or left(lcase(url),7)="http://" then 
				fpath = mid(url,instrrev(url,"/")+1)
				If InStr(savedfiles,fpath)=0 Then
					savedfiles = savedfiles & "[" & fpath & "]"
					if left(url,1)="/" Then
						save_img t0_new&url, webroot&"theme/"&t1&"/upfile/", fpath
					else
						if InStr(lcase(url),lcase(t0)) or left(lcase(url),7)="http://" then
							save_img url, webroot&"theme/"&t1&"/upfile/", fpath
						else
							url2 = Replace(url,"include/thumb.php?dir=","")
							save_img t0&"/"&url2, webroot&"theme/"&t1&"/upfile/", fpath
						end if
					End if
				End If
				getremote_img = Replace(getremote_img, url, "{skins}/upfile/"&fpath)
			'end if
		next
	end If

	regex.pattern="=('|"")([^\.]+)\.swf('|"")"
	set matches = regex.execute(getremote_img)
	if matches.count>0 Then
		eycms.newfolder webroot&"theme/"&t1&"/flash/"
		for each match in matches
			url = match.submatches(1) & ".swf"
			url = Replace(url,"'+'","")
			url = Replace(url,"' + '","")
			url = Replace(url,"""+""","")
			url = Replace(url,""" + ""","")
			if left(url,1)="/" or InStr(url,t0) or left(url,7)<>"http://" then 
				fpath = mid(url,instrrev(url,"/")+1)
				If InStr(savedfiles,fpath)=0 Then
					savedfiles = savedfiles & "[" & fpath & "]"
					if left(url,1)="/" Then
						save_img t0_new&url, webroot&"theme/"&t1&"/flash/", fpath
					else
						if InStr(lcase(url),lcase(t0)) then
							save_img url, webroot&"theme/"&t1&"/flash/", fpath
						else
							save_img t0&"/"&url, webroot&"theme/"&t1&"/flash/", fpath
						end if
					End if
				End If
				getremote_img = Replace(getremote_img, url, "{skins}/flash/"&fpath)
			end if
		next
	end If
	set matches = nothing
end Function

'正则处理替换外部图片地址并下载
function c_replace(root, curl, spath, fext)
	Dim fpath_xd, fpath1, fpath2, fpath3, fpath4, ii, css, root_new, localfile, localhtml
	fpath_xd = mid(curl, 1, instrrev(curl,"/")-1)     '相对路径  如：http://www.eycms.cn/css/2009
	If GetCount(fpath_xd,"/")>3 Then fpath1 = mid(fpath_xd, 1, instrrev(fpath_xd,"/")-1)
	If GetCount(fpath_xd,"/")>4 Then fpath2 = mid(fpath1, 1, instrrev(fpath1,"/")-1)
	If GetCount(fpath_xd,"/")>5 Then fpath3 = mid(fpath2, 1, instrrev(fpath2,"/")-1)
	If GetCount(fpath_xd,"/")>6 Then fpath4 = mid(fpath3, 1, instrrev(fpath3,"/")-1)
	If GetCount(root,"/")>=2 Then
		root_new="http://"&Split(root,"/")(2)
	End If
	If fpath1="" Then fpath1=root_new
	If fpath2="" Then fpath2=root_new
	If fpath3="" Then fpath3=root_new
	If fpath4="" Then fpath4=root_new
	css = mid(curl,instrrev(curl,"/")+1)
	localfile = Replace(Replace(spath,"images","css"),"font","css") & css
	Dim regex, matches, match, html, imghtml, imgPath, savePath, imgstr, imgstr2, imgname, imgarr
	set regex = new RegExp
	regex.IgnoreCase = true
	regex.Global = true
	regex.Pattern = "url\(('|"")*([^\)]+)\.("&fext&")([^\)]*)('|"")*\)"
	html = getxmlhttp(curl,session("encodeing"))
	if eycms.isfile(localfile) then
		localhtml = eycms.loadfile(localfile)
	else
		localhtml = html
	end if
	set matches = regex.execute(html)
	for each match in matches
		imgPath=""
		savePath=""
		imgstr=replace(match.value,"url(","")
		imgstr=replace(imgstr,"'","")
		imgstr=replace(imgstr,"""","")
		imgstr=replace(imgstr,")","")
		imgstr2 = imgstr
		if instr(imgstr,"#") then imgstr=split(imgstr,"#")(0)
		if instr(imgstr,"?") then imgstr=split(imgstr,"?")(0)
		imgPath = imgstr
		if instr(imgstr2,"vendor/flag-icon-css")=0 then
			If instr(imgarr,imgstr)=0 then
				If Left(imgstr,1)="/" Then imgPath = root_new & imgstr
				If Left(imgstr,1)<>"/" And Left(imgstr,2)<>".." And LCase(Left(imgstr,4))<>"http" Then imgPath = fpath_xd &"/" & imgstr
				If Left(imgstr,3)="../" Then imgPath = fpath1 &"/" & right(imgstr,len(imgstr)-3)
				If Left(imgstr,6)="../../" Then imgPath = fpath2 &"/" & right(imgstr,len(imgstr)-6)
				If Left(imgstr,9)="../../../" Then imgPath = fpath3 &"/" & right(imgstr,len(imgstr)-9)
				If Left(imgstr,12)="../../../../" Then imgPath = fpath4 &"/" & right(imgstr,len(imgstr)-12)
				imgPath = replace(imgPath,"""","")
				eycms.echo "正在提取" & imgstr2 & "<br>"
				response.flush()
				imgname = mid(imgPath,instrrev(imgPath,"/")+1)
				if fext="gif|jpg|png|cur" then
					localhtml = replace(localhtml, imgstr2, "../images/" & imgname)
				else
					localhtml = replace(localhtml, imgstr2, "../font/" & imgname)
				end if
				save_img imgPath, spath, imgname 
				imgarr = imgarr & "[" & imgstr & "]"
			End if
		end if
	Next
	eycms.newfile Replace(Replace(spath,"images","css"),"font","css"), css, localhtml, "utf-8"
end Function

function save_img(byval t0,byval t1,byval t2)
	on error resume next
	dim http,stm,filedata,filename,filesize
	t2 = Replace(t2,"include/thumb.php?dir=","")
	filename=t1 & t2
	set http=server.createobject("MSXML2.ServerXMLHTTP")
	with http
		.SetTimeOuts 20000, 20000, 30000, 30000
		.open "GET",t0,false
		.send()
		if .readystate<>4 Then exit function 
		filedata=.responsebody
		'if instr(.responsetext,"Not Found") Then exit function 
		'filesize=eycms.getnum(round(lenb(filedata))/1024)
		'If filesize=1.28 Then exit Function
	end with
	set stm=server.createobject("adodb.stream")
	with stm
		.type=1
		.open
		.write filedata
		.savetofile server.mappath(filename), 2
		.cancel
	.close
	end with
	if err then
		eycms.errlog "文件名："&filename&"<br>函数：save_img<br>详情："&t0&"<BR>"&err.description,1
		err.clear
		save_img=false
	else
		save_img=true
	end if
end Function
%>
