<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
server.ScriptTimeout =7200
serverlistid=0 '要设置为随机密码的服务器编号
If IsNumeric(Request ("serverlistid")) And Request ("serverlistid")<>""  Then serverlistid=Request ("serverlistid")
onlychangesamepass=false
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("canadmhost")="" And session("canadmhostadd")="" And session("canadmhostset")="" And session("canadmhostch")="" And session("canadmhostmidsub")="" And session("canadmhostmiddomain")="" And session("canadmhostmidcpu")="" And session("canadmhostmidrepay")="" And session("canadmhostdel")="" And session("canadmhostoth")="" 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_Host where ServerlistID = '"&serverlistid&"' order by id desc"
If onlychangesamepass=True Then Sql="Select * from FreeHost.FreeHost_Product_Host where ServerlistID = '"&serverlistid&"' and (ftpname=Ftppassword or Ftppassword='abc123' or Ftppassword='123456' or Ftppassword='888888')  order by id desc"
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="此类内容不存在！"
end if
end If


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

if not ef Then

response.write "自动改FTP密码开始...."
while not dsph.eof
If Left(dsph("Ftppassword"),1)<>Day(now) then
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsph("ftpname")
ostype=dsserver("ostype")
If ostype="windows" then
Response.Write "<br>处理ftp名:"&username&" "'&temp

Randomize
key=Cstr(Int((99999999 - 100000 + 1) * Rnd + 100000))
password=Day(now)&Left(md5(now&key),12)

ret=ResetPassword(URL,FreeHostsharekey,username,password)
response.write ret
dsph("Ftppassword")=password
dsph.update
'dsph.close

	Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where allowsubbyid='"&dsph("id")&"'"
	dsphsub.Open Sql,conn,1,3
while not dsphsub.Eof
IISID=dsphsub("IISID")
temp=ModifyUserSub(URL,FreeHostsharekey,username,password,IISID,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)
response.write "<br>　　处理此FTP名下子目录站:"&temp
dsphsub("Ftppassword")=password
dsphsub.update
dsphsub.movenext
wend
dsphsub.close


End If
End if
dsph.movenext
wend
dsph.close
response.write "<br>完成"
end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>