diff --git a/src/Admin/src/Service/AdminLoginService.php b/src/Admin/src/Service/AdminLoginService.php index 0da33ec..7e3dc4e 100644 --- a/src/Admin/src/Service/AdminLoginService.php +++ b/src/Admin/src/Service/AdminLoginService.php @@ -15,7 +15,9 @@ use Dot\GeoIP\Service\LocationService; use Exception; +use function get_browser; use function in_array; +use function ini_get; class AdminLoginService implements AdminLoginServiceInterface { @@ -111,21 +113,32 @@ private function logAdminVisit(array $serverParams, string $name, SuccessFailure $continent = $this->locationService->getContinent($ipAddress)->getName(); $organization = $this->locationService->getOrganization($ipAddress)->getName(); + /** + * For browscap information + * + * @see https://www.php.net/manual/en/function.get-browser.php + */ + if (ini_get('browscap')) { + $browser = get_browser($_SERVER['HTTP_USER_AGENT']); + } + $adminLogin = (new AdminLogin()) ->setAdminIp($this->locationService->obfuscateIpAddress($ipAddress)) ->setContinent($continent) ->setCountry($country) ->setOrganization($organization) - ->setDeviceType(null) - ->setDeviceBrand(null) + ->setDeviceType($browser->device_type ?? null) + ->setDeviceBrand($browser->device_name ?? null) ->setDeviceModel(null) - ->setIsMobile(YesNoEnum::No) - ->setOsName(null) - ->setOsVersion(null) - ->setOsPlatform(null) - ->setClientType(null) - ->setClientName(null) - ->setClientEngine(null) + ->setIsMobile( + isset($browser->ismobiledevice) && $browser->ismobiledevice ? YesNoEnum::Yes : YesNoEnum::No + ) + ->setOsName($browser->platform_description ?? null) + ->setOsVersion($browser->platform_version ?? null) + ->setOsPlatform($browser->platform ?? null) + ->setClientType($browser->browser_type ?? null) + ->setClientName($browser->browser ?? null) + ->setClientEngine($browser->renderingengine_name ?? null) ->setClientVersion(null) ->setLoginStatus($status) ->setIdentity($name);