<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
Function strtobin(str, charset)
  With Server.CreateObject("ADODB.Stream")
      .Type = 2
      .Mode = 3
      .Open
      .Charset = charset
      .WriteText str
      .Flush
      .Position = 0
      .Type = 1
       strtobin = .Read()
      .Close
  End With
End Function
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.QueryString ("agent1")="" And Request.QueryString ("username")="" and Request.QueryString ("endtime2")=""  and Request.QueryString ("status")=""  and Request.QueryString ("starttime2")=""   and Request.QueryString ("beianstatus")=""  and Request.QueryString ("hostname")="" and Request.QueryString ("ftpname")=""  and Request.QueryString ("ServerlistID")="" and Request.QueryString ("Hosttype")="" and Request.QueryString ("sqlname")="" or Instr(Request.QueryString ("hostname"), "'")>0  or Instr(Request.QueryString ("ftpname"), "'")>0    or Instr(Request.QueryString ("Hosttype"), "'")>0    or Instr(Request.QueryString ("sqlname"), "'")>0  Then
	ef=True
	ec="必须输入一项内容或有非法字符！"
elseIf session("canadmuser")="" Then
	ef=True
	ec="您没有此操作的权限。"
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")
	Set dsph = Server.CreateObject("ADODB.Recordset")
SQL="Select * from FreeHost.FreeHost_Product_Host where "
if Request.QueryString ("username")<>"" then Sql=Sql+"username= '"&trim(Request.QueryString ("username"))&"' and "
if Request.QueryString ("agent1")<>"" then Sql=Sql+"agent1= '"&trim(Request.QueryString ("agent1"))&"' and "
if hostname<>"" then Sql=Sql+"hostname like '%"&replace(hostname,"http://","")&"%' and "
if Request.QueryString ("ftpname")<>"" then Sql=Sql+"ftpname like '%"&trim(Request.QueryString ("ftpname"))&"%' and "
if Request.QueryString ("ServerlistID")<>"" then Sql=Sql+"ServerlistID = '"&trim(Request.QueryString ("ServerlistID"))&"' and "
if Request.QueryString ("Hosttype")<>"" then Sql=Sql+"Hosttype = '"&trim(Request.QueryString ("Hosttype"))&"' and "

if Request.QueryString ("status")<>"" then
if Request.QueryString ("status")="过期暂停" then
Sql=Sql+"istest = 'n' and endtime < '"&now&"' and status = '暂停' and "
elseif Request.QueryString ("status")="过期未暂停" then
Sql=Sql+"istest = 'n' and endtime < '"&now&"' and status = '正常' and "
elseif Request.QueryString ("status")="试用过期未暂停" then
Sql=Sql+"endtime < '"&now&"' and istest = 'y' and status = '正常' and "
elseif Request.QueryString ("status")="试用过期已暂停" then
Sql=Sql+"endtime < '"&now&"' and istest = 'y' and status = '暂停' and "
elseif Request.QueryString ("status")="试用过期" then
Sql=Sql+"endtime < '"&now&"' and istest = 'y' and "
elseif Request.QueryString ("status")="试用" then
Sql=Sql+"endtime > '"&now&"' and istest = 'y' and "
elseif Request.QueryString ("status")="停止" then
Sql=Sql+"status = '停止' and "
else
Sql=Sql+"istest = 'n' and status = '"&trim(Request.QueryString ("status"))&"' and "
end if
end if

if Request.QueryString ("beianstatus")<>"" and Request.QueryString ("beianstatus")<>"没有备案" then Sql=Sql+"beianstatus = '"&trim(Request.QueryString ("beianstatus"))&"' and "
if Request.QueryString ("beianstatus")="没有备案" then Sql=Sql+"beianstatus is null and "
if Request.QueryString ("starttime2") <>"" then  Sql=Sql+"hosttype<>'子目录绑定' and starttime>='"&Request.QUERYSTRING ("starttime1")&"' and starttime<'"&Request.QUERYSTRING ("starttime2")&"' and "
if Request.QueryString ("endtime2") <>"" then  Sql=Sql+"hosttype<>'子目录绑定' and endtime>='"&Request.QUERYSTRING ("endtime1")&"' and endtime<'"&Request.QUERYSTRING ("endtime2")&"' and "
if right(sql,5)=" and " then sql=left(sql,len(sql)-5)&" order by id desc"

