Merge branch 'hotspotbilling:Development' into Development

This commit is contained in:
Focuslinkstech 2024-12-22 09:30:20 +01:00 committed by GitHub
commit 486c849eee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 77 additions and 30 deletions

View File

@ -72,7 +72,7 @@ DROP TABLE IF EXISTS `tbl_payment_gateway`;
CREATE TABLE `tbl_payment_gateway` ( CREATE TABLE `tbl_payment_gateway` (
`id` int NOT NULL, `id` int NOT NULL,
`username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`user_id` int(11) NOT NULL, `user_id` int(11) INT NOT NULL DEFAULT 0,
`gateway` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'xendit | midtrans', `gateway` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'xendit | midtrans',
`gateway_trx_id` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `gateway_trx_id` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`plan_id` int NOT NULL, `plan_id` int NOT NULL,
@ -151,7 +151,7 @@ CREATE TABLE `tbl_transactions` (
`id` int NOT NULL, `id` int NOT NULL,
`invoice` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `invoice` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`user_id` int(11) NOT NULL, `user_id` int(11) INT NOT NULL DEFAULT 0,
`plan_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `plan_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`price` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `price` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`recharged_on` date NOT NULL, `recharged_on` date NOT NULL,

View File

@ -42,7 +42,7 @@ try {
$CHAPchallenge = _req('CHAPchallenge'); $CHAPchallenge = _req('CHAPchallenge');
$isCHAP = false; $isCHAP = false;
if (!empty($CHAPassword)) { if (!empty($CHAPassword)) {
$c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username'")->find_one(); $c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username' AND status = 'Active'")->find_one();
if ($c) { if ($c) {
if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) { if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['password']; $password = $c['password'];
@ -68,7 +68,7 @@ try {
} }
} }
} else { } else {
$c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY `pppoe_username` = '$username'")->find_one(); $c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY pppoe_username = '$username' AND status = 'Active'")->find_one();
if ($c) { if ($c) {
if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) { if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['password']; $password = $c['password'];
@ -111,7 +111,7 @@ try {
$username = Text::alphanumeric($username, "-_.,"); $username = Text::alphanumeric($username, "-_.,");
$d = ORM::for_table('tbl_voucher')->whereRaw("BINARY code = '$username'")->find_one(); $d = ORM::for_table('tbl_voucher')->whereRaw("BINARY code = '$username'")->find_one();
} else { } else {
$d = ORM::for_table('tbl_customers')->whereRaw("BINARY username = '$username'")->find_one(); $d = ORM::for_table('tbl_customers')->whereRaw("BINARY username = '$username' AND status = 'Active'")->find_one();
if ($d['password'] != $password) { if ($d['password'] != $password) {
if ($d['pppoe_password'] != $password) { if ($d['pppoe_password'] != $password) {
unset($d); unset($d);
@ -136,7 +136,7 @@ try {
$CHAPchallenge = _req('CHAPchallenge'); $CHAPchallenge = _req('CHAPchallenge');
$isCHAP = false; $isCHAP = false;
if (!empty($CHAPassword)) { if (!empty($CHAPassword)) {
$c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username'")->find_one(); $c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username' AND status = 'Active'")->find_one();
if ($c) { if ($c) {
if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) { if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['password']; $password = $c['password'];
@ -162,14 +162,16 @@ try {
} }
} }
} else { } else {
$c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY `pppoe_username` = '$username'")->find_one(); $c = ORM::for_table('tbl_customers')->select('password')->select('username')->select('pppoe_password')->whereRaw("BINARY pppoe_username = '$username' AND status = 'Active'")->find_one();
if ($c) { if ($c) {
if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) { if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['password']; $password = $c['password'];
$username = $c['username'];
$isVoucher = false; $isVoucher = false;
$isCHAP = true; $isCHAP = true;
} else if (!empty($c['pppoe_password']) && Password::chap_verify($c['pppoe_password'], $CHAPassword, $CHAPchallenge)) { } else if (!empty($c['pppoe_password']) && Password::chap_verify($c['pppoe_password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['pppoe_password']; $password = $c['pppoe_password'];
$username = $c['username'];
$isVoucher = false; $isVoucher = false;
$isCHAP = true; $isCHAP = true;
} else { } else {
@ -202,9 +204,15 @@ try {
} }
} }
$tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username'")->find_one(); $tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username'")->find_one();
if (!$tur) {
// if check if pppoe_username
$c = ORM::for_table('tbl_customers')->select('username')->select('pppoe_password')->whereRaw("BINARY pppoe_username = '$username'")->find_one();
$username = $c['username'];
$tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username'")->find_one();
}
if ($tur) { if ($tur) {
if (!$isVoucher && !$isCHAP) { if (!$isVoucher && !$isCHAP) {
$d = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username'")->find_one(); $d = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username' AND status = 'Active'")->find_one();
if ($d) { if ($d) {
if ($d['password'] != $password) { if ($d['password'] != $password) {
if ($d['pppoe_password'] != $password) { if ($d['pppoe_password'] != $password) {
@ -212,7 +220,7 @@ try {
} }
} }
} else { } else {
$d = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY `pppoe_username` = '$username'")->find_one(); $d = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY pppoe_username = '$username' AND status = 'Active'")->find_one();
if ($d) { if ($d) {
if ($d['password'] != $password) { if ($d['password'] != $password) {
if ($d['pppoe_password'] != $password) { if ($d['pppoe_password'] != $password) {
@ -226,7 +234,7 @@ try {
} else { } else {
if ($isVoucher) { if ($isVoucher) {
$username = Text::alphanumeric($username, "-_.,"); $username = Text::alphanumeric($username, "-_.,");
$v = ORM::for_table('tbl_voucher')->whereRaw("BINARY code = '$username'")->where('routers', 'radius')->find_one(); $v = ORM::for_table('tbl_voucher')->whereRaw("BINARY code = '$username' AND routers = 'radius'")->find_one();
if ($v) { if ($v) {
if ($v['status'] == 0) { if ($v['status'] == 0) {
if (Package::rechargeUser(0, $v['routers'], $v['id_plan'], "Voucher", $username)) { if (Package::rechargeUser(0, $v['routers'], $v['id_plan'], "Voucher", $username)) {
@ -264,8 +272,7 @@ try {
} }
header("HTTP/1.1 200 ok"); header("HTTP/1.1 200 ok");
$d = ORM::for_table('rad_acct') $d = ORM::for_table('rad_acct')
->whereRaw("BINARY username = '$username'") ->whereRaw("BINARY username = '$username' AND acctsessionid = '"._post('acctsessionid')."'")
->where('acctsessionid', _post('acctsessionid'))
->findOne(); ->findOne();
if (!$d) { if (!$d) {
$d = ORM::for_table('rad_acct')->create(); $d = ORM::for_table('rad_acct')->create();
@ -292,7 +299,7 @@ try {
$d->dateAdded = date('Y-m-d H:i:s'); $d->dateAdded = date('Y-m-d H:i:s');
$d->save(); $d->save();
if (_post('acctStatusType') == 'Start') { if (_post('acctStatusType') == 'Start') {
$tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username'")->where('status', 'on')->where('routers', 'radius')->find_one(); $tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username' AND `status` = 'on' AND `routers` = 'radius'")->find_one();
$plan = ORM::for_table('tbl_plans')->where('id', $tur['plan_id'])->find_one(); $plan = ORM::for_table('tbl_plans')->where('id', $tur['plan_id'])->find_one();
if ($plan['limit_type'] == "Data_Limit" || $plan['limit_type'] == "Both_Limit") { if ($plan['limit_type'] == "Data_Limit" || $plan['limit_type'] == "Both_Limit") {
$totalUsage = $d['acctOutputOctets'] + $d['acctInputOctets']; $totalUsage = $d['acctOutputOctets'] + $d['acctInputOctets'];
@ -334,7 +341,7 @@ function process_radiust_rest($tur, $code)
$bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']); $bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']);
// Count User Onlines // Count User Onlines
$USRon = ORM::for_table('rad_acct') $USRon = ORM::for_table('rad_acct')
->where('username', $tur['username']) ->whereRaw("BINARY username = '".$tur['username']."'")
->where("acctStatusType", 'Start') ->where("acctStatusType", 'Start')
->count(); ->count();
if ($USRon >= $plan['shared_users'] && $plan['type'] == 'Hotspot') { if ($USRon >= $plan['shared_users'] && $plan['type'] == 'Hotspot') {
@ -434,6 +441,5 @@ function show_radius_result($array, $code = 200)
header("HTTP/1.1 204 No Content"); header("HTTP/1.1 204 No Content");
die(); die();
} }
echo json_encode($array); die(json_encode($array));
die();
} }

View File

@ -923,5 +923,12 @@
"Notify_Admin_upon_self_registration": "Notify Admin upon self registration", "Notify_Admin_upon_self_registration": "Notify Admin upon self registration",
"Registration_Mandatory_Fields": "Registration Mandatory Fields", "Registration_Mandatory_Fields": "Registration Mandatory Fields",
"Mikrotik_SMS_Command": "Mikrotik SMS Command", "Mikrotik_SMS_Command": "Mikrotik SMS Command",
"Mandatory_Fields": "Mandatory Fields" "Mandatory_Fields": "Mandatory Fields",
"Usernames": "Usernames",
"Yours_Balance": "Yours Balance",
"Friend_Usernames": "Friend Usernames",
"Send_yours_balance___": "Send yours balance ? ",
"Cards": "Cards",
"CRM": "CRM",
"Coupons": "Coupons"
} }

View File

@ -381,8 +381,8 @@
"SuperAdmin": "Super Admin", "SuperAdmin": "Super Admin",
"Lists": "Daftar", "Lists": "Daftar",
"Vouchers": "Voucher", "Vouchers": "Voucher",
"Refill_Customer": "Isi Ulang Pelanggan", "Refill_Customer": "Isi Ulang Voucher",
"Recharge_Customer": "Isi Ulang Pelanggan", "Recharge_Customer": "Isi Ulang Paket",
"Plans": "Paket", "Plans": "Paket",
"PPPOE": "PPPOE", "PPPOE": "PPPOE",
"Bandwidth": "Bandwidth", "Bandwidth": "Bandwidth",
@ -822,7 +822,6 @@
"Methods": "Metode", "Methods": "Metode",
"Hap_Lite": "Hap Lite", "Hap_Lite": "Hap Lite",
"balance": "saldo", "balance": "saldo",
"Balance": "Saldo",
"radius": "radius", "radius": "radius",
"Max_30_days": "Maksimal 30 hari", "Max_30_days": "Maksimal 30 hari",
"Information": "Informasi", "Information": "Informasi",
@ -848,9 +847,44 @@
"Forgot_Password": "Lupa Kata Sandi", "Forgot_Password": "Lupa Kata Sandi",
"Validity_Periode": "Periode Validitas", "Validity_Periode": "Periode Validitas",
"Transaction_History_List": "Daftar Riwayat Transaksi", "Transaction_History_List": "Daftar Riwayat Transaksi",
"Plan": "Paket",
"plan": "paket", "plan": "paket",
"Plans" "Paket", "package": "paket",
"Package": "Paket", "Cards": "Kartu",
"package": "paket" "CRM": "CRM",
"Coupons": "Kupon",
"Custom_Fields": "Bidang Kustom",
"Search_Coupons": "Cari Kupon",
"Add_Coupon": "Tambahkan Kupon",
"Value": "Nilai",
"Max_Usage": "Penggunaan Maksimal",
"Usage_Count": "Jumlah Pemakaian",
"Min_Order": "Pesanan Min",
"Max_Discount": "Diskon Maksimal",
"Updated_Date": "Tanggal Diperbarui",
"Action": "Tindakan",
"No_coupons_found_": "Tidak ada kupon yang ditemukan.",
"Delete_Selected": "Hapus yang Dipilih",
"Coupon_Code": "Kode Kupon",
"Random": "Acak",
"Unique_code_for_the_coupon": "Kode unik untuk kupon",
"Fixed_Discount": "Diskon Tetap",
"Percent_Discount": "Diskon Persen",
"Discount_Value": "Nilai Diskon",
"Value_of_the_discount__amount_or_percentage_": "Nilai diskon (jumlah atau persentase)",
"Brief_explanation_of_the_coupon": "Penjelasan singkat tentang kupon",
"Maximum_number_of_times_this_coupon_can_be_used_0_is_Unlimited": "Jumlah maksimum penggunaan kupon ini 0 adalah Tidak Terbatas",
"Minimum_Order_Amount": "Jumlah Pesanan Minimum",
"Minimum_cart_total_required_to_use_this_coupon": "Total keranjang minimum yang diperlukan untuk menggunakan kupon ini",
"Max_Discount_Amount": "Jumlah Diskon Maksimum",
"Maximum_discount_amount_applicable__for_percent_type_": "Jumlah diskon maksimum yang berlaku (untuk jenis persen)",
"Value_of_the_discount__percentage__max_100_": "Nilai diskon (persentase, maks 100)",
"Value_of_the_discount__amount_": "Nilai diskon (jumlah)",
"Voucher_Cards": "Kartu Voucher",
"Create_Date": "Tanggal Pembuatan",
"Postpaid_Recharge_for_the_first_time_use": "Isi Ulang Pascabayar untuk penggunaan pertama kali",
"Select_Balance_Package_or_Custom_Amount": "Pilih Paket Saldo atau Jumlah Kustom",
"Or_custom_balance_amount_below": "Atau jumlah saldo khusus di bawah ini",
"Balance_Amount": "Jumlah Saldo",
"Input_custom_balance__will_ignore_plan_above": "Masukkan saldo khusus, akan mengabaikan rencana di atas",
"Note": "Catatan"
} }

View File

@ -176,8 +176,8 @@
"ALTER TABLE `tbl_customers` ADD `photo` VARCHAR(128) NOT NULL DEFAULT '/user.default.jpg' AFTER `password`;" "ALTER TABLE `tbl_customers` ADD `photo` VARCHAR(128) NOT NULL DEFAULT '/user.default.jpg' AFTER `password`;"
], ],
"2024.12.5": [ "2024.12.5": [
"ALTER TABLE `tbl_transactions` ADD `user_id` INT(11) NULL AFTER `username`;", "ALTER TABLE `tbl_transactions` ADD `user_id` INT(11) INT NOT NULL DEFAULT 0, AFTER `username`;",
"ALTER TABLE `tbl_payment_gateway` ADD `user_id` INT(11) NULL AFTER `username`;" "ALTER TABLE `tbl_payment_gateway` ADD `user_id` INT(11) INT NOT NULL DEFAULT 0, AFTER `username`;"
], ],
"2024.12.16": [ "2024.12.16": [
"CREATE TABLE `tbl_coupons` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `code` VARCHAR(50) NOT NULL UNIQUE, `type` ENUM('fixed', 'percent') NOT NULL, `value` DECIMAL(10,2) NOT NULL, `description` TEXT NOT NULL, `max_usage` INT NOT NULL DEFAULT 1,`usage_count` INT NOT NULL DEFAULT 0,`status` ENUM('active', 'inactive') NOT NULL, `min_order_amount` DECIMAL(10,2) NOT NULL, `max_discount_amount` DECIMAL(10,2) NOT NULL, `start_date` DATE NOT NULL,`end_date` DATE NOT NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);" "CREATE TABLE `tbl_coupons` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `code` VARCHAR(50) NOT NULL UNIQUE, `type` ENUM('fixed', 'percent') NOT NULL, `value` DECIMAL(10,2) NOT NULL, `description` TEXT NOT NULL, `max_usage` INT NOT NULL DEFAULT 1,`usage_count` INT NOT NULL DEFAULT 0,`status` ENUM('active', 'inactive') NOT NULL, `min_order_amount` DECIMAL(10,2) NOT NULL, `max_discount_amount` DECIMAL(10,2) NOT NULL, `start_date` DATE NOT NULL,`end_date` DATE NOT NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);"

View File

@ -18,7 +18,7 @@
{if !$custom} {if !$custom}
<ul class="list-group list-group-unbordered"> <ul class="list-group list-group-unbordered">
<li class="list-group-item"> <li class="list-group-item">
<b>{Lang::T('Plan Name')}</b> <b>{Lang::T('Package Name')}</b>
<span class="pull-right">{$plan['name_plan']}</span> <span class="pull-right">{$plan['name_plan']}</span>
</li> </li>
@ -59,7 +59,7 @@
{else} {else}
<ul class="list-group list-group-unbordered"> <ul class="list-group list-group-unbordered">
<li class="list-group-item"> <li class="list-group-item">
<b>{Lang::T('Plan Name')}</b> <b>{Lang::T('Package Name')}</b>
<span class="pull-right">{Lang::T('Custom Balance')}</span> <span class="pull-right">{Lang::T('Custom Balance')}</span>
</li> </li>