Lines 75-87
$debug and warn "Operation requested: $op";
Link Here
|
75 |
my ( $total, $handled, @counts, $tempfile, $tfh, %errors ); |
75 |
my ( $total, $handled, @counts, $tempfile, $tfh, %errors ); |
76 |
|
76 |
|
77 |
# Case is important in these operational values as the template must use case to be visually pleasing! |
77 |
# Case is important in these operational values as the template must use case to be visually pleasing! |
78 |
if ( ( $op eq 'Upload' ) && $uploadfile ) { |
78 |
if ( (( $op eq 'Upload' ) && $uploadfile) || |
|
|
79 |
( $op eq 'Capture' ) ) { |
79 |
my $dirname = File::Temp::tempdir( CLEANUP => 1 ); |
80 |
my $dirname = File::Temp::tempdir( CLEANUP => 1 ); |
80 |
$debug and warn "dirname = $dirname"; |
81 |
$debug and warn "dirname = $dirname"; |
81 |
my $filesuffix; |
82 |
my $filesuffix; |
82 |
if ( $uploadfilename =~ m/(\..+)$/i ) { |
83 |
if ( $uploadfilename =~ m/(\..+)$/i ) { |
83 |
$filesuffix = $1; |
84 |
$filesuffix = $1; |
84 |
} |
85 |
} |
|
|
86 |
if ( $op eq 'Capture' ) { |
87 |
$filesuffix = '.jpeg'; |
88 |
} |
85 |
( $tfh, $tempfile ) = |
89 |
( $tfh, $tempfile ) = |
86 |
File::Temp::tempfile( SUFFIX => $filesuffix, UNLINK => 1 ); |
90 |
File::Temp::tempfile( SUFFIX => $filesuffix, UNLINK => 1 ); |
87 |
$debug and warn "tempfile = $tempfile"; |
91 |
$debug and warn "tempfile = $tempfile"; |
Lines 90-106
if ( ( $op eq 'Upload' ) && $uploadfile ) {
Link Here
|
90 |
$errors{'NOTZIP'} = 1 |
94 |
$errors{'NOTZIP'} = 1 |
91 |
if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i ); |
95 |
if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i ); |
92 |
$errors{'NOWRITETEMP'} = 1 unless ( -w $dirname ); |
96 |
$errors{'NOWRITETEMP'} = 1 unless ( -w $dirname ); |
93 |
$errors{'EMPTYUPLOAD'} = 1 unless ( length($uploadfile) > 0 ); |
97 |
$errors{'EMPTYUPLOAD'} = 1 unless ( |
|
|
98 |
(defined($uploadfile) && length($uploadfile) > 0) || |
99 |
$op eq 'Capture' ); |
94 |
|
100 |
|
95 |
if (%errors) { |
101 |
if (%errors) { |
96 |
$template->param( ERRORS => [ \%errors ] ); |
102 |
$template->param( ERRORS => [ \%errors ] ); |
97 |
output_html_with_http_headers $input, $cookie, $template->output; |
103 |
output_html_with_http_headers $input, $cookie, $template->output; |
98 |
exit; |
104 |
exit; |
99 |
} |
105 |
} |
100 |
while (<$uploadfile>) { |
106 |
if ( $op eq 'Upload' ) { |
101 |
print $tfh $_; |
107 |
while (<$uploadfile>) { |
|
|
108 |
print $tfh $_; |
109 |
} |
110 |
close $tfh; |
111 |
} |
112 |
elsif ( $op eq 'Capture' ) { |
113 |
close $tfh; |
114 |
system('/usr/bin/streamer -o ' . $tempfile); |
102 |
} |
115 |
} |
103 |
close $tfh; |
|
|
104 |
if ( $filetype eq 'zip' ) { |
116 |
if ( $filetype eq 'zip' ) { |
105 |
unless ( system( "unzip", $tempfile, '-d', $dirname ) == 0 ) { |
117 |
unless ( system( "unzip", $tempfile, '-d', $dirname ) == 0 ) { |
106 |
$errors{'UZIPFAIL'} = $uploadfilename; |
118 |
$errors{'UZIPFAIL'} = $uploadfilename; |
Lines 157-163
elsif ( ( $op eq 'Upload' ) && !$uploadfile ) {
Link Here
|
157 |
$template->param( filetype => $filetype ); |
169 |
$template->param( filetype => $filetype ); |
158 |
} |
170 |
} |
159 |
elsif ( $op eq 'Delete' ) { |
171 |
elsif ( $op eq 'Delete' ) { |
160 |
my $dberror = RmPatronImage($cardnumber); |
172 |
my $dberror = RmPatronImage($borrowernumber); |
161 |
$debug and warn "Patron image deleted for $cardnumber"; |
173 |
$debug and warn "Patron image deleted for $cardnumber"; |
162 |
warn "Database returned $dberror" if $dberror; |
174 |
warn "Database returned $dberror" if $dberror; |
163 |
} |
175 |
} |
164 |
- |
|
|