<?php
/**
 *----------------------------------------------------------------------------*
 * 版权所有 2005-2013 HuCart.COM，并保留所有权利。
 * 网站地址: http://Www.HuCart.Com；
 * 作者: HuCart.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);
		
		User::userdetail();
		//echo 'ddd';
	}
	
	static 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);
		//echo 'd';
		//User::userdetail();
		//echo 'wwwwwww';
		$GLOBALS['Templ'] -> assign('act_url',BASE_WEBURL."/user/index.php?load=user&act=updateuser");
		
		$GLOBALS['Templ']-> display('user_tpl.html');
	}
	
	static 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('act_url',BASE_WEBURL."/user/index.php?load=user&act=actpwd");
		
		$GLOBALS['Templ']-> display('userpwd_tpl.html');
	}
	
	static function actpwd()
	{
		//修改密码可以有特殊符号
		$oldpwdval  	= trim($_REQUEST["oldpwd"]);  
		$use_pwdval		= trim($_REQUEST["use_pwd"]);  
		$reuse_pwdval 	= trim($_REQUEST["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'] -> select_one($sql);
		
		if($User["use_id"]!='')
		{
			//修改成功！
			$sqlup = " UPDATE ".SQL_PREFIX."user  set  use_pwd = '".md5($use_pwdval)."'  WHERE  use_id= ".$use_idval;
			$GLOBALS['MySql'] -> query_sql($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');
			
		}
	}

	static 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'] -> select_one($sqluser);
		
		$UserDetail["usd_rankimg"] = $GLOBALS['Helpe'] -> get_rank($UserDetail["usd_rankpoints"],'all'); 
		//var_dump($UserDetail);
		$GLOBALS['Templ'] -> assign('UserDetail',$UserDetail);
		//var_dump( $UserDetail );
		
	}
	
	static function updateuser()
	{

		$use_idval 				= $_SESSION["webUser"]["use_id"];
		$usd_sexval 			= $GLOBALS['Reque'] -> reqval["usd_sex"];
		$usd_nickval 			= $GLOBALS['Reque'] -> reqval["usd_nick"];
		$usd_birthdayval 		= $GLOBALS['Reque'] -> reqval["usd_birthday"];
		$usd_saltval 			= $GLOBALS['Reque'] -> reqval["usd_salt"];
		$usd_msnval 			= $GLOBALS['Reque'] -> reqval["usd_msn"];
		$usd_qqval 				= $GLOBALS['Reque'] -> reqval["usd_qq"];
		$usd_officephoneval 	= $GLOBALS['Reque'] -> reqval["usd_officephone"];
		$usd_homephoneval 		= $GLOBALS['Reque'] -> reqval["usd_homephone"];
		$usd_mobileval 			= $GLOBALS['Reque'] -> reqval["usd_mobile"];
		
		$usd_provinceval 	= $GLOBALS['Reque'] -> reqval["idprovince"];
		$usd_cityval 		= $GLOBALS['Reque'] -> reqval["idcity"];
		$usd_districtval 	= $GLOBALS['Reque'] -> reqval["iddistrict"];
		$usd_pcdallval		= $GLOBALS['Reque'] -> reqval["hiprovince"].$GLOBALS['Reque'] -> reqval["hicity"].$GLOBALS['Reque'] -> reqval["hidistrict"];
		
		//$usd_provinceval 		= $GLOBALS['Reque'] -> reqval["usd_province"];
		$usd_addressval 		= $GLOBALS['Reque'] -> reqval["usd_address"];
		$usd_truenameval 		= $GLOBALS['Reque'] -> reqval["usd_truename"];
		
		$usd_imageval 		= trim($_REQUEST["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'] -> query_sql( $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();
?>