增加获取预格式化后数据功能

This commit is contained in:
Chenx221 2024-03-22 14:48:17 +08:00
parent 41bfaafc4f
commit 96a5dcb9a5
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 23 additions and 3 deletions

View File

@ -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

View File

@ -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)) . ')';
}
}