DataManage.asp
资源名称:eat.rar [点击查看]
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:8k
源码类别:
数据库编程
开发平台:
ASP/ASPX
- <% Option Explicit %>
- <!--#include file="../FS_Inc/Const.asp" -->
- <!--#include file="../FS_InterFace/MF_Function.asp" -->
- <!--#include file="../FS_Inc/Function.asp" -->
- <!--#include file="../FS_Inc/Func_page.asp" -->
- <%'Copyright (c) 2006 Foosun Inc. Code by Simpwind.Xie
- Response.Buffer = True
- Response.Expires = -1
- Response.ExpiresAbsolute = Now() - 1
- Response.Expires = 0
- Response.CacheControl = "no-cache"
- Dim Conn,strShowErr,tmp_getPath
- MF_Default_Conn
- MF_Session_TF
- if not MF_Check_Pop_TF("MF_DataFix") then Err_Show
- if Request("Action")="Fix" then
- if not MF_Check_Pop_TF("MF015") then Err_Show
- On Error Resume Next
- Dim oldDB,bakDB,newDB,FSO,Engine,EditFile,prov
- if Request.QueryString("Sub") = "MF" then
- oldDB = "../"&G_DATABASE_CONN_STR
- bakDB = "../Foosun_Data/DataBase_BackUp/Foosun_Data.bak"
- newDB = "../Foosun_Data/Foosun_Data_comp.mdb"
- Else
- oldDB = "../"&G_User_DATABASE_CONN_STR
- bakDB = "../Foosun_Data/DataBase_BackUp/FS_ME.bak"
- newDB = "../Foosun_Data/FS_ME_comp.mdb"
- End if
- oldDB = Server.MapPath(oldDB)
- bakDB = Server.MapPath(bakDB)
- newDB = Server.MapPath(newDB)
- Set FSO = Server.CreateObject(G_FS_FSO)
- ' back up database
- FSO.CopyFile oldDB, bakDB , true
- ' compact database
- Set Engine = Server.CreateObject("JRO.JetEngine")
- prov = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
- Engine.CompactDatabase prov & OldDB, prov & newDB
- set Engine = nothing
- ' delete original database
- FSO.DeleteFile oldDB
- ' Move (rename) compacted database
- FSO.MoveFile newDB, oldDB
- set FSO = nothing
- Call MF_Insert_oper_Log("数据库维护","压缩数据库",now,session("admin_name"),"MF")
- strShowErr = "<li>数据库压缩成功.</li>"
- Response.Redirect("Success.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=")
- Response.end
- End if
- if Request("Action")="bak" then
- if not MF_Check_Pop_TF("MF016") then Err_Show
- Randomize
- Dim tmp_GetRamCode
- tmp_GetRamCode = GetRamCode(16)
- Set FSO = Server.CreateObject(G_FS_FSO)
- if FSO.FolderExists(Server.MapPath("..Foosun_DataDataBase_BackUp"))=false then FSO.createFolder Server.MapPath("..Foosun_DataDataBase_BackUp")
- if Request.QueryString("Sub") = "MF" then
- oldDB = "../"&G_DATABASE_CONN_STR
- bakDB = "../Foosun_Data/DataBase_BackUp/MF_"&tmp_GetRamCode&".bak"
- Else
- oldDB = "../"&G_User_DATABASE_CONN_STR
- bakDB = "../Foosun_Data/DataBase_BackUp/ME_"&tmp_GetRamCode&".bak"
- End if
- oldDB = Server.MapPath(Replace(Replace(oldDB,"//","/"),"//","/"))
- bakDB = Server.MapPath(Replace(Replace(bakDB,"//","/"),"//","/"))
- FSO.CopyFile oldDB, bakDB , true
- set FSO = nothing
- if Request.QueryString("Sub") = "MF" then
- tmp_getPath = G_VIRTUAL_ROOT_DIR&"/Foosun_Data/DataBase_BackUp/MF_"&tmp_GetRamCode&".bak"
- Else
- tmp_getPath = G_VIRTUAL_ROOT_DIR&"/Foosun_Data/DataBase_BackUp/ME_"&tmp_GetRamCode&".bak"
- End if
- Call MF_Insert_oper_Log("数据库维护","备份数据库,名称:"& bakDB &"",now,session("admin_name"),"MF")
- strShowErr = "<li>备份成功.</li><li>文件名:"& bakDB &"</li><li>请及时下载<a href="""&Replace(tmp_getPath,"//","/")&"""><b><<下载>></b></a> 下载结束后请<a href=""DataManage.asp?Action=DelData&File="& Replace(tmp_getPath,"//","/") &"""><b><<删除>></b></a></li>"
- Response.Redirect("Success.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=")
- Response.end
- End if
- if Request("Action")="DelData" then
- if not MF_Check_Pop_TF("MF016") then Err_Show
- Set FSO = Server.CreateObject(G_FS_FSO)
- FSO.DeleteFile Server.MapPath(Request.QueryString("File"))
- strShowErr = "<li>删除成功.</li>"
- Response.Redirect("Success.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=DataManage.asp?Type=bak")
- Response.end
- End if
- %>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <HEAD>
- <TITLE>FoosunCMS</TITLE>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
- </HEAD>
- <script language="JavaScript" src="../FS_Inc/PublicJS.js" type="text/JavaScript"></script>
- <link href="images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
- <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll=yes>
- <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
- <tr class="xingmu">
- <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>
- </td>
- </tr>
- <tr class="hback">
- <td><a href="DataManage.asp">首页</a><%if G_IS_SQL_DB = 0 then%> | <a href="DataManage.asp?Type=fix">数据库压缩</a> | <a href="DataManage.asp?Type=bak">数据库备份</a><%end if%> | <a href="DataManage.asp?Type=SQLexe">SQL语句查询操作</a></td>
- </tr>
- </table>
- <%
- Dim tmp_type
- tmp_type = Trim(Request.QueryString("Type"))
- select Case tmp_type
- Case "fix"
- if not MF_Check_Pop_TF("MF015") then Err_Show
- Call fixs()
- Case "bak"
- if not MF_Check_Pop_TF("MF016") then Err_Show
- Call Bak()
- Case "SQLexe"
- if not MF_Check_Pop_TF("MF017") then Err_Show
- Call SQLexe()
- Case else
- if not MF_Check_Pop_TF("MF017") then Err_Show
- Call SQLexe()
- End Select
- Sub fixs()
- %>
- <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
- <tr class="xingmu">
- <td class="xingmu">数据库压缩</td>
- </tr>
- <tr>
- <td height="52" class="hback"> <input type="button" name="Submit" value="开始压缩主数据库" onClick="window.location.href='DataManage.asp?Action=Fix&Type=fix&Sub=MF'">
- <input type="button" name="Submit2" value="开始压缩会员数据库" onClick="window.location.href='DataManage.asp?Action=Fix&Type=fix&Sub=ME'"></td>
- </tr>
- <tr>
- <td height="22" class="hback">说明:压缩前请备份您的数据库。以防止万一</td>
- </tr>
- </table>
- <%End Sub%>
- <%Sub bak()%>
- <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
- <tr class="xingmu">
- <td class="xingmu">数据库备份</td>
- </tr>
- <tr>
- <td height="51" class="hback"> <input type="button" name="Submit22" value="开始备份主数据库" onClick="window.location.href='DataManage.asp?Action=bak&Type=fix&Sub=MF'">
- <input type="button" name="Submit222" value="开始备份会员数据库" onClick="window.location.href='DataManage.asp?Action=bak&Type=bak&Sub=ME'"></td>
- </tr>
- <tr>
- <td height="31" class="hback">说明:请在备份完成后,及时删除备份文件,以防止别人恶意下载数据库文件</td>
- </tr>
- </table>
- <%End sub%>
- <%Sub SQLexe()%>
- <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" class="table">
- <form name="form1" method="post" action=""><tr class="xingmu">
- <td class="xingmu">数据库SQL语句查询操作</td>
- </tr>
- <tr>
- <td class="hback">说明:注:一次只能执行一条Sql语句。如果你对SQL不熟悉,请尽量不要使用。否则一旦出错,将是致命的。<br>
- 建议使用查询语句.如:select count(id) From FS_MF_Admin order by id desc,尽量不要使用delete,update等命令</td>
- </tr>
- <tr>
- <td class="hback"><textarea name="Content" rows="5" wrap="OFF" style="width:100%;"></textarea></td>
- </tr>
- <tr>
- <td class="hback"><iframe id="ResultShowFrame" scrolling="yes" src="DataSqlResult.asp" style="width:100%;" frameborder=1></iframe></td>
- </tr>
- <tr>
- <td class="hback">
- <input type="button" name="Submit3" value="执行SQL语句" onClick="{if(confirm('您确认执行SQL语句吗?n一旦SQL执行了删除或者操作命令,结果将是致命的!!!')){ExecuteSql();return true;}return false;}">
- <input name="Result" type="hidden" id="Result" value="Submit">
- </td>
- </tr></form>
- </table>
- <%End sub%>
- <script language="javascript" type="text/javascript" src="../../FS_Inc/wz_tooltip.js"></script>
- </body>
- </html>
- <%
- Set Conn = Nothing
- %><script language="JavaScript">
- function ExecuteSql()
- {
- var FormObj=frames["ResultShowFrame"].document.ExecuteForm;
- if (document.all.Content.value!='')
- {
- FormObj.Sql.value=document.all.Content.value;
- FormObj.Result.value='Submit';
- FormObj.submit();
- FormObj.Result.value='';
- }
- else alert('请填写SQL语句');
- }
- </script>