version 1.976.2.7, 2009/03/20 21:18:26
|
version 1.981, 2008/12/21 19:03:10
|
Line 73 package Apache::lonnet;
|
Line 73 package Apache::lonnet;
|
use strict; |
use strict; |
use LWP::UserAgent(); |
use LWP::UserAgent(); |
use HTTP::Date; |
use HTTP::Date; |
|
use Image::Magick; |
|
|
# use Date::Parse; |
# use Date::Parse; |
use vars qw(%perlvar %spareid %pr %prp $memcache %packagetab $tmpdir |
use vars qw(%perlvar %spareid %pr %prp $memcache %packagetab $tmpdir |
$_64bit %env %protocol); |
$_64bit %env %protocol); |
Line 97 use LONCAPA::Configuration;
|
Line 99 use LONCAPA::Configuration;
|
my $readit; |
my $readit; |
my $max_connection_retries = 10; # Or some such value. |
my $max_connection_retries = 10; # Or some such value. |
|
|
|
my $upload_photo_form = 0; #Variable to check when user upload a photo 0=not 1=true |
|
|
require Exporter; |
require Exporter; |
|
|
our @ISA = qw (Exporter); |
our @ISA = qw (Exporter); |
Line 177 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 522 sub appenv {
|
Line 512 sub appenv {
|
# ----------------------------------------------------- Delete from Environment |
# ----------------------------------------------------- Delete from Environment |
|
|
sub delenv { |
sub delenv { |
my ($delthis,$regexp) = @_; |
my $delthis=shift; |
if (($delthis=~/user\.role/) || ($delthis=~/user\.priv/)) { |
if (($delthis=~/user\.role/) || ($delthis=~/user\.priv/)) { |
&logthis("<font color=\"blue\">WARNING: ". |
&logthis("<font color=\"blue\">WARNING: ". |
"Attempt to delete from environment ".$delthis); |
"Attempt to delete from environment ".$delthis); |
Line 535 sub delenv {
|
Line 525 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 ($regexp) { |
if ($key=~/^\Q$delthis\E/) { |
if ($key=~/^$delthis/) { |
delete($env{$key}); |
delete($env{$key}); |
delete($disk_env{$key}); |
delete($disk_env{$key}); |
} |
} |
|
} else { |
|
if ($key=~/^\Q$delthis\E/) { |
|
delete($env{$key}); |
|
delete($disk_env{$key}); |
|
} |
|
} |
|
} |
} |
untie(%disk_env); |
untie(%disk_env); |
} |
} |
Line 1248 sub inst_userrules {
|
Line 1231 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 1261 sub get_domain_defaults {
|
Line 1245 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 2033 sub clean_filename {
|
Line 2015 sub clean_filename {
|
return $fname; |
return $fname; |
} |
} |
|
|
|
#Wrapper function for userphotoupload |
|
sub userphotoupload |
|
{ |
|
my($formname,$subdir) = @_; |
|
$upload_photo_form = 1; |
|
return &userfileupload($formname,undef,$subdir); |
|
} |
|
|
# --------------- Take an uploaded file and put it into the userfiles directory |
# --------------- Take an uploaded file and put it into the userfiles directory |
# input: $formname - the contents of the file are in $env{"form.$formname"} |
# input: $formname - the contents of the file are in $env{"form.$formname"} |
# the desired filenam is in $env{"form.$formname.filename"} |
# the desired filenam is in $env{"form.$formname.filename"} |
Line 2159 sub finishuserfileupload {
|
Line 2149 sub finishuserfileupload {
|
return '/adm/notfound.html'; |
return '/adm/notfound.html'; |
} |
} |
close(FH); |
close(FH); |
|
if($upload_photo_form==1) |
|
{ |
|
my $ima = Image::Magick->new; |
|
$ima->Read($filepath.'/'.$file); |
|
if($ima->Get('width') > 300) |
|
{ |
|
my $factor = $ima->Get('width')/300; |
|
$ima->Scale( width=>300, height=>$ima->Get('height')/$factor ); |
|
} |
|
if($ima->Get('height') > 400) |
|
{ |
|
my $factor = $ima->Get('height')/400; |
|
$ima->Scale( width=>$ima->Get('width')/$factor, height=>400); |
|
} |
|
|
|
|
|
$ima->Write($filepath.'/'.$file); |
|
$upload_photo_form = 0; |
|
} |
} |
} |
if ($parser eq 'parse') { |
if ($parser eq 'parse') { |
my $parse_result = &extract_embedded_items($filepath.'/'.$file,$allfiles, |
my $parse_result = &extract_embedded_items($filepath.'/'.$file,$allfiles, |
Line 4414 sub usertools_access {
|
Line 4423 sub usertools_access {
|
if (($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) { |
if (($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) { |
if ($action ne 'reload') { |
if ($action ne 'reload') { |
return $env{'environment.availabletools.'.$tool}; |
return $env{'environment.availabletools.'.$tool}; |
} |
} |
} |
} |
|
|
my ($toolstatus,$inststatus); |
my ($toolstatus,$inststatus); |
Line 9235 in the user's environment.db and in %env
|
Line 9244 in the user's environment.db and in %env
|
|
|
=item * |
=item * |
X<delenv()> |
X<delenv()> |
B<delenv($delthis,$regexp)>: removes all items from the session |
B<delenv($regexp)>: removes all items from the session |
environment file that begin with $delthis. If the |
environment file that matches the regular expression in $regexp. The |
optional second arg - $regexp - is true, $delthis is treated as a |
values are also delted from the current processes %env. |
regular expression, otherwise \Q$delthis\E is used. |
|
The values are also deleted from the current processes %env. |
|
|
|
=item * get_env_multiple($name) |
=item * get_env_multiple($name) |
|
|