<%doc>
# 
# $Id: sec-adv.html,v 1.2 2002/01/28 15:43:27 adulau Exp $
#
# Sec-advisory.html is page to manage security advisor and their source

# Authors : Alexandre Dulaunoy <alex@thinkingsecure.com>
# Copyright (C) 2001 Conostix S.A. Luxembourg - Tycho Fruru <tycho@conostix.com>
# Copyright (C) 2001, 2002 Alexandre Dulaunoy <alex@foo.be>

# 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.  See <http://www.fsf.org/copyleft/gpl.txt>.
#
# 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.
#
</%doc><%args>
$session

$action=>"none"
$source_id=>""
$source_url=>""
$source_remark=>""
$agent_id=>"0"
$ticket=>""
$subject=>""
$description=>""
</%args>

<%perl>


if ($action eq "add-new")
{
my $query ="INSERT INTO source (source_url, source_remark) VALUES ('$source_url','$source_remark')";
$session->{'lastaction'}="security advisory $source_id added";
my @resultsupdate = $m->comp('../internal/sql-query-adv.ipfc',query=>$query);
}
elsif ($action eq "update")
{

my $query  = "UPDATE source SET source_url = '".$source_url."', source_remark = '".$source_remark."' WHERE source_id =".$source_id."";
my @resultsupdate = $m->comp('../internal/sql-query-adv.ipfc',query=>$query);
$session->{'lastaction'}="security advisory $source_id updated";
}
elsif ($action eq "delete")
{
my $query ="DELETE FROM source WHERE source_id = $source_id";
my @resultsupdate = $m->comp('../internal/sql-query-adv.ipfc',query=>$query);
$session->{'lastaction'}="security advisory $source_id deleted";
}
elsif ($action eq "none")
{
$session->{'lastaction'}="none";
}
$session->{query} = "select source_id, source_url, source_creation, source_remark from source order by source_id";
my @results = $m->comp('../internal/sql-query-adv.ipfc',query=>$session->{query});

if ($ticket eq "generate ticket")
{
#print "yopùlkooiezrzeiproizep";
$session->{'tickettype'} = "secadvisory";
$session->{'ticketsubject'} = $subject;
$session->{'ticketdescription'} = $description;
}
</%perl>

<%perl>
my $return = $m->comp('../internal/head-page.html',title=>'Security Advisory Management',session=>$session);
</%perl>

<body>
<hr noshade>

Manage source of Security Advisory : <br>
<table><tr><td><b>source-id</b></td> <td><b>url</b></td> <td><b>creation date</b></td> <td><b>comment</b></td>
<td><b>action</b></td></tr>

% foreach my $current_line (@results) {
% my $cpt=0; 
<tr>
% foreach my $entry (@{$current_line}) {

%if ($cpt==0) {
% my $source_id = $entry;
<form>
<td>
<% $entry %>
<input type=hidden name=source_id value="<% $entry %>">   
</td>
%}
%elsif ($cpt==1) 
%{
<td>
<input type=text name=source_url size=45 value="<% $entry %>">
</td>
%}
%elsif ($cpt==2)
%{
<td>
%my @data = split(/\./,$entry);
<% $data[0] %>
</td>
%}
%elsif ($cpt==3)
%{
<td>
<input type=text name=source_remark value="<% $entry %>">
</td>
<td>
<input type=submit name=action value="update">
<input type=submit name=action value="delete">
</form>
</td>
</tr>
%}
%else
%{

%}
%$cpt++;
%}

%}
<%doc>
<input type=submit name=action value="add">
<input type=submit name=action value="remove">
</form>
</%doc>
<form>
<tr>
<td>
<center>
<i>fixed</i>
</center>
</td>
<td>
<input type=text name=source_url size=45 value="">
</td>
<td>
<center>
<i>fixed</i>
</center>
</td>
<td>
<input type=text name=source_remark size=20 value="">
</td>
<td>
<input type=submit name=action value="add-new">
</form>
</td>
</tr>
</table>

Latest Security Advisory :<br> 

<%perl>
my $query = "select advisory_id, advisory_text, advisory_id_src from advisory order by advisory_modified desc limit 50 ";
my @resultoutput = $m->comp('../internal/sql-query-adv.ipfc',query=>$query);
</%perl>
<table>
<tr>
<td><b> advisory ID</b></td> <td> <b> advisory_text </b> </td> <td> <b> 
advisory source id </b> </td> <td><b>action</b></td></tr>
</tr>
% foreach my $current_line (@resultoutput) {
% my $cpt=0; 
<tr>
% foreach my $entry (@{$current_line}) {
%if ($cpt == 0) {
<td>
<% $entry %>
% $session->{'advid'} = $entry;
</td>
%}
%elsif ($cpt == 1) {
<td>
<% $entry %>
% $session->{'advcomment'} = $entry;
</td>
%}
%elsif ($cpt == 2) {
<td>
<% $entry %>
% $session->{'advsourceid'} = $entry;
</td>
<td> 
<%doc>
<form onsubmit="window.open('./create-ticket.html','ticket','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes')">
</%doc>
<form action="create-ticket.html">

% $session->{'tickettype'} = "secadvisory";

<input type=hidden name=subject value="IPFC : Secadvisory <% $session->{'advid'} %>">
<input type=hidden name=description value="Advisory from <% $session->{'advsourceid'} %>----<% $session->{'advcomment'} %> --- ">
<input type=submit value="generate ticket" name=ticket>
</form>
</td>
%}
%else {
%}
% $cpt++;
%}

%}
</table>
<%perl>
my $endbody = $m->comp('../internal/end-page.html');
</%perl>

