mitrobill/system/controllers/paymentgateway.php

79 lines
2.5 KiB
PHP
Raw Normal View History

2022-09-05 15:12:00 +07:00
<?php
2024-02-26 14:38:04 +07:00
2022-09-05 15:12:00 +07:00
/**
2023-10-12 15:55:42 +07:00
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
**/
2022-09-05 15:12:00 +07:00
_admin();
$ui->assign('_system_menu', 'paymentgateway');
2024-03-12 10:00:28 +07:00
$action = alphanumeric($routes[1]);
2022-09-05 15:12:00 +07:00
$ui->assign('_admin', $admin);
2024-03-12 10:00:28 +07:00
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'));
}
2024-02-26 14:38:04 +07:00
if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) {
include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php';
2022-09-16 11:05:33 +07:00
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2024-02-26 14:38:04 +07:00
if (function_exists($action . '_save_config')) {
call_user_func($action . '_save_config');
} else {
2022-09-16 11:05:33 +07:00
$ui->display('a404.tpl');
}
2024-02-26 14:38:04 +07:00
} else {
if (function_exists($action . '_show_config')) {
call_user_func($action . '_show_config');
} else {
2022-09-16 11:05:33 +07:00
$ui->display('a404.tpl');
}
}
2024-02-26 14:38:04 +07:00
} else {
if (!empty($action)) {
2022-09-16 11:05:33 +07:00
r2(U . 'paymentgateway', 'w', Lang::T('Payment Gateway Not Found'));
2024-02-26 14:38:04 +07:00
} else {
$files = scandir($PAYMENTGATEWAY_PATH);
foreach ($files as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) == 'php') {
$pgs[] = str_replace('.php', '', $file);
2022-09-16 11:05:33 +07:00
}
}
2024-02-26 14:38:04 +07:00
if (isset($_POST['payment_gateway'])) {
2022-09-16 11:05:33 +07:00
$payment_gateway = _post('payment_gateway');
$d = ORM::for_table('tbl_appconfig')->where('setting', 'payment_gateway')->find_one();
2024-02-26 14:38:04 +07:00
if ($d) {
2022-09-16 11:05:33 +07:00
$d->value = $payment_gateway;
$d->save();
2024-02-26 14:38:04 +07:00
} else {
2022-09-16 11:05:33 +07:00
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'payment_gateway';
$d->value = $payment_gateway;
$d->save();
}
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway saved successfully'));
}
2022-10-13 14:00:54 +07:00
$ui->assign('_title', 'Payment Gateway Settings');
2022-09-16 11:05:33 +07:00
$ui->assign('pgs', $pgs);
$ui->display('paymentgateway.tpl');
}
2024-02-26 14:38:04 +07:00
}
2024-03-12 10:00:28 +07:00
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);
}
}
}