<%@ Language=VBScript %>
<%
If session("agentusername")<>"" Then Response.Redirect "/agent/admsql2.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=数据库产品&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")


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 dsSqlpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_SqlProductlist where id='"&Request.QueryString ("id")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsSqlpdlist.Open Sql,conn,1,1
if dsSqlpdlist.Eof then
	ef=True
	ec="产品不存在！"
else
   if dsSqlpdlist("isbyhost")="y" then
   	ef=True
	ec="赠送的只能自动开通！"
   end If
'读取月付
PAY_Month=dsSqlpdlist("PAY_Month")
PAY_Season=dsSqlpdlist("PAY_Season")
PAY_halfyear=dsSqlpdlist("PAY_halfyear")
PAY_Nextyear=dsSqlpdlist("PAY_Nextyear")
PAY_2year=dsSqlpdlist("PAY_2year")
PAY_3year=dsSqlpdlist("PAY_3year")
PAY_4year=dsSqlpdlist("PAY_4year")
PAY_5year=dsSqlpdlist("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_SqlProductlist_AGN where id='"&dsSqlpdlist ("id")&"' and agent1='"&agentname&"'"
	agnserverid.Open Sql,conn,1,1
dim isAgnHostSer
if not agnserverid.Eof then
if agnserverid ("ServerlistID")<>0 then
ServerlistID=agnserverid ("ServerlistID")
isAgnHostSer=true
else
isAgnHostSer=false
end if
end if
end if
end if

if not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>
　数据库产品自助开通
<%=htmlwrite("html3")%>
<br>
<form action="selfsql2.asp" method="post" name="autoopen">
  <TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
    <TBODY>
      <TR>
        <TD width="20%" vAlign=middle bgColor=#9E9E9E>&nbsp; <font color="#FFFFFF">开通数据库：</font></TD>
        <TD width="23%" height="40" bgColor=#ffffff>　数据库用户名：</TD>
        <TD width="57%" height="40" bgColor=#ffffff><input name="sqlname" type="text" id="sqlname" size="10" maxlength="14"></TD>
      </TR>
      <TR>
        <TD width="20%" rowspan="5" vAlign=middle bgColor=#EEEEEE>&nbsp;</TD>
        <TD height="40" bgColor=#ffffff>　数据库密码：</TD>
        <TD height="40" bgColor=#ffffff><input name="sqlpassword" type="password" id="sqlpassword" size="10" maxlength="20"></TD>
      </TR>
      <TR>
        <TD height="40" bgColor=#ffffff>　重复数据库密码：</TD>
        <TD height="40" bgColor=#ffffff><input name="resqlpassword" type="password" id="resqlpassword" size="10" maxlength="20"></TD>
      </TR>
      <TR>
        <TD height="40" bgColor=#ffffff><font color="#000000">　有效期限：</font></TD>
        <TD height="40" bgColor=#ffffff><select name="year"  onChange="chusrm(this.options[this.options.selectedIndex].value)">
<option value="0" selected>请您选择</option>
          <%if dsSqlpdlist("cantest")="y" then%>
          <option value="999">试用<%=Application("testtime")%>天</option>
          <%end if%>
          <%if dsSqlpdlist("canmonth")="y" then%>
          <option value="<%=PAY_Month%>">一个月</option>
          <%end if%>
<%if dsSqlpdlist("canseason")="y" then%>
		<option value="<%=PAY_Season%>">三个月</option>
<%end if%>
<%if dsSqlpdlist("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=dsSqlpdlist("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="&dsSqlpdlist("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="&dsSqlpdlist("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
usermoney=dsSqlpdlist("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%>
      <TR>
        <TD height="50" bgColor=#ffffff>　请选择机房：</TD>
      <TD height="50" bgColor=#ffffff>
<%
	Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_ServerSqllist where agent1='n' order by id asc"
if isAgnHostSer then Sql="Select * from FreeHost.FreeHost_ServerSqllist where agent1='"&agentname&"' order by id asc"
		dsX.Open Sql,conn,1,1
If dsX.Eof Then%>
服务器列表为空.
<%else%>
<select name="ServerlistID" id="ServerlistID">
<%while not dsX.Eof%>
<%if dsSqlpdlist("ServerlistID")=dsX("id") or dsSqlpdlist("ServerlistID2")=dsX("id") or dsSqlpdlist("ServerlistID3")=dsX("id") or dsSqlpdlist("ServerlistID4")=dsX("id") or dsSqlpdlist("ServerlistID5")=dsX("id") then

if dsX("softtype")="SQL2000" and dsX("MSSQLver")="2000" then softtype="SQL2000"
if dsX("softtype")="SQL2000" and dsX("MSSQLver")="2005" then softtype="SQL2005"
if dsX("softtype")="SQL2000" and dsX("MSSQLver")="2008" then softtype="SQL2008"
if dsX("softtype")="SQL2000" and dsX("MSSQLver")="2012" then softtype="SQL2012"
if dsX("softtype")="SQL2000" and dsX("MSSQLver")="2014" then softtype="SQL2014"
if dsX("softtype")="MySQL" and dsX("MySQLver")="5.0" then softtype="MySQL5.0"
if dsX("softtype")="MySQL" and dsX("MySQLver")="5.1" then softtype="MySQL5.1"
if dsX("softtype")="MySQL" and dsX("MySQLver")="5.5" then softtype="MySQL5.5"

%>
  <option value="<%=dsX("id")%>"><%=dsX("netby")%> <%=softtype%></option>
<%end if%> 
<%
dsX.movenext
wend%>
</select>
<%end if%>
</TD>
      </TR>
<%end if%> 
      <TR>
        <TD height="50" colspan="2" bgColor=#ffffff>　
        <input name="openX" type="submit" value="马上实时开通数据库" onClick="document.autoopen.openX.value ='请等待不要重复刷新！....';document.autoopen.openX.disabled=true;document.autoopen.submit()"></TD>
      </TR>
    </TBODY>
  </TABLE>
</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+' 元';
	if (s==999)
	document.all.moneynow.value='0'+' 元';
}
</script>

<%=htmlwrite("html4")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
