#!/usr/bin/perl # hides the absolute location of images, and only displays when # called locally. # must be called from the same server, with link of the form # image.cgi?id=x where x is the image name. use CGI qw/:cgi-lib/; $IMAGE_DIR = "../images"; $query = new CGI; $id = $query->param ("id") || 0; # check to see if same server if ($ENV{'HTTP_REFERER'} =~ /$ENV{'SERVER_NAME'}/) { print "Content-type: image/jpg\n\n"; if (open(IMAGEFILE,"$IMAGE_DIR/$id.jpg")) { while( ) { print; } close(IMAGEFILE); } else { open(IMAGEFILE,"$IMAGE_DIR/not_found.jpg") ; while( ) { print; } close(IMAGEFILE); } } else { # print your warning/error message print "Content-type: text/html\n\n"; print "

"; print $ENV{'SERVER_NAME'} . $ENV{'HTTP_REFERER'}; print ""; }