网络通信 频道

执行一个asp文件完成防止Access数据库下载

思路是来自:<%的使用,然后Asp执行的时候报错。

现在只是把他写成asp代码了,方便使用。

因为这样话可以直接执行就ok了,也不用下载数据库然后建表等。。。。然后再上传覆盖了。。。

偶的代码只是为了实现这个功能:讲究实用。请各位多多指点。。。。

顺便补充一下这代码产生的背景:我也是提议mdb映射的比较好,也作了录象了,后来他硬要问:在没有做隐射的虚拟主机上怎么办,所以就匆忙写了这么段代码免去他下载然后手工插入<%然后上传的麻烦。

1.加了详细的错误描述了。

2.我用随机表应该可以解决这个问题的吧。

3.我加入多个<%也基本可以避免%>的问题的吧。在简单的其他地方不涉及两进制数据的时候,我认为这个方法还是不错。

同时谢谢zhouzhen的批评。欢迎再次提出批评。。谢谢
<%OPTION EXPLICIT%>

字串6


<%
Dim str_form,str_version,i
dim mdbfile,conn,rec,str_notdown,tabale_notdown
str_version="code by 喜欢忧伤QQ:122545971<br>"
str_version=str_version&"本页代码作用:防止Access数据库被下载<br>"&"特点是:使用方便,直接上传到空间执行完毕就可以了。<br>"
str_version=str_version& "powers联盟大家庭<A href=''http://www.powers.com.cn''>_blank>http://www.powers.com.cn</A><br>"


mdbfile=request("mdbfile")

if mdbfile="" then
str_form="<form action='''' method=''post''>数据库文件名[包含相对路径]:<input type=text name=mdbfile></input><input type=''submit'' name=''submit'' value=''防止下载''>"
call out_YS(str_form)
response.end
end if


mdbfile=server.mappath(mdbfile)

字串4


set conn=server.createobject("adodb.connection")
On error resume next
conn.open "driver={microsoft access driver (*.mdb)};uid=admin;pwd=;dbq="&mdbfile
If Err Then
err.Clear
Set Conn = Nothing
call out_YS("数据库连接出错,请检查数据库名字和相对路径是否正确<A href=''javascript:history.back()''>返回</A>")
Response.End
End If


On error resume next
''取随机表名
RANDOMIZE()
tabale_notdown="notdown"&int(9999*rnd()+1)
tabale_notdown="notdown678"
conn.execute("create table "&tabale_notdown&"(notdown image)")
if err then
call out_YS("出错:<b>"&err.Description &"</b>,<br><br>请根据提示解决这个问题")
else
str_notdown=chrB(60)&chrB(37)
for i=1 to 13
str_notdown=str_notdown&chrB(60)&chrB(37)
next
set rec=server.createobject("ADODB.recordset") 字串1
rec.Open "SELECT * FROM notdown",conn,1,3
rec.addnew
rec("notdown").appendchunk str_notdown
rec.update
rec.close
set rec=nothing
call out_YS("防止下载完成,同时提醒一下,如果不是asp扩展名的请修改为asp")
end if
conn.close
set conn=nothing
sub out_YS(str_out)
response.write "<div align=left>"&str_version& "</div><center>"&"<br><br><br ><br>"&str_out&"<br>"&"<br> "&"<br>"&"<br>"&"<br>"&"&l t;br></center>"
end sub
%>


编者:mdb映射防止下载动画:http://soft.hackbase.com/view.asp?id=20050218mdb.rar

 

 

文章来源地址:http://www.hackhome.com/html/wlcl/wlaq/2006/0610/26610.html

0
相关文章