Character batch substitution program ASP Server version ******************
Installation method: Directly put the replace.asp file in an arbitrary support ASP+FSO environment
How to run: you can see the effect of the program with http://localhost/.../replace.asp access
The function of this program is primarily used to replace all text file characters in a folder.
such as: txt, htm, ASP, JSP, PHP 、...... All the text files
DIV+CSS layout compatible FF and IE browsers
---------currently has functional------------------------
Instant view of the current alternate file path
Optional backup original file is "original file. Bak"
folder infinite layer nested substitution character
Replaced file path display
Total number of files and number of replaced files displayed
...
Examples of program uses-
Clear similar web trojan <iframe src= "" width= "0" height= "0" ></iframe>
Bulk replacement file characters, a small number of files will not use this program
Can be uploaded on the server, replace the bulk substitution characters online
You can find a large number of text files that contain target characters when you are looking for characters and replaced strings.
....
155120699 Original Welcome hezhiwu5@163.com 21:47 2007-3-12
------------------------------------------------------------------------------------------------------
Copy Code code as follows:
<%option explicit%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<meta http-equiv= "Content-language" content= "ZH-CN"/>
<meta name= "Author" content= "155120699 writing hezhiwu5@163.com"/>
<meta name= "Description" content= "character Replacement program"/>
<meta name= "Copyright" content= "155120699 original Web program welcome correction"/>
<title> character Substitution Program ASP Server Edition </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>
<body>
<%
If Request.QueryString ("add") = "yes" then
%>
<div id= "Top" >
<div id= "Ftitle" > Program processing Results </div>
<div id= "Top_b" >
<div>
Total file: <span style= "color:red" id= "Allfile" > </span>
Replace file: <span style= "color:red" id= "Repfile" > </span>
</div>
<div><br/> was replaced with a file path list ↓<textarea id= "Txtreple" style= "Overflow:auto" ></textarea></div >
<div id= "Copyr" ><br/> The creation hezhiwu5@163.com
</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")) ' whether to back up files, true to backup files
Dim i:i=0 ' Total File count
Dim j:j=0 ' Number of files replaced
function Chkexistsfile (path) ' Determines whether a file exists, returns True if it exists, or returns false
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 (path) ' Gets the code for a file
Dim fso
If Chkexistsfile (path) Then
Set Fso=server.createobject ("Scripting.FileSystemObject")
Dim Filecode:set Filecode=fso.opentextfile (path,1)
Getfilecode=filecode.readall
Set fso=nothing
Else
Getfilecode=path & "This file does not exist"
End If
End Function
Sub Jstxt (TXT) ' uses JavaScript
Response.Write "<script type=" "Text/javascript" "language=" "JavaScript" ">"
Response.Write "<!--" (&CHR) &CHR (10)
Response.Write txt
Response.Write Chr (a) &CHR (a) & "//-->"
Response.Write "</script>"
End Sub
Sub Getfolderfile (CPath) ' Replaces all files under one (child) 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 (Trim (Request.Form ("Pfolder")) ' calling program
Else
%>
<div id= "Top" >
<form action= "? Add=yes" method= "post" name= "Strform" >
<div id= "Ftitle" > Character Batch Replacement </div>
<div id= "Top_b" >
<div> folder address: <input type= "text" size= "a" name= "Pfolder"/></div>
<div> Backup original file: <input type= "checkbox" Name= "bak" value= "true"/></div>
<div><br/> Lookup string ↓<textarea name= "Lookstr" ></textarea></div>
<DIV><BR/> Replace the lookup string ↓<textarea name= "Replacestr" ></textarea></div>
<div id= "BTM" ><input type= "button" value= "OK" onclick= "chk ()"/></div>
<div id= "Copyr" ><br/> The creation hezhiwu5@163.com
</div>
</form>
</div>
<script type= "Text/javascript" language= "JavaScript" >
<!--
function Chk ()
{
var forma=document.strform;
if (forma.pfolder.value== "")
{
Alert ("folder address cannot be empty");
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 ("Find string cannot be empty!") ");
Forma.lookstr.focus ();
}
else if (forma.replacestr.value== "")
{
Alert ("Replace the found string cannot be empty");
Forma.replacestr.focus ();
}
Else
{
Forma.submit ();
}
}
-->
</SCRIPT>
<% End If%>
</body>