<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("canmoneyK")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf Request("id")<>"" And not IsNumeric(Request("id"))  Then
	ef=True
	ec="ID应该是数字！"
elseif Request ("ftpname")<>"" and RegExpTest("[^A-Za-z0-9]",Request("ftpname")) Then
	ef=True
	ec="FTP名非法！"
end if

if not ef then
 
hostname=trim(replace(Request("hostname"),"http://",""))
if hostname<>"" then hostname=ComX.idntoac_7i24_com(cstr(hostname))
hostnamecheck=replace(hostname,".","")
hostnamecheck=replace(hostnamecheck,"xn--","")
If RegExpTest("[^A-Za-z0-9--]",hostnamecheck) Then
	ef=True
	ec="请输入合法的域名！"
end if
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
if Request("op")="del" Then
conn.Execute "delete FreeHost.FreeHost_ICPDB where (status<>'已提交备案，尚未备案成功' and status<>'备案成功')"
response.redirect "admicpdb.asp"
End if

if Request("op")="codeerr" Then
conn.Execute "update FreeHost.FreeHost_ICPDB set status='尚未检测' where (status<>'备案成功' and status<>'未提交备案' and status<>'已提交备案，尚未备案成功' and status<>'备案被拒绝')"
response.redirect "admicpdb.asp"
End if

if Request("op")<>"" And Request("op")<>"del" then
	Set dsICPDB = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ICPDB where id ='"&Request("id")&"'"
if Request("op")="add" then Sql="Select * from FreeHost.FreeHost_ICPDB where id ='"&Request("id")&"'"
	dsICPDB.Open Sql,conn,1,3
if not dsICPDB.Eof then

if Request("op")="y" or Request("op")="yaddhost" then dsICPDB("status")="备案成功"
if Request("op")="y2" or Request("op")="y2addhost" then dsICPDB("status")="已提交备案，尚未备案成功"
if Request("op")="n" then dsICPDB("status")="尚未检测"
if Request("op")="n2" then dsICPDB("status")="未提交备案"
dsICPDB("checktime")=Now
if Request("op")="d" then dsICPDB.delete
dsICPDB.update
if Request("op")<>"d" then
Sql="update FreeHost.FreeHost_ICPDB set status='"&dsICPDB("status")&"' where domain ='"&dsICPDB("domain")&"'"
    conn.Execute Sql
End if

'If Request("op")="yaddhost" Or Request("op")="y2addhost" Or Request("op")="n2"  Then
If 1=2  Then
'添加域名到虚拟主机中
newdomain=",:80:"&Replace(Replace(replace(Trim(LCase(dsICPDB("domain"))),"http://","")," ",""),"/","")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where ftpname='"&dsICPDB("ftpname")&"'"
'	Sql="Select * from FreeHost.FreeHost_Product_Host where ftpname='"&dsICPDB("ftpname")&"' and hostname+',' NOT LIKE '%"&newdomain&",%'"
'if Request("op")="n2" then Sql="Select * from FreeHost.FreeHost_Product_Host where ftpname='"&dsICPDB("ftpname")&"' and hostname+',' LIKE '%"&newdomain&",%'"
	dsph.Open Sql,conn,1,3
if Not dsph.Eof Then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serverlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if Not dsserver.Eof Then
'有这台服务器
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
ostype=dsserver("ostype")'linux
username=dsph ("Ftpname")
host=Replace(dsph("hostname")&newdomain,",,",",")


hostip=dsserver("ip")
isuseCDN=dsserver("isuseCDN")	
usecdn1=dsserver("usecdn1")
CDNORIport=dsserver("port")


hostcomment_arry=Split(host, ",")
hostcomment=Replace(hostcomment_arry(0),":80:","")&"_"&username&"_"&dsph ("username")
hostname=host
if dsserver("iisver")=6 then
hostnamestr=replace(hostname, ":80:","")
hostname_arry=Split(hostnamestr, ",")
for i=0 to ubound(hostname_arry)
hostname_arry(i)=ComX.idntoac_7i24_com(cstr(hostname_arry(i)))
next
hostname=""
for i=0 to ubound(hostname_arry)
hostname=hostname&":80:"&replace(replace(hostname_arry(i), " ",""),":80:","")&","
next
if right(hostname,1)="," then hostname=left(hostname,len(hostname)-1)
End if

