mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 19:54:31 +00:00
Restore stable watermark settings
This commit is contained in:
@@ -4,59 +4,6 @@ if (!defined('PHPWG_ROOT_PATH'))
|
||||
die('Hacking attempt!');
|
||||
}
|
||||
|
||||
function bratonien_tools_watermark_cache_dir()
|
||||
{
|
||||
return PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.'bratonien-watermark';
|
||||
}
|
||||
|
||||
function bratonien_tools_remove_tree($path)
|
||||
{
|
||||
$path = rtrim((string)$path, DIRECTORY_SEPARATOR);
|
||||
if ($path === '' || !file_exists($path)) return;
|
||||
|
||||
if (is_file($path) || is_link($path))
|
||||
{
|
||||
@unlink($path);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (scandir($path) ?: array() as $entry)
|
||||
{
|
||||
if ($entry === '.' || $entry === '..') continue;
|
||||
bratonien_tools_remove_tree($path.DIRECTORY_SEPARATOR.$entry);
|
||||
}
|
||||
@rmdir($path);
|
||||
}
|
||||
|
||||
function bratonien_tools_clear_watermark_cache()
|
||||
{
|
||||
$dir = bratonien_tools_watermark_cache_dir();
|
||||
$derivative_root = realpath(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR);
|
||||
$parent = realpath(dirname($dir));
|
||||
|
||||
if ($derivative_root === false || $parent === false || $parent !== $derivative_root)
|
||||
{
|
||||
throw new RuntimeException('Wasserzeichen-Cachepfad ist ungueltig.');
|
||||
}
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
bratonien_tools_remove_tree($dir);
|
||||
}
|
||||
}
|
||||
|
||||
function bratonien_tools_watermark_cache_upgrade()
|
||||
{
|
||||
$version = '0.9.7.13';
|
||||
if ((string)conf_get_param('bratonien_watermark_cache_version', '') === $version)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bratonien_tools_clear_watermark_cache();
|
||||
conf_update_param('bratonien_watermark_cache_version', $version);
|
||||
}
|
||||
|
||||
function bratonien_tools_get_watermark_defaults()
|
||||
{
|
||||
$defaults = conf_get_param('bratonien_watermark_defaults', null);
|
||||
@@ -93,7 +40,6 @@ function bratonien_tools_save_watermark_defaults()
|
||||
);
|
||||
|
||||
conf_update_param('bratonien_watermark_defaults', json_encode($config));
|
||||
bratonien_tools_clear_watermark_cache();
|
||||
|
||||
return array('message'=>'Globale Wasserzeichenregeln gespeichert.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user