<%@ Language=VBScript %>
<%If Request.Form ("api")=6 Then session.Timeout=1%>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If Request.Form("username")="" and Request.Form("domain")="" Then
	ef=True
	ec="域名/用户名没有填写！"
End if

If Request.Form("password")="" and Request.Form("inipass")="" Then
	ef=True
	ec="密码没有填写！"
End if

If Request.Form("username")<>"" and RegExpTest("[^A-Za-z0-9--]",Request.Form ("username")) Then
	ef=True
	ec="用户名非法！"
End If

If not IsNumeric(Request.Form("id"))  Then
	ef=True
	ec="ID应该是数字！"
End If

If not ef Then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
End If

if not ef Then
OriDomain= Request.Form("domain")
If OriDomain<>"" then
 
OriDomain=ComX.idntoac_7i24_com(Cstr(OriDomain))
If OriDomain="" or RegExpTest("[^.A-Za-z0-9--]",OriDomain) Then
	ef=True
	ec="域名非法！"

End if
OriDomain=ComX.actoidc_7i24_com(Cstr(OriDomain))
Enddomaintypeid=GetDomaintype(OriDomain)
End if
End If

If Request.Form("username")="" then
If not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
  Set dsdom = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Domain where domain='"&OriDomain&"' and status='正常' order by id desc"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
outcon="非法字符！"
Response.End
end if
		dsdom.Open Sql,conn,1,1
If dsdom.Eof Then
		ef=True
		ec="域名不存在！"
end if
end if

If not ef then
If dsdom("inipass")<>Request.Form ("inipass") Then
		ef=True
		ec="密码出错了！"
end if
end if

Else'API登陆
'检查用户名密码

If not ef then
  Set dsreg = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&Request.Form ("username")&"'"
If Request.Form ("isagn")="yes" Then Sql="Select * from FreeHost.FreeHost_AGENT where username='"&Request.Form ("username")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
outcon="非法字符！"
Response.End
end if
		dsreg.Open Sql,conn,1,1
If dsreg.Eof Then
		ef=True
		ec="会员名不存在！"
end if
end If

If Request.Form ("isagn")="yes" Then '是代理

if not ef then
if md5(Request.Form ("password"))<>dsreg("password") then
		ef=True
		ec="密码不正确！"
else
session("username")=""
session("password")=""
session("AgnRunasUser")=False
haveclosehtml=dsreg("haveclosehtml")
end if
end if 
if not ef then
if dsreg("agenttype")="n" then
		ef=True
		ec="您的代理资格尚未被审批！"
end if
end If

if not ef then
If IsNull(dsreg("usermoney")) Then
		ef=True
		ec="此帐号金额为空,不允许登陆,请联系管理员处理！"
End if
end If

If Not ef Then
session("agentusername")=dsreg("username")
session("agentusername_A")=dsreg("username")
session("atspace")="代理区"
session("agentpassword")=dsreg("password")
session("agentpasswordORI")=Request.Form ("password")
session("agenttype")=dsreg("agenttype")
session("agentusermoney")=dsreg("usermoney")
session("agentdegree")=dsreg("agentdegree")
if dsreg("cannextagn")="y" then session("cannextagn")=dsreg("cannextagn")
if dsreg("canmyserver")="y" then session("canmyserver")=dsreg("canmyserver")
session("awstoadmin")=dsreg("awstoadmin")
End if


else'不是代理
if not ef then
if Request.Form ("password")<>dsreg("password") then
		ef=True
		ec="会员密码不正确！"
Else
'处理登陆............
    session("agentusername")=""
	session("admau")=""
	session("agentname")="n"'200-11-30修改bug加上的。

if Application("emailau")=true then
if dsreg("emailau")="n" then 
		ef=True
		ec="此帐号尚未激活，请查收邮箱，激活帐号！"
end if
end If
If Not ef then
session("username")=dsreg("username")
session("password")=dsreg("password")
session("usermoney")=dsreg("usermoney")
session("atspace")="用户区"
if session("agentname")=session("username") then
session("AgnRunasUser")=True
else
session("AgnRunasUser")=false
end If
End if
if not ef then
If IsNull(dsreg("usermoney")) Then
		ef=True
		ec="此帐号金额为空,不允许登陆,请联系管理员处理！"
End if
end If

