Files
snipe-it/app/models/Setting.php
T
snipe 818d1769b8 Automated backup to dump SQL and zip uploaded files
Usage:

`php artisan snipeit:backup`

This can be set on a cron or scheduled task
2015-06-22 15:52:26 -07:00

78 lines
1.8 KiB
PHP
Executable File

<?php
class Setting extends Elegant
{
public static function getSettings()
{
static $static_cache = NULL;
if (!$static_cache) {
$static_cache = Setting::find(1);
}
return $static_cache;
}
public function lar_ver()
{
$app = App::getFacadeApplication();
return $app::VERSION;
}
public static function getDefaultEula() {
$Parsedown = new Parsedown();
if (Setting::getSettings()->default_eula_text) {
return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
} else {
return null;
}
}
/**
* Converts bytes into human readable file size.
*
* @param string $bytes
* @return string human readable file size (2,87 Мб)
* @author Mogilev Arseny
*/
public static function fileSizeConvert($bytes)
{
$bytes = floatval($bytes);
$arBytes = array(
0 => array(
"UNIT" => "TB",
"VALUE" => pow(1024, 4)
),
1 => array(
"UNIT" => "GB",
"VALUE" => pow(1024, 3)
),
2 => array(
"UNIT" => "MB",
"VALUE" => pow(1024, 2)
),
3 => array(
"UNIT" => "KB",
"VALUE" => 1024
),
4 => array(
"UNIT" => "B",
"VALUE" => 1
),
);
foreach($arBytes as $arItem)
{
if($bytes >= $arItem["VALUE"])
{
$result = $bytes / $arItem["VALUE"];
$result = round($result,2) .$arItem["UNIT"];
break;
}
}
return $result;
}
}