mirror of
https://github.com/hotspotbilling/phpnuxbill.git
synced 2025-02-25 16:06:32 +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,19 +24,39 @@ class Message
|
|||
global $config;
|
||||
run_hook('send_sms'); #HOOK
|
||||
if (!empty($config['sms_url'])) {
|
||||
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);
|
||||
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") {
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$smsurl = str_replace('[number]', urlencode($phone), $config['sms_url']);
|
||||
$smsurl = str_replace('[text]', urlencode($txt), $smsurl);
|
||||
Http::getData($smsurl);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +107,8 @@ class Message
|
|||
return "$via: $msg";
|
||||
}
|
||||
|
||||
public static function sendInvoice($cust, $trx){
|
||||
public static function sendInvoice($cust, $trx)
|
||||
{
|
||||
global $config;
|
||||
$textInvoice = Lang::getNotifText('invoice_paid');
|
||||
$textInvoice = str_replace('[[company_name]]', $config['CompanyName'], $textInvoice);
|
||||
|
|
Loading…
Reference in a new issue