mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-08 01:16:56 +01:00
* [ADD] Improved tracking handling.
* [MOD] Improved login process workflow.
This commit is contained in:
53
lib/SP/Repositories/Track/TrackRequest.php
Normal file
53
lib/SP/Repositories/Track/TrackRequest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace SP\Repositories\Track;
|
||||
|
||||
use SP\Core\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class TrackRequest
|
||||
* @package SP\Repositories\Track
|
||||
*/
|
||||
class TrackRequest
|
||||
{
|
||||
public $time;
|
||||
public $source;
|
||||
public $userId;
|
||||
protected $ipv6;
|
||||
protected $ipv4;
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setTrackIp($address)
|
||||
{
|
||||
$ip = @inet_pton($address);
|
||||
|
||||
if (strlen($ip) === 4) {
|
||||
$this->ipv4 = $ip;
|
||||
} elseif (strlen($ip) > 4) {
|
||||
$this->ipv6 = $ip;
|
||||
} elseif ($ip === false) {
|
||||
debugLog(sprintf('%s : %s', __('IP inválida'), $address));
|
||||
|
||||
throw new InvalidArgumentException(__u('IP inválida'), InvalidArgumentException::ERROR, $address);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIpv6()
|
||||
{
|
||||
return $this->ipv6;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIpv4()
|
||||
{
|
||||
return $this->ipv4;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user