version 1.1150, 2011/12/20 22:40:06
|
version 1.1158, 2012/03/14 20:53:50
|
Line 595 sub transfer_profile_to_env {
|
Line 595 sub transfer_profile_to_env {
|
|
|
# ---------------------------------------------------- Check for valid session |
# ---------------------------------------------------- Check for valid session |
sub check_for_valid_session { |
sub check_for_valid_session { |
my ($r) = @_; |
my ($r,$name) = @_; |
my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); |
my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); |
my $lonid=$cookies{'lonID'}; |
if ($name eq '') { |
|
$name = 'lonID'; |
|
} |
|
my $lonid=$cookies{$name}; |
return undef if (!$lonid); |
return undef if (!$lonid); |
|
|
my $handle=&LONCAPA::clean_handle($lonid->value); |
my $handle=&LONCAPA::clean_handle($lonid->value); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir; |
|
if ($name eq 'lonDAV') { |
|
$lonidsdir=$r->dir_config('lonDAVsessDir'); |
|
} else { |
|
$lonidsdir=$r->dir_config('lonIDsDir'); |
|
} |
return undef if (!-e "$lonidsdir/$handle.id"); |
return undef if (!-e "$lonidsdir/$handle.id"); |
|
|
my $opened = open(my $idf,'+<',"$lonidsdir/$handle.id"); |
my $opened = open(my $idf,'+<',"$lonidsdir/$handle.id"); |
Line 930 sub choose_server {
|
Line 938 sub choose_server {
|
my %domconfhash = &Apache::loncommon::get_domainconf($udom); |
my %domconfhash = &Apache::loncommon::get_domainconf($udom); |
my %servers = &get_servers($udom); |
my %servers = &get_servers($udom); |
my $lowest_load = 30000; |
my $lowest_load = 30000; |
my ($login_host,$hostname,$portal_path); |
my ($login_host,$hostname,$portal_path,$isredirect); |
foreach my $lonhost (keys(%servers)) { |
foreach my $lonhost (keys(%servers)) { |
my $loginvia; |
my $loginvia; |
if ($checkloginvia) { |
if ($checkloginvia) { |
Line 941 sub choose_server {
|
Line 949 sub choose_server {
|
&compare_server_load($server, $login_host, $lowest_load); |
&compare_server_load($server, $login_host, $lowest_load); |
if ($login_host eq $server) { |
if ($login_host eq $server) { |
$portal_path = $path; |
$portal_path = $path; |
|
$isredirect = 1; |
} |
} |
} else { |
} else { |
($login_host, $lowest_load) = |
($login_host, $lowest_load) = |
&compare_server_load($lonhost, $login_host, $lowest_load); |
&compare_server_load($lonhost, $login_host, $lowest_load); |
if ($login_host eq $lonhost) { |
if ($login_host eq $lonhost) { |
$portal_path = ''; |
$portal_path = ''; |
|
$isredirect = ''; |
} |
} |
} |
} |
} else { |
} else { |
Line 957 sub choose_server {
|
Line 967 sub choose_server {
|
if ($login_host ne '') { |
if ($login_host ne '') { |
$hostname = &hostname($login_host); |
$hostname = &hostname($login_host); |
} |
} |
return ($login_host,$hostname,$portal_path); |
return ($login_host,$hostname,$portal_path,$isredirect); |
} |
} |
|
|
# --------------------------------------------- Try to change a user's password |
# --------------------------------------------- Try to change a user's password |
Line 2799 sub resizeImage {
|
Line 2809 sub resizeImage {
|
# $resizewidth - width (pixels) to which to resize uploaded image |
# $resizewidth - width (pixels) to which to resize uploaded image |
# $resizeheight - height (pixels) to which to resize uploaded image |
# $resizeheight - height (pixels) to which to resize uploaded image |
# $mimetype - reference to scalar to accommodate mime type determined |
# $mimetype - reference to scalar to accommodate mime type determined |
# from File::MMagic if $parser = parse. |
# from File::MMagic. |
# |
# |
# output: url of file in userspace, or error: <message> |
# output: url of file in userspace, or error: <message> |
# or /adm/notfound.html if failure to upload occurse |
# or /adm/notfound.html if failure to upload occurse |
Line 2968 sub finishuserfileupload {
|
Line 2978 sub finishuserfileupload {
|
} |
} |
} |
} |
} |
} |
|
if (($context eq 'coursedoc') || ($parser eq 'parse')) { |
|
if (ref($mimetype)) { |
|
if ($$mimetype eq '') { |
|
my $mm = new File::MMagic; |
|
my $type = $mm->checktype_filename($filepath.'/'.$file); |
|
$$mimetype = $type; |
|
} |
|
} |
|
} |
if ($parser eq 'parse') { |
if ($parser eq 'parse') { |
my $mm = new File::MMagic; |
if ((ref($mimetype)) && ($$mimetype eq 'text/html')) { |
my $type = $mm->checktype_filename($filepath.'/'.$file); |
|
if ($type eq 'text/html') { |
|
my $parse_result = &extract_embedded_items($filepath.'/'.$file, |
my $parse_result = &extract_embedded_items($filepath.'/'.$file, |
$allfiles,$codebase); |
$allfiles,$codebase); |
unless ($parse_result eq 'ok') { |
unless ($parse_result eq 'ok') { |
Line 2979 sub finishuserfileupload {
|
Line 2996 sub finishuserfileupload {
|
' for embedded media: '.$parse_result); |
' for embedded media: '.$parse_result); |
} |
} |
} |
} |
if (ref($mimetype)) { |
|
$$mimetype = $type; |
|
} |
|
} |
} |
if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) { |
if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) { |
my $input = $filepath.'/'.$file; |
my $input = $filepath.'/'.$file; |
Line 3252 sub flushcourselogs {
|
Line 3266 sub flushcourselogs {
|
my $result = &inc('nohist_accesscount',\%temphash,$dom,$name); |
my $result = &inc('nohist_accesscount',\%temphash,$dom,$name); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
delete $accesshash{$entry}; |
delete $accesshash{$entry}; |
} elsif ($result eq 'unknown_cmd') { |
|
# Target server has old code running on it. |
|
my %temphash=($entry => $value); |
|
if (&put('nohist_resevaldata',\%temphash,$dom,$name) eq 'ok') { |
|
delete $accesshash{$entry}; |
|
} |
|
} |
} |
} else { |
} else { |
my ($dom,$name) = ($entry=~m{___($match_domain)/($match_name)/(.*)___(\w+)$}); |
my ($dom,$name) = ($entry=~m{___($match_domain)/($match_name)/(.*)___(\w+)$}); |
Line 3371 sub countacc {
|
Line 3379 sub countacc {
|
my $url=&declutter(shift); |
my $url=&declutter(shift); |
return if (! defined($url) || $url eq ''); |
return if (! defined($url) || $url eq ''); |
unless ($env{'request.course.id'}) { return ''; } |
unless ($env{'request.course.id'}) { return ''; } |
|
# |
|
# Mark that this url was used in this course |
|
# |
$accesshash{$env{'request.course.id'}.'___'.$url.'___course'}=1; |
$accesshash{$env{'request.course.id'}.'___'.$url.'___course'}=1; |
|
# |
|
# Increase the access count for this resource in this child process |
|
# |
my $key=$$.$processmarker.'_'.$dumpcount.'___'.$url.'___count'; |
my $key=$$.$processmarker.'_'.$dumpcount.'___'.$url.'___count'; |
$accesshash{$key}++; |
$accesshash{$key}++; |
} |
} |
Line 3852 sub get_domain_roles {
|
Line 3866 sub get_domain_roles {
|
|
|
# ----------------------------------------------------------- Interval timing |
# ----------------------------------------------------------- Interval timing |
|
|
|
{ |
|
# Caches needed for speedup of navmaps |
|
# We don't want to cache this for very long at all (5 seconds at most) |
|
# |
|
# The user for whom we cache |
|
my $cachedkey=''; |
|
# The cached times for this user |
|
my %cachedtimes=(); |
|
# When this was last done |
|
my $cachedtime=(); |
|
|
|
sub load_all_first_access { |
|
my ($uname,$udom)=@_; |
|
if (($cachedkey eq $uname.':'.$udom) && |
|
(abs($cachedtime-time)<5)) { |
|
return; |
|
} |
|
$cachedtime=time; |
|
$cachedkey=$uname.':'.$udom; |
|
%cachedtimes=&dump('firstaccesstimes',$udom,$uname); |
|
} |
|
|
sub get_first_access { |
sub get_first_access { |
my ($type,$argsymb)=@_; |
my ($type,$argsymb)=@_; |
my ($symb,$courseid,$udom,$uname)=&whichuser(); |
my ($symb,$courseid,$udom,$uname)=&whichuser(); |
Line 3864 sub get_first_access {
|
Line 3900 sub get_first_access {
|
} else { |
} else { |
$res=$symb; |
$res=$symb; |
} |
} |
my %times=&get('firstaccesstimes',["$courseid\0$res"],$udom,$uname); |
&load_all_first_access($uname,$udom); |
return $times{"$courseid\0$res"}; |
return $cachedtimes{"$courseid\0$res"}; |
} |
} |
|
|
sub set_first_access { |
sub set_first_access { |
Line 3879 sub set_first_access {
|
Line 3915 sub set_first_access {
|
} else { |
} else { |
$res=$symb; |
$res=$symb; |
} |
} |
|
$cachedkey=''; |
my $firstaccess=&get_first_access($type,$symb); |
my $firstaccess=&get_first_access($type,$symb); |
if (!$firstaccess) { |
if (!$firstaccess) { |
return &put('firstaccesstimes',{"$courseid\0$res"=>time},$udom,$uname); |
return &put('firstaccesstimes',{"$courseid\0$res"=>time},$udom,$uname); |
} |
} |
return 'already_set'; |
return 'already_set'; |
} |
} |
|
} |
# --------------------------------------------- Set Expire Date for Spreadsheet |
# --------------------------------------------- Set Expire Date for Spreadsheet |
|
|
sub expirespread { |
sub expirespread { |