#!/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 Foobar; 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();
                                                                                                                                                                                                  
#
# Get CGI Parameters
#
$query = new CGI;
$incident_name = $query->param("incident_name");
$incident_handler = $query->param("incident_handler");
$incident_severity = $query->param("incident_severity");
$incident_status = $query->param("incident_status");
$incident_description = $query->param("incident_description");
$date=`date +%Y"-"%m"-"%d" "%H":"%M":"%S`;
$date=~s/\n//g;
                                                                                                                                                                                                  
#
# DB Query Parameters
#
$addIncident_query=$db_handle->prepare("update event_management_data set incident_name=\'$incident_name\', incident_status=\'$incident_status\', incident_update_time=\'$date\', incident_severity=\'$incident_severity\', incident_description=\'$incident_description\', incident_handler=\'$incident_handler\' where incident_id=\'$id\'");
$rc=$addIncident_query->execute();
                                                                                                                                                                                                  
                                                                                                                                                                                                  
#
# HTML SECTION
#
printtitle();
                                                                                                                                                                                                  
print <<EOF;
<span class='titlehead'><b>PIX Event Management > Create New Incident</b></span>
<br><br><span class="main">
The following incident had  been added to the database:<br><br>
EOF
$getAllEvents = "SELECT incident_id, incident_entry_time, incident_status, incident_update_time, incident_name, incident_severity, incident_handler, incident_description FROM event_management_data where incident_name like \"$incident_name\"";
$statement2 = $db_handle->prepare($getAllEvents) or die "Couldn't prepare query '$getAllEvents': $DBI::errstr\n";
$statement2->execute();
while (($incident_id, $incident_entry_time, $incident_status, $incident_update_time, $incident_name, $incident_severity, $incident_handler, $incident_description) = $statement2->fetchrow) {
print <<EOF;
<table width="150" cellpadding="0" cellspacing="0">
<td width="150" bgcolor="#5479d8"><span class="button">PIX Incident Details</td>
</table>
<br><br>
<table width="600" cellpadding="0" cellspacing="0">
<td width="200"><span class="main">Incident Name:</td>
<td width="400"><span class="main"><b>$incident_name</b></td>
<tr>
<td width="200"><span class="main">Incident Entry Time:</td>
<td width="400"><span class="main">$incident_entry_time</td>
<tr>
<td width="200"><span class="main">Incident Update Time:</td>
<td width="400"><span class="main">$incident_update_time</td>
<tr>
<td width="200"><span class="main">Incident Handler:</td>
<td width="400"><span class="main">$incident_handler</td>
<tr>
<td width="200"><span class="main">Incident Severity:</td>
<td width="400"><span class="main">$incident_severity</td>
<tr>
<td width="200"><span class="main">Incident Status:</td>
<td width="400"><span class="main">$incident_status</td>
<tr>
<td width="200"><span class="main">Incident Description:</td>
<td width="400"><span class="main">$incident_description</td>
<tr>
<tr>
</table>
<br><br>
EOF
}

$db_handle->disconnect();

