<?
include_once("../mdaima_var_inc/config_system.php");//必须先调用获取基本参数 
include_once("../mdaima_var_inc/config_system_info.php");//必须先调用获取基本参数
include_once("../mdaima_var_inc/checkall.php"); 
include_once("../mdaima_var_inc/conn.php"); 

$url_info = geturl($_SERVER[QUERY_STRING],$key_url_md_5);
//--------------搜索条件生成
include_once("news_post_all.php"); 
//--------------搜索条件生成
$id=$url_info['id'];
$action=$url_info['action'];
$time=$url_info['time'];

//修改用户-开始

if ($action=="edit"){

	$nicheng=quotes_gpc_pd($_POST['nicheng'],1);
	$nicheng_py=quotes_gpc_pd($_POST['nicheng_py'],1);
	$tel=quotes_gpc_pd($_POST['tel'],1);
	$pass=quotes_gpc_pd($_POST['pass'],1);
	$password=quotes_gpc_pd($_POST['password'],1);
	
	if ( $tel!='' ){
		if (check_tel_mail($tel,1)=='result_false'){
			alert_ini_index();//输出alert所需文件
			echo "<script>alert_go('手机号码非标准格式！','alert_back','','error','');</script>";
			exit;
		}else{
			$sql="select tel from lei_user where tel='".$tel."' and id<>'".$id."' limit 1 " ;//检测除当前用户以外的用户是否有绑定这个手机号码的
			$result=$mysqli->query($sql);
			if($rs=$result->fetch_assoc()){
				alert_ini_index();//输出alert所需文件
				echo "<script>alert_go('手机号码不能重复绑定！','alert_back','','error','');</script>";
				exit;
			}
		}
	}

	if ($password=='1'){
		//md5($password.md5('@lei_user7d'))
		$update_password=",password='".md5(md5('000000').md5('@lei_user7d'))."'";
	}else{
		$update_password='';
	}
	//拼音，用户修改默认用PHP生成，后台可以手动配合JS修改

	$sql="update lei_user set nicheng='".$nicheng."',nicheng_py='".$nicheng_py."',tel='".$tel."',pass='".$pass."'".$update_password." where id='".$id."' limit 1";
	$mysqli->query($sql);
	
	$back_url=encrypt_url("&page=".$page."&id=".$id."&".$pageurl."&time=".time(),$key_url_md_5);
	
	alert_ini();//输出alert所需文件
	echo "<script>alert_go('用户信息保存成功！','alert_go','','ok','?".$back_url."');</script>";
	exit;
	
	$mysqli->close();

}
//结束

$sql="select * from lei_user where id='".$id."' limit 1 ";
$result=$mysqli->query($sql);
if($rs=$result->fetch_assoc()){
	$username=$rs["username"];
	$nicheng=$rs["nicheng"];
	$nicheng_py=$rs["nicheng_py"];
	$tel=$rs["tel"];
	$userimg=$rs["userimg"];
	$jifen=$rs["jifen"];
	$jifen_all=$rs["jifen_all"];
	$pass=$rs["pass"];
	$indate=$rs["indate"];
	$lasttime=$rs["lasttime"];
}else{
	echo "系统错误或超时！";
	$mysqli->close();
	exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/admin_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="gbk" src="js/jquery.min.js"></script>
<link href="css/bootstrap_modal.min.css" rel="stylesheet" media="screen">
<script src="js/pinyin.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js"></script>
<script language="javascript" type="text/javascript" src="js/my97datepicker/WdatePicker.js"></script>
<script language="JavaScript" type="text/javascript" src="js/pic.js"></script>
  
<style type="text/css">
<!--
#Layer1 {
	position:absolute;
	width:200px;
	height:115px;
	z-index:6;
}
-->
</style>
</head>