if not ef then
if dsreg("agent1")<>"n" then
 Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&dsreg("agent1")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsagent.Open Sql,conn,1,1
If dsagent.Eof Then
		ef=True
		ec="代理会员名不存在或密码出错了！"
else
session("agenttype")=dsagent("agenttype")
session("agentname")=dsreg("agent1")
haveclosehtml=dsagent("haveclosehtml")
end If
End If
End If
End if'不是代理处理


'完成处理登陆
End If
dsreg.close
Set dsreg=nothing
end if

If not ef then
  Set dsdom = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Domain where id='"&Request.Form ("id")&"' and username='"&Request.Form ("username")&"' and status='正常' order by id desc"
If Request.Form ("isagn")="yes" Then 	Sql="Select * from FreeHost.FreeHost_Product_Domain where (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') and id='"&Request.Form ("id")&"' and status='正常' order by id desc"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
outcon="非法字符！"
Response.End
end if
		dsdom.Open Sql,conn,1,1
If dsdom.Eof Then
		ef=True
		ec="域名不存在,只有处于正常状态的域名才能管理！"
end if
end if

End If'完成API登陆


If not ef then
if not dsdom("status")="正常" then
		ef=True
		ec="必须是成功注册或处于正常状态的域名才能管理！"
end if
end if

If not ef Then
session("returl")=""
session("Domain_type1")=dsdom("type1")
session("httpscookie")=""
session("DNSAUID")=dsdom("id")
session("domain")=dsdom("domain")
session("inipass")=dsdom("inipass")
session("api7select")=dsdom("api7select")
session("Domain_API")=dsdom("Domain_API")
if dsdom("DNS_API")=1 then
session("DNS_API")=1'STARTOUT DNS
else
session("DNS_API")=0'ORI dns
end if

if (dsdom("DNS_API")=0 or isnull(dsdom("DNS_API"))) And Not dsdom("api7select")=2 then
if dsdom("Domain_API")=1 then
urlD="http://mgt.dns.com.cn"


'elseif dsdom("Domain_API")=2 and (Enddomaintypeid=3  or Enddomaintypeid=6  or Enddomaintypeid=7)  then

if Application("showdomainpass")=true then

