Add Disk Size to Simple Stats
This commit is contained in:
parent
1a208b0642
commit
a39d3fff7f
@ -264,4 +264,32 @@ class Filesystem {
|
||||
public static function extension($file) {
|
||||
return pathinfo($file, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Size of file or directory in bytes
|
||||
* @param [string] $fileOrDirectory
|
||||
* @return [int|bool [bytes or false on error]
|
||||
*/
|
||||
public static function getSize($fileOrDirectory) {
|
||||
// Files
|
||||
if (is_file($fileOrDirectory)) {
|
||||
return filesize($fileOrDirectory);
|
||||
}
|
||||
// Directories
|
||||
if (file_exists($fileOrDirectory)) {
|
||||
$size = 0;
|
||||
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fileOrDirectory)) as $file){
|
||||
$size += $file->getSize();
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function bytesToHumanFileSize($bytes, $decimals = 2) {
|
||||
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
|
||||
$factor = floor((strlen($bytes) - 1) / 3);
|
||||
return sprintf("%.{$decimals}f ", $bytes / pow(1024, $factor)) . @$size[$factor];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Seitenaufrufe heute",
|
||||
"unique-visitors-today": "Besucher heute",
|
||||
"chart": "Chart",
|
||||
"table": "Table"
|
||||
"table": "Table",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Seitenaufrufe heute",
|
||||
"unique-visitors-today": "Besucher heute",
|
||||
"chart": "Chart",
|
||||
"table": "Table"
|
||||
"table": "Table",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Visits today",
|
||||
"unique-visitors-today": "Unique visitors today",
|
||||
"chart": "Chart",
|
||||
"table": "Table"
|
||||
"table": "Table",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Visitas de hoy",
|
||||
"unique-visitors-today": "Visitantes únicos de hoy",
|
||||
"chart": "Gráfico",
|
||||
"table": "Tabla"
|
||||
}
|
||||
"table": "Tabla",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "بازدیدهای امروز",
|
||||
"unique-visitors-today": "بازدید کنندگان منحصر به فرد امروز",
|
||||
"chart": "چارت",
|
||||
"table": "جدول"
|
||||
"table": "جدول",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Visites du jour",
|
||||
"unique-visitors-today": "Visiteurs uniques du jour",
|
||||
"chart": "Graphique",
|
||||
"table": "Tableau"
|
||||
"table": "Tableau",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Visite oggi",
|
||||
"unique-visitors-today": "Visitatori unici oggi",
|
||||
"chart": "Grafico",
|
||||
"table": "Tabella"
|
||||
"table": "Tabella",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Visits today",
|
||||
"unique-visitors-today": "Unique visitors today",
|
||||
"chart": "Chart",
|
||||
"table": "テーブル"
|
||||
"table": "テーブル",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Aantal bezoeken vandaag",
|
||||
"unique-visitors-today": "Unieke bezoekers vandaag",
|
||||
"chart": "Grafiek",
|
||||
"table": "Tabel"
|
||||
"table": "Tabel",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Посещений сегодня",
|
||||
"unique-visitors-today": "Уникальных посетителей сегодня",
|
||||
"chart": "Диаграмма",
|
||||
"table": "Таблица"
|
||||
"table": "Таблица",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"visits-today": "Bugün yapılan ziyaretler",
|
||||
"unique-visitors-today": "Bugün yapılan benzersiz ziyaretler",
|
||||
"chart": "Grafik",
|
||||
"table": "Tablo"
|
||||
"table": "Tablo",
|
||||
"disk-usage" : "Disk Usage"
|
||||
}
|
||||
|
@ -220,6 +220,11 @@ EOF;
|
||||
|
||||
public function renderContentStatistics($data)
|
||||
{
|
||||
global $L;
|
||||
$diskUsage = Filesystem::bytesToHumanFileSize(
|
||||
Filesystem::getSize(PATH_ROOT)
|
||||
);
|
||||
|
||||
$html = '<div class="my-5 pt-4 border-top">';
|
||||
$html .= "<h4 class='pb-2'>{$data['title']}</h4>";
|
||||
$html .= '
|
||||
@ -237,6 +242,7 @@ EOF;
|
||||
<table class="table table-borderless table-sm table-striped mt-3">
|
||||
<tbody>';
|
||||
|
||||
$html .= "<tr><th>{$L->get('disk-usage')}</th><td>$diskUsage</td></tr>";
|
||||
foreach ($data['data'] as $th => $td) {
|
||||
$html .= "
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user