| 关键词: nbsp response XmlDoc set objNodeList nothing strLocalPath objStream 文件 Write |
因有朋友需要XML版愚人笔记程序,说安装上传方便,所以我又上传了XML版的程序到原地址中。代码也是网上搜索的,打包速度和安装速度都不错,暂时没有发现错误。 我就顺便贴出来,各位黑友以后打包网站也方便。 类似工具:Asp整站打包后门工具http://hacknote.com/read/?37.html 这里是ASP打包MDB VBS解压Pack.asp 注意我标红色的部分,自行修改。 <% Dim ZipPathDir,ZipPathFile Dim startime,endtime Dim FilePath,DirPath '在此更改要打包文件夹的路径 ZipPathDir = "I:\备份文件\MySite\pzwx.cn\html\html" '这是要打包成的XML文件名 ZipPathFile = "Player.xml" if right(ZipPathDir,1)<>"\" then ZipPathDir=ZipPathDir&"\" '开始打包Call CreateXml(ZipPathFile) '遍历目录内的所有文件以及文件夹sub LoadData(DirPath) dim XmlDoc dim fso 'fso对象 dim objFolder '文件夹对象 dim objSubFolders '子文件夹集合 dim objSubFolder '子文件夹对象 dim objFiles '文件集合 dim objFile '文件对象 dim objStream dim pathname,TextStream,pp,Xfolder,Xfpath,Xfile,Xpath,Xstream dim PathNameStr response.Write("=========="&DirPath&"==========<br>") set fso=server.CreateObject("scripting.filesystemobject") set objFolder=fso.GetFolder(DirPath)'创建文件夹对象 Response.Write DirPath Response.flush Set XmlDoc = Server.CreateObject("Microsoft.XMLDOM") XmlDoc.load Server.MapPath(ZipPathFile) XmlDoc.async=false '写入每个文件夹路径 set Xfolder = XmlDoc.SelectSingleNode("//data").AppendChild(XmlDoc.CreateElement("folder")) Set Xfpath = Xfolder.AppendChild(XmlDoc.CreateElement("path")) Xfpath.text = replace(DirPath,ZipPathDir,"") set objFiles=objFolder.Files for each objFile in objFiles if lcase(DirPath & objFile.name) <> lcase(Request.ServerVariables("PATH_TRANSLATED")) then Response.Write "---<br/>" PathNameStr = DirPath & "" & objFile.name Response.Write PathNameStr & "" Response.flush '================================================ '写入文件的路径及文件内容 set Xfile = XmlDoc.SelectSingleNode("//data").AppendChild(XmlDoc.CreateElement("file")) Set Xpath = Xfile.AppendChild(XmlDoc.CreateElement("path")) Xpath.text = replace(PathNameStr,ZipPathDir,"") '创建文件流读入文件内容,并写入XML文件中 Set objStream = Server.CreateObject("ADODB.Stream") objStream.Type = 1 objStream.Open() objStream.LoadFromFile(PathNameStr) objStream.position = 0 Set Xstream = Xfile.AppendChild(XmlDoc.CreateElement("stream")) Xstream.SetAttribute "xmlns:dt","urn:schemas-microsoft-com:datatypes" '文件内容采用二制方式存放 Xstream.dataType = "bin.base64" Xstream.nodeTypedValue = objStream.Read() set objStream=nothing set Xpath = nothing set Xstream = nothing set Xfile = nothing '================================================ end if next Response.Write "<p>" XmlDoc.Save(Server.Mappath(ZipPathFile)) set Xfpath = nothing set Xfolder = nothing set XmlDoc = nothing '创建的子文件夹对象 set objSubFolders=objFolder.Subfolders '调用递归遍历子文件夹 for each objSubFolder in objSubFolders pathname = DirPath & objSubFolder.name & "\" LoadData(pathname) next set objFolder=nothing set objSubFolders=nothing set fso=nothing end sub '创建一个空的XML文件,为写入文件作准备sub CreateXml(FilePath) '程序开始执行时间 startime=timer() dim XmlDoc,Root Set XmlDoc = Server.CreateObject("Microsoft.XMLDOM") XmlDoc.async = False Set Root = XmlDoc.createProcessingInstruction("xml","version='1.0' encoding='UTF-8'") XmlDoc.appendChild(Root) XmlDoc.appendChild(XmlDoc.CreateElement("data")) XmlDoc.Save(Server.MapPath(FilePath)) Set Root = Nothing Set XmlDoc = Nothing Call LoadData(ZipPathDir) '程序结束时间 endtime=timer() response.Write("页面执行时间:" & FormatNumber((endtime-startime),3) & "秒")end sub%> install.asp <%Dim PathPath = Left(Request.ServerVariables("PATH_INFO"),InstrRev(Request.ServerVariables("PATH_INFO"),"/"))Dim strInstallPath,varInstallPathstrInstallPath = PathvarInstallPath = strInstallPath Response.Write "<ul>"Response.Write "<li>正在安装系统...</li>"Response.Flush() Call Release("Player.xml",strInstallPath)If Right(varInstallPath,1) <> "/" Then varInstallPath = varInstallPath & "/"Response.Write "<li>正在生成Html页面...</li>"Response.Flush() Response.Write "<script type=""text/javascript"" src=""" & varInstallPath & "save.asp""></script>"Response.Write "<li>安装成功。:)</li>"Response.Flush()Response.Write "</ul>" 'Release *** *** www.pzwx.cn *** ***Sub Release(strFileXML,strLocalPath) Dim objXmlFile Dim objNodeList Dim objFSO Dim objStream Dim I,J strLocalPath = Server.MapPath(strLocalPath) If Right(strLocalPath,1) <> "\" Then strLocalPath = strLocalPath & "\" Set objXmlFile = CreateObject("Microsoft.XMLDOM") objXmlFile.load(Server.MapPath(strFileXML)) If objXmlFile.readyState=4 Then If objXmlFile.parseError.errorCode = 0 Then Set objNodeList = objXmlFile.documentElement.selectNodes("//folder/path") Set objFSO = CreateObject("Scripting.FileSystemObject") J = objNodeList.Length - 1 For I = 0 To J If Not objFSO.FolderExists(strLocalPath & objNodeList(I).Text) Then objFSO.CreateFolder(strLocalPath & objNodeList(I).Text) Response.Write "<li>创建目录:" & strLocalPath & objNodeList(I).Text & "</li>" Response.Flush() End If Next Set objFSO = nothing Set objNodeList = Nothing Set objNodeList = objXmlFile.documentElement.selectNodes("//file/path") J = objNodeList.Length - 1 For I = 0 To J Set objStream = CreateObject("ADODB.Stream") With objStream .Type = 1 .Open .Write objNodeList(I).nextSibling.nodeTypedvalue .SaveToFile strLocalPath & objNodeList(I).Text,2 .Close() End With Set objStream = Nothing Response.Write "<li>创建文件:" & strLocalPath & objNodeList(I).Text & "</li>" Response.Flush() Next Set objNodeList = nothing End If End If Set objXmlFile = NothingEnd Sub%> |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|