欢迎光临
我们一直在努力

从PJBLOG中剥离出来的数据库和附件管理程序

以下的代码是从PJBLOG中剥离出来的网站数据库备份、压缩修复、恢复,以及附件的浏览、删除的管理程序,只要修改一下路径和自己网站的配置就可已使用在自己的系统中:

程序代码
<%if Request.QueryString("Fmenu")="SQLFile" then '数据库与文件%>

<%=categoryTitle%>
<%getMsg%>
<% if Request.QueryString("Smenu")="Attachments" then %>



<% dim AttPath,ArrFolder,Arrfile,ArrFolders,Arrfiles,arrUpFolders,arrUpFolder,TempF TempF="" AttPath=Request.QueryString("AttPath") if len(AttPath)<1 then AttPath="attachments" elseif bc(server.mapPath(AttPath),server.mapPath("attachments")) then AttPath="attachments" end If ArrFolders=split(getPathList(AttPath)(0),"*") Arrfiles=split(getPathList(AttPath)(1),"*") response.write "
"&AttPath&"
"
'http://www.xxx.cn/ConContent.asp?Fmenu=SQLFile&Smenu=Attachments&AttPath=attachments/month_0705
if AttPath<>"attachments" then
arrUpFolders=split(AttPath,"/")
for i=0 to ubound(arrUpFolders)-1
arrUpFolder=arrUpFolder&TempF&arrUpFolders(i)
TempF="/"
next
end if
if len(arrUpFolder)>0 then
response.write " 从PJBLOG中剥离出来的数据库和附件管理程序返回上级目录
"
end if
for each ArrFolder in ArrFolders
response.write " 从PJBLOG中剥离出来的数据库和附件管理程序"&ArrFolder&"
"
next
for each Arrfile in Arrfiles
response.write " "&getFileIcons(getFileInfo(AttPath&"/"&Arrfile)(1))&Arrfile&" "&getFileInfo(AttPath&"/"&Arrfile)(0)&" | "&getFileInfo(AttPath&"/"&Arrfile)(2)&" | "&getFileInfo(AttPath&"/"&Arrfile)(3)&"
"
next
response.write "

"
%>

如果文件夹内存在文件,那么该文件夹将无法删除!

<%else%>
数据库路径: <%=Server.MapPath(AccessFile)%>
数据库大小: <%=getFileInfo(AccessFile)(0)%>
数据库操作: 压缩修复 | 备份
<% Dim AccessFSO,AccessEngine,AccessSource '-------------压缩数据库----------------- if Request.QueryString("do")="Compact" then 'http://www.xxx.cn/ConContent.asp?Fmenu=SQLFile&do=Compact Set AccessFSO=Server.CreateObject("Scripting.FileSystemObject") IF AccessFSO.FileExists(Server.Mappath(AccessFile)) Then Response.Write "

"
Response.Write "压缩数据库开始,网站暂停一切用户的前台操作…
"
Response.Write "关闭数据库操作…
"
call CloseDB
Application.Lock
FreeApplicationMemory
Application(CookieName & "_SiteEnable") = 0
Application(CookieName & "_SiteDisbleWhy") = "网站暂停中,请稍候几分钟后再来…"
Application.UnLock
Set AccessEngine = CreateObject("JRO.JetEngine")
AccessEngine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(AccessFile), "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(AccessFile & ".temp")
AccessFSO.CopyFile Server.Mappath(AccessFile & ".temp"),Server.Mappath(AccessFile)
AccessFSO.DeleteFile(Server.Mappath(AccessFile & ".temp"))
Set AccessFSO = Nothing
Set AccessEngine = Nothing
Application.Lock
Application(CookieName & "_SiteEnable") = 1
Application(CookieName & "_SiteDisbleWhy") = ""
Application.UnLock
Response.write "压缩数据库完成…
"
Application.Lock
Application(CookieName & "_SiteEnable") = 1
Application(CookieName & "_SiteDisbleWhy") = ""
Application.UnLock
Response.Write "网站恢复正常访问…"
Response.Write "

"
Response.write ""
end if
end if
'————-备份数据库数据库—————–
if Request.QueryString("do")="Backup" then
'http://www.xxx.cn/ConContent.asp?Fmenu=SQLFile&do=Backup
Set AccessFSO=Server.CreateObject("Scripting.FileSystemObject")
IF AccessFSO.FileExists(Server.Mappath(AccessFile)) Then
Response.Write "

