session->userdata('status') === "admin_login"){ redirect('admin'); }elseif ($this->session->userdata('status') === "staff_login") { redirect('staff'); }elseif ($this->session->userdata('status') === "mahasiswa_login") { redirect('mahasiswa'); }elseif ($this->session->userdata('status') === "dosen_login") { redirect('dosen'); }elseif ($this->session->userdata('status') === "staff-mbkm_login") { redirect('staffmbkm'); }elseif ($this->session->userdata('status') === "staff-mbkm-internal_login") { redirect('staffmbkminternal'); }elseif ($this->session->userdata('status') === "staff-mbkm-outbound_login") { redirect('staffmbkmoutbound'); } } public function index() { $this->load->view('v_login'); } public function regis(){ if($this->input->post()){ $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); if($this->input->post('sebagai',true) == 'mahasiswa'){ $data = array( 'npm' => $this->input->post('npm',true), 'nmmhs' => $this->input->post('namadepan',true).' '.$this->input->post('namabelakang',true), 'jnskelamin' => $this->input->post('jnskelamin',true), 'stsemester' => 'stsemester', 'universitas' => $this->input->post('asaluniv',true), 'fakultas' => $this->input->post('fakultas',true), 'prodi' => $this->input->post('prodi',true), 'status' => 'menunggu', 'email' => $this->input->post('email',true), 'alamatuniv' => $this->input->post('alamatuniv',true), 'kotauniv' => $this->input->post('kotauniv',true), 'provinsiuniv' => $this->input->post('provinsiuniv',true), 'kodepos' => $this->input->post('kodepos',true), 'notelpuniv' => $this->input->post('notelpuniv',true), 'notelpuser' => $this->input->post('notelpuser',true), 'created_at' => $time, 'updated_at' => $time, ); $this->load->model('m_data'); $this->m_data->insert_data('mahasiswa_mbkm_luar', $data); $this->session->set_flashdata('flash_success',' Registrasi selesai, silahkan hubungi nomor kontak UNLA untuk info lebih lanjut.'); }elseif ($this->input->post('sebagai',true) == 'staff') { $data = array( 'namadepan' => $this->input->post('namadepan',true), 'namabelakang' => $this->input->post('namabelakang',true), 'email' => $this->input->post('email',true), 'username' => $this->input->post('username',true), 'asaluniv' => $this->input->post('asaluniv',true), 'alamatuniv' => $this->input->post('alamatuniv',true), 'kotauniv' => $this->input->post('kotauniv',true), 'provinsiuniv' => $this->input->post('provinsiuniv',true), 'notelpuniv' => $this->input->post('notelpuniv',true), 'notelpuser' => $this->input->post('notelpuser',true), 'kodepos' => $this->input->post('kodepos',true), 'create_at' => $time, 'update_at' => $time, 'status' => 'menunggu' ); $this->load->model('m_data'); $this->m_data->insert_data('admin_luar', $data); $this->session->set_flashdata('flash_success',' Registrasi selesai, silahkan hubungi nomor kontak UNLA untuk info lebih lanjut.'); } redirect('landing/login'); } $this->load->view('v_regis'); } function get_stsemester(){ $data = $this->db->get('stsemester'); echo json_encode($data->result()); } function get_univ(){ $data = $this->db->get('univ'); echo json_encode($data->result()); } public function login() { $this->load->model('m_login'); if($this->session->userdata('status') === "admin_login"){ redirect('admin'); }elseif ($this->session->userdata('status') === "staff_login") { redirect('staff'); }elseif ($this->session->userdata('status') === "mahasiswa_login") { redirect('mahasiswa'); }elseif ($this->session->userdata('status') === "dosen_login") { redirect('dosen'); }else { $uname = $this->input->get_post('username',TRUE); $pw = MD5($this->input->get_post('password',TRUE)); $where = array( 'username' => $uname, 'password' => $pw ); $where2 = array( 'username' => $uname ); // Update penghapusan fitur pemilihan role // cek username dan password $cek = $this->m_login->cek_login('user',$where); $ceku = $this->m_login->cek_login('user',$where2); $data = $this->m_login->data_login('user',$where2); // kondisi bila cek ada atau tidak if($cek > 0){ // kondisi username dan password benar // Penambahan kondisi apabila status user di block if ($data['block_stat'] == 'block') { // kondisi login tetapi status sudah block $this->session->set_flashdata('flash_error', 'Mohon maaf, Akun anda terblokir karena terlalu banyak kesalahan percobaan login. Silahkan hubungi P3TI UNLA.'); redirect('landing','refresh'); }elseif ($data['block_stat'] == 'allow') { // kondisi login normal // Tambahin kondisi 0 untuk batas login $update = array( 'log_error' => 5 ); $this->db->where('id', $data['id']); $this->db->update('user', $update); // =========================================== // siapkan array untuk session $data_session = array( 'id' => $data['id'], 'username' => $data['username'], 'status_lvl' => $data['status'], 'sub_lvl' => $data['sub_lvl'], 'status' => $data['status'].'_login', 'status_login' => 'login' ); $this->session->set_userdata($data_session); $this->session->set_flashdata('flash_login', 'Login sebagai '. $data['status']); if ( $data['status'] === 'admin') redirect(base_url().'admin'); elseif ( $data['status'] === 'mahasiswa') redirect(base_url().'mahasiswa'); elseif ( $data['status'] === 'staff') redirect(base_url().'staff'); elseif ( $data['status'] === 'dosen') redirect(base_url().'dosen'); elseif ( $data['status'] === 'staff-mbkm') redirect(base_url().'staffmbkm'); elseif ( $data['status'] === 'staff-mbkm-internal') redirect(base_url().'staffmbkminternal'); elseif ( $data['status'] === 'staff-mbkm-outbound') redirect(base_url().'staffmbkmoutbound'); } }else{ // kondisi username atau password salah if ($ceku > 0) { // kondisi username bener, password salah if ($data['block_stat'] == 'block') { // kondisi login salah tetapi status sudah block $this->session->set_flashdata('flash_error', 'Mohon maaf, Akun anda terblokir karena terlalu banyak kesalahan percobaan login. Silahkan hubungi P3TI UNLA.'); redirect('landing','refresh'); }elseif ($data['block_stat'] == 'allow') { // kondisi login salah normal // A. 1. menambahkan 1 hitungan pada field batas login 2. alert menampilkan batas kesalahan $update = array( "log_error" => $data['log_error'] - 1 ); $this->db->where('id', $data['id']); $this->db->update('user', $update); if ($update['log_error'] == 1) { $update2 = array( "block_stat" => 'block' ); $this->db->where('id', $data['id']); $this->db->update('user', $update2); } $this->session->set_flashdata('flash_error', 'Password anda salah. Akun anda akan terblokir apabila percobaan login melebihi batas. Sisa percobaan login: '.$update['log_error']); redirect('landing','refresh'); } }else{ // kondisi username salah, password salah // B. 1. kondisi biasa pada saat ada kesalahan login. $this->session->set_flashdata('flash_error', 'Username atau Password salah.'); redirect('landing','refresh'); } } $this->load->view('v_login'); } } } /* End of file Controllername.php */ ?>