<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%server.ScriptTimeout =30
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("cansetserver")="" Then
	ef=True
	ec="您没有此操作的权限。"
end if

ID=request.QueryString("id")

If ID="" then
	ef=True
	ec="ID没有提供。"
end if

if not ef then
on error resume next
dim softtype
Response.Write Sqltest(ID)
if err.number<>0 then Response.Write "出现错误："&err.description
if instr(err.description,"could not be resolved")>0 then%>
在主控服务器上，无法解析受控域名：<a href="<%=dsHostserver("site")%>"><%=dsHostserver("site")%></a>
<%end if%>
<br><br>
如果发生错误，请参考：<br>
<br>
<a href="http://sys.7i24.com/system/support/show.asp?id=107100944392" target="_blank">http://sys.7i24.com/system/support/show.asp?id=107100944392</a><br>
<br>
<%
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

'response.write returnstr&"testddd"
if instr(returnstr,"授权非法")>0 then 
response.write returnstr
response.end
end If
if instr(returnstr,"未发现数据源")>0 and instr(returnstr,"ODBC")>0 then 
response.write "您的服务器没有安装MyODBC，请您使用受控用户名密码先登陆www.7i24.com下载安装，如果您是win2008或2012操作系统，请将iis运行在32位，请参考http://sys.7i24.com/system/support/show.asp?id=20110408120131，出错信息为："&returnstr
response.end
end If
if instr(returnstr,"Can't connect to MySQL")>0 and instr(returnstr,"[MySQL]")>0 then 
response.write "您的这台服务器上的Mysql数据库没有启动，请您在服务器上，管理工具，服务管理中，找到Mysql，启动它，也可以直接重启操作系统试试，出错信息为："&returnstr
response.end
end If
if instr(returnstr,"Access denied for user") then 
response.write "您输入的root用户的密码不对,请修改后重试，出错信息为："&returnstr
response.end
end If
if instr(returnstr,"[MySQL]")>0 then 
response.write returnstr
response.end
end If
softtype=Sqlserver("softtype")
MySQLver=Sqlserver("MySQLver")
MSSQLver=Sqlserver("MSSQLver")
if softtype="SQL2000" then
response.write "尝试建立一个名为t7i24密码为123456的数据库："
response.write SqlAdd(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"),Sqlserver("homedir"),"10","10","t7i24","123456")
response.write "尝试马上删除这个数据库："
response.write PauseSQL(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"),"t7i24","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 "尝试建立一个名为t7i24密码为123456的数据库："
response.write SqlAddmysql(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"),Sqlserver("homedir"),"10","10","t7i24","123456")
response.write "尝试马上删除这个数据库："
response.write PauseSQL(Sqlserver("site"),Sqlserver("FreeHostsharekey"),Sqlserver ("admname"),Sqlserver("admpass"),"t7i24","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 &" <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")

'response.write "<br><font color=blue>del用目录：</font>"&DelDir(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
%>