<body>
<? include_once("js/js_alert.php"); //调用MODULE弹出框?>
<div class="wrap">	

	<div class="h_a">功能说明</div>
	<div class="prompt_text">
		<ol>
			<li>用户状态分为“审核”、“正常”和“已删除”。</li>
		</ol>
	</div>

	<form name="formsa" id="formsa" method="POST" enctype="multipart/form-data" action="?<?=encrypt_url("&page=".$page."&id=".$id."&".$pageurl."&action=edit&time=".time(),$key_url_md_5)?>"><!--//加密链变量 -->
	<div class="h_a">修改用户信息</div>
	<div class="table_full">
		<table width="100%" >
			<colgroup>
					<col class="th" >
					<col >
			</colgroup>
			<tr>
			  <th>用户名</th>
			  <td><?=$username?></td>
		  </tr>
		  <tr>
		      <th>昵称</th>
		      <td><input name="nicheng" type="text" class="input length_5" id="nicheng" value="<?=$nicheng?>" maxlength="30" onBlur="document.getElementById('nicheng_py').value=CC2PY(this.value).toUpperCase();" onKeyUp="document.getElementById('nicheng_py').value=CC2PY(this.value).toUpperCase()"/></td>
	      </tr>
		  
		   <tr>
		      <th>昵称拼音码</th>
		      <td><input name="nicheng_py" type="text" class="input length_5" id="nicheng_py" value="<?=$nicheng_py?>" maxlength="30" /></td>
	      </tr>
			
		  <tr>
			  <th>绑定手机号</th>
			  <td>
			  <input name="tel" type="text" id="tel" value="<?=$tel?>" class="input length_5" onkeyup="this.value=this.value.replace(/[^\d]/g,'');" onafterpaste="this.value=this.value.replace(/[^\d.]/g,'')"/></td>
		  </tr>
		   <tr>
			  <th>剩余积分</th>
			  <td><?=$jifen?> 分</td>
		  </tr>
		   <tr>
			  <th>历史积分</th>
			  <td><?=$jifen_all?> 分</td>
		  </tr>
			<tr>
			  <th>用户头像</th>
			  <td><a href="<?=$userimg?>" target="_blank"><img src="<?=$userimg?>" width="50" height="50" /></a></td>
		  </tr>
			<tr>
			  <th>用户状态</th>
			  <td><select name="pass" class="select_5" id="pass">
						<option value="0" <? if ($pass=='0'){?>selected="selected"<? }?> >审核中</option>
						<option value="1" <? if ($pass=='1'){?>selected="selected"<? }?>>正常</option>
						<option value="1" <? if ($pass=='90'){?>selected="selected"<? }?>>已删除</option>
					</select></td>
		  </tr>
		   <tr>
			  <th>注册时间</th>
			  <td><?=$indate?>
			  </td>
		  </tr>
		  <tr>
			  <th>最后活跃</th>
			  <td><?=$lasttime?></td>
		  </tr>
		  <tr>
			  <th>初始密码</th>
			  <td><input name="password" type="checkbox" id="password" value="1" onClick="if (this.checked){return confirm('确认要初始该用户的密码？')}"> 确认初始密码&nbsp;&nbsp;&nbsp; &nbsp;（勾选即表示将该用户的密码改为初始 000000 ）</td>
		  </tr>
		</table>
	</div>
	
	<div class="btn_wrap2">
		<div class="btn_wrap_pd2">
			<button class="btn btn_big btn_submit" type="button" onClick="alert_go('确认修改用户信息？','submit','formsa','wen','')" >保存信息</button>
			&nbsp;
			<?
			$back_url=encrypt_url("&page=".$page."&aid=".$id."&".$pageurl."&time=".time(),$key_url_md_5);
			?>
			<button class="btn btn_big loading_it" type="button" onClick="document.location.href='user.php?<?=$back_url?>';" > 返回列表 </button>
			
			
		</div>
	</div>

	</form>
</div>

<div id="a1" style=" position:absolute; z-index:9999;"></div>

<? /*
<link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" /><!--引用JQ -->
<script type="text/javascript" src="js/jquery.imgareaselect.pack.js"></script>
<script type="text/javascript">
	//<img id="photo" src="/images/1.jpg" />
	$(document).ready(function () {
		$('#photo').imgAreaSelect({ maxWidth: 217, maxHeight: 156, handles: true,fadeSpeed: 200});
		//{ aspectRatio: '4:3', handles: true }{ x1: 120, y1: 90, x2: 280, y2: 210 , onSelectChange: preview }
	});
</script>
*/
?>
</body>
</html>
