#! /usr/bin/perl # ticket - Infodrom Trouble Ticket System # Copyright (c) 1997-8 Martin Schulze # 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, USA. use CGI; use DBI; use Date::Calc qw(Delta_Days); push (@INC, "/etc/noc"); push (@INC, "/usr/lib/ticket"); require 'ticket-config.pl'; require 'ticket-db.pl'; require 'ticket.pl'; $progname = 'ticket'; $html_title = "

Trouble-Tickets

\n\n"; # Alle moeglichen Gruppen @ticket_groups = (); # Die Gruppen des Users @ticket_mygroups = (); %languages = ('ger', 'German', 'gbr', 'English', 'ita', 'Italian', 'ost', 'Plattdeutsch'); # left, middle, right @button_left = ('/','<','\\'); @button_right = ('/','>','\\'); %delimiter = ('Lynx','', 'Mosaic','   ', 'Mozilla',' ', 'Chimera',' . '); # ----------------------------------------------------------------------- # Sucht alle moeglichen User der angegebenen Gruppe(n) oder User heraus # sub get_users { my $user = shift; my $all = shift; my $groups = ""; my $first = 1; my %user = (); my $query; my $sth; my $rc; my @row; return if (!$user); if (substr($user,0,1) ne ":") { $groups = &user_groups($user) . &user_assoc($user); $groups =~ s/::/:/; if (!$groups) { &index_user($user); $groups = &user_groups($user); } } else { $groups = $user; } $groups =~ s/^:(.*):$/$1/; # Fetch all possible users and store them in our hashes # $query = "SELECT username,realname,email,groups,admin,maingroup FROM $ticket_table_user"; if (!$all) { $query .= " WHERE active = 1 AND ("; } else { $query .= " WHERE"; } foreach $group (split(/:/,$groups)) { $query .= " OR" if (!$first); $query .= " groups LIKE '%:$group:%'"; $first = 0; } $query .= " )" if (!$all); $query .= " ORDER BY realname"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0) { while (@row = $sth->fetchrow_array) { &index_user_hashes($row[0],$row[1],$row[2],$row[3],$row[4]); if ($row[0] && $row[1]) { $user{$row[0]} = sprintf("%s (%s)", $row[1], $row[5]); } } } } return %user; } # Sucht alle moeglichen Gruppen heraus # # ACHTUNG: Race-Condition: darf nicht 2x mit und ohne User aufgerufen # werden. # sub get_groups { my $groups = ""; my $assoc = ""; my @groups; my $group; my $where = ""; my $query; my $sth; my $rc; my @row; return @ticket_groups if ($#ticket_groups > -1); if ($_[0]) { $groups = &user_groups($_[0]); $groups =~ s/^:(.+):$/$1/; if ( exists($ticket_intern{'user'}) && exists($ticket_intern{'assoc'}) && $ticket_intern{'user'} eq $_[0]) { $assoc = $ticket_intern{'assoc'}; } else { $query = sprintf("SELECT assoc FROM $ticket_table_user WHERE username = '%s'", $_[0]); $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { $row[0] =~ s/^:(.+):$/$1/; $assoc = $row[0]; } } } $assoc =~ s/^:(.+):$/$1/; @groups = split (/:/, $assoc); foreach $group (@groups) { $groups .= ":" . $group if ($groups !~ /:$group:/); } @ticket_groups = split (/:/, $groups); } else { $query = "SELECT name FROM $ticket_table_groups"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0) { while (@row = $sth->fetchrow_array) { push (@ticket_groups, $row[0]); } } } } $query = "SELECT name,description FROM $ticket_table_groups WHERE name = '"; $query .= join ("' OR name = '", @ticket_groups); $query .= "'"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0) { while (@row = $sth->fetchrow_array) { $groupname{$row[0]} = $row[1]; } } } return @ticket_groups; } # Print some button, print them differently depending on the # browser. This routine could create some gif's on the fly if needed. # # [0] = 0, 1, 2 meaning top middle bottom # [1] = text # [1] = link sub print_button { my $type = $_[0]; my $text = $_[1]; my $link = $_[2]; if ($ticket_browser eq 'Lynx') { printf "%s%s%s \n", $link, $button_left[$type], $text, $button_right[$type]; } else { printf "%s \n", $link, $text; } } sub print_selection { my $is_lynx = ($ticket_browser eq 'Lynx'); print "
\n" if ($is_lynx); print "
\n"; printf "
", $ticket_html_base; print "\n" if ($_[0] eq "admin"); printf "\n", "/list/open", &gettext("Open Tickets"); print " ." if ($is_lynx); printf "\n", "/insert", &gettext("New Ticket"); print " ." if ($is_lynx); printf "\n", "/list/closed", &gettext("Closed Tickets"); print " ." if ($is_lynx); printf "\n
", "/list/all", &gettext("All Tickets"); printf "\n", "/queries", &gettext("Queries"); print " ." if ($is_lynx); printf "\n", "/admin", &gettext("Admin"); print " ." if ($is_lynx); printf "\n", "/info", &gettext("Info"); print " ." if ($is_lynx); printf "\n
\n", "/help", &gettext("Help"); print "
\n"; print "
\n"; } sub process_selection { my $path = $ENV{'PATH_INFO'}; $ENV{'PATH_INFO'} = ""; if (defined $cgi->param('button/list/open')) { $ENV{'PATH_INFO'} = "open"; &list(); } elsif (defined $cgi->param('button/list/closed')) { $ENV{'PATH_INFO'} = "closed"; &list(); } elsif (defined $cgi->param('button/list/all')) { $ENV{'PATH_INFO'} = "all"; &list(); } elsif (defined $cgi->param('button/insert')) { &insert(); } elsif (defined $cgi->param('button/queries')) { &queries(); } elsif (defined $cgi->param('button/info')) { &info(); } elsif (defined $cgi->param('button/help')) { &help(); } elsif (defined $cgi->param('button/admin')) { $ENV{'PATH_INFO'} = "edit" if (!$is_admin); &admin(); } elsif (defined $cgi->param('button/admin/newuser')) { $ENV{'PATH_INFO'} = "newuser"; &admin(); } elsif (defined $cgi->param('button/admin/newgroup')) { $ENV{'PATH_INFO'} = "newgroup"; &admin(); } elsif (defined $cgi->param('button/admin/newclass')) { $ENV{'PATH_INFO'} = "newclass"; &admin(); } } sub print_select_priority { my $prio = shift; print ""; } sub print_select_class { my $class = shift; my $query; my $sth; my $rc; my @row; $query = "SELECT name,description FROM $ticket_table_classes ORDER BY description"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0) { print ""; } } } sub print_select_anchor { my $groups = shift; my $anchor = shift; my $group; my $first = 1; my $query; my $sth; my $rc; my @row; $query = "SELECT nr,subject,class FROM $ticket_table WHERE "; if ($groups) { $groups =~ s/^:(.*):$/$1/; $query .= " ("; foreach $group (split(/:/,$groups)) { $query .= " OR" if (!$first); $query .= " groups LIKE '%:$group:%'"; $first = 0; } $query .= " OR" if (!$first); $query .= sprintf(" nr = %d )", $anchor); } else { $groups = &user_groups($ENV{'REMOTE_USER'}); if ($groups) { $query .= " ("; foreach $group (split(/:/,$groups)) { $query .= " OR" if (!$first); $query .= " groups LIKE '%:$group:%'"; $first = 0; } $query .= sprintf(" OR nr = %d )", $anchor); } else { $query .= sprintf (" insertp = '%s'", &user_email($ENV{'REMOTE_USER'})); } } $query .= " AND closing = '' ORDER BY subject"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0) { print ""; } else { print ""; } } else { print ""; } } sub textarea_size { my $size; if ($ticket_browser ne 'Lynx') { $size = $_[0] / 70; } else { $size = $_[0] / 50; } if ($ticket_browser eq 'Mozilla') { $size = ($size / 2); } return $size; } sub select_ticketuser { my $name = shift; my $selected; my %tockuser; my $user; if ($_[0]) { $selected = $_[0]; %ticketuser = &get_users($ENV{'REMOTE_USER'}) if (%ticketuser == ()); } else { %ticketuser = &get_users($ENV{'REMOTE_USER'},"all") if (%ticketuser == ()); } foreach $user (keys(%ticketuser)) { $tockuser{$ticketuser{$user}} = $user; } printf ""; } sub select_ticketgroups { my $name = $_[0]; my $selected = $_[1]; my $flag = $_[$#_]; my @ticketgroups; my @sortgroups; my $group; my $half; my $i; if ($flag =~ /nopublic/) { @ticketgroups = &get_groups(); } else { @ticketgroups = &get_groups($ENV{'REMOTE_USER'}); } push (@ticketgroups, '') if ($flag =~ /addempty/); push (@ticketgroups, 'Public') if ($flag !~ /nopublic/); @sortgroups = sort(@ticketgroups); if (($flag !~ /nomultiple/) && ($ticket_intern{'misc'} =~ /tablegroups/) && $ticket_browser_table) { $half = int(($#sortgroups+2)/2); print "\n"; $i=0;while ($i < $half) { print " \n"; printf " \n", $name, $sortgroups[$i], $selected =~ /:$sortgroups[$i]:/?' checked':'', &groupname($sortgroups[$i]); if ($half+$i <= ($#sortgroups+1)) { printf " \n", $name, $sortgroups[$half+$i], $selected =~ /:$sortgroups[$half+$i]:/?' checked':'', &groupname($sortgroups[$half+$i]); } else { printf " \n"; } print " \n"; $i++; } print "
%s%s
\n";
    } else {
	printf "";
    }
}

