--- loncom/cgi/userstatus.pl 2007/10/02 01:36:31 1.16 +++ loncom/cgi/userstatus.pl 2010/03/23 12:01:49 1.20 @@ -1,7 +1,7 @@ #!/usr/bin/perl $|=1; # User Status -# $Id: userstatus.pl,v 1.16 2007/10/02 01:36:31 albertel Exp $ +# $Id: userstatus.pl,v 1.20 2010/03/23 12:01:49 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,23 +26,24 @@ $|=1; # http://www.lon-capa.org/ # - use strict; + use lib '/home/httpd/lib/perl/'; +use Apache::lonlocal; use LONCAPA::Configuration; -use LONCAPA; +use LONCAPA::loncgi; +use LONCAPA::lonauthcgi; use HTTP::Headers; use GDBM_File; +# -------------------- Read loncapa.conf (and by default, loncapa_apache.conf). +my $perlvar=&LONCAPA::Configuration::read_conf('loncapa.conf'); +print "Content-type: text/html\n\n"; my %usercount; my @actl=('Active','Moderately Active','Inactive'); - -print "Content-type: text/html\n\n"; - -# -------------------- Read loncapa.conf (and by default, loncapa_apache.conf). -&main(); +&main($perlvar); sub analyze_time { my ($since)=@_; @@ -68,13 +69,67 @@ sub add_count { } sub main { - my $perlvar=LONCAPA::Configuration::read_conf('loncapa.conf'); + my ($perlvar) = @_; delete $$perlvar{'lonReceipt'}; # remove since sensitive and not needed delete $$perlvar{'lonSqlAccess'}; # remove since sensitive and not needed - my $oneline=($ENV{'QUERY_STRING'} eq 'simple'); - my $justsummary=($ENV{'QUERY_STRING'} eq 'summary'); - unless ($oneline) { print "
\n$filename
". - "Login time: ". - localtime($userinfo{'user.login.time'}). - ' Browser: '.$userinfo{'browser.type'}. - " on ".$userinfo{'browser.os'}."Client: ". - $userinfo{'request.host'}."\n"; - &showact('Overall',%usercount); - &showact('Domain',%usercount); - &showact('Course',%usercount); - &show('Browser',%usercount); - &show('OS',%usercount); + &showact('Overall',\%lt,%usercount); + &showact('Domain',\%lt,%usercount); + &showact('Course',\%lt,%usercount); + &show('Browser',\%lt,%usercount); + &show('OS',\%lt,%usercount); # print "\n"; - print "Load Average: ".$loadavg; + print "$lt{'load'}: ".$loadavg; print ""; } else { foreach my $l1 (sort keys %usercount) { @@ -190,8 +244,8 @@ sub main { } sub show { - my ($cat,%usercount)=@_; - print("
$type | "); print(join(" | ",sort(keys(%{$usercount{$cat}{$type}}))));
@@ -208,10 +262,10 @@ sub show {
}
sub showact {
- my ($cat,%usercount)=@_;
- print("$cat\n"); + my ($cat,$ltref,%usercount)=@_; + print("$ltref->{$cat}\n"); - print("
|
---|