mirror of
https://github.com/hotspotbilling/phpnuxbill.git
synced 2025-02-26 00:18:43 +08:00
split sms characters to 160
This commit is contained in:
parent
dd4329ad3d
commit
b7c663f4ee
1 changed files with 33 additions and 12 deletions
|
@ -24,14 +24,17 @@ class Message
|
||||||
global $config;
|
global $config;
|
||||||
run_hook('send_sms'); #HOOK
|
run_hook('send_sms'); #HOOK
|
||||||
if (!empty($config['sms_url'])) {
|
if (!empty($config['sms_url'])) {
|
||||||
|
if (strlen($txt) > 160) {
|
||||||
|
$txts = str_split($txt, 160);
|
||||||
|
foreach ($txts as $txt) {
|
||||||
if (strlen($config['sms_url']) > 4 && substr($config['sms_url'], 0, 4) != "http") {
|
if (strlen($config['sms_url']) > 4 && substr($config['sms_url'], 0, 4) != "http") {
|
||||||
try{
|
try {
|
||||||
$mikrotik = Mikrotik::info($config['sms_url']);
|
$mikrotik = Mikrotik::info($config['sms_url']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::sendSMS($client, $phone, $txt);
|
Mikrotik::sendSMS($client, $phone, $txt);
|
||||||
}catch(Exception $e){
|
} catch (Exception $e) {
|
||||||
// ignore, add to logs
|
// ignore, add to logs
|
||||||
_log("Failed to send SMS using Mikrotik.\n". $e->getMessage(), 'SMS', 0);
|
_log("Failed to send SMS using Mikrotik.\n" . $e->getMessage(), 'SMS', 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$smsurl = str_replace('[number]', urlencode($phone), $config['sms_url']);
|
$smsurl = str_replace('[number]', urlencode($phone), $config['sms_url']);
|
||||||
|
@ -39,6 +42,23 @@ class Message
|
||||||
Http::getData($smsurl);
|
Http::getData($smsurl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (strlen($config['sms_url']) > 4 && substr($config['sms_url'], 0, 4) != "http") {
|
||||||
|
try {
|
||||||
|
$mikrotik = Mikrotik::info($config['sms_url']);
|
||||||
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
Mikrotik::sendSMS($client, $phone, $txt);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// ignore, add to logs
|
||||||
|
_log("Failed to send SMS using Mikrotik.\n" . $e->getMessage(), 'SMS', 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$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)
|
public static function sendWhatsapp($phone, $txt)
|
||||||
|
@ -87,7 +107,8 @@ class Message
|
||||||
return "$via: $msg";
|
return "$via: $msg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sendInvoice($cust, $trx){
|
public static function sendInvoice($cust, $trx)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$textInvoice = Lang::getNotifText('invoice_paid');
|
$textInvoice = Lang::getNotifText('invoice_paid');
|
||||||
$textInvoice = str_replace('[[company_name]]', $config['CompanyName'], $textInvoice);
|
$textInvoice = str_replace('[[company_name]]', $config['CompanyName'], $textInvoice);
|
||||||
|
|
Loading…
Reference in a new issue