#!/usr/bin/perl
#
#
# PIX Logging Architecture
# [Kristof Philipsen]
#
# This file is part of PIX Logging Architecture
#
# PIX Logging Architecture 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.
#
# PIX Logging Architecture 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 PIX Logging Architecture; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

use DBI;
use CGI;

#
# include configuration
#
require "conf.pl";      # General Configuration
require "subs.pl";      # Subroutines
 
#
# Make Database Connection
#
db_connect();
 
#
# CGI Parameters
#
$query = new CGI;
$type = clean_input($query->param("type"));
 
if ($type eq "") {
    $type="traffic";
}

#
# HTML SECTION
#
printtitle();

if ($type eq "traffic") { 
print <<EOF;
<span class='titlehead'><b>PLA Configuration > Traffic Logs > Create Description</b></span>
EOF
}
if ($type eq "ids") {
print <<EOF;
<span class='titlehead'><b>PLA Configuration > IDS Logs > Create Description</b></span>
EOF
}
print <<EOF;
<br><br><br>
<form action="./pix_config_description_process" method="get" name="description">
 <table width="500" cellpadding="0" cellspacing="0" border="0">
    <td bgcolor="#5479d8"><span class="button"> >> General Criteria</span</td>
    </table>
    <table width="500" cellpadding="0" cellspacing="0" border="0" bgcolor="#d9d9d9">
    <td><br>
    <input type="hidden" name="type" value="$type">
    <span class="main">Description Name:</span> <input type="text" name="description_name" size="60" width="50"><span class="main"><br>
    Logging Resource: 
    <select name="log_resource">
    <option selected value="">All Firewalls
    <option value="">
EOF
$getAllResources="SELECT log_resource from traffic_log group by log_resource";
$AllResources = $db_handle->prepare($getAllResources) or die "Couldn't prepare query '$getAllResources': $DBI::errstr\n";
$AllResources->execute();
while ($log_resource = $AllResources->fetchrow) {
print <<EOF;
<option value="$log_resource">$log_resource
EOF
}
print <<EOF;
</select><br>
EOF
if ($type eq "traffic") {
print <<EOF;
Logging Action: 
<select name="log_action">
<option selected value="any">Any
<option>
<option value="ACCEPT">Accept
<option value="DROP">Drop
</select>
&nbsp;&nbsp;
EOF
}
print <<EOF;
Protocol: 
<select name="log_protocol">
<option selected value="TCP">TCP
<option value="UDP">UDP
<option value="ICMP">ICMP
EOF
if ($type eq "ids") {
print <<EOF;
<option value="IP">IP
EOF
}
print <<EOF;
</select><br>
Traffic Type/Priority:
<select name="traffic_type">
<option selected value="Normal/Low">Normal/Low
<option value="Normal/Medium">Normal/Medium
<option value="Normal/High">Normal/High
<option value="Anomalous/Low">Anomalous/Low
<option value="Anomalous/Medium">Anomalous/Medium
<option value="Anomalous/High">Anomalous/High
</select>
    </td>
    </table>
    <table width="500" cellpadding="0" cellspacing="0" border="0">
    <td bgcolor="#5479d8"><span class="button"> >> TCP/IP Criteria</span</td>
    </table>
    <table width="500" cellpadding="0" cellspacing="0" border="0" bgcolor="#d9d9d9">
    <td><br>
    <span class="main">Src IP:</span> <input type="text" name="src_ip" border="0"></input>
EOF
    if ($type eq "traffic") {
print <<EOF;
    <span class="main">Src Port:</span> <input type="text" name="src_pt" size="5"></input>
EOF
    }
print <<EOF;
    <br>
    <span class="main">Dst IP:</span> <input type="text" name="dst_ip" border="0"></input>
EOF
    if ($type eq "traffic") {
print <<EOF;
    <span class="main">Dst Port:</span> <input type="text" name="dst_pt" size="5"></input>
EOF
    }
print <<EOF;
    <br><br>
    </td></table>
  <table width="500" cellpadding="0" cellspacing="0" border="0">
    <td bgcolor="#5479d8"><span class="button"> >> Description Criteria</span</td>
    </table>
    <table width="500" cellpadding="0" cellspacing="0" border="0" bgcolor="#d9d9d9">
    <td><br>
<span class="main">Description Detail:</span><br>
<textarea name="description_detail" rows="5" cols="60" scrollable="no" multiline="true"></textarea><span class="main">
<br><br>
</td>
<tr>
<td bgcolor="#000000" align="left" valign="top" height="3"></td>
<tr>
<td bgcolor="#a7a7a7" align="left" valign="top">
<input type="image" src="images/pla_create.gif" border="0" value="Create">
<a href="javascript:window.document.description.reset();"><img src="images/pla_reset.gif" border="0"></a>
</form>
</td></table>
EOF
$db_handle->disconnect();