'hostcomment=username&"_"&Replace(hostname_arry(0),":80:","")&"_"&dsph ("username")
'调用开通function
host=hostname

if dsserver("iisver")>6 Then
hostnamestr=replace(host, ":80:","")
hostname_arry=Split(hostnamestr, ",")
for i=0 to ubound(hostname_arry)
hostname_arry(i)=ComX.actoidc_7i24_com(cstr(hostname_arry(i)))
next
host=""
for i=0 to ubound(hostname_arry)
host=host&":80:"&replace(replace(hostname_arry(i), " ",""),":80:","")&","
next
if right(host,1)="," then host=left(host,len(host)-1)
End If

if Application("hostoneip")=true then
Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Host_IP where HostID="&dsph("id")
		dsX.Open Sql,conn,1,1
If not dsX.Eof Then
host=Replace(host,":80:",dsX("IP")&":80:")
If dsph("iphead")=true then host=dsX("IP")&":80:"&dsX("IP")&","&host
If dsph("nullhead")=true Then host=dsX("IP")&":80:,"&host
End if
End if


if isuseCDN=true Then host=Replace(host,":80:",":"&CDNORIport&":")
'Response.Write host
'Response.end
temp=ModifyUser2(URL,FreeHostsharekey,username,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)



dsph("hostname")=hostname

'显示备案成功
alldomainok=1
hostname=dsph("hostname")
hostname=replace(hostname, ":80:","")
hostname_arry=Split(hostname, ",")
for i=0 to ubound(hostname_arry)
domain=hostname_arry(i)

domain=ComX.idntoac_7i24_com(cstr(domain))


	Set dsICPDB = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ICPDB where domain='"&GetDomainMain(domain)&"'"
	dsICPDB.Open Sql,conn,1,3
if dsICPDB.Eof Then
alldomainok=0
Else
If dsICPDB("status")<>"备案成功" Then alldomainok=0
end If
dsICPDB.close
Next

If alldomainok=1 then
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where Hosttype='子目录绑定' and allowsubbyid='"&dsph("id")&"' order by endtime desc"
dsphsub.Open Sql,conn,1,3
While Not dsphsub.eof
'显示备案成功
hostname=dsphsub("hostname")
hostname=replace(hostname, ":80:","")
hostname_arry=Split(hostname, ",")
for i=0 to ubound(hostname_arry)
domain=hostname_arry(i)

domain=ComX.idntoac_7i24_com(cstr(domain))
	Set dsICPDB = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ICPDB where domain='"&GetDomainMain(domain)&"'"
	dsICPDB.Open Sql,conn,1,3
if dsICPDB.Eof Then
alldomainok=0
Else
If dsICPDB("status")<>"备案成功" Then alldomainok=0
end If
dsICPDB.close
Next
dsphsub.movenext
Wend
End if

If alldomainok=1 Then 
dsph("alldomainok")=1
dsph("beianstatus")="备案成功"
Else
If dsph("beianstatus")="备案成功" then
dsph("alldomainok")=0
dsph("beianstatus")=Null
End if
End if





dsph.update
dsph.close
'完成绑域名
End if
end if
End if


end If


if Request("op")="add" Then
If hostname<>"" then
if dsICPDB.Eof Then dsICPDB.addnew
dsICPDB("domain")=GetDomainMain(hostname)
dsICPDB("status")=Request("status")
If Request("ftpname")<>"" Then
dsICPDB("ftpname")=LCase(Trim(Request("ftpname")))
Else
dsICPDB("ftpname")=null
End If
If Request("ICP_SN")<>"" Then
dsICPDB("ICP_SN")=LCase(Trim(Request("ICP_SN")))
Else
dsICPDB("ICP_SN")=null
End if
If Request("ICP_Who")<>"" Then
dsICPDB("ICP_Who")=Trim(Request("ICP_Who"))
Else
dsICPDB("ICP_Who")=null
End if
dsICPDB("firstaddtime")=Now
dsICPDB.update
End if
End if


response.redirect "admicpdb.asp"
end if
end if



