[LON-CAPA-cvs] cvs: loncom /cgi userstatus.pl

www lon-capa-cvs@mail.lon-capa.org
Tue, 29 Jul 2003 20:17:52 -0000


www		Tue Jul 29 16:17:52 2003 EDT

  Modified files:              
    /loncom/cgi	userstatus.pl 
  Log:
  Query string switch to "oneline" mode which only reports numbers.
  Would be nice in 1.0, cannot cause any damage in "real" parts of LON-CAPA
  
  
Index: loncom/cgi/userstatus.pl
diff -u loncom/cgi/userstatus.pl:1.2 loncom/cgi/userstatus.pl:1.3
--- loncom/cgi/userstatus.pl:1.2	Wed Feb 26 09:10:38 2003
+++ loncom/cgi/userstatus.pl	Tue Jul 29 16:17:52 2003
@@ -14,8 +14,8 @@
 use IO::File;
 
  
-print "Content-type: text/html\n\n".
-      "<html><body bgcolor=#FFFFFF>\n";
+print "Content-type: text/html\n\n";
+      
 # -------------------- Read loncapa.conf (and by default, loncapa_apache.conf).
 my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
 my %perlvar=%{$perlvarref};
@@ -23,7 +23,8 @@
 delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
 delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
 
-print "<h1>User Status ".localtime()."</h1>";
+my $oneline=($ENV{'QUERY_STRING'} eq 'simple');
+unless ($oneline) { print "<html><body bgcolor=#FFFFFF>\n<h1>User Status ".localtime()."</h1>"; }
 
 my $filename;
 opendir(DIR,$perlvar{'lonIDsDir'});
@@ -37,7 +38,7 @@
         $now=time;
         $since=$now-$mtime;
         $sinceacc=$now-$atime;
-	print ("\n\n<hr />");
+	unless ($oneline) { print ("\n\n<hr />"); }
         my %userinfo=();
         undef $userinfo;
         my $fh=IO::File->new($perlvar{'lonIDsDir'}.'/'.$filename);
@@ -56,6 +57,7 @@
         if ($since>21600) { $color="#AAAAAA"; $userclass="Inactive"; }
         $usercount{$userclass}++;
         $usercount{'in Domain '.$userinfo{'user.domain'}}++;
+      unless ($oneline) {
         print '<font color="'.$color.'">';
         print '<h3>'.$userinfo{'environment.lastname'}.', '.
 	       $userinfo{'environment.firstname'}.' '.
@@ -80,13 +82,19 @@
         print "<br /><b>Last Transaction:</b> ".localtime($mtime).
        " (".$since." secs ago) <br /><b>Last Access:</b> ".localtime($atime).
        " (".$sinceacc." secs ago)";
-       print ("</font>");       
+       print ("</font>"); 
+     }      
     }
 }
 closedir(DIR);
+unless ($oneline) { 
 print "<hr /><h2>User Count</h2>";
 foreach (sort keys %usercount) {
     print "<b>".$_.":</b> ".$usercount{$_}."<br />";
 }
-
 print "</body></html>";
+} else {
+foreach (sort keys %usercount) {
+    print $_.'='.$usercount{$_}.'&';
+}
+}