增加获取预格式化后数据功能
This commit is contained in:
parent
41bfaafc4f
commit
96a5dcb9a5
@ -73,7 +73,20 @@ class FileSizeHelper
|
||||
$userHomeDir = Yii::getAlias(Yii::$app->params['dataDirectory']) . '/' . $user_id . '.secret';
|
||||
return self::getDirectorySize($userHomeDir);
|
||||
}
|
||||
|
||||
public static function getUserAllDirSize(int $user_id = null): int
|
||||
{
|
||||
if ($user_id === null) {
|
||||
$user_id = Yii::$app->user->id;
|
||||
}
|
||||
return self::getUserHomeDirSize($user_id) + self::getUserVaultDirSize($user_id);
|
||||
}
|
||||
public static function getFormatUserAllDirSize(int $user_id = null): string
|
||||
{
|
||||
if ($user_id === null) {
|
||||
$user_id = Yii::$app->user->id;
|
||||
}
|
||||
return self::formatBytes(self::getUserAllDirSize($user_id));
|
||||
}
|
||||
/**
|
||||
* @param $bytes
|
||||
* @param $precision
|
||||
|
@ -15,15 +15,16 @@ class IPLocation
|
||||
public function __construct()
|
||||
{
|
||||
$status = Yii::$app->params['enableIpInfo'];
|
||||
if($status){
|
||||
if ($status) {
|
||||
$this->is_disabled = false;
|
||||
$this->client = new IPinfo(Yii::$app->params['ipinfoToken']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDetails(string $ip): ?Details
|
||||
{
|
||||
$instance = new self();
|
||||
if($instance->is_disabled){
|
||||
if ($instance->is_disabled) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
@ -41,4 +42,10 @@ class IPLocation
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFormatDetails(string $ip): string
|
||||
{
|
||||
$details = self::getDetails($ip);
|
||||
return $ip.' (' . ($details->bogon ? ('Bogon IP') : ($details->city . ', ' . $details->country)) . ')';
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user