protecting images in rev-cgi generated html

Nicolas Cueto niconiko at gmail.com
Tue Jan 29 05:54:37 EST 2008


Greetings The List,

For a while, I've been relying on a rev-cgi script
that generates an html table representing a 5x5
picture-bingo card. The rev script embeds the
25 images as urls in the html code. A snippet
of the code is below.

However, from a browser people could easily
peek at  the code and then link to the images
on their own webpage via their url.

My solution for now is to use an .htaccess file
that prohibits such hotlinking. But, obviously, it's
still possible to access any one of the images by
simply entering  its url directly into a browser.

Anyway. While looking for a solution, I came upon
this interesting comment on a php/apache forum:


  "A better solution would be to use a server-side
  scripted approach, where the user sees a single
  script-generated page, which then includes images
  by calling them by *filename* on the server, not
  by URL. These images need not even have a URL,
  and would be accessible only by the script."


When I read the words "server-side script" and
"script-generated page", it struck me as very similar
to what I'm doing now with rev-as-cgi. But, what
I'm stumped at is the "calling them by *filename*" bit.

Is it possible to deliver such a thing in html form with
a rev-based server-side cgi script? I sure hope so!
And, if indeed it is possible, would someone care
to write out some suggestions as to how to do it?

As always, thank you for your patience, especially
if I'm asking for the moon here.

Cheers,

Nicolas Cueto

<< START of my code snippet >>

#!revolution
on startup
put "http://mywebsite.com/images/bingo/" into tImageDirectory
put "1.gif" into tChoose[1]
put "2.gif" into tChoose[2]
put "3.gif" into line tChoose[3]
... put "25.gif" into line tChoose[25]
put empty into tHTMLtable
put 1 into i
repeat
  if i = 26 then exit repeat
  repeat with r = 1 to 5 -- set a new row every 5th column
      put line i of tShuffledImages into tGifImage
      put "<td>" & cr & "<div align=" & quote & "center" & quote & \
       "><img src=" & quote & tChoose[i] & tGifImage & quote & \
       " width=" & quote & "110" & quote & " height=" & quote & "110"
& quote & \
       "></div>" & cr & "</td>" & cr after tHTMLtable
      put (i + 1) into i
  end repeat
  put "</tr>" & cr & "<tr>" & cr after tHTMLtable
end repeat
-- generate the result in the form
-- of an html page
put url "file:./html_templates/BingoTophalf.htm" into tPage
put cr & tHTMLtable  & cr after tPage
put url "file:./html_templates/BingoBottomhalf.htm" after tPage
put tPage into buffer
--  write out the minimal set of HTTP protocol headers (to stdout)
put "Content-Type: text/html" & crlf
put "Content-Length:" && the length of buffer & crlf & crlf
put buffer
end startup

<< END of my code snippet >>




More information about the use-livecode mailing list