forked from kevinowino869/mitrobill
.github
admin
install
pages_template
qrcode
system
autoload
PEAR2
Admin.php
App.php
Balance.php
File.php
Hookers.php
Http.php
Lang.php
Message.php
Mikrotik.php
Package.php
Paginator.php
Password.php
Radius.php
Timezone.php
User.php
Validator.php
index.html
cache
controllers
lan
paymentgateway
plugin
uploads
vendor
boot.php
composer.json
composer.lock
cron.php
cron_reminder.php
index.html
orm.php
updates.json
ui
.gitignore
CHANGELOG.md
LICENSE
README.md
composer.json
config.sample.php
favicon.ico
index.php
update.php
version.json
77 lines
2.5 KiB
PHP
77 lines
2.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
|
**/
|
|
|
|
class Message
|
|
{
|
|
|
|
public static function sendTelegram($txt)
|
|
{
|
|
global $config;
|
|
run_hook('send_telegram'); #HOOK
|
|
if (!empty($config['telegram_bot']) && !empty($config['telegram_target_id'])) {
|
|
Http::getData('https://api.telegram.org/bot' . $config['telegram_bot'] . '/sendMessage?chat_id=' . $config['telegram_target_id'] . '&text=' . urlencode($txt));
|
|
}
|
|
}
|
|
|
|
|
|
public static 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);
|
|
Http::getData($smsurl);
|
|
}
|
|
}
|
|
|
|
public static 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);
|
|
Http::getData($waurl);
|
|
}
|
|
}
|
|
|
|
public static function sendPackageNotification($phone, $name, $package, $message, $via)
|
|
{
|
|
$msg = str_replace('[[name]]', "*$name*", $message);
|
|
$msg = str_replace('[[package]]', "*$package*", $msg);
|
|
if (
|
|
!empty($phone) && strlen($phone) > 5
|
|
&& !empty($message) && in_array($via, ['sms', 'wa'])
|
|
) {
|
|
if ($via == 'sms') {
|
|
Message::sendSMS($phone, $msg);
|
|
} else if ($via == 'wa') {
|
|
Message::sendWhatsapp($phone, $msg);
|
|
}
|
|
}
|
|
return "$via: $msg";
|
|
}
|
|
|
|
public static function sendBalanceNotification($phone, $name, $balance, $balance_now, $message, $via)
|
|
{
|
|
$msg = str_replace('[[name]]', "*$name*", $message);
|
|
$msg = str_replace('[[current_balance]]', Lang::moneyFormat($balance_now), $msg);
|
|
$msg = str_replace('[[balance]]', "*" . Lang::moneyFormat($balance) . "*", $msg);
|
|
if (
|
|
!empty($phone) && strlen($phone) > 5
|
|
&& !empty($message) && in_array($via, ['sms', 'wa'])
|
|
) {
|
|
if ($via == 'sms') {
|
|
Message::sendSMS($phone, $msg);
|
|
} else if ($via == 'wa') {
|
|
Message::sendWhatsapp($phone, $msg);
|
|
}
|
|
}
|
|
return "$via: $msg";
|
|
}
|
|
}
|