diff --git a/system/autoload/Admin.php b/system/autoload/Admin.php index 1cd149d2..cdd16f8c 100644 --- a/system/autoload/Admin.php +++ b/system/autoload/Admin.php @@ -12,14 +12,14 @@ class Admin public static function getID() { global $db_pass, $config; - $enable_session_timeout = $config['enable_session_timeout']; -if ($enable_session_timeout) { -$timeout = 0; -if($config['session_timeout_duration']){ -$timeout = intval($config['session_timeout_duration']); -} - $session_timeout_duration = $timeout * 60; // Convert minutes to seconds -} + $enable_session_timeout = $config['enable_session_timeout']; + if ($enable_session_timeout) { + $timeout = 0; + if ($config['session_timeout_duration']) { + $timeout = intval($config['session_timeout_duration']); + } + $session_timeout_duration = $timeout * 60; // Convert minutes to seconds + } if (isset($_SESSION['aid']) && isset($_SESSION['aid_expiration']) && $_SESSION['aid_expiration'] > time()) { return $_SESSION['aid']; diff --git a/system/autoload/Lang.php b/system/autoload/Lang.php index 5a52b96d..5b3f42ed 100644 --- a/system/autoload/Lang.php +++ b/system/autoload/Lang.php @@ -11,7 +11,7 @@ class Lang public static function T($key) { global $_L, $lan_file, $config; - if(is_array($_SESSION['Lang'])){ + if (is_array($_SESSION['Lang'])) { $_L = array_merge($_L, $_SESSION['Lang']); } $key = preg_replace('/\s+/', ' ', $key); @@ -124,20 +124,20 @@ class Lang } } $when = ""; - if(time()>strtotime($datetime)){ + if (time() > strtotime($datetime)) { $when = Lang::T('ago'); - }else{ + } else { $when = ''; } if (!$full) $string = array_slice($string, 0, 1); - if($string){ - if(empty($when)){ - return ''. implode(', ', $string) .''; - }else{ - return implode(', ', $string) .' '. $when; + if ($string) { + if (empty($when)) { + return '' . implode(', ', $string) . ''; + } else { + return implode(', ', $string) . ' ' . $when; } - }else{ + } else { return Lang::T('just now'); } } @@ -245,16 +245,30 @@ class Lang return $txt; } - public static function maskText($text){ + public static function maskText($text) + { $len = strlen($text); - if($len < 3){ + if ($len < 3) { return "***"; - }else if($len<5){ - return substr($text,0,1)."***".substr($text,-1,1); - }else if($len<8){ - return substr($text,0,2)."***".substr($text,-2,2); - }else{ - return substr($text,0,4)."******".substr($text,-3,3); + } else if ($len < 5) { + return substr($text, 0, 1) . "***" . substr($text, -1, 1); + } else if ($len < 8) { + return substr($text, 0, 2) . "***" . substr($text, -2, 2); + } else { + return substr($text, 0, 4) . "******" . substr($text, -3, 3); } } + + // echo Json array to text + public static function jsonArray2text($array, $start = '', $result = '') + { + foreach ($array as $k => $v) { + if (is_array($v)) { + $result .= self::jsonArray2text($v, "$start$k.", ''); + } else { + $result .= "$start$k = " . strval($v) . "\n"; + } + } + return $result; + } } diff --git a/system/controllers/order.php b/system/controllers/order.php index 7b77bea5..177063a9 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -460,7 +460,6 @@ switch ($action) { } else { $d->price = ($plan['price'] + $add_cost + $tax); } - //$d->price = ($plan['price'] + $add_cost); $d->created_date = date('Y-m-d H:i:s'); $d->status = 1; $d->save(); diff --git a/system/controllers/paymentgateway.php b/system/controllers/paymentgateway.php index 7621b11b..a22f848b 100644 --- a/system/controllers/paymentgateway.php +++ b/system/controllers/paymentgateway.php @@ -19,6 +19,36 @@ if ($action == 'delete') { r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted')); } +if ($action == 'audit') { + $pg = alphanumeric($routes[2]); + $q = alphanumeric(_req('q'),'-._ '); + $query = ORM::for_table('tbl_payment_gateway')->order_by_desc("id"); + $query->selects('id', 'username', 'gateway', 'gateway_trx_id', 'plan_id', 'plan_name', 'routers_id', 'routers', 'price', 'pg_url_payment', 'payment_method', 'payment_channel', 'expired_date', 'created_date', 'paid_date', 'trx_invoice', 'status'); + $query->where('gateway', $pg); + if(!empty($q)) { + $query->whereRaw("(gateway_trx_id LIKE '%$q%' OR username LIKE '%$q%' OR routers LIKE '%$q%' OR plan_name LIKE '%$q%')"); + $append_url = 'q='. urlencode($q); + } + $pgs = Paginator::findMany($query, ["search" => $search], 50, $append_url); + + $ui->assign('_title', 'Payment Gateway Audit'); + $ui->assign('pgs', $pgs); + $ui->assign('pg', $pg); + $ui->assign('q', $q); + $ui->display('paymentgateway-audit.tpl'); + die(); +} + +if ($action == 'auditview') { + $pg = alphanumeric($routes[2]); + + $d = ORM::for_table('tbl_payment_gateway')->find_one($pg); + $ui->assign('_title', 'Payment Gateway Audit View'); + $ui->assign('pg', $d); + $ui->display('paymentgateway-audit-view.tpl'); + die(); +} + if (_post('save') == 'actives') { $pgs = ''; if(is_array($_POST['pgs'])){ diff --git a/system/lan/english.json b/system/lan/english.json index 78d6ae85..4dc09ab4 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -681,5 +681,10 @@ "Idle_Timeout__Logout_Admin_if_Idle_for_xx_minutes": "Idle Timeout, Logout Admin if Idle for xx minutes", "Failed_to_create_transaction__please_tell_seller_": "Failed to create transaction, please tell seller.", "paid_off": "paid off", - "Sync_account_if_you_failed_login_to_internet": "Sync account if you failed login to internet" + "Sync_account_if_you_failed_login_to_internet": "Sync account if you failed login to internet", + "Channel": "Channel", + "Payment_Link": "Payment Link", + "Created": "Created", + "2": "2", + "_": "-" } \ No newline at end of file diff --git a/system/updates.json b/system/updates.json index c71bddf3..72a5bfbd 100644 --- a/system/updates.json +++ b/system/updates.json @@ -130,8 +130,8 @@ "ALTER TABLE `tbl_voucher` ADD `used_date` DATETIME NULL DEFAULT NULL AFTER `status`;", "UPDATE `tbl_voucher` SET `used_date`=now() WHERE `status`=1;" ], - "2024.7.31" : [ - "ALTER TABLE `tbl_payment_gateway` CHANGE `gateway_trx_id` `gateway_trx_id` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;", - "ALTER TABLE `tbl_payment_gateway` CHANGE `pg_url_payment` `pg_url_payment` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;" + "2024.8.1" : [ + "ALTER TABLE `tbl_payment_gateway` CHANGE `gateway_trx_id` `gateway_trx_id` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';", + "ALTER TABLE `tbl_payment_gateway` CHANGE `pg_url_payment` `pg_url_payment` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';" ] } \ No newline at end of file diff --git a/ui/ui/paymentgateway-audit-view.tpl b/ui/ui/paymentgateway-audit-view.tpl new file mode 100644 index 00000000..844f6fb0 --- /dev/null +++ b/ui/ui/paymentgateway-audit-view.tpl @@ -0,0 +1,79 @@ +{include file="sections/header.tpl"} + + +
+
+
+
+ {$pg['gateway_trx_id']} +
+
+
    +
  • + TRX ID  {$pg['id']}  +
  • +
  • + {Lang::T('Invoice')}   + {$pg['trx_invoice']} +   +
  • +
  • + {Lang::T('Status')}  {if $pg['status'] == 1}UNPAID{elseif $pg['status'] == 2}PAID{elseif $pg['status'] == 3}FAILED{else}CANCELED{/if}  +
  • +
  • + {Lang::T('Username')} +  {$pg['username']}  +
  • +
  • + {Lang::T('Plan Name')}  {$pg['plan_name']}  +
  • +
  • + {Lang::T('Routers')}  {$pg['routers']}  +
  • +
  • + {Lang::T('Price')}  {Lang::moneyFormat($pg['price'])}  +
  • +
  • + {Lang::T('Payment Link')}  {if $pg['pg_url_payment']} + open + {/if}  +
  • +
  • + {Lang::T('Channel')}  {$pg['payment_method']} - + {$pg['payment_channel']}  +
  • +
  • + {Lang::T('Created')}  {if $pg['created_date'] != null}{Lang::dateTimeFormat($pg['created_date'])}{/if}  +
  • +
  • + {Lang::T('Expired')}  {if $pg['expired_date'] != null}{Lang::dateTimeFormat($pg['expired_date'])}{/if}  +
  • +
  • + {Lang::T('Paid')}  {if $pg['paid_date'] != null}{Lang::dateTimeFormat($pg['paid_date'])}{/if}  +
  • +
+
+
+
+
+ +
+
+ Response when request payment +
+
{if $pg['pg_request'] != null}{Lang::jsonArray2text(json_decode($pg['pg_request'], true))}{/if}
+
+
+
+ Response when payment PAID +
+
{if $pg['pg_request'] != null}{Lang::jsonArray2text(json_decode($pg['pg_paid_response'], true))}{/if}
+
+ +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/paymentgateway-audit.tpl b/ui/ui/paymentgateway-audit.tpl new file mode 100644 index 00000000..7c97a2f0 --- /dev/null +++ b/ui/ui/paymentgateway-audit.tpl @@ -0,0 +1,71 @@ +{include file="sections/header.tpl"} +
+
+ {ucwords($pg)} +
+
+ +
+ + + + + + + + + + + + + + + + + + + + {foreach $pgs as $pg} + + + + + + + + + + + + + + + + {/foreach} + +
TRX IDPG ID{Lang::T('Username')}{Lang::T('Plan Name')}{Lang::T('Routers')}{Lang::T('Price')}{Lang::T('Payment Link')}{Lang::T('Channel')}{Lang::T('Created')}{Lang::T('Expired')}{Lang::T('Paid')}{Lang::T('Invoice')}{Lang::T('Status')}
{$pg['id']}{$pg['gateway_trx_id']}{$pg['username']} + {$pg['plan_name']}{$pg['routers']}{Lang::moneyFormat($pg['price'])} + {if $pg['pg_url_payment']} + open + {/if} + {$pg['payment_method']} - {$pg['payment_channel']}{if $pg['created_date'] != null}{Lang::dateTimeFormat($pg['created_date'])}{/if}{if $pg['expired_date'] != null}{Lang::dateTimeFormat($pg['expired_date'])}{/if}{if $pg['paid_date'] != null}{Lang::dateTimeFormat($pg['paid_date'])}{/if}{if $pg['trx_invoice']}{$pg['trx_invoice']}{/if}{if $pg['status'] == 1}UNPAID{elseif $pg['status'] == 2}PAID{elseif $pg['status'] == 3}FAILED{else}CANCELED{/if} +
+
+ {include file="pagination.tpl"} + kembali +
+
+ +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/paymentgateway.tpl b/ui/ui/paymentgateway.tpl index 14297297..bb22196d 100644 --- a/ui/ui/paymentgateway.tpl +++ b/ui/ui/paymentgateway.tpl @@ -14,9 +14,19 @@ {ucwords($pg)} - + +
+
+ Audit +
+
+ +
+
+ {/foreach} diff --git a/version.json b/version.json index ef69fb2f..5695ed0e 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2024.8.1" + "version": "2024.8.1.1" } \ No newline at end of file