admin_data.asp
上传用户:comthink
上传日期:2021-05-06
资源大小:1280k
文件大小:8k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. <!--#include file =conn.asp-->
  2. <!-- #include file="inc/const.asp" -->
  3. <title><%=txl_info(0)%>--管理页面</title>
  4. <!--#include file="inc/admin_css.asp"-->
  5. <meta NAME=GENERATOR Content="Microsoft FrontPage 3.0" CHARSET=GB2312>
  6. <BODY leftmargin="0" bottommargin="0" rightmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
  7. <%
  8. dim action
  9. action=trim(request("action"))
  10. dim dbpath,bkfolder,bkdbname,fso,fso1
  11. select case action
  12. case "CompressData" '压缩数据
  13. if not supermaster or session("flag")="" then
  14. Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用,请<a href=admin_index.asp target=_top>登陆</a>后进入。<br><li>您没有管理本页面的权限。"
  15. call txl_error()
  16. else
  17. dim tmprs
  18. dim allarticle
  19. dim Maxid
  20. dim topic,dateandtime,body
  21. call CompressData()
  22. end if
  23. case "BackupData" '备份数据
  24. if not supermaster or session("flag")="" then
  25. Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用,请<a href=admin_index.asp target=_top>登陆</a>后进入。<br><li>您没有管理本页面的权限。"
  26. call txl_error()
  27. else
  28. if request("act")="Backup" then
  29. call updata()
  30. else
  31. call BackupData()
  32. end if
  33. end if
  34. case "RestoreData" '恢复数据
  35. dim backpath
  36. if not supermaster or session("flag")="" then
  37. Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用,请<a href=admin_index.asp target=_top>登陆</a>后进入。<br><li>您没有管理本页面的权限。"
  38. call txl_error()
  39. else
  40. if request("act")="Restore" then
  41. Dbpath=request.form("Dbpath")
  42. backpath=request.form("backpath")
  43. if dbpath="" then
  44. response.write "请输入您要恢复成的数据库全名"
  45. else
  46. Dbpath=server.mappath(Dbpath)
  47. end if
  48. backpath=server.mappath(backpath)
  49. Set Fso=server.createobject("scripting.filesystemobject")
  50. if fso.fileexists(dbpath) then  
  51. fso.copyfile Dbpath,Backpath
  52. response.write "成功恢复数据!"
  53. else
  54. response.write "备份目录下并无您的备份文件!"
  55. end if
  56. else
  57. call RestoreData()
  58. end if
  59. end if
  60. case else
  61. Errmsg=Errmsg+"<br>"+"<li>选取相应的操作。"
  62. call txl_error()
  63. end select
  64. conn.close
  65. set conn=nothing
  66. response.write"</body></html>"
  67. '====================恢复数据库=========================
  68. sub RestoreData()
  69. %>
  70. <table border="0"  cellspacing="1" cellpadding="5" height="1" align=center width="95%" class="tableBorder" <tr>
  71. <th height=25 >
  72.     &nbsp;&nbsp;<B>恢复论坛数据</B>( 需要FSO支持,FSO相关帮助请看微软网站 )
  73.    </th>
  74.    </tr>
  75. <form method="post" action="ADMIN_data.asp?action=RestoreData&act=Restore">
  76.   
  77.    <tr>
  78.    <td height=100 class="txlrow">
  79.    &nbsp;&nbsp;备份数据库路径(相对):<input type=text size=30 name=DBpath value="DataBackuptxl5_Backup.MDB">&nbsp;&nbsp;<BR>
  80.    &nbsp;&nbsp;目标数据库路径(相对):<input type=text size=30 name=backpath value="<%=db%>"><BR>&nbsp;&nbsp;填写您当前使用的数据库路径,如不想覆盖当前文件,可自行命名(注意路径是否正确),然后修改conn.asp文件,如果目标文件名和当前使用数据库名一致的话,不需修改conn.asp文件<BR>
  81. &nbsp;&nbsp;<input type=submit value="恢复数据"> <br>
  82.    -----------------------------------------------------------------------------------------<br>
  83.    &nbsp;&nbsp;在上面填写本程序的数据库路径全名,本程序的默认备份数据库文件为DataBackuplbtxl_Backup.MDB,请按照您的备份文件自行修改。<br>
  84.    &nbsp;&nbsp;您可以用这个功能来备份您的法规数据,以保证您的数据安全!<br>
  85.    &nbsp;&nbsp;注意:所有路径都是相对与程序空间根目录的相对路径</font>
  86.    </td>
  87.    </tr>
  88.    </form>
  89.    </table>
  90. <%
  91. end sub
  92. '====================备份数据库=========================
  93. sub BackupData()
  94. %>
  95. <table border="0"  cellspacing="1" cellpadding="5" height="1" align=center width="95%" class="tableBorder">
  96.    <tr>
  97.    <th height=25 >
  98.    &nbsp;&nbsp;<B>备份论坛数据</B>( 需要FSO支持,FSO相关帮助请看微软网站 )
  99.    </th>
  100.    </tr>
  101.    <form method="post" action="ADMIN_data.asp?action=BackupData&act=Backup">
  102.    <tr>
  103.    <td height=100 class="txlrow">
  104.    &nbsp;&nbsp;
  105. 当前数据库路径(相对路径):<input type=text size=15 name=DBpath value="<%=db%>"><BR>&nbsp;&nbsp;
  106. 备份数据库目录(相对路径):<input type=text size=15 name=bkfolder value=Databackup>&nbsp;如目录不存在,程序将自动创建<BR>&nbsp;&nbsp;
  107. 备份数据库名称(填写名称):<input type=text size=15 name=bkDBname value=txl5.MDB>&nbsp;如备份目录有该文件,将覆盖,如没有,将自动创建<BR>
  108. &nbsp;&nbsp;<input type=submit value="确定"><br>
  109.    -----------------------------------------------------------------------------------------<br>
  110.    &nbsp;&nbsp;在上面填写本程序的数据库路径全名,本程序的默认数据库文件为Datalbtxl5.MDB,<B>请一定不能用默认名称命名备份数据库</B><br>
  111.    &nbsp;&nbsp;您可以用这个功能来备份您的法规数据,以保证您的数据安全!<br>
  112.    &nbsp;&nbsp;注意:所有路径都是相对与程序空间根目录的相对路径 </font>
  113.    </td>
  114.    </tr>
  115.    </form>
  116.    </table>
  117. <%
  118. end sub
  119. sub updata()
  120. Dbpath=request.form("Dbpath")
  121. Dbpath=server.mappath(Dbpath)
  122. bkfolder=request.form("bkfolder")
  123. bkdbname=request.form("bkdbname")
  124. Set Fso=server.createobject("scripting.filesystemobject")
  125. if fso.fileexists(dbpath) then
  126. If CheckDir(bkfolder) = True Then
  127. fso.copyfile dbpath,bkfolder& ""& bkdbname
  128. else
  129. MakeNewsDir bkfolder
  130. fso.copyfile dbpath,bkfolder& ""& bkdbname
  131. end if
  132. response.write "备份数据库成功,您备份的数据库路径为" &bkfolder& ""& bkdbname
  133. Else
  134. response.write "找不到您所需要备份的文件。"
  135. End if
  136. end sub
  137. '------------------检查某一目录是否存在-------------------
  138. Function CheckDir(FolderPath)
  139. folderpath=Server.MapPath(".")&""&folderpath
  140.     Set fso1 = CreateObject("Scripting.FileSystemObject")
  141.     If fso1.FolderExists(FolderPath) then
  142.        '存在
  143.        CheckDir = True
  144.     Else
  145.        '不存在
  146.        CheckDir = False
  147.     End if
  148.     Set fso1 = nothing
  149. End Function
  150. '-------------根据指定名称生成目录-----------------------
  151. Function MakeNewsDir(foldername)
  152. dim f
  153.     Set fso1 = CreateObject("Scripting.FileSystemObject")
  154.         Set f = fso1.CreateFolder(foldername)
  155.         MakeNewsDir = True
  156.     Set fso1 = nothing
  157. End Function
  158. '====================压缩数据库 =========================
  159. sub CompressData()
  160. %>
  161. <table border="0"  cellspacing="1" cellpadding="5" height="1" align=center width="95%" class="tableBorder">
  162. <form action="Admin_data.asp?action=CompressData" method="post">
  163. <tr>
  164. <td class="txlrow" height=25><b>注意:</b><br>输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作) </td>
  165. </tr>
  166. <tr>
  167. <td class="txlrow">压缩数据库:<input type="text" name="dbpath" value="Datatxl5.MDB">&nbsp;
  168. <input type="submit" value="开始压缩"></td>
  169. </tr>
  170. <tr>
  171. <td class="txlrow"><input type="checkbox" name="boolIs97" value="True">如果使用 Access 97 数据库请选择
  172. (默认为 Access 2000 数据库)<br><br></td>
  173. </tr>
  174. <form>
  175. </table>
  176. <%
  177. dim dbpath,boolIs97
  178. dbpath = request("dbpath")
  179. boolIs97 = request("boolIs97")
  180. If dbpath <> "" Then
  181. dbpath = server.mappath(dbpath)
  182. response.write(CompactDB(dbpath,boolIs97))
  183. End If
  184. end sub
  185. '=====================压缩参数=========================
  186. Function CompactDB(dbPath, boolIs97)
  187. Dim fso, Engine, strDBPath,JET_3X
  188. strDBPath = left(dbPath,instrrev(DBPath,""))
  189. Set fso = CreateObject("Scripting.FileSystemObject")
  190. If fso.FileExists(dbPath) Then
  191. Set Engine = CreateObject("JRO.JetEngine")
  192. If boolIs97 = "True" Then
  193. Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
  194. "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb;" _
  195. & "Jet OLEDB:Engine Type=" & JET_3X
  196. Else
  197. Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
  198. "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb"
  199. End If
  200. fso.CopyFile strDBPath & "temp.mdb",dbpath
  201. fso.DeleteFile(strDBPath & "temp.mdb")
  202. Set fso = nothing
  203. Set Engine = nothing
  204. CompactDB = "你的数据库, " & dbpath & ", 已经压缩成功!" & vbCrLf
  205. Else
  206. CompactDB = "数据库名称或路径不正确. 请重试!" & vbCrLf
  207. End If
  208. End Function
  209. %>