version 1.16, 2007/10/02 01:36:31
|
version 1.17, 2008/11/28 20:45:21
|
Line 26 $|=1;
|
Line 26 $|=1;
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
|
|
|
|
use strict; |
use strict; |
|
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
|
use Apache::lonlocal; |
use LONCAPA::Configuration; |
use LONCAPA::Configuration; |
use LONCAPA; |
use LONCAPA::loncgi; |
use HTTP::Headers; |
use HTTP::Headers; |
use GDBM_File; |
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 %usercount; |
my @actl=('Active','Moderately Active','Inactive'); |
my @actl=('Active','Moderately Active','Inactive'); |
|
|
|
&main($perlvar); |
print "Content-type: text/html\n\n"; |
|
|
|
# -------------------- Read loncapa.conf (and by default, loncapa_apache.conf). |
|
&main(); |
|
|
|
sub analyze_time { |
sub analyze_time { |
my ($since)=@_; |
my ($since)=@_; |
Line 68 sub add_count {
|
Line 68 sub add_count {
|
} |
} |
|
|
sub main { |
sub main { |
my $perlvar=LONCAPA::Configuration::read_conf('loncapa.conf'); |
my ($perlvar) = @_; |
delete $$perlvar{'lonReceipt'}; # remove since sensitive and not needed |
delete $$perlvar{'lonReceipt'}; # remove since sensitive and not needed |
delete $$perlvar{'lonSqlAccess'}; # remove since sensitive and not needed |
delete $$perlvar{'lonSqlAccess'}; # remove since sensitive and not needed |
|
|
my $oneline=($ENV{'QUERY_STRING'} eq 'simple'); |
if (!&LONCAPA::loncgi::check_ipbased_access()) { |
my $justsummary=($ENV{'QUERY_STRING'} eq 'summary'); |
if (!&LONCAPA::loncgi::check_cookie_and_load_env()) { |
unless ($oneline) { print "<html><body bgcolor=#FFFFFF>\n<h1>User Status ".localtime()."</h1>"; } |
&Apache::lonlocal::get_language_handle(); |
|
print &LONCAPA::loncgi::missing_cookie_msg(); |
|
return; |
|
} |
|
|
|
if (!&LONCAPA::loncgi::can_view('userstatus')) { |
|
&Apache::lonlocal::get_language_handle(); |
|
print &LONCAPA::loncgi::unauthorized_msg('userstatus'); |
|
return; |
|
} |
|
} |
|
|
|
&Apache::lonlocal::get_language_handle(); |
|
my (%gets,$dom,$oneline,$justsummary); |
|
&LONCAPA::loncgi::cgi_getitems($ENV{'QUERY_STRING'},\%gets); |
|
if (defined($gets{'simple'})) { |
|
$oneline = 'simple'; |
|
} |
|
if (defined($gets{'summary'})) { |
|
$justsummary = 'summary'; |
|
} |
|
|
|
my %lt = &Apache::lonlocal::texthash( |
|
usrs => 'User Status', |
|
login => 'Login time', |
|
on => 'on', |
|
Client => 'Client', |
|
role => 'Role', |
|
notc => 'Not in a course', |
|
ltra => 'Last Transaction', |
|
lacc => 'Last Access', |
|
secs => 'secs ago', |
|
usrc => 'User Counts', |
|
load => 'Load Average', |
|
Overall => 'Overall', |
|
Domain => 'Domain', |
|
Course => 'Course', |
|
Browser => 'Browser', |
|
OS => 'OS', |
|
Active => 'Active', |
|
'Moderately Active' => 'Moderately Active', |
|
Inactive => 'Inactive', |
|
); |
|
|
|
unless ($oneline) { |
|
my $now = time(); |
|
print '<html><body bgcolor="#FFFFFF">'."\n". |
|
"<h1>$lt{'usrs'} ".&Apache::lonlocal::locallocaltime($now).'</h1>'; |
|
} |
|
|
opendir(DIR,$$perlvar{'lonIDsDir'}); |
opendir(DIR,$$perlvar{'lonIDsDir'}); |
my @allfiles=(sort(readdir(DIR))); |
my @allfiles=(sort(readdir(DIR))); |
Line 113 sub main {
|
Line 161 sub main {
|
$userinfo{'user.name'}."\@".$userinfo{'user.domain'}. |
$userinfo{'user.name'}."\@".$userinfo{'user.domain'}. |
")</h3>\n". |
")</h3>\n". |
"<p><tt>$filename</tt></p>". |
"<p><tt>$filename</tt></p>". |
"<b>Login time:</b> ". |
"<b>$lt{'login'}:</b> ". |
localtime($userinfo{'user.login.time'}). |
&Apache::lonlocal::locallocaltime($userinfo{'user.login.time'}). |
' <b>Browser</b>: '.$userinfo{'browser.type'}. |
" <b>$lt{'Browser'}</b>: ".$userinfo{'browser.type'}. |
" on ".$userinfo{'browser.os'}."<b>Client:</b> ". |
" $lt{'on'} ".$userinfo{'browser.os'}."<b>$lt{'Client'}:</b>". |
$userinfo{'request.host'}."<br />\n<b>Role: </b>". |
$userinfo{'request.host'}."<br />\n<b>$lt{'role'}: </b>". |
$userinfo{'request.role'}." "; |
$userinfo{'request.role'}." "; |
} |
} |
&add_count('Browser',$userinfo{'browser.type'},$userinfo{'browser.version'}); |
&add_count('Browser',$userinfo{'browser.type'},$userinfo{'browser.version'}); |
Line 128 sub main {
|
Line 176 sub main {
|
' ('.$cid.')'; |
' ('.$cid.')'; |
if (!$justsummary) { |
if (!$justsummary) { |
$users{$userclass}{$filename} .= |
$users{$userclass}{$filename} .= |
"<b>Course:</b> ".$coursename; |
"<b>$lt{'Course'}:</b> ".$coursename; |
} |
} |
&add_count('Course',$coursename,$userclass); |
&add_count('Course',$coursename,$userclass); |
} else { |
} else { |
if (!$justsummary) { |
if (!$justsummary) { |
$users{$userclass}{$filename} .= |
$users{$userclass}{$filename} .= $lt{'notc'}; |
"Not in a course."; |
|
} |
} |
&add_count('Course','No Course',$userclass); |
&add_count('Course','No Course',$userclass); |
} |
} |
if (!$justsummary) { |
if (!$justsummary) { |
$users{$userclass}{$filename} .= |
$users{$userclass}{$filename} .= |
"<br /><b>Last Transaction:</b> ".localtime($mtime). |
"<br /><b>$lt{'ltra'}:</b> ".&Apache::lonlocal::locallocaltime($mtime). |
" (".$since." secs ago) <br /><b>Last Access:</b> ". |
" (".$since." $lt{'secs'}) <br /><b>$lt{'lacc'}:</b> ". |
localtime($atime)." (".$sinceacc." secs ago)". |
&Apache::lonlocal::locallocaltime($atime)." (".$sinceacc." $lt{'secs'})". |
"</font>"; |
"</font>"; |
} |
} |
} |
} |
Line 150 sub main {
|
Line 197 sub main {
|
} |
} |
if (!$oneline && !$justsummary) { |
if (!$oneline && !$justsummary) { |
foreach my $class (@actl) { |
foreach my $class (@actl) { |
print("\n\n<hr /><h1>$class</h1>"); |
print("\n\n<hr /><h1>$lt{$class}</h1>"); |
foreach my $filename (sort(keys(%{$users{$class}}))) { |
foreach my $filename (sort(keys(%{$users{$class}}))) { |
print("\n\n".$users{$class}{$filename}."\n\n<hr />"); |
print("\n\n".$users{$class}{$filename}."\n\n<hr />"); |
} |
} |
Line 162 sub main {
|
Line 209 sub main {
|
my $loadavg=<LOADAVGH>; |
my $loadavg=<LOADAVGH>; |
close(LOADAVGH); |
close(LOADAVGH); |
unless ($oneline) { |
unless ($oneline) { |
print "<hr /><h2>User Counts</h2>"; |
print "<hr /><h2>$lt{'usrc'}</h2>"; |
# print "<pre>\n"; |
# print "<pre>\n"; |
&showact('Overall',%usercount); |
&showact('Overall',\%lt,%usercount); |
&showact('Domain',%usercount); |
&showact('Domain',\%lt,%usercount); |
&showact('Course',%usercount); |
&showact('Course',\%lt,%usercount); |
&show('Browser',%usercount); |
&show('Browser',\%lt,%usercount); |
&show('OS',%usercount); |
&show('OS',\%lt,%usercount); |
|
|
# print "\n</pre>"; |
# print "\n</pre>"; |
print "<b>Load Average:<b> ".$loadavg; |
print "<b>$lt{'load'}:<b> ".$loadavg; |
print "</body></html>"; |
print "</body></html>"; |
} else { |
} else { |
foreach my $l1 (sort keys %usercount) { |
foreach my $l1 (sort keys %usercount) { |
Line 190 sub main {
|
Line 237 sub main {
|
} |
} |
|
|
sub show { |
sub show { |
my ($cat,%usercount)=@_; |
my ($cat,$ltref,%usercount)=@_; |
print("<h3>$cat</h3>\n"); |
print("<h3>$ltref->{$cat}</h3>\n"); |
foreach my $type (sort(keys(%{$usercount{$cat}}))) { |
foreach my $type (sort(keys(%{$usercount{$cat}}))) { |
print("<table border='1'><tr><th>$type</th><th>"); |
print("<table border='1'><tr><th>$type</th><th>"); |
print(join("</th><th>",sort(keys(%{$usercount{$cat}{$type}})))); |
print(join("</th><th>",sort(keys(%{$usercount{$cat}{$type}})))); |
Line 208 sub show {
|
Line 255 sub show {
|
} |
} |
|
|
sub showact { |
sub showact { |
my ($cat,%usercount)=@_; |
my ($cat,$ltref,%usercount)=@_; |
print("<h3>$cat</h3>\n"); |
print("<h3>$ltref->{$cat}</h3>\n"); |
|
|
print("<table border='1'><tr><th></th><th>"); |
print("<table border='1'><tr><th></th><th>"); |
print(join("</th><th>",('Any',@actl))); |
print(join("</th><th>",('Any',@actl))); |