<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%server.ScriptTimeout =20
If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("canmyserver")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="ID应该是数字！"
ElseIf Request("id")=""  Then
	ef=True
	ec="ID应该是数字！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsHostserver = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Serversqllist where id='"&Request("id")&"' and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"')"
		dsHostserver.Open Sql,conn,1,1
If dsHostserver.Eof Then
	ef=True
	ec="服务器不存在。"
end if
end if

if not ef then
on error resume next
dim softtype
Response.Write Sqltest(Request("id"))
end if
if ef then
Response.Redirect "e.asp?e="&ec
end if

Function Sqltest(ID)
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
Set Sqlserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serversqllist where id="&ID
	Sqlserver.Open Sql,conn,1,1
  Dim returnstr
if not Sqlserver.eof then
sql=""
body=URLEncoding("userid="&Sqlserver("admname")&"&pwd="&Sqlserver("admpass")&"&sql="&sql)
Set MaintoCSCom=Server.CreateObject("www.7i24.com")
if Sqlserver("softtype")="SQL2000" Then
RetInfo=MaintoCSCom.DOHTTPSSL(Sqlserver("site")&"?SQLACTION",Sqlserver("FreeHostsharekey"),body,FreeHost_t1,FreeHost_t2,FreeHost_t3,FreeHost_t4)
Else
RetInfo=MaintoCSCom.DOHTTPSSL(Sqlserver("site")&"?SQLACTIONmysql",Sqlserver("FreeHostsharekey"),body,FreeHost_t1,FreeHost_t2,FreeHost_t3,FreeHost_t4)
end if
returnstr = RetInfo
Set MaintoCSCom =Nothing

if instr(returnstr,"授权非法")>0 or instr(returnstr,"[MySQL]")>0 then 
response.write returnstr
response.end
end if
softtype=Sqlserver("softtype")
if softtype="SQL2000" then
response.write "尝试建立一个名为test7i24密码为123456的数据库："
response.write SqlAdd(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"),Sqlserver("homedir"),"10","10","test7i24","123456")
response.write "尝试马上删除这个数据库："
response.write PauseSQL(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"),"test7i24","123456",2)
Else
If MySQLver<5.5 then
response.write "尝试将root用户更改成兼容旧密码的模式："
response.write ChangeRootmysql(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"))
Else
response.write "尝试将root用户恢复成新的5.5以上密码的模式："
response.write ChangeRootmysqlNew(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"))
End If
response.write "尝试建立一个名为test7i24密码为123456的数据库："
response.write SqlAddmysql(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"),Sqlserver("homedir"),"10","10","test7i24","123456")
response.write "尝试马上删除这个数据库："
response.write PauseSQL(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"),"test7i24","123456",2)
end if

if Sqlserver("softtype")="MySQL" then
getsize=ShowDirSize (Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver("homedir"))
if instr(getsize,"NOT IMPLEMENTED")>1 then 
returnstr = "请升级受控端到3.0版" 
else
if instr(getsize,"出错")>1 then 
returnstr = returnstr &" 数据库放置的目录设置不正确：" &Sqlserver("homedir")
else
getsize=GETvalue(getsize,";目录大小为：",";FreeHostEnd")
returnstr = returnstr &"所有数据库的大小："& getsize
getsize=int(getsize/1024/1024)
returnstr = returnstr &"("& getsize&"M)"
end if 
end if

end if


'if Sqlserver("softtype")="MySQL" then
getsize=ShowDirSize (Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver("homedir"))
if instr(getsize,"NOT IMPLEMENTED")>1 then 
returnstr = "请升级受控端到3.0版" 
else
if instr(getsize,"出错")>1 then 
returnstr = returnstr &" <font color=red>数据库放置的目录设置不正确，注意mysql及sql2000的data目录是您在安装Mysql及sql2000时设置的，不是在自检这儿设置，错误的目录名为：" &Sqlserver("homedir")&"<br>"
else
getsize=GETvalue(getsize,";目录大小为：",";FreeHostEnd")
returnstr = returnstr &"所有数据库的占用硬盘大小："& getsize
getsize=int(getsize/1024/1024)
returnstr = returnstr &"("& getsize&"M)"
end if 
end if
'end if


response.write "<br><font color=blue>建立备份专用目录：</font>"&CreateDir(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver("homedir")&"\backup")

else
	returnstr = "不存在的服务器！"
end if
Sqlserver.close
set Sqlserver=nothing
conn.close
set conn=nothing
	Sqltest = returnstr
End Function

Function ChangeRootmysql(URL,FreeHostsharekey,userid,pwd)'2.0增加
sql="set password for "&userid&"@'localhost'=old_password('"&pwd&"');"
if mysqlis415 then sql="set password for "&userid&"@'"&server.URLEncode ("%")&"'=old_password('"&pwd&"');"
body=URLEncoding("userid="&userid&"&pwd="&pwd&"&sql="&sql)
Set MaintoCSCom=Server.CreateObject("www.7i24.com")
body=URLEncoding("Poolname="&Poolname)
RetInfo=MaintoCSCom.DOHTTPSSL(Url&"?SQLACTIONmysql",FreeHostsharekey,body,FreeHost_t1,FreeHost_t2,FreeHost_t3,FreeHost_t4)
Set MaintoCSCom =Nothing
ChangeRootmysql=RetInfo

End Function
Function ChangeRootmysqlNew(URL,FreeHostsharekey,userid,pwd)'2.0增加
sql="set password for "&userid&"@'localhost'=password('"&pwd&"');"
if mysqlis415 then sql="set password for "&userid&"@'"&server.URLEncode ("%")&"'=old_password('"&pwd&"');"
body=URLEncoding("userid="&userid&"&pwd="&pwd&"&sql="&sql)
Set MaintoCSCom=Server.CreateObject("www.7i24.com")
RetInfo=MaintoCSCom.DOHTTPSSL(Url&"?SQLACTIONmysql",FreeHostsharekey,body,FreeHost_t1,FreeHost_t2,FreeHost_t3,FreeHost_t4)
Set MaintoCSCom =Nothing
ChangeRootmysqlNew=RetInfo
End Function
%>