Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 456)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 466)
@@ -3,4 +3,7 @@
 class User extends MX_Controller
 {
+
+	const TOKENPW = 'violet';
+
 	public function __construct()
 	{
@@ -15,5 +18,8 @@
 		{
 			$user = $user_info['user'];
-			$data = $this->get_data($user);
+			$us_id = $user_info['us_id'];
+			$src = "SBG";
+			$token = md5($us_id.self::TOKENPW);
+			$data = $this->get_data($src, $token, $us_id);
 			$this->load->view('frontend/user_profile', $data);
 			
@@ -24,34 +30,21 @@
 	}
 	
-	private function get_data($user)
+	private function get_data($src, $token, $us_id)
 	{
 		$this->load->model('user_model');
-		$arr_users = explode("&", $user);
-		$str_id = $arr_users[0];
-		$str_username = $arr_users[1];
-		$str_fullname = $arr_users[2];
-		$str_gender = $arr_users[3];
-		$str_email = $arr_users[4];
-		$str_phone = $arr_users[5];
-		$str_school = $arr_users[6];
-		$str_province = $arr_users[7];
-		$str_money = $arr_users[8];
-		$str_level = $arr_users[9];
-		$arr_id = explode("=", $str_id);
-		$arr_username = explode("=", $str_username);
-		$arr_fullname = explode("=", $str_fullname);
-		$arr_gender = explode("=", $str_gender);
-		$arr_email = explode("=", $str_email);
-		$arr_phone = explode("=", $str_phone);
-		$arr_school = explode("=", $str_school);
-		$arr_province = explode("=", $str_province);
-		$arr_money = explode("=", $str_money);
-		$arr_level = explode("=", $str_level);
-		$us = $this->user_model->get_user_by_id($arr_id[1]);
-		$data = array('us_id'=>$arr_id[1], 'username'=>$arr_username[1], 'full_name'=>$arr_fullname[1],
-					'gender'=>$arr_gender[1], 'email'=>$arr_email[1], 'phone'=>$arr_phone[1], 'school'=>$arr_school[1],
-					'acc_balanced'=>$us['acc_balanced'], 'expire_date'=>$us['expire_date'], 'date_diff'=>$this->dateDiff($us['expire_date'])
-				);
-		return $data;
+		$user = $this->user_model->get_user_info($src, $token, $us_id);
+		
+		if (strpos($user, '&')){
+			parse_str($user);
+			$us = $this->user_model->get_user_by_id($us_id);
+			$data = array('us_id'=>$us_id, 'username'=>$username, 'fullname'=>$fullname,
+						'gender'=>$gender, 'email'=>$email, 'phone'=>$phone, 'school'=>$school, 'province'=>$province,
+						'acc_balanced'=>$us['acc_balanced'], 'expire_date'=>$us['expire_date'], 'date_diff'=>$this->dateDiff($us['expire_date'])
+					);
+			return $data;
+		}else
+		{
+			return "";
+		}
 	}
 	
@@ -78,3 +71,92 @@
 		
 	}
+	
+	public function update_user()
+	{
+		$this->load->helper('email');
+		$us_id=$this->uri->segment(4);
+		$user_info = $this->session->userdata('userInfo');
+		if ($user_info)
+		{
+			$result = array();
+			$result['success'] = 0;
+			$src = "SBG";
+			$token = md5($us_id.self::TOKENPW);
+			$user = $this->get_data($src, $token, $us_id);
+			$input = $this->input->post();
+			if ($input){
+				$input['username'] = $user['username'];
+				$input['fullname'] = $user['fullname'];
+				$input['password'] = '';
+				$input['oldpass'] = '';
+				$this->load->model('user_model');
+				$result['fullname'] = $input['fullname'];
+				if (strlen($input['email'])>0){
+					if(!valid_email($input['email']))
+					{
+						$result['errors']['email_err'] = "Email khÃŽng ÄÃºng Äá»nh dáº¡ng";
+					}
+				}
+				if (!isset($result['errors'])){
+					$result['data'] = $this->user_model->update_user($src, $token, $input, $us_id);
+					$result['success'] = 1;
+				}
+				echo json_encode($result);
+			}
+			
+		}else
+		{
+			redirect('frontend/home');
+		}
+	}
+	
+	public function change_password()
+	{
+		$us_id=$this->uri->segment(4);
+		$user_info = $this->session->userdata('userInfo');
+		if ($user_info)
+		{
+			$this->load->model('user_model');
+			$us_id = $user_info['us_id'];
+			$src = "SBG";
+			$token = md5($us_id.self::TOKENPW);
+			if (strlen($input['passwd']) == 0)
+			{
+				$result['errors']['passwd_old_err'] = "Máº­t kháº©u khÃŽng ÄÆ°á»£c Äá» trá»ng !";
+			}
+			if (strlen($input['passwd_new']) == 0)
+			{
+				$result['errors']['passwd_new_err'] = "Máº­t kháº©u khÃŽng ÄÆ°á»£c Äá» trá»ng !";
+			}else if($input['passwd'] == $input['passwd_new'])
+			{
+				$result['errors']['passwd_new_err'] = "Máº­t kháº©u trÃ¹ng vá»i máº­t kháº©u hiá»n táº¡i !";
+			}
+			if ($input['passwd_new'] != $input['confirm_passwd_new'])
+			{
+				$result['errors']['confirm_passwd_new_err'] = "Máº­t kháº©u khÃŽng trÃ¹ng nhau !";
+			}
+			if (!isset($result['errors']))
+			{
+				$user = array('username'=>$username, 'fullname'=>null,  );
+				$data = $this->user_model->update_user($src, $token, $user, $us_id);
+				parse_str($data);
+				switch($status)
+				{
+					case 0:
+						$result['success'] = 1;
+						break;
+					case 6:
+						$result['errors']['passwd_old_err'] = "Máº­t kháº©u cung cáº¥p khÃŽng ÄÃºng !";
+						break;
+					default:
+						break;
+				}
+			}
+			
+			echo json_encode($result);
+		}else
+		{
+			redirect('frontend/home');
+		}
+	}
 }
