phpnuxbill/system/controllers/paymentgateway.php

84 lines
2.5 KiB
PHP
Raw Normal View History

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