version 1.977, 2008/12/09 11:32:03
|
version 1.983, 2009/01/02 23:07:49
|
Line 181 sub create_connection {
|
Line 181 sub create_connection {
|
return 0; |
return 0; |
} |
} |
|
|
|
sub get_server_timezone { |
|
my ($cnum,$cdom) = @_; |
|
my $home=&homeserver($cnum,$cdom); |
|
if ($home ne 'no_host') { |
|
my $cachetime = 24*3600; |
|
my ($timezone,$cached)=&is_cached_new('servertimezone',$home); |
|
if (defined($cached)) { |
|
return $timezone; |
|
} else { |
|
my $timezone = &reply('servertimezone',$home); |
|
return &do_cache_new('servertimezone',$home,$timezone,$cachetime); |
|
} |
|
} |
|
} |
|
|
# -------------------------------------------------- Non-critical communication |
# -------------------------------------------------- Non-critical communication |
sub subreply { |
sub subreply { |
Line 525 sub delenv {
|
Line 539 sub delenv {
|
tie(my %disk_env,'GDBM_File',$env{'user.environment'}, |
tie(my %disk_env,'GDBM_File',$env{'user.environment'}, |
(&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) { |
(&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) { |
foreach my $key (keys(%disk_env)) { |
foreach my $key (keys(%disk_env)) { |
if ($key=~/^$delthis/) { |
if ($key=~/^\Q$delthis\E/) { |
delete($env{$key}); |
delete($env{$key}); |
delete($disk_env{$key}); |
delete($disk_env{$key}); |
} |
} |
Line 1231 sub inst_userrules {
|
Line 1245 sub inst_userrules {
|
sub get_domain_defaults { |
sub get_domain_defaults { |
my ($domain) = @_; |
my ($domain) = @_; |
my $cachetime = 60*60*24; |
my $cachetime = 60*60*24; |
my ($defauthtype,$defautharg,$deflang,%deftools); |
|
my ($result,$cached)=&is_cached_new('domdefaults',$domain); |
my ($result,$cached)=&is_cached_new('domdefaults',$domain); |
if (defined($cached)) { |
if (defined($cached)) { |
if (ref($result) eq 'HASH') { |
if (ref($result) eq 'HASH') { |
Line 1245 sub get_domain_defaults {
|
Line 1258 sub get_domain_defaults {
|
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; |
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; |
$domdefaults{'auth_def'} = $domconfig{'defaults'}{'auth_def'}; |
$domdefaults{'auth_def'} = $domconfig{'defaults'}{'auth_def'}; |
$domdefaults{'auth_arg_def'} = $domconfig{'defaults'}{'auth_arg_def'}; |
$domdefaults{'auth_arg_def'} = $domconfig{'defaults'}{'auth_arg_def'}; |
|
$domdefaults{'timezone_def'} = $domconfig{'defaults'}{'timezone_def'}; |
|
$domdefaults{'datelocale_def'} = $domconfig{'defaults'}{'datelocale_def'} |
} else { |
} else { |
$domdefaults{'lang_def'} = &domain($domain,'lang_def'); |
$domdefaults{'lang_def'} = &domain($domain,'lang_def'); |
$domdefaults{'auth_def'} = &domain($domain,'auth_def'); |
$domdefaults{'auth_def'} = &domain($domain,'auth_def'); |
Line 1791 sub ssi_body {
|
Line 1806 sub ssi_body {
|
} |
} |
my $output=''; |
my $output=''; |
my $response; |
my $response; |
if ($filelink=~/^http\:/) { |
if ($filelink=~/^https?\:/) { |
($output,$response)=&externalssi($filelink); |
($output,$response)=&externalssi($filelink); |
} else { |
} else { |
($output,$response)=&ssi($filelink,%form); |
($output,$response)=&ssi($filelink,%form); |
Line 4406 sub is_portfolio_file {
|
Line 4421 sub is_portfolio_file {
|
} |
} |
|
|
sub usertools_access { |
sub usertools_access { |
my ($uname,$udom,$tool) = @_; |
my ($uname,$udom,$tool,$action) = @_; |
my $access; |
my $access; |
my %tools = ( |
my %tools = ( |
aboutme => 1, |
aboutme => 1, |
Line 4420 sub usertools_access {
|
Line 4435 sub usertools_access {
|
$uname = $env{'user.name'}; |
$uname = $env{'user.name'}; |
} |
} |
|
|
my $hashid=$uname.':'.$udom; |
if (($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) { |
my ($result,$cached) = &is_cached_new('usertools.'.$tool,$hashid); |
if ($action ne 'reload') { |
if (defined($cached)) { |
return $env{'environment.availabletools.'.$tool}; |
return $result; |
} |
} |
} |
|
|
my ($toolstatus,$inststatus); |
my ($toolstatus,$inststatus); |
Line 4443 sub usertools_access {
|
Line 4458 sub usertools_access {
|
} else { |
} else { |
$access = 0; |
$access = 0; |
} |
} |
&do_cache_new('usertools.'.$tool,$hashid,$access,600); |
|
return $access; |
return $access; |
} |
} |
|
|
Line 4457 sub usertools_access {
|
Line 4471 sub usertools_access {
|
} else { |
} else { |
$access = 0; |
$access = 0; |
} |
} |
&do_cache_new('usertools.'.$tool,$hashid,$access,600); |
|
return $access; |
return $access; |
} |
} |
} |
} |
Line 4478 sub usertools_access {
|
Line 4491 sub usertools_access {
|
} elsif ($hasnoaccess) { |
} elsif ($hasnoaccess) { |
$access = 0; |
$access = 0; |
} |
} |
&do_cache_new('usertools.'.$tool,$hashid,$access,600); |
|
return $access; |
return $access; |
} |
} |
} else { |
} else { |
Line 4488 sub usertools_access {
|
Line 4500 sub usertools_access {
|
} elsif ($domdef{$tool}{'default'} == 0) { |
} elsif ($domdef{$tool}{'default'} == 0) { |
$access = 0; |
$access = 0; |
} |
} |
&do_cache_new('usertools.'.$tool,$hashid,$access,600); |
|
return $access; |
return $access; |
} |
} |
} |
} |
} else { |
} else { |
$access = 1; |
$access = 1; |
&do_cache_new('usertools.'.$tool,$hashid,$access,600); |
|
return $access; |
return $access; |
} |
} |
} |
} |
Line 8337 sub repcopy_userfile {
|
Line 8347 sub repcopy_userfile {
|
if (-e $transferfile) { return 'ok'; } |
if (-e $transferfile) { return 'ok'; } |
my $request; |
my $request; |
$uri=~s/^\///; |
$uri=~s/^\///; |
$request=new HTTP::Request('GET','http://'.&hostname(&homeserver($cnum,$cdom)).'/raw/'.$uri); |
my $homeserver = &homeserver($cnum,$cdom); |
|
my $protocol = $protocol{$homeserver}; |
|
$protocol = 'http' if ($protocol ne 'https'); |
|
$request=new HTTP::Request('GET',$protocol.'://'.&hostname($homeserver).'/raw/'.$uri); |
my $response=$ua->request($request,$transferfile); |
my $response=$ua->request($request,$transferfile); |
# did it work? |
# did it work? |
if ($response->is_error()) { |
if ($response->is_error()) { |
Line 8352 sub repcopy_userfile {
|
Line 8365 sub repcopy_userfile {
|
|
|
sub tokenwrapper { |
sub tokenwrapper { |
my $uri=shift; |
my $uri=shift; |
$uri=~s|^http\://([^/]+)||; |
$uri=~s|^https?\://([^/]+)||; |
$uri=~s|^/||; |
$uri=~s|^/||; |
$env{'user.environment'}=~/\/([^\/]+)\.id/; |
$env{'user.environment'}=~/\/([^\/]+)\.id/; |
my $token=$1; |
my $token=$1; |
Line 8360 sub tokenwrapper {
|
Line 8373 sub tokenwrapper {
|
if ($udom && $uname && $file) { |
if ($udom && $uname && $file) { |
$file=~s|(\?\.*)*$||; |
$file=~s|(\?\.*)*$||; |
&appenv({"userfile.$udom/$uname/$file" => $env{'request.course.id'}}); |
&appenv({"userfile.$udom/$uname/$file" => $env{'request.course.id'}}); |
return 'http://'.&hostname(&homeserver($uname,$udom)).'/'.$uri. |
my $homeserver = &homeserver($uname,$udom); |
|
my $protocol = $protocol{$homeserver}; |
|
$protocol = 'http' if ($protocol ne 'https'); |
|
return $protocol.'://'.&hostname($homeserver).'/'.$uri. |
(($uri=~/\?/)?'&':'?').'token='.$token. |
(($uri=~/\?/)?'&':'?').'token='.$token. |
'&tokenissued='.$perlvar{'lonHostID'}; |
'&tokenissued='.$perlvar{'lonHostID'}; |
} else { |
} else { |
Line 8375 sub tokenwrapper {
|
Line 8391 sub tokenwrapper {
|
sub getuploaded { |
sub getuploaded { |
my ($reqtype,$uri,$cdom,$cnum,$info,$rtncode) = @_; |
my ($reqtype,$uri,$cdom,$cnum,$info,$rtncode) = @_; |
$uri=~s/^\///; |
$uri=~s/^\///; |
$uri = 'http://'.&hostname(&homeserver($cnum,$cdom)).'/raw/'.$uri; |
my $homeserver = &homeserver($cnum,$cdom); |
|
my $protocol = $protocol{$homeserver}; |
|
$protocol = 'http' if ($protocol ne 'https'); |
|
$uri = $protocol.'://'.&hostname($homeserver).'/raw/'.$uri; |
my $ua=new LWP::UserAgent; |
my $ua=new LWP::UserAgent; |
my $request=new HTTP::Request($reqtype,$uri); |
my $request=new HTTP::Request($reqtype,$uri); |
my $response=$ua->request($request); |
my $response=$ua->request($request); |
Line 8457 sub filelocation {
|
Line 8476 sub filelocation {
|
|
|
sub hreflocation { |
sub hreflocation { |
my ($dir,$file)=@_; |
my ($dir,$file)=@_; |
unless (($file=~m-^http://-i) || ($file=~m-^/-)) { |
unless (($file=~m-^https?\://-i) || ($file=~m-^/-)) { |
$file=filelocation($dir,$file); |
$file=filelocation($dir,$file); |
} elsif ($file=~m-^/adm/-) { |
} elsif ($file=~m-^/adm/-) { |
$file=~s-^/adm/wrapper/-/-; |
$file=~s-^/adm/wrapper/-/-; |
Line 8653 sub get_dns {
|
Line 8672 sub get_dns {
|
open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab"); |
open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab"); |
foreach my $dns (<$config>) { |
foreach my $dns (<$config>) { |
next if ($dns !~ /^\^(\S*)/x); |
next if ($dns !~ /^\^(\S*)/x); |
$alldns{$1} = 1; |
my $line = $1; |
|
my ($host,$protocol) = split(/:/,$line); |
|
if ($protocol ne 'https') { |
|
$protocol = 'http'; |
|
} |
|
$alldns{$host} = $protocol; |
} |
} |
while (%alldns) { |
while (%alldns) { |
my ($dns) = keys(%alldns); |
my ($dns) = keys(%alldns); |
delete($alldns{$dns}); |
|
my $ua=new LWP::UserAgent; |
my $ua=new LWP::UserAgent; |
my $request=new HTTP::Request('GET',"http://$dns$url"); |
my $request=new HTTP::Request('GET',"$alldns{$dns}://$dns$url"); |
my $response=$ua->request($request); |
my $response=$ua->request($request); |
|
delete($alldns{$dns}); |
next if ($response->is_error()); |
next if ($response->is_error()); |
my @content = split("\n",$response->content); |
my @content = split("\n",$response->content); |
&Apache::lonnet::do_cache_new('dns',$url,\@content,30*24*60*60); |
&Apache::lonnet::do_cache_new('dns',$url,\@content,30*24*60*60); |