<%@ 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("canadmemailupdate")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf Request.Form ("id")="" Then
	ef=True
	ec="请选择产品！"
ElseIf Instr(1, Request.Form ("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request.Form ("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf not IsNumeric(Request.Form ("hosttypeAuto"))  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_Email 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="Email不存在！"
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 dshostold = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_EmailProductlist where Emailtype='"&dsph ("Emailtype")&"'"
	dshostold.Open Sql,conn,1,1
if dshostold.Eof then
	ef=True
	ec="旧产品类型不存在！"
end if
end if


if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerEmaillist 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
	Set dshost = Server.CreateObject("ADODB.Recordset")	
	'新产品类别
	Sql="Select * from FreeHost.FreeHost_EmailProductlist where id='"&Request.Form ("hosttypeAuto")&"'"
	dshost.Open Sql,conn,1,1
if dshost.Eof then
	ef=True
	ec="新的产品类型不存在！"
Else
newhosttype=dshost("emailtype")
NewtypePrice=dshost("usermoney")'新产品价格
End If
End If



if not ef Then
olduser_money=ds("usermoney")
oldtime=dsph ("endtime")
starttime=dsph ("endtime")
pdtype=dsph("Emailtype")

moneych=0
oldtime=dsph ("endtime")


If dsph ("Emailtype")<>newhosttype Then'类型变更

'response.write "类型变"

typechange=true
pdtype="原类型："&dsph ("Emailtype")&" 新类型："&newhosttype
FreeHost_oplog session("admusername"),"信息","管理员修改邮箱，("&dsph ("id")&")原类型:"&dsph ("Emailtype")&"新类型:"&newhosttype
dsph ("Emailtype")=newhosttype
dsph.update
If Request.Form ("chmoneyauto")<>"" Then
'变更金额
if Request.Form ("usermoneyauto")<>"" then'手工指定变更金额
ds("usermoney")=ds("usermoney")-Request.Form ("usermoneyauto")
moneych=-Request.Form ("usermoneyauto")
'response.write "---手工设置"
else'计算差价


daytoend=DateDiff("d",NOW,dsph("endtime"))
if daytoend<0 Then daytoend=0
if dsph("istest")="y" then  daytoend=0
oldusermoneyleft=dshostold("usermoney")/365*daytoend
if oldusermoneyleft<0 then oldusermoneyleft=0'防止出现特殊情况
newtypeusemoneyforuser=NewtypePrice/365*daytoend'计算新产品价格
oldusermoneytake=newtypeusemoneyforuser-oldusermoneyleft
ds("usermoney") =ds("usermoney")-Fix(oldusermoneytake)
moneych=-Fix(oldusermoneytake)

end if
end if

end if

newuser_money=ds("usermoney")
'moneych=newuser_money-olduser_money
temptime=dsph ("endtime")
ds.update

if Request.Form ("istestch1")="y" then
dsph("status")="正常"
dsph("istest")="n"
dsph.update
FreeHost_oplog session("admusername"),"信息","管理员修改邮箱，("&dsph ("id")&") 将试用的改成正式的"
end If




'更新产品类别
dsph ("Emailtype")=dshost("Emailtype")
dsph ("emailcount")=dshost("emailcount")
dsph ("userspacelimt")=dshost("userspacelimt")
dsph ("domainspacelimt")=dshost("domainspacelimt")
dsph ("domainmustsame")=dshost("domainmustsame")


dsph("status")="正常"
starttime=dsph ("endtime")
temptime=dsph ("endtime")
dsph.update

isadd="y"
If newuser_money<olduser_money Then isadd="n"

If moneych<>0 Then FreeHost_moneyNewlog conn,"y","n","y","n",isadd,isAgnHostSer,abs(moneych),dsph ("username"),session("admusername"),dsph ("username"),olduser_money,newuser_money,agnusername,agnStmoney,agnEndmoney,session("admusername"),"管理员升级邮箱产品("&dsph ("id")&")","管理员升级邮箱产品("&dsph ("id")&")","邮箱产品",dsph("id"),pingzheng,type1,bank,haveget,havecheck

'FreeHost_moneyNewlog conn,                 isuser,isagn,issup,ishand,isadd,isAgnHostSer,moneyX,username,opusername,norusername,norStmoney,norEndmoney,agnusername,agnStmoney,agnEndmoney,supusername,forwhat,corewhat,whichProduct,pdid,pingzheng,type1,bank,haveget,havecheck

'FreeHost_oplog session("admusername"),"信息","管理员完成升级邮箱操作,("&dsph ("id")&")"




Set dspdallemail = Server.CreateObject("ADODB.Recordset")	
		Sql="Select top 1 * from FreeHost.FreeHost_Product_ALLEmail where username='"&ds ("username")&"' and PdEID='"&dsph ("id")&"'"
		dspdallemail.Open Sql,conn,1,3
if not dspdallemail.Eof then
emailname=trim(dspdallemail("emailname"))
emailarry=split(emailname,"@")
name1=emailarry(0)
domain=lcase(trim(emailarry(1)))
op=0
temp2=PauseEmail(dsph ("ServerlistID"),dspdallemail("emailname"),op)
tem=ModAdmEmail(dsph ("ServerlistID"),trim(dspdallemail("emailname")),domain,dsph ("emailcount"),dsph ("domainspacelimt")*1024)'maxuser
end if




%>
<!--#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"><br>
<br>
        受控端返回信息：<%=temp2%> <%=tem%> <br>
<br>

</div>
                <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"><%=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"><%=newhosttype%></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="37"><font color="#000000"> 　　　 现在的到期时间是:</font></td>
                      <td colspan="3"><%=temptime%></td>
                    </tr>
                    <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%>
