mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Continuo migrando, estoy perfilando activity y los settings
This commit is contained in:
41
ci4/app/Helpers/logger_helper.php
Normal file
41
ci4/app/Helpers/logger_helper.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
|
||||
if (!function_exists('setLog')) {
|
||||
function setLog($level, $event, $user_id = 0)
|
||||
{
|
||||
$activity_model = new \App\Models\Sistema\ActivityModel();
|
||||
$request = \Config\Services::request();
|
||||
$ip = $request->getIPAddress();
|
||||
$agent = $request->getUserAgent();
|
||||
|
||||
$currentAgent = identifyAgent($agent);
|
||||
|
||||
$activity_model->save([
|
||||
'user_id' => $user_id,
|
||||
'level' => $level,
|
||||
'event' => $event,
|
||||
'ip' => $ip,
|
||||
'os' => $agent->getPlatform(),
|
||||
'browser' => $currentAgent,
|
||||
'detail' => $agent
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('identifyAgent')) {
|
||||
function identifyAgent($agent)
|
||||
{
|
||||
if ($agent->isBrowser()) {
|
||||
return $agent->getBrowser() . ' ' . $agent->getVersion();
|
||||
}
|
||||
if ($agent->isRobot()) {
|
||||
return $agent->getRobot();
|
||||
}
|
||||
if ($agent->isMobile()) {
|
||||
return $agent->getMobile();
|
||||
}
|
||||
return 'Unidentified User Agent';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user