[LON-CAPA-cvs] cvs: loncom(version_2_11_X) / lond
raeburn
raeburn at source.lon-capa.org
Mon May 4 11:15:17 EDT 2020
raeburn Mon May 4 15:15:17 2020 EDT
Modified files: (Branch: version_2_11_X)
/loncom lond
Log:
- For 2.11
Backport 1.561
Index: loncom/lond
diff -u loncom/lond:1.489.2.35 loncom/lond:1.489.2.36
--- loncom/lond:1.489.2.35 Mon Jan 13 13:41:24 2020
+++ loncom/lond Mon May 4 15:15:16 2020
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.489.2.35 2020/01/13 13:41:24 raeburn Exp $
+# $Id: lond,v 1.489.2.36 2020/05/04 15:15:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -63,7 +63,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.489.2.35 $'; #' stupid emacs
+my $VERSION='$Revision: 1.489.2.36 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -4576,6 +4576,45 @@
}
®ister_handler("courselastaccess",\&course_lastaccess_handler, 0, 1, 0);
+sub course_sessions_handler {
+ my ($cmd, $tail, $client) = @_;
+ my $userinput = "$cmd:$tail";
+ my ($cdom,$cnum,$lastactivity) = split(':',$tail);
+ my $dbsuffix = '_'.$cdom.'_'.$cnum.'.db';
+ my (%sessions,$qresult);
+ my $now=time;
+ if (opendir(DIR,$perlvar{'lonIDsDir'})) {
+ my $filename;
+ while ($filename=readdir(DIR)) {
+ next if ($filename=~/^\./);
+ next if ($filename=~/^publicuser_/);
+ next if ($filename=~/^[a-f0-9]+_(linked|lti_\d+)\.id$/);
+ if ($filename =~ /^($LONCAPA::match_user)_\d+_($LONCAPA::match_domain)_/) {
+ my ($uname,$udom) = ($1,$2);
+ next unless (-e "$perlvar{'lonDaemons'}/$uname$dbsuffix");
+ my $mtime = (stat("$perlvar{'lonIDsDir'}/$filename"))[9];
+ my $since=$now-$mtime;
+ if ($lastactivity < 0) {
+ next if ($since <= $lastactivity);
+ } else {
+ next if ($since > $lastactivity);
+ }
+ $sessions{$uname.':'.$udom} = $mtime;
+ }
+ }
+ closedir(DIR);
+ }
+ foreach my $user (keys(%sessions)) {
+ $qresult.=&escape($user).'='.$sessions{$user}.'&';
+ }
+ if ($qresult) {
+ chop($qresult);
+ }
+ &Reply($client, \$qresult, $userinput);
+ return 1;
+}
+®ister_handler("coursesessions",\&course_sessions_handler, 0, 1, 0);
+
#
# Puts an unencrypted entry in a namespace db file at the domain level
#
More information about the LON-CAPA-cvs
mailing list