<?php
session_start();
require_once "../init.php";
require_once "../authority.inc.php";

if($_POST['ID'] != '')
{
	$ID = $_POST['ID'];
}
else
{
	$ID = $_GET['ID'];
}
if($_POST['key'] != '')
{
	$key = $_POST['key'];
}
else
{
	$key = $_GET['key'];
}
if($_POST['backUrl'] != '')
{
	$backUrl = $_POST['backUrl'];
}
else
{
	$backUrl = $_GET['backUrl'];
}
$GID = $_POST['GID'];
$Domain = $_POST['Domain'];
$fIDProd = $_POST['fIDProd'];
$UserName = $_POST['UserName'];
$FtpServer = $_POST['FtpServer'];
$FtpUser = $_POST['FtpUser'];
$Password = $_POST['Password'];
$LineType = $_POST['LineType'];
$fDBType = $_POST['fDBType'];
$iStatus = $_POST['iStatus'];
$dtCreate = $_POST['dtCreate'];
$dtExpiry = $_POST['dtExpiry'];
$Edit = $_POST['Edit'];

if(!CheckHashKey('host'.$ID,$key)){
   $DB->close();
   die("非法入侵");
}
/****** 空间信息 ******/
if(!$Edit){
	$sql="select * from host where IDHost='$ID'";
	$result=$DB->query($sql);
	$HostI=$DB->fetch_array($result);
	$dkey = GetHashKey('host'.$HostI[IDHost]);
	$ukey = GetHashKey('users'.$HostI[UserName]);

    $sql="select * from `database` where fIDHost='$ID'";
	$result=$DB->query($sql);
	$DbInfo=$DB->fetch_array($result);
}

$boxInfo = box_for_vhost('name');
$boxInfo[-1] = "无建站宝盒";
$boxInfo[0] = "跟随空间分配";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改产品</title>
<LINK href="../share/style.css" rel=stylesheet>
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />
<script src='../share/global.js'></script>
</head>
<body>
<? include "../share/top.php"?>
<div id="topLink">
<div id="topInfo">
	<span class="tTitle">产品管理</span>
	<span class="sarr"> >> </span><a href="<?=$GLOBALS["parentpath"]?>">返回到管理首页</a>
</div>
</div>
<!--子导航--><div class="page-container">
<? include "product_nav.inc.php"?>
<!--结束-->

	  <?
	  if($Edit==1){
		  $sql="update host set GID='$GID',UserName='$UserName',Domain='$Domain',fIDProd='$fIDProd',".
			  "FtpServer='$FtpServer',Password='$Password',FtpUser='$FtpUser',".
			  "iStatus='$iStatus',dtCreate='$dtCreate',dtExpiry='$dtExpiry' where IDHost=$ID";
		  $DB->query($sql);

		  if($IDDatabase){
			$sql="update `database` set DbServer='$DbServer',DbName='$DbName',DbUser='$DbUser',DbType='$DbType'".
			     "where IDDatabase=$IDDatabase";
			$DB->query($sql);
		  }
		  echo "<center><br><br>产品  <font color='blue'> $Domain </font>修改成功";
		  echo "<br><br><a href='product_edit.php?ID=".$ID."&key=".$key."&backUrl=".urlencode($backUrl)."'>返回产品详细信息</a>  <a href='$backUrl'>返回</a></center><br>";
	  }else{ 
	  ?>
        <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="table" class="table table-border table-bordered table-bg table-hover table-sort">
          <form action="product_edit.php" method="post">
              <tr id="tr">
				<td colspan="2">
				产品详细信息 -
					<a href="host_op.php?ID=<?=$HostI[IDHost]?>&key=<?=$dkey?>&op=delete&backUrl=<?=urlencode($backUrl)?>" onClick="return confirm('确定删除吗?')">删除</a> 
				</td>
			  </tr>
			  <tr>
				<td width="40%" align="right">编号(ID):</td>
				<td><input name="ID" type="text" class="inputline" value="<?=$HostI[IDHost]?>" readonly>
				(此项不可修改)</td>
			  </tr>
			  <tr>
				<td align="right">(GID):</td>
				<td><input name="GID" type="text" class="inputline" value="<?=$HostI[GID]?>">
				</td>
			  </tr>
			 
			  <tr>
				<td align="right">产品号:</td>
				<td><input name="fIDProd" type="text" class="inputline" value="<?=$HostI[fIDProd]?>">(<font color='red'>必须要和产品设置中的产品号一致,如不清楚请不要修改</font>)</td>
			  </tr>
			  <tr>
				<td align="right">所属用户:</td>
				<td><input name="UserName" type="text" class="inputline" value="<?=$HostI[UserName]?>"> <a href='../users/user_edit.php?UserName=<?=$HostI[UserName]?>&backUrl=<?=$backUrl?>&key=<?=$ukey?>' target="_blank">用户资料</a></td>
			  </tr>
		
             
			  <tr>
				<td align="right">状态:</td>
				<td>
				<select name="iStatus">
				  <!--<option value="-1" <?if($HostI[iStatus]==-1)echo "selected"?>>已删除</option>-->
				  <option value="<?=ProductStatus_NotActived?>" <?if($HostI[iStatus]==ProductStatus_NotActived)echo "selected"?>>未交费</option>
				  <option value="<?=ProductStatus_Doing?>" <?if($HostI[iStatus]==ProductStatus_Doing)echo "selected"?>>已付款</option>
				  <option value="<?=ProductStatus_Actived?>" <?if($HostI[iStatus]==ProductStatus_Actived)echo "selected"?>>已发货</option>
				 <option value="<?=ProductStatus_Stoped?>" <?if($HostI[iStatus]==ProductStatus_Stoped)echo "selected"?>>已收货</option>
				</select>
			  </tr>
			  <tr>
				<td align="right">建立时间:</td>
				<td><input type='text' class="inputline" name="dtCreate" size="30" value="<?=$HostI[dtCreate]?>"></td>
			  </tr>  
			
              <tr>
              <td colspan='2' align='center'>
			  <br>
			      <input name="submit" type="submit" class="bt2" value="提 交">
				  &nbsp;&nbsp;
				  <input name="reset" type="button" class="bt2" value="返 回" onClick="location='<?=$backUrl?>'">
			      <input name="Edit" type="hidden" value="1">
				  <input name="backUrl" type="hidden" value="<?=$backUrl?>">
				  <input name="key" type="hidden" value="<?=$key?>">
			<br><br>
			  </td>
            </tr>
          </form>
        </table>
	<?}?>

<? 
$DB->close();
include "../share/bottom.php"?>
</div>
</body>
</html>
