<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("HOSTAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf Instr(1, Request.Form ("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request.Form ("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf Request.Form ("op2")<>"" And Request.Form ("newpassword")="" Then
	ef=True
	ec="新密码为空！"
ElseIf Request.Form ("op2")<>"" And Request.Form ("newpassword")<>Request.Form ("renewpassword") Then
	ef=True
	ec="密码不一致！"
ElseIf Request.Form ("op2")<>"" And (RegExpTest("[^A-Za-z0-9]",Request.Form ("newpassword"))  or len(Request.Form ("newpassword"))<11 or len(Request.Form ("newpassword"))>14) Then
	ef=True
	ec="FTP密码不符合要求,密码只能是字母与数字组成,而且,密码长度不能小于10位,也不能大于14位！"
ElseIf Request.Form ("op2")<>"" And IsNumeric(Request.Form ("newpassword"))  Then
	ef=True
	ec="FTP密码最少必须有一个字母！"
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 id='"&session("HOSTAUID")&"'"
			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 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
if Request.Form ("op2")<>"" And dsph("ftpname")=Request.Form ("newpassword") then
	ef=True
	ec="FTP密码不能和FTP名一样！"
end if
end if

if not ef then
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsph("ftpname")


Randomize
ftpRkey=CLng((100000000 - 20 + 7850) * Rnd + 100)
Ftppassword=Ucase(Left(md5(now&ftpRkey),10))&right(md5(now&ftpRkey),4)'2010-8-5
password=Ftppassword

If Request.Form ("op2")<>"" Then password=Request.Form ("newpassword")

ostype=dsserver("ostype")'linux
%>

<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
　修改FTP密码

<%

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

	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where allowsubbyid='"&session("HOSTAUID")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
IISID=dsph("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 temp
dsph("Ftppassword")=password
dsph.update
dsph.movenext
wend
dsph.close

%><br><br>FTP密码已成功更改！新密码为：<%=password%><br><br>
　<a href="selfhostmodify.asp?id=<%=session("HOSTAUID")%>"><font color="#000000">[返回]</font></a>
<!--#include virtual="/inc-freehost-function/template-hostadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>