当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp实现rar压缩和解压缩源代码

ASP
Adodb.Command 平时很少注意到的一个参数
Asp.Net控件加载错误的解决方法
远程连接access数据库的方法
创建具有JScript的HTML的XMLHTTP
在Asp中如何快速优化分页的技巧
用VB生成DLL封装ASP代码,连接数据库
RS.OPEN SQL,CONN,A,B 全接触
利用adodb.stream直接下载任何后缀的文件(防盗链)
用ASP编程控制在IIS建立Web站点的程序代码
使用VBScript操作Html复选框(CheckBox)控件
把文章内容中涉及到的图片自动保存到本地服务器
两个不同数据库表的分页显示解决方案
使用组件封装数据库操作(一)
使用组件封装数据库操作(二)
如何在pb中创建COM组件,并在asp中调用并返回结果集?
用ASP和Microsoft.XMLDOM分析远程XML文件
浅谈无刷新取得远程数据技术
将ASP纪录集输出成n列的的表格形式显示的方法
在ASP中通过oo4o连接Oracle数据库的例子
Server Application Error详细解决办法

ASP 中的 asp实现rar压缩和解压缩源代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 144 ::
收藏到网摘: n/a

asp实现rar压缩和解压缩源代码,只要一个文件就可能搞定,asp压缩目录或文件,解压rar文件,删除特定文件等功能.此源码方便大家进行二次开发,分享出来.

以下是winrar.asp代码:

以下为引用的内容:

<!--
Name -阿言在线winrar插件 
copyright -北国药苑BBS(www.spubbs.com)
created - 2006/5/17
author - 阿言:[email protected] QQ:12895551
-->
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<title>欢迎使用阿言在线winrar插件</title>
<body>
<TABLE border=0 width=80% align=center cellspacing=1 cellpadding=3 style="FONT-FAMILY: Verdana;font-size:14px;BORDER: #000000 1px solid;background-color:#f7f7f7">
<tr>
<th width="100%" height="24" bgcolor="#e4e4e4"><strong><font color="#FF0000">阿言在线winrar插件</font></strong>最新更新时间2006.5.17 [<a href="http://www.spubbs.com/dispbbs.asp?boardid=24&id=19979" target=_blank>支持页面</a>]
</th>
</tr>
<tr>
  <td>
