<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
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 Instr(1, session("username"), "'", 1)>0 then
	ef=True
	ec="非法用户名！"
ElseIf Request("ip1")<>"" And not IsNumeric(replace(Request("ip1"),".","")) Then
	ef=True
	ec="ip1不对"
ElseIf Request("ip2")<>"" And not IsNumeric(replace(Request("ip2"),".","")) Then
	ef=True
	ec="ip2不对"
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


dim softtype,MySQLver,MSSQLver
softtype=dsserver("softtype")
MySQLver=dsserver("MySQLver")
MSSQLver=dsserver("MSSQLver")
FreeHostsharekey=dsserver("FreeHostsharekey")
URL=dsserver("site")
opport=dsserver("port")
userid=dsserver ("admname")
pwd=dsserver("admpass")
sqlname=dsph("sqlname")
sqlpassword=dsph("sqlpassword")

op=2
ret=PauseSQL(URL,FreeHostsharekey,userid,pwd,sqlname,sqlpassword,op)
ret=ret&"删除旧库成功"
homedir=dsserver("homedir")
username=dsph("ftpname")
ftpdir=homedir&"\backup\"&sqlname&"_"&dsph("randir")
varcon=" /E /T /R "&username
todeluser=1
delacl=1
todelftp=1
'if not isnull(dsph("ftpendtime")) then
'ret = ret&"删除这个库的备份FTP："&DelFTP(URL,FreeHostsharekey,username,ftpdir,varcon,todeluser,delacl,todelftp)
'end if
'if not isnull(dsph("randir")) then
'ret = ret&"删除这个库的备份目录："&DelDir(URL,FreeHostsharekey,ftpdir)
'end if

for iipsec=1 to 2
'response.write dsph("ip"&iipsec)&iipsec&"<br>"
if not isnull(dsph("ip"&iipsec)) then
	Set dsphip = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Sql where (ip1='"&dsph("ip"&iipsec)&"' or ip2='"&dsph("ip"&iipsec)&"') and id<>'"&dsph ("id")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsphip.Open Sql,conn,1,3
if dsphip.Eof then
'opvar="del"
'ret=ret&OPIpsec(URL,FreeHostsharekey,opvar,dsph("ip"&iipsec),opport)
'dsph("ip"&iipsec)=null
end if
dsphip.close
end if
next

FreeHost_clientlog conn,dsph ("username"),dsph ("username"),"用户自己在用户区清空数据库","数据库产品",dsph ("id"),"删除","","",ret
'response.write "<br>删除库："&ret
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerSqllist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
'重开


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

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

homedir=dsserver("homedir")
ip=dsserver("ip")
port=dsserver("port")
userspacelimt=dsph("userspacelimt")
logspacelimt=dsph("logspacelimt")
sqlname=dsph("sqlname")
sqlpassword=dsph("sqlpassword")
if softtype="SQL2000" then
retsql=SqlAdd(URL,FreeHostsharekey,userid,pwd,homedir,userspacelimt,logspacelimt,sqlname,sqlpassword)
else
retsql=SqlAddmysql(URL,FreeHostsharekey,userid,pwd,homedir,userspacelimt,logspacelimt,sqlname,sqlpassword)
end if
FreeHost_oplog dsph ("username"),"信息","清空后自动开通,数据库名:"&sqlname&" 返回信息："&retsql
'response.write "<br><br><br>开通库："&retsql
'outtemp=ret&retsql
outtemp=retsql



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


<br>

<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR>
      <TD height="35" align="center" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">清空数据库：</font></TD>
      </TR>
    <TR>
      <TD height="35" align="center" vAlign=middle bgColor=#EEEEEE>
	   
		<%=outtemp%>
		</TD>
      </TR>
  </TBODY>
</TABLE>
<br>
<br>
<br>


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