📄 adddoc.asp
字号:
<%@ Language=VBScript %>
<%
' Use of this software is permitted, provided that the code is NOT
' modified without written permission of Yansa Inc. (http://www.yasna.com)
' THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
' WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
' OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
' DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
' ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
' LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
' USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
' ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
' OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
' OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
' SUCH DAMAGE.
Response.Expires = -1
Server.ScriptTimeout = 600
Dim username
Dim password
%>
<!-- #include file="freeaspupload.asp" -->
<%
Dim uploadsDirVar
uploadsDirVar = Server.MapPath("./docs")
username = session("user")
password = session("pass")
%>
<!-- #include file="validate.asp" -->
<%
nodeid = Request.QueryString("id")
Set Upload = New FreeASPUpload
Upload.Save(uploadsDirVar)
for each fileKey in Upload.UploadedFiles.keys
fname = Upload.UploadedFiles(fileKey).FileName
next
ks = Upload.FormElements.Keys
for each Key in Upload.FormElements.Keys
response.write Key & "=" & Upload.FormElements.Item(Key) &"<br>"
if (lcase(Key) = "docreate" and lcase(Upload.FormElements.Item(Key)) = "true") then
doCreate = true
end if
if (lcase(Key) = "title" ) then
newTitle = Upload.FormElements.Item(Key)
end if
next
if (fname = "" and newTitle = "") then
doCreate = false
end if
%>
<%
strXMLFile = server.MapPath("xml/intranet.xml")
'starting XMLDOM
set objXML = Server.CreateObject("Msxml2.DOMDocument")
'turning off asynchronous loading
objXML.async = false
'loading the XML file
objXML.load(strXMLFile)
Set root = objXML.documentElement
if doCreate then
' Get Max Node Id
For Each node In root.childNodes
if node.attributes.item(0).value > maxid then
maxid = node.attributes.item(0).value
maxid = maxid + 1
end if
Next
For Each node In root.childNodes
if node.attributes.item(0).value = nodeid then
Set newDocument = objXML.createNode(1,"document","")
Set aTitle = objXML.createNode(1,"title","")
if fname <> "" then
Set aLink = objXML.createNode(1,"link","1")
aLink.text = fname
else
if fname = "" then
Set aLink = objXML.createNode(1,"link","0")
aLink.text = maxid
end if
end if
aTitle.text = newTitle
newDocument.appendChild(aTitle)
newDocument.appendChild(aLink)
node.childNodes.item(1).appendChild(newDocument)
end if
Next
Set newnode = objXML.createNode(1, "Page", maxid)
set newPageTitle = objXML.createNode(1,"title","")
newPageTitle.text = "page title"
newnode.appendChild(newPageTitle)
newnode.appendChild(objXML.createNode(1,"links",""))
root.appendChild(newnode)
objXML.save(strXMLFile)
end if
%>
<% response.redirect "editpage.asp?id="&nodeid %>
<html>
<head>
<title>Page Upload</title>
</head>
<body>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -