0 ) $contents = file_get_contents($file); //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, $contents); $findme = "# alert"; //find string for disabled alerts $highlight = "yes"; if (strstr($splitcontents[$lineid], $findme)) $highlight = "no"; if ($highlight == "no") $splitcontents[$lineid] = substr($splitcontents[$lineid], 2); if ($_POST) { if ($_POST['save']) { //copy string into file array for writing if ($_POST['highlight'] == "yes") $splitcontents[$lineid] = $_POST['code']; else $splitcontents[$lineid] = "# " . $_POST['code']; //write disable/enable sid to config.xml $sid = get_middle($splitcontents[$lineid], 'sid:', ';', 0); if (is_numeric($sid)) { // rule_sid_on registers if (!empty($a_nat[$id]['rule_sid_on'])) $a_nat[$id]['rule_sid_on'] = str_replace("||enablesid $sid", "", $a_nat[$id]['rule_sid_on']); if (!empty($a_nat[$id]['rule_sid_on'])) $a_nat[$id]['rule_sid_off'] = str_replace("||disablesid $sid", "", $a_nat[$id]['rule_sid_off']); if ($_POST['highlight'] == "yes") $a_nat[$id]['rule_sid_on'] = "||enablesid $sid" . $a_nat[$id]['rule_sid_on']; else $a_nat[$id]['rule_sid_off'] = "||disablesid $sid" . $a_nat[$id]['rule_sid_off']; } //write the new .rules file @file_put_contents($file, implode($delimiter, $splitcontents)); write_config(); echo ""; exit; } } $pgtitle = array(gettext("Advanced"), gettext("File Editor")); ?>