sms using Mikrotik
This commit is contained in:
@ -24,9 +24,20 @@ class Message
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user