From 282d7d9101c71f2d23982758dbe130a3aa387b04 Mon Sep 17 00:00:00 2001 From: Daniel Schmitz Date: Fri, 9 Jul 2021 17:07:50 +0800 Subject: [PATCH] migrate old image + fix versioning --- .../updates/froxlor/0.10/update_0.10.inc.php | 31 +++++++++++++++++-- lib/Froxlor/Froxlor.php | 14 ++++----- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/install/updates/froxlor/0.10/update_0.10.inc.php b/install/updates/froxlor/0.10/update_0.10.inc.php index 278f6c43..1f2d360e 100644 --- a/install/updates/froxlor/0.10/update_0.10.inc.php +++ b/install/updates/froxlor/0.10/update_0.10.inc.php @@ -826,12 +826,39 @@ if (\Froxlor\Froxlor::isDatabaseVersion('202106160')) { \Froxlor\Froxlor::updateToDbVersion('202106270'); } -if (\Froxlor\Froxlor::isDatabaseVersion('202107070')) { - +if (\Froxlor\Froxlor::isDatabaseVersion('202106270')) { showUpdateStep("Adding custom logo image settings", true); Settings::AddNew("panel.logo_image_header", ''); Settings::AddNew("panel.logo_image_login", ''); lastStepStatus(0); + // Migrating old custom logo over, if exists + $custom_logo_file_old = \Froxlor\Froxlor::getInstallDir() . '/templates/Sparkle/assets/img/logo_custom.png'; + if (file_exists($custom_logo_file_old)) { + showUpdateStep("Migrating existing custom logo to new settings", true); + + $path = \Froxlor\Froxlor::getInstallDir().'/img/'; + if (!is_dir($path) && !mkdir($path, 0775)) { + throw new \Exception("img directory does not exist and cannot be created"); + } + if (!is_writable($path)) { + if (!chmod($path, '0775')) { + throw new \Exception("Cannot write to img directory"); + } + } + + // Save as new custom logo header + $save_to = 'logo_header.png'; + copy($custom_logo_file_old, $path.$save_to); + Settings::Set("panel.logo_image_header", "img/{$save_to}?v=".time()); + + // Save as new custom logo login + $save_to = 'logo_login.png'; + copy($custom_logo_file_old, $path.$save_to); + Settings::Set("panel.logo_image_login", "img/{$save_to}?v=".time()); + + lastStepStatus(0); + } + \Froxlor\Froxlor::updateToDbVersion('202107070'); } diff --git a/lib/Froxlor/Froxlor.php b/lib/Froxlor/Froxlor.php index e9ccbe30..9e9fb3f2 100644 --- a/lib/Froxlor/Froxlor.php +++ b/lib/Froxlor/Froxlor.php @@ -10,7 +10,7 @@ final class Froxlor const VERSION = '0.10.26'; // Database version (YYYYMMDDC where C is a daily counter) - const DBVERSION = '202106270'; + const DBVERSION = '202107070'; // Distribution branding-tag (used for Debian etc.) const BRANDING = ''; @@ -63,7 +63,7 @@ final class Froxlor * * @param string $to_check * version to check, if empty current version is used - * + * * @return bool true if version to check does not match, else false */ public static function hasUpdates($to_check = null) @@ -84,7 +84,7 @@ final class Froxlor * * @param int $to_check * version to check, if empty current dbversion is used - * + * * @return bool true if version to check does not match, else false */ public static function hasDbUpdates($to_check = null) @@ -105,7 +105,7 @@ final class Froxlor * * @param int $to_check * version to check - * + * * @return bool true if version to check matches, else false */ public static function isDatabaseVersion($to_check = null) @@ -124,7 +124,7 @@ final class Froxlor * * @param string $new_version * new-version - * + * * @return bool true on success, else false */ public static function updateToDbVersion($new_version = null) @@ -150,7 +150,7 @@ final class Froxlor * * @param string $new_version * new-version - * + * * @return bool true on success, else false */ public static function updateToVersion($new_version = null) @@ -191,7 +191,7 @@ final class Froxlor * * @param string $to_check * version to check - * + * * @return bool true if version to check matches, else false */ public static function isFroxlorVersion($to_check = null)