migrate old image + fix versioning

This commit is contained in:
Daniel Schmitz 2021-07-09 17:07:50 +08:00
parent 48f6601003
commit 282d7d9101
2 changed files with 36 additions and 9 deletions

View File

@ -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');
}

View File

@ -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)