if not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html8")%>
<%=htmlwrite("html9")%>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0 background="img/midtop4.gif">
  <TBODY>
    <TR>
      <TD width=53 align="left" background="img/midtop1.gif"><strong> 　 </strong><font color="#FFFFFF">─<strong>&gt;</strong></font> </TD>
      <TD width="126" align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="90" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="admicp.asp"><font color="#FFFFFF"><strong>备案管理</strong></font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width="200" align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="150" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="admicpdb.asp"><font color="#FFFFFF"><strong>本地备案数据库管理</strong></font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="100" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="beiancheck.asp" target="_blank"><font color="#FFFFFF"><strong>批量查询</strong></font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width="83" align="left">&nbsp;</TD>
      <TD width="74" align="left">&nbsp;</TD>
      <TD width=23 align="right"><IMG height=59 
                  src="img/rtop4.jpg" 
                  width=19></TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=19 background="img/midlef.gif" id=rightid>&nbsp;</TD>
      <TD height="300" align="center" vAlign=top bgcolor="#FFFFFF">
<form name="form1" method="get" action="admicpdb.asp">
         <DIV class="tableborder"><table width="100%"  border="0" cellspacing="1">
        <tr >
          <td height="24" colspan="2" align="center" background="img/tablebg.gif"><font color="#FFFFFF">查找域名</font></td>
        </tr>
        <tr bgcolor="#E4EAF2">
          <td width="9%" height="40" align="right" bgcolor="#E4EAF2">&nbsp;</td>
          <td width="91%" align="left">域名：
<input name="hostname" type="text" id="hostname" size="15">　
或FTP名：
<input name="ftpname" type="text" id="ftpname" size="15">
<input type="submit" name="Submit" value="搜索">
　　　<a href="admicpdb.asp?havecheck=n"><font color="#000000">所有未检测的</font></a>　<a href="admicpdb.asp?havecheck=x"><font color="#000000">所有备案失败的</font></a>　<a href="admicpdb.asp?havecheck=w"><font color="#000000">已提交备案但没通过的</font></a>

　<a href="admicpdb.asp?op=del" onClick="if (confirm('请您确认删除操作')==false){return false;}"><font color="#000000">删除所有没备案成功的</font></a>
　<a href="admicpdb.asp?op=codeerr" onClick="if (confirm('请您确认操作')==false){return false;}"><font color="#000000">将状态出错的改成未检测</font></a> </td>
        </tr>
      </table>
         </div>
</form>	
<%


'if Request("id")="" then
	Set dsICPDB = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ICPDB order by id desc"
if Request("id")<>"" then 	Sql="Select * from FreeHost.FreeHost_ICPDB where  id ='"&Request("id")&"' order by id desc"
if Request("hostname")<>"" then 	Sql="Select * from FreeHost.FreeHost_ICPDB where  domain like '%"&hostname&"%' order by id desc"
if Request("ftpname")<>"" then 	Sql="Select * from FreeHost.FreeHost_ICPDB where  ftpname='"&Request("ftpname")&"' order by id desc"
'if Request("username")<>"" then 	Sql="Select * from FreeHost.FreeHost_ICPDB where  username = '"&Request("username")&"' order by id desc"
if Request("havecheck")="n" then 	Sql="Select * from FreeHost.FreeHost_ICPDB  where status='尚未检测' order by id desc"
if Request("havecheck")="x" then 	Sql="Select * from FreeHost.FreeHost_ICPDB  where status<>'备案成功' and status<>'尚未检测' order by id desc"
if Request("havecheck")="w" then 	Sql="Select * from FreeHost.FreeHost_ICPDB  where status='已提交备案，尚未备案成功' order by id desc"