sTime = DateDiff("s", "1970-1-1 0:00:00", DateAdd("s",-28800,Now))
auth = md5(md5(dsdom("inipass"))&md5(Application("Domain_Agent_password_1_API"))&"Q#!*&^VMXP")
key = md5(Application("Domain_Agent_username_1")& dsdom("domain") & left(sTime, len(sTime) - 3) & "ZL*$@,>HDY")
strSend = "domainName="&server.URLEncode(dsdom("domain"))&"&auth="&auth&"&key="&Key
ret = Post_RetrunStr("http://mgt.dns.com.cn/main/domain_epp.php",strSend)
tokeary=Split(ret,"token")
token=Replace(tokeary(1),"""}","")
token=Replace(token,""":""","")
If token="" Then 
Response.write "验证失败，请检查密码，或重置密码后再试"
Response.End
Else
response.redirect "http://mgt.dns.com.cn/main/domain_tmp.php?token="&token
End If

End if

elseif dsdom("Domain_API")=2 and (Enddomaintypeid=6  or Enddomaintypeid=7)  then
'urlD="http://mns.xinnet.com"
urlD="http://dcp.xinnet.com"
elseif dsdom("Domain_API")=2 then
if Application("showdomainpass")=true then
domarry=split(session("domain"),".")
domtemp=right(session("domain"),len(session("domain"))-len(domarry(0)))
Response.CodePage=65001
Response.Charset="UTF-8" 
%>

<form name="form1" method="post" action="http://dcp.xinnet.com/domainLogin.do?method=domainEnter" ID="Form1">
<input name="domainName" type="hidden" value="<%=dsdom("Domain")%>">
<input name="password" type="hidden" value="<%=dsdom("inipass")%>">
<img id="validateCodeImg"  src="http://dcp.xinnet.com/Modules/agent/domain/validate_picture.jsp" height="30" width="65" align="top">
<input name="checkCode" type="text" style="width:40px" />
<input type="submit" name="Submit" value="<%If ef then%>Error if you want to login pls click here<%else%>login...........<%End if%>">
</form>
<script language="JavaScript">
//document.Form1.submit();
</script>


<%response.end

'urlD="http://dcp.xinnet.com"
'新的dns
'urlD="https://www.paycenter.com.cn/cgi-bin/vpp/DomainLogin?Domain="&domarry(0)&"&Suffix="&domtemp&"&Password="&server.URLEncode(session("inipass"))&"&B1=%A1%A1%B5%C7%A1%A1%C2%BC%A1%A1"
'If  Enddomaintypeid=7 Then urlD="https://www.paycenter.com.cn/cgi-bin/vpp/DomainLogin?Domain="&session("domain")&"&Suffix=&Password="&server.URLEncode(session("inipass"))&"&B1=%A1%A1%B5%C7%A1%A1%C2%BC%A1%A1"



else
urlD="http://mydns2.xinnet.com"
end if
elseif dsdom("Domain_API")=3 then
'urlD="http://www.bizcn.com/domainportal"
urlD="http://dnsmsn.com/login/domain/doLogin.do"
%>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<form name="form1" method="post" action="<%=urlD%>" ID="Form1">
<input name="domainName" type="hidden" value="<%=dsdom("Domain")%>">
<input name="password" type="hidden" value="<%=dsdom("inipass")%>">

<input type="submit" name="Submit" value="login...........">
</form>
<script language="JavaScript">
document.Form1.submit();
</script>

<%
response.end
elseif dsdom("Domain_API")=4 then
urlD="http://www.dns-diy.com"

Response.CodePage=65001
Response.Charset="UTF-8" 
%>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<form name="form1" method="post" action="http://www.dns-diy.com/login.aspx" ID="Form1">
<input name="username" type="hidden" value="<%=dsdom("Domain")%>">
<input name="password" type="hidden" value="<%=session("inipass")%>">
<input type="submit" name="Submit" value="login...........">
</form>
<script language="JavaScript">
document.Form1.submit();
</script>


<%
response.end



elseif dsdom("Domain_API")=5 then
urlD="http://diy.hichina.com"

elseif dsdom("Domain_API")=7 then
urlD="http://access.enom.com"
If Application("api7select")=1 Then urlD="http://dns.world-server.net"
If Application("api7select")=2 Then Response.Redirect "e.asp?e=本接口必须用自己的DNS"

elseif dsdom("Domain_API")=6 Then

'-------------以下是登录中国数据代码-------------------

'确保Application("Domain_Agent_url_6")、Application("Domain_Agent_username_6")、Application("Domain_Agent_password_6")都存在
'登录中国数据
	If LCase(Application("Domain_Agent_url_6"))="http://api.zgsj.com" Then
		api6DomainLoginCp=Application("Domain_Agent_url_6")&"/agentserver/domain/api.asp?method=DomainLoginCp"
		dn=dsdom("Domain")
		checksum=MD5("DomainLoginCp"+Application("Domain_Agent_username_6")+Application("Domain_Agent_password_6")+dn)
		body="client="&Application("Domain_Agent_username_6")&"&name="+server.URLEncode (dn)+"&checksum="&checksum
		retdns=ONLY_POST(api6DomainLoginCp,api6DomainLoginCp,body)
		If Instr(retdns, "&info=")<=0 Then
			Response.write "登录失败，错误原因："&server.URLEncode (retdns):Response.End
		Else
			tmep=split(retdns,"&info=")
			loginurl=tmep(1)
			Response.redirect loginurl
			Response.End
		End If
	End If

'-------------以上是登录中国数据代码-------------------

api6admurl=Application("Domain_Agent_url_6")&"/dns/dnslogin.asp"
%>

<meta http-equiv="content-type" content="text/html; charset=gb2312">
<form name="form1" method="post" action="<%=api6admurl%>" ID="Form1">
<input name="domain" type="hidden" value="<%=dsdom("Domain")%>">
<input name="inipass" type="hidden" value="<%=dsdom("inipass")%>">
<input name="api" type="hidden" value="6">
<input type="submit" name="Submit" value="login...........">
</form>
<script language="JavaScript">
document.Form1.submit();
</script>

<%
response.end
end if

response.redirect urlD
end if
end if


if not ef then
dsdom.close
conn.Close
set conn=nothing
Response.Redirect "logininfo.asp"
end if

if ef then
Response.Redirect "e.asp?e="&ec
end if%>
