]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/ids.cgi
ids.cgi: Rework "Enable IPS" section
[ipfire-2.x.git] / html / cgi-bin / ids.cgi
index 604d216c8938fea9aee7055cb95f399b4bf89866..1235d477668bd1da437d8733e0cbe5f4221ed687 100644 (file)
@@ -323,8 +323,8 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
                &IDS::call_suricatactrl("cron", $cgiparams{'AUTOUPDATE_INTERVAL'});
        }
 
-       # Check if a ruleset is present - if not download it.
-       unless (%idsrules) {
+       # Check if a ruleset is present - if not or the source has been changed download it.
+       if((! %idsrules) || ($oldsettings{'RULES'} ne $cgiparams{'RULES'})) {
                # Check if the red device is active.
                unless (-e "${General::swroot}/red/active") {
                        $errormessage = "$Lang::tr{'could not download latest updates'} - $Lang::tr{'system is offline'}";
@@ -352,6 +352,14 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
                                &IDS::oinkmaster();
                        }
 
+                       # Check if the IDS is running.
+                       if(&IDS::ids_is_running()) {
+                               # Call suricatactrl to stop the IDS - because of the changed
+                               # ruleset - the use has to configure it before suricata can be
+                               # used again.
+                               &IDS::call_suricatactrl("stop");
+                       }
+
                        # Perform a reload of the page.
                        &reload();
                }
@@ -644,8 +652,13 @@ $selected{'AUTOUPDATE_INTERVAL'}{$rulessettings{'AUTOUPDATE_INTERVAL'}} = "selec
 &Header::openpage($Lang::tr{'intrusion detection system'}, 1, '');
 
 ### Java Script ###
+print"<script>\n";
+
+# Java script variable declaration for show and hide.
+print"var show = \"$Lang::tr{'ids show'}\"\;\n";
+print"var hide = \"$Lang::tr{'ids hide'}\"\;\n";
+
 print <<END
-<script>
        // JQuery function to show/hide the text input field for
        // Oinkcode/Subscription code.
        \$(function() {
@@ -666,6 +679,15 @@ print <<END
        // of a given category.
        function showhide(tblname) {
                \$("#" + tblname).toggle();
+
+               // Get current content of the span element.
+               var content = document.getElementById("span_" + tblname);
+
+               if (content.innerHTML === show) {
+                       content.innerHTML = hide;
+               } else {
+                       content.innerHTML = show;
+               }
        }
 </script>
 END
@@ -753,11 +775,11 @@ if (%idsrules) {
                <table width='100%' border='0'>
                        <tr>
                                <td class='base' colspan='2'>
-                                       <input type='checkbox' name='ENABLE_IDS' $checked{'ENABLE_IDS'}{'on'}>$Lang::tr{'ids activate'} $Lang::tr{'intrusion detection system'}
+                                       <input type='checkbox' name='ENABLE_IDS' $checked{'ENABLE_IDS'}{'on'}>&nbsp$Lang::tr{'ids enable'}
                                </td>
 
                                <td class='base' colspan='2'>
-                                       <input type='checkbox' name='MONITOR_TRAFFIC_ONLY' $checked{'MONITOR_TRAFFIC_ONLY'}{'on'}>$Lang::tr{'ids monitor traffic only'}
+                                       <input type='checkbox' name='MONITOR_TRAFFIC_ONLY' $checked{'MONITOR_TRAFFIC_ONLY'}{'on'}>&nbsp$Lang::tr{'ids monitor traffic only'}
                        </td>
                        </tr>
 
@@ -845,9 +867,9 @@ print <<END
 
                        <td>
                                <select name='AUTOUPDATE_INTERVAL'>
-                                       <option value='off' $selected{'AUTOUPDATE_INTERVAL'}{'off'} >$Lang::tr{'no'}</option>
-                                       <option value='daily' $selected{'AUTOUPDATE_INTERVAL'}{'daily'} >$Lang::tr{'urlfilter daily'}</option>
-                                       <option value='weekly' $selected{'AUTOUPDATE_INTERVAL'}{'weekly'} >$Lang::tr{'urlfilter weekly'}</option>
+                                       <option value='off' $selected{'AUTOUPDATE_INTERVAL'}{'off'} >- $Lang::tr{'Disabled'} -</option>
+                                       <option value='daily' $selected{'AUTOUPDATE_INTERVAL'}{'daily'} >$Lang::tr{'Daily'}</option>
+                                       <option value='weekly' $selected{'AUTOUPDATE_INTERVAL'}{'weekly'} >$Lang::tr{'Weekly'}</option>
                                </select>
                        </td>
                </tr>
@@ -1043,7 +1065,7 @@ if (%idsrules) {
                        print"</td>\n";
                        print"<td class='base' width='90%'><b>$rulefile</b></td>\n";
                        print"<td class='base' width='5%' align='right'>\n";
-                       print"<a href=\"javascript:showhide('$categoryname')\">SHOW</a>\n";
+                       print"<a href=\"javascript:showhide('$categoryname')\"><span id='span_$categoryname'>$Lang::tr{'ids show'}</span></a>\n";
                        print"</td>\n";
                        print"</tr>\n";