<?php
/**
 *	Generated by miceCMS
 *	http://www.miceCMS.com/
 */
class my_updateAction extends security_login {
	function action(){
		ModuleLimit(__CLASS__);
		global $conn;
		$miceSession = new session();

		$user=new model_User();
		$user->setSubsection('WHERE user_id='.$miceSession->get('userid'));
		$results=$user->doSelectOne();

		$loginname=$_POST['loginname'];
		$password1=$_POST['pw1'];
		$password2=$_POST['pw2'];
		$pwd='';

		if($password1==$password2 and strlen($password1)>0 and strlen($loginname)>0)
		{
			$salt = md5(rand(100000, 999999).$loginname);
			$pwd=sha1($salt.$password1);
		}else if(strlen($password1)>0){
			$jsstring='Dialog.alert("新密码和确认密码不一致",function(){history.back(-1);});';
			MessageBox($jsstring);
		}

		
		
		$realname=$_POST['realname'];
		$explam=$_POST['explam'];
		$url=$_POST['url'];
		$email=strtolower($_POST['email']);
		$nicename=$_POST['nicename'];
		$address=$_POST['address'];
		$headimg=$_POST['headimg'];
		$brothday=$_POST['brothday'];
		$sex=$_POST['sex'];
		$im=$_POST['im'];
		$telno=$_POST['telno'];

		if($loginname==""){
			$jsstring='Dialog.alert("登录名不能为空",function(){history.back(-1);});';
			MessageBox($jsstring);
			exit;
		}

		if($results)
		{
			$ins='内容已存在';
			if(strlen($pwd)>0){
				$user->setSalt($salt);
				$user->setPassword($pwd);
			}
			$user->setRealname($realname);
			$user->setExplam($explam);
			$user->setUrl($url);
			$user->setEmail($email);
			$user->setNicename($nicename);
			$user->setAddress($address);
			$user->setHeadimg($headimg);
			$user->setBrothday($brothday);
			$user->setSex($sex);
			$user->setIm($im);
			$user->setTelno($telno);
			$results=$user->doUpdate();

			if($results)
				$exeresult='更新成功';
			else
				$exeresult='更新失败';

		}

		$jsstring='Dialog.alert(\''.$exeresult.'\',function(){window.location.href="'.MICE_URL.'admin.php/my";window.event.returnValue = false;},300,100,"返回到我的资料");';
		MessageBox($jsstring);
		exit;
	}
}
?>