|
Server : Apache System : Linux server.mata-lashes.com 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : matalashes ( 1004) PHP Version : 8.1.29 Disable Function : NONE Directory : /home/matalashes/.trash/app.bak2/Libraries/Ps/ |
Upload File : |
<?php
namespace App\Libraries\Ps;
use Config\Services;
class Loglib
{
//LOG ARRAY
function log()
{
$session = service('session');
$request = service('request');
if ($session->has('user_id')) {
log_message('info', 'User ID ' . $session->get('user_id') . ' from IP '
. $request->getIPAddress() . ' accessed ' . $request->uri->getPath());
}
}
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
function getUserAgent()
{
if ($this->CI->agent->is_browser()) {
$agent = $this->CI->agent->browser() . ' ' . $this->CI->agent->version();
} elseif ($this->CI->agent->is_robot()) {
$agent = $this->CI->agent->robot();
} elseif ($this->CI->agent->is_mobile()) {
$agent = $this->CI->agent->mobile();
} else {
$agent = 'Unidentified User Agent';
}
return $agent;
}
function getPlatform()
{
return $this->CI->agent->platform();
}
}