增加获取预格式化后数据功能
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
|
||||
|
@ -20,6 +20,7 @@ class IPLocation
|
||||
$this->client = new IPinfo(Yii::$app->params['ipinfoToken']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDetails(string $ip): ?Details
|
||||
{
|
||||
$instance = new self();
|
||||
@ -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