From 165f7370b89857b4db89eb2d873fa120791bd8cf Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 2 Aug 2011 15:59:36 +0000 Subject: Polishing of the snort pacakge, part 2: * Get rid of snort_head.inc * No more apply settings button since it does not make sense * Other cleanups in many parts of the code Tested only on 2.0 --- config/snort/snort_rules_edit.php | 123 ++++++++++++-------------------------- 1 file changed, 39 insertions(+), 84 deletions(-) (limited to 'config/snort/snort_rules_edit.php') diff --git a/config/snort/snort_rules_edit.php b/config/snort/snort_rules_edit.php index 05712e49..deb489dc 100644 --- a/config/snort/snort_rules_edit.php +++ b/config/snort/snort_rules_edit.php @@ -61,60 +61,23 @@ if (isset($id) && $a_nat[$id]) { $pconfig['rulesets'] = $a_nat[$id]['rulesets']; } -/* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); - - -$file = $_GET['openruleset']; - -//read snort file -$filehandle = fopen($file, "r"); - //get rule id $lineid = $_GET['ids']; +$file = $_GET['openruleset']; //read file into string, and get filesize also chk for empty files if (filesize($file) > 0 ) { - $contents2 = fread($filehandle, filesize($file)); + $contents2 = file_get_contents($file); }else{ $contents2 = ''; } -//close handler -fclose ($filehandle); - //delimiter for each new rule is a new line $delimiter = "\n"; //split the contents of the string file into an array using the delimiter $splitcontents = explode($delimiter, $contents2); -//copy rule contents from array into string -$tempstring = $splitcontents[$lineid]; - -if (!function_exists('write_rule_file')) { -function write_rule_file($content_changed, $received_file) -{ - //read snort file with writing enabled - $filehandle = fopen($received_file, "w"); - - //delimiter for each new rule is a new line - $delimiter = "\n"; - - //implode the array back into a string for writing purposes - $fullfile = implode($delimiter, $content_changed); - - //write data to file - fwrite($filehandle, $fullfile); - - //close file handle - fclose($filehandle); - -} -} - - - if($_POST['highlight'] <> "") { if($_POST['highlight'] == "yes" or $_POST['highlight'] == "enabled") { @@ -147,16 +110,16 @@ if ($_POST) $splitcontents[$lineid] = $rule_content2; //write the new .rules file - write_rule_file($splitcontents, $file); + @file_put_contents($file, implode($delimiter, $splitcontents)); - header("Location: /snort/snort_view_edit.php?id=$id&openruleset=$file&ids=$ids"); + echo ""; + //header("Location: /snort/snort_view_edit.php?id=$id&openruleset=$file&ids=$ids"); exit; } } $pgtitle = array(gettext("Advanced"), gettext("File Editor")); -// ?> @@ -165,45 +128,38 @@ $pgtitle = array(gettext("Advanced"), gettext("File Editor")); - - -
-
-
- -
- ' . "\n"; - - echo 'Disable original rule :'; - - - echo ' - - - -
- - - - - -
-
- - -
-
'; - - } - ?> - + + + + + + + +
+ + +
+ Disable original rule :
+ + /> + + /> + +
+ + + + +
+
+ + +
+
+
@@ -212,17 +168,16 @@ $pgtitle = array(gettext("Advanced"), gettext("File Editor")); wrap="off" style="width: 98%; margin: 7px;" class=":showcolumns" rows="33" - cols="" name="code2"> + cols="" name="code2">
- - + -- cgit v1.2.3