| 
      
            Lines 25-30
          use File::Temp;
      
      
        Link Here
      
     | 
  
        
          | 25 | 
          use File::Copy;  | 
          25 | 
          use File::Copy;  | 
        
        
          | 26 | 
          use CGI qw ( -utf8 );  | 
          26 | 
          use CGI qw ( -utf8 );  | 
        
        
          | 27 | 
          use GD;  | 
          27 | 
          use GD;  | 
        
            
               | 
               | 
              28 | 
              use MIME::Base64;  | 
            
        
          | 28 | 
          use C4::Context;  | 
          29 | 
          use C4::Context;  | 
        
        
          | 29 | 
          use C4::Auth;  | 
          30 | 
          use C4::Auth;  | 
        
        
          | 30 | 
          use C4::Output;  | 
          31 | 
          use C4::Output;  | 
        
  
    | 
      
            Lines 43-60
          unless (C4::Context->preference('patronimages')) {
      
      
        Link Here
      
     | 
  
        
          | 43 | 
              exit;  | 
          44 | 
              exit;  | 
        
        
          | 44 | 
          }  | 
          45 | 
          }  | 
        
        
          | 45 | 
           | 
          46 | 
           | 
        
          
            
              | 46 | 
              my ($template, $loggedinuser, $cookie)  | 
              47 | 
              my ($template, $loggedinuser, $cookie) = get_template_and_user(  | 
            
            
              | 47 | 
                  = get_template_and_user({template_name => "tools/picture-upload.tt", | 
              48 | 
                  { | 
            
            
              | 48 | 
              					query => $input,  | 
              49 | 
                      template_name => "tools/picture-upload.tt",  | 
            
            
              | 49 | 
              					type => "intranet",  | 
              50 | 
                      query => $input,  | 
            
            
              | 50 | 
              					authnotrequired => 0,  | 
              51 | 
                      type => "intranet",  | 
            
            
              | 51 | 
              					flagsrequired => { tools => 'batch_upload_patron_images'}, | 
              52 | 
                      authnotrequired => 0,  | 
            
            
              | 52 | 
              					debug => 0,  | 
              53 | 
                      flagsrequired => { tools => 'batch_upload_patron_images'}, | 
            
            
              | 53 | 
              					});  | 
              54 | 
                      debug => 0,  | 
            
            
               | 
               | 
              55 | 
                  }  | 
            
            
              | 56 | 
              );  | 
            
        
          | 54 | 
           | 
          57 | 
           | 
        
        
          | 55 | 
          our $filetype      = $input->param('filetype') || ''; | 
          58 | 
          our $filetype      = $input->param('filetype') || ''; | 
        
        
          | 56 | 
          my $cardnumber     = $input->param('cardnumber'); | 
          59 | 
          my $cardnumber     = $input->param('cardnumber'); | 
        
          
            
              | 57 | 
              our $uploadfilename = $input->param('uploadfile') || ''; | 
              60 | 
              our $uploadfilename = $input->param('uploadfile') || $input->param('uploadfilename') || ''; | 
            
            
               | 
               | 
              61 | 
              my $uploadfiletext = $input->param('uploadfiletext') || ''; | 
            
        
          | 58 | 
          my $uploadfile     = $input->upload('uploadfile'); | 
          62 | 
          my $uploadfile     = $input->upload('uploadfile'); | 
        
        
          | 59 | 
          my $borrowernumber = $input->param('borrowernumber'); | 
          63 | 
          my $borrowernumber = $input->param('borrowernumber'); | 
        
        
          | 60 | 
          my $op             = $input->param('op') || ''; | 
          64 | 
          my $op             = $input->param('op') || ''; | 
        
  
    | 
      
            Lines 87-93
          our @counts = ();
      
      
        Link Here
      
     | 
  
        
          | 87 | 
          our %errors = ();  | 
          91 | 
          our %errors = ();  | 
        
        
          | 88 | 
           | 
          92 | 
           | 
        
        
          | 89 | 
          # Case is important in these operational values as the template must use case to be visually pleasing!  | 
          93 | 
          # Case is important in these operational values as the template must use case to be visually pleasing!  | 
        
          
            
              | 90 | 
              if ( ( $op eq 'Upload' ) && $uploadfile ) { | 
              94 | 
              if ( ( $op eq 'Upload' ) && ($uploadfile || $uploadfiletext) ) { | 
            
        
          | 91 | 
           | 
          95 | 
           | 
        
        
          | 92 | 
              output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )  | 
          96 | 
              output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )  | 
        
        
          | 93 | 
                  unless Koha::Token->new->check_csrf({ | 
          97 | 
                  unless Koha::Token->new->check_csrf({ | 
        
  
    | 
      
            Lines 106-123
          if ( ( $op eq 'Upload' ) && $uploadfile ) {
      
      
        Link Here
      
     | 
  
        
          | 106 | 
              $debug and warn "tempfile = $tempfile";  | 
          110 | 
              $debug and warn "tempfile = $tempfile";  | 
        
        
          | 107 | 
              my ( @directories, $results );  | 
          111 | 
              my ( @directories, $results );  | 
        
        
          | 108 | 
           | 
          112 | 
           | 
        
            
              | 109 | 
                  $errors{'NOTZIP'} = 1 | 
               | 
               | 
            
            
              | 110 | 
                    if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i );  | 
            
        
          | 111 | 
              $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname ); | 
          113 | 
              $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname ); | 
        
          
            
              | 112 | 
                  $errors{'EMPTYUPLOAD'} = 1 unless ( length($uploadfile) > 0 ); | 
              114 | 
                  if ( length($uploadfiletext) == 0 ) { | 
            
            
               | 
               | 
              115 | 
                      $errors{'NOTZIP'} = 1 | 
            
            
              | 116 | 
                        if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i );  | 
            
            
              | 117 | 
                      $errors{'EMPTYUPLOAD'} = 1 unless ( length($uploadfile) > 0 ); | 
            
            
              | 118 | 
                  }  | 
            
        
          | 113 | 
           | 
          119 | 
           | 
        
        
          | 114 | 
              if (%errors) { | 
          120 | 
              if (%errors) { | 
        
        
          | 115 | 
                  $template->param( ERRORS => [ \%errors ] );  | 
          121 | 
                  $template->param( ERRORS => [ \%errors ] );  | 
        
        
          | 116 | 
                  output_html_with_http_headers $input, $cookie, $template->output;  | 
          122 | 
                  output_html_with_http_headers $input, $cookie, $template->output;  | 
        
        
          | 117 | 
                  exit;  | 
          123 | 
                  exit;  | 
        
        
          | 118 | 
              }  | 
          124 | 
              }  | 
        
          
            
              | 119 | 
                  while (<$uploadfile>) { | 
              125 | 
               | 
            
            
              | 120 | 
                      print $tfh $_;  | 
              126 | 
                  if ( length($uploadfiletext) == 0 ) { | 
            
            
               | 
               | 
              127 | 
                      while (<$uploadfile>) { | 
            
            
              | 128 | 
                          print $tfh $_;  | 
            
            
              | 129 | 
                      }  | 
            
            
              | 130 | 
                  } else { | 
            
            
              | 131 | 
                      if ( $uploadfiletext =~ /data:image\/jpeg;base64,(.*)/ ) { | 
            
            
              | 132 | 
                          my $encoded_picture = $1;  | 
            
            
              | 133 | 
                          my $decoded_picture = decode_base64($encoded_picture);  | 
            
            
              | 134 | 
                          print $tfh $decoded_picture;  | 
            
            
              | 135 | 
                      } else { | 
            
            
              | 136 | 
                          $errors{'BADPICTUREDATA'} = 1; | 
            
            
              | 137 | 
                          $template->param( ERRORS => [ \%errors ] );  | 
            
            
              | 138 | 
                          output_html_with_http_headers $input, $cookie, $template->output;  | 
            
            
              | 139 | 
                          exit;  | 
            
            
              | 140 | 
                      }  | 
            
        
          | 121 | 
              }  | 
          141 | 
              }  | 
        
        
          | 122 | 
              close $tfh;  | 
          142 | 
              close $tfh;  | 
        
        
          | 123 | 
              if ( $filetype eq 'zip' ) { | 
          143 | 
              if ( $filetype eq 'zip' ) { | 
        
            
              | 124 | 
              -   | 
               | 
               |