Note:
1、this tool can replace text characters such as asp,.txt, php, aspx... on the website
2. Upload replace. asp to the root directory of the website and run http: // website domain name/replace. asp
3. To ensure security, please delete or rename the program after you use it
Copy codeThe Code is as follows: <% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "936" %>
<% Option explicit
Response. Buffer = true
Response. CharSet = "GB2312"
Server. ScriptTimeout = 9999999
%>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Meta http-equiv = "Content-Language" content = "zh-CN"/>
<Title> Iframe Replacement Program </title>
<Style type = "text/css">
<! --
# Top
{
Text-align: center;
Margin: auto;
Font-size: 11pt;
}
# Top_ B
{
Text-align: left;
Width: 350px;
Border: 1px solid #000000;
Margin: auto;
Padding: 0px;
Line-height: 200%;
}
# Top_ B div
{
Padding-left: 8px;
Padding-right: 8px;
}
# Ftitle
{
Text-align: center;
Width: 350px;
Background: silver;
Font-weight: bold;
Letter-spacing: 5px;
Font-size: 15pt;
Padding: 3px 0 3px 0;
Color: red;
Margin: auto;
Border: 1px solid #000000;
Border-width: 1px 1px 0 1px;
}
# Btm
{
Text-align: center;
Padding-top: 8px;
Padding-bottom: 8px;
Background: # ececec
}
Textarea
{
Width: 330;
Height: 100px
}
# Copyr
{
Font-size: 9pt;
Text-align: center;
Color: silver
}
-->
</Style>
</Head>
<Body>
<%
If request. querystring ("add") = "yes" then
%>
<Div id = "top">
<Div id = "ftitle"> program processing result </div>
<Div id = "top_ B">
<Div>
Total files: <span style = "color: red" id = "allfile"> </span>
Files replaced: <span style = "color: red" id = "repfile"> </span>
</Div>
<Div> <br/> replaced file path list objects <textarea id = "txtreple" style = "height: 300px; overflow: auto"> </textarea>
</Div>
<Div id = "copyr"> <br/>
</Div>
</Div>
</Div>
<%
Dim oldstr: oldstr = request. form ("lookstr") 'source string
Dim newstr: newstr = request. form ("replacestr") 'New String
Dim rep: rep = cbool (request. form ("bak") 'indicates whether to back up the file. true indicates the backup file.
Dim I: I = 0' total number of files
Dim j: j = 0' Number of replaced files
Function chkexistsfile (path) 'determines whether a file exists. If yes, true is returned; otherwise, false is returned.
Dim fso
Set fso = server. createobject ("scripting. filesystemobject ")
If fso. fileexists (path) then
Chkexistsfile = true
Else
Chkexistsfile = false
End if
Set fso = nothing
End function
Function getfilecode (TemplateFname) 'obtains the code of a file.
Dim FSO, FileObj, FileStreamObj
Set FSO = CreateObject ("scripting. filesystemobject ")
If FSO. FileExists (TemplateFname) = False Then
Getfilecode = ""
Else
Set FileObj = FSO. GetFile (TemplateFname)
Set FileStreamObj = FileObj. OpenAsTextStream (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) 'uses 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) 'replaces all files in a (sub) folder
Response. flush
Dim fso: set fso = server. createobject ("scripting. filesystemobject ")
If fso. folderexists (cpath) = false then
Jstxt ("alert (" "& replace (cpath," \ "," \ ") &" does not exist in this folder! "&""")")
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") 'Call the program
Else
%>
<Div id = "top">
<Form action = "? Add = yes "method =" post "name =" strform ">
<Div id = "ftitle"> Iframe batch Replacement Program </div>
<Div id = "top_ B">
<Div>
<P> folder address:
<Input type = "text" size = "25" name = "pfolder"/>
</P>
<P> for the root directory, enter:/, specify the directory, and enter: "/directory /"
</P>
</Div>
<Div> back up the original file: <input type = "checkbox" name = "bak" value = "true"/> </div>
<Div> <br/> Search for strings <textarea name = "lookstr" rows = "10"> </textarea>
</Div>
<Div> <br/> Replace the searched string 'struct' <textarea name = "replacestr"> </textarea> </div>
<Div id = "btm"> <input type = "submit" value = "OK"/> </div>
<Div id = "copyr"> <br/>
</Div>
</Div>
</Form>
</Div>
<SCRIPT type = "text/javascript" LANGUAGE = "JavaScript">
<! --
Function chk ()
{
Var forma = document. strform;
If (forma. pfolder. value = "")
{
Alert ("folder address cannot be blank ");
Forma. pfolder. focus ();
Return;
}
Else
{
Forma. pfolder. value = forma. pfolder. value. replace (///g ,"\\");
Forma. pfolder. value = forma. pfolder. value. replace (/. /G ,".");
}
If (forma. lookstr. value = "")
{
Alert ("the search string cannot be blank! ");
Forma. lookstr. focus ();
}
Else if (forma. replacestr. value = "")
{
Alert ("the string to be searched cannot be blank ");
Forma. replacestr. focus ();
}
Else
{
Forma. submit ();
}
}
// -->
</SCRIPT>
<% End if %>
</Body>
</Html>