Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 542)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 556)
@@ -1,143 +1,151 @@
 ﻿<?php
-if (!defined('BASEPATH'))
-    exit('No direct script access allowed');
+if (! defined ( 'BASEPATH' ))
+	exit ( 'No direct script access allowed' );
 
 /**
  * Home Class
- * 
+ *
  * @author dzungnv02
- *
+ *        
  */
 class Home extends MX_Controller {
-
-    const TOKENPW = 'violet';
-
-    public function __construct() {
-        parent::__construct();
-        $this->load->helper('cookie');
-    }
-
-    public function index() {
-        $user_info = $this->session->userdata('userInfo');
-        if ($user_info) {
-            redirect('/frontend/lecture');
-        } else {
-            $cookie_name = "siteCookie";
-            if (isset($_COOKIE[$cookie_name])) {
-                $arr_user = parse_str($_COOKIE[$cookie_name]);
-                $user_info = array('username' => $arr_user['username'], 'user' => $arr_user['user'], 'us_id' => $arr_user['us_id'], 'logined_in' => TRUE);
-                $this->session->set_userdata('userInfo', $user_info);
-                redirect('/frontend/lecture');
-            } else {
-                $this->load->view('home');
-            }
-        }
-    }
-
-    public function signin() {
-        $username = $this->input->post('username', TRUE);
-        $password = $this->input->post('password', TRUE);
-        $autologin = ($this->input->post('remember_me') == 'on') ? 1 : 0;
+	const TOKENPW = 'violet';
+	public function __construct() {
+		parent::__construct ();
+		$this->load->helper ( 'cookie' );
+	}
+	
+	public function index() {
+		$user_info = $this->session->userdata ( 'userInfo' );
+		if ($user_info) {
+			redirect ( '/frontend/lecture' );
+		} else {
+			$cookie_name = "siteCookie";
+			if (isset ( $_COOKIE [$cookie_name] )) {
+				$arr_user = parse_str ( $_COOKIE [$cookie_name] );
+				$user_info = array (
+						'username' => $arr_user ['username'],
+						'user' => $arr_user ['user'],
+						'us_id' => $arr_user ['us_id'],
+						'logined_in' => TRUE 
+				);
+				$this->session->set_userdata ( 'userInfo', $user_info );
+				redirect ( '/frontend/lecture' );
+			} else {
+				$this->load->view ( 'home' );
+			}
+		}
+	}
+	
+	public function signin() {
+		$username = $this->input->post ( 'username', TRUE );
+		$password = $this->input->post ( 'password', TRUE );
+		$autologin = ($this->input->post ( 'remember_me' ) == 'on') ? 1 : 0;
 		$src = 'SBG';
-        $token = md5($username . self::TOKENPW);
-        $this->load->model(array('user_model'));
-        $data = $this->user_model->checkLogin($src, $token, $username, $password);
-        
-        
-        if ($data == null) {
-            $this->session->set_flashdata('login_error', TRUE);
-            redirect('/frontend/home');
-        } else {
-            parse_str($data);
-            $is_viettel=$this->is_viettel($phone);
-            switch ($status) {
-                case 0:
-                case 4:
-
-                    if ($autologin == 1) {
-                        $cookie_name = 'siteCookie';
-                        //$cookie_time = 7200;
-                        $cookie_time = 3600 * 24 * 30;
-                        setcookie($cookie_name, 'username=' . $username . '&user=' . $data . '&us_id=' . $id, time() + $cookie_time);
-                    }
-                    $userdata = array('username' => $username, 'user' => $data, 'us_id' => $id, 'logined_in' => TRUE,'is_viettel'=>$is_viettel);
-                    $this->session->set_userdata('userInfo', $userdata);
-                    redirect('/frontend/lecture');
-                    break;
-                case 1:
-                    $this->session->set_flashdata('login_error', TRUE);
-                    redirect('/frontend/home');
-                    break;
-                case 2:
-                case 3:
-                    $this->session->set_flashdata('login_error', TRUE);
-                    redirect('/frontend/home');
-                    break;
-                //case 4:
-                //redirect('/frontend/home');
-                case 10:
-                    $this->session->set_flashdata('login_error_token', TRUE);
-                    redirect('/frontend/home');
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-
-    public function signout() {
-        $this->session->sess_destroy();
-        //unset($this->session->userdata); 
-        $cookie_name = "siteCookie";
-        setcookie($cookie_name, 'username=' . "", time() - 3600);
-        redirect('/frontend/home');
-    }
-    
-    public function register() {
-        $this->load->model('user_model');
-        $sentNumber = '0979947802';
-        $serviceID = 1;
-        $receiveID = '0985685735';
-        $commandcode = 'commandcode1';
-        $info = 'ABCD';
-        //$receiveTime = time();
-        $receiveTime = date("Y-m-d H:i:s");
-        $data = $this->user_model->register($sentNumber, $receiveID, $serviceID, $commandcode, $info, $receiveTime);
-        echo $data;
-    }
-
-    public function change_profile() {
-        $this->load->model('user_model');
-        $sentNumber = '0979947802';
-        $serviceID = 1;
-        $password = '123456';
-        $commandcode = "SBG";
-        $receiveID = '01662860000';
-        $info = "SBG TD";
-        $receiveTime = date("Y-m-d H:i:s");
-        $status = 0;
-        $data = $this->user_model->changeProfile($sentNumber, $receiveID, $password, $status);
-        echo $data;
-    }
-
-    public function change_password() {
-        $this->load->model('user_model');
-        $sentNumber = '01662860000';
-        $serviceID = 1;
-        $password = '123456';
-        //$oldpass = '123456';
-        $commandcode = "SBG";
-        //$receiveID = '0979947802';
-        $info = "SBG MK";
-        $receiveTime = date("Y-m-d H:i:s");
-        $status = 0;
-        $data = $this->user_model->changePassword($sentNumber, $password, $serviceID, $commandcode, $info, $receiveTime, $status);
-        echo $data;
-    }
-
-	
-	public function register_vip()
-	{
-		$this->load->model('user_model');
+		$token = md5 ( $username . self::TOKENPW );
+		$this->load->model ( array (
+				'user_model' 
+		) );
+		$data = $this->user_model->checkLogin ( $src, $token, $username, $password );
+		
+		if ($data == null) {
+			$this->session->set_flashdata ( 'login_error', TRUE );
+			redirect ( '/frontend/home' );
+		} else {
+			parse_str ( $data );
+			$is_viettel = $this->is_viettel ( $phone );
+			switch ($status) {
+				case 0 :
+				case 4 :
+					
+					if ($autologin == 1) {
+						$cookie_name = 'siteCookie';
+						// $cookie_time = 7200;
+						$cookie_time = 3600 * 24 * 30;
+						setcookie ( $cookie_name, 'username=' . $username . '&user=' . $data . '&us_id=' . $id, time () + $cookie_time );
+					}
+					$userdata = array (
+							'username' => $username,
+							'user' => $data,
+							'us_id' => $id,
+							'logined_in' => TRUE,
+							'is_viettel' => $is_viettel 
+					);
+					$this->session->set_userdata ( 'userInfo', $userdata );
+					redirect ( '/frontend/lecture' );
+					break;
+				case 1 :
+					$this->session->set_flashdata ( 'login_error', TRUE );
+					redirect ( '/frontend/home' );
+					break;
+				case 2 :
+				case 3 :
+					$this->session->set_flashdata ( 'login_error', TRUE );
+					redirect ( '/frontend/home' );
+					break;
+				// case 4:
+				// redirect('/frontend/home');
+				case 10 :
+					$this->session->set_flashdata ( 'login_error_token', TRUE );
+					redirect ( '/frontend/home' );
+					break;
+				default :
+					break;
+			}
+		}
+	}
+	
+	public function signout() {
+		$this->session->sess_destroy ();
+		// unset($this->session->userdata);
+		$cookie_name = "siteCookie";
+		setcookie ( $cookie_name, 'username=' . "", time () - 3600 );
+		redirect ( '/frontend/home' );
+	}
+	
+	public function register() {
+		$this->load->model ( 'user_model' );
+		$sentNumber = '0979947802';
+		$serviceID = 1;
+		$receiveID = '0985685735';
+		$commandcode = 'commandcode1';
+		$info = 'ABCD';
+		// $receiveTime = time();
+		$receiveTime = date ( "Y-m-d H:i:s" );
+		$data = $this->user_model->register ( $sentNumber, $receiveID, $serviceID, $commandcode, $info, $receiveTime );
+		echo $data;
+	}
+	
+	public function change_profile() {
+		$this->load->model ( 'user_model' );
+		$sentNumber = '0979947802';
+		$serviceID = 1;
+		$password = '123456';
+		$commandcode = "SBG";
+		$receiveID = '01662860000';
+		$info = "SBG TD";
+		$receiveTime = date ( "Y-m-d H:i:s" );
+		$status = 0;
+		$data = $this->user_model->changeProfile ( $sentNumber, $receiveID, $password, $status );
+		echo $data;
+	}
+	
+	public function change_password() {
+		$this->load->model ( 'user_model' );
+		$sentNumber = '01662860000';
+		$serviceID = 1;
+		$password = '123456';
+		// $oldpass = '123456';
+		$commandcode = "SBG";
+		// $receiveID = '0979947802';
+		$info = "SBG MK";
+		$receiveTime = date ( "Y-m-d H:i:s" );
+		$status = 0;
+		$data = $this->user_model->changePassword ( $sentNumber, $password, $serviceID, $commandcode, $info, $receiveTime, $status );
+		echo $data;
+	}
+	
+	public function register_vip() {
+		$this->load->model ( 'user_model' );
 		$sentNumber = '01662860000';
 		$serviceID = 1;
@@ -146,13 +154,12 @@
 		$mainAccBalanced = 15000;
 		$info = "SBG DK VIP1";
-		$receiveTime = date("Y-m-d H:i:s");
-		$status = 0;
-		$data = $this->user_model->registerVip($sentNumber, $vipNum, $serviceID, $commandcode, $info, $status);
-		echo $data;
-	}
-	
-	public function recharge_account()
-	{
-		$this->load->model('user_model');
+		$receiveTime = date ( "Y-m-d H:i:s" );
+		$status = 0;
+		$data = $this->user_model->registerVip ( $sentNumber, $vipNum, $serviceID, $commandcode, $info, $status );
+		echo $data;
+	}
+	
+	public function recharge_account() {
+		$this->load->model ( 'user_model' );
 		$sentNumber = '0979947802';
 		$receiveID = '01662860000';
@@ -164,19 +171,28 @@
 		$info = "SBG NAP 01662860000 10000";
 		$status = 0;
-		$data = $this->user_model->rechargeAccount($sentNumber, $receiveID, $mainAccBalanced, $amount, $serviceID, $commandcode, $info, $status);
-		echo $data;
-	}
-        public function is_viettel($number)
-        {
-            $viettel=array('096','097','098','0163','0164','0165','0166','0167','0168','0169');
-            foreach ($viettel as $num)
-            {
-                if (strpos($number, $num)===0)
-                {
-                  return true;                
-                }
-            }
-            return false; 
-        }
+		$data = $this->user_model->rechargeAccount ( $sentNumber, $receiveID, $mainAccBalanced, $amount, $serviceID, $commandcode, $info, $status );
+		echo $data;
+	}
+	
+	public function is_viettel($number) {
+		$viettel = array (
+				'096',
+				'097',
+				'098',
+				'0163',
+				'0164',
+				'0165',
+				'0166',
+				'0167',
+				'0168',
+				'0169' 
+		);
+		foreach ( $viettel as $num ) {
+			if (strpos ( $number, $num ) === 0) {
+				return true;
+			}
+		}
+		return false;
+	}
 }
 
