<!--#include file="conn.asp" -->
<!--#include file="inc/usdl.asp" -->
<!--#include file="inc/gl.asp" -->
<!--#include file="inc/hostconfig.asp" -->
<!--#include file="inc/ftp.asp" -->
<!--#include file="inc/iis.asp" -->

<% page_help="3" '分配本页帮助参数
j=session("dl")
call gl(Trim(Request.form("bh")))
bh=Trim(Request.form("bh"))
if bh="" or bh=empty then 
  Response.Write("参数不正确...")
  Response.end
end if
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=page_title%> ::产品开通::</title>
<link href="css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
	color: #006600;
	font-weight: bold;
}
-->
</style>
</head>


<body leftmargin="3" topmargin="0">
<!--#include file="head.asp" -->
<table width="779" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="779" height="19" valign="bottom"><font color="#990000">　→ </font>你当前位置：<a href="default.asp">首 
      页 </a>&gt;&gt;主机开通</td>
  </tr>
  <tr>
    <td height="1" background="images/2.jpg"></td>
  </tr>
</table>
<table width="763" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="196" height="474" valign="top"> 
      <div align="center"><img src="pic/shop_title.gif"> 
        <!--#include file="in.asp" -->
        <!--#include file="helt_inc.asp" -->
		<!--#include file="contact.asp" -->
        <a href="help.asp"><img src="pic/pay_online2.gif" alt="支付方式请点这里..." width="168" height="70" border="0"></a></div></td>
    <td width="1" valign="top" bgcolor="#F2F2F2"> </td>
    <td width="553" valign="top"><p> 
        <%  
		
		application lock
		msg=""
		msg_ok=""
		
'查看用户账号上金额		
		sql="select * from user where userid='"&session("us")&"'"
		 rs.open sql,conn,1,1
		  if not rs.eof then
		    user_je=rs("je")
		   else
		   msg="<li>不存在此用户!</li>"
		   end if
		 rs.close 
		 
'读取此订单所需金额	 
 if trim(msg)="" then
  sql="select * from shop where userid='"&session("us")&"'and bh="&bh&" and jf=false and sx=false"
    rs.open sql,conn,1,1
     if not rs.eof  then
      host_je=rs("je")
	  host_mc=rs("mc")
      else
         msg=msg&"<li>订单不存在或以经开通..</li>"
      end if
	rs.close
end if 

'用户账号支付
if trim(msg)="" then
 if user_je-host_je>=0 then
   sql="update user set je="&user_je-host_je&" where userid='"&session("us")&"'"
   conn.execute(sql)
   msg_ok="<li>账号支付成功</li>"
   sql="update shop set jf=true where bh="&bh
   conn.execute(sql)
   '与入财务日志
   bo="订单:"&bh&"/"&host_mc
   sql="insert into memo(userid,je,body,log,zje) values ('"&session("us")&"',"&-host_je&",'"&bo&"','购物',"&user_je-host_je&")"
   conn.execute(sql)
  else
   msg=msg&"<li>对不起您账号上的余额不足..</li>"
  end if
end if

'读取用户提交的虚拟主机数据
if trim(msg)="" then
 sql="select * from host_shop where bh="&bh
  rs.open sql,conn,1,1
  if not rs.eof then
   ftp_auto=rs("ftp_auto")               '是否支持在线开通
   ftp_name=rs("ftp")                    'ftp用户名
   ftp_dat=rs("nx")   
   ftp_dat1=rs("nx")              '注册年限
   ftp_password=rs("ftp_password")       'ftp密码  
   ftp_host=rs("ftp_host")               'ftp空间大小
   ftp_path=rs("ftp_path")               'ftp日录
   web_dns=rs("dns")                     '绑定的域名
   web_ip=rs("web_ip")   
   iis_UserName=rs("iis_UserName") 
   iis_Password=rs("iis_Password")         
   else
    msg=msg&"<li>用户订单错误..</li>"
   end if
   rs.close
