2022-09-13 13:14:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
|
|
|
use Misuzu\Config;
|
2023-01-01 20:23:53 +00:00
|
|
|
use Misuzu\Config\CfgTools;
|
2022-09-13 13:14:49 +00:00
|
|
|
use Misuzu\Users\User;
|
|
|
|
|
|
|
|
require_once '../../../misuzu.php';
|
|
|
|
|
|
|
|
if(!User::hasCurrent()
|
|
|
|
|| !perms_check_user(MSZ_PERMS_GENERAL, User::getCurrent()->getId(), MSZ_PERM_GENERAL_MANAGE_CONFIG)) {
|
|
|
|
echo render_error(403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sName = (string)filter_input(INPUT_GET, 'name');
|
2023-01-01 20:23:53 +00:00
|
|
|
if(!CfgTools::validateName($sName) || !$cfg->hasValue($sName))
|
2022-09-13 13:14:49 +00:00
|
|
|
throw new \Exception("Config value does not exist.");
|
|
|
|
|
|
|
|
if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
if(!CSRF::validateRequest())
|
|
|
|
throw new \Exception("Request verification failed.");
|
|
|
|
|
2023-07-17 17:43:17 +00:00
|
|
|
$msz->createAuditLog('CONFIG_DELETE', [$sName]);
|
2023-01-01 20:23:53 +00:00
|
|
|
$cfg->removeValue($sName);
|
2022-09-13 13:14:49 +00:00
|
|
|
url_redirect('manage-general-settings');
|
|
|
|
} else {
|
2023-01-01 20:23:53 +00:00
|
|
|
$sValue = $cfg->getValue($sName);
|
2022-09-13 13:14:49 +00:00
|
|
|
|
|
|
|
Template::render('manage.general.setting-delete', [
|
|
|
|
'conf_var' => [
|
|
|
|
'name' => $sName,
|
2023-01-01 20:23:53 +00:00
|
|
|
'type' => CfgTools::type($sValue),
|
2022-09-13 13:14:49 +00:00
|
|
|
'value' => $sValue,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|