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') ]); }