Change procedure management. Using URL instead of file

This commit is contained in:
Guillaume COEUGNET
2016-06-06 11:41:41 +02:00
parent 88eb7c4c04
commit 6c8a75a5f7
5 changed files with 9 additions and 12 deletions

View File

@@ -97,7 +97,7 @@ if(defined('show_settings')) {
</div>
<div class="form-group row">
<div class="col-sm-4">
<label for="proc" class="control-label">Show Doc field: </label>
<label for="proc" class="control-label">Show Procedure field: </label>
</div>
<div class="col-sm-8">
<select class="form-control" name="proc">';
@@ -264,11 +264,11 @@ var alerts_grid = $("#alerts_'.$unique_id.'").bootgrid({
url: "ajax_form.php",
data: { type: "open-proc", alert_id: alert_id },
success: function(msg){
window.open("procs/"+msg);
// $("#message").html(\'<div class="alert alert-info">Opening \'+msg+\'</div>\');
if (msg != "ERROR") { window.open(msg); }
else { $("#message").html(\'<div class="alert alert-info">Procedure link does not seem to be valid, please check the rule.</div>\'); }
},
error: function(){
$("#message").html(\'<div class="alert alert-info">An error occurred opening procedure for this alert. Does the procedure exists ?</div>\');
$("#message").html(\'<div class="alert alert-info">An error occurred opening procedure for this alert. Does the procedure link was configured ?</div>\');
}
});
});

View File

@@ -27,14 +27,11 @@ $mute = mres($_POST['mute']);
$invert = mres($_POST['invert']);
$name = mres($_POST['name']);
if ($_POST['proc'] != "") { $proc = $_POST['proc']; }
else { $proc = "noproc.pdf"; }
else { $proc = ""; }
if (empty($rule)) {
$update_message = 'ERROR: No rule was generated - did you forget to click and / or?';
}
else if (! file_exists ("procs/".$proc)) {
$update_message = 'ERROR: Procedure \''.$proc.'\' doesn\'t exists in procs directory';
}
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)) {

View File

@@ -20,7 +20,8 @@ if (!is_numeric($alert_id)) {
}
else {
$proc = dbFetchCell('SELECT proc FROM alerts,alert_rules WHERE alert_rules.id = alerts.rule_id AND alerts.id = ?', array($alert_id));
if (! file_exists ("procs/$proc")) { echo header("HTTP/1.0 404 Not Found"); }
if (($proc == "") || ($proc == "NULL")) { echo header("HTTP/1.0 404 Not Found"); }
else if (! preg_match ('/^http:\/\//', $proc)) { echo "ERROR"; }
else { echo $proc; }
exit;
}

View File

@@ -135,7 +135,7 @@ if(is_admin() !== false) {
</div>
</div>
<div class='form-group'>
<label for='proc' class='col-sm-3 control-label'>Doc name: </label>
<label for='proc' class='col-sm-3 control-label'>Procedure URL: </label>
<div class='col-sm-9'>
<input type='text' id='proc' name='proc' class='form-control' maxlength='30'>
</div>

View File

@@ -1,2 +1 @@
ALTER TABLE alert_rules ADD COLUMN proc VARCHAR(30) AFTER name;
UPDATE alert_rules SET proc="noproc.pdf";
ALTER TABLE alert_rules ADD COLUMN proc VARCHAR(80) AFTER name;