version 1.518, 2016/02/17 19:15:44
|
version 1.522, 2016/05/30 03:16:38
|
Line 2496 sub remove_user_file_handler {
|
Line 2496 sub remove_user_file_handler {
|
if (-e $file) { |
if (-e $file) { |
# |
# |
# If the file is a regular file unlink is fine... |
# If the file is a regular file unlink is fine... |
# However it's possible the client wants a dir. |
# However it's possible the client wants a dir |
# removed, in which case rmdir is more approprate: |
# removed, in which case rmdir is more appropriate. |
|
# Note: rmdir will only remove an empty directory. |
# |
# |
if (-f $file){ |
if (-f $file){ |
unlink($file); |
unlink($file); |
|
# for html files remove the associated .bak file |
|
# which may have been created by the editor. |
|
if ($ufile =~ m{^((docs|supplemental)/(?:\d+|default)/\d+(?:|/.+)/)[^/]+\.x?html?$}i) { |
|
my $path = $1; |
|
if (-e $file.'.bak') { |
|
unlink($file.'.bak'); |
|
} |
|
} |
} elsif(-d $file) { |
} elsif(-d $file) { |
rmdir($file); |
rmdir($file); |
} |
} |
Line 5453 sub create_auto_enroll_password_handler
|
Line 5462 sub create_auto_enroll_password_handler
|
®ister_handler("autocreatepassword", \&create_auto_enroll_password_handler, |
®ister_handler("autocreatepassword", \&create_auto_enroll_password_handler, |
0, 1, 0); |
0, 1, 0); |
|
|
|
sub auto_export_grades_handler { |
|
my ($cmd, $tail, $client) = @_; |
|
my $userinput = "$cmd:$tail"; |
|
my ($cdom,$cnum,$info,$data) = split(/:/,$tail); |
|
my $inforef = &Apache::lonnet::thaw_unescape($info); |
|
my $dataref = &Apache::lonnet::thaw_unescape($data); |
|
my ($outcome,$result);; |
|
eval { |
|
local($SIG{__DIE__})='DEFAULT'; |
|
my %rtnhash; |
|
$outcome=&localenroll::export_grades($cdom,$cnum,$inforef,$dataref,\%rtnhash); |
|
if ($outcome eq 'ok') { |
|
foreach my $key (keys(%rtnhash)) { |
|
$result .= &escape($key).'='.&Apache::lonnet::freeze_escape($rtnhash{$key}).'&'; |
|
} |
|
$result =~ s/\&$//; |
|
} |
|
}; |
|
if (!$@) { |
|
if ($outcome eq 'ok') { |
|
if ($cipher) { |
|
my $cmdlength=length($result); |
|
$result.=" "; |
|
my $encresult=''; |
|
for (my $encidx=0;$encidx<=$cmdlength;$encidx+=8) { |
|
$encresult.= unpack("H16", |
|
$cipher->encrypt(substr($result, |
|
$encidx, |
|
8))); |
|
} |
|
&Reply( $client, "enc:$cmdlength:$encresult\n", $userinput); |
|
} else { |
|
&Failure( $client, "error:no_key\n", $userinput); |
|
} |
|
} else { |
|
&Reply($client, "$outcome\n", $userinput); |
|
} |
|
} else { |
|
&Failure($client,"export_error\n",$userinput); |
|
} |
|
return 1; |
|
} |
|
®ister_handler("autoexportgrades", \&auto_export_grades_handler, |
|
0, 1, 0); |
|
|
# Retrieve and remove temporary files created by/during autoenrollment. |
# Retrieve and remove temporary files created by/during autoenrollment. |
# |
# |
# Formal Parameters: |
# Formal Parameters: |
Line 5473 sub retrieve_auto_file_handler {
|
Line 5527 sub retrieve_auto_file_handler {
|
my ($filename) = split(/:/, $tail); |
my ($filename) = split(/:/, $tail); |
|
|
my $source = $perlvar{'lonDaemons'}.'/tmp/'.$filename; |
my $source = $perlvar{'lonDaemons'}.'/tmp/'.$filename; |
if ( (-e $source) && ($filename ne '') ) { |
|
|
if ($filename =~m{/\.\./}) { |
|
&Failure($client, "refused\n", $userinput); |
|
} elsif ( (-e $source) && ($filename ne '') ) { |
my $reply = ''; |
my $reply = ''; |
if (open(my $fh,$source)) { |
if (open(my $fh,$source)) { |
while (<$fh>) { |
while (<$fh>) { |
Line 5505 sub crsreq_checks_handler {
|
Line 5562 sub crsreq_checks_handler {
|
my $userinput = "$cmd:$tail"; |
my $userinput = "$cmd:$tail"; |
my $dom = $tail; |
my $dom = $tail; |
my $result; |
my $result; |
my @reqtypes = ('official','unofficial','community','textbook'); |
my @reqtypes = ('official','unofficial','community','textbook','placement'); |
eval { |
eval { |
local($SIG{__DIE__})='DEFAULT'; |
local($SIG{__DIE__})='DEFAULT'; |
my %validations; |
my %validations; |