Example #1
0
 public function register()
 {
     $inputs['username'] = array('type' => 'input', 'label' => 'Username', 'rules' => 'required');
     $inputs['password'] = array('type' => 'password', 'label' => 'Password', 'rules' => 'required');
     $inputs['email'] = array('type' => 'input', 'label' => 'Email', 'rules' => 'required');
     $inputs['hp'] = array('type' => 'input', 'label' => 'Mobile Phone', 'rules' => 'required');
     $inputs['height'] = array('type' => 'input', 'label' => 'Height (cm)', 'rules' => 'required');
     $inputs['gender'] = array('type' => 'input', 'label' => 'Gender', 'rules' => 'required', 'options' => array('male' => 'Male', 'female' => 'Female'));
     $defaults = array();
     if (rbt_valid_post($inputs)) {
         $_POST['password'] = hashim($this->input->post('password'));
         $_POST['created_at'] = date('Y-m-d H:i:s');
         $_POST['status'] = 'activated';
         $this->db->insert('users', $this->input->post());
         toshout_success('Your account has been created. <br/>Please <a href="' . site_url('login') . '">login here &raquo;</a>');
         redirect('umum/register');
     }
     $data['inputs'] = $inputs;
     $data['defaults'] = $defaults;
     if (!$this->uri->segment(3)) {
         $data['title'] = 'Register';
     } else {
         $data['title'] = 'Change Details';
     }
     $this->load->view('umum_form', $data);
 }
Example #2
0
 public function setting()
 {
     $user = $this->session->userdata('user');
     $inputs['username'] = array('type' => 'input', 'label' => 'Username', 'rules' => 'required');
     $inputs['password'] = array('type' => 'password', 'label' => 'Password', 'rules' => 'required');
     $inputs['email'] = array('type' => 'input', 'label' => 'Email', 'rules' => 'required');
     $inputs['hp'] = array('type' => 'input', 'label' => 'Mobile Phone', 'rules' => 'required');
     $inputs['height'] = array('type' => 'input', 'label' => 'Height (cm)', 'rules' => 'required');
     $inputs['gender'] = array('type' => 'dropdown', 'label' => 'Gender', 'rules' => 'required', 'options' => array('male' => 'Male', 'female' => 'Female'));
     $defaults = array();
     if (rbt_valid_post($inputs)) {
         $_POST['password'] = hashim($this->input->post('password'));
         // $_POST['created_at'] = date('Y-m-d H:i:s');
         // $_POST['status'] = 'activated';
         $this->db->where('id', $user['id']);
         $this->db->update('users', $this->input->post());
         // $this->db->insert('users',$this->input->post());
         toshout_success('Your settings has been changed.');
     }
     $this->db->where('id', $user['id']);
     $query = $this->db->get('users');
     $defaults = $query->row_array();
     $defaults['password'] = robot($defaults['password']);
     $data['inputs'] = $inputs;
     $data['defaults'] = $defaults;
     $data['title'] = 'Change Details';
     $this->load->view('dashboard_form', $data);
 }
Example #3
0
 function setting()
 {
     if ($this->input->post()) {
         $this->db->where(array('id' => $this->session->userdata('id')));
         $query = $this->db->get('users');
         $res = $query->result_array();
         if ($this->input->post('old_password') and $this->input->post('new_password')) {
             //renew password
             if (hashim($this->input->post('old_password')) == $res[0]['password']) {
                 $_POST['password'] = hashim($this->input->post('new_password'));
             } else {
                 toshout(array('Password lama tidak tepat. Password tidak dikemaskini.Sila cuba sekali lagi.' => 'error'));
             }
         }
         $where = array('id' => $this->session->userdata('id'));
         unset($_POST['old_password']);
         unset($_POST['new_password']);
         $this->db->where($where);
         $this->db->update('users', $this->input->post());
         toshout(array('Maklumat anda telah dikemaskini.' => 'success'));
     }
     $this->load->helper('form');
     $this->db->where(array('id' => $this->session->userdata('id')));
     $query = $this->db->get('users');
     $res = $query->result_array();
     $_POST = $res[0];
     unset($_POST['password']);
     //$_POST['password'] = $this->encrypt->decode($_POST['password'], $_POST['email']);
     $this->load->view('v_user_setting');
 }