"
Response.Write "备份数据库开始,网站暂停一切用户的前台操作…
"
Response.Write "关闭数据库操作…
"
call CloseDB
Application.Lock
FreeApplicationMemory
Application(CookieName & "_SiteEnable") = 0
Application(CookieName & "_SiteDisbleWhy") = "网站暂停中,请稍候几分钟后再来…"
Application.UnLock
CopyFiles Server.Mappath(AccessFile),Server.Mappath("backup/Backup_" & DateToStr(Now(),"YmdHIS") & "_" & randomStr(8) &".mbk")
Application.Lock
Application(CookieName & "_SiteEnable") = 1
Application(CookieName & "_SiteDisbleWhy") = ""
Application.UnLock
Response.write "压缩数据库完成…
"
Application.Lock
Application(CookieName & "_SiteEnable") = 1
Application(CookieName & "_SiteDisbleWhy") = ""
Application.UnLock
Response.Write "网站恢复正常访问…"
Response.Write "

"
Response.write ""
end if
Set AccessFSO=Nothing
end if
'—————还原数据库————
if Request.QueryString("do")="Restore" then
AccessSource=Request.QueryString("source")
Set AccessFSO=Server.CreateObject("Scripting.FileSystemObject")
IF AccessFSO.FileExists(Server.Mappath(AccessSource)) Then
Response.Write "

"
Response.Write "还原数据库开始,网站暂停一切用户的前台操作…
"
Response.Write "关闭数据库操作…
"
call CloseDB
Application.Lock
FreeApplicationMemory
Application(CookieName & "_SiteEnable") = 0
Application(CookieName & "_SiteDisbleWhy") = "网站暂停中,请稍候几分钟后再来…"
Application.UnLock
CopyFiles Server.Mappath(AccessFile),Server.Mappath(AccessFile & ".TEMP")
if DeleteFiles(Server.Mappath(AccessFile)) then response.write ("原数据库删除成功
")
response.write CopyFiles(Server.Mappath(AccessSource),Server.Mappath(AccessFile))
if DeleteFiles(Server.MapPath(AccessSource)) then response.write ("数据库备份删除成功
")
if DeleteFiles(Server.Mappath(AccessFile & ".TEMP")) then response.write ("Temp备份删除成功
")
Application.Lock
Application(CookieName & "_SiteEnable") = 1
Application(CookieName & "_SiteDisbleWhy") = ""
Application.UnLock
Response.write "数据库还原完成…
"
Application.Lock
Application(CookieName & "_SiteEnable") = 1
Application(CookieName & "_SiteDisbleWhy") = ""
Application.UnLock
Response.Write "网站恢复正常访问…"
Response.Write "

"
Response.write ""
end if
Set AccessFSO=Nothing
end if
'—————删除备份数据库————
if Request.QueryString("do")="DelFile" then
AccessSource=Request.QueryString("source")
Set AccessFSO=Server.CreateObject("Scripting.FileSystemObject")
IF AccessFSO.FileExists(Server.Mappath(AccessSource)) Then
Response.Write "

"
if DeleteFiles(Server.MapPath(AccessSource)) then response.write ("数据库备份删除成功
")
Response.Write "

"
end if
Set AccessFSO=Nothing
end if
%>

数据库备份列表:
<% dim BackUpFiles,BackUpFile BackUpFiles=split(getPathList("backup")(1),"*") for each BackUpFile in BackUpFiles response.write ""&getFileIcons(getFileInfo("backup/"&BackUpFile)(1))&BackUpFile&""
response.write " 删除 | 还原数据库"
response.write " | "&getFileInfo("backup/"&BackUpFile)(0)&" | "&getFileInfo("backup/"&BackUpFile)(2)&"
"
next
%>
<%end if%>

赞(0) 打赏
未经允许不得转载:新席地网博客 » 从PJBLOG中剥离出来的数据库和附件管理程序
分享到: 更多 (0)
标签:

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  • Q Q(选填)

新席地网-苏州网站制作,360度全景摄影,微信小程序营销推广,抖音运营推广

QQ :13945502电话:17895058839

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

×
订阅图标按钮