Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.976 and 1.977

version 1.976, 2008/12/08 23:00:47 version 1.977, 2008/12/09 11:32:03
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 2011  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 2137  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,

Removed from v.1.976  
changed lines
  Added in v.1.977


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>