in reply to Find the thief: CGI & JPG & hidden info

This is an implementation of what was suggested in the nodes above:

#!/usr/bin/perl # filename: marker.pl use JPEG::Comment; use File::Slurp; use CGI; use strict; use warnings; my $images = '/path/to/images'; my $q = CGI->new; my $username = $q->remote_user; my $path_info = $q->path_info; my $filename = "$images/$path_info"; if (-e $filename) { my $image = read_file($filename); print $q->header('image/jpeg'); print jpegcomment($image, "Downloaded by $username"); } else { print $q->header( -status => '404' ); } exit;
This script should be called this way: <img src="/cgi-bin/marker.pl/image.jpg">. All the comments you have read apply to this solution; please note that you should check the obtained $filename to avoid possible problems; remember that served images should not be visible directly.

HTH, Valerio

Replies are listed 'Best First'.
Re: Re: Find the thief: CGI & JPG & hidden info
by diotalevi (Canon) on Feb 27, 2004 at 20:12 UTC
    You didn't binmode STDOUT before writing that file to it.
      Yes, he did; it just looked like this: use CGI;
        Really? I had no idea. I've never noticed that in the documentation before. Thanks!