home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / SHOWDIR.CMD < prev    next >
OS/2 REXX Batch file  |  1998-04-12  |  4KB  |  105 lines

  1. /* SRE-http front end to tim tassonis's showdir */
  2.  
  3. show_dir:
  4. parse arg  ddir, tempfile, reqstrg,list,verb ,uri,user, ,
  5.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  6.          servername,host_nickname,homedir
  7. parse var list sel1 '?' .
  8.  
  9.  
  10. if verb="" then do
  11.     Say " This SRE-http add-on is NOT meant to be run from the command line! "
  12.     Say "(see SHOWDIR.DOC for details)"
  13.     exit
  14. end  /* Do */
  15.  
  16. showdirp='showdir.rxx'
  17.  
  18. file=sref_do_virtual(ddir,sel1,enmadd,0,transaction,homedir,host_nickname)
  19. /* get info from htaccess file (relative to sel1) */
  20.   htfile=get_value('HTACCESS_FILE')
  21.   if htfile=0 then do
  22.      dir.build=1;dir.exclude='';dir.info=''; dir.describe=''
  23.      dir.forbid=0
  24.   end  /* Do */
  25.   else do
  26.      tmp1=sref_htaccess(0,file,htfile,0,0,0,0,0,0,0,1)   /* parse out usefull stuff */
  27.      parse var tmp1 dir.build ',' DIR.exclude ',' dir.info  ,
  28.                            ',' dir.describe ',' dir.forbid ',' ashow
  29.      if strip(aSHOW)\=' ' then SHOWDIRp=ASHOW
  30.      dir.describe=strip(dir.describe); dir.info=strip(dir.info)
  31.      dir.exclude=strip(dir.exclude)
  32.   end
  33.   
  34.   if strip(dir.build)=0 | strip(dir.forbid)=1 then do
  35.         response('forbid','is denied.')
  36.         return ' Forbidden directory '
  37.   end
  38.    sel1=strip(sel1,'l','/')
  39.    interpret "message = "showdirp"(filespec('drive',file)||filespec('path',file), sel1, Dir.Describe, Dir.Info, Dir.Exclude)"
  40.    foo=sref_var('VAR TYPE text/html BINARY NAME message')
  41.  
  42. return ' Directory displayed '
  43.  
  44.  
  45. /* ----------- */                                                        
  46. /* get environment value, possibly host specific */                      
  47. /* ------------ */                                                       
  48. get_value: procedure expose enmadd host_nickname                          
  49. parse arg vname,hname0
  50. if hname0=0 then 
  51.         hname=' '
  52. else                                                    
  53.     hname=strip(host_nickname)                          
  54.  
  55. vname=strip(vname) ;
  56. if hname<>' ' then do
  57.    booger=strip(enmadd||vname||'.'||hname)
  58.    aval=value(booger,,'os2environment')
  59.    if aval<>' ' Then                                                     
  60.         return aval                                                      
  61. end                                                                      
  62. aval=value(enmadd||vname,,'os2environment')                              
  63. return aval                                                              
  64.  
  65.  
  66.  
  67. /* ----------------------------------------------------------------------- */
  68. /* RESPONSE: Standard [mostly error] responses.                            */
  69. /* ----------------------------------------------------------------------- */
  70. /* This routine should stay in the main filter program.                    */
  71. /* Arguments are: response type and extended message information.          */
  72. /* It returns the GoServe command to handle the result file.               */
  73. response: procedure expose tempfile  reqstrg   servername
  74.   parse arg request, message
  75.   select
  76.     when request='badreq'   then use='400 Bad request syntax'
  77.     when request='notfound' then use='404 Not found'
  78.     when request='forbid'   then use='403 Forbidden'
  79.     when request='unauth'   then use='401 Unauthorized'
  80.     when request='notallowed' then use='405 Method not allowed'
  81.     when request='notimplemented' then use='501 Not implemented'
  82.     otherwise do
  83.         use='406 Not acceptable'
  84.         ss=sref_error('weird response '|| request||' '|| message,1)
  85.       end
  86.     end  /* Add others to this list as needed */
  87.  
  88.  
  89.   /* Now set the response and build the response file */
  90.   'RESPONSE HTTP/1.0' use     /* Set HTTP response line */
  91.   parse var use code text
  92.   call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  93.   call lineout tempfile, "<html><head><title>"text"</title></head>"
  94.   call lineout tempfile, "<body><h2>Sorry...</h2>"
  95.   call lineout tempfile, "<p>The request from your Web client: " message"."
  96.   call lineout tempfile, "<hr><em>HTTP response code:</em>" code '['text']'
  97.   call lineout tempfile, "<br><em>From web server at:</em>" servername
  98.   call lineout tempfile, "<br><em>Running:</em>" server()
  99.   call lineout tempfile, "</body></html>"
  100.   call lineout tempfile  /* close */
  101.   foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  102.   return foo
  103.  
  104.  
  105.