sms using Mikrotik
This commit is contained in:
parent
9d79121696
commit
6a0ad7f178
@ -24,11 +24,22 @@ 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") {
|
||||||
|
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('[number]', urlencode($phone), $config['sms_url']);
|
||||||
$smsurl = str_replace('[text]', urlencode($txt), $smsurl);
|
$smsurl = str_replace('[text]', urlencode($txt), $smsurl);
|
||||||
Http::getData($smsurl);
|
Http::getData($smsurl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function sendWhatsapp($phone, $txt)
|
public static function sendWhatsapp($phone, $txt)
|
||||||
{
|
{
|
||||||
|
@ -501,4 +501,19 @@ class Mikrotik
|
|||||||
->setArgument('numbers', $profileID)
|
->setArgument('numbers', $profileID)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function sendSMS($client, $to, $message)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$req = new RouterOS\Request('/tool/sms/send');
|
||||||
|
$client(
|
||||||
|
$req
|
||||||
|
->setArgument('phone', $to)
|
||||||
|
->setArgument('message', $message)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,16 @@ switch ($action) {
|
|||||||
$themes[] = $file;
|
$themes[] = $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$r = ORM::for_table('tbl_routers')->find_many();
|
||||||
|
$ui->assign('r', $r);
|
||||||
|
if (function_exists("shell_exec")) {
|
||||||
$php = trim(shell_exec('which php'));
|
$php = trim(shell_exec('which php'));
|
||||||
if (empty($php)) {
|
if (empty($php)) {
|
||||||
$php = 'php';
|
$php = 'php';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$php = 'php';
|
||||||
|
}
|
||||||
$ui->assign('php', $php);
|
$ui->assign('php', $php);
|
||||||
$ui->assign('dir', str_replace('controllers', '', __DIR__));
|
$ui->assign('dir', str_replace('controllers', '', __DIR__));
|
||||||
$ui->assign('themes', $themes);
|
$ui->assign('themes', $themes);
|
||||||
@ -473,10 +479,9 @@ switch ($action) {
|
|||||||
$d->value = $tawkto;
|
$d->value = $tawkto;
|
||||||
$d->save();
|
$d->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($radius_enable) {
|
if ($radius_enable) {
|
||||||
try {
|
try {
|
||||||
Radius::getTableNas()->find_one(1);
|
Radius::getTableNas()->find_many();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$ui->assign("error_title", "RADIUS Error");
|
$ui->assign("error_title", "RADIUS Error");
|
||||||
$ui->assign("error_message", "Radius table not found.<br><br>" .
|
$ui->assign("error_message", "Radius table not found.<br><br>" .
|
||||||
|
@ -225,6 +225,20 @@
|
|||||||
replaced.
|
replaced.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label">Or use Mikrotik SMS</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<select class="form-control" onchange="document.getElementById('sms_url').value = this.value">
|
||||||
|
<option value="">Select Router</option>
|
||||||
|
{foreach $r as $rs}
|
||||||
|
<option value="{$rs['name']}">{$rs['name']}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="help-block col-md-4">Must include <b>[text]</b> & <b>[number]</b>, it will be
|
||||||
|
replaced.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<small id="emailHelp" class="form-text text-muted">You can use WhatsApp in here too. <a
|
<small id="emailHelp" class="form-text text-muted">You can use WhatsApp in here too. <a
|
||||||
href="https://wa.nux.my.id/login" target="_blank">Free Server</a></small>
|
href="https://wa.nux.my.id/login" target="_blank">Free Server</a></small>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user