<%@ Language=VBScript %>
<%
Function SystemTest(URL)
  Dim returnstr
	Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.setTimeouts FreeHost_t1, FreeHost_t2, FreeHost_t3, FreeHost_t4
xml.Open "GET", "http://"&Url&"/autorun/maindo.asp", False
xml.send
returnstr = bytes2BSTR(xml.responsebody)
	Set xml = Nothing
  SystemTest = returnstr
End Function

Function bytes2BSTR(vIn)
    strReturn = ""
    For i = 1 To LenB(vIn)
        ThisCharCode = AscB(MidB(vIn,i,1))
        If ThisCharCode < &H80 Then
            strReturn = strReturn & Chr(ThisCharCode)
        Else
            NextCharCode = AscB(MidB(vIn,i+1,1))
            strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + Clng(NextCharCode))
            i = i + 1
        End If
    Next
    bytes2BSTR = strReturn
End Function


If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseif not Application("canagnrar")=true then
	ef=True
	ec="管理员设置不允许打包下载。"
end if
if not ef then%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%>　模板打包下载
<%=htmlwrite("html6")%>
<%
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AgentRaR where  username='"&session("agentusername")&"'"
		ds.Open Sql,conn,1,3
if Request("op")="donow" and Not ds.eof then%>
<br><br>
打包命令正在处理中，请不要重复操作。
<%end if

if Request("op")="delete" and Not ds.eof Then
ds.delete
ds.update
ds.Requery
End If

if Request("op")="donow" and ds.eof Then

If IsNumeric(Request("site")) then
Set dsagentdomain = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_ALLdomain where id='"&Request("site")&"' order by id asc"
		dsagentdomain.Open Sql,conn,1,1
If not dsagentdomain.eof Then

'检查域名是否能解析访问
On Error Resume next
ret=SystemTest(dsagentdomain("domain"))

If ret="at:" then


ds.addnew
ds("username")=session("agentusername")
ds("sendtime")=now
ds("status")="处理中"
ds("site1")=dsagentdomain("domain")
ds("site2")=dsagentdomain("domain")
ds.update
ds.Requery
Else%>
<br>
<br>
<font color=red>不能访问您所指定的域名<%=dsagentdomain("domain")%>，请检查有没有解析好到现在的IP上。</font>
<br>
<%End if

End If
End if

end if

%>
<br>
<br>
<DIV class="tableborder" id="table1">
<table width="100%"  border="0" cellspacing="1">
  <tr >
    <td height="24" align="center" background="img/tablebg.gif"><font color="#FFFFFF">代理名</font></td>
    <td height="24" align="center" background="img/tablebg.gif"><font color="#FFFFFF">时间</font></td>
    <td align="center" background="img/tablebg.gif"><font color="#FFFFFF">状态</font></td>
    <td align="center" background="img/tablebg.gif"><font color="#FFFFFF">操作</font></td>
  </tr>
  <tr bgcolor="#E4EAF2">
    <td width="9%" height="40" align="center" bgcolor="#E4EAF2"><%=session("agentusername")%></td>
    <td width="23%" align="center"><%If not ds.Eof Then%><%=ds("sendtime")%><%end if%></td>
    <td width="23%" align="center"><%If not ds.Eof Then%><%=ds("status")%><%end if%></td>
    <td width="45%" align="center"><%If ds.Eof Then%>
<form action="agentrar.asp" method="post">
    选择基于
      <select name="site">
<%
	Set dsagentdomain = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_ALLdomain where username='"&session("agentusername")&"' order by id asc"
		dsagentdomain.Open Sql,conn,1,1
while not dsagentdomain.eof%>

 <option value="<%=dsagentdomain("id")%>"><%=dsagentdomain("domain")%></option>
<%
dsagentdomain.movenext
wend
%>
</select>
<input name="op" type="hidden" value="donow">
      域名来生成网站文件，<input name="submit" type="submit" value="点击现在生成">
</form>		  
      <%else%>
	  <%If ds("status")="已完成" Then%><br>
      <a href="/agphoto/<%=session("agentusername")%>.rar">马上下载打包好的文件</a><br><br>
	  <a href="agentrar.asp?op=delete">删除打包好的文件，重来</a><br><br>
      <%else%><br>
	  请等候十分钟再来下载。<br>
	  <a href="agentrar.asp?op=delete">删除重来>>></a><br><br>
      <%end if%>
      <%end if%></td>
  </tr>
</table>
</div>
<br>
您可以使用本功能将模板文件打包下载，下载后您可以将文件解压，解压后的文件就是一个完整的网站，您可以上传到任何虚拟主机中使用。
<%=htmlwrite("html7")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
