mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-05 04:46:03 +01:00
rewrote this function to make it safer
This commit is contained in:
@@ -1440,23 +1440,22 @@ class Admin
|
||||
{
|
||||
$backup_file = $this->grav['locator']->findResource('log://backup.log');
|
||||
|
||||
if (!file_exists($backup_file)) {
|
||||
$file = JsonFile::instance($backup_file);
|
||||
$content = $file->content() ?? null;
|
||||
|
||||
if (!file_exists($backup_file) || is_null($content) || !isset($content['time'])) {
|
||||
return [
|
||||
'days' => '∞',
|
||||
'chart_fill' => 100,
|
||||
'chart_empty' => 0
|
||||
];
|
||||
}
|
||||
$file = JsonFile::instance($backup_file);
|
||||
$content = $file->content();
|
||||
|
||||
$backup = new \DateTime();
|
||||
$backup->setTimestamp($content['time']);
|
||||
$diff = $backup->diff(new \DateTime());
|
||||
|
||||
$days = $diff->days;
|
||||
$days = $diff->days;
|
||||
$chart_fill = $days > 30 ? 100 : round($days / 30 * 100);
|
||||
|
||||
return [
|
||||
'days' => $days,
|
||||
'chart_fill' => $chart_fill,
|
||||
|
||||
Reference in New Issue
Block a user