<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("HOSTAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。此功能只有代理可以操作。"
ElseIf not IsNumeric(session("HOSTAUID"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf Instr(1, Request("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
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 dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where id='"&session("HOSTAUID")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,1
if dsph.Eof then
	ef=True
	ec="不存在的虚拟主机ID！"
end if
end If

if not ef then
if dsph("agent1")<>session("agentusername") then
	ef=True
	ec="此虚拟主机ID并不是当前代理名下所有！"
end If
end if

if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') and username='"&dsph ("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 dsHostpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_HostProductlist where Hosttype='"&dsph("Hosttype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHostpdlist.Open Sql,conn,1,1
if dsHostpdlist.Eof then
	ef=True
	ec="产品不存在！"
Else
'读取月付
PAY_Month=dsHostpdlist("PAY_Month")
PAY_Season=dsHostpdlist("PAY_Season")
PAY_halfyear=dsHostpdlist("PAY_halfyear")
PAY_Nextyear=dsHostpdlist("PAY_Nextyear")
if dsph("istest")="y" then PAY_Nextyear="1"
PAY_2year=dsHostpdlist("PAY_2year")
PAY_3year=dsHostpdlist("PAY_3year")
PAY_4year=dsHostpdlist("PAY_4year")
PAY_5year=dsHostpdlist("PAY_5year")
end if
end If


if not ef then
if not isnull(dsph("repaymoney")) then
	ef=True
	ec="由于此产品被管理员设置了单独的续费价格，因此，请您联系管理员帮您手工升级。"
end if
end if

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serverlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
Else
	ostype=dsserver("ostype")'linux
dim isAgnHostSer
if dsserver("agent1")=dsph("agent1") then
isAgnHostSer=true
Else
isAgnHostSer=false
end if
end if
end if

if not ef then
%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
　代理 <%=session("agentusername")%> 管理名下用户 <%=dsph("username")%> 的虚拟主机 FTP用户名：<%=dsph("ftpname")%>


续费/升级<br>
<br>
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#C8DAFF" id="t1">
  <tr height="24">
    <td width="17%" align="right" bgcolor="#ECF2FF"> 用户名：</td>
    <td width="83%" align="left" bgcolor="#FAFAFA">　<a href="/agent/searchuser.asp?username=<%=ds("username")%>" target="_blank"><%=ds("username")%></a></td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 金额：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("usermoney")%> 元 </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 电子邮件：</td>
    <td align="left" bgcolor="#FAFAFA">　<a href=mailto:<%=ds("email")%>><font color="#000000"><%=ds("email")%></font></a> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> QQ：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("qq")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right">代理名：</td>
    <td align="left" bgcolor="#FAFAFA">　
        <%if ds("agent1")<>"n" then%>
        <a href="searchagent.asp?username=<%=ds("agent1")%>" target="_blank"><font color="blue"><%=ds("agent1")%></font></a>
        <%end if%></td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"><div align="right">中文名：</div></td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("truename")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 联系地址：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("address")%> 　邮编：<%=ds("postid")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 电话：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("tel")%> 　传真：<%=ds("fax")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 备注：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("coreinfo")%></td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 身份证号码：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("perid")%></td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 注册ip：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("regip")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 注册时间：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("regtime")%> </td>
  </tr>
</table>
<form action="agn-uphost-time.asp" method="post" name="autoopenY">
<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR align="center">
      <TD height="35" colspan="2" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">延长使用期限：</font></TD>
      </TR>
    <TR>
      <TD height="28" align="center" vAlign=middle bgColor=#FFFFFF>开通时间：<%=formatdatetime(dsph("starttime"),1)%></TD>
      <TD height="28" align="center" vAlign=middle bgColor=#FFFFFF>到期时间：<%=formatdatetime(dsph("endtime"),1)%></TD>
    </TR>
    <TR>
      <TD height="18" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF>延长：
        <input type="radio" name="year" value="<%=PAY_Month%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_Month%>*document.autoopenY.hidenusermoney.value);">
一个月
<input type="radio" name="year" value="<%=PAY_Season%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_Season%>*document.autoopenY.hidenusermoney.value);">
一季
<input type="radio" name="year" value="<%=PAY_halfyear%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_halfyear%>*document.autoopenY.hidenusermoney.value);">
半年
<input type="radio" name="year" value="<%=PAY_Nextyear%>" checked onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_Nextyear%>*document.autoopenY.hidenusermoney.value);">
一年
<input type="radio" name="year" value="<%=PAY_2year%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_2year%>*document.autoopenY.hidenusermoney.value);">
两年
<input type="radio" name="year" value="<%=PAY_3year%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_3year%>*document.autoopenY.hidenusermoney.value);">
三年
<input type="radio" name="year" value="<%=PAY_4year%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_4year%>*document.autoopenY.hidenusermoney.value);">
四年
<input type="radio" name="year" value="<%=PAY_5year%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_5year%>*document.autoopenY.hidenusermoney.value);">
五年</TD>
    </TR>
    <TR>
      <TD height="33" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF>        <%if isnull(dsph("repaymoney")) then%><%
agentname=session("agentusername")
'if dsph("username")=session("agentusername") then '操作自己的虚拟主机
	Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent where username='"&agentname&"'"
		dsagent.Open Sql,conn,1,1
if Not dsagent.eof then
Set dsagnettype = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Agent_pers where agenttype='"&dsagent("agenttype")&"'" 
		dsagnettype.Open Sql,conn,1,1
if Not dsagnettype.eof Then
canshowagnpric=True
Else
canshowagnpric=false
End if
end If
dsagent.close
'end If

usermoney=dsHostpdlist("usermoney")
if agentname<>"n" then
	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='虚拟主机' and username='"&agentname&"' and id="&dsHostpdlist("id")&""
		dsendmoney.Open Sql,conn,1,1
if not dsendmoney.eof then
usermoney=dsendmoney("usermoney")
end if
dsendmoney.close
end If%>用户价格：<%=usermoney%>元/年<input type="hidden" name="hidenusermoney" value="<%=usermoney%>"><%

if canshowagnpric then%>　　<font color=red>(代理成本价格
<%
	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='虚拟主机' and username='"&agentname&"' and id="&dsHostpdlist("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
usermoneyAGN=dsHostpdlist("usermoney")*dsagnettype("pers")
else
usermoneyAGN=dsagnpri("usermoney")
end if
dsagnpri.close
%>)</font><%End if%>
<%
If canshowagnpric And isAgnHostSer then%>
(<font color=red>当前此产品为独立模式产品</font>)
<%
usermoneyAGN=0
End if%>
<%=usermoneyAGN%><%else%>(单独设置的价格)　<%=dsph("repaymoney")%><%end if%> 元/年</TD>
    </TR>
<%if dsph("username")<>session("agentusername") Then'是否处理自己的虚拟主机%>
    <TR>
      <TD height="38" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF><input name="chmoney" type="checkbox" id="chmoney" value="y">
        <font color="#000000">从用户金额中自动扣除</font>(不选将以成本价扣除代理自己的钱) 价格：
        <input name="usermoney" type="text" id="usermoney" size="5" maxlength="5"  value="<%=usermoney%>">
元
</TD>
    </TR>
<%else%>
<input name="usermoney" type="hidden" id="usermoney" size="5" maxlength="5"  value="<%=usermoney%>">
<%End if%>
    <TR>
      <TD height="38" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF><input name="id" type="hidden" value="<%=session("HOSTAUID")%>">
        <input type="submit" name="Submit" value="马上续期"></TD>
    </TR>
  </TBODY>
</TABLE>
</form>
<form action="agn-uphost-type.asp" method="post" name="form1">
<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR align="center">
      <TD height="35" colspan="2" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">升级产品：</font></TD>
      </TR>
<%
	Set dsHostlist = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_HostProductlist where canbyenduser='y'  and (onlyusebyagn is null or onlyusebyagn='"&agentname&"') order by orderbyid desc"
if agentname<>"n" then Sql="Select * from FreeHost.FreeHost_HostProductlist where canbyagnenduser='y'  and (onlyusebyagn is null or onlyusebyagn='"&agentname&"') order by orderbyid desc"
		dsHostlist.Open Sql,conn,1,1
If dsHostlist.Eof Then%>
产品列表为空.
<%else
while not dsHostlist.Eof

If dsHostlist("cantwodb")=true Then
canselectdb=false
else
canselectdb=true
end if

usermoney=dsHostlist("usermoney")
if agentname<>"n" then
	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='虚拟主机' and username='"&agentname&"' and id="&dsHostlist("id")&""
		dsendmoney.Open Sql,conn,1,1
if not dsendmoney.eof then
usermoney=dsendmoney("usermoney")
end if
dsendmoney.close
end if
if (dsHostpdlist("updatebytypeid")="y" and dsHostlist("typeid")=dsHostpdlist("typeid")) or isnull(dsHostpdlist("updatebytypeid")) or dsHostpdlist("updatebytypeid")="n" then
%>
  
    <TR>
      <TD height="35" vAlign=middle bgColor=#FFFFFF><%isAgnHostSer=false
	info=dsHostlist("info")
	Hosttype=dsHostlist("Hosttype")
	Set newname_host = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_HostProductlist_AGN where agent1='"&agentname&"' and id='"&dsHostlist("id")&"'"
		newname_host.Open Sql,conn,1,1
if not newname_host.eof then
info=newname_host("info")
Hosttype=newname_host("Hosttype")
if newname_host ("ServerlistID")<>0 Then isAgnHostSer=True '这是独立模板的产品
newname_host.close
end if



%>　　<%=dsHostlist("id")%>.<input type="radio" name="Hostlistid" value="<%=dsHostlist("id")%>" <%If dsHostpdlist("id")=dsHostlist("id") then%>disabled<%End if%>>
      <%=Hosttype%><%If dsHostpdlist("id")=dsHostlist("id") then%><br>　　　　　当前类型<%End if%></TD>
      <TD height="35" align="center" vAlign=middle bgColor=#FFFFFF>出售价格：<%=usermoney%> 元 

<font color=red>(代理成本价格
<%'注意是dsHostlist 2个地方
	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='虚拟主机' and username='"&agentname&"' and id="&dsHostlist("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
usermoneyAGN=dsHostlist("usermoney")*dsagnettype("pers")
else
usermoneyAGN=dsagnpri("usermoney")
end if
dsagnpri.close
%>)</font>
<%
If isAgnHostSer then%>
(<font color=red>当前此产品为独立模式产品</font>)
<%
usermoneyAGN=0
End if%>
<%=usermoneyAGN%>元
	  
	  　<a href="/style/info/hostmore.asp?id=<%=dsHostlist("id")%>" target="_blank"><font color="#000000">详细介绍</font></a><br>
	  <%
If canselectdb then
	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<%=dsHostlist("id")%>">
  <%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%>
  <option value="<%=dsSqlpdlist("id")%>"><%=dsSqlserver("softtype")%> [大小<%=dsSqlpdlist("userspacelimt")%>M]</option>
  <%dsSqlserver.movenext
wend
dsSqlserver.close
dsSqlpdlist.movenext
wend%>
  <%If havesql=True then%>
</select>
注意选择后不能更改
<%End if%>
<%dsSqlpdlist.close

End if
%>
</TD>
    </TR>
<%
end if
dsHostlist.movenext
wend
dsHostlist.close
set dsHostlist=nothing
end if%>	
<%if dsph("username")<>session("agentusername") Then'是否处理自己的虚拟主机%>
    <TR>
      <TD height="38" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF><input name="chmoney" type="checkbox" id="chmoney" value="y">
        <font color="#000000">手工强行指定从用户金额中扣除</font>：
        <input name="usermoney" type="text" id="usermoney" size="4" maxlength="4"  value="0">
元
(不选将时按正常扣除用户费用)</TD>
    </TR>
<%else%>
<input name="usermoney" type="hidden" id="usermoney" size="5" maxlength="5"  value="<%=usermoney%>">
<%End if%>
    <TR>
      <TD height="38" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF><input name="id" type="hidden" value="<%=session("HOSTAUID")%>">
        <input type="submit" name="Submit" value="只计算升级费用">
        　
        <input type="submit" name="Submit" value="马上升级到此产品"></TD>
    </TR>
</TABLE>
</form>

<br>
<br>

　<a href="selfhostmodify.asp?id=<%=session("HOSTAUID")%>"><font color="#000000">[返回上一页]</font></a>
<!--#include virtual="/inc-freehost-function/template-hostadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>