From d5f29a5c74a5f56e5fc66498afd45e2463334950 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 14 Dec 2022 15:57:20 +0700 Subject: [PATCH 01/15] update readme --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5b66ca2b..e310f242 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ Click link to download Goto Discussionif you want another Payment Gateway +Some documentation + ## System Requirements Most current web servers with PHP & MySQL installed will be capable of running PHPNuxBill @@ -30,7 +32,7 @@ Most current web servers with PHP & MySQL installed will be capable of running P Minimum Requirements - Linux or Windows OS -- PHP Version 7.0+ +- PHP Version 7.2+ - Both PDO & MySQLi Support - GD2 Image Library - CURL support @@ -42,17 +44,14 @@ The problem with windows is hard to set cronjob, better Linux ## Installation -- Rename **pages_template** to **pages** -- Rename **config.sample.php** to **config.php** and make it writeable (chmod 777) -- make writeable folder **ui/cache/** and **ui/compiled** -- Open web and run installation -- set cronjobs or scheduller for **system/cron.php** -- make **config.php** unwriteable (chmod 644) +clone this repository or download zip or release - -See [WIKI](https://github.com/hotspotbilling/phpnuxbill/wiki/Instalation) - -baca [WIKI](https://github.com/hotspotbilling/phpnuxbill/wiki/Instalation) +1. Rename **pages_template** to **pages** +2. Rename **config.sample.php** to **config.php** and make it writeable (chmod 777) +3. make writeable folder **ui/cache/** and **ui/compiled** +4. Open web and run installation +5. set [cronjob](https://github.com/hotspotbilling/phpnuxbill/wiki/Cron-Jobs) or scheduller for **system/cron.php** +6. make **config.php** unwriteable (chmod 644) ## UPDGRADE @@ -60,9 +59,12 @@ for old version, below Version 6, backup **system/config.php**, delete all file for version 6 above, just replace all files, using filezilla can choose overwrite if different file size or time. +or git pull if you use git clone + ## RADIUS system Still on development + ## Paid Support Start from Rp 500.000 or $50 From d526ceb6bc45f59369939336abb67a957911ca59 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 31 Jan 2023 09:14:02 +0700 Subject: [PATCH 02/15] Fix delete --- system/controllers/customers.php | 3 +++ ui/ui/bandwidth.tpl | 2 +- ui/ui/customers.tpl | 2 +- ui/ui/users.tpl | 2 +- ui/ui/voucher.tpl | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/system/controllers/customers.php b/system/controllers/customers.php index 8f412fed..21ea411f 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -79,6 +79,7 @@ switch ($action) { try { $d->delete(); } catch (Exception $e) { + } catch(Throwable $e){ } try { $c->delete(); @@ -88,10 +89,12 @@ switch ($action) { try { $d->delete(); } catch (Exception $e) { + } catch(Throwable $e){ } try { $c->delete(); } catch (Exception $e) { + } catch(Throwable $e){ } } diff --git a/ui/ui/bandwidth.tpl b/ui/ui/bandwidth.tpl index 166ab486..25ec3fe6 100644 --- a/ui/ui/bandwidth.tpl +++ b/ui/ui/bandwidth.tpl @@ -41,7 +41,7 @@ {$ds['rate_up']} {$ds['rate_up_unit']} {$_L['Edit']} - {$_L['Delete']} + {$_L['Delete']} {/foreach} diff --git a/ui/ui/customers.tpl b/ui/ui/customers.tpl index 7ede1915..c3d1ae07 100644 --- a/ui/ui/customers.tpl +++ b/ui/ui/customers.tpl @@ -45,7 +45,7 @@ {$_L['Recharge']} {$_L['Edit']} - {$_L['Delete']} + {$_L['Delete']} {/foreach} diff --git a/ui/ui/users.tpl b/ui/ui/users.tpl index 0be15f64..4f42fd32 100644 --- a/ui/ui/users.tpl +++ b/ui/ui/users.tpl @@ -49,7 +49,7 @@ class="btn btn-warning btn-sm">{$_L['Edit']} {if ($_admin['username']) neq ($ds['username'])} {$_L['Delete']} + class="btn btn-danger btn-sm" onclick="confirm('{$_L['Delete']}?')">{$_L['Delete']} {/if} diff --git a/ui/ui/voucher.tpl b/ui/ui/voucher.tpl index c989fcc3..a8678450 100644 --- a/ui/ui/voucher.tpl +++ b/ui/ui/voucher.tpl @@ -61,7 +61,7 @@ {if $ds['user'] eq '0'} - {else} {$ds['user']} {/if} {$_L['Delete']} + class="btn btn-danger btn-sm" onclick="confirm('{$_L['Delete']}?')">{$_L['Delete']} {/foreach} From 976300bac7a37218dc32ee0db6e5037e7cc96b18 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 31 Jan 2023 14:26:49 +0700 Subject: [PATCH 03/15] Plugin Manager, install belum --- system/controllers/pluginmanager.php | 33 +++++++++++++++++ system/lan/indonesia/common.lan.php | 3 ++ ui/ui/plugin-manager.tpl | 55 ++++++++++++++++++++++++++++ ui/ui/sections/header.tpl | 8 ++-- 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 system/controllers/pluginmanager.php create mode 100644 ui/ui/plugin-manager.tpl diff --git a/system/controllers/pluginmanager.php b/system/controllers/pluginmanager.php new file mode 100644 index 00000000..6f77b1dc --- /dev/null +++ b/system/controllers/pluginmanager.php @@ -0,0 +1,33 @@ +assign('_title', $_L['Plugin Manager']); +$ui->assign('_system_menu', 'settings'); + +$action = $routes['1']; +$admin = Admin::_info(); +$ui->assign('_admin', $admin); + + +if ($admin['user_type'] != 'Admin') { + r2(U . "dashboard", 'e', $_L['Do_Not_Access']); +} + +switch ($action) { + + default: + $cache = 'system/cache/plugin_repository.json'; + if (file_exists($cache) && time() - filemtime($cache) > (24 * 60 * 60)) { + $json = json_decode(file_get_contents($cache), true); + } + $data = file_get_contents('https://hotspotbilling.github.io/Plugin-Repository/repository.json'); + file_put_contents($cache, $data); + $json = json_decode($data, true); + $ui->assign('plugins', $json['plugins']); + $ui->assign('pgs', $json['payment_gateway']); + $ui->display('plugin-manager.tpl'); +} diff --git a/system/lan/indonesia/common.lan.php b/system/lan/indonesia/common.lan.php index fe3ad38f..070c5a83 100644 --- a/system/lan/indonesia/common.lan.php +++ b/system/lan/indonesia/common.lan.php @@ -306,3 +306,6 @@ $_L['Verification_Code'] = 'Verification Code'; $_L['SMS_Verification_Code'] = 'SMS Verification Code'; $_L['Please_enter_your_email_address'] = 'Please enter your email address'; $_L['Failed_to_create_Paypal_transaction'] = 'Failed to create Paypal transaction.'; +$_L['Plugin'] = 'Plugin'; +$_L['Plugin_Manager'] = 'Plugin Manager'; +$_L['Plugin_Manager'] = 'Plugin Manager'; diff --git a/ui/ui/plugin-manager.tpl b/ui/ui/plugin-manager.tpl new file mode 100644 index 00000000..b8d00508 --- /dev/null +++ b/ui/ui/plugin-manager.tpl @@ -0,0 +1,55 @@ +{include file="sections/header.tpl"} +
+
+
+
{Lang::T('Plugin')}
+
+ {foreach $plugins as $plugin} +
+
+
+

