#!/usr/local/bin/perl
# index_user.cgi

require './proc-lib.pl';
&header($text{'index_title'}, "", "user", !$no_module_config, 1);
print "<hr>\n";

&index_links("user");
@procs = sort { $b->{'cpu'} <=> $a->{'cpu'} } &list_processes();
@procs = grep { !$hide{$_->{'user'}} } @procs;
@procs = grep { $_->{'user'} eq $remote_user } @procs if ($user_processes_only);
@users = &unique(map { $_->{'user'} } @procs);
foreach $u (@users) {
	@uinfo = getpwnam($u);
	$uinfo[6] =~ s/,.*$//;
	print "<dt><font size=+1>$u ",
		$uinfo[6] ? "($uinfo[6])" : "","</font><br>\n";
	print "<dd><table border width=90%>\n";
	print "<tr $tb> <td width=1% nowrap><b>$text{'pid'}</b></td>\n";
	print "         <td width=1%><b>$text{'cpu'}</b></td>\n";
	if ($info_arg_map{'_stime'}) {
		print "         <td width=1%><b>$text{'stime'}</b></td>\n";
		}
	print "         <td width=98%><b>$text{'command'}</b></td> </tr>\n";
	foreach $pr (grep { $_->{'user'} eq $u } @procs) {
		$p = $pr->{'pid'};
		print "<tr $cb>\n";
		if ($access{'edit'}) {
			print "<td><a href=\"edit_proc.cgi?$p\">$p</a></td>\n";
			}
		else {
			print "<td>$p</td>\n";
			}
		print "<td nowrap>$pr->{'cpu'}</td>\n";
		if ($info_arg_map{'_stime'}) {
			print "<td nowrap>",$pr->{'_stime'} || "<br>","</td>\n";
			}
		print "<td>",&html_escape(&cut_string($pr->{'args'})),
		      "</td>\n";
		print "</tr>\n";
		}
	print "</table><p>\n";
	}
print "</dl>\n";

print "<hr>\n";
&footer("/", $text{'index'});

