<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("username")="" Then
	ef=True
	ec="请您先登陆用户区，再续费，在主机面板中不能续费。也有可能是超时造成了出错。"
ElseIf Request("id")="" 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")

agentname=session("agentname")
if session("AgnRunasUser")=True 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

	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where id='"&Request("id")&"'"
	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
	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
	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="服务器不存在！"
end if
end If

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

if not ef then
%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
　虚拟主机自助管理


<br>
<form action="selfhostmodifyendtime.asp" method="post" name="autoopen">
<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="17" align="center" vAlign=middle bgColor=#FFFFFF>开通时间：<%=formatdatetime(dsph("starttime"),1)%></TD>
      <TD align="center" vAlign=middle bgColor=#FFFFFF>到期时间：<%=formatdatetime(dsph("endtime"),1)%></TD>
    </TR>
    <TR>
      <TD height="18" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF><div align=center>
<%if isnull(dsph("repaymoney")) then%><%
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

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
usermoney=dsHostpdlist("usermoney")*dsagnettype("pers")
else
usermoney=dsagnpri("usermoney")
end if
dsagnpri.close
%>)</font><%End if%>
<%
If canshowagnpric And isAgnHostSer then%>
(<font color=red>当前此产品为独立模式产品</font>)
<%
usermoney=0
End if%>
<%
'=usermoney
%><%else%>(管理员单独设置过此产品的续费价格)　<%
'=dsph("repaymoney")
usermoney=dsph("repaymoney")
%><%end if%></div><br>
	  
	  延长：
        <%if dsHostpdlist("canmonth")="y" then%>
        <input type="radio" name="year" value="<%=PAY_Month%>" onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_Month*usermoney%>);">
一个月
<%end if%>
<%if dsHostpdlist("canseason")="y" then%>
<input type="radio" name="year" value="<%=PAY_Season%>" onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_Season*usermoney%>);">
一季
<%end if%>
<%if dsHostpdlist("canhalfyear")="y" then%>
<input type="radio" name="year" value="<%=PAY_halfyear%>" onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_halfyear*usermoney%>);">
半年
<%end if%>
<input type="radio" name="year" value="<%=PAY_Nextyear%>" checked onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_Nextyear%>*<%=usermoney%>);" >
一年
<input type="radio" name="year" value="<%=PAY_2year%>"  onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_2year%>*<%=usermoney%>);" >
两年
<input type="radio" name="year" value="<%=PAY_3year%>" onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_3year%>*<%=usermoney%>);" >
三年
<input type="radio" name="year" value="<%=PAY_4year%>" onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_4year%>*<%=usermoney%>);" >
四年
<input type="radio" name="year" value="<%=PAY_5year%>" onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_5year%>*<%=usermoney%>);">
五年 <br>
<br>
</TD>
    </TR>
    <TR>
      <TD height="33" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF> 扣费：        
        <input name="moneynow" type="text" value="<%=PAY_Nextyear*usermoney%>" size="8" readonly="true" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px;text-align: right"> 
元</TD>
    </TR>
    <TR>
      <TD height="28" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF><input name="id" type="hidden" value="<%=Request("id")%>">
        <input type="submit" name="openX" value="马上续期" onClick="document.autoopen.openX.value ='请等待不要重复刷新！....';document.autoopen.openX.disabled=true;document.autoopen.submit()"></TD>
    </TR>
  </TBODY>
</TABLE>
</form>

　<a href="selfhostmodify.asp?id=<%=Request("id")%>"><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%>
