split sms to 160 only for mikrotik
This commit is contained in:
parent
9c22c22f6c
commit
d666e052f4
@ -24,10 +24,10 @@ 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($config['sms_url']) > 4 && substr($config['sms_url'], 0, 4) != "http") {
|
||||||
if (strlen($txt) > 160) {
|
if (strlen($txt) > 160) {
|
||||||
$txts = str_split($txt, 160);
|
$txts = str_split($txt, 160);
|
||||||
foreach ($txts as $txt) {
|
foreach ($txts as $txt) {
|
||||||
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']);
|
||||||
@ -36,14 +36,8 @@ class Message
|
|||||||
// 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 {
|
|
||||||
$smsurl = str_replace('[number]', urlencode($phone), $config['sms_url']);
|
|
||||||
$smsurl = str_replace('[text]', urlencode($txt), $smsurl);
|
|
||||||
Http::getData($smsurl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
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']);
|
||||||
@ -52,6 +46,7 @@ class Message
|
|||||||
// 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']);
|
||||||
$smsurl = str_replace('[text]', urlencode($txt), $smsurl);
|
$smsurl = str_replace('[text]', urlencode($txt), $smsurl);
|
||||||
@ -59,7 +54,6 @@ class Message
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static function sendWhatsapp($phone, $txt)
|
public static function sendWhatsapp($phone, $txt)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user