DataManage.asp
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:8k
源码类别:

数据库编程

开发平台:

ASP/ASPX

  1. <% Option Explicit %>
  2. <!--#include file="../FS_Inc/Const.asp" -->
  3. <!--#include file="../FS_InterFace/MF_Function.asp" -->
  4. <!--#include file="../FS_Inc/Function.asp" -->
  5. <!--#include file="../FS_Inc/Func_page.asp" -->
  6. <%'Copyright (c) 2006 Foosun Inc. Code by Simpwind.Xie
  7. Response.Buffer = True
  8. Response.Expires = -1
  9. Response.ExpiresAbsolute = Now() - 1
  10. Response.Expires = 0
  11. Response.CacheControl = "no-cache"
  12. Dim Conn,strShowErr,tmp_getPath
  13. MF_Default_Conn
  14. MF_Session_TF
  15. if not MF_Check_Pop_TF("MF_DataFix") then Err_Show
  16. if Request("Action")="Fix" then
  17. if not MF_Check_Pop_TF("MF015") then Err_Show
  18. On Error Resume Next
  19. Dim oldDB,bakDB,newDB,FSO,Engine,EditFile,prov
  20. if Request.QueryString("Sub") = "MF" then
  21. oldDB = "../"&G_DATABASE_CONN_STR
  22. bakDB = "../Foosun_Data/DataBase_BackUp/Foosun_Data.bak" 
  23. newDB = "../Foosun_Data/Foosun_Data_comp.mdb" 
  24. Else
  25. oldDB = "../"&G_User_DATABASE_CONN_STR
  26. bakDB = "../Foosun_Data/DataBase_BackUp/FS_ME.bak" 
  27. newDB = "../Foosun_Data/FS_ME_comp.mdb" 
  28. End if
  29. oldDB = Server.MapPath(oldDB)
  30. bakDB = Server.MapPath(bakDB)
  31. newDB = Server.MapPath(newDB)
  32.     Set FSO = Server.CreateObject(G_FS_FSO) 
  33.     ' back up database 
  34.     FSO.CopyFile oldDB, bakDB , true 
  35.     ' compact database 
  36.     Set Engine = Server.CreateObject("JRO.JetEngine") 
  37.     prov = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
  38.     Engine.CompactDatabase prov & OldDB, prov & newDB 
  39.     set Engine = nothing 
  40.     ' delete original database 
  41.     FSO.DeleteFile oldDB 
  42.     ' Move (rename) compacted database 
  43.     FSO.MoveFile newDB, oldDB 
  44.     set FSO = nothing  
  45. Call MF_Insert_oper_Log("数据库维护","压缩数据库",now,session("admin_name"),"MF")
  46. strShowErr = "<li>数据库压缩成功.</li>"
  47. Response.Redirect("Success.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=")
  48. Response.end
  49. End if
  50. if Request("Action")="bak" then
  51. if not MF_Check_Pop_TF("MF016") then Err_Show
  52. Randomize
  53. Dim tmp_GetRamCode
  54. tmp_GetRamCode = GetRamCode(16)
  55.     Set FSO = Server.CreateObject(G_FS_FSO) 
  56. if FSO.FolderExists(Server.MapPath("..Foosun_DataDataBase_BackUp"))=false then FSO.createFolder Server.MapPath("..Foosun_DataDataBase_BackUp") 
  57. if Request.QueryString("Sub") = "MF" then
  58. oldDB = "../"&G_DATABASE_CONN_STR
  59. bakDB = "../Foosun_Data/DataBase_BackUp/MF_"&tmp_GetRamCode&".bak" 
  60. Else
  61. oldDB = "../"&G_User_DATABASE_CONN_STR
  62. bakDB = "../Foosun_Data/DataBase_BackUp/ME_"&tmp_GetRamCode&".bak" 
  63. End if
  64. oldDB = Server.MapPath(Replace(Replace(oldDB,"//","/"),"//","/"))
  65. bakDB = Server.MapPath(Replace(Replace(bakDB,"//","/"),"//","/"))
  66.     FSO.CopyFile oldDB, bakDB , true 
  67.     set FSO = nothing  
  68. if  Request.QueryString("Sub") = "MF" then
  69. tmp_getPath = G_VIRTUAL_ROOT_DIR&"/Foosun_Data/DataBase_BackUp/MF_"&tmp_GetRamCode&".bak"
  70. Else
  71. tmp_getPath = G_VIRTUAL_ROOT_DIR&"/Foosun_Data/DataBase_BackUp/ME_"&tmp_GetRamCode&".bak"
  72. End if
  73. Call MF_Insert_oper_Log("数据库维护","备份数据库,名称:"& bakDB &"",now,session("admin_name"),"MF")
  74. strShowErr = "<li>备份成功.</li><li>文件名:"& bakDB &"</li><li>请及时下载<a href="""&Replace(tmp_getPath,"//","/")&"""><b><<下载>></b></a>&nbsp;&nbsp;下载结束后请<a href=""DataManage.asp?Action=DelData&File="& Replace(tmp_getPath,"//","/") &"""><b><<删除>></b></a></li>"
  75. Response.Redirect("Success.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=")
  76. Response.end
  77. End if
  78. if Request("Action")="DelData" then
  79. if not MF_Check_Pop_TF("MF016") then Err_Show
  80.     Set FSO = Server.CreateObject(G_FS_FSO) 
  81.     FSO.DeleteFile Server.MapPath(Request.QueryString("File")) 
  82. strShowErr = "<li>删除成功.</li>"
  83. Response.Redirect("Success.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=DataManage.asp?Type=bak")
  84. Response.end
  85. End if
  86. %>
  87. <html xmlns="http://www.w3.org/1999/xhtml">
  88. <HEAD>
  89. <TITLE>FoosunCMS</TITLE>
  90. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
  91. </HEAD>
  92. <script language="JavaScript" src="../FS_Inc/PublicJS.js" type="text/JavaScript"></script>
  93. <link href="images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
  94. <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll=yes>
  95. <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
  96.   <tr class="xingmu">
  97.     <td class="xingmu"><a href="#" onmouseover="this.T_BGCOLOR='#404040';this.T_FONTCOLOR='#FFFFFF';return escape('<div align='center'>FoosunCMS4.0<br> Code by Simpwind.Xie <BR>Copyright (c) 2006 Foosun Inc</div>')" class="sd"><strong>数据库维护</strong></a>
  98.       </td>
  99.   </tr>
  100.   <tr class="hback">
  101.     <td><a href="DataManage.asp">首页</a><%if G_IS_SQL_DB = 0 then%>&nbsp;|&nbsp;<a href="DataManage.asp?Type=fix">数据库压缩</a>&nbsp;|&nbsp;<a href="DataManage.asp?Type=bak">数据库备份</a><%end if%>&nbsp;|&nbsp;<a href="DataManage.asp?Type=SQLexe">SQL语句查询操作</a></td>
  102.   </tr>
  103. </table>
  104. <%
  105. Dim tmp_type
  106. tmp_type = Trim(Request.QueryString("Type"))
  107. select Case tmp_type 
  108. Case "fix"
  109. if not MF_Check_Pop_TF("MF015") then Err_Show
  110. Call fixs()
  111. Case "bak"
  112. if not MF_Check_Pop_TF("MF016") then Err_Show
  113. Call Bak()
  114. Case "SQLexe"
  115. if not MF_Check_Pop_TF("MF017") then Err_Show
  116. Call SQLexe()
  117. Case else
  118. if not MF_Check_Pop_TF("MF017") then Err_Show
  119. Call SQLexe()
  120. End Select
  121. Sub fixs()
  122. %>
  123. <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
  124.   <tr class="xingmu"> 
  125.     <td class="xingmu">数据库压缩</td>
  126.   </tr>
  127.   <tr> 
  128.     <td height="52" class="hback"> <input type="button" name="Submit" value="开始压缩主数据库" onClick="window.location.href='DataManage.asp?Action=Fix&Type=fix&Sub=MF'"> 
  129.       <input type="button" name="Submit2" value="开始压缩会员数据库" onClick="window.location.href='DataManage.asp?Action=Fix&Type=fix&Sub=ME'"></td>
  130.   </tr>
  131.   <tr>
  132.     <td height="22" class="hback">说明:压缩前请备份您的数据库。以防止万一</td>
  133.   </tr>
  134. </table>
  135. <%End Sub%>
  136. <%Sub bak()%>
  137. <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
  138.   <tr class="xingmu"> 
  139.     <td class="xingmu">数据库备份</td>
  140.   </tr>
  141.   <tr> 
  142.     <td height="51" class="hback"> <input type="button" name="Submit22" value="开始备份主数据库" onClick="window.location.href='DataManage.asp?Action=bak&Type=fix&Sub=MF'"> 
  143.       <input type="button" name="Submit222" value="开始备份会员数据库" onClick="window.location.href='DataManage.asp?Action=bak&Type=bak&Sub=ME'"></td>
  144.   </tr>
  145.   <tr>
  146.     <td height="31" class="hback">说明:请在备份完成后,及时删除备份文件,以防止别人恶意下载数据库文件</td>
  147.   </tr>
  148. </table>
  149. <%End sub%>
  150. <%Sub SQLexe()%>
  151. <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
  152.   <form name="form1" method="post" action=""><tr class="xingmu"> 
  153.     <td class="xingmu">数据库SQL语句查询操作</td>
  154.   </tr>
  155.   <tr> 
  156.       <td class="hback">说明:注:一次只能执行一条Sql语句。如果你对SQL不熟悉,请尽量不要使用。否则一旦出错,将是致命的。<br>
  157.         建议使用查询语句.如:select count(id) From FS_MF_Admin order by id desc,尽量不要使用delete,update等命令</td>
  158.   </tr>
  159.   <tr> 
  160.     <td class="hback"><textarea name="Content" rows="5" wrap="OFF" style="width:100%;"></textarea></td>
  161.   </tr>
  162.   <tr> 
  163.     <td class="hback"><iframe id="ResultShowFrame" scrolling="yes" src="DataSqlResult.asp" style="width:100%;" frameborder=1></iframe></td>
  164.   </tr>
  165.   <tr>
  166.     <td class="hback">
  167.         <input type="button" name="Submit3" value="执行SQL语句" onClick="{if(confirm('您确认执行SQL语句吗?n一旦SQL执行了删除或者操作命令,结果将是致命的!!!')){ExecuteSql();return true;}return false;}">
  168.         <input name="Result" type="hidden" id="Result" value="Submit">
  169.       </td>
  170.   </tr></form>
  171. </table>
  172. <%End sub%>
  173. <script language="javascript" type="text/javascript" src="../../FS_Inc/wz_tooltip.js"></script>
  174. </body>
  175. </html>
  176. <%
  177. Set Conn = Nothing
  178. %><script language="JavaScript">
  179. function ExecuteSql()
  180. {
  181. var FormObj=frames["ResultShowFrame"].document.ExecuteForm;
  182. if (document.all.Content.value!='')
  183. {
  184. FormObj.Sql.value=document.all.Content.value;
  185. FormObj.Result.value='Submit';
  186. FormObj.submit();
  187. FormObj.Result.value='';
  188. }
  189. else alert('请填写SQL语句');
  190. }
  191. </script>