| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/wamp/www/sipapbd_2020_pergeseran3/application/controllers/ |
Upload File : |
<?php
class User extends Userpage_Controller{
public function __construct()
{
parent:: __construct();
$this->modul_name = 'user';
$this->modul_display = 'Akun Saya';
$this->view_form = 'auth/user_info';
$this->load->model('auth/user_model', 'data_model');
}
function index()
{
$data = array();
$data['modul'] = $this->modul_name;
$id = $this->session->userdata['id_user'];
if ($id!==0)
{
$data['data'] = $this->data_model->get_data_by_id($id);
}
$data['main_content'] = $this->view_form;
$this->load->view('layout/template',$data);
}
function validasi_form()
{
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[3]|max_length[50]|callback__cek_duplikasi');
$this->form_validation->set_rules('nama', 'Nama Operator', 'trim|required|max_length[100]');
$this->form_validation->set_rules('email', 'Email', 'trim|max_length[100]|valid_email|callback__cek_duplikasi_email');
if ($this->input->post('mode') == 'new')
{
$this->form_validation->set_rules('passwd', 'Password', 'required|trim|min_length[8]|max_length[50]');
$this->form_validation->set_rules('repasswd', 'Ulangi password', 'required|trim|min_length[8]|max_length[50]|matches[passwd]');
}
$this->form_validation->set_message('required', '%s tidak boleh kosong.');
$this->form_validation->set_message('max_length', '%s tidak boleh melebihi %s karakter.');
$this->form_validation->set_message('min_length', '%s tidak boleh kurang dari %s karakter.');
$this->form_validation->set_message('valid_email', '%s tidak valid.');
$this->form_validation->set_message('_cek_duplikasi', 'Kode sudah ada.');
$this->form_validation->set_message('_cek_duplikasi_email', 'Email sudah digunakan.');
$this->form_validation->set_message('matches', '%s tidak sama.');
}
public function _cek_duplikasi()
{
return $this->data_model->check_duplikasi_username();
}
public function _cek_duplikasi_email()
{
return $this->data_model->check_duplikasi_email();
}
public function ubah_password()
{
$response = (object) NULL;
$this->load->model('auth/login_model', 'auth');
$this->load->library('form_validation');
$this->form_validation->set_rules('oldpasswd', 'Password Lama', 'required|trim|callback__cek_password');
$this->form_validation->set_rules('newpasswd', 'Password Baru', 'required|trim|min_length[8]|max_length[50]');
$this->form_validation->set_rules('renewpasswd', 'Ulang password Baru', 'required|trim|matches[newpasswd]');
$this->form_validation->set_message('required', '%s tidak boleh kosong.');
$this->form_validation->set_message('max_length', '%s tidak boleh melebihi %s karakter.');
$this->form_validation->set_message('min_length', '%s tidak boleh kurang dari %s karakter.');
$this->form_validation->set_message('_cek_password', 'Password Lama tidak valid.');
$this->form_validation->set_message('matches', '%s tidak sama.');
if($this->form_validation->run() == TRUE)
{
$success = $this->data_model->save_password();
if($success){
$response->isSuccess = TRUE;
$response->sql = $this->db->queries;
$response->message = 'Password berhasil disimpan';
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Password gagal disimpan';
$response->sql = $this->db->queries;
$response->error = $this->data_model->last_error_message;
}
}
else
{
$response->isSuccess = FALSE;
$response->message = validation_errors();
}
echo json_encode($response);
}
public function _cek_password()
{
return $this->data_model->check_password();
}
public function proses()
{
$response = (object) NULL;
$this->load->library('form_validation');
$this->validasi_form();
if($this->form_validation->run() == TRUE)
{
$this->data_model->fill_data();
$success = $this->data_model->save_data();
if($success){
$response->isSuccess = TRUE;
$response->message = 'Data berhasil disimpan';
$response->sql = $this->db->queries;
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Data gagal disimpan';
$response->error = $this->data_model->last_error_message;
$response->sql = $this->db->queries;
}
}
else
{
$response->isSuccess = FALSE;
$response->sql = $this->db->queries;
$response->message = validation_errors();
}
echo json_encode($response);
}
}