sub select_languages
{
    my $name = $_[0];
    my $selected = $_[1];

    printf "";
}

sub select_programs
{
    my $name = $_[0];
    my $selected = $_[1];

    printf "";
}

# [0] name
# [1] radio || checkbox
# [2] value
# [3] text
# [4] value= (opt)
sub print_box
{
    my $value = "j";
    $value = $_[4] if (length($_[4]));

    printf "%s", $_[3];
}

sub list_staff
{
    my $res = "";

    $res = $_[0] if ($_[0]);
    if ($_[1]) {
	$res .= " " if ($res);
	$res .= $_[1] 
    }
    if ($_[2]) {
	$res .= " " if ($res);
	$res .= $_[2] 
    }
    return $res;
}

sub print_actions
{
    my $nr = shift;
    my @arr = ();
    my $acc;
    my $admin = (defined $cgi->param('admin') && &is_admin($ENV{'REMOTE_USER'}))?1:undef;

    if ($admin) {
	$acc = 1;
    } else {
	$acc = &has_access($nr, $ENV{'REMOTE_USER'});
    }

    print  "
\n"; printf "
\n", $ticket_html_base; printf "\n", $nr; printf "\n", $nr; printf "\n" if ($admin); push (@arr, sprintf("", "/edit", sprintf(&gettext("Edit #%d"), $nr))) if ($acc); if ($_[0] ne "delete") { push (@arr,sprintf("", "/update", sprintf(&gettext("Followup #%d"), $nr))); push (@arr, sprintf("", "/close", sprintf(&gettext("Close #%d"), $nr))) if ($acc && !&has_open_children($nr)); } else { push (@arr, sprintf("", "/clone", sprintf(&gettext("Reopen #%d"), $nr))); push (@arr, sprintf("", "/delete", sprintf(&gettext("Delete #%d"), $nr))) if ($acc); } if ($ticket_browser eq 'Lynx') { print join (" .\n", @arr) . "\n"; } else { print join ("\n", @arr) . "\n"; } print "
\n"; print "
\n"; } sub process_actions { $ENV{'PATH_INFO'} = ""; if (defined $cgi->param('button/edit')) { &edit(); } elsif (defined $cgi->param('button/update')) { &insert(); } elsif (defined $cgi->param('button/close')) { &close(); } elsif (defined $cgi->param('button/clone')) { &clone(); } elsif (defined $cgi->param('button/delete')) { &delete(); } else { &print_first_banner(); } } sub list_children { my $nr = shift; my $type = shift; my $head = shift; my $query; my $sth; my $rc; my @row; $query = "SELECT nr,subject,class,staff0 FROM $ticket_table WHERE anchor = $nr"; $query .= " AND closing = ''" if ($type eq "open"); $query .= " AND closing <> ''" if ($type eq "closed"); $query .= " ORDER BY subject"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0) { printf "%s\n", $head if ($head); print "
\n"; while (@row = $sth->fetchrow_array) { printf "#%d %s (%s, %s)
\n", $row[0], $ticket_html_base, $row[0], $row[1], &get_class_descrip($row[2]), $row[3]; } print "

\n"; } } } sub print_banner { my $typ = 2; if ($ticket_browser_table && $ticket_intern{'misc'} =~ /tablelist/) { printf "\n\n", $ticket_browser; &eval_tickets($dbh,$_[0]); $typ = 1 if ($_[0] =~ /closing <> ''/); $typ = 0 if ($_[0] =~ /closing = ''/); &print_tickets(0,$typ, (defined $cgi->param('admin') && &is_admin($ENV{'REMOTE_USER'}))?"&admin=y":""); &print_selection(); } sub print_first_banner { my $where = ""; my $i; $where = "WHERE closing = '' AND ( groups LIKE '%:Public:%' "; $i=0; while ($i < $ticket_staff) { $where .= sprintf (" OR staff%d = '%s'", $i++, $ENV{'REMOTE_USER'}); } $where .= ") AND priority <> 3"; &print_banner($where); } sub list { my $tmp; my $i; my $expr; if (!length($ENV{'PATH_INFO'})) { &print_first_banner(); } elsif ($ENV{'PATH_INFO'} eq "open") { &print_banner("WHERE closing = ''"); } elsif ($ENV{'PATH_INFO'} eq "closed") { &print_banner("WHERE closing <> ''"); } elsif ($ENV{'PATH_INFO'} eq "all") { &print_banner(""); } elsif ($ENV{'PATH_INFO'} eq "priority") { &print_banner(sprintf ("WHERE closing = '' AND priority = %d", $cgi->param('priority'))); } elsif ($ENV{'PATH_INFO'} eq "class") { &print_banner(sprintf ("WHERE closing = '' AND class = '%s'", $cgi->param('class'))); } elsif ($ENV{'PATH_INFO'} eq "user") { $tmp = sprintf ("WHERE closing = '' AND ( insertp = '%s'", &user_email($cgi->param('user'))); $i=0; while ($i < $ticket_staff) { $tmp .= sprintf (" OR staff%d = '%s'", $i++, $cgi->param('user')); } $tmp .= " )"; &print_banner ($tmp); # &print_banner(sprintf ("WHERE insertp = '%s' OR staff0 = '%s' OR staff1 = '%s' OR staff2 = '%s' AND closing = ''", # &user_email($cgi->param('user')), # $cgi->param('user'), $cgi->param('user'), $cgi->param('user'))); } elsif ($ENV{'PATH_INFO'} eq "group") { &print_banner(sprintf ("WHERE closing = '' AND groups LIKE '%%:%s:%%'", $cgi->param('group'))); } elsif ($ENV{'PATH_INFO'} eq "subject") { &print_banner(sprintf ("WHERE subject $ticket_clike '%s'", &sql_clike($cgi->param('keyword')))); } elsif ($ENV{'PATH_INFO'} eq "search") { $expr = &sql_clike($cgi->param('keyword')); &print_banner(sprintf ("WHERE subject $ticket_clike '%s' OR body $ticket_clike '%s' OR closing $ticket_clike '%s'", $expr, $expr, $expr)); } elsif ($ENV{'PATH_INFO'} eq "insertrange") { $tmp = ""; if (length($cgi->param('insertdfrom'))) { $tmp = sprintf ("insertd >= '%s'", &date_to_string($cgi->param('insertdfrom'))); } if (length($cgi->param('insertdto'))) { $tmp .= " AND " if (length($tmp)); $tmp .= sprintf ("insertd <= '%s'", &date_to_string($cgi->param('insertdto'))); } $tmp = "WHERE " . $tmp if (length($tmp)); &print_banner($tmp); } elsif ($ENV{'PATH_INFO'} eq "seireuq") { print "

Combined query

\n\n"; &print_banner($tmp); } else { &print_banner("WHERE closing = ''"); } } sub display_ticket { my $nr = shift; my $actions = shift; my $query; my $sth; my $rc; my @row; my @staff; $query = sprintf("SELECT * FROM $ticket_table WHERE nr = %d",$nr); $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { if ((defined $cgi->param('admin') && &is_admin($ENV{'REMOTE_USER'})) || &is_visible($row[4+$ticket_staff], $row[10+$ticket_staff])) { printf "

Ticket #%d (%s)

\n\n", $row[0], $row[1]; print "
\n";
		printf "Subject : %s\n", &de_msql($row[1]);
		printf "Class ..: %s\n", &get_class_descrip($row[2]);
		printf "Priority: %s\n", $ticket_priorities[$row[3]];
		$i=0; @staff=();
		while ($i < $ticket_staff) {
		    push (@staff, $row[4+$i]) if ($row[4+$i]);
		    $i++;
		}
		printf "Staff ..: %s\n", join (", ", &uniq_user_realname(@staff));
		$row[4+$ticket_staff] =~ s/^:(.*):$/$1/;
		$row[4+$ticket_staff] =~ s/:/, /g;
		printf "Gruppen : %s\n", $row[4+$ticket_staff] if (length($row[4+$ticket_staff]));
		printf "Auftrag : #%d %s\n",
		    $row[5+$ticket_staff], $ticket_html_base, $row[5+$ticket_staff],
		    &get_subject($row[5+$ticket_staff]) if ($row[5+$ticket_staff]);
		printf "Fixdate : %s\n", &string_to_date($row[8+$ticket_staff]) if (length($row[8+$ticket_staff]));
		printf "Inserted: %s by %s\n", &string_to_date($row[9+$ticket_staff]),
		    &email_realname($row[10+$ticket_staff]);
		printf "Closed .: %s by %s\n", &string_to_date($row[11+$ticket_staff]),
		    &email_realname($row[12+$ticket_staff]) if (length($row[11+$ticket_staff]));
		printf "Modified: %s by %s\n", &string_to_date($row[16+$ticket_staff]),
		    &email_realname($row[17+$ticket_staff]);
		printf "Time ...: %d min\n", $row[13+$ticket_staff]
		    if ($row[13+$ticket_staff] && $row[13+$ticket_staff] > 0);
		print  "
\n"; print "Text:\n"; if ($row[6+$ticket_staff] eq "j") { print "
\n";
		} else {
		    print  "
\n"; } printf "%s\n", &de_msql($row[7+$ticket_staff]); if ($row[6+$ticket_staff] eq "j") { print "
\n"; } else { print "

\n"; } if ($row[15+$ticket_staff]) { printf "Closing (%s):\n", &string_to_date($row[11+$ticket_staff]); if ($row[14+$ticket_staff] eq "j") { print "

\n";
		    } else {
			print  "
\n"; } printf "%s\n", &de_msql($row[15+$ticket_staff]); if ($row[14+$ticket_staff] eq "j") { print "
\n"; } else { print "

\n"; } } &list_children($row[0], "open", "" . &gettext("Open children") . ":"); &list_children($row[0], "closed", "" . &gettext("Closed children") . ":"); if ($actions) { if (length($row[15+$ticket_staff])) { &print_actions($row[0], "delete"); } else { &print_actions($row[0]); } } } else { print "

" . sprintf (&gettext("Access to ticket #%d denied!"), $nr) . "

\n\n"; } } else { print "

" . sprintf (&gettext("The ticket #%d does not exist!"), $nr) . "

\n\n"; &print_selection() if ($action); } } else { &error_query($query); } } sub group_in_use { my $query; my $sth; my $rc; my @row; $query = sprintf("SELECT user FROM $ticket_table_user WHERE groups LIKE ':%s:' OR group = '%s'", $_[0],$_[0]); $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { return 1; } } return 0; } sub listone { my $nr = $cgi->param('nr'); if ($nr) { &display_ticket($nr, 1); } else { print "

" . sprintf (&gettext("The field '%s' must not be empty!"), &gettext("Nr.")) . "

\n\n"; } } sub edit { my $nr = $cgi->param('nr'); my $i; my $shortdate = &shortdate(); my $fieldlength, $lines; my $query; my $sth; my $rc; my @row; my $admin = (defined $cgi->param('admin') && &is_admin($ENV{'REMOTE_USER'}))?1:undef; if ($admin || &has_access($nr,$ENV{'REMOTE_USER'})) { $query = "SELECT * FROM $ticket_table WHERE nr = $nr"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { printf "

" . sprintf(&gettext("Edit ticket #%d"), $nr) . "

\n\n"; printf "
\n", $ticket_html_base; printf "\n", $nr; print "\n" if ($admin); print "
\n";
		printf "Subject : \n", &html_quote($row[1]);
		print  "Klasse  : "; &print_select_class($row[2]);print "\n";
		print  "Priority: "; &print_select_priority($row[3]);print "\n";
		printf "Staff   : ";
		$i=0;while ($i < $ticket_staff) {
		    $staff = sprintf ("staff%d", $i);
		    &select_ticketuser($staff,$row[4+$i]);
		    print "\n          " if ($i % 2);
		    $i++;
		}
		print "\n" if ($i % 2);
		printf "Gruppen : ";
		&select_ticketgroups("groups",$row[4+$ticket_staff]);
		print  "Auftrag : "; &print_select_anchor($row[4+$ticket_staff],$row[5+$ticket_staff]);print "\n";
		# 11 - insertd
		printf "\n", $row[9+$ticket_staff];
		printf "\n", $row[10+$ticket_staff];
		printf &gettext("Inserted at %s by %s") . "\n", &string_to_date($row[9+$ticket_staff]),
		    &email_realname($row[10+$ticket_staff]);
		# 14 - 18: closed, closep, closetime, closingpre, closing
		if (length($row[15+$ticket_staff])) {
		    printf &gettext("Closed at %s by %s") . "\n", &string_to_date($row[11+$ticket_staff]),
		        &email_realname($row[12+$ticket_staff]);
		}
		printf &gettext("Last modified at %s by %s") . "
\n", &string_to_date($row[16+$ticket_staff]), &email_realname($row[17+$ticket_staff]); printf "Text : (max. %d) Format <pre>: ", $ticket_length{'body'}; &print_box ("bodypre", "radio", $row[6+$ticket_staff], "ja ", "j"); &print_box ("bodypre", "radio", $row[6+$ticket_staff], "nein", "n"); print "\n" if ($ticket_browser ne 'Lynx'); $text = $row[7+$ticket_staff]; $text =~ s/(\r?\n)+$//g; $text =~ s/(

\r?\n?)+$//; $fieldlength = &textarea_size($ticket_length{'body'}); if ($ticket_browser eq 'Lynx') { $lines = $text =~ tr/\n//; if (($lines) + 3 > $fieldlength) { $fieldlength = $ticket_length{'body'} / (length($text) / $lines) + 5; } } printf "

