Exemple #1
0
 function create_user()
 {
     $submit = $this->input->post('submit');
     if ($submit) {
         $show = 0;
         $hide = 1;
         unset($_POST['submit']);
         // Checking user status
         $level = $this->session->userdata('user_previleges');
         if ($level !== $this->super && $level !== $this->admin) {
             die(sprintf('%s@@%s@@', $show, lang('messageNoPermission')));
         }
         // Checking if field is null
         $vresult = $this->_validate_form();
         if (!$vresult) {
             die(sprintf('%s@@%s@@', $show, validation_errors()));
         }
         // Checking username availability
         list($bresult, $msg) = $this->model_user->auto_checking(array('username' => $this->input->post('username')));
         if ($bresult) {
             die(sprintf('%s@@%s@@', $show, $msg));
         }
         //Checking password match
         $option = array('cost' => 10, 'salt' => password_hash(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM), PASSWORD_BCRYPT));
         $pass1 = tempHash($this->input->post('password'), $option);
         $pass2 = tempHash($this->input->post('repassword'), $option);
         if (!hash_equals($pass1, $pass2)) {
             die(sprintf('%s@@%s@@', $show, lang('messagePasswNotMatch')));
         }
         unset($_POST['repassword']);
         //Checking email valid format
         if (!_valid_email($_POST['email'])) {
             die(sprintf('%s@@%s@@', $show, lang('messageEmailNotValid')));
         }
         // if($level === $this->super)
         // 	$_POST['status'] = 1; // Set status to active
         $_POST = $this->model_user->_generate_birth_date($this->input->post());
         list($_POST['hash'], $_POST['salt'], $_POST['password']) = $this->model_user->_create_hash($this->input->post());
         list($bresult, $msg) = $this->model_user->add_user($this->input->post());
         if (!$bresult) {
             die(sprintf('%s@@%s@@', $show, $msg));
         } else {
             die(sprintf('%s@@%s@@', $hide, $msg));
         }
     }
     $upparams = array('level' => $this->session->userdata('level'));
     $data['usprev'] = $this->model_user->usprev_dropdown($upparams);
     $this->load->view('user/add_user', $data);
 }
Exemple #2
0
 function verify_conf()
 {
     $submit = $this->input->post('submit');
     $id = $this->input->post('username');
     if ($submit) {
         unset($_POST['submit']);
         $show = 0;
         $hide = 1;
         $this->form_validation->set_rules('password', lang('label_password'), 'required');
         $this->form_validation->set_rules('repassword', lang('label_repassword'), 'required');
         if ($this->form_validation->run() === FALSE) {
             die(sprintf('%s@@%s@@', $show, validation_errors()));
         }
         $option = array('cost' => 10, 'salt' => password_hash(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM), PASSWORD_BCRYPT));
         $pass1 = tempHash($this->input->post('password'), $option);
         $pass2 = tempHash($this->input->post('repassword'), $option);
         if (!hash_equals($pass1, $pass2)) {
             die(sprintf('%s@@%s@@', $show, lang('messagePasswNotMatch')));
         }
         unset($_POST['repassword']);
         list($_POST['hash'], $_POST['salt'], $_POST['password']) = $this->model_user->_create_hash($this->input->post());
         $_POST['status'] = 1;
         list($bresult, $msg) = $this->model_user->add_user($this->input->post(), $id);
         if ($bresult) {
             die(sprintf('%s@@%s@@', $hide, $msg));
         } else {
             die(sprintf('%s@@%s@@', $show, $msg));
         }
     }
 }