Use ASP to package a file into an XML file package, and download the file with the unwrapped ASP tool.

Source: Internet
Author: User
Tags servervariables

Pack the file into an XML file package. It is an ASP tool that can be unwrapped!

Package all the website source code into the XML file, generate the updata. xml file, and upload the XML file to the space.
Then, release all the files through the install. asp file.
Just like the automatic installation package of Z-blog.
Code It was written by an out-of-date brother, but the code seems to be wrong. This is because I have modified it for reference and it can run normally !~~
This Code can be applied to ASP Program . How to implement it !~~
We will discuss it in the reply below !~~~
You do not need to set the package directory version. You need to set the differences between the two versions:
You don't need to set the package directory version, just put it in the directory you want to package for execution.
To set the package directory version, you must specify the path to be packaged (modified in the Program). If this parameter is not specified, you cannot package the package.
No need to set directory-package files
Copy code The Code is as follows: <% @ Language = "VBScript" codePage = "65001" %>
<% Option explicit %>
<% On error resume next %>
<% Response. charset = "UTF-8" %>
<% Server. scripttimeout = 99999999%>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> file package Program </title>
</Head>

<Body>
<%

Dim zippathdir, zippathfile, zipfileext
Dim startime, endtime
'Change the path of the folder to be packaged here
Zippathdir = left (request. servervariables ("path_translated"), limit Rev (request. servervariables ("path_translated "),"\"))'
'Generated XML file
Zippathfile = "Update. xml"
'File extension not packaged
Zipfileext = "DB; Bak"
If right (zippathdir, 1) <> "\" then zippathdir = zippathdir &"\"
'Start Packaging
Createxml (zippathfile)
'Traverse all files and folders in the directory
Sub loaddata (dirpath)
Dim xmldoc
Dim FSO 'fso object
Dim objfolder 'Folder object
Dim objsubfolders
Dim objsubfolder 'subfolders
Dim objfiles
Dim objfile 'file object
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) 'create a folder object

Response. Write dirpath
Response. Flush

Set xmldoc = server. Createobject ("Microsoft. xmldom ")
Xmldoc. Load (server. mappath (zippathfile ))
Xmldoc. async = false

'Write each folder path
Set xfolder = xmldoc. selectsinglenode ("// root"). 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") and lcase (dirpath & objfile. Name) <> lcase (dirpath & zippathfile) then
If ext (objfile. Name) then
Response. Write "--- <br/>"
Pathnamestr = dirpath & "& objfile. Name
Response. Write pathnamestr &""
Response. Flush
'================================================ ==========
'File writing path and file content
Set XFile = xmldoc. selectsinglenode ("// root"). appendchild (xmldoc. createelement ("file "))
Set XPath = XFile. appendchild (xmldoc. createelement ("path "))
XPath. Text = Replace (pathnamestr, zippathdir ,"")
'Create a file stream to read the file content and write it into the XML file
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"
'File content is stored in binary format
Xstream. datatype = "bin. base64"
Xstream. nodetypedvalue = objstream. Read ()

Set objstream = nothing
Set XPath = nothing
Set xstream = nothing
Set XFile = nothing
'================================================ ==========
End if
End if
Next
Response. Write "<p>"
Xmldoc. Save (server. mappath (zippathfile ))
Set xfpath = nothing
Set xfolder = nothing
Set xmldoc = nothing

'Created subfolder object
Set objsubfolders = objfolder. subfolders
'Call recursive traversal of subfolders
For each objsubfolder in objsubfolders
Pathname = dirpath & objsubfolder. Name &"\"
Loaddata (pathname)
Next
Set objfolder = nothing
Set objsubfolders = nothing
Set FSO = nothing

End sub

'Create an empty XML file to prepare for file writing.
Sub createxml (filepath)
'Execution start time of the program
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 ("root "))
Xmldoc. Save (server. mappath (filepath ))
Set root = nothing
Set xmldoc = nothing
Loaddata (zippathdir)
'Program End Time
Endtime = timer ()
Response. Write ("Page execution time:" & formatnumber (endtime-startime), 3) & "seconds ")
End sub

'Determine whether the file type is legal
Function ext (filename)
EXT = true
Dim temp_ext, E
Temp_ext = Split (zipfileext ,";")
For E = 0 to ubound (temp_ext)
If mid (filename, limit Rev (filename, ".") + 1) = temp_ext (e) Then ext = false
Next
End Function
%>
</Body>
</Html>

Decompress ASP filesCopy codeThe Code is as follows: <% @ Language = "VBScript" codePage = "65001" %>
<% Option explicit %>
<% On error resume next %>
<% Response. charset = "UTF-8" %>
<% Server. scripttimeout = 99999999%>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> file unpacking program </title>
</Head>

<Body>
<%
Dim strlocalpath
'Obtain the physical path of the current folder
Strlocalpath = left (request. servervariables ("path_translated"), limit Rev (request. servervariables ("path_translated "),"\"))

Dim objxmlfile
Dim objnodelist
Dim objfso
Dim objstream
Dim I, j

Set objxmlfile = server. Createobject ("Microsoft. xmldom ")
Objxmlfile. Load (server. mappath ("Update. xml "))

If objxmlfile. readystate = 4 then
If objxmlfile. parseerror. errorcode = 0 then

Set objnodelist = objxmlfile.doc umentelement. selectnodes ("// Folder/path ")
Set objfso = Createobject ("scripting. FileSystemObject ")

J = objnodelist. Length-1
For I = 0 to J
If objfso. folderexists (strlocalpath & objnodelist (I). Text) = false then
Objfso. createfolder (strlocalpath & objnodelist (I). Text)
End if
Response. Write "create directory" & objnodelist (I). Text & "<br/>"
Response. Flush
Next
Set objfso = nothing
Set objnodelist = nothing
Set objnodelist = objxmlfile.doc umentelement. 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
Response. Write "release files" & objnodelist (I). Text & "<br/>"
Response. Flush
. Close
End
Set objstream = nothing
Next
Set objnodelist = nothing
End if
End if

Set objxmlfile = nothing

Response. Write "file unwrapped"
%>
</Body>
</Html>

Package File Download

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.