<%
Function GetXmlText(Url)
	Dim HTTPObj
	Set HTTPObj = Server.CreateObject("Microsoft.XMLHTTP") 
	With HTTPObj 
		.Open "Get", Url, False, "", "" 
		.Send 
	End With 
	if HTTPObj.Readystate <> 4 then
		Set HTTPObj = Nothing
		GetPageContent = False
		Exit Function
	end if
	GetXmlText = ResponseStrToStr(HTTPObj.ResponseBody)
	Set HTTPObj = Nothing
End Function

Function ResponseStrToStr(BodyStr)
	Dim ADOStreamObj
	Set ADOStreamObj = Server.CreateObject("Adodb.Stream")
	ADOStreamObj.Type = 1
	ADOStreamObj.Mode = 3
	ADOStreamObj.Open
	ADOStreamObj.Write BodyStr
	ADOStreamObj.Position = 0
	ADOStreamObj.Type = 2
	ADOStreamObj.Charset = "UTF-8"
	ResponseStrToStr = ADOStreamObj.ReadText 
	ADOStreamObj.Close
	Set ADOStreamObj = Nothing
End Function

function GetFileContent(filepath)
	on error resume next
  	set createhtm=Server.CreateObject("Adodb.Stream")
	filepath=server.mappath(filepath)
	createhtm.type=2
	createhtm.mode=3
 	createhtm.CharSet = "UTF-8"
	createhtm.open()
	createhtm.loadfromfile(filepath) '从模板文件装载
	tempfile=createhtm.size
  	if err.number>0 then
		xz=-18
		response.write filepath & err.description& "<br>"
		err.clear
		response.end 
	else
		GetFileContent=createhtm.readtext(tempfile)
	end if
	createhtm.close : set createhtm=nothing
end function

Function LoseTagA(ContentStr)
	Dim ClsTempLoseStr,regEx
	ClsTempLoseStr = Cstr(ContentStr)
	Set regEx = New RegExp
	regEx.Pattern = "<(\/){0,1}a[^<>]*>"
	regEx.IgnoreCase = True
	regEx.Global = True
	ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
	LoseTagA = ClsTempLoseStr
	Set regEx = Nothing
End Function

Sub SaveToFile(strBody,File)
    Dim objStream
    Set objStream = Server.CreateObject("ADODB.Stream")
    With objStream
        .Type = 2
        .Open
        .Charset = "UTF-8"
        .Position = objStream.Size
  	.WriteText = strBody
        .SaveToFile Server.MapPath(file),2
        .Close
    End With
    Set objStream = Nothing
End Sub

Function WriteLineToFile(updatenum)
  Const ForReading = 1, ForWriting = 2
  Dim fso, f
  Set fso = CreateObject("Scripting.FileSystemObject")
  v_updatefile=server.mappath("update.txt")
  Set f = fso.OpenTextFile(v_updatefile, ForWriting, True)
  for i=updatenum to 10
	f.WriteLine date()&"-"&updatenum+i
  next

  set fso=nothing
End Function

Function GetDesignWeb08(ContentStr)
	Dim ClsTempLoseStr,regEx
	ClsTempLoseStr = Cstr(ContentStr)
	Set regEx = New RegExp
	regEx.Pattern = "Powerd By：Web08.net"
	regEx.IgnoreCase = True
	regEx.Global = True
	v_result=regEx.Test(ClsTempLoseStr)
	if v_result then
		GetDesignWeb08=0
	else
		GetDesignWeb08=1
	end if 
	Set regEx = Nothing
End Function

Function GetDesignWeb08_1(ContentStr)
	Dim ClsTempLoseStr,regEx
	ClsTempLoseStr = Cstr(ContentStr)
	Set regEx = New RegExp
	regEx.Pattern = "Designed By：web08.net"
	regEx.IgnoreCase = True
	regEx.Global = True
	v_result=regEx.Test(ClsTempLoseStr)
	if v_result then
		GetDesignWeb08_1=0
	else
		GetDesignWeb08_1=1
	end if 
	Set regEx = Nothing
End Function

