mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix coding style part 2
This commit is contained in:
@@ -12,30 +12,36 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
$brk = false;
|
||||
if( !is_numeric($_POST['map_id']) ) {
|
||||
array_unshift($ret,'ERROR: No map selected');
|
||||
} else {
|
||||
if( dbFetchCell('SELECT COUNT(B.id) FROM alert_map,alert_map AS B WHERE alert_map.rule=B.rule && alert_map.id = ?',array($_POST['map_id'])) <= 1 ) {
|
||||
$rule = dbFetchRow('SELECT alert_rules.id,alert_rules.device_id FROM alert_map,alert_rules WHERE alert_map.rule=alert_rules.id && alert_map.id = ?',array($_POST['map_id']));
|
||||
$rule['device_id'] = str_replace(":",'',$rule['device_id']);
|
||||
if( dbUpdate(array('device_id'=>$rule['device_id']),'alert_rules','id = ?',array($rule['id'])) >= 0 ) {
|
||||
$ret[] = "Restored Rule: <i>".$rule['id'].": device_id = '".$rule['device_id']."'</i>";
|
||||
} else {
|
||||
array_unshift($ret, 'ERROR: Rule '.$rule['id'].' has not been restored.');
|
||||
$brk = true;
|
||||
}
|
||||
}
|
||||
if( $brk === false && dbDelete('alert_map', "`id` = ?", array($_POST['map_id'])) ) {
|
||||
$ret[] = 'Map has been deleted.';
|
||||
} else {
|
||||
array_unshift($ret, 'ERROR: Map has not been deleted.');
|
||||
}
|
||||
if (!is_numeric($_POST['map_id'])) {
|
||||
array_unshift($ret, 'ERROR: No map selected');
|
||||
}
|
||||
foreach( $ret as $msg ) {
|
||||
echo $msg."<br/>";
|
||||
else {
|
||||
if (dbFetchCell('SELECT COUNT(B.id) FROM alert_map,alert_map AS B WHERE alert_map.rule=B.rule && alert_map.id = ?', array($_POST['map_id'])) <= 1) {
|
||||
$rule = dbFetchRow('SELECT alert_rules.id,alert_rules.device_id FROM alert_map,alert_rules WHERE alert_map.rule=alert_rules.id && alert_map.id = ?', array($_POST['map_id']));
|
||||
$rule['device_id'] = str_replace(':', '', $rule['device_id']);
|
||||
if (dbUpdate(array('device_id' => $rule['device_id']), 'alert_rules', 'id = ?', array($rule['id'])) >= 0) {
|
||||
$ret[] = 'Restored Rule: <i>'.$rule['id'].": device_id = '".$rule['device_id']."'</i>";
|
||||
}
|
||||
else {
|
||||
array_unshift($ret, 'ERROR: Rule '.$rule['id'].' has not been restored.');
|
||||
$brk = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($brk === false && dbDelete('alert_map', '`id` = ?', array($_POST['map_id']))) {
|
||||
$ret[] = 'Map has been deleted.';
|
||||
}
|
||||
else {
|
||||
array_unshift($ret, 'ERROR: Map has not been deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($ret as $msg) {
|
||||
echo $msg.'<br/>';
|
||||
}
|
||||
|
Reference in New Issue
Block a user