end if

if ftp_auto then    '如果此空间支持在线开通 

  '检查是否存在些文件夹,没有则新建
   if trim(msg)="" then
   'on error resume next
    Err.Clear
      Set fs =server.CreateObject("Scripting.FileSystemObject")
	    fs.createfolder(ftp_path&"\"&ftp_name)
	   If Err.Number = 0 Then
	     msg_ok=msg_ok&"<li>目录新建成功!!!</li>"
	   else
	    msg=msg&"<li>目录新建失败!!!</li>"
	   end if
	   '复制空间开通后的默认文件
	   set fso=createobject("Scripting.FileSystemObject")
	   fso.copyfile default_file,ftp_path&"\"&ftp_name&"\"
	   If Err.Number = 0 Then
	     msg_ok=msg_ok&"<li>默认文件复制成功!!!</li>"
	   else
	    msg=msg&"<li>默认文件复制失败!!!</li>"
	   end if
	   
    end if

 '如果不存在相同的ftp用户名则.开通ftp
 if trim(msg)="" then
     Set fs =server.CreateObject("Scripting.FileSystemObject")
     set file=fs.OpenTextFile(seuv_filepath,1)
    if instr(file.readall,"[USER="&ftp_name&"|1]")=0 then
	
    ftpok=auto_ftp(ftp_name,ftp_password,ftp_host,ftp_path&"\"&ftp_name,seuv_filepath,ftp_dat)
'----------------------------------------------------------------------------
    if ftpok="ok" then
	 msg_ok=msg_ok&"<li>ftp开通成功!!!</li>"
	 else
	  msg=msg&"<li>FTP开通出错:"&ftpok&"</li>"
	 end if
	 else
       msg=msg&"<li>此ftp用户名已经存在,请和管理员联系..</li>"
    end if
  end if
 '-------------------开通 web 绑定iis
  if trim(msg)="" then 	
     ss=ASTCreateWebSite(web_ip,ftp_path&"\"&ftp_name,web_dns,web_dns,80,"localhost",True,iis_UserName,iis_Password,iis_logofile,web_default,ftp_name&"."&web_zs)
 '-----------------------------	
    if ss<>"" then
	  sql="update shop set sx=true where bh="&bh
      conn.execute(sql)
	  '写入虚拟主机日志
	  sql="select * from host_shop where iis_id="&ss
	  rs.open sql,conn,1,1
	   if rs.eof then
	   sql="update host_shop set iis_id="&ss&" where bh="&bh
       conn.execute(sql)
	   msg_ok=msg_ok&"<li>iis开通成功!!!</li>"
	   else
	   msg_ok=msg_ok&"<li>iis开通成功,但是写入订单中的IIS序号出现重复.</li><li>请和管理员联系,当前站点IIS序号为"&ss&"</li><li>您的产品开通成功，但是写入数据时出现错，请把上面的内容用email发送给管理员处理.</li>"
	  end if
	  rs.close
	 
	 sql="insert into web_logo(bh,userid,log,sl,je,ftp_user,ftp_password,ftp_path,web_dns) values ("&bh&",'"&session("us")&"','"&"开设主机/"&host_mc&"|iisID="&ss&"',"&ftp_dat1&","&host_je&",'"&ftp_name&"','"&ftp_password&"','"&ftp_path&"','"&web_dns&"')"
     conn.execute(sql)
	else
	 msg=msg&"<li>iis开设失败.</li>"
	end if	
  end if


end if '如果此空间不支持在线开通 
  %>
      </p>
      <p><strong>　</strong></p>
      <p><strong><font color="#999999">虚拟主机订单支付</font></strong><font color="#999999">:</font></p>
      <hr width="90%" size="1"> <div align="center"> 
        <% if msg<>"" then 
	       msg="你的订单号:<font color=#FF0000><b>"&bh&"</b></font><ul>"&msg&msg_ok&"</ul>　请记住此定单号,如果是你账号上金额不足,请先申请入账再来开通,请把上面的错误信息复制,用Email发送给网站管理员."
		   Response.Write  "<img src='pic/error.gif' width='338' height='268'> "
		else 
	  Response.Write( "<p align='center'><img src='pic/succend.gif' width='440' height='207' border='0'></p>")
 end if
	   %>
      </div>
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="100%" height="238" valign="top"> 
            <%  if msg="" and ftp_auto then %> 
            <p class="style1">看到此页面说明你的虚拟主机已经开通..</p>
            <p>&nbsp;</p>
            <table width="450" height="235" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#F0F0F0" bordercolorlight="" bordercolordark="ffffff">
              <tr> 
                <td width="100" bgcolor="#F5F5F5"><div align="center"><font color="#000000">订 
                    单 号:</font></div></td>
                <td width="222"><font color="#FF0000"><strong><%= bh %> 　</strong></font><a href="user8_host.asp?bh=<%=bh%>">修改虚所主机参数</a></td>
              </tr>
              <tr> 
                <td bgcolor="#F5F5F5"><div align="center"><font color="#000000">产品名称:</font></div></td>
                <td><font color="#0000FF"><%= host_mc %></font></td>
              </tr>
              <tr> 
                <td bgcolor="#F5F5F5"><div align="center"><font color="#000000">支付金额: 
                    &nbsp;</font></div></td>
                <td><font color="#FF0000">￥<%= host_je %></font></td>
              </tr>
              <tr> 
                <td bgcolor="#F5F5F5"><div align="center"><font color="#000000">Ftp主机:</font></div></td>
                <td><a href=ftp://<%=ftp_name&":"&ftp_password&"@"&web_ip %> target="_blank"><%= web_ip %></a></td>
              </tr>
              <tr> 
                <td bgcolor="#F5F5F5"><div align="center"><font color="#000000">Ftp账号:</font></div></td>
                <td><%= ftp_name %>&nbsp;</td>
              </tr>
              <tr> 
                <td bgcolor="#F5F5F5"><div align="center"><font color="#000000">Ftp密码: 
                    </font></div></td>
                <td><%= ftp_password %></td>
              </tr>
              <tr> 
                <td bgcolor="#F5F5F5"><div align="center"><font color="#000000">绑定域名: 
                    </font></div></td>
                <td><a href=http://<%= web_dns %> target="_blank">http://<%= web_dns %></a></td>
              </tr>
              <tr> 
                <td height="28" bgcolor="#F5F5F5"><div align="center"><font color="#000000">赠送域名:</font></div></td>
                <td><a href=http://<%=ftp_name&"."&web_zs %> target="_blank">http://<%= ftp_name&"."&web_zs %></a>&nbsp;</td>
              </tr>
              <tr>
                <td height="28" bgcolor="#F5F5F5"><div align="center">备 注:</div></td>
                <td><%= msg_ok %>&nbsp;</td>
              </tr>
              <tr> 
                <td height="54" colspan="2"> <p><font color="#FF0000"> 　注</font>:请把你的域名的A记录解析到 
                    <font color="#FF0000"><%= web_ip %></font> 域名生效后就可以用你的域名访问你的网站了,现在可以用我们赠送的二级域名来访问你的网站</p></td>
              </tr>
            </table>
            <% 
			else
			if msg<>"" then
			Response.Write(msg)
			else
			Response.Write "<p>此订单号是: <font color='#FF0000'><strong>"&bh&"</strong></font></p><ul><li>此订单支付成功.</li><li>请等侍管理员帮你开通.</li></ul>"
			end if
	  end if %> </td>
        </tr>
      </table>
      <p align="center"><a href="user3.asp">查看支付成功的产品 &gt;&gt;&gt;</a></p></td>
  </tr>
</table>

<%
application unlock
call CloseDatabase '关闭数据库链接
%>
<!--#include file="top.asp" -->
</body>
</html>





