Example #4
0
 public function login($username, $password)
 {
     // $this->db->select('id, username, email, fullname, hp, ic, address, fb_id, status, key, nexmo_credit');
     $this->db->where('username', $username);
     $this->db->where('password', hashim($password));
     $query = $this->db->get('users');
     if ($query->num_rows() === 1) {
         $user = $query->row_array();
         $this->session->set_userdata('user', $user);
         // set groups
         // $this->db->select('groups.*');
         // $this->db->where('user_group.user_id', $user['id']);
         // $this->db->join('groups', 'groups.id = user_group.group_id');
         // $query = $this->db->get('user_group');
         // foreach($query->result_array() as $row){
         // 	$groups[$row['id']] = $row['name'];
         // }
         $groups[] = $user['group'];
         $this->session->set_userdata('group', $groups);
         // set organisations
         // $this->db->select('organisations.*');
         // $this->db->where('user_organisation.user_id', $user['id']);
         // $this->db->join('organisations', 'organisations.id = user_organisation.organisation_id');
         // $query = $this->db->get('user_organisation');
         // foreach($query->result_array() as $row){
         // 	$organisations[$row['id']] = $row['name'];
         // }
         // $this->session->set_userdata('orgs', $organisations);
         // set organisaations
         // $this->db->select('organisations.name,organisations.address,organisations.email,organisations.tel');
         // $this->db->where('user_organisation.user_id', $user['user_id']);
         // $this->db->join('organisations', 'organisations.id = user_organisation.organisation_id');
         // $query = $this->db->get('user_organisation');
         // $organisations = $query->result_array();
         // $this->session->set_userdata('organisations', $groups);
         // set response to be sent
         $response['status'] = true;
         $response['message'] = 'Welcome back ' . ucwords($user['username']) . '!';
         $response['error'] = false;
     } else {
         $response['status'] = false;
         $response['message'] = 'Login denied. Please check your username and password.';
         $response['error'] = false;
     }
     return $response;
 }
Example #5
0
 function edit_self()
 {
     $this->db->where(array('id' => $this->session->userdata('id')));
     $query = $this->db->get('users');
     $q = $query->result_array();
     if ($this->input->post()) {
         $this->load->library('form_validation');
         $this->form_validation->set_message('is_unique', 'The %s value has been used by other user. Please key in other value:');
         $this->form_validation->set_rules('username', 'Username', 'required');
         if ($q[0]['email'] != $this->input->post('email')) {
             $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');
         } else {
             $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
         }
         if ($this->form_validation->run()) {
             //run validation, if success run this!
             $data = $this->input->post();
             unset($data['old_password']);
             unset($data['new_password']);
             if ($this->input->post('old_password') && $this->input->post('new_password')) {
                 $this->db->where(array('password' => hashim($this->input->post('old_password')), 'email' => $this->input->post('email')));
                 $query = $this->db->get('users');
                 if ($query->num_rows() == 1) {
                     $data['password'] = hashim($this->input->post('new_password'));
                 } else {
                     toshout(array('Old password is invalid.' => 'error'));
                 }
             }
             $this->db->where(array('id' => $this->session->userdata("id")));
             $this->db->update('users', $data);
             toshout(array('Success' => 'success'));
         }
     }
     $this->db->where(array('id' => $this->session->userdata('id')));
     $query = $this->db->get('users');
     $q = $query->result_array();
     $_POST = $q[0];
     unset($_POST['tags']);
     unset($_POST['password']);
     $this->load->view('v_sacl_edit_self');
 }
