Initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
|
||||
function log_activity($module, $action, $desc, $status = 'success')
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
$ip = $CI->input->ip_address();
|
||||
|
||||
if (!$ip || $ip == '0.0.0.0') {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ??
|
||||
$_SERVER['REMOTE_ADDR'] ??
|
||||
'UNKNOWN';
|
||||
}
|
||||
|
||||
$CI->db->insert('activity_logs', [
|
||||
'user_id' => $CI->session->userdata('user_id') ?? 0,
|
||||
'module' => strtolower($module),
|
||||
'action' => strtolower($action),
|
||||
'description' => $desc,
|
||||
'status' => strtolower($status),
|
||||
'ip_address' => $ip,
|
||||
'created_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
if (!function_exists('tanggal_indo')) {
|
||||
function tanggal_indo($tanggal, $format = 'd F Y')
|
||||
{
|
||||
if (empty($tanggal) || $tanggal == '0000-00-00') {
|
||||
return '-';
|
||||
}
|
||||
|
||||
$bulan = [
|
||||
1 => 'Januari',
|
||||
'Februari',
|
||||
'Maret',
|
||||
'April',
|
||||
'Mei',
|
||||
'Juni',
|
||||
'Juli',
|
||||
'Agustus',
|
||||
'September',
|
||||
'Oktober',
|
||||
'November',
|
||||
'Desember'
|
||||
];
|
||||
|
||||
$timestamp = strtotime($tanggal);
|
||||
|
||||
$hari = date('d', $timestamp);
|
||||
$bulan_index = (int)date('m', $timestamp);
|
||||
$tahun = date('Y', $timestamp);
|
||||
|
||||
return $hari . ' ' . $bulan[$bulan_index] . ' ' . $tahun;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Cek permission user
|
||||
* @param string $key => nama fitur (misal: 'siswa', 'dashboard')
|
||||
* @param string $action => action yang dicek (misal: 'can_view', 'can_export')
|
||||
* @return bool
|
||||
*/
|
||||
function check_permission($key, $action = 'can_view') {
|
||||
$CI =& get_instance();
|
||||
$permissions = $CI->session->userdata('permissions');
|
||||
|
||||
if (!$permissions || !is_array($permissions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pastikan key ada
|
||||
if (!isset($permissions[$key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Jika value berupa array (multiple permissions), cek dengan in_array
|
||||
if (is_array($permissions[$key])) {
|
||||
return in_array($action, $permissions[$key]);
|
||||
}
|
||||
|
||||
// Jika value berupa string tunggal
|
||||
return $permissions[$key] === $action;
|
||||
}
|
||||
Reference in New Issue
Block a user