Function Web_L_FindStartI()
 	for i=0 to ubound(v_filelist)-1
		v_filelist_i=replace(v_filelist(i),chr(13),"")
		v_filelist_i=trim(replace(v_filelist_i," ",""))
		v_tmp=split(v_filelist_i,"-")
		v_tmp1=split(v_localupdate,"-")
		v_len=ubound(v_tmp)
		v_len1=ubound(v_tmp1)
		if v_len<>v_len1 then
			v_newupdate=0
		else
			for ii=0 to v_len
				if cint(v_tmp(ii))<>cint(v_tmp1(ii)) then
					v_newupdate=0
					exit for
				else 
					v_newupdate=1
				end if
			next
		end if
		if v_newupdate=1 then
			v_istart=i
			exit for
		end if 
	next
End Function

Function Web_L_Getupdatelist()
	for i=v_istart+1 to ubound(v_filelist)-1
		v_updatelist=v_updatelist&","&v_filelist(i)
	next
End Function

Function web_l_splitcontent(v_tmpfilelist,v_foldername)
	v_tmpfile=split(v_tmpfilelist,chr(13))
	for i=0 to ubound(v_tmpfile)
		v_tmpfileurl=ReplaceChar(c_serveraddr&v_foldername&"/"&trim(split(v_tmpfile(i),".")(0))&".txt")
		v_tmpcontent=getxmltext(v_tmpfileurl)
		call Web_FolderName(ReplaceChar(v_tmpfile(i)))
		call savetofile(v_tmpcontent,"../"&ReplaceChar(v_tmpfile(i)))
	next
End Function

Function ReplaceChar(tmpchar)
	ReplaceChar=replace(tmpchar,chr(9),"")
	ReplaceChar=replace(ReplaceChar,chr(13),"")
	ReplaceChar=replace(ReplaceChar," ","")
	ReplaceChar=replace(ReplaceChar,chr(10),"")
	ReplaceChar=replace(ReplaceChar,chr(11),"")
	ReplaceChar=replace(ReplaceChar," ","")
End Function

Function DelTmpFile(filepath)
	on error resume next
	filepath=server.mappath(filepath)
	Dim fso
  	Set fso = CreateObject("Scripting.FileSystemObject")
  	fso.DeleteFile(filepath)
End Function

Function ReplaceCharToHtml(tmpchar)
	ReplaceChartohtml=replace(tmpchar,chr(13),"<br>")
End Function

Function Web_FolderName(v_tmppath)
	v_tmpfolder=split(v_tmppath,"/")
	endi=ubound(v_tmpfolder)-1
	for i=0 to endi
		v_tmp=v_tmp&"/"&v_tmpfolder(i)
		call Web_FolderExist(v_tmp)
	next
End Function

Function Web_FolderExist(v_tmp)
	v_tmp2=".."&v_tmp
	v_tmp2=server.mappath(v_tmp2)
	response.write v_tmp2
	Dim fso
  	Set fso = CreateObject("Scripting.FileSystemObject")
  	If (fso.FolderExists(v_tmp2))=false Then
    		  Set f = fso.CreateFolder(v_tmp2)
		  CreateFolderDemo = f.Path
 	End If
	set fso=nothing
	v_tmp2=""
End Function

Function ShowFileList(folderspec)
	folderspec=server.mappath(folderspec)
	Dim fso, f, f1, fc, s
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set f = fso.GetFolder(folderspec)
	Set fc = f.Files
	For Each f1 in fc
		if f1.name<>"conn.asp" then
		 	s = s&","&f1.name
		end if 
	Next
	s=replace(s,",","",1,1)
	ShowFileList = s
End Function

Function update_Get_RootDir(v_dir)
	If v_dir="" then
		v_dir="/"
	elseif v_dir="/" then
		v_dir="/"
	elseif v_dir="\" then
		v_dir="/"
	Else
		if left(v_dir,1)="/" or left(v_dir,1)="\" then
			v_dir=replace(v_dir,left(v_dir,1),"")
		end if
		if right(v_dir,1)="/" or right(v_dir,1)="\" then
			v_dir=replace(v_dir,right(v_dir,1),"")
		end if
		v_dir="/"&v_dir&"/"
	End If
	update_Get_RootDir=v_dir
End Function
%>