\n", $fieldlength, $text, $shortdate, $ENV{'REMOTE_USER'}; printf "Fixdate : \n", &string_to_date($row[8+$ticket_staff]); # 14 - 18: closed, closep, closetime, closingpre, closing if (length($row[15+$ticket_staff])) { printf "Time : min\n\n", $row[13+$ticket_staff]; printf "Closing (%s): (max. %d) Format <pre>: ", &string_to_date($row[11+$ticket_staff]), $ticket_length{'closing'}; &print_box ("closingpre", "radio", $row[14+$ticket_staff], "ja ", "j"); &print_box ("closingpre", "radio", $row[14+$ticket_staff], "nein", "n"); print "\n" if ($ticket_browser ne 'Lynx'); $text = $row[15+$ticket_staff]; $text =~ s/(\r?\n)+$//g; $text =~ s/(

\r?\n?)+$//; $fieldlength = &textarea_size($ticket_length{'closing'}); if ($ticket_browser eq 'Lynx') { $lines = $text =~ tr/\n//; if (($lines) + 3 > $fieldlength) { $fieldlength = $ticket_length{'closing'} / (length($text) / $lines) + 5; } } printf "

\n", $fieldlength, $text, $shortdate, $ENV{'REMOTE_USER'}; } print "

\n"; &list_children($row[0], "open", "" . &gettext("Open children") . ":"); &list_children($row[0], "closed", "" . &gettext("Closed children") . ":"); printf "
", &gettext("Update"); print " . " if ($ticket_browser eq 'Lynx'); printf "
\n", &gettext("Reset"); print "
\n"; } else { &error_query($query); } } else { &error_query($query); } } else { printf &gettext("Access to ticket #%d denied!"), $nr; } } sub insert { my @addrs; my $class = "Misc"; my $priority = 2; my @groups; my $groups; my $subject; my $staff; my @staff; my $i; my $query; my $sth; my $rc; my @row; my $val; if (!length($cgi->param('subject'))) { if (!$cgi->param('anchor') || $cgi->param('anchor') == 0) { print "

" . &gettext("Insert new ticket") . "

\n\n"; $groups = &user_primary($ENV{'REMOTE_USER'}); } else { $query = "SELECT class,priority"; $i=0; while ($i < $ticket_staff) { $query .= sprintf (",staff%d", $i); $i++; } $query .= ",groups,subject FROM $ticket_table WHERE nr = " . $cgi->param('anchor'); $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { $class = $row[0]; $priority = $row[1]; $i=0; @staff=();while ($i < $ticket_staff) { push (@staff, $row[2+$i++]); } $groups = $row[2+$ticket_staff]; $subject = $row[3+$ticket_staff]; } } printf "

" . sprintf(&gettext("Followup ticket #%d (%s)"), $cgi->param('anchor'), $subject) . "

\n\n"; $subject = substr($subject, 0, 20); } printf "
\n", $ticket_html_base; print "
\n";
	printf "Subject : \n", &html_quote($subject);
	print  "Klasse  : "; &print_select_class($class);print "\n";
	print  "Priority: "; &print_select_priority($priority);print "\n";
	printf "Staff   : ";
	$i=0;while ($i < $ticket_staff) {
	    $staff = sprintf ("staff%d", $i);
	    $val=$row[2+$i];
	    $val='none' if (!$val);
	    &select_ticketuser($staff,$val);
	    print "\n          " if ($i % 2);
	    $i++;
	}
	print "\n" if ($i % 2);
	print  "Gruppen : ";
	&select_ticketgroups("groups",":".$groups.":");
        print "\n";
	printf "", $cgi->param('anchor');
	printf "Text    : (max. %d) Format <pre>: ", $ticket_length{'body'};
	&print_box ("bodypre", "radio", "n", "ja ", "j");
	&print_box ("bodypre", "radio", "n", "nein", "n");
	print "\n" if ($ticket_browser ne 'Lynx');
	printf "

