fix for bug 1771: Template errors with remote itemtype image
[koha.git] / members / patronimage.pl
blob92b861206065596f60ce3060d754bcad96d5d1ee
1 #!/usr/bin/perl
3 # Copyright 2008 Foundations Bible College & Seminary Inc.
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
23 use strict;
24 use CGI; #qw(:standard escapeHTML);
25 use C4::Context;
26 use C4::Members;
28 $|=1;
30 my $DEBUG = 0;
31 my $data = new CGI;
32 my $cardnumber;
34 =head1 NAME
36 patronimage.pl - Script for retrieving and formating Koha patron images for display
38 =head1 SYNOPSIS
40 <img src="patronimage.pl?crdnum= />
42 =head1 DESCRIPTION
44 This script, when called from within HTML and passed a valid patron cardnumber, will retrieve the image data associated with that cardnumber if one exists, format it in proper HTML format and pass it back to be displayed.
46 =cut
48 if ($data->param('crdnum')) {
49 $cardnumber = $data->param('crdnum');
50 } else {
51 $cardnumber = shift;
55 warn "Cardnumber passed in: $cardnumber" if $DEBUG;
57 my ($imagedata, $dberror) = GetPatronImage($cardnumber);
59 if ($dberror) {
60 warn "Database Error!";
61 exit;
64 # NOTE: Never dump the contents of $imagedata->{'patronimage'} via a warn to a log or nasty
65 # things will result... you have been warned!
67 if ($imagedata) {
68 print $data->header (-type => $imagedata->{'mimetype'}, -'Cache-Control' => 'no-store', -Content_Length => length ($imagedata->{'imagefile'})), $imagedata->{'imagefile'};
69 exit;
70 } else {
71 warn "No image exists for $cardnumber";
72 exit;
75 exit;
77 =back
79 =head1 AUTHOR
81 Chris Nighswonger cnighswonger <at> foundations <dot> edu
83 =cut