From: Stephen L Johnson Date: Wed, 29 Jan 2003 23:01:51 +0000 (+0000) Subject: FInal commit for Ack enhancements X-Git-Tag: spong-2_8_0-beta1~46 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f40d24a5929c48d891cba70a4dd9635df2dbd48;p=spong.git FInal commit for Ack enhancements --- diff --git a/src/www-spong-ack.pl b/src/www-spong-ack.pl index e4bf6d7..528224f 100755 --- a/src/www-spong-ack.pl +++ b/src/www-spong-ack.pl @@ -11,13 +11,16 @@ # History # (1) Created, pulled out of www-spong program (Ed 07-28-97) # -# $Id: www-spong-ack.pl,v 1.9 2001/04/17 02:58:12 sljohnson Exp $ +# $Id: www-spong-ack.pl,v 1.10 2003/01/29 23:01:51 sljohnson Exp $ + +use lib "@@LIBDIR@@"; use CGI; use Sys::Hostname; use Socket; use POSIX; use Time::Local; +use Spong::Host; # Load our configuration variables, including the user specified configuration # information (spong.conf, spong.hosts, and spong.groups files). @@ -40,7 +43,7 @@ $HOST =~ tr/A-Z/a-z/; $cmd = $ENV{'PATH_INFO'}; -if( $cmd =~ m!^/delete/(.+?)-(\w+)-(\d+)$! ) { &remove( $1, $2, $3 ); exit; } +if( $cmd =~ m!^/delete/(.+?)-(.+?)-(\d+)$! ) { &remove( $1, $2, $3 ); exit; } if( $cmd =~ m!^/help$! ) { &help(); exit; } if( $cmd =~ m!^/ack-doit$! ) { &ack_doit(); exit; } @@ -59,6 +62,7 @@ if( $cmd eq "" || $cmd eq "/" ) { &ack(); exit; } sub ack { my( $group, $service ) = @_; my( @hostlist ) = hostlist( $group ); + my $cgi = new CGI; my $host; $group = "all" unless $group; @@ -84,24 +88,58 @@ sub ack { if( $#hostlist >= 1 ) { print "\n"; } else { print "\n"; print "\n"; } - print "

Service: (The service you are acknowledging"; + print "

Service: (The services you are acknowledging"; print ", or \"all\" to signify all services)
\n"; - print ""; + if( $#hostlist >= 1 ) { + print ""; + } else { + my ($h) = new Spong::Host($hostlist[0]); + $service = 'all' unless defined $service; + + print "\n"; + } print "

Duration: (When service will be "; print "available, +5h, +2d, 18:00, 7/28/97)
\n"; + print "
\n"; + print " If custom:\n"; print "\n"; print "

Email: (Email address of the contact person"; print ")
\n"; - print "\n"; + + if (defined $cgi->remote_user() && defined $HUMANS{$cgi->remote_user()}{'email'}) { + print "remote_user()}{'email'} . "\">\n"; + } else { + print "\n"; + } print "

Message: (Description of the "; print "problem, details about the solution)
\n"; @@ -121,12 +159,20 @@ sub ack { sub ack_doit { my $cgi = new CGI; my $host = $cgi->param( 'host' ); - my $services = $cgi->param( 'services' ); + my (@serv) = $cgi->param( 'services' ); my $date = $cgi->param( 'duration' ); my $user = $cgi->param( 'user' ); my $message = $cgi->param( 'message' ); my $group = $cgi->param( 'group' ); + my ($services) = join(',', @serv); + $services =~ s/ //g; # Make sure there aren't any spaces... + + my $date = $cgi->param( 'duration' ); + if ($cgi->param('duration_select') ne 'custom') { + $date = $cgi->param('duration_select'); + } + if( $services eq "" ) { &error( "Service name not supplied." ); } if( $host eq "" ) { &error( "Host name not supplied." ); } if( $date eq "" ) { &error( "Duration not supplied." ); } @@ -142,6 +188,10 @@ sub ack_doit { if( $date =~ /^\+\s*(\d+)\s*([mhdw])$/ ) { $time = time() + ( $1 * $secs{$2} ); $ok = 1; } + # Check for a duration in the format HH:MM... + if( $date =~ /\b(\d+):(\d+)\b/ ) { + ( $hour, $min, $sec ) = ( $1, $2, 0 ); $ok = 1; } + # Check for a duration in the format HH:MM:SS... if( $date =~ /\b(\d+):(\d+):(\d+)\b/ ) { ( $hour, $min, $sec ) = ( $1, $2, $3 ); $ok = 1; } @@ -157,7 +207,7 @@ sub ack_doit { if( $ok ) { $time = timelocal( $sec, $min, $hour, $mday, $mon, $year) unless $time; } else { - &error( "Invalid duration specifier, view the " . + &error( "Invalid duration ($date) specifier, view the " . "Help screen for more " . "information on valid formats." ); } @@ -173,7 +223,13 @@ sub ack_doit { &header(); print "Acknowledge Problems - Success


\n"; print "Your acknowledgment has been successfully registered. Please "; - print "press here"; + + if ($group eq 'all' && $main::WWW_DEFAULT_VIEW eq 'GROUPS') { + print "press here"; + } else { + print "press here"; + } + print " to refresh the spong display.

\n"; } } @@ -194,7 +250,7 @@ sub remove { # their acknowledgment. if( $r ne "ok" ) { - &error( "Could not acknowledge $host/$service!

Message: $r"); + &error( "Could not remove acknowledgement for $host/$service!

Message: $r"); } else { # If we can tell where they came from, then just redirect them back, @@ -400,7 +456,7 @@ sub acklist { if( $results =~ /^\s*$/ ) { return "No current acknowledgments."; } my $str = ""; - foreach $ack ( split( /\n/, $results ) ) { + foreach $ack ( sort split( /\n/, $results ) ) { ($host, $service, $time) = (split( /:/, $ack )); my $id = "$host-$service-$time";