\n", &textarea_size($ticket_length{'body'}); print "Fixdate :

"; print "

\n"; printf "
", &gettext("Insert"); print " . " if ($ticket_browser eq 'Lynx'); printf "
\n", &gettext("Reset"); print "
\n\n"; } else { @groups = $cgi->param('groups'); $i=0; @staff=();while ($i < $ticket_staff) { $staff = sprintf ("staff%d", $i); push (@staff, $cgi->param($staff)) if (length($cgi->param($staff))); $i++; } # Args: (user,subject,class,priority,@staff,groups,anchor,bodypre,body,fixdate)) { $nr = &ticket_insert($ENV{'REMOTE_USER'}, $cgi->param('subject'), $cgi->param('class'), $cgi->param('priority'),\@staff,join (" ",@groups),$cgi->param('anchor'), $cgi->param('bodypre'),$cgi->param('body'),$cgi->param('fixdate')); if ($nr) { printf "

" . sprintf(&gettext("Ticket #%s (%s) opened"), sprintf("%d",$ticket_html_base,$nr,$nr), $cgi->param('subject')) . "

\n"; &print_selection(); } else { &print_selection(); } } } sub close { my $nr = $cgi->param('nr'); my @addrs; my @staff; my $user; my $i; my $query; my $sth; my $rc; my @row; my $url; my $admin = (defined $cgi->param('admin') && &is_admin($ENV{'REMOTE_USER'}))?1:undef; my ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst); my ($my_year,$my_mon,$my_day,$ti_year,$ti_mon,$ti_day); if ($admin || &has_access($nr,$ENV{'REMOTE_USER'})) { if (!length($nr)) { &print_banner("WHERE closing = ''"); } elsif (!length($cgi->param('closing'))) { if (ticket_is_closed($nr)) { edit (); return; } # print "

" . sprintf(&gettext("Close ticket #%d (%s) "), $nr, &get_subject($nr)) . "

\n\n"; if (!&has_open_children($nr)) { &display_ticket($nr,0); printf "
\n", $ticket_html_base; print "\n" if ($admin); printf "\n", $nr; print "
\n";
		print  "Time   :  min\n\n";
		printf "Closing: (max. %d): Format <pre>: ", $ticket_length{'closing'};
		&print_box ("closingpre", "radio", "n", "ja ", "j");
		&print_box ("closingpre", "radio", "n", "nein", "n");
		print "\n" if ($ticket_browser ne 'Lynx');
		printf "

\n", &textarea_size($ticket_length{'closing'}); print "

\n"; printf "
", &gettext("Close"); print " . " if ($ticket_browser eq 'Lynx'); printf "
\n", &gettext("Reset"); print "
\n"; } else { # Dieses Ticket kann nicht geschlossen werden print "

" . &gettext("This ticket cannot be closed!") . "

\n\n"; print &gettext("There are still open tickets:") . "
\n"; &list_children($nr, "open"); &print_actions($nr); } } else { if (ticket_is_closed($nr)) { print "

" . sprintf (&gettext("Ticket#%d is already closed!"),$nr) . "

"; return; } if (length($cgi->param('closing')) > ($ticket_length{'closing'}-1)) { print "

" . sprintf (&gettext("The field '%s' must not contain more than %d characters!"), "Closing", $ticket_length{'closing'}) . "

\n\n"; return; } # printf "

" . sprintf (&gettext("Close ticket #%d (%s) "), $nr, &get_subject($nr)) . "

\n\n"; if (&has_open_children($nr)) { print "

" . &gettext("This ticket cannot be closed!") . "

\n\n"; print &gettext("There are still open tickets:") . "
\n"; &list_children($nr, "open"); &print_actions($nr); } else { $user = &user_email($ENV{'REMOTE_USER'}); $date = &stringdate(); $query = sprintf ("UPDATE $ticket_table SET closetime=%d,closingpre='%s',closing=%s,closed='%s',closep='%s'" . ",changed='%s',changep='%s'", $cgi->param('closetime'),$cgi->param('closingpre'), $dbh->quote(substr(&prepare_text($cgi->param('closing')),0,$ticket_length{'closing'}-1)), $date, $user, $date, $user) . " WHERE nr = $nr"; $sth = $dbh->do($query); if ($sth) { print "

" . sprintf(&gettext("Ticket #%s is closed."), sprintf("%d",$ticket_html_base,$nr,$nr)) . "

\n"; $query = "SELECT insertp,subject,class,priority,groups,anchor,body,insertd"; $i=0; while ($i < $ticket_staff) { $query .= sprintf(",staff%d",$i++); } $query .= " FROM $ticket_table WHERE nr = $nr"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { $i=0; @staff=(); while ($i < $ticket_staff) { push (@staff, $row[8+$i]) if ($row[8+$i] && length($row[8+$i])); $i++; } } # We send the mail from a cloned process in # order to give a quick response to the web # interface. # $| = 1; print ""; $| = 0; if (&forkme() == 0) { # The DBD subsystem reports an error, but all queries from before are finished already. $dbh->disconnect; $dbh = &noc_connect(); open (MAIL, "|$ticket_sendmailcmd"); push (@staff, $ENV{'REMOTE_USER'}); printf MAIL "To: %s\n", join(", ", &uniq_user_email(@staff)); pop (@staff); printf MAIL "From: %s\n", $ticket_from; printf MAIL "Bcc: %s\n", $ticket_bcc if ($ticket_bcc); printf MAIL "Subject: [CLOSE] #%d: %s\n", $nr, &de_html($row[1]); print MAIL "Precedence: junk\n"; printf MAIL "X-Mailer: ticket %s\n", $ticket_version; $url = $ticket_html_proto . "://" . $ENV{'SERVER_NAME'}; $url .= ":" . $ENV{'SERVER_PORT'} if ($ENV{'SERVER_PORT'} != 80); $url .= $ticket_html_base . "/listone?nr=" . $nr; print MAIL "\n"; printf MAIL &gettext("%s has closed the following ticket on %s:") . "\n\n", &user_realname($ENV{'REMOTE_USER'}), &string_to_date($date); printf MAIL "Ticket ....: #%d\n", $nr; printf MAIL "Subject ...: %s\n", &de_html($row[1]); printf MAIL "Klasse ....: %s\n", &get_class_descrip($row[2]); printf MAIL "Prioritaet : %s\n", $ticket_priorities[$row[3]]; printf MAIL "Mitarbeiter: %s\n", join (", ", &uniq_user_realname(@staff)); $row[4] =~ s/^:(.*):$/$1/; $row[4] =~ s/:/, /g; printf MAIL "Gruppen ...: %s\n", $row[4] if (length($row[4])); printf MAIL "Auftrag ...: #%d (%s)\n", $row[5], &get_subject($row[5]) if ($row[5]); ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst) = localtime(time); $my_year = $date_year+1900; $my_mon = $date_mon+1; $my_day = $date_mday; $ti_year = substr($row[7],0,4); $ti_mon = substr($row[7],4,2); $ti_day = substr($row[7],6,2); printf MAIL "Lifetime ..: %d day(s)\n", Delta_Days($ti_year,$ti_mon,$ti_day,$my_year,$my_mon,$my_day); printf MAIL "Time ......: %d min\n", $cgi->param('closetime'); printf MAIL "URL .......: %s\n", $url; printf MAIL "\n%s\n", &de_html($row[6]); print MAIL "\n" . &gettext("The following reason was given:") . "\n\n"; printf MAIL "%s\n\n", &de_html($cgi->param('closing')); printf MAIL "\n%s,\n\n\t%s\n", &gettext("Best regards"), &gettext("Your Ticket System"); print MAIL $ticket_signature; close (MAIL); exit (0); } } } else { &error_query($query); } &print_selection(); } } } else { printf &gettext("Access to ticket #%d denied!"), $nr; } } sub update { my $nr = $cgi->param('nr'); my $user = &user_email($ENV{'REMOTE_USER'}); my @groups = $cgi->param('groups'); my $groups; my $subject; my $body; my $closing; my @staff; my @staff; my $x; my $i; my $query; my $sth; my $rc; my @row; my $url; my $stamp = undef; my ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst); my ($my_year,$my_mon,$my_day,$ti_year,$ti_mon,$ti_day); my $admin = (defined $cgi->param('admin') && &is_admin($ENV{'REMOTE_USER'}))?1:undef; printf "

" . sprintf(&gettext("Edit ticket #%d (%s)"), $nr, &get_subject($nr)) . "