'Response.Write sql

			if Instr(1,sql, ";", 1)>0 or Instr(1,Replace(sql,"xn--",""), "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsICPDB.PageSize = 25
	dsICPDB.Open Sql,conn,1,1
if dsICPDB.Eof then
%>
<br>
没有这类内容。
<%
Else

If Request.QueryString ("id")<>"" then
hostname=dsICPDB("domain")
ftpname=dsICPDB("ftpname")
status=dsICPDB("status")
ICP_SN=dsICPDB("ICP_SN")
ICP_Who=dsICPDB("ICP_Who")
End If


%>
<%if Request.ServerVariables("QUERY_STRING")<>"" then
ask=Split(Request.ServerVariables("QUERY_STRING"), chr(38)&"pn")
else
ask=Split("freehost=1", "")
ask(0)="freehost=lsoft"
end if
	pn=1
if Request.QueryString ("pn")<>"" then pn=Request.QueryString ("pn")
If dsICPDB.RecordCount <> 0 Then dsICPDB.AbsolutePage = CLng(pn)  
    if clng(pn)<=10 then
    begini=1
      if dsICPDB.PageCount<=10 then
       endini=dsICPDB.PageCount 
       else
       endini=10
      end if
    end if
%>
<%if clng(pn)<=10 then%>最新 <%for i=begini to endini
    if clng(pn)=i then%><font color=red>[<%=i%>]</font><%else%><a href="?<%=ask(0)%>&pn=<%=i%>"><font color="#000000">[<%=i%>]</font></a><%end if%>　<%next%> 
        <%else%>　<a href="?<%=ask(0)%>&pn=1"><font color="#000000">最新[1]--[10]</font></a>　　现在是第<font color=red>[<%=pn%>]</font>页 
        　共<%=dsICPDB.PageCount%>页　<%end if%><%If Clng(pn)>1 Then%><a href="?<%=ask(0)%>&pn=<%=pn-1%>">上一页</a><%End If%>|<%If Clng(pn)<dsICPDB.PageCount Then%><a href="?<%=ask(0)%>&pn=<%=pn+1%>"><font color="#000000">下一页</font></a>
        <%End If%>
<DIV class="tableborder"><table width="100%"  border="0" cellspacing="1">
          <tr bgcolor="#CCCCCC">
            <td width="6%" height="24" align="center" background="img/tablebg.gif" bgcolor="#CCCCCC"><font color="#FFFFFF">编号</font></td>
            <td width="10%" align="center" background="img/tablebg.gif" bgcolor="#CCCCCC"><font color="#FFFFFF">域名</font></td>
            <td width="9%" align="center" background="img/tablebg.gif" bgcolor="#CCCCCC"><font color="#FFFFFF">状态</font></td>
            <td width="12%" align="center" background="img/tablebg.gif" bgcolor="#CCCCCC"><font color="#FFFFFF">录入时间</font></td>
            <td width="11%" align="center" background="img/tablebg.gif" bgcolor="#CCCCCC"><font color="#FFFFFF">操作</font></td>
          </tr>
<%
For N=1 To dsICPDB.PageSize 
					If dsICPDB.RecordCount=0 Then Exit For
%>
          <tr bgcolor="#E4EAF2" onmouseover=this.bgColor='#cccccc'; onmouseout=this.bgColor='#E4EAF2';>
            <td width="6%" height="140" align="center"><%=dsICPDB("id")%></td>
            <td width="10%" height="140" align="center"><font color="#000000"><a href="handhost1.asp?hostname=<%=dsICPDB("domain")%>" target="_blank"><font color="#000000"><%=ComX.actoidc_7i24_com(Cstr(dsICPDB("domain")))%></font></a>
			<%if not isnull(dsICPDB("ftpname")) then%><br>
<br>
<a href="handhost1.asp?ftpname=<%=dsICPDB("ftpname")%>" target="_blank">FTP名：<%=dsICPDB("ftpname")%></a>　<a href="admicpdb.asp?id=<%=dsICPDB("id")%>">修改</a>
<%end if%>
</font></td>
            <td width="9%" height="140" align="center">
			<%=dsICPDB("status")%><br><%=dsICPDB("ICP_SN")%><br><%=dsICPDB("ICP_Who")%>
			<br>
			<%=dsICPDB("checktime")%></td>
            <td width="12%" height="140" align="center"><%=dsICPDB("firstaddtime")%><br>
              <a href="admicpdbupimg.asp?id=<%=dsICPDB("id")%>" target="_blank">查看/上传图片</a></td>
            <td width="11%" height="140" align="center">
<a href="admicpdb.asp?id=<%=dsICPDB("id")%>&op=yaddhost"><font color="#000000">更改为备案成功</font></a><br>
<br>

<a href="admicpdb.asp?id=<%=dsICPDB("id")%>&op=y2"><font color="#000000">更改为已提交备案，尚未备案成功</font></a><br>
<br>
<a href="admicpdb.asp?id=<%=dsICPDB("id")%>&op=n2"><font color="#000000">更改为未备案</font></a>　　<a href="admicpdb.asp?id=<%=dsICPDB("id")%>&op=n"><font color="#000000">更改为未检测</font></a><br>
<br><a href="admicpdb.asp?id=<%=dsICPDB("id")%>">修改</a>　　　
<a href="admicpdb.asp?id=<%=dsICPDB("id")%>&op=d"><font color="#000000">删除</font></a></td>
          </tr>

        <%
If clng(pn)=dsICPDB.PageCount Then
I = dsICPDB.RecordCount - (dsICPDB.PageCount-1) * dsICPDB.PageSize
If N=I Then Exit For
End If
dsICPDB.movenext
Next%>
</table>
</div>
<%end if
dsICPDB.close
set dsICPDB=nothing
'end if
%>
<form action="admicpdb.asp" method="post" name="autoopen">
  <DIV class="tableborder">
    <table width="100%"  border="0" cellspacing="1">
      <tr>
        <td height="24" colspan="2" align="center" background="img/tablebg.gif"><font color="#FFFFFF">录入/修改：<%=id%></font></td>
      </tr>
      <tr bgcolor="#E4EAF2">
        <td width="9%" align="right">&nbsp;</td>
        <td width="91%" align="left">          <br>
          <br>
          <%if Application("beianusecode")=1 then%>
　录入域名前，您可以检查是否备案<br>
　域名：
<input name="hostname" type="text" id="hostname" onBlur="doicpcheck(this.value);" size="20" value="<%=hostname%>">
(不需要输入www或http://,系统会自动提取主域名)<br>
<br>
　再输入验证码(稍等一会右边的图片才会出现)：
<input name="icpcode" type="text" id="icpcode" size="6" maxlength="10" onmouseover="this.focus()" onFocus="this.select()">
<img id=imgcode height=50 src="" width=200 name=imgcode style="display:none" onClick="doicpcheck(document.autoopen.hostname.value);document.autoopen.icpcode.value='';"> <br>
<br>
　<a href="javascript:doicpcheckend(document.autoopen.icpcode.value);">再点这儿检查备案状态&gt;&gt;&gt;</a>　　检查结果(请耐心等候两分钟)：
<div id="divicpinfo"><br>
</div>
<%else%>
　域名：<input name="hostname" type="text" id="hostname"  size="20" value="<%=hostname%>">
<%end if%>          <br><br>
          　 状态：
          <select name="status" id="status">
            <option value="备案成功" <%if status="备案成功" then%>selected<%end if%>>备案成功</option>
            <option value="已提交备案，尚未备案成功" <%if status="已提交备案，尚未备案成功" then%>selected<%end if%>>已提交备案，尚未备案成功</option>			
            <option value="尚未检测" <%if status="尚未检测" then%>selected<%end if%>>尚未检测</option>
            <option value="未提交备案" <%if status="未提交备案" then%>selected<%end if%>>未提交备案</option>			
          </select>
          　FTP名：
          <input name="ftpname" type="text" id="ftpname" size="10" maxlength="14" value="<%=ftpname%>">          <br>
          　 备案号：
          <input name="ICP_SN" type="text" id="ICP_SN" size="16" maxlength="40" value="<%=ICP_SN%>">
          　 备案主体：
          <input name="ICP_Who" type="text" id="ICP_Who" size="16" maxlength="40" value="<%=ICP_Who%>">
<br>
          <br>
          <input name="id" type="hidden" id="id" size="20" value="<%=Request.QueryString ("id")%>">
		  <input name="op" type="hidden" id="id" size="20" value="add">
          　
          <input type="submit" name="Submit222" value="执行">
          (如果上面已显示成功录入数据库，就不需要点执行了)(Linux接口必须点执行)
          <%if Request.QueryString ("id")<>"" then%>
          　　 <a href="admicpdb.asp?id=<%=Request.QueryString ("id")%>&op=d"><font color="red">删除</font></a> 　　
          <%end if%></td>
      </tr>
    </table>
  </div>
</form>

      </TD>
      <TD width=18 background="img/midri.gif">&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD width=30><IMG height=19 
                  src="img/rb1.jpg" 
                  width=30></TD>
      <TD 
                background=img/rb2.jpg>&nbsp;</TD>
      <TD width=30><IMG height=19 
                  src="img/rb3.jpg" 
                  width=30></TD>
    </TR>
  </TBODY>
</TABLE>
<script src="/inc-freehost-function/icpcheck.js"></script>
<%=htmlwrite("html10")%>
<%
end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
