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:
@ -165,4 +165,18 @@ if (!function_exists('newUUID')) {
|
||||
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('getSystemSettings')) {
|
||||
function getSystemSettings()
|
||||
{
|
||||
// Get Settings
|
||||
$session = session();
|
||||
$settingsBase = new \App\Models\Sistema\SettingsModel();
|
||||
$settings = $settingsBase->first() ?? [];
|
||||
$session->set('settings', $settings);
|
||||
if (empty($session->get('lang'))) {
|
||||
$session->set('lang', 'es');
|
||||
}
|
||||
}
|
||||
}
|
||||
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