\n\n"; if (!$admin && !&has_access($nr,$ENV{'REMOTE_USER'})) { printf &gettext("Access to ticket #%d denied!"), $nr; return; } $subject = $dbh->quote(substr($cgi->param('subject'), 0, $ticket_length{'subject'}-1)); $body = $cgi->param('body'); $body =~ s/\r//g; # Netscape on Windows inserts ^M if (substr($body, length($body)-1, 1) eq "]") { $stamp = sprintf ("[%s/%s]", &shortdate(), $ENV{'REMOTE_USER'}); $body = substr($body,0,length($body)-length($stamp)-5) if (substr($body, length($body)-length($stamp)-5, 4) eq "
"); } $sqlbody = $dbh->quote(substr(&prepare_text($body),0,$ticket_length{'body'}-1)); $i=0; @staff = (); while ($i < $ticket_staff) { $x = sprintf ("staff%d", $i++); push (@staff, $cgi->param($x)) if ($cgi->param($x) && length($cgi->param($x))); } if (!&ticket_is_valid("html",length($subject)-2,\@staff,join (" ",@groups),length($sqlbody)-2)) { &print_selection(); } else { $groups = ":" . join (":", @groups) . ":"; if (!length($cgi->param('closing'))) { $query = sprintf ("UPDATE $ticket_table SET subject=%s,class='%s',anchor=%d,priority=%d," . "groups='%s',bodypre='%s',body=%s,fixdate='%s',changed='%s',changep='%s'", $subject, $cgi->param('class'), $cgi->param('anchor'), $cgi->param('priority'), $groups, $cgi->param('bodypre'), $sqlbody, &date_to_string($cgi->param('fixdate')), &stringdate(), $user); } else { $closing = $cgi->param('closing'); $closing =~ s/\r//g; # Netscape on Windows inserts ^M if (substr($closing, length($closing)-1, 1) eq "]") { $stamp = sprintf ("[%s/%s]", &shortdate(), $ENV{'REMOTE_USER'}) if (!$stamp); $closing = substr($closing,0,length($closing)-length($stamp)-5) if (substr($closing, length($closing)-length($stamp)-5, 4) eq "
"); } $query = sprintf ("UPDATE $ticket_table SET subject=%s,class='%s',anchor=%d,priority=%d," . "groups='%s',bodypre='%s',body=%s," . "closetime=%d,closingpre='%s',closing=%s," . "fixdate='%s',changed='%s',changep='%s'", $subject, $cgi->param('class'), $cgi->param('anchor'), $cgi->param('priority'), $groups, $cgi->param('bodypre'), $sqlbody, $cgi->param('closetime'), $cgi->param('closingpre'), $dbh->quote(substr(&prepare_text($closing),0,$ticket_length{'closing'}-1)), &date_to_string($cgi->param('fixdate')), &stringdate(), $user); } $i=0; while ($i < $ticket_staff) { $query .= sprintf(",staff%d='%s'", $i, $staff[$i]); $i++; } $query .= " WHERE nr = $nr"; $sth = $dbh->do($query); if ($sth) { printf "

" . sprintf(&gettext("Ticket #%s (%s) was updated."), sprintf("%d",$ticket_html_base,$nr,$nr), &get_subject($nr)) . "

\n"; # We send the mail from a cloned process in # order to give a quick response to the web # interface. # $| = 1; print ""; $| = 0; if (&forkme() == 0) { $dbh->disconnect; $dbh = &noc_connect(); open (MAIL, "|$ticket_sendmailcmd"); push (@staff, $ENV{'REMOTE_USER'}); printf MAIL "To: %s\n", join(", ", &uniq_user_email(@staff)); pop (@staff); printf MAIL "From: %s\n", $ticket_from; printf MAIL "Bcc: %s\n", $ticket_bcc if ($ticket_bcc); printf MAIL "Subject: [UPDATE] #%d: %s\n", $nr, &de_html($cgi->param('subject')); print MAIL "Precedence: junk\n"; printf MAIL "X-Mailer: ticket %s\n", $ticket_version; print MAIL "\n"; printf MAIL &gettext("%s has updated the following ticket on %s:") . "\n\n", &user_realname($ENV{'REMOTE_USER'}), &string_to_date(&stringdate()); printf MAIL "Ticket ....: #%d\n", $nr; printf MAIL "Subject ...: %s\n", &de_html($cgi->param('subject')); printf MAIL "Klasse ....: %s\n", &get_class_descrip($cgi->param('class')); printf MAIL "Prioritaet : %s\n", $ticket_priorities[$cgi->param('priority')]; printf MAIL "Mitarbeiter: %s\n", join(", ", &uniq_user_realname(@staff)); printf MAIL "Gruppen ...: %s\n", join (", ", @groups) if ($#groups > -1); printf MAIL "Auftrag ...: #%d (%s)\n", $cgi->param('anchor'), &get_subject($cgi->param('anchor')) if ($cgi->param('anchor')); ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst) = localtime(time); $my_year = $date_year+1900; $my_mon = $date_mon+1; $my_day = $date_mday; $ti_year = substr($cgi->param('insertd'),0,4); $ti_mon = substr($cgi->param('insertd'),4,2); $ti_day = substr($cgi->param('insertd'),6,2); printf MAIL "Lifetime ..: %d day(s)\n", Delta_Days($ti_year,$ti_mon,$ti_day,$my_year,$my_mon,$my_day); printf MAIL "Inserted ..: %s by %s\n", string_to_date($cgi->param('insertd')), &email_realname($cgi->param('insertp')); $url = $ticket_html_proto . "://" . $ENV{'SERVER_NAME'}; $url .= ":" . $ENV{'SERVER_PORT'} if ($ENV{'SERVER_PORT'} != 80); $url .= $ticket_html_base . "/listone?nr=" . $nr; printf MAIL "URL .......: %s\n", $url; printf MAIL "\n%s\n", &de_html($body); if (length($cgi->param('closing'))) { print MAIL &gettext("This ticket is already closed:") . "\n"; printf MAIL "%s\n", &de_html($cgi->param('closing')); } else { print MAIL sprintf ("\n" . &gettext("%s was set as fixdate."), $cgi->param('fixdate')) . "\n\n" if (length($cgi->param('fixdate'))); } printf MAIL "\n%s,\n\n\t%s\n", &gettext("Best regards"), &gettext("Your Ticket System"); print MAIL $ticket_signature; close (MAIL); exit (0); } &print_selection(); } else { &error_query($query); } } } sub delete { my $nr = $cgi->param('nr'); my $subject = &get_subject($nr); my @staff; my $i; my $query; my $sth; my $rc; my @row; print "

" . sprintf (&gettext("Remove ticket #%d (%s) "), $nr, $subject) . "

\n\n"; if ((defined $cgi->param('admin') && &is_admin($ENV{'REMOTE_USER'})) || &has_access($nr,$ENV{'REMOTE_USER'})) { $query = "SELECT insertp"; $i=0; while ($i < $ticket_staff) { $query .= sprintf(",staff%d",$i++); } $query .= ",closing FROM $ticket_table WHERE nr = $nr"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { if (length($row[1+$ticket_staff])) { $query = "DELETE FROM $ticket_table WHERE nr = $nr"; $sth = $dbh->do($query); print "

" . sprintf(&gettext("Ticket #%d has been removed from the database"), $nr, $subject) . "

\n"; $date = &stringdate(); $i=0; @staff=(); while ($i < $ticket_staff) { push (@staff, $row[1+$i]) if ($row[1+$i]); $i++; } # We send the mail from a cloned process in # order to give a quick response to the web # interface. # $| = 1; print ""; $| = 0; if (&forkme(1) == 0) { $dbh->disconnect; $dbh = &noc_connect(); open (MAIL, "|$ticket_sendmailcmd"); push (@staff, $ENV{'REMOTE_USER'}); printf MAIL "To: %s\n", join(", ", &uniq_user_email(@staff)); pop (@staff); printf MAIL "From: %s\n", $ticket_from; printf MAIL "Bcc: %s\n", $ticket_bcc if ($ticket_bcc); printf MAIL "Subject: [DELETE] #%d: %s\n", $nr, &de_html($subject); print MAIL "Precedence: junk\n"; printf MAIL "X-Mailer: ticket %s\n", $ticket_version; printf MAIL &gettext("%s has removed the following ticket from the database on %s:") . "\n\n", &user_realname($ENV{'REMOTE_USER'}), &string_to_date(&stringdate()); printf MAIL "Ticket ....: #%d\n", $nr; printf MAIL "Subject ...: %s\n", &de_html($subject); printf MAIL "Inserted ..: %s\n", $row[0]; printf MAIL "Mitarbeiter: %s\n", join (", ", &uniq_user_realname(@staff)); printf MAIL "\n%s,\n\n\t%s\n", &gettext("Best regards"), &gettext("Your Ticket System"); print MAIL $ticket_signature; close (MAIL); exit (0); } &print_selection(); } else { printf &gettext("This ticket is not yet closed.") . "\n"; } } else { &error_query($query); } } else { &error_query($query); } } else { printf &gettext("Access to ticket #%d denied!"), $nr; } } sub clone { my $nr = $cgi->param('nr'); my $subject = &get_subject($nr); my @staff; my $i; my $query; my $sth; my $rc; my @row; my $newnr; my $body; my $groups; print "

" . sprintf (&gettext("Reopen ticket #%d (%s) "), $nr, $subject) . "

