| 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 : /wamp/www/SIPBOS_2020/application/modules/auth/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Auth extends Core_Controller
{
var $appconfig;
var $appconfig_file;
var $appconfig_path;
public function __construct()
{
parent::__construct();
$this->load->model('Login_model');
$this->appconfig = 'appconfig';
$this->appconfig_path = APPPATH.'config/';
$this->appconfig_file = $this->appconfig_path.$this->appconfig.'.php';
}
function index()
{
if($this->session->userdata('login') == TRUE){
redirect('home');
}
else
{
// cek apakah file appconfig.php ada ?
if (!file_exists($this->appconfig_file))
{
show_error('File konfigurasi tidak ditemukan.');
}
else {
$this->load->config($this->appconfig, TRUE);
$app_config = $this->config->item($this->appconfig);
$maintenance = isset($app_config['maintenance'])?$app_config['maintenance']:'0';
if($maintenance=='1'){
$this->load->view('maintenance');
}
else{
$data['title'] = get_title('Login');
$data['option_tahun'] = $this->Login_model->get_thn();
$data['tahun_kini'] = date('Y');
$this->load->view('login_view', $data);;
}
}
}
}
function process_login()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username','Username');
$this->form_validation->set_rules('password','Password');
if($this->form_validation->run() == TRUE){
$username = $this->input->post('username');
$password = $this->input->post('password');
/*
$tahun = $this->input->post('tahun');
$status = $this->input->post('STATUS');
*/
$cek = $this->Login_model->check_user($username, $password);
switch($cek){
case 1 : // akun di blokir
$error = "<strong>Status akun anda tidak aktif. Hubungi Administrator</strong>";
$this->session->set_flashdata('message', $error);
break;
case 2 : // sukses login
$this->load->config($this->appconfig, TRUE);
$app_config = $this->config->item($this->appconfig);
$tahun = $app_config['tahun'];
$status = $app_config['status'];
$user = $this->Login_model->get_user_info($username);
$pemda = $this->Login_model->get_pemda();
$user_data = array(
'app_id' => $this->Login_model->app_id,
'username' => $username,
'nama_operator' => $user['NAME'],
'login' => TRUE,
'id_user' => $user['ID'],
'id_skpd' => $user['SKPD_ID'] ? $user['SKPD_ID'] : 0,
'kode_skpd' => $user['KODE_SKPD_LKP'],
'nama_skpd' => $user['NAMA_SKPD'],
'ppkd' => $user['PPKD'] ? $user['PPKD'] : '0',
'group' => $this->Login_model->app_id == 'SIPKD' ? $user['GROUP_ID'] : $user['GROUP_ID2'],
'admin' => $user['SYS_ADMIN'],
'tahun' => $tahun,
'status' => $status,
'nama_pemda' => $pemda['NAMA_PEMDA'],
);
$this->session->set_userdata($user_data);
break;
case 3 : // group tdk aktif
$error = "<strong>Status Group anda tidak aktif.</strong>";
$this->session->set_flashdata('message', $error);
break;
default:
$error = "<B>Username atau password Anda salah!</B>";
$this->session->set_flashdata('message', $error);
}
redirect('login');
}
else
{
$this->load->view('login_view',$data);
}
}
function get_thn_session($tahun = 0)
{
$option_status = $this->Login_model->get_sts($tahun);
$js = 'id="status_id" class="status"';
if($option_status)
{
echo form_dropdown('STATUS', $option_status, '', $js);
}
else
{
echo form_dropdown('STATUS', array(''=> '-'), '', $js);
}
}
function logout()
{
$this->session->sess_destroy();
redirect('login', 'refresh');
}
}