Interactive Site listing CGI

Jan Schenkel janschenkel at yahoo.com
Mon Feb 7 15:10:51 EST 2005


--- Peter Reid <preid at reidit.co.uk> wrote:
> Does anyone have a bit of Rev CGI that will display
> a folder/file 
> list of a specified web site that allows the user to
> traverse the 
> filing system?
> 
> I'd like to produce a simple intranet site that
> stores a collection 
> of folders containing images that the end user can
> traverse and view 
> as and when required.  This will be on a Mac running
> OS X 10.3.7.
> 
> Thanks
> 
> Peter
> 

Hi Peter,

I think this is a case where one can transplant
regular Transcript into the rev-cgi arena. From a
recent post :
<http://lists.runrev.com/pipermail/use-revolution/2005-February/050789.html>

Of course in that script you can skip the folders, if
you're not looking to make available the files in the
subfolders.

So you'll end up with something like :
--
on startUp

  ## STEP 1 :: read the arguments
  # read the query string passed from the webserver
  put $QUERY_STRING into tQueryStringA
  # turn it into an array for convenient access
  split tQueryStringA using "&" and "="
  # make sure to URLDecode the arguments
  put the keys of tQueryStringA into tArgNames
  repeat for each line tArgName in tArgNames
    put URLDecode(tQueryStringA[tArgName]) \
        into tArgumentsA[URLDecode(tArgName]
  end repeat

  ## STEP 2 :: read the files
  # now that we have our arguments, move on to the dir
  set the defaultDirectory to <tRootDir> & \
      tArgumentsA["directory"]
  # read all the files in the chosen directory
  put the files into tFiles

  ## STEP 3 :: build the file list as an HTML page
  # you will want to change the formatting
  put "<html><head>" into tBuffer
  put "<title>Directory Contents</title>" after \
      tBuffer
  put "</head><body>" after tBuffer
  put "<h1>Directory Contents :" && \
      tArgumentsA["directory"] after tBuffer
  put "</h1><hr />" after tBuffer
  # loop over the files
  repeat for each line tFile in tFiles
    put "<a href=" & quote & \
        URLEncode(tArgumentsA["directory"]) & "/" & \
        URLEncode(tFile) & quote & ">" after tBuffer
    put tFile & "</a><br />" after tBuffer
  end repeat
  put "<hr /></body></html>" after tBuffer
  
  ## STEP 4 :: send the result to the webserver
  # start with the headers
  put "Content-Type: text/html" & cr
  put "Content-Length: && the length of tBuffer
  put cr & cr & tBuffer

  # end of the cgi-script
end startUp
--

Hope this gets you closer to your solution,

Jan Schenkel.

=====
Quartam - Tools for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250


More information about the use-livecode mailing list