\n\n"; $query = "SELECT subject,class,priority,groups,bodypre,body"; $i=0; while ($i < $ticket_staff) { $query .= sprintf(",staff%d",$i++); } $query .= " FROM $ticket_table WHERE nr = $nr"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { $i=0; @staff=(); while ($i < $ticket_staff) { push (@staff, $row[6+$i]) if ($row[6+$i]); $i++; } $body = $row[5]; $body =~ s:\[([^/\]]*)/([^\]]*)\].*::; $groups = $row[3]; $groups =~ s/^:(.*):$/\1/; $newnr = &ticket_insert($ENV{'REMOTE_USER'}, $row[0], $row[1], $row[2], \@staff, $groups, 0, $row[4], $body,''); if ($newnr) { $query = "UPDATE $ticket_table SET anchor=$newnr WHERE nr = $nr"; $sth = $dbh->do($query); printf "

" . sprintf(&gettext("Ticket #%s (%s) opened"), sprintf("%d",$ticket_html_base,$newnr,$newnr), $subject) . "

\n"; &print_selection(); } else { &error_query($query); } } else { &error_query($query); } } else { &error_query($query); } } sub admin { my $tmp; my @progs; my @assoc; my $grouplist; my $group; my $user; my $query; my $sth; my $rc; my @row; my @misc; if ($cgi->param('user')) { $user = $cgi->param('user'); } else { $user = $ENV{'REMOTE_USER'} } if ((!$is_admin) && !($user eq $ENV{'REMOTE_USER'} && (($ENV{'PATH_INFO'} eq "edit") || ($ENV{'PATH_INFO'} eq "update")))) { print "

" . &gettext("Access to admin pages denied!") . "

\n\n"; print "

" . &gettext("Ask the maintainer for permission.") . "

\n\n"; &print_selection(); return; } if (!length($ENV{'PATH_INFO'})) { printf "
\n", $ticket_html_base; $query = "SELECT realname,username,email,groups,active FROM $ticket_table_user ORDER by realname"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0) { print "\n

" . &gettext("List of users") . "

\n\n"; if ($ticket_browser_table) { print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "\n"; } else { print "
    \n"; } while (@row = $sth->fetchrow_array) { $row[3] =~ s/^:(.*):$/$1/; $row[3] =~ s/:/ /g; if ($ticket_browser_table) { print "
