diff --git a/system/controllers/paymentgateway.php b/system/controllers/paymentgateway.php index 0fed9f2e..72ed9b4c 100644 --- a/system/controllers/paymentgateway.php +++ b/system/controllers/paymentgateway.php @@ -8,9 +8,17 @@ _admin(); $ui->assign('_system_menu', 'paymentgateway'); -$action = alphanumeric($routes['1']); +$action = alphanumeric($routes[1]); $ui->assign('_admin', $admin); +if ($action == 'delete') { + $pg = alphanumeric($routes[2]); + if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $pg . '.php')) { + deleteFile($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, $pg); + } + r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted')); +} + if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) { include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { @@ -55,3 +63,16 @@ if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) $ui->display('paymentgateway.tpl'); } } + + +function deleteFile($path, $name) +{ + $files = scandir($path); + foreach ($files as $file) { + if (is_file($path . $file) && strpos($file, $name) !== false) { + unlink($path . $file); + } else if (is_dir($path . $file) && !in_array($file, ['.', '..'])) { + deleteFile($path . $file . DIRECTORY_SEPARATOR, $name); + } + } +} diff --git a/ui/ui/paymentgateway.tpl b/ui/ui/paymentgateway.tpl index 3100bb30..0a583bd8 100644 --- a/ui/ui/paymentgateway.tpl +++ b/ui/ui/paymentgateway.tpl @@ -1,33 +1,22 @@ {include file="sections/header.tpl"}
{ucwords($pg)} | ++ |