if Request.QueryString ("orderbybytes")="d" then Sql=replace(Sql," id desc"," (BytesSent+BytesReceived) desc")
if Request.QueryString ("orderbybytes")="m" then Sql=replace(Sql," id desc"," thismonbytes desc")
if Request.QueryString ("orderbybytes")="cpu" then Sql=replace(Sql," id desc"," TimeTaken desc")

if Request.QueryString ("orderbybytes")="CDNMBthismonth" then Sql=replace(Sql," id desc"," CDNMBthismonth desc")
txml=dateadd("y",-1,now)
if Request.QueryString ("orderbybytes")="CDNMB-d" then Sql=replace(Sql," id desc"," CDNMB"&day(txml)&" desc")

if Request.QueryString ("top20")="y" then sql=Replace(sql," * "," top 20 * ")

'Response.Write sql
if Instr(1,sql, ";", 1)>0 or Instr(1,replace(sql,"xn--",""), "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
        dsph.Open Sql,conn,1,1
if dsph.Eof then
	ef=True
	ec="数据库中没有此类内容。"
else
allcount=dsph.recordcount	
end if
end if

if not ef then
txml=dateadd("y",-1,now)
If request.QueryString("csv")="yes" Then


con="#id,用户名,中文名,联系人,电话,手机,QQ,产品类型,空间大小(M),域名,FTP名,IP,状态,购买时间,到期时间"&vbcrlf
while not dsph.Eof
Hosttype=dsph("Hosttype")
hostname=dsph("hostname")
hostname=replace(hostname, ":80:","")
hostname_arry=Split(hostname, ",")
Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username = '"&dsph ("username")&"'"
		ds.Open Sql,conn,1,1
if Not ds.Eof Then
truename=ds("truename")
tel=ds("tel")
mobi=ds("mobi")
qq=ds("qq")
contact=ds("contact")
End If

spacelimt=dsph("spacelimt")
if isnull(dsph("spacelimt")) then	
		Set ori_host_name = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_HostProductlist where Hosttype='"&dsph("Hosttype")&"'"
		ori_host_name.Open Sql,conn,1,1
		if not ori_host_name.eof then	
spacelimt=ori_host_name("spacelimt")
end if
end if
Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serverlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
ip=dsserver("ip")
dsserver.close
hostname=Replace(hostname,",","@")
con=con&dsph("id")&","&dsph("username")&","&ds("truename")&","&ds("tel")&","&ds("mobi")&","&ds("qq")&","&ds("contact")&","&dsph("Hosttype")&","&spacelimt&","&hostname&","&dsph("ftpname")&","&ip&","&dsph("status")&","&formatdatetime(dsph("starttime"),1)&","&formatdatetime(dsph("endtime"),1)&vbcrlf
dsph.movenext
Wend


conbyte=strtobin(con, "GBK")
Filesize=Lenb(conbyte)
Response.AddHeader "Content-Disposition", "attachment; filename=host.csv"  '添加头信息，为"文件下载/另存为"对话框指定默认文件名
Response.AddHeader "Content-Length", Filesize            'file.Length.ToString()    '添加头信息，指定文件大小，让浏览器能够显示下载进度
Response.ContentType = "application/csv"                '指定返回的是一个不能被客户端读取的流，必须被下载
Response.BinaryWrite conbyte
Response.Flush 
Response.end
End if
%>
<form action="sxaction.asp" method="post" name="formBT" target="_top" id="formBT">
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" bgcolor="#333333">
  <tr bgcolor="#C1BFBF" align="center">
    <td>选</td>
    <td>产品类型</td>
    <td height="21">用户名</td>
    <td>域　名</td>
    <td>容量</td>
    <td height="21">FTP用户名</td>
    <td>IP 地址</td>
    <td>开通到期</td>
    <td>流量/资源</td>
    <td>状态</td>
    <td>操作</td>
    <td>ICP</td>
  </tr>
<%while not dsph.Eof%>
<%

	Hosttype=dsph("Hosttype")

'		end if

hostname=dsph("hostname")
hostname=replace(hostname, ":80:","")
hostname_arry=Split(hostname, ",")

	%>
  <tr align="center" bgcolor="#FFFFFF" onmouseover=this.bgColor='#E4EAF2'; onmouseout=this.bgColor='#FFFFFF';>
    <td><input name="dsphid" type="checkbox" id="dsphid" value="<%=dsph("id")%>"></td>
    <td><%=Hosttype%></td>
    <td height="30"><a href="searchuser.asp?username=<%=dsph("username")%>"><%=dsph("username")%></a><br>
<%if dsph("agent1")<>"n" then%>
(<a href="searchagent.asp?username=<%=dsph("agent1")%>" target="_blank"><font color="#FF0000"><%=dsph("agent1")%></font></a>)
<%end if%>
<%if not isnull(dsph("kefu")) then%><br><a href="admkefu.asp?kefu=<%=dsph("kefu")%>">(<font color="#0000FF"><%=dsph("kefu")%>)</font></a>
      <%end if%>

<%If request("showuserinfo")="y" Then

Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username = '"&dsph ("username")&"'"
		ds.Open Sql,conn,1,1
if Not ds.Eof then
%>
<br>
真名：<%=ds("truename")%>
电话：<%=ds("tel")%> 手机：<%=ds("mobi")%> 传真：<%=ds("fax")%> QQ:<%=ds("qq")%> 邮箱：<a href=mailto:<%=ds("email")%>><font color="#000000"><%=ds("email")%></font></a>
 地址：<%=ds("prv")%>/<%=ds("city")%>/<%=ds("address")%> 联系人：<%=ds("contact")%> 邮编：<%=ds("postid")%>
<%
End If
ds.close
End If
%>
	
	</td>
    <td><%for idname=0 to ubound(hostname_arry)%>
	<a href="http://<%=hostname_arry(idname)%>" target="_blank">	  <%if ComX.actoidc_7i24_com(cstr(hostname_arry(idname)))<>hostname_arry(idname) then%>
          <%=ComX.actoidc_7i24_com(cstr(hostname_arry(idname)))%> (<%=hostname_arry(idname)%>)
          <%else%>
          <%=hostname_arry(idname)%>
          <%end if%></a><%If request("showicpinfo")="y" Then

Set dsICPDB = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_ICPDB where domain = '"&ComX.idntoac_7i24_com(hostname_arry(idname))&"'"
'response.write sql
		dsICPDB.Open Sql,conn,1,1
if Not dsICPDB.Eof then
%>,<%=dsICPDB("ICP_SN")%>,<%=dsICPDB("ICP_Who")%><%
End If
dsICPDB.close
End If
%>

	<br>	
<%next%></td>
    <td><%=dsph("spacelimt")%><%if isnull(dsph("spacelimt")) then
	
		Set ori_host_name = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_HostProductlist where Hosttype='"&dsph("Hosttype")&"'"
		ori_host_name.Open Sql,conn,1,1
		if not ori_host_name.eof then

	
	%><%=ori_host_name("spacelimt")%><%end if
	end if%>M</td>
    <td><%=dsph("ftpname")%></td>
    <td><%
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serverlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
%><%=dsserver("ip")%><%dsserver.close%>
      <br>    </td>
    <td><%=formatdatetime(dsph("starttime"),1)%><br>
    <%=formatdatetime(dsph("endtime"),1)%></td>
    <td>昨天:
      <%
if Not isnull(dsph("BytesReceived")) And Not isnull(dsph("BytesSent")) then
value=FormatNumber(((CDbl(dsph("BytesReceived"))+CDbl(dsph("BytesSent")))/1048576),1,-1)
End if
%>
      <%=value%> M<br>
本月:
<%
value=FormatNumber((CDbl(dsph("thismonbytes"))/1048576),1,-1)
%>
<%=value%> M<br>
CPU:
<%
value=FormatNumber(((CDbl(dsph("TimeTaken")))/8640000/5),1,-1)
%>
<%=value%>%<br>

<%if Request.QueryString ("orderbybytes")="CDNMBthismonth" or Request.QueryString ("orderbybytes")="CDNMB-d" then%>
本月CDN流量<%=dsph("CDNMBthismonth")%>MB<br>
昨天CDN流量<%=dsph("CDNMB"&day(txml))%>MB
<%end if%>
</td>
    <td><%if dsph("endtime")>NOW then%>
      <%if dsph("istest")="y" then%>
      <font color="#FF0000">试用</font><%else%>
      <%=dsph("status")%>
      <%end if%>
      <%else%>
      <font color="#FF0000">过期</font>
      <%if dsph("status")="暂停" then%>
      <br>
      <font color="#FF0000">暂停</font>
      <%end if%>
      <%end if%></td>
    <td><a href="handhost1.asp?username=<%=dsph("username")%>&id=<%=dsph("id")%>"><font color="#000000">管理</font></a></td>
    <td><a href="beian.asp?id=<%=dsph("id")%>"><%if dsph("beianstatus")="备案成功" then%><FONT color=red>成功</FONT><%else%><FONT color=#000000>备案</FONT><%end if%></td>
  </tr>
<%
dsph.movenext
wend%>
</table>

<br>


记录数：<%=allcount%>


<%
dsph.close
set dsph=nothing
conn.Close 
set conn=nothing
%>
  <a href="#docend" onClick="doselectall()"><b>[全选]</b></a>  <a href="#docend" onClick="undoselectall()"><b>[全不选]</b></a>　<a href="sx.asp?<%=Request.QueryString%>&csv=yes">导出CSV</a><br>
  <br>
批量操作:　
<input type="submit" name="Submit" value="暂停" onClick="JavaScript:if(confirm('确定暂停吗？此操作需要长时间完成,确定后请耐心等候,不要关闭IE或刷新IE.')){document.formBT.submit();}">
<input type="submit" name="Submit" value="停止"  onClick="JavaScript:if(confirm('确定停止吗？此操作需要长时间完成,确定后请耐心等候,不要关闭IE或刷新IE.')){document.formBT.submit();}">
<input type="submit" name="Submit" value="恢复" onClick="JavaScript:if(confirm('确定恢复吗？此操作需要长时间完成,确定后请耐心等候,不要关闭IE或刷新IE.')){document.formBT.submit();}">
<input type="submit" name="Submit" value="删除"  onClick="JavaScript:if(confirm('确定删除吗？此操作无法恢复？此操作需要长时间完成,确定后请耐心等候,不要关闭IE或刷新IE.')){document.formBT.submit();}">
<br>
　
      
如果是暂停可以选择下面暂停的原因：<br>
　
<input name="pauseweb" type="radio" value="pauseweb" <%if pausereason=1 then%>checked<%end if%>>
超过使用期限
<input name="pauseweb" type="radio" value="pauseweb2" <%if pausereason=2 then%>checked<%end if%>>
政治或色情
<input name="pauseweb" type="radio" value="pauseweb3" <%if pausereason=3 then%>checked<%end if%>>
上传引起不稳定的程序或其他原因<br>
　
<input name="pauseweb" type="radio" value="pauseweb4" <%if pausereason=4 then%>checked<%end if%>>
没有备案或备案不成功<br>
</form>
<a name="docend"></a>
<%end if
if ef then%>
<%=ec%>
<%end if%>
<script>
var partable=parent.document.getElementById("table0");
if (partable!=null)
partable.style.display='';
partable=parent.document.getElementById("outconM");
if (partable!=null)
partable.innerHTML = document.body.innerHTML;

function doselectall()
{
var   all=document.formBT
var   checks=all.getElementsByTagName("input"); 
 for(var   i=0;i<checks.length;i++)   
      {     


		if (checks[i].name=="dsphid")
			{

				checks[i].checked=true;

			}
      }   
}
function undoselectall()
{
var   all=document.formBT
var   checks=all.getElementsByTagName("input"); 
 for(var   i=0;i<checks.length;i++)   
      {     


		if (checks[i].name=="dsphid")
			{

				checks[i].checked=false;

			}
      }   
}
</script>