\n"; printf " \n", $ticket_html_base,$row[1], $row[0]; printf " \n", $row[1]; printf " \n", $row[2], $row[2]; printf " \n", $row[3]; print "\n"; } else { if ($ticket_browser eq 'Lynx') { printf "
  • %s (%s, %s) [%s%s]", $ticket_html_base, $row[1], $row[0], $row[1], $row[2], $row[3], (", disabled","")[$row[4]]; } else { printf "
  • %s (%s, %s) [%s%s]", $ticket_html_base, $row[1], $row[0], $row[1], $row[2], $row[2], $row[3], (", disabled","")[$row[4]]; } print "\n"; } } if ($ticket_browser_table) { print "
  • RealnameUserEmailGroups
    %s%s%s%s
    \n\n"; } else { print "\n\n"; } } } printf "

    \n", &gettext("New user"); $query = "SELECT name,description FROM $ticket_table_groups ORDER by name"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0) { print "\n

    " . &gettext("List of groups") . "

    \n\n"; if ($ticket_browser_table) { print "\n"; print "\n"; print " \n"; print " \n"; print "\n"; } else { print "
      \n"; } while (@row = $sth->fetchrow_array) { if ($ticket_browser_table) { print "
    \n"; printf " \n", $ticket_html_base,$row[0], $row[0]; printf " \n", $row[1]; print "\n"; } else { printf "
  • %s (%s)\n", $ticket_html_base, $row[0], $row[0], $row[1]; } } if ($ticket_browser_table) { print "
  • NameDescription
    %s%s
    \n\n"; } else { print "\n\n"; } } } printf "

    \n", &gettext("New group"); $query = "SELECT name,description FROM $ticket_table_classes ORDER by name"; $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 ) { print "\n

    " . &gettext("List of classes") . "

    \n\n"; if ($ticket_browser_table) { print "\n"; print "\n"; print " \n"; print " \n"; print "\n"; } else { print "
      \n"; } while (@row = $sth->fetchrow_array) { if ($ticket_browser_table) { print "
    \n"; printf " \n", $ticket_html_base,$row[0], $row[0]; printf " \n", $row[1]; print "\n"; } else { printf "
  • %s (%s)\n", $ticket_html_base, $row[0], $row[0], $row[1]; } } if ($ticket_browser_table) { print "
  • NameDescription
    %s%s
    \n\n"; } else { print "\n\n"; } } } printf "

    \n", &gettext("New class"); print "
    \n"; if ($is_admin) { &print_selection("admin"); } else { &print_selection(""); } } elsif ($ENV{'PATH_INFO'} eq "edit") { if ($cgi->param('group')) { $query = sprintf ("SELECT * FROM $ticket_table_groups WHERE name = '%s'", $cgi->param('group')); $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { print "

    " . sprintf(&gettext("Update group %s (%s)"), $cgi->param('group'), $row[1]). "

    \n\n"; printf "
    \n", $ticket_html_base; print "
    \n";
    		    printf "\n", $cgi->param('group');
    		    printf "Name     : \n", $row[1];
    		    print "
    \n"; printf "
    ", &gettext("Update"); print " . " if ($ticket_browser eq 'Lynx'); printf "
    \n", &gettext("Reset"); printf "%s\n", $ticket_html_base,$row[0], &gettext("Delete"); print "
    \n"; } else { print "

    " . sprintf (&gettext("Unknown group: %s"), $cgi->param('group')) . "

    \n\n"; &print_selection(); } } } elsif ($cgi->param('class')) { $query = sprintf ("SELECT * FROM $ticket_table_classes WHERE name = '%s'", $cgi->param('class')); $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { print "

    " . sprintf(&gettext("Update class %s (%s)"), $cgi->param('class'), $row[1]). "

    \n\n"; printf "
    \n", $ticket_html_base; print "
    \n";
    		    printf "\n", $cgi->param('class');
    		    printf "Name     : \n", $row[1];
    		    print "
    \n"; printf "
    ", &gettext("Update"); print " . " if ($ticket_browser eq 'Lynx'); printf "
    \n", &gettext("Reset"); printf "%s\n", $ticket_html_base,$row[0], &gettext("Delete"); print "
    \n"; } else { print "

    " . sprintf (&gettext("Unknown class: %s"), $cgi->param('class')) . "

    \n\n"; &print_selection(); } } } else { $query = sprintf ("SELECT * FROM $ticket_table_user WHERE username = '%s'", $user); $sth = $dbh->prepare($query); if ($sth) { $rc = $sth->execute; if ($rc > 0 && (@row = $sth->fetchrow_array)) { print "

    " . sprintf(&gettext("Update user %s (%s)"), $user, $row[1]). "

    \n\n"; printf "
    \n", $ticket_html_base; print "
    \n";
    		    printf "\n", $user;
    		    printf "Name      : \n", $row[1];
    		    printf "Email     : \n", $row[2];
    		    print  "Sprache   : ";
    		    &select_languages("language",$row[3]);
    		    if ($is_admin) {
    			printf "\nGruppe    : ";
    			&select_ticketgroups("group",":".$row[4].":", "nopublic nomultiple");
    			printf "\nGruppen   : ";
    			&select_ticketgroups("groups",$row[5], "nopublic");
    			print "\n" if ($ticket_browser ne 'Lynx');
    			printf "Assoziiert: ";
    			&select_ticketgroups("assoc",$row[6], "nopublic");
    			print "\n" if ($ticket_browser ne 'Lynx');
    			printf "Programme : ";
    			&select_programs ("programs",$row[7]);
    			print "\n" if ($ticket_browser ne 'Lynx');
    			print  "Misc.     : ";
    			printf "%s ",
    		            $row[9] =~ /:tablegroups:/?" checked": "", gettext("Groups as table");
    			printf "%s\n",
    		            $row[9] =~ /:tablelist:/?" checked": "", gettext("List as table");
    			printf "Active    : ";
    			&print_box ("active", "radio", $row[8], "ja ", "1");
    			&print_box ("active", "radio", $row[8], "nein
    \n", "0"); printf "Admin : "; &print_box ("admin", "radio", $row[9], "ja ", "j"); &print_box ("admin", "radio", $row[9], "nein
    \n", "n"); } else { print "\nMisc. : "; printf "%s ", gettext("Groups as table"); printf "%s\n", gettext("List as table"); } print "
    \n"; printf "
    ", &gettext("Update"); print " . " if ($ticket_browser eq 'Lynx'); printf "
    \n", &gettext("Reset"); printf "%s\n", $ticket_html_base,$row[0], &gettext("Delete") if ($is_admin); print "
    \n"; } else { print "

    " . sprintf (&gettext("Unknown user: %s"), $cgi->param('user')) . "

    \n\n"; &print_selection(); } } } } elsif ($ENV{'PATH_INFO'} eq "update") { if ($cgi->param('user')) { if ($is_admin) { @row = $cgi->param('groups'); @assoc = $cgi->param('assoc'); @progs = $cgi->param('programs'); } else { # Just a dummy... @row = ('dummy'); } @misc = $cgi->param('misc'); if ($#row == -1 || !length($cgi->param('realname')) || !length($cgi->param('email'))) { print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "Realname") . "

    \n\n" if (!length($cgi->param('realname'))); print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "Email") . "

    \n\n" if (!length($cgi->param('email'))); print "

    " . sprintf (&gettext("Primary group %s not in grouplist!"), $cgi->param('group')) . "

    \n\n" if ($grouplist !~ /:$group:/); } else { if ($is_admin) { $grouplist = ":" . join(":",@row) . ":"; $group = $cgi->param('group'); if ($grouplist !~ /:$group:/) { print "

    " . sprintf (&gettext("Primary group %s not in grouplist!"), $cgi->param('group')) . "

    \n\n"; } else { $query = sprintf ("UPDATE $ticket_table_user SET " . "realname=%s,email=%s,language='%s',maingroup='%s',groups='%s'," . "assoc='%s',programs='%s',misc='%s',active=%d,admin='%s' " . "WHERE username = '%s'", $dbh->quote($cgi->param('realname')), $dbh->quote($cgi->param('email')), $cgi->param('language'), $group, $grouplist, ":" . join(":",@assoc) . ":", ":" . join(":",@progs) . ":", ":" . join(":",@misc) . ":", $cgi->param('active'), $cgi->param('admin'), $cgi->param('user')); } } else { $query = sprintf ("UPDATE $ticket_table_user SET realname=%s,email=%s,language='%s',misc='%s'" . "WHERE username = '%s'", $dbh->quote($cgi->param('realname')), $dbh->quote($cgi->param('email')), $cgi->param('language'), ":" . join(":",@misc) . ":", $cgi->param('user')); } $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("User %s (%s) updated."), $cgi->param('user'), $cgi->param('realname')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Update of %s (%s) failed!"), $cgi->param('user'), $cgi->param('realname')) . "

    \n\n"; } } } elsif ($cgi->param('group')) { if (!length($cgi->param('description'))) { print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "Description") . "

    \n\n"; } else { $query = sprintf ("UPDATE $ticket_table_groups SET description=%s WHERE name = '%s'", $dbh->quote($cgi->param('description')), $cgi->param('group')); $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("Group %s (%s) updated."), $cgi->param('group'), $cgi->param('description')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Update of %s (%s) failed!"), $cgi->param('group'), $cgi->param('description')) . "

    \n\n"; } } } elsif ($cgi->param('class')) { if (!length($cgi->param('description'))) { print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "Description") . "

    \n\n"; } else { $query = sprintf ("UPDATE $ticket_table_classes SET description=%s WHERE name = '%s'", $dbh->quote($cgi->param('description')), $cgi->param('class')); $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("Class %s (%s) updated."), $cgi->param('class'), $cgi->param('description')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Update of %s (%s) failed!"), $cgi->param('class'), $cgi->param('description')) . "

    \n\n"; } } } else { print "

    " . &gettext("No user, group or class given!") . "

    \n\n"; } &print_selection(); } elsif ($ENV{'PATH_INFO'} eq "insert") { if ($cgi->param('user')) { @row = $cgi->param('groups'); @assoc = $cgi->param('assoc'); @progs = $cgi->param('programs'); if ($#row == -1 || !$cgi->param('user') || !$cgi->param('realname') || !$cgi->param('email')) { print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "User") . "

    \n\n" if (!length($cgi->param('user'))); print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "Realname") . "

    \n\n" if (!length($cgi->param('realname'))); print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "Email") . "

    \n\n" if (!length($cgi->param('email'))); } else { $query = sprintf ("INSERT INTO $ticket_table_user VALUES (%s,%s,%s,'%s','%s','%s','%s','%s',%d,'%s','%s')", $dbh->quote($cgi->param('user')),$dbh->quote($cgi->param('realname')), $dbh->quote($cgi->param('email')), $cgi->param('language'), $cgi->param('group'),":" . join(":",@row) . ":",":" . join(":",@assoc) . ":", ":" . join(":",@progs) . ":", $cgi->param('active'), $cgi->param('admin'), ":" . join(":",@misc) . ":"); $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("User %s (%s) added."), $cgi->param('user'), $cgi->param('realname')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Insert of %s (%s) failed!"), $cgi->param('user'), $cgi->param('realname')) . "

    \n\n"; } } } elsif ($cgi->param('group')) { if (!$cgi->param('description')) { print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "Description") . "

    \n\n"; } else { $tmp = $cgi->param('group'); $tmp =~ s/[\'\\ ]//g; $query = sprintf ("INSERT INTO $ticket_table_groups VALUES ('%s',%s)", $cgi->param('group'),$dbh->quote($cgi->param('description'))); $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("Group %s (%s) added."), $cgi->param('group'), $cgi->param('description')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Insert of %s (%s) failed!"), $cgi->param('group'), $cgi->param('description')) . "

    \n\n"; } } } elsif ($cgi->param('class')) { if (!$cgi->param('description')) { print "

    " . sprintf (&gettext("The field '%s' must not be empty!"), "Description") . "

    \n\n"; } else { $tmp = $cgi->param('class'); $tmp =~ s/[\'\\ ]//g; $query = sprintf ("INSERT INTO $ticket_table_classes VALUES ('%s',%s)", $cgi->param('class'),$dbh->quote($cgi->param('description'))); $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("Class %s (%s) added."), $cgi->param('class'), $cgi->param('description')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Insert of %s (%s) failed!"), $cgi->param('class'), $cgi->param('description')) . "

    \n\n"; } } } else { print "

    " . &gettext("No user, group or class given!") . "

    \n\n"; } &print_selection(); } elsif ($ENV{'PATH_INFO'} eq "newuser") { print "

    " . &gettext("Insert new user") . "

    \n\n"; printf "
    \n", $ticket_html_base; print "
    \n";
    	printf "User      : \n";
    	printf "Name      : \n";
    	printf "Email     : \n";
    	printf "Sprache   : ";
    	&select_languages("language", "ger");
    	printf "\nGruppe    : ";
    	&select_ticketgroups("group","nopublic nomultiple");
    	printf "\nGruppen   : ";
    	&select_ticketgroups("groups","nopublic");
    	print "\n" if ($ticket_browser eq 'Lynx');
    	printf "Assoziiert: ";
    	&select_ticketgroups("assoc","nopublic");
    	print "\n" if ($ticket_browser eq 'Lynx');
    	printf "Programme : ";
    	&select_programs ("programs", "-");
    	print "\n" if ($ticket_browser eq 'Lynx');
    	print  "Misc.     : ";
    	printf "%s ",
    	    gettext("Groups as table");
    	printf "%s\n",
    	    gettext("List as table");
    	printf "Active    : ";
    	&print_box ("active", "radio", "1", "ja ", "1");
    	&print_box ("active", "radio", "1", "nein
    \n", "0"); printf "Admin : "; &print_box ("admin", "radio", "n", "ja ", "j"); &print_box ("admin", "radio", "n", "nein
    \n", "n"); print "
    \n"; printf "
    ", &gettext("Insert"); print " . " if ($ticket_browser eq 'Lynx'); printf "
    \n", &gettext("Reset"); print "
    \n"; } elsif ($ENV{'PATH_INFO'} eq "newgroup") { print "

    " . &gettext("Insert new group") . "

    \n\n"; printf "
    \n", $ticket_html_base; print "
    \n";
    	printf "Name     : \n";
    	printf "Text     : \n";
    	print "
    \n"; printf "
    ", &gettext("Insert"); print " . " if ($ticket_browser eq 'Lynx'); printf "
    \n", &gettext("Reset"); print "
    \n"; } elsif ($ENV{'PATH_INFO'} eq "newclass") { print "

    " . &gettext("Insert new class") . "

    \n\n"; printf "
    \n", $ticket_html_base; print "
    \n";
    	printf "Name     : \n";
    	printf "Text     : \n";
    	print "
    \n"; printf "
    ", &gettext("Insert"); print " . " if ($ticket_browser eq 'Lynx'); printf "
    \n", &gettext("Reset"); print "
    \n"; } elsif ($ENV{'PATH_INFO'} eq "delete") { if ($cgi->param('user')) { $query = sprintf ("DELETE FROM $ticket_table_user WHERE username = %s", $dbh->quote($cgi->param('user'))); $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("User %s removed."), $cgi->param('user')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Removal of user %s failed!"), $cgi->param('user')) . "

    \n\n"; } } elsif ($cgi->param('group')) { if (!group_in_use( $cgi->param('group') )) { $query = sprintf ("DELETE FROM $ticket_table_groups WHERE name = '%s'", $cgi->param('group')); $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("Group %s removed."), $cgi->param('group')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Removal of group %s failed!"), $cgi->param('group')) . "

    \n\n"; } } else { print "

    " . sprintf (&gettext("A user is still assigned to group %s!"), $cgi->param('group')) . "

    \n\n"; } } elsif ($cgi->param('class')) { $query = sprintf ("DELETE FROM $ticket_table_classes WHERE name = '%s'", $cgi->param('class')); $sth = $dbh->do($query); if ($sth) { print "

    " . sprintf (&gettext("Class %s removed."), $cgi->param('class')) . "

    \n\n"; } else { print "

    " . sprintf (&gettext("Removal of class %s failed!"), $cgi->param('class')) . "

    \n\n"; } } else { print "

    " . &gettext("No user, group or class given!") . "

    \n\n"; } &print_selection(); } } sub relshow { my $table = $_[0]; my $cmd; return if (!$_[0]); if ($ticket_dbhost) { $cmd = "relshow -h $ticket_dbhost $ticket_dbase $table|"; } else { $cmd = "relshow $ticket_dbase $table|"; } if (open (IN, "$cmd")) { while () { next until (/^ [+|]/); print; } close (IN); } } sub queries { my $is_admin = undef; $is_admin = 1 if (defined $cgi->param('admin') && &is_admin($ENV{'REMOTE_USER'})); print "

    " . &gettext("Special Queries") . "

    \n\n"; if ($ticket_browser_table) { print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; print "\n"; } # Zweite Tabelle if ($ticket_browser_table) { print "\n"; print " \n"; print " \n"; print " \n"; print "\n"; } # Dritte Tabelle if ($ticket_browser_table) { print "\n"; print " \n"; print " \n"; print "\n"; } else { print "
    \n"; } # Vierte Tabele if ($ticket_browser_table) { print "\n"; print " \n"; print "\n"; print "
    \n"; } else { print "
    \n"; } print "
    \n"; printf "\n
    \n", $ticket_html_base; print "" . &gettext("Open tickets by priority") . "
    \n"; print "\n" if ($is_admin); print "
    \n"; print "\n"; print "
    \n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "
    \n"; printf "\n
    \n", $ticket_html_base; print "" . &gettext("Open tickets by staff") . "
    \n"; print "\n" if ($is_admin); &select_ticketuser("user"); print "
    \n"; print "\n"; print "
    \n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "
    \n"; printf "\n
    \n", $ticket_html_base; print "" . &gettext("Open tickets by classes") . "
    \n"; print "\n" if ($is_admin); &print_select_class(); print "
    \n"; print "\n"; print "
    \n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "
    \n"; printf "\n
    \n", $ticket_html_base; print "" . &gettext("Tickets by groups") . "
    \n"; print "\n" if ($is_admin); print "Group: "; &select_ticketgroups("group","nomultiple"); print "\n"; print "\n"; print "
    \n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "
    \n"; printf "\n
    \n", $ticket_html_base; print "" . &gettext("Ticket by number") . "
    \n"; print "\n" if ($is_admin); print "Nummer: \n"; print "\n"; print "
    \n"; print &gettext("Shows ticket with that number") . "\n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "
    \n"; printf "\n
    \n", $ticket_html_base; print "" . &gettext("Tickets by substring") . "
    \n"; print "\n" if ($is_admin); print "Subject: \n"; print "\n"; print "
    \n"; print &gettext("Subject contains keyword") . "\n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "
    \n"; printf "\n
    \n", $ticket_html_base; print "" . &gettext("Tickets by substring") . "
    \n"; print "\n" if ($is_admin); print "Substring: \n"; print "\n"; print "
    \n"; print &gettext("Textareas contain keyword, closed tickets as well") . "\n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "
    \n"; printf "\n
    \n", $ticket_html_base; print "" . &gettext("Tickets by period") . "
    \n"; print "\n" if ($is_admin); print "Von: \n"; print "Bis:
    \n"; print "\n"; print "
    \n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } printf "\n
    \n", $ticket_html_base; print "
    " . &gettext("Combined Query") . "

    \n"; print "
    \n"; print "\n"; print " \n"; print " \n"; print "\n"; print "\n"; $ticketuser{''}=''; print " \n"; print " \n"; print "\n"; print "\n"; print " \n"; print " \n"; print "\n"; print "\n"; print " \n"; print " \n"; print "\n"; print "\n"; print "
    open
    closed
    Staff
    \n"; &select_ticketuser("user"); print "
    Priority
    \n"; print "
    \n"; print "
    Group
    \n"; &select_ticketgroups("group","nomultiple addempty"); print "
    Subject
    \n
    Class
    \n"; &print_select_class(''); print "
    Substring
    \n
    \n"; print "
    \n"; if ($ticket_browser_table) { print "
    \n

    \n

    \n"; } else { print "


    \n"; } print &gettext("The lookups are case insensitive.") . "\n"; &print_selection(); } # FIXME sub help { my $host; if ($ticket_html_base !~ /^http:/) { $host = $ENV{'SERVER_URL'}; chop ($host) if ($host =~ /\/$/ && $ticket_html_base =~ /^\//); $host .= $ticket_html_base; } else { $host = $ticket_html_base; } printf "\n

    Hilfe zum Ticket-System

    \n\n", $ticket_html_base; if (open (F, "$ticket_file_help")) { while () { s/__BASE__/$host/g; print; } close (F); } &print_selection(); } sub info { printf "\n

    Informationen zum Ticket-System

    \n\n", $ticket_html_base; if (open (F, "$ticket_file_info")) { print while (); close (F); } if ($is_admin) { print "Die Tabellen laufen zur Zeit auf $ticket_dbhost in der Datenbank $ticket_dbase.

    \n\n"; if ($ticket_browser_table) { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    \n"; } else { print "
    \n"; } print "

    Ticket-Tabelle

    \n"; print "
    \n";
    	&relshow ($ticket_table);
    	print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "

    User-Tabelle

    \n"; print "
    \n";
    	&relshow ($ticket_table_user);
    	print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "

    Gruppen-Tabelle

    \n"; print "
    \n";
    	&relshow ($ticket_table_groups);
    	print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "
    \n"; } print "

    Klassen-Tabelle

    \n"; print "
    \n";
    	&relshow ($ticket_table_classes);
    	print "
    \n"; if ($ticket_browser_table) { print "
    \n"; } else { print "


    \n"; } } &print_selection(); } sub print_html_groups() { my $groups = &user_groups($ENV{'REMOTE_USER'}); my $g; $groups =~ s/^:(.*):$/$1/; $groups =~ s/:/ /g; if (length($groups) > 65) { $groups = substr($groups, 0, 62) . "..."; } print "\n" . " \n \n \n \n
    \n
    \n"; printf " User: %s", $ticket_html_base, $ENV{'REMOTE_USER'}, $ENV{'REMOTE_USER'}; printf " (%s)", &user_realname($ENV{'REMOTE_USER'}) if (length($groups) <= 48); # printf " - Groups: %s\n", $groups; printf " - Groups:"; foreach $g (split(/ /,$groups)) { if ($g eq "...") { printf "%s", $g; } else { printf " %s", $ticket_html_base, $g, $g; } } print "\n
    \n"; print "
    \n" if ($ENV{'HTTP_USER_AGENT'} !~ /Mozilla/); print "\n"; } # ----------------------------------------------------------------------- $cgi = new CGI; print $cgi->header(); print $ticket_html_header; if (!length($ENV{'REMOTE_USER'})) { print "

    No user specified!

    \n\n"; print $ticket_html_footer; exit (0); } $dbh = &ticket_init($ENV{'REMOTE_USER'}); if (!$dbh) { print "

    Cannot connect to database!

    "; print $ticket_html_footer; exit (0); } print_html_groups(); $is_admin = &is_admin($ENV{'REMOTE_USER'}); if (length ($ENV{'PATH_INFO'})) { $ENV{'PATH_INFO'} =~ s,^/,,; if ($ENV{'PATH_INFO'} eq "listone") { &listone(); } elsif ($ENV{'PATH_INFO'} =~ /^list/) { $ENV{'PATH_INFO'} =~ s,^list,,; $ENV{'PATH_INFO'} =~ s,^/,,; &list(); } elsif ($ENV{'PATH_INFO'} =~ /^admin/) { $ENV{'PATH_INFO'} =~ s,^admin,,; $ENV{'PATH_INFO'} =~ s,^/,,; &admin(); } elsif ($ENV{'PATH_INFO'} eq "selection") { &process_selection(); } elsif ($ENV{'PATH_INFO'} eq "action") { &process_actions(); } elsif ($ENV{'PATH_INFO'} eq "edit") { &edit(); } elsif ($ENV{'PATH_INFO'} eq "update") { &update(); } elsif ($ENV{'PATH_INFO'} eq "delete") { &delete(); } elsif ($ENV{'PATH_INFO'} eq "close") { &close(); } elsif ($ENV{'PATH_INFO'} eq "queries") { &queries(); } elsif ($ENV{'PATH_INFO'} eq "insert" || $ENV{'PATH_INFO'} eq "insertdata") { &insert(); } elsif ($ENV{'PATH_INFO'} =~ /^help/) { &help(); } elsif ($ENV{'PATH_INFO'} =~ /^info/) { &info(); } else { &print_first_banner(); } } else { &print_first_banner(); } print $ticket_html_footer; $dbh->disconnect;