Example #6
0
 public function login()
 {
     //login biasa
     if ($this->input->post()) {
         $this->load->library('encrypt');
         $where = array($this->config->item('sacl_login_column') => $this->input->post($this->config->item('sacl_login_column')), 'password' => hashim($this->input->post('password')));
     }
     //login google
     // if($this->input->get('state')==$this->g_state) {
     // 	$this->load->library('Curl');
     // 	$api_call = array(
     // 					'code' => $this->input->get('code'),
     // 					'client_id' => $this->g_clientid,
     // 					'client_secret' => $this->g_clientsecret,
     // 					'redirect_uri' => $this->g_redirect,
     // 					'grant_type' => $this->g_granttype
     // 					  );
     // 	$api_post = $this->curl->simple_post('https://accounts.google.com/o/oauth2/token', $api_call);
     // 	$api = json_decode($api_post);
     // 	$data['token'] = $api->access_token;
     // 	$response = $this->curl->simple_get('https://www.googleapis.com/oauth2/v2/userinfo',array('access_token'=>$data['token']));
     // 	$user = json_decode($response);
     // 	$email = $user->email;
     // 	$where = array(
     // 					'email'=>$email,
     // 					//'password'=>hashim($this->input->post('password'))
     // 				);
     // }
     //kalau 2-2 login attempt wujud pilih username
     if ($this->input->post() or $this->input->get()) {
         //where organisation_id;
         // if($this->input->post('email') !== 'root' AND $this->input->post('email') !== '*****@*****.**' AND $this->input->post('email') !== 'superadmin' AND $this->input->post('email') !== '*****@*****.**'){
         // 	$org = get_organisation();
         // 	if($org != NULL) $where['organisation_id'] = $org['id'];
         // }
         //$this->db->select('id, username, fullname, email, tags');
         $this->db->from('users');
         // dumper($where);
         $this->db->where($where);
         $query = $this->db->get();
         //dumper($this->db->last_query());
         //check if exists. If not throw error
         if ($query->num_rows() == 1) {
             $res = $query->result_array();
             //create tag
             $tags = unserialize($res[0]['tags']);
             foreach ($tags as $tag_id) {
                 $this->db->or_where(array('id' => $tag_id));
             }
             $q = $this->db->get('tags');
             foreach ($q->result_array() as $tags) {
                 $tagid[] = $tags['id'];
             }
             $res[0]['tags_id'] = $tagid;
             //get users_data details
             $this->db->where('user_id', $res[0]['id']);
             $query = $this->db->get('users_data');
             $users_data = $query->row_array();
             unset($users_data['id']);
             unset($res[0]['password']);
             $sess = $res[0] + $users_data;
             $this->session->set_userdata($sess);
             //set session for user details
             return TRUE;
         } else {
             toshout(array('Login Error. Pastikan maklumat anda benar dan tepat.' => 'error'));
         }
     }
 }
Example #7
0
 public function daftar_affiliate()
 {
     $hons['Tuan'] = 'tuan';
     $hons['Cikpuan'] = 'cikpuan';
     $input['honorific'] = array('type' => 'dropdown', 'label' => 'Honorific', 'rules' => 'required', 'options' => $hons);
     $input['display_name'] = array('type' => 'input', 'label' => 'Name', 'rules' => 'required');
     $input['username'] = array('type' => 'input', 'label' => 'Username', 'rules' => 'required');
     $input['password'] = array('type' => 'password', 'label' => 'Password', 'rules' => 'required');
     $input['email'] = array('type' => 'input', 'label' => 'Email', 'rules' => 'required|valid_email');
     $input['hp'] = array('type' => 'input', 'label' => 'H/P', 'rules' => 'required');
     if (rbt_valid_post($input)) {
         // dumper($this->input->post());
         // add to user
         $_POST['password'] = hashim($_POST['password']);
         $_POST['key'] = md5(microtime() . json_encode($_POST));
         $insert['honorific'] = $this->input->post('honorific');
         $insert['display_name'] = $this->input->post('display_name');
         $insert['username'] = $this->input->post('username');
         $insert['password'] = $this->input->post('password');
         $insert['email'] = $this->input->post('email');
         $insert['hp'] = $this->input->post('hp');
         $insert['key'] = $this->input->post('key');
         $this->db->insert('users', $insert);
         $user_id = $this->db->insert_id();
         // add to user_group
         $param['user_id'] = $user_id;
         $param['group_id'] = 4;
         $this->db->insert('user_group', $param);
         $this->load->model('Despatch');
         $this->Despatch->activation($user_id);
         toshout_success('Mohon semak email dan klik link activation untuk activate account');
         redirect('umum/daftar_affiliate');
     }
     $data['inputs'] = $input;
     $data['title'] = 'Daftar Sebagai Affiliate';
     $data['defaults'] = array();
     $this->load->view('umum_form', $data);
 }