Fix coding style part 2

This commit is contained in:
Job Snijders
2015-07-14 17:41:54 +02:00
parent ad9590df9b
commit 361653aa81
731 changed files with 37529 additions and 33991 deletions
+53 -36
View File
@@ -12,68 +12,85 @@
* the source code distribution for details.
*/
if(is_admin() === false) {
if (is_admin() === false) {
die('ERROR: You need to be admin');
}
$rule = implode(" ", $_POST['rules']);
$rule = rtrim($rule,'&&');
$rule = rtrim($rule,'||');
$rule = implode(' ', $_POST['rules']);
$rule = rtrim($rule, '&&');
$rule = rtrim($rule, '||');
$alert_id = $_POST['alert_id'];
$count = mres($_POST['count']);
$delay = mres($_POST['delay']);
$count = mres($_POST['count']);
$delay = mres($_POST['delay']);
$interval = mres($_POST['interval']);
$mute = mres($_POST['mute']);
$invert = mres($_POST['invert']);
$name = mres($_POST['name']);
$mute = mres($_POST['mute']);
$invert = mres($_POST['invert']);
$name = mres($_POST['name']);
if(empty($rule)) {
$update_message = "ERROR: No rule was generated - did you forget to click and / or?";
} elseif(validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1' || $_POST['device_id'][0] == ':') {
if (empty($rule)) {
$update_message = 'ERROR: No rule was generated - did you forget to click and / or?';
}
else if (validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1' || $_POST['device_id'][0] == ':') {
$device_id = $_POST['device_id'];
if(!is_numeric($count)) {
$count='-1';
if (!is_numeric($count)) {
$count = '-1';
}
$delay_sec = convert_delay($delay);
$delay_sec = convert_delay($delay);
$interval_sec = convert_delay($interval);
if($mute == 'on') {
if ($mute == 'on') {
$mute = true;
} else {
}
else {
$mute = false;
}
if($invert == 'on') {
if ($invert == 'on') {
$invert = true;
} else {
}
else {
$invert = false;
}
$extra = array('mute'=>$mute,'count'=>$count,'delay'=>$delay_sec,'invert'=>$invert,'interval'=>$interval_sec);
$extra = array(
'mute' => $mute,
'count' => $count,
'delay' => $delay_sec,
'invert' => $invert,
'interval' => $interval_sec,
);
$extra_json = json_encode($extra);
if(is_numeric($alert_id) && $alert_id > 0) {
if(dbUpdate(array('rule' => $rule,'severity'=>mres($_POST['severity']),'extra'=>$extra_json,'name'=>$name), 'alert_rules', 'id=?',array($alert_id)) >= 0) {
if (is_numeric($alert_id) && $alert_id > 0) {
if (dbUpdate(array('rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules', 'id=?', array($alert_id)) >= 0) {
$update_message = "Edited Rule: <i>$name: $rule</i>";
} else {
$update_message = "ERROR: Failed to edit Rule: <i>".$rule."</i>";
}
} else {
if( is_array($_POST['maps']) ) {
else {
$update_message = 'ERROR: Failed to edit Rule: <i>'.$rule.'</i>';
}
}
else {
if (is_array($_POST['maps'])) {
$device_id = ':'.$device_id;
}
if( dbInsert(array('device_id'=>$device_id,'rule'=>$rule,'severity'=>mres($_POST['severity']),'extra'=>$extra_json,'name'=>$name),'alert_rules') ) {
if (dbInsert(array('device_id' => $device_id, 'rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules')) {
$update_message = "Added Rule: <i>$name: $rule</i>";
if( is_array($_POST['maps']) ) {
foreach( $_POST['maps'] as $target ) {
$_POST['rule'] = $name;
if (is_array($_POST['maps'])) {
foreach ($_POST['maps'] as $target) {
$_POST['rule'] = $name;
$_POST['target'] = $target;
$_POST['map_id'] = '';
include('forms/create-map-item.inc.php');
include 'forms/create-map-item.inc.php';
unset($ret,$target,$raw,$rule,$msg,$map_id);
}
}
} else {
$update_message = "ERROR: Failed to add Rule: <i>".$rule."</i>";
}
}
} else {
$update_message = "ERROR: invalid device ID or not a global alert";
else {
$update_message = 'ERROR: Failed to add Rule: <i>'.$rule.'</i>';
}
}//end if
}
else {
$update_message = 'ERROR: invalid device ID or not a global alert';
}//end if
echo $update_message;