diff --git a/system/autoload/Message.php b/system/autoload/Message.php index c8f184d9..05fea6db 100644 --- a/system/autoload/Message.php +++ b/system/autoload/Message.php @@ -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);