<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("canadmhostset")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf Request.Form ("id")="" Then
	ef=True
	ec="请选择产品！"
ElseIf not IsNumeric(Request.Form ("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
elseif trim(Request.Form ("starttime"))<>"" And trim(Request.Form ("endtime"))="" Then
	ef=True
	ec="手工指定开通时间时，必须填写到期时间及扣除金额！"
ElseIf not IsDate(Request("starttime")) and Request("starttime")<>""  Then
	ef=True
	ec="请输入合法的开始日期！"
ElseIf not IsDate(Request("endtime")) and Request("endtime")<>""  Then
	ef=True
	ec="请输入合法的到期日期！"
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='"&Request.Form ("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,3
if dsph.Eof then
	ef=True
	ec="host不存在！"
end if
end if

if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&dsph("username")&"'"
		ds.Open Sql,conn,1,3
if ds.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 hosttype='"&dsph ("hosttype")&"'"
	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")
if dsph("istest")="y" then PAY_Nextyear="1"
PAY_2year=dshost("PAY_2year")
PAY_3year=dshost("PAY_3year")
PAY_4year=dshost("PAY_4year")
PAY_5year=dshost("PAY_5year")
end if
end if

if not ef then
If Request.Form ("year")<>PAY_Month and Request.Form ("year")<>PAY_Season  and Request.Form ("year")<>PAY_halfyear and Request.Form ("year")<>PAY_2year and Request.Form ("year")<>PAY_3year and Request.Form ("year")<>PAY_4year and Request.Form ("year")<>PAY_5year and Request.Form ("year")<>PAY_Nextyear Then
	ef=True
	ec="请选择时间！"
end If
end If

if not ef then
if dsph("istest")="y" then
MaxConnections=dshost ("MaxConnections")
spacelimit=dshost ("spacelimt")
MaxBandwidth=dshost("MaxBandwidth")
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
end if
end if

if not ef then
if Request.Form ("endtime")<>"" and Request.Form ("usermoney")="" then
	ef=True
	ec="手工指定时间必须填写扣除金额"
end if
end if

if not ef then
olduser_money=ds("usermoney")
if Request.Form ("usermoney")="" then
cost=dshost("usermoney")
cost=cost*Request.Form ("year")
else
cost=Clng(Request.Form ("usermoney"))
end If
if cost>ds("usermoney") then
	ef=True
	ec="很抱歉,用户的余额不足！共需:"&cost&"元"
end if
end if


if not ef then
'结束时间
oldtime=dsph("endtime")
if dsph("istest")="y" then  oldtime=now
y=Request.Form ("year")

if y=PAY_Nextyear then temptime=dateadd("yyyy",1,oldtime)
if y=PAY_2year then temptime=dateadd("yyyy",2,oldtime)
if y=PAY_3year then temptime=dateadd("yyyy",3,oldtime)
if y=PAY_4year then temptime=dateadd("yyyy",4,oldtime)
if y=PAY_5year then temptime=dateadd("yyyy",5,oldtime)

if y=PAY_Month then temptime=dateadd("y",31,oldtime)
if y=PAY_Season then temptime=dateadd("y",92,oldtime)
if y=PAY_halfyear then temptime=dateadd("y",182,oldtime)

if trim(Request.Form ("endtime"))<>"" then temptime=Request.Form ("endtime")
end if


if not ef then

'开始扣费
ds("usermoney") =ds("usermoney") -cost
ds.update
'更新产品类别
'dsph ("Hosttype")=dshost("Hosttype")
'if dsph("istest")="y" then
starttime=dsph ("endtime")

dsph ("endtime")=temptime
dsph("istest")="n"
dsph("emailstatus")=Null
dsph("smsstatus")=null


'end if
dsph.update
newuser_money=ds("usermoney")
temptime=dsph("endtime")
moneych=-cost

pdtype=dsph("hosttype")
logfor="超级管理员延期host("&dsph("Ftpname")&")"
if trim(Request.Form ("starttime"))<>"" then logfor="超级管理员修改开通host时间原时间:"&starttime&"新时间:"&Request.Form ("starttime")
if trim(Request.Form ("starttime"))<>"" then dsph ("starttime")=Request.Form ("starttime")

FreeHost_moneyNewlog conn,"y","n","y","n","n",isAgnHostSer,-moneych,dsph ("username"),session("admusername"),dsph ("username"),olduser_money,newuser_money,agnusername,agnStmoney,agnEndmoney,session("admusername"),"管理员延期虚拟主机",logfor,"虚拟主机",dsph("id"),pingzheng,type1,bank,haveget,havecheck


'送CDN
haveopenCDN=False
	Set dsCDNpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_CDNProductlist where id='"&dshost("CDNpdID")&"'"
	dsCDNpdlist.Open Sql,conn,1,1
if Not dsCDNpdlist.Eof Then
Set dsphCDN = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_CDN where username='"&dsph ("username")&"'"
	dsphCDN.Open Sql,conn,1,3
haveopenCDN=true
dsphCDN("endtime")=temptime
dsphCDN("status")="正常"
dsphCDN("kefu")=ds("kefunow")
dsphCDN.Update
End If


'开通邮箱
Set dsphemail = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Email where byhost='"&dsph("id")&"'"
	dsphemail.Open Sql,conn,1,3
if not dsphemail.Eof then
dsphemail("endtime")=temptime
dsphemail("status")="正常"
dsphemail("istest")="n"
dsphemail.update
retemail="赠送的邮箱产品已延期"
dsphemail.close
end if


'Sql

Set dsphSql = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Sql where byhost='"&dsph("id")&"'"
	dsphSql.Open Sql,conn,1,3
while not dsphSql.Eof
dsphSql("endtime")=temptime
dsphSql("istest")="n"
dsphSql("status")="正常"
dsphSql.update
retSql="赠送的数据库产品已延期"
	Set dsserverSQL = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerSqllist where id='"&dsphSql ("ServerlistID")&"'"
	dsserverSQL.Open Sql,conn,1,1
If Not dsserverSQL.eof then

dim softtype,MySQLver,MSSQLver
softtype=dsserverSQL("softtype")
MySQLver=dsserverSQL("MySQLver")
MSSQLver=dsserverSQL("MSSQLver")

FreeHostsharekey_SQL=dsserverSQL("FreeHostsharekey")
URL_SQL=dsserverSQL("site")
opport=dsserverSQL("port")
userid=dsserverSQL ("admname")
pwd=dsserverSQL("admpass")
sqlname=dsphSql("sqlname")
sqlpassword=dsphSql("sqlpassword")
op=0
temp=temp&PauseSQL(URL_SQL,FreeHostsharekey_SQL,userid,pwd,sqlname,sqlpassword,op)
'response.write ret
End if
dsphSql.movenext
wend
dsphSql.close


username=dsph("Ftpname")
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
tourl=dsserver("pauseweb")

dsph ("endtime")=temptime

dsph("emailstatus")=Null
dsph("smsstatus")=null

dsph("istest")="n"

endtime=dsph("endtime")
dsph.update
homedir=""
'on error resume next
'Response.Write

If ostype="windows" then
temp=ModifyUser2(URL,FreeHostsharekey,username,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)
End if


if dsph("status")="暂停" Or ostype="linux" Then
if dsph("beianstatus")="备案成功" Or (dsph("pausereason")<>4 and dsph("pausereason")<>2) then
op=0
'Response.Write 
temp=PauseSite(URL,FreeHostsharekey,username,tourl,op)
'Response.Write 
temp=temp&FTPOP(URL,FreeHostsharekey,username,0)'恢复FTP权限
dsph("status")="正常"
End if
dsph.update
end if

'处理子目录绑定
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where allowsubbyid='"&dsph("id")&"'"
	dsphsub.Open Sql,conn,1,3
while not dsphsub.eof
IISID=dsphsub("IISID")
op=0
if dsph("beianstatus")="备案成功" Or (dsph("pausereason")<>4 and dsph("pausereason")<>2) then
'Response.Write 
temp=temp&PauseSiteSub(URL,FreeHostsharekey,IISID,tourl,op)
dsphsub("status")="正常"
End if
dsphsub("endtime")=endtime
dsphsub.update
dsphsub.movenext
wend
dsphsub.close




%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html8")%>
<%=htmlwrite("html9")%>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0 background="img/midtop4.gif">
  <TBODY>
    <TR>
      <TD width=53 align="left" background="img/midtop1.gif"><strong> 　 </strong><font color="#FFFFFF">─<strong>&gt;</strong></font> </TD>
      <TD align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="90" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="admhost.asp"><font color="#FFFFFF"><strong>虚拟主机管理</strong></font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width="83">&nbsp;</TD>
      <TD width="83" align="left">&nbsp;</TD>
      <TD align="left">&nbsp;</TD>
      <TD width=23 align="right"><IMG height=59 
                  src="img/rtop4.jpg" 
                  width=19></TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=19 background="img/midlef.gif" id=rightid>&nbsp;</TD>
      <TD height="300" align="center" vAlign=top bgcolor="#FFFFFF">	  <table width="65%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><br>
              </td>
        </tr>
      </table>
        <br>
        <table width="65%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><br>
                <DIV class="tableborder">
                  <table width="100%"  border="0" align="center" cellpadding="2" cellspacing="1">
                    <tr align="center" bordercolor="#000000" bgcolor="#999999">
                      <td height="24" colspan="4" background="img/tablebg.gif"><font color="#990000"><font color="#FFFFFF">虚拟主机延期成功，以下是相关的资料</font></font></td>
                    </tr>
					                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td width="53%" height="30"><font color="#000000"> 　　　 受控端返回：</font></td>
                      <td width="47%" colspan="3"><%=temp%></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td width="53%" height="30"><font color="#000000"> 　　　 用户的原金额：</font></td>
                      <td width="47%" colspan="3"><%=olduser_money%> 元</td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="41"><font color="#000000">　　　 用户的金额变化：</font></td>
                      <td colspan="3"><font color=red><%=moneych%> 元</font></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="39"><font color="#000000">　　　 用户的新金额：</font></td>
                      <td colspan="3"><font color="#000000"><%=newuser_money%> 元</font></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="37"><font color="#000000"> 　　　 原来的到期时间是:</font></td>
                      <td colspan="3"><%=oldtime%></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="37"><font color="#000000"> 　　　 现在的到期时间是:</font></td>
                      <td colspan="3"><%=temptime%></td>
                    </tr>
<%if haveopenCDN then%>
    <tr bordercolor="#000000">
    <td height="60" bgcolor="#eeeeee"><font color="#000000"> 　　　 CDN说明：</font></td>
    <td bgcolor="#eeeeee"><a href="/user/sqladm.asp"><font color="#000000">附送的CDN产品已延期</font></a></td>
  </tr>
<%end if%>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="37" colspan="4" align="right" bgcolor="#E4EAF2"><font color="#000000"> 　　　</font><a href="#top"><font color="#6B9EDE" face="Arial, Helvetica, sans-serif">Top↑</font></a> </td>
                    </tr>
                  </table>
                </div>
                
            </td>
          </tr>
        </table></TD>
      <TD width=18 background="img/midri.gif">&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD width=30><IMG height=19 
                  src="img/rb1.jpg" 
                  width=30></TD>
      <TD 
                background=img/rb2.jpg>&nbsp;</TD>
      <TD width=30><IMG height=19 
                  src="img/rb3.jpg" 
                  width=30></TD>
    </TR>
  </TBODY>
</TABLE>
<%=htmlwrite("html10")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
