<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf Request.Form ("ApiPass")="" or RegExpTest("[^A-Za-z0-9]",Request.Form ("ApiPass")) Then
	ef=True
	ec="会员名没有写/或会员名中有非法字符！"
ElseIf Request("apiip1")<>"" and not IsNumeric(replace(Request("apiip1"),".","")) then
	ef=True
	ec="无效的IP地址1！"
ElseIf Request("apiip2")<>"" and not IsNumeric(replace(Request("apiip2"),".","")) then
	ef=True
	ec="无效的IP地址2！"
ElseIf Request("apiip3")<>"" and not IsNumeric(replace(Request("apiip3"),".","")) then
	ef=True
	ec="无效的IP地址3！"
ElseIf Request("apiip4")<>"" and not IsNumeric(replace(Request("apiip4"),".","")) then
	ef=True
	ec="无效的IP地址4！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&session("agentusername")&"'"
		dsagent.Open Sql,conn,1,3
If dsagent.Eof Then
	ef=True
	ec="代理不存在!"
end if
end if

if not ef then
if isnull(dsagent("canuseapi"))  then
	ef=True
	ec="管理员没有授权您有API模式的权限，请联系管理员开通!"
end if
end if

if not ef then
dsagent("ApiPass")=Trim(Request.Form ("ApiPass"))
If IsNull(dsagent("apiip1")) Then dsagent("apiip1")=""
If IsNull(dsagent("apiip2")) Then dsagent("apiip2")=""
If IsNull(dsagent("apiip3")) Then dsagent("apiip3")=""
If IsNull(dsagent("apiip4")) Then dsagent("apiip4")=""

If Request.Form ("apiip1")<>"" Then dsagent("apiip1")=Trim(Request.Form ("apiip1"))
If Request.Form ("apiip2")<>"" Then dsagent("apiip2")=Trim(Request.Form ("apiip2"))
If Request.Form ("apiip3")<>"" Then dsagent("apiip3")=Trim(Request.Form ("apiip3"))
If Request.Form ("apiip4")<>"" Then dsagent("apiip4")=Trim(Request.Form ("apiip4"))

dsagent.update
dsagent.close
set dsagent=nothing
conn.Close 
set conn=nothing
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%>
　API密码
<%=htmlwrite("html6")%>
<br>

设置成功！

<%=htmlwrite("html7")%>
<%
end if
if ef then%>
<%=ec%>
<%end if%>
