<?php 
require "../../Run.php";
require "include/admin.fun.php";

  if($admin!=1&&$admin!=2)
  {
	ehtml('非法权限！');
	exit();
  }

$mysql = new D('user');

$user_info = $mysql->where(array('xid'=>$_GET['uid'],'site_u'=>WAPID))->find();

	$title      =  $user_info['nc'];
	$user_admin =  $user_info['admin'];
	$user_pass  =  $user_info['pass'];
	$mod_pass   =  $_POST['pass'];
	$readpass = qxpd($admin,$user_admin);
	echo head($title.'的信息管理');
	echo topNav('用户信息修改','<a href="useradmin.php?">列表</a>','<a href="../../admin/wap_admin.php?">后台</a>');
	if($readpass == true)
	{
	if($_POST['action'] == 'mod'){
	
		if($_POST['user_name'] != user2('name',$_GET['uid'])){
			if($mysql->where(array('name'=>$_POST['user_name'],'site_u'=>WAPID))->find())
			{
				ehtml("用户名重复了!");
				exit();
			}
		}
	if($_POST['user_name'] == NULL ||$_POST['nc'] == NULL){
		die("用户名昵称不能为空！");
	}
	$mod_pass = $_POST['pass'] == null ? user('pass','id',$user_info['id']):MD5($_POST['pass']);
	if($mysql->where(array('id' => $user_info['id'],'site_u' => WAPID))
		  ->update(
			array(
				'name'  =>  $_POST["user_name"],
				'nc'    =>  $_POST["nc"],
				'head'  =>  $_POST['head'],
				'admin' =>  $_POST['admin'],
				'vip'   =>  $_POST['vip'],
				'pass'  =>  $mod_pass
				)
			)){
				echo '<div class="tip">修改成功</div>';
			}else{
				echo '<div class="tip">修改失败</div>';
			}
}
echo '<div class="content">
<form method="POST" action="userinfo.php?uid='.$_GET['uid'].'&action=mod">用户昵称：<br><input type="text" name="nc" value="'.user2('nc',$_GET['uid'],WAPID).'"/><br>';
echo '用户名：<br><input type="text" name="user_name" value="'.user2('name',$_GET['uid'],WAPID).'"/><br>';
echo '<input type="hidden" name="uid" value="'.$_GET['uid'].'"/>';
echo '<input type="hidden" name="action" value="mod"/>';
echo '用户ID：'.user2('xid',$_GET['uid'],WAPID).'/'.user2('id',$_GET['uid'],WAPID).'<br>';
echo '用户头像：<br><input type="text"  name="head" value="'.user2('head',$_GET['uid'],WAPID).'"/><br>';
echo '密码:<br><input type="text" name="pass" value=""/>';
echo '<br>密码不修改请留空';
echo '<br>权限：<br><select name="admin">';
echo '<option value="1" ';
$a = user2('admin',$_GET['uid'],WAPID);
if($a==1){
echo 'selected="selected"';
}
echo'>超级管理员</option>';
echo '<option value="2"';
if($a==2){
echo 'selected="selected"';
}
echo'>站长</option>';
echo '<option value="3"';
if($a==3){
echo 'selected="selected"';
}
echo'>总编</option>';
echo '<option value="4"';
if($a==4){
echo 'selected="selected"';
}
echo'>总版</option>';
echo '<option value="0"';
if($a!=1 && $a != 2 && $a!=3){
echo 'selected="selected"';
}
echo'>普通</option>';
echo '</select><br>';
echo '身份<br>';
if(user2('vip',$_GET['uid'],WAPID) == '1'){
	$dq =  '当前：VIP身份';
}else{
	$dq = '当前：普通身份';
}
echo '<select name="vip">';
echo '<option value="'.user2('vip',$_GET['uid'],WAPID).'">'.$dq.'</option>';
echo '<option value="0">普通身份</option>';
echo '<option value="1">VIP身份</option>';
echo '</select><br>';
echo '<input type="submit" value="保存修改"></form>
<br>高级：<a href="#">[锁定用户]</a></div>';
}else{
	echo '<div class="tip">您的权限不足!</div>';
}
echo footer(1);