Files
2026-09-11 16:03:00 +07:00

25 lines
750 B
PHP

<?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 = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'UNKNOWN';
}
$CI->db->insert('activity_logs', [
'user_id' => $CI->session->userdata('user_id') ?? 0,
'module' => strtolower($module),
'action' => strtolower($action),
'description' => substr(strip_tags((string) $desc), 0, 1000),
'status' => strtolower($status),
'ip_address' => $ip,
'created_at' => date('Y-m-d H:i:s')
]);
}