version 1.489.2.34, 2020/01/13 03:46:32
|
version 1.489.2.40, 2021/02/10 15:05:51
|
Line 4576 sub course_lastaccess_handler {
|
Line 4576 sub course_lastaccess_handler {
|
} |
} |
®ister_handler("courselastaccess",\&course_lastaccess_handler, 0, 1, 0); |
®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_username)_\d+_($LONCAPA::match_domain)_/) { |
|
my ($uname,$udom) = ($1,$2); |
|
next unless (-e "$perlvar{'lonDaemons'}/tmp/$uname$dbsuffix"); |
|
my $mtime = (stat("$perlvar{'lonIDsDir'}/$filename"))[9]; |
|
if ($lastactivity < 0) { |
|
next if ($mtime-$now > $lastactivity); |
|
} else { |
|
next if ($now-$mtime > $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 |
# Puts an unencrypted entry in a namespace db file at the domain level |
# |
# |
Line 4624 sub put_domain_handler {
|
Line 4662 sub put_domain_handler {
|
# domain directory. |
# domain directory. |
# |
# |
# Parameters: |
# Parameters: |
# $cmd - Command request keyword (get). |
# $cmd - Command request keyword (getdom). |
# $tail - Tail of the command. This is a colon separated list |
# $tail - Tail of the command. This is a colon separated list |
# consisting of the domain and the 'namespace' |
# consisting of the domain and the 'namespace' |
# which selects the gdbm file to do the lookup in, |
# which selects the gdbm file to do the lookup in, |
Line 4641 sub put_domain_handler {
|
Line 4679 sub put_domain_handler {
|
sub get_domain_handler { |
sub get_domain_handler { |
my ($cmd, $tail, $client) = @_; |
my ($cmd, $tail, $client) = @_; |
|
|
|
|
my $userinput = "$cmd:$tail"; |
my $userinput = "$cmd:$tail"; |
|
|
my ($udom,$namespace,$what)=split(/:/,$tail,3); |
my ($udom,$namespace,$what)=split(/:/,$tail,3); |
chomp($what); |
my $res = LONCAPA::Lond::get_dom($userinput); |
my @queries=split(/\&/,$what); |
if ($res =~ /^error:/) { |
my $qresult=''; |
&Failure($client, \$res, $userinput); |
my $hashref = &tie_domain_hash($udom, "$namespace", &GDBM_READER()); |
|
if ($hashref) { |
|
for (my $i=0;$i<=$#queries;$i++) { |
|
$qresult.="$hashref->{$queries[$i]}&"; |
|
} |
|
if (&untie_domain_hash($hashref)) { |
|
$qresult=~s/\&$//; |
|
&Reply($client, \$qresult, $userinput); |
|
} else { |
|
&Failure( $client, "error: ".($!+0)." untie(GDBM) Failed ". |
|
"while attempting getdom\n",$userinput); |
|
} |
|
} else { |
} else { |
&Failure($client, "error: ".($!+0)." tie(GDBM) Failed ". |
&Reply($client, \$res, $userinput); |
"while attempting getdom\n",$userinput); |
|
} |
} |
|
|
return 1; |
return 1; |
Line 5185 sub tmp_del_handler {
|
Line 5209 sub tmp_del_handler {
|
®ister_handler("tmpdel", \&tmp_del_handler, 0, 1, 0); |
®ister_handler("tmpdel", \&tmp_del_handler, 0, 1, 0); |
|
|
# |
# |
|
# Process the updatebalcookie command. This command updates a |
|
# cookie in the lonBalancedir directory on a load balancer node. |
|
# |
|
# Parameters: |
|
# $cmd - Command that got us here. |
|
# $tail - Tail of the request (escaped cookie: escaped current entry) |
|
# |
|
# $client - socket open on the client process. |
|
# |
|
# Returns: |
|
# 1 - Indicating processing should continue. |
|
# Side Effects: |
|
# A cookie file is updated from the lonBalancedir directory |
|
# A reply is sent to the client. |
|
# |
|
sub update_balcookie_handler { |
|
my ($cmd, $tail, $client) = @_; |
|
|
|
my $userinput= "$cmd:$tail"; |
|
chomp($tail); |
|
my ($cookie,$lastentry) = map { &unescape($_) } (split(/:/,$tail)); |
|
|
|
my $updatedone; |
|
if ($cookie =~ /^$LONCAPA::match_domain\_$LONCAPA::match_username\_[a-f0-9]{32}$/) { |
|
my $execdir=$perlvar{'lonBalanceDir'}; |
|
if (-e "$execdir/$cookie.id") { |
|
my $doupdate; |
|
if (open(my $fh,'<',"$execdir/$cookie.id")) { |
|
while (my $line = <$fh>) { |
|
chomp($line); |
|
if ($line eq $lastentry) { |
|
$doupdate = 1; |
|
last; |
|
} |
|
} |
|
close($fh); |
|
} |
|
if ($doupdate) { |
|
if (open(my $fh,'>',"$execdir/$cookie.id")) { |
|
print $fh $clientname; |
|
close($fh); |
|
$updatedone = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ($updatedone) { |
|
&Reply($client, "ok\n", $userinput); |
|
} else { |
|
&Failure( $client, "error: ".($!+0)."file update failed ". |
|
"while attempting updatebalcookie\n", $userinput); |
|
} |
|
return 1; |
|
} |
|
®ister_handler("updatebalcookie", \&update_balcookie_handler, 0, 1, 0); |
|
|
|
# |
# Process the delbalcookie command. This command deletes a balancer |
# Process the delbalcookie command. This command deletes a balancer |
# cookie in the lonBalancedir directory created by switchserver |
# cookie in the lonBalancedir directory on a load balancer node. |
# |
# |
# Parameters: |
# Parameters: |
# $cmd - Command that got us here. |
# $cmd - Command that got us here. |
Line 5204 sub del_balcookie_handler {
|
Line 5285 sub del_balcookie_handler {
|
my $userinput= "$cmd:$cookie"; |
my $userinput= "$cmd:$cookie"; |
|
|
chomp($cookie); |
chomp($cookie); |
|
$cookie = &unescape($cookie); |
my $deleted = ''; |
my $deleted = ''; |
if ($cookie =~ /^$LONCAPA::match_domain\_$LONCAPA::match_username\_[a-f0-9]{32}$/) { |
if ($cookie =~ /^$LONCAPA::match_domain\_$LONCAPA::match_username\_[a-f0-9]{32}$/) { |
my $execdir=$perlvar{'lonBalanceDir'}; |
my $execdir=$perlvar{'lonBalanceDir'}; |
Line 5670 sub auto_export_grades_handler {
|
Line 5752 sub auto_export_grades_handler {
|
return 1; |
return 1; |
} |
} |
®ister_handler("autoexportgrades", \&auto_export_grades_handler, |
®ister_handler("autoexportgrades", \&auto_export_grades_handler, |
0, 1, 0); |
1, 1, 0); |
|
|
|
|
# Retrieve and remove temporary files created by/during autoenrollment. |
# Retrieve and remove temporary files created by/during autoenrollment. |