#!/usr/bin/perl # # $Id: imagepop.pl,v 1.3 2006/01/23 21:39:30 ddoughty Exp $ # # Source File: image.pl require 'sitecfg.pl'; require 'testlib.pl'; my $HBI_imagepop_Debug = 0 ; # 1 for debugging, 0 for production. &app_initialize; warn "debug image.pl Line " . __LINE__ . " FORM tid X$FORM{'tid'}X\n" if {$HBI_imagepop_Debug} ; warn "debug image.pl Line " . __LINE__ . " FORM img X$FORM{'img'}X\n" if {$HBI_imagepop_Debug} ; warn "debug image.pl Line " . __LINE__ . " pathsep X${pathsep}X\n" if {$HBI_imagepop_Debug} ; warn "debug image.pl Line " . __LINE__ . " testgraphic X${testgraphic}X\n" if {$HBI_imagepop_Debug} ; # &show_illegal_access_warning ; &show_illegal_access_warning unless ($FORM{'tid'}) ; unless ($FORM{'tid'}) { warn "ERROR: Missing tid value." ; &show_illegal_access_warning ; } unless (&get_session($FORM{'tid'})) { warn "ERROR: Missing SESSION for tid value $FORM{'tid'}." ; &show_illegal_access_warning ; } my $ImageFile = $FORM{'img'} ; if ($ImageFile =~ /pdf$/i ) { # Deal with PDF file. $imgfile = join($pathsep, $testgraphic, $FORM{'img'}); warn "debug image.pl Line " . __LINE__ . " imgfile X${imgfile}X\n" if {$HBI_imagepop_Debug} ; @filesegs = split(/\./, $FORM{'img'}); $fext = $filesegs[$#filesegs]; $contentType = $CONTENT_TYPES{$fext} ; warn "debug image.pl Line " . __LINE__ . " fext X${fext}X contentType X${contentType}X\n" if {$HBI_imagepop_Debug} ; print "Content-Type: ${contentType}\n\n"; open (IMGFILE, "<$imgfile"); binmode(IMGFILE); $fsize = (stat(IMGFILE))[7]; warn "debug image.pl Line " . __LINE__ . " fsize X${fsize}X\n" if {$HBI_imagepop_Debug} ; read(IMGFILE, $img, $fsize); close IMGFILE; binmode(STDOUT); print $img; } else { # Deal with a normal image file: gif, etc. warn "debug image.pl Line " . __LINE__ . "\n" if {$HBI_imagepop_Debug} ; print "Content-Type: text/html\n\n"; if (&get_session($FORM{'tid'})) { print "
\n"; } } exit 0 ;