mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
More updates for new transports
This commit is contained in:
@@ -181,7 +181,7 @@ else if ($action == 'add-clickatell') {
|
||||
$mobiles = explode('\n', $config_to);
|
||||
foreach ($mobiles as $mobile) {
|
||||
if (!empty($mobile)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.clickatell.'.$config_id.'.to', 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'Clickatell mobile'), 'config');
|
||||
dbInsert(array('config_name' => 'alert.transports.clickatell.'.$config_id.'.to.', 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'Clickatell mobile'), 'config');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ elseif ($action == 'add-playsms') {
|
||||
$mobiles = explode('\n', $config_to);
|
||||
foreach ($mobiles as $mobile) {
|
||||
if (!empty($mobile)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.to', 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'PlaySMS mobile'), 'config');
|
||||
dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.to.', 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'PlaySMS mobile'), 'config');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ $status = 'error';
|
||||
if (!is_numeric($config_id)) {
|
||||
$message = 'ERROR: No config item';
|
||||
}
|
||||
else if ($action == 'update-textarea') {
|
||||
elseif ($action == 'update-textarea') {
|
||||
$extras = explode(PHP_EOL, $_POST['config_value']);
|
||||
foreach ($extras as $option) {
|
||||
list($k,$v) = explode('=', $option, 2);
|
||||
@@ -33,15 +33,21 @@ else if ($action == 'update-textarea') {
|
||||
if ($config_type == 'slack') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Slack Transport'), 'config');
|
||||
}
|
||||
else if ($config_type == 'hipchat') {
|
||||
elseif ($config_type == 'hipchat') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Hipchat Transport'), 'config');
|
||||
}
|
||||
else if ($config_type == 'pushover') {
|
||||
elseif ($config_type == 'pushover') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Pushover Transport'), 'config');
|
||||
}
|
||||
elseif ($config_type == 'boxcar') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.boxcar.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Boxcar Transport'), 'config');
|
||||
}
|
||||
elseif ($config_type == 'clickatell') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.clickatell.'.$config_id.'.to.', 'config_value' => $k, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Clickatell Transport'), 'config');
|
||||
}
|
||||
elseif ($config_type == 'playsms') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.to.', 'config_value' => $k, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'PlaySMS Transport'), 'config');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,15 +60,21 @@ else if ($action == 'update-textarea') {
|
||||
if ($config_type == 'slack') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.slack.$config_id.%' AND `config_name` != 'alert.transports.slack.$config_id.url' AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
else if ($config_type == 'hipchat') {
|
||||
elseif ($config_type == 'hipchat') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.hipchat.$config_id.%' AND (`config_name` != 'alert.transports.hipchat.$config_id.url' AND `config_name` != 'alert.transports.hipchat.$config_id.room_id' AND `config_name` != 'alert.transports.hipchat.$config_id.from') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
else if ($config_type == 'pushover') {
|
||||
elseif ($config_type == 'pushover') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.pushover.$config_id.%' AND (`config_name` != 'alert.transports.pushover.$config_id.appkey' AND `config_name` != 'alert.transports.pushover.$config_id.userkey') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
else if ($config_type == 'boxcar') {
|
||||
elseif ($config_type == 'boxcar') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.boxcar.$config_id.%' AND (`config_name` != 'alert.transports.boxcar.$config_id.access_token' AND `config_name` != 'alert.transports.boxcar.$config_id.userkey') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
elseif ($config_type == 'clickatell') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.clickatell.$config_id.%' AND (`config_name` != 'alert.transports.clickatell.$config_id.token') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
elseif ($config_type == 'playsms') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.playsms.$config_id.%' AND (`config_name` != 'alert.transports.playsms.$config_id.url' AND `config_name` != 'alert.transports.playsms.$config_id.from' AND `config_name` != 'alert.transports.playsms.$config_id.user' AND `config_name` != 'alert.transports.playsms.$config_id.token') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
}
|
||||
|
||||
$message = 'Config item has been updated:';
|
||||
|
||||
@@ -1097,7 +1097,7 @@ function get_config_like_name($name) {
|
||||
$name = array($name);
|
||||
$items = array();
|
||||
foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_name` LIKE '%?%'", array($name)) as $config_item) {
|
||||
$items[$config_item['config_name']] = $config_item;
|
||||
$items[$config_item['config_id']] = $config_item;
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
||||
@@ -803,7 +803,7 @@ echo '<div id="boxcar_appkey_template" class="hide">
|
||||
</div>';
|
||||
$clickatells = get_config_like_name('alert.transports.clickatell.%.token');
|
||||
foreach ($clickatells as $clickatell) {
|
||||
$to = get_config_like_name('alert.transports.clickatell.'.$clickatell['config_id'].'.to');
|
||||
$to = get_config_like_name('alert.transports.clickatell.'.$clickatell['config_id'].'.to.');
|
||||
$new_extra = array();
|
||||
unset($upd_extra);
|
||||
foreach ($to as $number) {
|
||||
@@ -871,7 +871,7 @@ foreach ($playsms as $item) {
|
||||
$playsms_user = get_config_by_name('alert.transports.playsms.'.$item['config_id'].'.user');
|
||||
$playsms_token = get_config_by_name('alert.transports.playsms.'.$item['config_id'].'.token');
|
||||
$playsms_from = get_config_by_name('alert.transports.playsms.'.$item['config_id'].'.from');
|
||||
$to = get_config_like_name('alert.transports.playsms.'.$item['config_id'].'.%');
|
||||
$to = get_config_like_name('alert.transports.playsms.'.$item['config_id'].'.to.');
|
||||
$new_extra = array();
|
||||
unset($upd_extra);
|
||||
foreach ($to as $number) {
|
||||
|
||||
Reference in New Issue
Block a user