Merge branch 'master' of github.com:dignajar/bludit
This commit is contained in:
commit
b9a474311b
|
@ -890,4 +890,18 @@ function transformImage($file, $imageDir, $thumbnailDir=false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $image;
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function downloadRestrictedFile($file) {
|
||||||
|
if (is_file($file)) {
|
||||||
|
header('Content-Description: File Transfer');
|
||||||
|
header('Content-Type: application/octet-stream');
|
||||||
|
header('Content-Disposition: attachment; filename="'.basename($file).'"');
|
||||||
|
header('Expires: 0');
|
||||||
|
header('Cache-Control: must-revalidate');
|
||||||
|
header('Pragma: public');
|
||||||
|
header('Content-Length: ' . filesize($file));
|
||||||
|
readfile($file);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -264,4 +264,32 @@ class Filesystem {
|
||||||
public static function extension($file) {
|
public static function extension($file) {
|
||||||
return pathinfo($file, PATHINFO_EXTENSION);
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,13 @@ class pluginBackup extends Plugin {
|
||||||
|
|
||||||
public function adminSidebar()
|
public function adminSidebar()
|
||||||
{
|
{
|
||||||
$backups = $this->backupList();
|
global $login;
|
||||||
return '<a class="nav-link" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$this->className().'">Backups <span class="badge badge-primary badge-pill">'.count($backups).'</span></a>';
|
if ($login->role() === 'admin') {
|
||||||
|
$backups = $this->backupList();
|
||||||
|
return '<a class="nav-link" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$this->className().'">Backups <span class="badge badge-primary badge-pill">'.count($backups).'</span></a>';
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function form()
|
public function form()
|
||||||
|
@ -66,7 +71,7 @@ class pluginBackup extends Plugin {
|
||||||
$html .= '<h4 class="font-weight-normal">'.Date::format($filename, BACKUP_DATE_FORMAT, 'F j, Y, g:i a').'</h4>';
|
$html .= '<h4 class="font-weight-normal">'.Date::format($filename, BACKUP_DATE_FORMAT, 'F j, Y, g:i a').'</h4>';
|
||||||
// Allow download if a zip file
|
// Allow download if a zip file
|
||||||
if ($this->zip) {
|
if ($this->zip) {
|
||||||
$html .= '<a class="btn btn-outline-secondary btn-sm mr-1 mt-1" href="'.DOMAIN_CONTENT.'workspaces/backup/'.$filename.'.zip"><span class="fa fa-download"></span> '.$L->get('download').'</a>';
|
$html .= '<a class="btn btn-outline-secondary btn-sm mr-1 mt-1" href="'.DOMAIN_BASE.'plugin-backup-download?file='.$filename.'.zip"><span class="fa fa-download"></span> '.$L->get('download').'</a>';
|
||||||
}
|
}
|
||||||
$html .= '<button name="restoreBackup" value="'.$filename.'" class="btn btn-outline-secondary btn-sm mr-1 mt-1" type="submit"><span class="fa fa-rotate-left"></span> '.$L->get('restore-backup').'</button>';
|
$html .= '<button name="restoreBackup" value="'.$filename.'" class="btn btn-outline-secondary btn-sm mr-1 mt-1" type="submit"><span class="fa fa-rotate-left"></span> '.$L->get('restore-backup').'</button>';
|
||||||
$html .= '<button name="deleteBackup" value="'.$filename.'" class="btn btn-outline-danger btn-sm mr-1 mt-1" type="submit"><span class="fa fa-trash"></span> '.$L->get('delete-backup').'</button>';
|
$html .= '<button name="deleteBackup" value="'.$filename.'" class="btn btn-outline-danger btn-sm mr-1 mt-1" type="submit"><span class="fa fa-trash"></span> '.$L->get('delete-backup').'</button>';
|
||||||
|
@ -76,6 +81,29 @@ class pluginBackup extends Plugin {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloading Backups is not allowed by default server config
|
||||||
|
* This webhook is to allow downloads for admins
|
||||||
|
* Webhook: plugin-backup-download?file={backup-name.zip}
|
||||||
|
*/
|
||||||
|
public function beforeAll()
|
||||||
|
{
|
||||||
|
global $L;
|
||||||
|
$webhook = 'plugin-backup-download';
|
||||||
|
if ($this->webhook($webhook)) {
|
||||||
|
if (!empty($_GET['file'])) {
|
||||||
|
$login = new Login();
|
||||||
|
if ($login->role() === 'admin') {
|
||||||
|
downloadRestrictedFile(PATH_WORKSPACES.'backup/'.$_GET['file']);
|
||||||
|
} else {
|
||||||
|
Alert::set($L->g('You do not have sufficient permissions'));
|
||||||
|
Redirect::page('dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function backupList()
|
public function backupList()
|
||||||
{
|
{
|
||||||
if ($this->zip) {
|
if ($this->zip) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -8,5 +8,6 @@
|
||||||
"visits-today": "Seitenaufrufe heute",
|
"visits-today": "Seitenaufrufe heute",
|
||||||
"unique-visitors-today": "Besucher heute",
|
"unique-visitors-today": "Besucher heute",
|
||||||
"chart": "Chart",
|
"chart": "Chart",
|
||||||
"table": "Table"
|
"table": "Table",
|
||||||
|
"disk-usage" : "Disk Usage"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
"visits-today": "Seitenaufrufe heute",
|
"visits-today": "Seitenaufrufe heute",
|
||||||
"unique-visitors-today": "Besucher heute",
|
"unique-visitors-today": "Besucher heute",
|
||||||
"chart": "Chart",
|
"chart": "Chart",
|
||||||
"table": "Table"
|
"table": "Table",
|
||||||
|
"disk-usage" : "Disk Usage"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
"visits-today": "Visits today",
|
"visits-today": "Visits today",
|
||||||
"unique-visitors-today": "Unique visitors today",
|
"unique-visitors-today": "Unique visitors today",
|
||||||
"chart": "Chart",
|
"chart": "Chart",
|
||||||
"table": "Table"
|
"table": "Table",
|
||||||
|
"disk-usage" : "Disk Usage"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
"visits-today": "Visitas de hoy",
|
"visits-today": "Visitas de hoy",
|
||||||
"unique-visitors-today": "Visitantes únicos de hoy",
|
"unique-visitors-today": "Visitantes únicos de hoy",
|
||||||
"chart": "Gráfico",
|
"chart": "Gráfico",
|
||||||
"table": "Tabla"
|
"table": "Tabla",
|
||||||
}
|
"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": "Visites du jour",
|
"visits-today": "Visites du jour",
|
||||||
"unique-visitors-today": "Visiteurs uniques du jour",
|
"unique-visitors-today": "Visiteurs uniques du jour",
|
||||||
"chart": "Graphique",
|
"chart": "Graphique",
|
||||||
"table": "Tableau"
|
"table": "Tableau",
|
||||||
|
"disk-usage" : "Disk Usage"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
"visits-today": "Visite oggi",
|
"visits-today": "Visite oggi",
|
||||||
"unique-visitors-today": "Visitatori unici oggi",
|
"unique-visitors-today": "Visitatori unici oggi",
|
||||||
"chart": "Grafico",
|
"chart": "Grafico",
|
||||||
"table": "Tabella"
|
"table": "Tabella",
|
||||||
|
"disk-usage" : "Disk Usage"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
"visits-today": "Visits today",
|
"visits-today": "Visits today",
|
||||||
"unique-visitors-today": "Unique visitors today",
|
"unique-visitors-today": "Unique visitors today",
|
||||||
"chart": "Chart",
|
"chart": "Chart",
|
||||||
"table": "テーブル"
|
"table": "テーブル",
|
||||||
|
"disk-usage" : "Disk Usage"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
"visits-today": "Aantal bezoeken vandaag",
|
"visits-today": "Aantal bezoeken vandaag",
|
||||||
"unique-visitors-today": "Unieke bezoekers vandaag",
|
"unique-visitors-today": "Unieke bezoekers vandaag",
|
||||||
"chart": "Grafiek",
|
"chart": "Grafiek",
|
||||||
"table": "Tabel"
|
"table": "Tabel",
|
||||||
|
"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": "Bugün yapılan ziyaretler",
|
"visits-today": "Bugün yapılan ziyaretler",
|
||||||
"unique-visitors-today": "Bugün yapılan benzersiz ziyaretler",
|
"unique-visitors-today": "Bugün yapılan benzersiz ziyaretler",
|
||||||
"chart": "Grafik",
|
"chart": "Grafik",
|
||||||
"table": "Tablo"
|
"table": "Tablo",
|
||||||
|
"disk-usage" : "Disk Usage"
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,6 +220,11 @@ EOF;
|
||||||
|
|
||||||
public function renderContentStatistics($data)
|
public function renderContentStatistics($data)
|
||||||
{
|
{
|
||||||
|
global $L;
|
||||||
|
$diskUsage = Filesystem::bytesToHumanFileSize(
|
||||||
|
Filesystem::getSize(PATH_ROOT)
|
||||||
|
);
|
||||||
|
|
||||||
$html = '<div class="my-5 pt-4 border-top">';
|
$html = '<div class="my-5 pt-4 border-top">';
|
||||||
$html .= "<h4 class='pb-2'>{$data['title']}</h4>";
|
$html .= "<h4 class='pb-2'>{$data['title']}</h4>";
|
||||||
$html .= '
|
$html .= '
|
||||||
|
@ -237,6 +242,7 @@ EOF;
|
||||||
<table class="table table-borderless table-sm table-striped mt-3">
|
<table class="table table-borderless table-sm table-striped mt-3">
|
||||||
<tbody>';
|
<tbody>';
|
||||||
|
|
||||||
|
$html .= "<tr><th>{$L->get('disk-usage')}</th><td>$diskUsage</td></tr>";
|
||||||
foreach ($data['data'] as $th => $td) {
|
foreach ($data['data'] as $th => $td) {
|
||||||
$html .= "
|
$html .= "
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue