<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request("username")=""  or RegExpTest("[^A-Za-z0-9]",Request("username")) Then
	ef=True
	ec="请输入用户名！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="ID应该是数字！"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where  (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') and username='"&Request("username")&"'"
				if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		ds.Open Sql,conn,1,1
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end If

if not ef then
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&ds("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,3
If dsagent.Eof Then
		ef=True
		ec="代理会员名不存在或密码出错了！"
end if
end if

if not ef then
	Set dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_HostProductlist where id='"&Request("id")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dshost.Open Sql,conn,1,1
if dshost.Eof then
	ef=True
	ec="产品不存在！"
Else

'读取月付
PAY_Month=dshost("PAY_Month")
PAY_Season=dshost("PAY_Season")
PAY_halfyear=dshost("PAY_halfyear")
PAY_Nextyear=dshost("PAY_Nextyear")
PAY_2year=dshost("PAY_2year")
PAY_3year=dshost("PAY_3year")
PAY_4year=dshost("PAY_4year")
PAY_5year=dshost("PAY_5year")

ServerlistID=dshost ("ServerlistID")
if ds("agent1")<>"n" then
	Set agnserverid = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_HostProductlist_AGN where id='"&dshost ("id")&"' and agent1='"&ds("agent1")&"'"
	agnserverid.Open Sql,conn,1,1
dim isAgnHostSer
if not agnserverid.Eof then
if agnserverid ("ServerlistID")<>0 then
ServerlistID=agnserverid ("ServerlistID")
isAgnHostSer=true
else
isAgnHostSer=false
end if
end if
end if'isagn
end if
end if

if not ef then
	Set dsHostlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_HostProductlist where id='"&Request("id")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHostlist.Open Sql,conn,1,1
if dsHostlist.Eof then
	ef=True
	ec="产品不存在！"
end if
end if

if not ef then
	Set dsServerlist = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Serverlist where id='"&ServerlistID&"'"
		dsServerlist.Open Sql,conn,1,1
if dsServerlist.Eof then
	ef=True
	ec="服务器为空！"
end if
end if

if not ef then
	Set dsagnettype = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Agent_pers where agenttype='"& session("agenttype")&"'"
		dsagnettype.Open Sql,conn,1,1
if dsagnettype.Eof then
	ef=True
	ec="代理类型折扣为空，请先设置它！"
end if
end if


if not ef then

	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='虚拟主机' and username='"&session ("agentusername")&"' and id="&dsHostlist("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
myrealcost=dsHostlist("usermoney")*dsagnettype("pers")
else
myrealcost=dsagnpri("usermoney")
end if
dsagnpri.close

	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='虚拟主机' and username='"&session("agentusername")&"' and id="&dsHostlist("id")&""
		dsendmoney.Open Sql,conn,1,1
'		response.write sql
if dsendmoney.eof then
usermoney=dsHostlist("usermoney")
else
usermoney=dsendmoney("usermoney")
end if
dsendmoney.close

myrealcost=Clng(FormatNumber(myrealcost,0,-1,0,0))'四舍五入'2011-8-29
'usermoney=Clng(FormatNumber(usermoney,0,-1,0,0))'四舍五入

%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%>
 　开通虚拟主机
 <%=htmlwrite("html6")%>
 <%
	


  homedir=dsServerlist("homedir") 

AccessFlags=1
if dsHostlist("asp")="y" then
AccessFlags=513
ScriptMaps=dsServerlist("asp") 
end if
if dsHostlist("aspx")="y" then
AccessFlags=513
ScriptMaps=ScriptMaps&"|"&dsServerlist("aspx") 
end if
if dsHostlist("cgi")="y" then
AccessFlags=517
ScriptMaps=ScriptMaps&"|"&dsServerlist("cgi") 
end if
if dsHostlist("php")="y" then
AccessFlags=513
ScriptMaps=ScriptMaps&"|"&dsServerlist("php") 
end if
if dsServerlist("infosafe")<>"" And AccessFlags>1 then
ScriptMaps=ScriptMaps&"|"&dsServerlist("infosafe") 
end if
ScriptMaps=trim(replace(ScriptMaps,"||","|"))

  %>
<%session("ServerlistID")=dsHostlist("ServerlistID")%>
<%session("homedir")=homedir%>
<%session("DefaultDoc")=""%>
<%session("LogFileDirectory")=LogFileDirectory%>
<%session("AccessFlags")=AccessFlags%>
<%session("ScriptMaps")=ScriptMaps%>
<%session("HttpErrors")=HttpErrors%>
<br>用户名：<%=ds("username")%>
<br>余额：<%if trim(lcase(Request("username")))<>trim(lcase(session("agentusername"))) then%><%=ds("usermoney")%><%else%><%=dsagent("usermoney")%><%End if%> 元
<br>
电子邮件：<a href=mailto:<%=ds("email")%>><font color="#000000"><%=ds("email")%></font></a> <br>
QQ：<%=ds("qq")%>
<br>中文名：<%=ds("truename")%>
<br>联系地址：<%=ds("address")%>
<br>电话：<%=ds("tel")%>
<br>注册ip：<%=ds("regip")%>
<br>注册时间：<%=ds("regtime")%>

              <form action="admhost3.asp" method="post" name="autoopen">
 <input name="username" type="hidden" size="30" value="<%=ds("username")%>">
 <table width="100%"  border="0" cellspacing="1" bgcolor="#000000">
   <tr>
     <td width="9%" height="56" rowspan="2" bgcolor="#FAFAFA">
	 <p><%if isAgnHostSer=true then%>
	   <br>
　<font color=red><b>独立模式产品</b></font><br>	 
　分配的空间大小：
<input name="spacelimit" type="text" id="spacelimit" size="4" value="<%=dshost("spacelimt")%>">
M IIS连接数：
<input name="MaxConnections" type="text" id="MaxConnections" size="8" value="<%=dshost("MaxConnections")%>">
(4294967295表示无限制)<br>
　多少用户共用一个应用程序池(IIS6):
<input name="AppPoolnum" type="text" id="AppPoolnum" size="3" value="<%=dshost("AppPoolnum")%>">
<br>
　带宽上限(IIS 6)：
<input name="MaxBandwidth" type="text" id="MaxBandwidth" size="10" maxlength="10" value="<%=dshost("MaxBandwidth")%>">
字节/秒(默认是4294967295表示无限制)
<br>
　手工指定到期时间:
<input type="text" name="endtime" size="10" maxlength="10">
2005-7-24<br>
<!--　默认首页:
<input name="DefaultDoc" type="text" id="host1" size="30" value="">
<br>
　日志目录:
<input name="LogFileDirectory" type="text" id="host1" size="30" value="">
<br>
　AccessFlags:
<input name="AccessFlags" type="text" id="host1" size="5" value="<%=AccessFlags%>">
1为静态网页，513为asp/aspx/php,517为cgi<br>
　修改应用程序影射:
<textarea name="ScriptMaps" cols="50" id="host1"><%=ScriptMaps%></textarea>
<br>
　修改自定义错误:
<textarea name="HttpErrors" cols="50" id="host1"><%=HttpErrors%></textarea>-->
<%end if%><br>
<!--　       　域名：
                  <input name="hostname1" type="text" id="host1" size="30" onBlur="doicpcheck(this.value);">
                  <br>
域名二：
<input name="hostname2" type="text" id="host1" size="30">
<br>
　域名三：
<input name="hostname3" type="text" id="host1" size="30">
<br>
　域名四：
<input name="hostname4" type="text" id="host1" size="30">
<br>
　域名五：
<input name="hostname5" type="text" id="host1" size="30">
<br>
　(如果不指定将自动生成临时域名)<br>-->
　FTP用户名：
<input name="Ftpname" type="text" id="Ftpname" value="<%if Request("Ftpname")="" then%><%=ds("username")%><%else%><%=Request("Ftpname")%><%end if%>" size="10" maxlength="14">
<br>

　
<input type="radio" name="year" value="999"  onClick="document.autoopen.usermoney.value =0;" <%if Clng(Request("year"))=999 then%>checked<%end if%>>
试用<%=Application("testtime")%>天
<input type="radio" name="year" value="<%=PAY_Month%>" onClick="document.autoopen.usermoney.value =Math.round(<%=PAY_Month*usermoney%>);" <%if Clng(Request("year"))=PAY_Month then%>checked<%end if%>>
一个月
<input type="radio" name="year" value="<%=PAY_Season%>" onClick="document.autoopen.usermoney.value =Math.round(<%=PAY_Season*usermoney%>);" <%if Clng(Request("year"))=PAY_Season then%>checked<%end if%>>
一季
<input type="radio" name="year" value="<%=PAY_halfyear%>" onClick="document.autoopen.usermoney.value =Math.round(<%=PAY_halfyear*usermoney%>);" <%if Clng(Request("year"))=PAY_halfyear then%>checked<%end if%>>
半年
<input type="radio" name="year" value="1" checked onClick="document.autoopen.usermoney.value =1*<%=usermoney%>;" <%if Clng(Request("year"))=1 then%>checked<%end if%>>
一年
<input type="radio" name="year" value="<%=PAY_2year%>" onClick="document.autoopen.usermoney.value =Math.round(<%=PAY_2year%>*<%=usermoney%>);" <%if Clng(Request("year"))=PAY_2year then%>checked<%end if%>>
两年
<input type="radio" name="year" value="<%=PAY_3year%>" onClick="document.autoopen.usermoney.value =Math.round(<%=PAY_3year%>*<%=usermoney%>);" <%if Clng(Request("year"))=PAY_3year then%>checked<%end if%>>
三年
<input type="radio" name="year" value="<%=PAY_4year%>" onClick="document.autoopen.usermoney.value =Math.round(<%=PAY_4year%>*<%=usermoney%>);" <%if Clng(Request("year"))=PAY_4year then%>checked<%end if%>>
四年
<input type="radio" name="year" value="<%=PAY_5year%>" onClick="document.autoopen.usermoney.value =Math.round(<%=PAY_5year%>*<%=usermoney%>);" <%if Clng(Request("year"))=PAY_5year then%>checked<%end if%>>
五年 <br>
<%if isAgnHostSer=false then%>
　请选择机房：　<%
	Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Serverlist order by orderbyid desc"
		dsX.Open Sql,conn,1,1
If dsX.Eof Then%>
服务器列表为空.
<%else%>
<select name="ServerlistID" id="ServerlistID">
<%while not dsX.Eof%>
<%if dshost("ServerlistID")=dsX("id") or dshost("ServerlistID2")=dsX("id") or dshost("ServerlistID3")=dsX("id") or dshost("ServerlistID4")=dsX("id") or dshost("ServerlistID5")=dsX("id") then%>
  <option value="<%=dsX("id")%>" <%if Request("ServerlistID")=cstr(dsX("id")) then%>selected<%end if%>><%=dsX("netby")%></option>
<%end if%> 
<%
dsX.movenext
wend%>
</select>
<%end if%>
 <br><br>
<%end if%>
 <input name="Hosttype" type="hidden" size="8" value="<%=dsHostlist("id")%>">
　将要开通的产品为：<b><%=dsHostlist("Hosttype")%></b> <%if isAgnHostSer=true then%><font color=red>成本价格:0 元/年</font><%else%>成本价格:<%=myrealcost%> 元/年<%end if%> 我的零售价格:<%=usermoney%> 元 /年<br>
　
<%if trim(lcase(Request("username")))<>trim(lcase(session("agentusername"))) then%><input name="chmoney" type="checkbox" id="chmoney" value="y">
<font color="#FF0000">从用户金额中扣除</font>(不选将以成本价扣除代理自己的钱) 价格：
<input name="usermoney" type="text" id="usermoney" value="<%=usermoney%>" size="4" maxlength="4">
元<br>
<%else%>
<input name="usermoney" type="hidden" value="0">
<%end if%>
<%
	Set dsSqlpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_SqlProductlist where Hosttype='"&dsHostlist("Hosttype")&"' and isbyhost='y'"
	dsSqlpdlist.Open Sql,conn,1,1
if not dsSqlpdlist.Eof Then
havesql=true%>
　　附送：
<select name="dsSqlpdlistID">
  <%end if%>
  <%while not dsSqlpdlist.Eof
	Set dsSqlserver = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Serversqllist where id='"&dsSqlpdlist ("ServerlistID")&"'"
		dsSqlserver.Open Sql,conn,1,1
while not dsSqlserver.Eof

if dsSqlserver("softtype")="SQL2000" and dsSqlserver("MSSQLver")="2000" then softtype="SQL2000"
if dsSqlserver("softtype")="SQL2000" and dsSqlserver("MSSQLver")="2005" then softtype="SQL2005"
if dsSqlserver("softtype")="SQL2000" and dsSqlserver("MSSQLver")="2008" then softtype="SQL2008"
if dsSqlserver("softtype")="SQL2000" and dsSqlserver("MSSQLver")="2012" then softtype="SQL2012"
if dsSqlserver("softtype")="SQL2000" and dsSqlserver("MSSQLver")="2014" then softtype="SQL2014"
if dsSqlserver("softtype")="MySQL" and dsSqlserver("MySQLver")="5.0" then softtype="MySQL5.0"
if dsSqlserver("softtype")="MySQL" and dsSqlserver("MySQLver")="5.1" then softtype="MySQL5.1"
if dsSqlserver("softtype")="MySQL" and dsSqlserver("MySQLver")="5.5" then softtype="MySQL5.5"

%>
  <option value="<%=dsSqlpdlist("id")%>"><%=softtype%> [大小<%=dsSqlpdlist("userspacelimt")%>M]</option>
  <%dsSqlserver.movenext
wend
dsSqlserver.close
dsSqlpdlist.movenext
wend%>
  <%If havesql=True then%>
</select>
注意选择后不能更改
<%End if%>
<%dsSqlpdlist.close%>
<br>
　内部记录：
<input name="corewhat" type="text" id="corewhat" size="70" maxlength="200">
<br>
　

<input name="tiaokuan" type="checkbox" value="y" checked>
我已阅读并同意了<a href="/user/tiaokuan.asp" target="_blank"><b>《服务条款》</b></a>　　
<input name="openX" type="submit" value="下一步" onClick="document.autoopen.openX.value ='请等待不要重复刷新！....';document.autoopen.openX.disabled=true;document.autoopen.submit()">
<br>
</p>
       <p></p>
      <p>&nbsp;    </p></td>
   </tr>
 </table>
              </form>
<%if Request("year")<>"" then%>
<script language="JavaScript" type="text/JavaScript">
document.autoopen.usermoney.value =Math.round(<%=Request("year")%>*<%=usermoney%>);
//autoopen.hostname1.value='<%=Request("ftpname")%>'+'.<%=tempdomain%>';
</script>
<%end if%>
<%=htmlwrite("html7")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