{$plugin['name']}

+
+
{$plugin['description']}
@{$plugin['author']} Last update: {$plugin['last_update']}
+ +
+
+ {/foreach} +
+
+
+
{Lang::T('Payment Gateway')}
+
+ {foreach $pgs as $pg} +
+
+
+

{$pg['name']}

+
+
{$pg['description']}
@{$plugin['author']} Last update: {$plugin['last_update']}
+ +
+
+ {/foreach} +
+
+
+{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index 8fb9c858..d19ee779 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -163,7 +163,7 @@ {$_MENU_AFTER_REPORTS} {/if} {if $_admin['user_type'] eq 'Admin'} -
  • +
  • {$_L['Network']} @@ -215,6 +215,8 @@ href="{$_url}settings/users">{$_L['Administrator_Users']}
  • {$_L['Backup_Restore']}
  • +
  • {Lang::T('Plugin Manager')}
  • {$_MENU_SETTINGS} @@ -240,9 +242,9 @@

    - {$_title} + {$_title}

    - {if isset($notify)}{$notify}{/if} \ No newline at end of file +{if isset($notify)}{$notify}{/if} \ No newline at end of file From 6042538d8e0dab231614b379150c6a68e996d5cd Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:48:05 +0700 Subject: [PATCH 04/15] Move send SMS/Wa/Telegram to class --- system/autoload/Message.php | 58 +++++++++++++++++++++++++++++++++++++ system/boot.php | 34 ---------------------- 2 files changed, 58 insertions(+), 34 deletions(-) create mode 100644 system/autoload/Message.php diff --git a/system/autoload/Message.php b/system/autoload/Message.php new file mode 100644 index 00000000..2ac91adf --- /dev/null +++ b/system/autoload/Message.php @@ -0,0 +1,58 @@ + 5 + && !empty($textExpired) && in_array($via, ['sms', 'wa']) + ) { + $msg = str_replace('[[name]]', $name, $textExpired); + $msg = str_replace('[[package]]', $package, $msg); + if ($via == 'sms') { + Message::sendSMS($phone, $msg); + } else if ($via == 'wa') { + Message::sendWhatsapp($phone, $msg); + } + } + } + +} diff --git a/system/boot.php b/system/boot.php index 01c4d67c..2b55909b 100644 --- a/system/boot.php +++ b/system/boot.php @@ -228,40 +228,6 @@ function alphanumeric($str, $tambahan = "") return preg_replace("/[^a-zA-Z0-9" . $tambahan . "]+/", "", $str); } - -function sendTelegram($txt) -{ - global $config; - run_hook('send_telegram'); #HOOK - if (!empty($config['telegram_bot']) && !empty($config['telegram_target_id'])) { - file_get_contents('https://api.telegram.org/bot' . $config['telegram_bot'] . '/sendMessage?chat_id=' . $config['telegram_target_id'] . '&text=' . urlencode($txt)); - } -} - - -function sendSMS($phone, $txt) -{ - global $config; - run_hook('send_sms'); #HOOK - if (!empty($config['sms_url'])) { - $smsurl = str_replace('[number]', urlencode($phone), $config['sms_url']); - $smsurl = str_replace('[text]', urlencode($txt), $smsurl); - file_get_contents($smsurl); - } -} - -function sendWhatsapp($phone, $txt) -{ - global $config; - run_hook('send_whatsapp'); #HOOK - if (!empty($config['wa_url'])) { - $waurl = str_replace('[number]', urlencode($phone), $config['wa_url']); - $waurl = str_replace('[text]', urlencode($txt), $waurl); - file_get_contents($waurl); - } -} - - function time_elapsed_string($datetime, $full = false) { $now = new DateTime; From 3130310d9c7faaf87850cbada5d800f3529f5171 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:49:26 +0700 Subject: [PATCH 05/15] add notification settings --- system/controllers/settings.php | 35 ++++++++++++++++++++++++++++++++ ui/ui/app-settings.tpl | 36 +++++++++++++++++++++++++++++++-- ui/ui/sections/user-footer.tpl | 23 ++++++++++----------- 3 files changed, 80 insertions(+), 14 deletions(-) diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 13940b82..8a5e818e 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -210,6 +210,9 @@ switch ($action) { $telegram_target_id = _post('telegram_target_id'); $sms_url = _post('sms_url'); $wa_url = _post('wa_url'); + $user_notification_expired = _post('user_notification_expired'); + $user_notification_expired_text = _post('user_notification_expired_text'); + $user_notification_payment = _post('user_notification_payment'); $address = _post('address'); $tawkto = _post('tawkto'); $radius_mode = _post('radius_mode')*1; @@ -286,6 +289,38 @@ switch ($action) { $d->save(); } + $d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_expired')->find_one(); + if($d){ + $d->value = $user_notification_expired; + $d->save(); + }else{ + $d = ORM::for_table('tbl_appconfig')->create(); + $d->setting = 'user_notification_expired'; + $d->value = $user_notification_expired; + $d->save(); + } + + $d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_expired_text')->find_one(); + if($d){ + $d->value = $user_notification_expired_text; + $d->save(); + }else{ + $d = ORM::for_table('tbl_appconfig')->create(); + $d->setting = 'user_notification_expired_text'; + $d->value = $user_notification_expired_text; + $d->save(); + } + + $d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_payment')->find_one(); + if($d){ + $d->value = $user_notification_payment; + $d->save(); + }else{ + $d = ORM::for_table('tbl_appconfig')->create(); + $d->setting = 'user_notification_payment'; + $d->value = $user_notification_payment; + $d->save(); + } $d = ORM::for_table('tbl_appconfig')->where('setting', 'tawkto')->find_one(); if($d){ diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index c7539244..19aeed4f 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -26,7 +26,7 @@
    + rows="3">{Lang::htmlspecialchars($_c['address'])} {$_L['You_can_use_html_tag']}
    @@ -100,6 +100,38 @@
    +
    {Lang::T('User Notification')}
    +
    +
    + +
    + +

    {Lang::T('User will get notification when package expired')}

    +
    +
    +
    + +
    + +

    {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')}

    +
    +
    +
    + +
    + +

    {Lang::T('User will get notification when buy package or package refilled')}

    +
    +
    +
    Tawk.to Chat Widget
    @@ -119,7 +151,7 @@ add dst-host=*.tawk.to
    - + {$_L['You_can_use_html_tag']}
    diff --git a/ui/ui/sections/user-footer.tpl b/ui/ui/sections/user-footer.tpl index 67c1dfc9..80701398 100644 --- a/ui/ui/sections/user-footer.tpl +++ b/ui/ui/sections/user-footer.tpl @@ -1,15 +1,14 @@ - - -
    -{if isset($_c['CompanyFooter'])} -
    - {$_c['CompanyFooter']} -
    -{else} - -{/if} + +
    + {if isset($_c['CompanyFooter'])} +
    + {$_c['CompanyFooter']} +
    + {else} + + {/if} From b10cfa2a8e18e62a1119628f49247a310f9084ba Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:49:44 +0700 Subject: [PATCH 06/15] add expired notification --- system/cron.php | 91 +++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/system/cron.php b/system/cron.php index 84204db7..13a4837f 100644 --- a/system/cron.php +++ b/system/cron.php @@ -1,7 +1,8 @@ find_many(); -foreach($result as $value){ - $config[$value['setting']]=$value['value']; +foreach ($result as $value) { + $config[$value['setting']] = $value['value']; } date_default_timezone_set($config['timezone']); -$d = ORM::for_table('tbl_user_recharges')->where('status','on')->find_many(); +$textExpired = $config['user_notification_expired_text']; + +$d = ORM::for_table('tbl_user_recharges')->where('status', 'on')->find_many(); run_hook('cronjob'); #HOOK -foreach ($d as $ds){ - if($ds['type'] == 'Hotspot'){ - $date_now = strtotime(date("Y-m-d H:i:s")); - $expiration = strtotime($ds['expiration'].' '.$ds['time']); - echo $ds['expiration']." : ".$ds['username']; - if ($date_now >= $expiration){ - echo " : EXPIRED \r\n"; - $u = ORM::for_table('tbl_user_recharges')->where('id',$ds['id'])->find_one(); - $c = ORM::for_table('tbl_customers')->where('id',$ds['customer_id'])->find_one(); - $m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one(); +foreach ($d as $ds) { + if ($ds['type'] == 'Hotspot') { + $date_now = strtotime(date("Y-m-d H:i:s")); + $expiration = strtotime($ds['expiration'] . ' ' . $ds['time']); + echo $ds['expiration'] . " : " . $ds['username']; + if ($date_now >= $expiration) { + echo " : EXPIRED \r\n"; + $u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one(); + $c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one(); + $m = ORM::for_table('tbl_routers')->where('name', $ds['routers'])->find_one(); - if(!$_c['radius_mode']){ + if (!$_c['radius_mode']) { $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); - Mikrotik::setHotspotLimitUptime($client,$c['username']); - Mikrotik::removeHotspotActiveUser($client,$c['username']); + Mikrotik::setHotspotLimitUptime($client, $c['username']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Message::sendExpiredNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $textExpired, $config['user_notification_expired']); + } + //update database user dengan status off + $u->status = 'off'; + $u->save(); + } else echo " : ACTIVE \r\n"; + } else { + $date_now = strtotime(date("Y-m-d H:i:s")); + $expiration = strtotime($ds['expiration'] . ' ' . $ds['time']); + echo $ds['expiration'] . " : " . $ds['username']; + if ($date_now >= $expiration) { + echo " : EXPIRED \r\n"; + $u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one(); + $c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one(); + $m = ORM::for_table('tbl_routers')->where('name', $ds['routers'])->find_one(); + + if (!$_c['radius_mode']) { + $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); + Mikrotik::disablePpoeUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); + Message::sendExpiredNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $textExpired, $config['user_notification_expired']); } - //update database user dengan status off - $u->status = 'off'; - $u->save(); - }else echo " : ACTIVE \r\n"; - }else{ - $date_now = strtotime(date("Y-m-d H:i:s")); - $expiration = strtotime($ds['expiration'].' '.$ds['time']); - echo $ds['expiration']." : ".$ds['username']; - if ($date_now >= $expiration){ - echo " : EXPIRED \r\n"; - $u = ORM::for_table('tbl_user_recharges')->where('id',$ds['id'])->find_one(); - $c = ORM::for_table('tbl_customers')->where('id',$ds['customer_id'])->find_one(); - $m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one(); - - if(!$_c['radius_mode']){ - $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); - Mikrotik::disablePpoeUser($client,$c['username']); - Mikrotik::removePpoeActive($client,$c['username']); - } - - $u->status = 'off'; - $u->save(); - }else echo " : ACTIVE \r\n"; - } + $u->status = 'off'; + $u->save(); + } else echo " : ACTIVE \r\n"; + } } From 1315621259cf3b807e1726880c7356e84d4f860d Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:50:55 +0700 Subject: [PATCH 07/15] check notification --- system/autoload/Package.php | 26 ++++++++++++++++---------- system/controllers/prepaid.php | 26 ++++++++++++++++++-------- system/controllers/voucher.php | 4 ++-- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 53c87a46..19c0b087 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -51,8 +51,8 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::removeHotspotUser($client,$c['username']); - Mikrotik::addHotspotUser($client,$p,$c); + Mikrotik::removeHotspotUser($client, $c['username']); + Mikrotik::addHotspotUser($client, $p, $c); } $b->customer_id = $id_customer; @@ -84,7 +84,7 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::addHotspotUser($client,$p,$c); + Mikrotik::addHotspotUser($client, $p, $c); } $d = ORM::for_table('tbl_user_recharges')->create(); @@ -115,7 +115,7 @@ class Package $t->type = "Hotspot"; $t->save(); } - sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] . + Message::sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] . "\nRouter: " . $router_name . "\nGateway: " . $gateway . "\nChannel: " . $channel . @@ -125,8 +125,8 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::removePpoeUser($client,$c['username']); - Mikrotik::addPpoeUser($client,$p,$c); + Mikrotik::removePpoeUser($client, $c['username']); + Mikrotik::addPpoeUser($client, $p, $c); } $b->customer_id = $id_customer; @@ -158,7 +158,7 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::addPpoeUser($client,$p,$c); + Mikrotik::addPpoeUser($client, $p, $c); } $d = ORM::for_table('tbl_user_recharges')->create(); @@ -189,7 +189,7 @@ class Package $t->type = "PPPOE"; $t->save(); } - sendTelegram("#u$c[username] #buy #PPPOE \n" . $p['name_plan'] . + Message::sendTelegram("#u$c[username] #buy #PPPOE \n" . $p['name_plan'] . "\nRouter: " . $router_name . "\nGateway: " . $gateway . "\nChannel: " . $channel . @@ -198,7 +198,7 @@ class Package $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); - sendWhatsapp($c['username'], "*$_c[CompanyName]*\n" . + $msg = "*$_c[CompanyName]*\n" . "$_c[address]\n" . "$_c[phone]\n" . "\n\n" . @@ -214,7 +214,13 @@ class Package "$_L[Created_On] :\n*" . date($_c['date_format'], strtotime($in['recharged_on'])) . " $in[time]*\n" . "$_L[Expires_On] :\n*" . date($_c['date_format'], strtotime($in['expiration'])) . " $in[time]*\n" . "\n\n" . - "$_c[note]"); + "$_c[note]"; + + if ($_c['user_notification_payment'] == 'sms') { + Message::sendSMS($c['phonenumber'], $msg); + } else if ($_c['user_notification_payment'] == 'wa') { + Message::sendWhatsapp($c['phonenumber'], $msg); + } return true; } } diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index 90fe7b93..4aa267a1 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -169,7 +169,7 @@ switch ($action) { $t->type = "Hotspot"; $t->save(); } - sendTelegram( "$admin[fullname] #Recharge Voucher #Hotspot for #u$c[username]\n".$p['name_plan']. + Message::sendTelegram( "$admin[fullname] #Recharge Voucher #Hotspot for #u$c[username]\n".$p['name_plan']. "\nRouter: ".$server. "\nPrice: ".$p['price']); } else { @@ -241,7 +241,7 @@ switch ($action) { $t->type = "PPPOE"; $t->save(); } - sendTelegram( "$admin[fullname] #Recharge Voucher #PPPOE for #u$c[username]\n".$p['name_plan']. + Message::sendTelegram( "$admin[fullname] #Recharge Voucher #PPPOE for #u$c[username]\n".$p['name_plan']. "\nRouter: ".$server. "\nPrice: ".$p['price']); } @@ -249,7 +249,7 @@ switch ($action) { $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); $ui->assign('in', $in); - sendWhatsapp($c['username'], "*$config[CompanyName]*\n". + $msg = "*$config[CompanyName]*\n". "$config[address]\n". "$config[phone]\n". "\n\n". @@ -265,8 +265,13 @@ switch ($action) { "$_L[Created_On] :\n*".date($config['date_format'], strtotime($in['recharged_on']))." $in[time]*\n". "$_L[Expires_On] :\n*".date($config['date_format'], strtotime($in['expiration']))." $in[time]*\n". "\n\n". - "$config[note]"); + "$config[note]"; + if ($_c['user_notification_payment'] == 'sms') { + Message::sendSMS($c['phonenumber'], $msg); + } else if ($_c['user_notification_payment'] == 'wa') { + Message::sendWhatsapp($c['phonenumber'], $msg); + } $ui->assign('date', $date_now); $ui->display('invoice.tpl'); @@ -631,7 +636,7 @@ switch ($action) { $v1->user = $c['username']; $v1->save(); - sendTelegram( "$admin[fullname] #Refill #Voucher #Hotspot for #u$c[username]\n".$p['name_plan']. + Message::sendTelegram( "$admin[fullname] #Refill #Voucher #Hotspot for #u$c[username]\n".$p['name_plan']. "\nCode: ".$code. "\nRouter: ".$v1['routers']. "\nPrice: ".$p['price']); @@ -709,7 +714,7 @@ switch ($action) { $v1->save(); - sendTelegram( "$admin[fullname] Refill #Voucher #PPPOE for #u$c[username]\n".$p['name_plan']. + Message::sendTelegram( "$admin[fullname] Refill #Voucher #PPPOE for #u$c[username]\n".$p['name_plan']. "\nCode: ".$code. "\nRouter: ".$v1['routers']. "\nPrice: ".$p['price']); @@ -718,7 +723,7 @@ switch ($action) { $ui->assign('in', $in); - sendWhatsapp($c['username'], "*$config[CompanyName]*\n". + $msg = "*$config[CompanyName]*\n". "$config[address]\n". "$config[phone]\n". "\n\n". @@ -734,8 +739,13 @@ switch ($action) { "$_L[Created_On] :\n*".date($config['date_format'], strtotime($in['recharged_on']))." $in[time]*\n". "$_L[Expires_On] :\n*".date($config['date_format'], strtotime($in['expiration']))." $in[time]*\n". "\n\n". - "$config[note]"); + "$config[note]"; + if ($_c['user_notification_payment'] == 'sms') { + Message::sendSMS($c['phonenumber'], $msg); + } else if ($_c['user_notification_payment'] == 'wa') { + Message::sendWhatsapp($c['phonenumber'], $msg); + } $ui->assign('date', $date_now); $ui->display('invoice.tpl'); } else { diff --git a/system/controllers/voucher.php b/system/controllers/voucher.php index 65704807..22ee64dc 100644 --- a/system/controllers/voucher.php +++ b/system/controllers/voucher.php @@ -123,7 +123,7 @@ switch ($action) { $v1->user = $c['username']; $v1->save(); // Telegram to Admin - sendTelegram('#u' . $c['username'] . " Activate #Voucher #Hotspot\n" . $p['name_plan'] . + Message::sendTelegram('#u' . $c['username'] . " Activate #Voucher #Hotspot\n" . $p['name_plan'] . "\nCode: " . $code . "\nRouter: " . $v1['routers'] . "\nPrice: " . $p['price']); @@ -200,7 +200,7 @@ switch ($action) { $v1->user = $c['username']; $v1->save(); // Telegram to Admin - sendTelegram('#u' . $c['username'] . " Activate #Voucher #PPPOE\n" . $p['name_plan'] . + Message::sendTelegram('#u' . $c['username'] . " Activate #Voucher #PPPOE\n" . $p['name_plan'] . "\nCode: " . $code . "\nRouter: " . $v1['routers'] . "\nPrice: " . $p['price']); From 26be14bf0ea06f83b78dcf4f1c1fea374e7907d2 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:51:05 +0700 Subject: [PATCH 08/15] add new lang text --- system/autoload/Lang.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/autoload/Lang.php b/system/autoload/Lang.php index f5e08e60..dc9292f6 100644 --- a/system/autoload/Lang.php +++ b/system/autoload/Lang.php @@ -8,4 +8,8 @@ class Lang { public static function T($var) { return Lang($var); } + + public static function htmlspecialchars($var) { + return htmlspecialchars($var); + } } From 41c3628eebd3aaaf6aad9b1daf7d3e3d39c44d24 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:51:13 +0700 Subject: [PATCH 09/15] add new lang text --- system/lan/indonesia/common.lan.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/system/lan/indonesia/common.lan.php b/system/lan/indonesia/common.lan.php index 070c5a83..be92d519 100644 --- a/system/lan/indonesia/common.lan.php +++ b/system/lan/indonesia/common.lan.php @@ -301,11 +301,18 @@ $_L['Buy_Package'] = 'Buy Package'; $_L['Email'] = 'Email'; $_L['Company_Footer'] = 'Company Footer'; $_L['Will_show_below_user_pages'] = 'Will show below user pages'; -$_L['Request_OTP'] = 'Request OTP'; -$_L['Verification_Code'] = 'Verification Code'; -$_L['SMS_Verification_Code'] = 'SMS Verification Code'; -$_L['Please_enter_your_email_address'] = 'Please enter your email address'; -$_L['Failed_to_create_Paypal_transaction'] = 'Failed to create Paypal transaction.'; -$_L['Plugin'] = 'Plugin'; -$_L['Plugin_Manager'] = 'Plugin Manager'; -$_L['Plugin_Manager'] = 'Plugin Manager'; +$_L['Request_OTP'] = 'Request OTP'; +$_L['Verification_Code'] = 'Verification Code'; +$_L['SMS_Verification_Code'] = 'SMS Verification Code'; +$_L['Please_enter_your_email_address'] = 'Please enter your email address'; +$_L['Failed_to_create_Paypal_transaction'] = 'Failed to create Paypal transaction.'; +$_L['Plugin'] = 'Plugin'; +$_L['Plugin_Manager'] = 'Plugin Manager'; +$_L['Plugin_Manager'] = 'Plugin Manager'; +$_L['User_Notification'] = 'User Notification'; +$_L['Expired_Notification'] = 'Expired Notification'; +$_L['User_will_get_notification_when_package_expired'] = 'User will get notification when package expired'; +$_L['Expired_Notification_Message'] = 'Expired Notification Message'; +$_L['bnameb_will_be_replaced_with_Customer_Name_bpackageb_will_be_replaced_with_Package_name'] = '[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.'; +$_L['Payment_Notification'] = 'Payment Notification'; +$_L['User_will_get_invoice_notification_when_buy_package_or_package_refilled'] = 'User will get invoice notification when buy package or package refilled'; From ba85ed6d0e876db3cd4005b4154b10a1533ca7f0 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:51:24 +0700 Subject: [PATCH 10/15] change text --- ui/ui/app-settings.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index 19aeed4f..39f4a4f6 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -128,7 +128,7 @@ -

    {Lang::T('User will get notification when buy package or package refilled')}

    +

    {Lang::T('User will get invoice notification when buy package or package refilled')}

    From ec45d59a684f9a053c1ca51aec8645280dbcf557 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:51:36 +0700 Subject: [PATCH 11/15] change sending message --- system/controllers/register.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/controllers/register.php b/system/controllers/register.php index 8a8c11ac..13aeb2c9 100644 --- a/system/controllers/register.php +++ b/system/controllers/register.php @@ -132,7 +132,7 @@ switch ($do) { }else{ $otp = rand(100000,999999); file_put_contents($otpPath, $otp); - sendSMS($username,$config['CompanyName']."\nYour Verification code are: $otp"); + Message::sendSMS($username,$config['CompanyName']."\nYour Verification code are: $otp"); $ui->assign('username', $username); $ui->assign('notify', '
    @@ -42,7 +46,11 @@ class="btn btn-primary"> Website Github - Install