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

$UserName = $_GET['UserName'];
$key = $_GET['key'];
$backUrl = $_GET['backUrl'];

if(!CheckHashKey('users'.$UserName,$key)){
   $DB->close();
   die("非法入侵");
}
?>
<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" />
</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>
<!--子导航-->
<? include "user_nav.inc.php"?>
<!--结束-->
<div style="text-align:center;margin:100px 0px 100px 0px;font-size:14px;">
<?
	//检查此会员是否有产品记录
	$tables = array(
	
		array("table"=>"host","Info"=>"产品记录"),
	
		
		array("table"=>"financial","Info"=>"财务记录")
	);
	$candel = 1;
	for($i=0;$i<count($tables);$i++){
		$sql = "select count(*) from `".$tables[$i]['table']."` where UserName='$UserName'";
		$rs  = $DB->query($sql);
		$has = $DB->result($rs,0,0);
		if($has>0){
			$msg = "<img src='../images/w.gif' align='absmiddle'> <font color='#FF0000'> 删除会员 $UserName 失败:此会员有 ".$tables[$i]['Info']." </font>";
			$candel = 0;
			break;
		}
	}
	if($candel){
		$sql = "delete from users where UserName='$UserName'";
		$DB->query($sql);
		$msg = "<img src='../images/c.gif' align='absmiddle'> <font color='#009900'> 删除会员 $UserName 成功 </font>";
	}
	echo "$msg <a href='".$backUrl."'>[返回]</a>";
?>
</div>
<? 
$DB->close();
include "../share/bottom.php";
?>
</body>
</html>