Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions src/Admin/src/Service/AdminLoginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down
Loading