in reply to restricting public access to images

how can i use a CGI script to protect images from public access?

You have a couple of options: If you're using Apache, you can put HTML pages and the images they reference into a directory that you've set up to require basic authorization.

Or, you could use a CGI that checks for a cookie (that only your authorized users gets). If the right cookie is present, the CGI prints the correct response header, and then opens the image (which resides in some sekret location) and prints it. (If you're on win32, be sure to do binmode(STDOUT) first.)

Replies are listed 'Best First'.
Re: Re: restricting public access to images
by submersible_toaster (Chaplain) on Oct 08, 2002 at 04:16 UTC
    I'd hope you'd look to your httpd first to handle this sort of access control. Apache's .htaccess files my fav way to keep people where they should be.
    AuthType Basic AuthName "Squid User Access Reports" AuthUserFile /usr/local/apache/conf/passwords <Limit GET POST> order deny,allow deny from none allow from all require valid-user </Limit>
    Which is sloppy in some ways , this could certainly be more secure, giving your cgi carte-blanche to send users hither and thither IMHO is pleading for trouble. Doing this kind of ACL on an image by image basis ... would be pretty tricky though. Other things I've seen done , serialize your imagenames to death when they're created - so folks aren't able to guess them. Getting off topic now. bad karma. --shout down now!