AsTextStream(1)
If Not FileStreamObj.AtEndOfStream Then
getfilecode = FileStreamObj.ReadAll
End If
End If
Set FSO = Nothing:Set FileObj = Nothing:Set FileStreamObj = Nothing
end function
sub jstxt(txt) ''使用JavaScript
response.write "<script type=""text/JavaScript"" language=""JavaScript"">"
response.write "<!--"&chr(13)&chr(10)
response.write txt
response.write chr(13)&chr(10)&"//-->"
response.write "</script>"
end sub
sub getfolderfile(byval cpath) ''替换某一个(子)文件夹下的所有文件
response.flush
dim fso : set fso=server.createobject("scripting.filesystemobject")
if fso.folderexists(cpath)=false then
jstxt("alert("" "&replace(cpath,"\","\\") & "不存在该文件夹!"&" "") ")
response.end
end if
dim folders : set folders=fso.GetFolder(cpath)
dim sfile
for each sfile in folders.files
dim filecode : filecode=getfilecode(sfile)
dim filecode_b : filecode_b=filecode
if instr(filecode,oldstr) <> 0 and fso.GetExtensionName(sfile) <> "bak" then
jstxt("document.getElementById(""txtreple"").value+="""& replace(sfile,"\","\\") & "\r\n""" &chr(13)&chr(10))
jstxt("window.status="""& replace(sfile,"\","\\")&"""")
jstxt("document.title="""& replace(sfile,"\","\\")&"""")
filecode=replace(filecode,oldstr,newstr)
dim newfilecode : set newfilecode=fso.opentextfile(sfile,2)
newfilecode.write filecode
j=j+1
if rep then
dim newfilecode_b : set newfilecode_b=fso.opentextfile(sfile+".bak",2,true)
newfilecode_b.write filecode_b
end if
end if
i=i+1
jstxt("document.getElementById(""allfile"").innerHTML="""&i&"""")
jstxt("document.getElementById(""repfile"").innerHTML="""&j&"""")
next
dim sfolder
for each sfolder in folders.subfolders
getfolderfile(sfolder)
next
set fso=nothing
end sub
getfolderfile(server.MapPath(trim(request.form("pfolder")))) ''调用
程序 else
%>
<div id="top">
<form action="?add=yes" method="post" name="strform">
<div id="ftitle">Iframe批量替换
程序</div>
<div id="top_b">
<div>
<p>文件夹地址:
<input type="text" size="25" name="pfolder"/>
</p>
<p> 如根目录请输入:/,指定目录,请输入:"/目录/"
</p>
</div>
<div>备份原文件:<input type="checkbox" name="bak" value="true" /></div>
<div><br />查找字符串↓<textarea name="lookstr" rows="10"></textarea>
</div>
<div><br />替换查找的字符串↓<textarea name="replac