<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
server.ScriptTimeout =2400
If session("SqlAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf Instr(1, Request("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf not IsNumeric(Request("backupid"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf Instr(1, session("username"), "'", 1)>0 then
	ef=True
	ec="非法用户名！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Sql where id='"&session("SqlAUID")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="不存在的虚拟主机ID！"
end if
end if

if not ef then
	Set dsHostpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_SQLProductlist where SQLtype='"&dsph("SQLtype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHostpdlist.Open Sql,conn,1,1
if dsHostpdlist.Eof then
	ef=True
	ec="产品不存在！"
end if
end if

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerSQLlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
end if
end if

if not ef then

if isnull(dsph("randir")) then
Randomize
id=Int((99900000 - 0 + 1) * Rnd + 0)
dsph("randir")=id
dsph.update
end if

URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
userid=dsserver ("admname")
pwd=dsserver("admpass")
homedir=dsserver("homedir")
ip=dsserver("ip")
port=dsserver("port")
sqlname=dsph("sqlname")
sqlpassword=dsph("sqlpassword")

'backuptime=year(now)&month(now)&day(now)&hour(now)&Minute(now)&Second(now)
backuptime=Request("backupid")


dim softtype,MySQLver,MSSQLver
softtype=dsserver("softtype")
MySQLver=dsserver("MySQLver")
MSSQLver=dsserver("MSSQLver")


if Request("Submit")="截断数据库日志" then
if softtype="SQL2000" then
userid=sqlname
pwd=sqlpassword

if dsserver("softtype")="SQL2000" and dsserver("MSSQLver")="2000" then softtype="SQL2000"
if dsserver("softtype")="SQL2000" and dsserver("MSSQLver")="2005" then softtype="SQL2005"
if dsserver("softtype")="SQL2000" and dsserver("MSSQLver")="2008" then softtype="SQL2008"
if dsserver("softtype")="SQL2000" and dsserver("MSSQLver")="2012" then softtype="SQL2012"
if dsserver("softtype")="SQL2000" and dsserver("MSSQLver")="2014" then softtype="SQL2014"
if dsserver("softtype")="SQL2000" and dsserver("MSSQLver")="2016" then softtype="SQL2016"

ret2="<font color=blue><b>"&SqlDelLog(URL,FreeHostsharekey,userid,pwd,sqlname,backupdir)&"</b></font>"
end if
end if

end if

if not ef then
%>
<!--#include virtual="/inc-freehost-function/template-sqladm-top.asp"-->
　数据库自助管理


<br>
<br>
<br>
<%if softtype="SQL2000" then%>
<%end if%>
<font color=red><%=ret2%></font><br><br><br>

　<a href="selfsqlmodify.asp?id=<%=Request("id")%>"><font color="#000000">[返回上一页]</font></a><br><br>
<!--#include virtual="/inc-freehost-function/template-sqladm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end If


Function SqlDelLog(URL,FreeHostsharekey,userid,pwd,sqlname,backupdir)
  Dim returnstr,body
sql="USE "&sqlname&" BACKUP LOG "&sqlname&" with NO_LOG;DBCC SHRINKDATABASE ("&sqlname&")"
If  softtype="SQL2008" Or  softtype="SQL2012" Or  softtype="SQL2014" Or  softtype="SQL2016" Then
sql="USE [master] ALTER DATABASE "&sqlname&" SET RECOVERY SIMPLE WITH NO_WAIT;ALTER DATABASE "&sqlname&" SET RECOVERY SIMPLE;USE "&sqlname&" DBCC SHRINKFILE (["&sqlname&"_Log] , 11, TRUNCATEONLY);USE [master] ALTER DATABASE "&sqlname&" SET RECOVERY FULL WITH NO_WAIT;ALTER DATABASE "&sqlname&" SET RECOVERY FULL;"
End if
'response.write sql
body=URLEncoding("userid="&userid&"&pwd="&pwd&"&sql="&sql)
Set MaintoCSCom=Server.CreateObject("www.7i24.com")
RetInfo=MaintoCSCom.DOHTTPSSL(Url&"?SQLACTION",FreeHostsharekey,body,FreeHost_t1,FreeHost_t2,FreeHost_t3,FreeHost_t4)
Set MaintoCSCom =Nothing
SqlDelLog=RetInfo

End Function


%>