<%@ Language=VBScript %>
<%
selectedserverid=0'默认首选的服务器ID
If session("agentusername")<>"" Then Response.Redirect "/agent/admCDN2.asp?username="&session("agentusername")&"&id="&Request.QueryString ("id")
If session("username")="" Then
If Application("hpsystem")=false  And Application("canuseorder")=true and Request.ServerVariables("HTTP_FreeHostAPI")<>"7i24.com" Then Response.Redirect "order.asp?type=CDN产品&id="&Request.QueryString ("id")
	ef=True
	ec="请您先登陆会员区。"
ElseIf Request.QueryString ("id")="" Then
	ef=True
	ec="请选择产品！"
ElseIf Instr(1, Request.QueryString ("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request.QueryString ("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsHostpdlist = Server.CreateObject("ADODB.Recordset")

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

	Sql="Select * from FreeHost.FreeHost_CDNProductlist where id='"&Request.QueryString ("id")&"'"
	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")
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 agentname<>"n" then
	Set agnserverid = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_CDNProductlist_AGN where id='"&dsHostpdlist ("id")&"' and agent1='"&agentname&"'"
	agnserverid.Open Sql,conn,1,1
dim isAgnHostSer
if not agnserverid.Eof then
isAgnHostSer=false
end if
end if
end if

if not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>
　CDN自助开通
<%=htmlwrite("html3")%>
<br>
<form action="selfCDN2.asp" method="post" name="autoopen">
  <table 
            width="600" border=1 align=left cellpadding=0 cellspacing=0 bordercolorlight=#cccccc bordercolordark=#fbfbfb>
    <tbody>
      <tr>
        <td width="105" height="40" valign=middle bgcolor=#9E9E9E>&nbsp; <font color="#FFFFFF">填写资料：</font></td>
        <td width="118" rowspan="2" bgcolor=#ffffff><font color="#000000">　CDN　自命名：</font>        </td>
        <td width="369" rowspan="2" bgcolor=#ffffff><input name="CDNname" type="text" id="CDNname" size="10" maxlength="14">
        (3至14个字母)</td>
      </tr>
      <tr>
        <td width="105" rowspan="4" valign=middle bgcolor=#EEEEEE>&nbsp;</td>
      </tr>
      <tr>
        <td height="50" bgcolor=#ffffff><font color="#000000">　CDN管理密码：</font>          </td>
        <td width="369" height="50" bgcolor=#ffffff><input name="CDNpassword" type="password" id="CDNpassword" size="10" maxlength="14">
        (3至14个字母或数字)</td>
      </tr>
      <tr>
        <td height="40" bgcolor=#ffffff><font color="#000000">　有效期限：</font></td>
        <td bgcolor=#ffffff><select name="year"  onChange="chusrm(this.options[this.options.selectedIndex].value)">
            <option value="0" selected>请您选择</option>
            <%if dsHostpdlist("cantest")="y" then%>
            <option value="999">试用<%=Application("testtime")%>天</option>
            <%end if%>
            <%if dsHostpdlist("canmonth")="y" then%>
            <option value="<%=PAY_Month%>">一个月</option>
            <%end if%>
            <%if dsHostpdlist("canseason")="y" then%>
            <option value="<%=PAY_Season%>">三个月</option>
            <%end if%>
            <%if dsHostpdlist("canhalfyear")="y" then%>
            <option value="<%=PAY_halfyear%>">半年</option>
            <%end if%>
            <option value="1">一年</option>
            <option value="<%=PAY_2year%>">两年</option>
            <option value="<%=PAY_3year%>">三年</option>
            <option value="<%=PAY_4year%>">四年</option>
            <option value="<%=PAY_5year%>">五年</option>
          </select>
            <input type="hidden" name="id" value="<%=Request.QueryString ("id")%>">
            <%
usermoney=dsHostpdlist("usermoney")
if agentname<>"n" then
	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='CDN产品' 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='CDN产品' 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%>
  <input name="moneynow" type="text" value="" size="7" readonly="true" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" ></td>
      </tr>
      <%if isAgnHostSer=false then%>
      <%end if%>
      <tr>
        <td height="40" colspan="2" bgcolor=#ffffff>　
            <input name="openX" type="submit" value="马上实时开通CDN" onClick="document.autoopen.openX.value ='请等待不要重复刷新！....';document.autoopen.openX.disabled=true;document.autoopen.submit()"></td>
      </tr>
    </tbody>
  </table>
  <p><br>
  </p>
</form>
<script language="JavaScript" type="text/JavaScript">
//document.openX.moneynow.value=<%=usermoney%>;
function chusrm(s)
{

//	document.all.moneynow.value=Math.round((s*<%=usermoney%>)*100)/100+' 元';
	document.all.moneynow.value=Math.round((s*<%=usermoney%>))+' 元';

	if (s==999)
	{
	document.all.moneynow.value='0'+' 元';
	
	}
}
</script>
<%=htmlwrite("html4")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
