<?php
/*
** SnortCenter Copyright (C) 2001,2002,2003 Stefan Dens
**
** Author: Stefan Dens <hide@address.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
?>
<?php
include("config.php");
$db = NewACIDDBConnection($DBlib_path, $DBtype);
$db->acidConnect($DB_dbname, $DB_host, $DB_port, $DB_user, $DB_password);
if ($do == "Save") {
$sql_insert = "INSERT INTO rules_template (template_name, template_description, def_template) ";
$sql_values = "VALUES ('$template_name', '$template_description', 'no')";
$result = $db->acidExecute($sql_insert.$sql_values);
$result->acidFreeRows();
$result = $db->acidExecute("SELECT max(id) FROM rules_template");
$myrow = $result->acidFetchRow();
$result->acidFreeRows();
$template_id = $myrow[0];
echo '<SCRIPT language=javascript>setTimeout("location.href=\'sensor_rules.php?sensor_id='.$sensor_id.'\'",0);</SCRIPT>';
}
if ($do == "Update") {
$result = $db->acidExecute("UPDATE rules_template SET template_name='$template_name', template_description='$template_description' where id='$template_id'");
$result->acidFreeRows();
echo '<SCRIPT language=javascript>setTimeout("location.href=\'sensor_rules.php?sensor_id='.$sensor_id.'\'",0);</SCRIPT>';
}
if ($do == "Delete") {
$result = $db->acidExecute("Delete FROM rules_template where id='$template_id'");
$result->acidFreeRows();
echo '<SCRIPT language=javascript>setTimeout("location.href=\'sensor_rules.php?sensor_id='.$sensor_id.'\'",0);</SCRIPT>';
}
if ($do != "new") {
$result = $db->acidExecute("SELECT template_name, template_description FROM rules_template where id='$template_id'");
$myrow = $result->acidFetchRow();
$result->acidFreeRows();
list($template_name, $template_description) = $myrow;
}
include('top.inc.php');
echo "<BR>";
echo "<table align=center border=0 cellpadding=1 cellspacing=0 width=60%><tr bgcolor=#f9f890><td>";
echo "<table style=\"font-size:12px; font-family: Verdana;\" align=center border=0 cellspacing=0 cellpadding=0 width=100%>";
echo "<FORM action=\"\" method=GET>";
echo "<INPUT TYPE=HIDDEN NAME=sensor_id VALUE='$sensor_id'>";
echo "<INPUT TYPE=HIDDEN NAME=template_id VALUE='$template_id'>";
echo "<TR><TD colspan=2><B>$lang[277]</B></TD></TR>";
echo "<TR bgcolor=#DDDDDD><TD> $lang[279]</TD><TD><INPUT NAME=template_name TYPE=TEXT value='$template_name' SIZE=50></TD></TR>";
echo "<TR bgcolor=#DDDDDD><TD> $lang[280]</TD><TD><INPUT NAME=template_description TYPE=text value='$template_description' SIZE=65></TD></TR>";
echo "<TR bgcolor=#DDDDDD><TD colspan=2> </TD></TR>";
echo "</TABLE></TD></TR></TABLE><BR>";
if ($do == "new") {
echo "<CENTER><INPUT NAME='do' VALUE='Save' TYPE=SUBMIT> <INPUT VALUE='Reset' TYPE=RESET></CENTER>";
} else {
echo "<CENTER><INPUT NAME='do' VALUE='Update' TYPE=SUBMIT> <INPUT VALUE='Reset' TYPE=RESET> <INPUT NAME='do' VALUE='Delete' TYPE=SUBMIT></CENTER>";
}
echo "</FORM>";
echo "<BR>";
require('bottom.inc.php');
?>