佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > 用asp實現(xiàn)的iframe批量替換工具

用asp實現(xiàn)的iframe批量替換工具

熱門標簽:電子圍欄 科大訊飛語音識別系統(tǒng) 阿里云 Mysql連接數(shù)設置 團購網(wǎng)站 服務器配置 銀行業(yè)務 Linux服務器
說明:
1、此工具可以批量替換網(wǎng)站上asp,.txt,php,aspx...等等文本型的字符
2、將replace.asp上傳至網(wǎng)站根目錄后,運行http://網(wǎng)站域名/replace.asp
3、為了安全,使用本程序后請刪除或更名
復制代碼 代碼如下:

%@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替換程序/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">程序處理結(jié)果/div> 
    div id="top_b"> 
        div> 
            總文件:span style="color:red" id="allfile"> /span>個   
            替換過文件:span style="color:red" id="repfile"> /span>個 
        /div> 
        div>br />被替換過文件路徑列表↓textarea id="txtreple" style="height:300px;overflow:auto">/textarea>
        /div> 
      div id="copyr">br />
      /div> 
    /div> 
/div> 

dim oldstr :oldstr=request.form("lookstr")  '源字符串 
dim newstr :newstr=request.form("replacestr") '新字符串 
dim rep : rep=cbool(request.form("bak"))   '是否備份文件,true為備份文件 
dim i : i=0  '總文件個數(shù) 
dim j : j=0  '被替換的文件個數(shù) 
function chkexistsfile(path) '判斷一個文件是否存在,如果存在,返回true,否則返回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(TemplateFname) '獲取一個文件的代碼 
    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) '使用JavaScript 
    response.write "script type=""text/JavaScript"" language=""JavaScript"">" 
    response.write "!--"chr(13)chr(10) 
    response.write txt 
    response.write chr(13)chr(10)"http://-->" 
    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")))) '調(diào)用程序 
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>          如根目錄請輸入:/,指定目錄,請輸入:quot;/目錄/quot;
              /p>
            /div> 
            div>備份原文件:input type="checkbox" name="bak" value="true" />/div> 
            div>br />查找字符串↓textarea name="lookstr" rows="10">/textarea>
            /div> 
            div>br />替換查找的字符串↓textarea name="replacestr">/textarea>/div> 
            div id="btm">input type="submit" value=" 確定 " />/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("文件夾地址不能為空"); 
        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("查找字符串不能為空!"); 
        forma.lookstr.focus(); 
    } 
    else if(forma.replacestr.value=="") 
    { 
        alert("替換查找的字符串不能為空"); 
        forma.replacestr.focus(); 
    } 
    else 
    { 
        forma.submit(); 
    } 

//--> 
/SCRIPT> 
% end if %> 
/body> 
/html>

標簽:江蘇 棗莊 萍鄉(xiāng) 衢州 衡水 大理 蚌埠 廣元

巨人網(wǎng)絡通訊聲明:本文標題《用asp實現(xiàn)的iframe批量替換工具》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    达孜县| 大邑县| 礼泉县| 慈溪市| 盐山县| 黔东| 金沙县| 文昌市| 濮阳县| 常熟市| 丹寨县| 赣州市| 康定县| 运城市| 株洲县| 临江市| 潍坊市| 洪雅县| 铜鼓县| 河池市| 揭东县| 黑龙江省| 思茅市| 富宁县| 临武县| 理塘县| 宁远县| 溆浦县| 长泰县| 涞水县| 天峻县| 瑞昌市| 灵武市| 临澧县| 张家口市| 霍城县| 临安市| 正安县| 兴海县| 棋牌| 七台河市|