<?php
/**
 *----------------------------------------------------------------------------*
 * 版权所有 2005-2013 GV32.COM，并保留所有权利。
 * 网站地址: http://www.gv32.com；
 * 作者: GV32.COM
 *----------------------------------------------------------------------------*
**/
class User
{
	function User()
	{
		$GLOBALS['Helpe']-> get_usermenu();
		
		$getmenu = $GLOBALS['Helpe']->get_menu();
		$GLOBALS['Templ']->assign('getmenu',$getmenu);
		
		$getlink = $GLOBALS['Helpe']->get_link();
		$GLOBALS['Templ']->assign('getlink',$getlink);
		
		$getuserlink = $GLOBALS['WebSe']->getuserlink();
		$GLOBALS['Templ']->assign('getuserlink',$getuserlink);
		
		$userdetail = $this -> userdetail();
	}
	
	function infolist()
	{
		$webtitle = '基本信息 - 用户中心';
		//处理你现在的位置
		$nowaddress = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/user/">用户中心</a> > 基本信息';
		
		$GLOBALS['Templ'] -> assign('webtitle',$webtitle);
		
		$GLOBALS['Templ'] -> assign('nowaddress',$nowaddress);
		
		$this -> userdetail();
		
		$GLOBALS['Templ'] -> assign('actUrl',BASE_WEBURL."/user/index.php?load=user&act=updateuser");
		
		$GLOBALS['Templ']-> display('user_tpl.html');
	}
	
	function pwd()
	{
		$webtitle = '修改密码 - 用户中心';
		//处理你现在的位置
		$nowaddress = '您现在所在的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/user/">用户中心</a> > 修改密码';
		
		$GLOBALS['Templ'] -> assign('webtitle',$webtitle);
		
		$GLOBALS['Templ'] -> assign('nowaddress',$nowaddress);
		
		$GLOBALS['Templ'] -> assign('actUrl',BASE_WEBURL."/user/index.php?load=user&act=actpwd");
		
		$GLOBALS['Templ']-> display('userpwd_tpl.html');
	}
	
	function actpwd()
	{
		$oldpwdval  	= $GLOBALS['Reque'] -> funpost("oldpwd");
		$use_pwdval		= $GLOBALS['Reque'] -> funpost("use_pwd");
		$reuse_pwdval 	= $GLOBALS['Reque'] -> funpost("reuse_pwd");
		
		$use_idval 		= $_SESSION["webUser"]["use_id"];
		
		$sql = " SELECT use_id  FROM ".SQL_PREFIX."user WHERE use_id= '".$use_idval."' AND  use_pwd = '".md5($oldpwdval)."' LIMIT 1 ";
		
		$User = $GLOBALS['MySql'] -> selectOne($sql);
		
		if($User["use_id"]!='')
		{
			//修改成功！
			$sqlup = " UPDATE ".SQL_PREFIX."user  set  use_pwd = '".md5($use_pwdval)."'  WHERE  use_id= ".$use_idval;
			$GLOBALS['MySql'] -> querySql($sqlup);
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['LA_pwdsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/?load=user&act=pwd");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			//exit();
		}else{
			//修改有误!
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['LA_pwderror']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/?load=user&act=pwd");	
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			
		}
	}

	function userdetail()
	{
		$webuse_id = $_SESSION["webUser"]["use_id"] ;
		
		$sqluser = " SELECT *  FROM  ".SQL_PREFIX."userdetail  WHERE use_id = ".$webuse_id."  GROUP BY use_id ORDER BY `use_id` LIMIT 1 ";
		
		$UserDetail = $GLOBALS['MySql'] -> selectOne($sqluser);
		
		$UserDetail["usd_rankimg"] = $GLOBALS['Helpe'] -> get_rank($UserDetail["usd_rankpoints"],'all'); 
		
		$GLOBALS['Templ'] -> assign('UserDetail',$UserDetail);
		//var_dump( $UserDetail );
		
	}
	
	function updateuser()
	{
		//var_dump($_REQUEST);
		$use_idval 				= $_SESSION["webUser"]["use_id"];
		$usd_sexval 			= $GLOBALS['Reque'] -> funpost("usd_sex");
		$usd_nickval 			= $GLOBALS['Reque'] -> funpost("usd_nick");
		$usd_birthdayval 		= $GLOBALS['Reque'] -> funpost("usd_birthday");
		$usd_saltval 			= $GLOBALS['Reque'] -> funpost("usd_salt");
		$usd_msnval 			= $GLOBALS['Reque'] -> funpost("usd_msn");
		$usd_qqval 				= $GLOBALS['Reque'] -> funpost("usd_qq");
		$usd_officephoneval 	= $GLOBALS['Reque'] -> funpost("usd_officephone");
		$usd_homephoneval 		= $GLOBALS['Reque'] -> funpost("usd_homephone");
		$usd_mobileval 			= $GLOBALS['Reque'] -> funpost("usd_mobile");
		
		$usd_provinceval 	= $GLOBALS['Reque'] -> funpost("idprovince");
		$usd_cityval 		= $GLOBALS['Reque'] -> funpost("idcity");
		$usd_districtval 	= $GLOBALS['Reque'] -> funpost("iddistrict");
		$usd_pcdallval		= $GLOBALS['Reque'] -> funpost("hiprovince").$GLOBALS['Reque'] -> funpost("hicity").$GLOBALS['Reque'] -> funpost("hidistrict");
		
		//$usd_provinceval 		= $GLOBALS['Reque'] -> funpost("usd_province");
		$usd_addressval 		= $GLOBALS['Reque'] -> funpost("usd_address");
		$usd_truenameval 		= $GLOBALS['Reque'] -> funpost("usd_truename");
		
		$usd_imageval 		= $GLOBALS['Reque'] -> funpost("usd_image");
		
		if($use_idval)
		{
			$updatesql = "UPDATE `".SQL_PREFIX."userdetail` SET  usd_sex = '".$usd_sexval."' , usd_nick = '".$usd_nickval."' , usd_birthday = '".$usd_birthdayval."' , usd_salt = '".$usd_saltval."' , usd_msn = '".$usd_msnval."' , usd_qq = '".$usd_qqval."' , usd_officephone = '".$usd_officephoneval."' , usd_homephone = '".$usd_homephoneval."' , usd_mobile = '".$usd_mobileval."' , usd_province = '".$usd_provinceval."' ,usd_city = '".$usd_cityval."' ,usd_district = '".$usd_districtval."' , usd_address = '".$usd_addressval."' , usd_truename = '".$usd_truenameval."' ,`usd_image` = '$usd_imageval'  WHERE  use_id = '".$use_idval."' ";
			
			$GLOBALS['MySql'] -> querySql( $updatesql );
		}
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']["LA_addsusse"]);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/index.php?load=user&act=infolist");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
		
	}
	

	
	
}

$User = new User();
?>