<?php 
require "../Run.php";

if($login!=1){
 header("location: ../../index.php?cid=".$_GET['cid']."&sid=".$sid_info);
  }
  $title=$nc;
echo head($nc.'的信息修改');
echo '<div class="title">'.$title.'的信息修改</div>';
if($_POST['action']=='mod'){
if($_POST['nc'] == NULL)
{
	ehtml("用户名昵称不能为空！");
	exit();
}
//开始修改用户信息；
   if($_POST['pass']!=$pass){
       function M_D_5($data){
	        $data1=md5($data);
	        $data2=md5($data1);
	        $data3=md5($data2);
	        $data4=md5($data3);
	        $pass_word=strtoupper($data4);
            return $pass_word;	 
    }
	$D = date(YmdHis);
	$data=$_POST['name'].$_POST['nc'].$_POST['pass'].$D;
	$sid_mod  = M_D_5($data);
    }else{
	$sid_mod  = $userinfo['sid'];
	}

$modnc = htmlspecialchars($_POST['nc'], ENT_QUOTES); 
$modnc = preg_replace('/(\r\n)|(\n)/',' ',$modnc);
$modnc = mb_substr($modnc,0,20,"UTF-8");
$modpass = $_POST['pass'] == null ? user('pass','id',MYID):MD5($_POST['pass']);
$sql="UPDATE user SET nc='{$modnc}',pass='{$modpass}',qianm='{$_POST['qm']}',email='{$_POST['email']}',sid='{$sid_mod}' WHERE id='{$id}'";
    $result=mysql_query($sql);
	if($result && mysql_affected_rows()>0){
	echo "<div class=\"tip\">修改成功</div>";
    }else{
    echo "<div class=\"tip\">修改失败</div>";
    }
}
echo '<div class="ceontent">
<form method="POST" action="?">用户昵称[<=20字符]：<br><input type="text" name="nc" value="'.$nc.'"/><br>';
echo '用户名：'.$name.'<br>';
echo '密码：<br><input type="text" name="pass" value=""/><br>不修改请留空<br>';
echo '邮箱：<br><input type="text" name="email" value="'.$email.'"/><br>';
echo '<input type="hidden" name="action" value="mod"/>';
echo '用户ID：'.$xid.'<br>';
echo '用户头像：<br><img src="'.$head.'"/><br>';
echo '[<a href="head.php?sid='.$sid_info.'">上传我的头像</a>]<br>';
echo '[签名]<br/><input type="text" name="qm" value="'.$qianm.'"><br>';
echo '<input type="submit" value="资料修改完成"/></form>';
echo '
     </div>
	 <div class="mylink">
	<a href="zone.php?sid='.$sid_info.'">我的空间</a>|<a href="../../index.php?sid='.$sid_info.'">首页</a>
	 </div>
	 '.UBB($wap_bottom,$wapid).'
	 </body>
</html>';
?>