<%
Server.ScriptTimeout=99999
Dim winrar,cmddir
Winrar="C:\Program Files\WinRAR\Winrar.exe" ’Winrar.exe的路径Progra~1。
cmddir="%windir%\system32\cmd.exe" ’cmd.exe的路径
user="spubbs.com"’用户名
pwd="spubbs.com"’登陆、压缩、解压缩密码,出于安全考虑,请将此密码设置足够强壮
if request.Form("user")=user and request.Form("pwd")=pwd then
response.write "本文件夹路径:"&Server.Mappath(".")&"<br>"
from=request.Form("from")
where=request.Form("where")
if from<>"" and where<>"" then
  Dim a,b,Shell,Runing,Runcode,Cmd 
  if instr(where,":")=0 then a=Server.mappath(""&where&"") else a=where
  if instr(from,":")=0 then b=Server.mappath(""&from&"") else b=from
  ’response.Write b
  if right(b,1)<>"\" and left(right(b,4),1)<>"." then b=b&".rar"
  On Error Resume Next 
  Set Shell = Server.CreateObject("WScript.Shell")
  if  request.QueryString("action")=1 then ’解压缩
  if not ReportFileStatus(b)then Response.Write(b&"不存在!"):Response.End()
  Runing= cmddir&" /c """&winrar&""" x -ibck -t -y -o+ -p"&pwd&" " ’设置运行解压缩的命令。
  Cmd=Runing&b&" "&a&"\" 
  elseif request.QueryString("action")=0 then ’压缩
  if (not ReportFileStatus(a)) and (not ReportFolderStatus(a)) then Response.Write(a&"不存在!"):Response.End()
  Cmd= cmddir&" /c del /f /q "&b
  Runcode = Shell.Run(Cmd,1,True)
  Runing= cmddir&" /c """&winrar&""" a -ibck -y -ep -o+ -p"&pwd&" " ’压缩。
  Cmd=Runing&b&" "&a
  else  ’删除文件 
  Cmd= cmddir&" /c del /f /q "&b
  end if
  Runcode = Shell.Run(Cmd,1,True)
  Runing = Shell.Run(cmddir&" /c taskkill /im winrar.exe",1,false)
  Runing = Shell.Run(cmddir&" /c exit",1,false)
  Set Shell=nothing 
  ErrInfo
%> 
<%else%>
<form name="frm" method="post" action="?action=1" style="BORDER: #d9d9d9 1px solid;background-color:#f7f7f7">
--------------------------------------<strong>解压缩</strong>---------------------------------------
<br>
<br>
请输入rar文件地址:
<input name="from" value="1.rar" size="50"><br>
解压到:<input  name="where" value="." size="50">
文件夹请使用绝对路径且在最后加“\” <br>
<br>
<input name="submit" type="submit" value=" 解 压 "><input type="hidden" name="user" value="<%=request.Form("user")%>">
<input type="hidden" name="pwd" value="<%=request.Form("pwd")%>"></FORM>
<form name="frm" method="post" action="?action=0" style="BORDER: #d9d9d9 1px solid;background-color:#f7f7f7">
--------------------------------------<strong>压缩文件</strong>---------------------------------------<br>
<br>
请输入要压缩文件地址:
<input  name="where" value="./data/dvbbs7#.mdb" size="50">
文件夹也可<br>
<br>
存放路径及新文件名:<input name="from" value="../data/1.rar" size="50">
自动覆盖同名文件<br>
<br>
<input name="submit" type="submit" value=" 压 缩 "><input type="hidden" name="user" value="<%=request.Form("user")%>">
<input type="hidden" name="pwd" value="<%=request.Form("pwd")%>"></FORM>
<%
ErrInfo
end if
else
login()
end if
Sub ErrInfo
  if not isempty(Runcode) and Runcode=0 Then 
  Response.Write("命令成功执行,您提交的命令如下:<br>"& Cmd) 
  elseif not isempty(Runcode) then 
  Response.Write("命令执行失败!权限不够或者该程序无法在DOS状态下运行,您提交的命令如下:<br>" & Cmd)
  else
  end if
  If Err Then
     Response.Write "<br>"&err.description
  err.Clear
  End If
%>
<form name="frm" method="post" action="?action=2" style="BORDER: #d9d9d9 1px solid;background-color:#f7f7f7">
--------------------------------------<strong>删除文件</strong>---------------------------------------<br>
<br>
请输入要删除文件地址:<input name="from"  size="50" value=<%=from%>>
文件夹请使用绝对路径且在最后加“\” <br>
<input type="hidden" name="where" value=<%if where<>"" then response.Write where else response.Write "."%>>
<br>
<input name="submit" type="submit" value=" 删 除 ">
<input type="hidden" name="user" value="<%=request.Form("user")%>">
<input type="hidden" name="pwd" value="<%=request.Form("pwd")%>">
</FORM>
<br>
<%
End Sub
Function ReportFileStatus(filespec) 
  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")
  ReportFileStatus=false
  If (fso.FileExists(filespec)) Then  ReportFileStatus = true
  Set fso =nothing
End Function
Function ReportFolderStatus(fldr) 
  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")
  ReportFolderStatus=false
  If (fso.FolderExists(fldr)) Then  ReportFolderStatus = true
  Set fso =nothing
End Function
Sub login()
%>
<form name="frm" method="post" action="?action=2" style="BORDER: #d9d9d9 1px solid;background-color:#f7f7f7">
  <p>--------------------------------------<strong>登陆系统</strong>---------------------------------------<br>
    <br>
用户名:
<input name="user" value="spubbs.com">
  </p>
密 码:
    <input name="pwd" type="password" id="pwd">  
    <br>
  <br>
  <input name="submit" type="submit" value=" 登陆 ">
</FORM>
<%End sub%>
</td>
</tr>
<tr>
  <td height="22" align="center" bgcolor="#e8e8e8">Powered By :<a href = "mailto:[email protected]">阿言</a>&nbsp; <a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=12895551&Site=www.spubbs.com在线winrar&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa?p=1:12895551:3 alt=给阿言发即时消息QQ:12895551 align=absbottom></a>   Copyright &copy;2003 - 2006  <a href="http://www.spubbs.com">北国药苑BBS</a></td>
</tr>
</table>
</body>